answer
stringlengths 15
1.25M
|
|---|
#nullable disable
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Interactive;
using Microsoft.VisualStudio.InteractiveWindow;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.Interactive
{
[ExportInteractive(typeof(<API key>), ContentTypeNames.CSharpContentType)]
internal sealed class <API key> : <API key>, <API key>
{
private readonly <API key> <API key>;
private readonly <API key> <API key>;
[<API key>]
[Obsolete(MefConstruction.<API key>, error: true)]
public <API key>(
<API key> <API key>,
<API key> <API key>,
<API key> <API key>,
<API key> <API key>,
<API key> <API key>)
: base(<API key>, <API key>, <API key>)
{
<API key> = <API key>;
<API key> = <API key>;
}
protected override <API key> <API key> => <API key>;
protected override IInteractiveWindow <API key>(bool focus)
=> <API key>.Open(instanceId: 0, focus: focus).InteractiveWindow;
}
}
|
module.exports = {
getMeta: function(meta) {
var d = meta.metaDescription || meta.description || meta.Description;
if (d && d instanceof Array) {
d = d[0];
}
return {
description: d
}
}
};
|

Long Haul is a minimal jekyll theme built with COMPASS / SASS / SUSY and focuses on long form blog plosts. It is meant to used as a starting point for a jekyll blog/website.
If you really enjoy Long Haul and want to give me credit somewhere on the send or tweet out your experience with Long Haul and tag me [@brianmaierjr](https://twitter.com/brianmaier).
## Features
- Minimal, Type Focused Design
- Built with SASS + COMPASS
- Layout with SUSY Grid
- SVG Social Icons
- Responsive Nav Menu
- XML Feed for RSS Readers
- Contact Form via Formspree
- 5 Post Loop with excerpt on Home Page
- Previous / Next Post Navigation
- Estimated Reading Time for posts
- Stylish Drop Cap on posts
- A Better Type Scale for all devices
## Setup
1. [Install Jekyll](http://jekyllrb.com)
2. Fork the [Long Haul repo](http://github.com/brianmaierjr/long-haul)
3. Clone it
4. Install susy `gem install susy`
5. Install normalize `gem install normalize-scss`
6. Run Jekyll `jekyll serve -w`
7. Run `compass watch`
8. Customize!
## Site Settings
The main settings can be found inside the `_config.yml` file:
- **title:** title of your site
- **description:** description of your site
- **url:** your url
- **paginate:** the amount of posts displayed on homepage
- **navigation:** these are the links in the main site navigation
- **social** diverse social media usernames (optional)
- **google_analytics** Google Analytics key (optional)
This is [MIT](LICENSE) with no added caveats, so feel free to use this Jekyll theme on your site without linking back to me or using a disclaimer.
|
#ifndef _BMP_IO_H
#define _BMP_IO_H
#include <stdio.h>
#include "<API key>.h"
int <API key>(FILE *fp, bmp_file_t *ptrbmp);
void free_bmp(bmp_file_t *ptrbmp);
int output_bmp(FILE *fp, bmp_file_t *ptrbmp);
#endif
|
;(function($) {
// TODO rewrite as a widget, removing all the extra plugins
$.extend($.fn, {
swapClass: function(c1, c2) {
var c1Elements = this.filter('.' + c1);
this.filter('.' + c2).removeClass(c2).addClass(c1);
c1Elements.removeClass(c1).addClass(c2);
return this;
},
replaceClass: function(c1, c2) {
return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
},
hoverClass: function(className) {
className = className || "hover";
return this.hover(function() {
$(this).addClass(className);
}, function() {
$(this).removeClass(className);
});
},
heightToggle: function(animated, callback) {
animated ?
this.animate({ height: "toggle" }, animated, callback) :
this.each(function(){
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
if(callback)
callback.apply(this, arguments);
});
},
heightHide: function(animated, callback) {
if (animated) {
this.animate({ height: "hide" }, animated, callback);
} else {
this.hide();
if (callback)
this.each(callback);
}
},
prepareBranches: function(settings) {
if (!settings.prerendered) {
// mark last tree items
this.filter(":last-child:not(ul)").addClass(CLASSES.last);
// collapse whole tree, or only those marked as closed, anyway except those marked as open
this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
}
// return all items with sublists
return this.filter(":has(>ul)");
},
applyClasses: function(settings, toggler) {
// TODO use event delegation
this.filter(":has(>ul):not(:has(>a))").find(">span").unbind("click.treeview").bind("click.treeview", function(event) {
// don't handle click events on children, eg. checkboxes
if ( this == event.target )
toggler.apply($(this).next());
}).add( $("a", this) ).hoverClass();
if (!settings.prerendered) {
// handle closed ones first
this.filter(":has(>ul:hidden)")
.addClass(CLASSES.expandable)
.replaceClass(CLASSES.last, CLASSES.lastExpandable);
// handle open ones
this.not(":has(>ul:hidden)")
.addClass(CLASSES.collapsable)
.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
// create hitarea if not present
var hitarea = this.find("div." + CLASSES.hitarea);
if (!hitarea.length)
hitarea = this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea);
hitarea.removeClass().addClass(CLASSES.hitarea).each(function() {
var classes = "";
$.each($(this).parent().attr("class").split(" "), function() {
classes += this + "-hitarea ";
});
$(this).addClass( classes );
})
}
// apply event to hitarea
this.find("div." + CLASSES.hitarea).click( toggler );
},
treeview: function(settings) {
settings = $.extend({
cookieId: "treeview"
}, settings);
if ( settings.toggle ) {
var callback = settings.toggle;
settings.toggle = function() {
return callback.apply($(this).parent()[0], arguments);
};
}
// factory for treecontroller
function treeController(tree, control) {
// factory for click handlers
function handler(filter) {
return function() {
// reuse toggle event handler, applying the elements to toggle
// start searching for all hitareas
toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
// for plain toggle, no filter is provided, otherwise we need to check the parent element
return filter ? $(this).parent("." + filter).length : true;
}) );
return false;
};
}
// click on first element to collapse tree
$("a:eq(0)", control).click( handler(CLASSES.collapsable) );
// click on second to expand tree
$("a:eq(1)", control).click( handler(CLASSES.expandable) );
// click on third to toggle tree
$("a:eq(2)", control).click( handler() );
}
// handle toggle event
function toggler() {
$(this)
.parent()
// swap classes for hitarea
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.<API key>, CLASSES.<API key> )
.end()
// swap classes for parent li
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
// find child lists
.find( ">ul" )
// toggle them
.heightToggle( settings.animated, settings.toggle );
if ( settings.unique ) {
$(this).parent()
.siblings()
// swap classes for hitarea
.find(">.hitarea")
.replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.replaceClass( CLASSES.<API key>, CLASSES.<API key> )
.end()
.replaceClass( CLASSES.collapsable, CLASSES.expandable )
.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find( ">ul" )
.heightHide( settings.animated, settings.toggle );
}
}
this.data("toggler", toggler);
function serialize() {
function binary(arg) {
return arg ? 1 : 0;
}
var data = [];
branches.each(function(i, e) {
data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
});
$.cookie(settings.cookieId, data.join(""), settings.cookieOptions );
}
function deserialize() {
var stored = $.cookie(settings.cookieId);
if ( stored ) {
var data = stored.split("");
branches.each(function(i, e) {
$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
});
}
}
// add treeview class to activate styles
this.addClass("treeview");
// prepare branches and find all tree items with child lists
var branches = this.find("li").prepareBranches(settings);
switch(settings.persist) {
case "cookie":
var toggleCallback = settings.toggle;
settings.toggle = function() {
serialize();
if (toggleCallback) {
toggleCallback.apply(this, arguments);
}
};
deserialize();
break;
case "location":
var current = this.find("a").filter(function() {
return this.href.toLowerCase() == location.href.toLowerCase();
});
if ( current.length ) {
// TODO update the open/closed classes
var items = current.addClass("selected").parents("ul, li").add( current.next() ).show();
if (settings.prerendered) {
// if prerendered is on, replicate the basic class swapping
items.filter("li")
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.<API key>, CLASSES.<API key> );
}
}
break;
}
branches.applyClasses(settings, toggler);
// if control option is set, create the treecontroller and show it
if ( settings.control ) {
treeController(this, settings.control);
$(settings.control).show();
}
return this;
}
});
// classes used by the plugin
// need to be styled via external stylesheet, see first example
$.treeview = {};
var CLASSES = ($.treeview.classes = {
open: "open",
closed: "closed",
expandable: "expandable",
expandableHitarea: "expandable-hitarea",
<API key>: "<API key>",
collapsable: "collapsable",
collapsableHitarea: "collapsable-hitarea",
<API key>: "<API key>",
lastCollapsable: "lastCollapsable",
lastExpandable: "lastExpandable",
last: "last",
hitarea: "hitarea"
});
})(jQuery);
|
<?php
namespace PhpFlo\Fbp\Loader\Tests;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamFile;
use PhpFlo\Common\Exception\LoaderException;
use PhpFlo\Fbp\Loader\Loader;
use PhpFlo\Fbp\Test\TestCase;
class LoaderTest extends TestCase
{
/**
* @var vfsStreamFile
*/
private $file;
/**
* @expectedException \PhpFlo\Common\Exception\LoaderException
*/
public function <API key>()
{
$data = Loader::load('test.yml');
}
public function testLoadYamlFile()
{
$yaml = <<<EOF
properties:
name: ''
initializers: { }
processes:
ReadFile:
component: ReadFile
metadata: { label: ReadFile }
SplitbyLines:
component: SplitStr
metadata: { label: SplitStr }
Display:
component: Output
metadata: { label: Output }
CountLines:
component: Counter
metadata: { label: Counter }
connections:
-
src: { process: ReadFile, port: OUT }
tgt: { process: SplitbyLines, port: IN }
-
src: { process: ReadFile, port: ERROR }
tgt: { process: Display, port: IN }
-
src: { process: SplitbyLines, port: OUT }
tgt: { process: CountLines, port: IN }
-
src: { process: CountLines, port: COUNT }
tgt: { process: Display, port: IN }
EOF;
$url = $this->createFile('test.yml', $yaml);
$definition = Loader::load($url);
$this->assertArrayHasKey('connections', $definition->toArray());
}
public function testLoadJsonFile()
{
$json = <<< EOF
{
"properties": {
"name": ""
},
"initializers": [],
"processes": {
"ReadFile": {
"component": "ReadFile",
"metadata": {
"label": "ReadFile"
}
},
"SplitbyLines": {
"component": "SplitStr",
"metadata": {
"label": "SplitStr"
}
},
"Display": {
"component": "Output",
"metadata": {
"label": "Output"
}
},
"CountLines": {
"component": "Counter",
"metadata": {
"label": "Counter"
}
}
},
"connections": [
{
"src": {
"process": "ReadFile",
"port": "OUT"
},
"tgt": {
"process": "SplitbyLines",
"port": "IN"
}
},
{
"src": {
"process": "ReadFile",
"port": "ERROR"
},
"tgt": {
"process": "Display",
"port": "IN"
}
},
{
"src": {
"process": "SplitbyLines",
"port": "OUT"
},
"tgt": {
"process": "CountLines",
"port": "IN"
}
},
{
"src": {
"process": "CountLines",
"port": "COUNT"
},
"tgt": {
"process": "Display",
"port": "IN"
}
}
]
}
EOF;
$url = $this->createFile('test.json', $json);
$definition = Loader::load($url);
$this->assertArrayHasKey('connections', $definition->toArray());
}
public function testLoadFbpFile()
{
$fbp = <<<EOF
ReadFile(ReadFile) OUT -> IN SplitbyLines(SplitStr)
ReadFile(ReadFile) ERROR -> IN Display(Output)
SplitbyLines(SplitStr) OUT -> IN CountLines(Counter)
CountLines(Counter) COUNT -> IN Display(Output)
EOF;
$url = $this->createFile('test.fbp', $fbp);
$definition = Loader::load($url);
$this->assertArrayHasKey('connections', $definition->toArray());
}
/**
* @expectedException \PhpFlo\Common\Exception\LoaderException
*/
public function <API key>()
{
$uri = $this->createFile('test.fbp', '');
Loader::load($uri);
}
/**
* @expectedException \PhpFlo\Common\Exception\LoaderException
*/
public function <API key>()
{
Loader::load('my/file/test.xyz');
}
/**
* @expectedException \PhpFlo\Common\Exception\LoaderException
*/
public function <API key>()
{
Loader::load('test.fbp');
}
private function createFile($name, $content)
{
$root = vfsStream::setup();
$this->file = vfsStream::newFile($name)->at($root);
$this->file->setContent($content);
return $this->file->url();
}
}
|
!((document, $) => {
var clip = new Clipboard('.copy-button');
clip.on('success', function(e) {
$('.copied').show();
$('.copied').fadeOut(2000);
});
})(document, jQuery);
|
.yui-h-slider, .yui-v-slider {
position: relative;
}
.yui-h-slider .yui-slider-thumb, .yui-v-slider .yui-slider-thumb {
position: absolute;
cursor: default;
}
.yui-skin-sam .yui-h-slider {
background: url(bg-h.gif) no-repeat 5px 0;
height: 28px;
width: 228px;
}
.yui-skin-sam .yui-h-slider .yui-slider-thumb {
top: 4px;
}
.yui-skin-sam .yui-v-slider {
background: url(bg-v.gif) no-repeat 12px 0;
height: 228px;
width: 48px;
}
.cke_uicolor_picker .yui-picker-panel {
background: #e3e3e3;
border-color: #888;
}
.cke_uicolor_picker .yui-picker-panel .hd {
background-color: #ccc;
font-size: 100%;
line-height: 100%;
border: 1px solid #e3e3e3;
font-weight: bold;
overflow: hidden;
padding: 6px;
color: #000;
}
.cke_uicolor_picker .yui-picker-panel .bd {
background: #e8e8e8;
margin: 1px;
height: 200px;
}
.cke_uicolor_picker .yui-picker-panel .ft {
background: #e8e8e8;
margin: 1px;
padding: 1px;
}
.cke_uicolor_picker .yui-picker {
position: relative;
}
.cke_uicolor_picker .<API key> {
cursor: default;
width: 18px;
height: 18px;
top: -8px;
left: -2px;
z-index: 9;
position: absolute;
}
.cke_uicolor_picker .yui-picker-hue-bg {
-moz-outline: none;
outline: 0 none;
position: absolute;
left: 200px;
height: 183px;
width: 14px;
background: url(hue_bg.png) no-repeat;
top: 4px;
}
.cke_uicolor_picker .yui-picker-bg {
-moz-outline: none;
outline: 0 none;
position: absolute;
top: 4px;
left: 4px;
height: 182px;
width: 182px;
background-color: #F00;
background-image: url(picker_mask.png);
}
*html .cke_uicolor_picker .yui-picker-bg {
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src = 'picker_mask.png', sizingMethod = 'scale');
}
.cke_uicolor_picker .yui-picker-mask {
position: absolute;
z-index: 1;
top: 0;
left: 0;
}
.cke_uicolor_picker .yui-picker-thumb {
cursor: default;
width: 11px;
height: 11px;
z-index: 9;
position: absolute;
top: -4px;
left: -4px;
}
.cke_uicolor_picker .yui-picker-swatch {
position: absolute;
left: 240px;
top: 4px;
height: 60px;
width: 55px;
border: 1px solid #888;
}
.cke_uicolor_picker .<API key> {
position: absolute;
left: 304px;
top: 4px;
height: 24px;
width: 24px;
border: 1px solid #888;
}
.cke_uicolor_picker .yui-picker-controls {
position: absolute;
top: 72px;
left: 226px;
font: 1em monospace;
}
.cke_uicolor_picker .yui-picker-controls .hd {
background: transparent;
border-width: 0 !important;
}
.cke_uicolor_picker .yui-picker-controls .bd {
height: 100px;
border-width: 0 !important;
}
.cke_uicolor_picker .yui-picker-controls ul {
float: left;
padding: 0 2px 0 0;
margin: 0;
}
.cke_uicolor_picker .yui-picker-controls li {
padding: 2px;
list-style: none;
margin: 0;
}
.cke_uicolor_picker .yui-picker-controls input {
font-size: .85em;
width: 2.4em;
}
.cke_uicolor_picker .<API key> {
clear: both;
padding: 2px;
}
.cke_uicolor_picker .<API key> input {
width: 4.6em;
}
.cke_uicolor_picker .yui-picker-controls a {
font: 1em arial, helvetica, clean, sans-serif;
display: block;
*display: inline-block;
padding: 0;
color: #000;
}
|
<!DOCTYPE html>
<html>
<head>
<title>Centering grid content</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<meta name="description" content="Centering grid content" />
<meta name="keywords" content="javascript, dynamic, grid, layout, jquery plugin, flex layouts"/>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../freewall.js"></script>
<script type="text/javascript" src="../plugin/centering.js"></script>
<style type="text/css">
.free-wall {
margin: 15px;
}
</style>
</head>
<body>
<div class='header'>
<div class="clearfix">
<div class="float-left">
<h1><a href="http://vnjs.net/www/project/freewall/">Free Wall</a></h1>
<div class='target'>Creating dynamic grid layouts.</div>
</div>
</div>
</div>
<div id="freewall" class="free-wall">
<div class="brick size32">
<div class='cover'>
<h2>Centering grid content</h2>
</div>
</div>
<div class="brick size12 add-more">
<div class='cover'>
<h2>Add more block</h2>
</div>
</div>
</div>
<script type="text/javascript">
var colour = [
"rgb(142, 68, 173)",
"rgb(243, 156, 18)",
"rgb(211, 84, 0)",
"rgb(0, 106, 63)",
"rgb(41, 128, 185)",
"rgb(192, 57, 43)",
"rgb(135, 0, 0)",
"rgb(39, 174, 96)"
];
$(".brick").each(function() {
this.style.backgroundColor = colour[colour.length * Math.random() << 0];
});
$(function() {
var wall = new Freewall("#freewall");
wall.reset({
selector: '.brick',
animate: true,
cellW: 160,
cellH: 160,
delay: 50,
onResize: function() {
wall.fitWidth();
}
});
wall.fitWidth();
var temp = '<div class="brick {size}" style="background-color: {color}"><div class="cover"></div></div>';
var size = "size23 size22 size21 size13 size12 size11".split(" ");
$(".add-more").click(function() {
var html = temp.replace('{size}', size[size.length * Math.random() << 0])
.replace('{color}', colour[colour.length * Math.random() << 0]);
wall.prepend(html);
});
});
</script>
</body>
</html>
|
var binary = require('node-pre-gyp');
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json')));
var binding = require(binding_path);
var Stream = require('stream').Stream,
inherits = require('util').inherits;
function Snapshot() {}
Snapshot.prototype.getHeader = function() {
return {
typeId: this.typeId,
uid: this.uid,
title: this.title
}
}
/**
* @param {Snapshot} other
* @returns {Object}
*/
Snapshot.prototype.compare = function(other) {
var selfHist = nodesHist(this),
otherHist = nodesHist(other),
keys = Object.keys(selfHist).concat(Object.keys(otherHist)),
diff = {};
keys.forEach(function(key) {
if (key in diff) return;
var selfCount = selfHist[key] || 0,
otherCount = otherHist[key] || 0;
diff[key] = otherCount - selfCount;
});
return diff;
};
function ExportStream() {
Stream.Transform.call(this);
this._transform = function noTransform(chunk, encoding, done) {
done(null, chunk);
}
}
inherits(ExportStream, Stream.Transform);
/**
* @param {Stream.Writable|function} dataReceiver
* @returns {Stream|undefined}
*/
Snapshot.prototype.export = function(dataReceiver) {
dataReceiver = dataReceiver || new ExportStream();
var toStream = dataReceiver instanceof Stream,
chunks = toStream ? null : [];
function onChunk(chunk, len) {
if (toStream) dataReceiver.write(chunk);
else chunks.push(chunk);
}
function onDone() {
if (toStream) dataReceiver.end();
else dataReceiver(null, chunks.join(''));
}
this.serialize(onChunk, onDone);
return toStream ? dataReceiver : undefined;
};
function nodes(snapshot) {
var n = snapshot.nodesCount, i, nodes = [];
for (i = 0; i < n; i++) {
nodes[i] = snapshot.getNode(i);
}
return nodes;
};
function nodesHist(snapshot) {
var objects = {};
nodes(snapshot).forEach(function(node){
var key = node.type === "Object" ? node.name : node.type;
objects[key] = objects[node.name] || 0;
objects[key]++;
});
return objects;
};
function CpuProfile() {}
CpuProfile.prototype.getHeader = function() {
return {
typeId: this.typeId,
uid: this.uid,
title: this.title
}
}
CpuProfile.prototype.export = function(dataReceiver) {
dataReceiver = dataReceiver || new ExportStream();
var toStream = dataReceiver instanceof Stream;
var error, result;
try {
result = JSON.stringify(this);
} catch (err) {
error = err;
}
process.nextTick(function() {
if (toStream) {
if (error) {
dataReceiver.emit('error', error);
}
dataReceiver.end(result);
} else {
dataReceiver(error, result);
}
});
return toStream ? dataReceiver : undefined;
};
var startTime, endTime;
var activeProfiles = [];
var profiler = {
/*HEAP PROFILER API*/
get snapshots() { return binding.heap.snapshots; },
takeSnapshot: function(name, control) {
var snapshot = binding.heap.takeSnapshot.apply(null, arguments);
snapshot.__proto__ = Snapshot.prototype;
snapshot.title = name;
return snapshot;
},
getSnapshot: function(index) {
var snapshot = binding.heap.snapshots[index];
if (!snapshot) return;
snapshot.__proto__ = Snapshot.prototype;
return snapshot;
},
findSnapshot: function(uid) {
var snapshot = binding.heap.snapshots.filter(function(snapshot) {
return snapshot.uid == uid;
})[0];
if (!snapshot) return;
snapshot.__proto__ = Snapshot.prototype;
return snapshot;
},
deleteAllSnapshots: function () {
binding.heap.snapshots.forEach(function(snapshot) {
snapshot.delete();
});
},
<API key>: binding.heap.<API key>,
<API key>: binding.heap.<API key>,
getHeapStats: binding.heap.getHeapStats,
<API key>: binding.heap.<API key>,
/*CPU PROFILER API*/
get profiles() { return binding.cpu.profiles; },
startProfiling: function(name, recsamples) {
if (activeProfiles.length == 0 && typeof process.<API key> == "function")
process.<API key>();
name = name || "";
if (activeProfiles.indexOf(name) < 0)
activeProfiles.push(name)
startTime = Date.now();
binding.cpu.startProfiling(name, recsamples);
},
stopProfiling: function(name) {
var index = activeProfiles.indexOf(name);
if (name && index < 0)
return;
var profile = binding.cpu.stopProfiling(name);
endTime = Date.now();
profile.__proto__ = CpuProfile.prototype;
if (!profile.startTime) profile.startTime = startTime;
if (!profile.endTime) profile.endTime = endTime;
if (name)
activeProfiles.splice(index, 1);
else
activeProfiles.length = activeProfiles.length - 1;
if (activeProfiles.length == 0 && typeof process.<API key> == "function")
process.<API key>();
return profile;
},
getProfile: function(index) {
return binding.cpu.profiles[index];
},
findProfile: function(uid) {
var profile = binding.cpu.profiles.filter(function(profile) {
return profile.uid == uid;
})[0];
return profile;
},
deleteAllProfiles: function() {
binding.cpu.profiles.forEach(function(profile) {
profile.delete();
});
}
};
module.exports = profiler;
process.profiler = profiler;
|
/**
* Server/client environment: argument handling, config file parsing,
* thread wrappers, startup time
*/
#ifndef <API key>
#define <API key>
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <attributes.h>
#include <compat.h>
#include <compat/assumptions.h>
#include <fs.h>
#include <logging.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/memory.h>
#include <util/threadnames.h>
#include <util/time.h>
#include <exception>
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted
// Application startup time (used for uptime calculation)
int64_t GetStartupTime();
extern const char * const <API key>;
void SetupEnvironment();
bool SetupNetworking();
template<typename... Args>
bool error(const char* fmt, const Args&... args)
{
LogPrintf("ERROR: %s\n", tfm::format(fmt, args...));
return false;
}
void <API key>(const std::exception *pex, const char* pszThread);
bool FileCommit(FILE *file);
bool TruncateFile(FILE *file, unsigned int length);
int <API key>(int nMinFD);
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
bool RenameOver(fs::path src, fs::path dest);
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false);
void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name);
bool DirIsWritable(const fs::path& directory);
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
/** Release all directory locks. This is used for unit testing only, at runtime
* the global destructor will take care of the locks.
*/
void <API key>();
bool <API key>(const fs::path& p);
fs::path GetDefaultDataDir();
// The blocks directory is always net specific.
const fs::path &GetBlocksDir();
const fs::path &GetDataDir(bool fNetSpecific = true);
// Return true if -datadir option points to a valid directory or is not specified.
bool CheckDataDirOption();
/** Tests only */
void ClearDatadirCache();
fs::path GetConfigFile(const std::string& confPath);
#ifdef WIN32
fs::path <API key>(int nFolder, bool fCreate = true);
#endif
#if HAVE_SYSTEM
void runCommand(const std::string& strCommand);
#endif
/**
* Most paths passed as configuration arguments are treated as relative to
* the datadir if they are not absolute.
*
* @param path The path to be conditionally prefixed with datadir.
* @param net_specific Forwarded to GetDataDir().
* @return The normalized path.
*/
fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific = true);
inline bool IsSwitchChar(char c)
{
#ifdef WIN32
return c == '-' || c == '/';
#else
return c == '-';
#endif
}
enum class OptionsCategory {
OPTIONS,
CONNECTION,
WALLET,
WALLET_DEBUG_TEST,
ZMQ,
DEBUG_TEST,
CHAINPARAMS,
NODE_RELAY,
BLOCK_CREATION,
RPC,
GUI,
COMMANDS,
REGISTER_COMMANDS,
HIDDEN // Always the last option to avoid printing these in the help
};
struct SectionInfo
{
std::string m_name;
std::string m_file;
int m_line;
};
class ArgsManager
{
public:
enum Flags {
NONE = 0x00,
// Boolean options can accept negation syntax -noOPTION or -noOPTION=1
ALLOW_BOOL = 0x01,
ALLOW_INT = 0x02,
ALLOW_STRING = 0x04,
ALLOW_ANY = ALLOW_BOOL | ALLOW_INT | ALLOW_STRING,
DEBUG_ONLY = 0x100,
/* Some options would cause cross-contamination if values for
* mainnet were used while running on regtest/testnet (or vice-versa).
* Setting them as NETWORK_ONLY ensures that sharing a config file
* between mainnet and regtest/testnet won't cause problems due to these
* parameters by accident. */
NETWORK_ONLY = 0x200,
};
protected:
friend class ArgsManagerHelper;
struct Arg
{
std::string m_help_param;
std::string m_help_text;
unsigned int m_flags;
};
mutable CCriticalSection cs_args;
std::map<std::string, std::vector<std::string>> m_override_args GUARDED_BY(cs_args);
std::map<std::string, std::vector<std::string>> m_config_args GUARDED_BY(cs_args);
std::string m_network GUARDED_BY(cs_args);
std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
NODISCARD bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
public:
ArgsManager();
/**
* Select the network in use
*/
void SelectConfigNetwork(const std::string& network);
NODISCARD bool ParseParameters(int argc, const char* const argv[], std::string& error);
NODISCARD bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
/**
* Log warnings for options in m_section_only_args when
* they are specified in the default section but not overridden
* on the command line or in a network-specific section in the
* config file.
*/
const std::set<std::string> <API key>() const;
/**
* Log warnings for unrecognized section names in the config file.
*/
const std::list<SectionInfo> <API key>() const;
/**
* Return a vector of strings of the given argument
*
* @param strArg Argument to get (e.g. "-foo")
* @return command-line arguments
*/
std::vector<std::string> GetArgs(const std::string& strArg) const;
/**
* Return true if the given argument has been manually set
*
* @param strArg Argument to get (e.g. "-foo")
* @return true if the argument has been set
*/
bool IsArgSet(const std::string& strArg) const;
/**
* Return true if the argument was originally passed as a negated option,
* i.e. -nofoo.
*
* @param strArg Argument to get (e.g. "-foo")
* @return true if the argument was passed negated
*/
bool IsArgNegated(const std::string& strArg) const;
/**
* Return string argument or default value
*
* @param strArg Argument to get (e.g. "-foo")
* @param strDefault (e.g. "1")
* @return command-line argument or default value
*/
std::string GetArg(const std::string& strArg, const std::string& strDefault) const;
/**
* Return integer argument or default value
*
* @param strArg Argument to get (e.g. "-foo")
* @param nDefault (e.g. 1)
* @return command-line argument (0 if invalid number) or default value
*/
int64_t GetArg(const std::string& strArg, int64_t nDefault) const;
/**
* Return boolean argument or default value
*
* @param strArg Argument to get (e.g. "-foo")
* @param fDefault (true or false)
* @return command-line argument or default value
*/
bool GetBoolArg(const std::string& strArg, bool fDefault) const;
/**
* Set an argument if it doesn't already have a value
*
* @param strArg Argument to set (e.g. "-foo")
* @param strValue Value (e.g. "1")
* @return true if argument gets set, false if it already had a value
*/
bool SoftSetArg(const std::string& strArg, const std::string& strValue);
/**
* Set a boolean argument if it doesn't already have a value
*
* @param strArg Argument to set (e.g. "-foo")
* @param fValue Value (e.g. false)
* @return true if argument gets set, false if it already had a value
*/
bool SoftSetBoolArg(const std::string& strArg, bool fValue);
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
// been set. Also called directly in testing.
void ForceSetArg(const std::string& strArg, const std::string& strValue);
/**
* Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
* @return CBaseChainParams::MAIN by default; raises runtime error if an invalid combination is given.
*/
std::string GetChainName() const;
/**
* Add argument
*/
void AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat);
/**
* Add many hidden arguments
*/
void AddHiddenArgs(const std::vector<std::string>& args);
/**
* Clear available arguments
*/
void ClearArgs() {
LOCK(cs_args);
m_available_args.clear();
m_network_only_args.clear();
}
/**
* Get the help string
*/
std::string GetHelpMessage() const;
/**
* Return Flags for known arg.
* Return ArgsManager::NONE for unknown arg.
*/
unsigned int FlagsOfKnownArg(const std::string& key) const;
};
extern ArgsManager gArgs;
/**
* @return true if help has been requested via a command-line arg
*/
bool HelpRequested(const ArgsManager& args);
/** Add help options to the args manager */
void SetupHelpOptions(ArgsManager& args);
/**
* Format a string to be used as group of options in help messages
*
* @param message Group name (e.g. "RPC server options:")
* @return the formatted string
*/
std::string HelpMessageGroup(const std::string& message);
/**
* Format a string to be used as option description in help messages
*
* @param option Option message (e.g. "-rpcuser=<user>")
* @param message Option description (e.g. "Username for JSON-RPC connections")
* @return the formatted string
*/
std::string HelpMessageOpt(const std::string& option, const std::string& message);
/**
* Return the number of cores available on the current system.
* @note This does count virtual cores, such as those provided by HyperThreading.
*/
int GetNumCores();
/**
* .. and a wrapper that just calls func once
*/
template <typename Callable> void TraceThread(const char* name, Callable func)
{
util::ThreadRename(name);
try
{
LogPrintf("%s thread start\n", name);
func();
LogPrintf("%s thread exit\n", name);
}
catch (const boost::thread_interrupted&)
{
LogPrintf("%s thread interrupt\n", name);
throw;
}
catch (const std::exception& e) {
<API key>(&e, name);
throw;
}
catch (...) {
<API key>(nullptr, name);
throw;
}
}
std::string CopyrightHolders(const std::string& strPrefix);
/**
* On platforms that support it, tell the kernel the calling thread is
* CPU-intensive and non-interactive. See SCHED_BATCH in sched(7) for details.
*
* @return The return value of sched_setschedule(), or 1 on systems without
* sched_setschedule().
*/
int <API key>();
namespace util {
//! Simplification of std insertion
template <typename Tdst, typename Tsrc>
inline void insert(Tdst& dst, const Tsrc& src) {
dst.insert(dst.begin(), src.begin(), src.end());
}
template <typename TsetT, typename Tsrc>
inline void insert(std::set<TsetT>& dst, const Tsrc& src) {
dst.insert(src.begin(), src.end());
}
#ifdef WIN32
class WinCmdLineArgs
{
public:
WinCmdLineArgs();
~WinCmdLineArgs();
std::pair<int, char**> get();
private:
int argc;
char** argv;
std::vector<std::string> args;
};
#endif
} // namespace util
#endif // <API key>
|
<?php
namespace Sonata\AdminBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* Class <API key>.
*
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*/
abstract class <API key> extends Extension
{
/**
* Fix template configuration.
*
* @param array $configs
* @param ContainerBuilder $container
* @param array $<API key>
*
* @return array
*/
protected function <API key>(array $configs, ContainerBuilder $container, array $<API key> = array())
{
$defaultConfig = array(
'templates' => array(
'types' => array(
'list' => array(
'array' => 'SonataAdminBundle:CRUD:list_array.html.twig',
'boolean' => 'SonataAdminBundle:CRUD:list_boolean.html.twig',
'date' => 'SonataAdminBundle:CRUD:list_date.html.twig',
'time' => 'SonataAdminBundle:CRUD:list_time.html.twig',
'datetime' => 'SonataAdminBundle:CRUD:list_datetime.html.twig',
'text' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'textarea' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'email' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'trans' => 'SonataAdminBundle:CRUD:list_trans.html.twig',
'string' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'smallint' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'bigint' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'integer' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'decimal' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'identifier' => 'SonataAdminBundle:CRUD:list_string.html.twig',
'currency' => 'SonataAdminBundle:CRUD:list_currency.html.twig',
'percent' => 'SonataAdminBundle:CRUD:list_percent.html.twig',
'choice' => 'SonataAdminBundle:CRUD:list_choice.html.twig',
'url' => 'SonataAdminBundle:CRUD:list_url.html.twig',
'html' => 'SonataAdminBundle:CRUD:list_html.html.twig',
),
'show' => array(
'array' => 'SonataAdminBundle:CRUD:show_array.html.twig',
'boolean' => 'SonataAdminBundle:CRUD:show_boolean.html.twig',
'date' => 'SonataAdminBundle:CRUD:show_date.html.twig',
'time' => 'SonataAdminBundle:CRUD:show_time.html.twig',
'datetime' => 'SonataAdminBundle:CRUD:show_datetime.html.twig',
'text' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'trans' => 'SonataAdminBundle:CRUD:show_trans.html.twig',
'string' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'smallint' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'bigint' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'integer' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'decimal' => 'SonataAdminBundle:CRUD:base_show_field.html.twig',
'currency' => 'SonataAdminBundle:CRUD:show_currency.html.twig',
'percent' => 'SonataAdminBundle:CRUD:show_percent.html.twig',
'choice' => 'SonataAdminBundle:CRUD:show_choice.html.twig',
'url' => 'SonataAdminBundle:CRUD:show_url.html.twig',
'html' => 'SonataAdminBundle:CRUD:show_html.html.twig',
),
),
),
);
// let's add some magic, only overwrite template if the SonataIntlBundle is enabled
$bundles = $container->getParameter('kernel.bundles');
if (isset($bundles['SonataIntlBundle'])) {
$defaultConfig['templates']['types']['list'] = array_merge($defaultConfig['templates']['types']['list'], array(
'date' => 'SonataIntlBundle:CRUD:list_date.html.twig',
'datetime' => 'SonataIntlBundle:CRUD:list_datetime.html.twig',
'smallint' => 'SonataIntlBundle:CRUD:list_decimal.html.twig',
'bigint' => 'SonataIntlBundle:CRUD:list_decimal.html.twig',
'integer' => 'SonataIntlBundle:CRUD:list_decimal.html.twig',
'decimal' => 'SonataIntlBundle:CRUD:list_decimal.html.twig',
'currency' => 'SonataIntlBundle:CRUD:list_currency.html.twig',
'percent' => 'SonataIntlBundle:CRUD:list_percent.html.twig',
));
$defaultConfig['templates']['types']['show'] = array_merge($defaultConfig['templates']['types']['show'], array(
'date' => 'SonataIntlBundle:CRUD:show_date.html.twig',
'datetime' => 'SonataIntlBundle:CRUD:show_datetime.html.twig',
'smallint' => 'SonataIntlBundle:CRUD:show_decimal.html.twig',
'bigint' => 'SonataIntlBundle:CRUD:show_decimal.html.twig',
'integer' => 'SonataIntlBundle:CRUD:show_decimal.html.twig',
'decimal' => 'SonataIntlBundle:CRUD:show_decimal.html.twig',
'currency' => 'SonataIntlBundle:CRUD:show_currency.html.twig',
'percent' => 'SonataIntlBundle:CRUD:show_percent.html.twig',
));
}
if (!empty($<API key>)) {
$defaultConfig = <API key>($defaultConfig, $<API key>);
}
array_unshift($configs, $defaultConfig);
return $configs;
}
}
|
<?php
namespace Druidfi;
class Envs
{
const ENV_DEVELOPMENT = 'development';
const ENV_TESTING = 'testing';
const ENV_STAGING = 'staging';
const ENV_PRODUCTION = 'production';
const ERROR_NOT_VALID = 'Error: env "%s" is not valid! Please use one of the following: %s';
/**
* Get error message for invalid env
*
* @param $env
*
* @return string
*/
public static function <API key>($env)
{
return sprintf(self::ERROR_NOT_VALID, $env, join(', ', self::getValidEnvs()));
}
/**
* Get list of valid environments
*
* @return array Valid environments
*/
public static function getValidEnvs()
{
return [
self::ENV_DEVELOPMENT,
self::ENV_TESTING,
self::ENV_STAGING,
self::ENV_PRODUCTION,
];
}
/**
* Check if given env is valid
*
* @param $env
*
* @return bool
*/
public static function isValidEnv($env)
{
return in_array($env, self::getValidEnvs());
}
}
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\Fuse.Reactive\0.18.8\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Behavior.h>
namespace g{namespace Fuse{namespace Reactive{struct Binding;}}}
namespace g{namespace Fuse{struct Node;}}
namespace g{
namespace Fuse{
namespace Reactive{
// public abstract class Binding :450
struct Binding_type : ::g::Fuse::Behavior_type
{
void(*fp_NewValue)(::g::Fuse::Reactive::Binding*, uObject*);
};
Binding_type* Binding_typeof();
void Binding__ctor_1_fn(Binding* __this, uString* key);
void Binding__get_Key_fn(Binding* __this, uString** __retval);
void Binding__set_Key_fn(Binding* __this, uString* value);
void <API key>(Binding* __this, ::g::Fuse::Node** __retval);
void <API key>(Binding* __this, ::g::Fuse::Node* n);
void <API key>(Binding* __this, ::g::Fuse::Node* n);
struct Binding : ::g::Fuse::Behavior
{
uStrong<uObject*> _pathSubscription;
uStrong<uString*> _Key;
void ctor_1(uString* key);
uString* Key();
void Key(uString* value);
void NewValue(uObject* obj) { (((Binding_type*)__type)->fp_NewValue)(this, obj); }
::g::Fuse::Node* Node();
};
}}} // ::g::Fuse::Reactive
|
from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))
|
A flexible wrapper for [gl-vao](http://github.com/mikolalysenko/gl-vao)
and [gl-buffer](http://github.com/mikolalysenko/gl-buffer) that you can use to
set up renderable WebGL geometries from a variety of different formats.
## Usage ##
[
Creates a new geometry attached to the WebGL canvas context `gl`.
geom.attr(name, values[, opt])
Define a new attribute value, for example using a simplicial complex:
javascript
var createGeometry = require('gl-geometry')
var bunny = require('bunny')
var geom = createGeometry(gl)
.attr('positions', bunny)
The following vertex formats are supported and will be normalized:
* Arrays of arrays, e.g. `[[0, 0, 0], [1, 0, 0], [1, 1, 0]]`.
* Flat arrays, e.g. `[0, 0, 0, 1, 0, 0, 1, 1, 0]`.
* [Typed arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays),
preferably a `Float32Array`.
* 1-dimensional [ndarrays](http://github.com/mikolalysenko/ndarray).
* [simplicial complexes](https://github.com/mikolalysenko/simplicial-complex),
i.e. an object with a `positions` array and a `cells` array. The former is
a list of unique vertices in the mesh (if you've used three.js, think
`THREE.Vector3`), and the latter is an index mapping these vertices to faces
(`THREE.Face3`) in the mesh. It looks something like this:
json
{
"positions": [
[0.0, 0.0, 0.0],
[1.5, 0.0, 0.0],
[1.5, 1.5, 0.0],
[0.0, 1.5, 0.0]
],
"cells": [
[0, 1, 2],
[1, 2, 3]
]
}
You can specify `opt.size` for the vertex size, defaults to 3.
geom.faces(values[, opt])
Pass a simplicial complex's `cells` property here in any of the above formats
to use it as your index when drawing the geometry. For example:
javascript
var createGeometry = require('gl-geometry')
var bunny = require('bunny')
bunny.normals = normals.vertexNormals(
bunny.cells
, bunny.positions
)
var geom = createGeometry(gl)
.attr('positions', bunny.positions)
.attr('normals', bunny.normals)
.faces(bunny.cells)
You can specify `opt.size` for the cell size, defaults to 3.
geom.bind([shader])
Binds the underlying [VAO](https:
be called before calling `geom.draw`. Optionally, you can pass in a
[gl-shader](http://github.com/gl-modules/gl-shader) or
[glslify](http://github.com/chrisdickinson/glslify) shader instance to
automatically set up your attribute locations for you.
geom.draw(mode, start, stop)
Draws the geometry to the screen using the currently bound shader.
Optionally, you can pass in the drawing mode, which should be one of the
following:
* `gl.POINTS`
* `gl.LINES`
* `gl.LINE_STRIP`
* `gl.LINE_LOOP`
* `gl.TRIANGLES`
* `gl.TRIANGLE_STRIP`
* `gl.TRIANGLE_FAN`
The default value is `gl.TRIANGLES`. You're also able to pass in a `start` and
`stop` range for the points you want to render, just the same as you would
with `gl.drawArrays` or `gl.drawElements`.
geom.unbind()
Unbinds the underlying VAO. This *must* be done when you're finished drawing,
unless you're binding to another gl-geometry or gl-vao instance.
geom.dispose()
Disposes the underlying element and array buffers, as well as the VAO.
## See Also
* [ArrayBuffer and Typed Arrays](https://www.khronos.org/registry/webgl/specs/1.0/#5.13)
* [The WebGL Context](https://www.khronos.org/registry/webgl/specs/1.0/#5.14)
* [simplicial-complex](http://github.com/mikolalysenko/simplicial-complex)
* [ndarray](http://github.com/mikolalysenko/ndarray)
* [gl-shader](http://github.com/mikolalysenko/gl-shader)
* [gl-buffer](http://github.com/mikolalysenko/gl-buffer)
* [gl-vao](http://github.com/mikolalysenko/gl-vao)
MIT. See [LICENSE.md](http:
|
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/><!-- using block title in layout.dt--><!-- using block ddox.defs in ddox.layout.dt--><!-- using block ddox.title in ddox.layout.dt-->
<title>Class FilePath</title>
<link rel="stylesheet" type="text/css" href="../../styles/ddox.css"/>
<link rel="stylesheet" href="../../prettify/prettify.css" type="text/css"/>
<script type="text/javascript" src="../../scripts/jquery.js"></script>
<script type="text/javascript" src="../../prettify/prettify.js"></script>
<script type="text/javascript" src="../../scripts/ddox.js"></script>
</head>
<body onload="prettyPrint(); setupDdox();">
<nav id="main-nav"><!-- using block navigation in layout.dt-->
<ul class="tree-view">
<li class="collapsed tree-view">
<a href="#" class="package">components</a>
<ul class="tree-view">
<li>
<a href="../../components/animation.html" class=" module">animation</a>
</li>
<li>
<a href="../../components/assetanimation.html" class=" module">assetanimation</a>
</li>
<li>
<a href="../../components/assets.html" class=" module">assets</a>
</li>
<li>
<a href="../../components/camera.html" class=" module">camera</a>
</li>
<li>
<a href="../../components/icomponent.html" class=" module">icomponent</a>
</li>
<li>
<a href="../../components/lights.html" class=" module">lights</a>
</li>
<li>
<a href="../../components/material.html" class=" module">material</a>
</li>
<li>
<a href="../../components/mesh.html" class=" module">mesh</a>
</li>
<li>
<a href="../../components/userinterface.html" class=" module">userinterface</a>
</li>
</ul>
</li>
<li class="collapsed tree-view">
<a href="#" class="package">core</a>
<ul class="tree-view">
<li>
<a href="../../core/dgame.html" class=" module">dgame</a>
</li>
<li>
<a href="../../core/gameobject.html" class=" module">gameobject</a>
</li>
<li>
<a href="../../core/<API key>.html" class=" module"><API key></a>
</li>
<li>
<a href="../../core/prefabs.html" class=" module">prefabs</a>
</li>
<li>
<a href="../../core/properties.html" class=" module">properties</a>
</li>
<li>
<a href="../../core/reflection.html" class=" module">reflection</a>
</li>
<li>
<a href="../../core/scene.html" class=" module">scene</a>
</li>
</ul>
</li>
<li class="collapsed tree-view">
<a href="#" class="package">graphics</a>
<ul class="tree-view">
<li class="collapsed tree-view">
<a href="#" class="package">adapters</a>
<ul class="tree-view">
<li>
<a href="../../graphics/adapters/adapter.html" class=" module">adapter</a>
</li>
<li>
<a href="../../graphics/adapters/linux.html" class=" module">linux</a>
</li>
<li>
<a href="../../graphics/adapters/mac.html" class=" module">mac</a>
</li>
<li>
<a href="../../graphics/adapters/win32.html" class=" module">win32</a>
</li>
</ul>
</li>
<li class="collapsed tree-view">
<a href="#" class="package">shaders</a>
<ul class="tree-view">
<li class="collapsed tree-view">
<a href="#" class="package">glsl</a>
<ul class="tree-view">
<li>
<a href="../../graphics/shaders/glsl/ambientlight.html" class=" module">ambientlight</a>
</li>
<li>
<a href="../../graphics/shaders/glsl/animatedgeometry.html" class=" module">animatedgeometry</a>
</li>
<li>
<a href="../../graphics/shaders/glsl/directionallight.html" class=" module">directionallight</a>
</li>
<li>
<a href="../../graphics/shaders/glsl/geometry.html" class=" module">geometry</a>
</li>
<li>
<a href="../../graphics/shaders/glsl/pointlight.html" class=" module">pointlight</a>
</li>
<li>
<a href="../../graphics/shaders/glsl/userinterface.html" class=" module">userinterface</a>
</li>
</ul>
</li>
<li>
<a href="../../graphics/shaders/glsl.html" class=" module">glsl</a>
</li>
<li>
<a href="../../graphics/shaders/shaders.html" class=" module">shaders</a>
</li>
</ul>
</li>
<li>
<a href="../../graphics/adapters.html" class=" module">adapters</a>
</li>
<li>
<a href="../../graphics/graphics.html" class=" module">graphics</a>
</li>
<li>
<a href="../../graphics/shaders.html" class=" module">shaders</a>
</li>
</ul>
</li>
<li class=" tree-view">
<a href="#" class="package">utility</a>
<ul class="tree-view">
<li>
<a href="../../utility/awesomium.html" class=" module">awesomium</a>
</li>
<li>
<a href="../../utility/concurrency.html" class=" module">concurrency</a>
</li>
<li>
<a href="../../utility/config.html" class=" module">config</a>
</li>
<li>
<a href="../../utility/filepath.html" class="selected module">filepath</a>
</li>
<li>
<a href="../../utility/input.html" class=" module">input</a>
</li>
<li>
<a href="../../utility/output.html" class=" module">output</a>
</li>
<li>
<a href="../../utility/string.html" class=" module">string</a>
</li>
<li>
<a href="../../utility/time.html" class=" module">time</a>
</li>
</ul>
</li>
<li>
<a href="../../components.html" class=" module">components</a>
</li>
<li>
<a href="../../core.html" class=" module">core</a>
</li>
<li>
<a href="../../graphics.html" class=" module">graphics</a>
</li>
<li>
<a href="../../utility.html" class=" module">utility</a>
</li>
</ul>
<noscript>
<p style="color: red">The search functionality needs JavaScript enabled</p>
</noscript>
<div id="symbolSearchPane" style="display: none">
<p>
<input id="symbolSearch" type="text" placeholder="Search for symbols" onchange="performSymbolSearch(24);" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
</p>
<ul id="symbolSearchResults" style="display: none"></ul>
<script type="application/javascript" src="../../symbols.js"></script>
<script type="application/javascript">
//<![CDATA[
var symbolSearchRootDir = "../../"; $('#symbolSearchPane').show();
</script>
</div>
</nav>
<div id="main-contents">
<h1>Class FilePath</h1><!-- using block body in layout.dt--><!-- using block ddox.description in ddox.layout.dt-->
<p> A class which stores default resource paths, and handles path manipulation.
</p>
<section>
</section>
<section>
<h2>Inherits from</h2>
<ul>
<li>
<code class="prettyprint lang-d"><code class="prettyprint lang-d">Object</code></code>
(base class)
</li>
</ul>
</section><!-- using block ddox.sections in ddox.layout.dt-->
<!-- using block ddox.members in ddox.layout.dt-->
<section>
<h2>Constructors</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.this.html" class="public">
<code>this</code>
</a>
</td>
<td> Create an instance based on a given file <a href="../../utility/filepath/FilePath.this.html#path"><code class="prettyprint lang-d">path</code></a>.
</td>
</tr>
</table>
</section>
<section>
<h2>Fields</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.ResourceHome.html" class="public"><code>ResourceHome</code></a>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The path to the resources home folder.
</td>
</tr>
</table>
</section>
<section>
<h2>Properties</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.baseFileName.html" class="public property"><code>baseFileName</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The name of the file without its <a href="../../utility/filepath/FilePath.extension.html"><code class="prettyprint lang-d">extension</code></a>.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.directory.html" class="public property"><code>directory</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The path to the <code class="prettyprint lang-d">directory</code> containing the file.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.extension.html" class="public property"><code>extension</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The extensino of the file.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.fileName.html" class="public property"><code>fileName</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The name of the file with its <a href="../../utility/filepath/FilePath.extension.html"><code class="prettyprint lang-d">extension</code></a>.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.fullPath.html" class="public property"><code>fullPath</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The full path to the file.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.relativePath.html" class="public property"><code>relativePath</code></a>
<span class="<API key>">[get]</span>
</td>
<td><code class="prettyprint lang-d">string</code></td>
<td> The relative path from the executable to the file.
</td>
</tr>
</table>
</section>
<section>
<h2>Methods</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.getContents.html" class="public">
<code>getContents</code>
</a>
</td>
<td> TODO
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.scanDirectory.html" class="public">
<code>scanDirectory</code>
</a>
</td>
<td> Get all files in a given <a href="../../utility/filepath/FilePath.directory.html"><code class="prettyprint lang-d">directory</code></a>.
</td>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.toFile.html" class="public">
<code>toFile</code>
</a>
</td>
<td> Converts to a std.stdio.File
</td>
</tr>
</table>
</section>
<section>
<h2>Enums</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../../utility/filepath/FilePath.Resources.html" class="public">
<code>Resources</code>
</a>
</td>
<td> Paths to the different resource files.
</td>
</tr>
</table>
</section>
<section>
<h2>Authors</h2><!-- using block ddox.authors in ddox.layout.dt-->
</section>
<section>
<h2>Copyright</h2>
</section>
<section>
<h2>License</h2>
</section>
</div>
</body>
</html>
|
{% if page.meta_description %} {% assign meta_description = page.meta_description %} {% else %} {%
assign meta_description = page.content | strip_html | strip_newlines | truncate: 150 %} {% endif %}
<head prefix="og: http://ogp.me/ns
<title>{{ page.meta_title }}</title>
<meta charset="utf-8" />
<meta name="keywords" content="{{ page.keywords | default: site.keywords }}" />
<meta name="description" content="{{ meta_description }}" />
<meta name="author" content="{{ page.author | default: site.author }}" />
<meta name="robots" content="index, follow" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0" />
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.url }}" />
<!-- Verifications -->
<meta name="p:domain_verify" content="{{ site.pinterest_verify }}" />
<meta name="msvalidate.01" content="{{ site.bing_verify }}" />
<!-- Facebook Open Graph Info -->
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ page.url | replace:'index.html','' | prepend: site.url }}" />
<meta property="og:title" content="{{ meta_title }}" />
<meta property="og:description" content="{{ meta_description | truncate: 160 }}" />
<meta property="fb:app_id" content="{{ site.fb_app_id }}" />
<meta property="fb:admins" content="{{ site.fb_admins }}" />
<meta property="fb:profile_id" content="{{ site.fb_profile_id }}" />
<meta
property="og:image"
content="{{ site.images | prepend: site.url }}/{{ page.og_image | default: site.og_image }}"
/>
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="1500" />
<meta property="og:image:height" content="785" />
<!-- Favicons etc -->
<link
rel="apple-touch-icon"
sizes="57x57"
href="{{ site.images }}/favicons/apple-icon-57x57.png"
/>
<link
rel="apple-touch-icon"
sizes="60x60"
href="{{ site.images }}/favicons/apple-icon-60x60.png"
/>
<link
rel="apple-touch-icon"
sizes="72x72"
href="{{ site.images }}/favicons/apple-icon-72x72.png"
/>
<link
rel="apple-touch-icon"
sizes="76x76"
href="{{ site.images }}/favicons/apple-icon-76x76.png"
/>
<link
rel="apple-touch-icon"
sizes="114x114"
href="{{ site.images }}/favicons/apple-icon-114x114.png"
/>
<link
rel="apple-touch-icon"
sizes="120x120"
href="{{ site.images }}/favicons/apple-icon-120x120.png"
/>
<link
rel="apple-touch-icon"
sizes="144x144"
href="{{ site.images }}/favicons/apple-icon-144x144.png"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="{{ site.images }}/favicons/apple-icon-152x152.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="{{ site.images }}/favicons/apple-icon-180x180.png"
/>
<link
rel="icon"
type="image/png"
sizes="192x192"
href="{{ site.images }}/favicons/<API key>.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="{{ site.images }}/favicons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="96x96"
href="{{ site.images }}/favicons/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="{{ site.images }}/favicons/favicon-16x16.png"
/>
<link rel="manifest" href="{{ site.images }}/favicons/manifest.json" />
<meta name="<API key>" content="#ffffff" />
<meta name="<API key>" content="{{ site.images }}/favicons/ms-icon-144x144.png" />
<meta name="theme-color" content="#ffffff" />
<script>
// Add a class to the html element if JS is enabled
(function(html) {
html.classList.add('js');
})(document.documentElement);
</script>
<link href="{{ site.assets }}/css/main.css?v=@version@" rel="stylesheet" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Playfair+Display:900"
rel="stylesheet"
/>
</head>
|
layout: media
title: "In front of book shelves"
excerpt: "PaperFaces portrait of @mr_craig drawn with Paper by 53 on an iPad."
image:
feature: <API key>.jpg
thumb: <API key>.jpg
category: paperfaces
tags: [portrait, illustration, paper by 53]
PaperFaces portrait of [@mr_craig](http://twitter.com/mr_craig).
{% include <API key>.html %}
|
using System;
using NPoco;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
{
[TableName(TableName)]
[ExplicitColumns]
[PrimaryKey("Id")]
internal class TwoFactorLoginDto
{
public const string TableName = Cms.Core.Constants.DatabaseSchema.Tables.TwoFactorLogin;
[Column("id")]
[PrimaryKeyColumn]
public int Id { get; set; }
[Column("userOrMemberKey")]
[Index(IndexTypes.NonClustered)]
public Guid UserOrMemberKey { get; set; }
[Column("providerName")]
[Length(400)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.UniqueNonClustered, ForColumns = "providerName,userOrMemberKey", Name = "IX_" + TableName + "_ProviderName")]
public string ProviderName { get; set; }
[Column("secret")]
[Length(400)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string Secret { get; set; }
}
}
|
import WebdriverIO from './lib/webdriverio'
import Multibrowser from './lib/multibrowser'
import ErrorHandler from './lib/utils/ErrorHandler'
import <API key> from './lib/helpers/<API key>'
import pkg from './package.json'
const <API key> = <API key>()
const VERSION = pkg.version
let remote = function (options = {}, modifier) {
/**
* initialise monad
*/
let wdio = WebdriverIO(options, modifier)
/**
* build prototype: commands
*/
for (let commandName of Object.keys(<API key>)) {
wdio.lift(commandName, <API key>[commandName])
}
let prototype = wdio()
prototype.defer.resolve()
return prototype
}
let multiremote = function (options) {
let multibrowser = new Multibrowser()
for (let browserName of Object.keys(options)) {
multibrowser.addInstance(
browserName,
remote(options[browserName], multibrowser.getInstanceModifier())
)
}
return remote(options, multibrowser.getModifier())
}
export { remote, multiremote, VERSION, ErrorHandler }
|
<?php
namespace Elcodi\Component\Currency\Adapter\<API key>;
use GuzzleHttp\Client;
use Elcodi\Component\Currency\Adapter\<API key>\Interfaces\<API key>;
/**
* Class <API key>
*/
class <API key> implements <API key>
{
/**
* @var Client
*
* Client
*/
private $client;
/**
* Service constructor
*
* @param Client $client Guzzle client for requests
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Get the latest exchange rates.
*
* This method will take in account always that the base currency is USD,
* and the result must complain this format.
*
* [
* "EUR" => "1,78342784",
* "YEN" => "0,67438268",
* ...
* ]
*
* @return array exchange rates
*/
public function getExchangeRates()
{
$exchangeRates = [];
$response = $this
->client
->get(
'http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote',
[
'query' => [
'format' => 'json',
],
]
)
->json();
foreach ($response['list']['resources'] as $resource) {
$fields = $resource['resource']['fields'];
$symbol = str_replace('=X', '', $fields['symbol']);
$exchangeRates[$symbol] = (float) $fields['price'];
}
return $exchangeRates;
}
}
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Unicode Manipulation: GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="<API key>.html" title="Character Set Conversion">
<link rel="next" href="<API key>.html" title="Base64 Encoding">
<meta name="generator" content="GTK-Doc V1.24 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span>
<a href="#<API key>.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="<API key>.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="<API key>.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="<API key>"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="<API key>.top_of_page"></a>Unicode Manipulation</span></h2>
<p>Unicode Manipulation — functions operating on Unicode characters and
UTF-8 strings</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="<API key>.functions"></a><h2>Functions</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-validate" title="g_unichar_validate ()">g_unichar_validate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isalnum" title="g_unichar_isalnum ()">g_unichar_isalnum</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isalpha" title="g_unichar_isalpha ()">g_unichar_isalpha</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-iscntrl" title="g_unichar_iscntrl ()">g_unichar_iscntrl</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isdefined" title="g_unichar_isdefined ()">g_unichar_isdefined</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isdigit" title="g_unichar_isdigit ()">g_unichar_isdigit</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isgraph" title="g_unichar_isgraph ()">g_unichar_isgraph</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-islower" title="g_unichar_islower ()">g_unichar_islower</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-ismark" title="g_unichar_ismark ()">g_unichar_ismark</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isprint" title="g_unichar_isprint ()">g_unichar_isprint</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-ispunct" title="g_unichar_ispunct ()">g_unichar_ispunct</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isspace" title="g_unichar_isspace ()">g_unichar_isspace</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-istitle" title="g_unichar_istitle ()">g_unichar_istitle</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isupper" title="g_unichar_isupper ()">g_unichar_isupper</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-isxdigit" title="g_unichar_isxdigit ()">g_unichar_isxdigit</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-iswide" title="g_unichar_iswide ()">g_unichar_iswide</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-toupper" title="g_unichar_toupper ()">g_unichar_toupper</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-tolower" title="g_unichar_tolower ()">g_unichar_tolower</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-totitle" title="g_unichar_totitle ()">g_unichar_totitle</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-compose" title="g_unichar_compose ()">g_unichar_compose</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-decompose" title="g_unichar_decompose ()">g_unichar_decompose</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#GUnicodeType" title="enum GUnicodeType"><span class="returnvalue">GUnicodeType</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-type" title="g_unichar_type ()">g_unichar_type</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#GUnicodeBreakType" title="enum GUnicodeBreakType"><span class="returnvalue">GUnicodeBreakType</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="returnvalue">GUnicodeScript</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="returnvalue">GUnicodeScript</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint32" title="guint32"><span class="returnvalue">guint32</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-next-char" title="g_utf8_next_char()">g_utf8_next_char</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()">g_utf8_get_char</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="returnvalue">glong</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-prev-char" title="g_utf8_prev_char ()">g_utf8_prev_char</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="returnvalue">glong</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strlen" title="g_utf8_strlen ()">g_utf8_strlen</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strncpy" title="g_utf8_strncpy ()">g_utf8_strncpy</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strchr" title="g_utf8_strchr ()">g_utf8_strchr</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strrchr" title="g_utf8_strrchr ()">g_utf8_strrchr</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strreverse" title="g_utf8_strreverse ()">g_utf8_strreverse</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-substring" title="g_utf8_substring ()">g_utf8_substring</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()">g_utf8_validate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strup" title="g_utf8_strup ()">g_utf8_strup</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-strdown" title="g_utf8_strdown ()">g_utf8_strdown</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-casefold" title="g_utf8_casefold ()">g_utf8_casefold</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-normalize" title="g_utf8_normalize ()">g_utf8_normalize</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-collate" title="g_utf8_collate ()">g_utf8_collate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-collate-key" title="g_utf8_collate_key ()">g_utf8_collate_key</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><API key></a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="returnvalue">gunichar2</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-to-utf16" title="g_utf8_to_utf16 ()">g_utf8_to_utf16</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-to-ucs4" title="g_utf8_to_ucs4 ()">g_utf8_to_ucs4</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf8-to-ucs4-fast" title="g_utf8_to_ucs4_fast ()">g_utf8_to_ucs4_fast</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf16-to-ucs4" title="g_utf16_to_ucs4 ()">g_utf16_to_ucs4</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-utf16-to-utf8" title="g_utf16_to_utf8 ()">g_utf16_to_utf8</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="returnvalue">gunichar2</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-ucs4-to-utf16" title="g_ucs4_to_utf16 ()">g_ucs4_to_utf16</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-ucs4-to-utf8" title="g_ucs4_to_utf8 ()">g_ucs4_to_utf8</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="<API key>.html#g-unichar-to-utf8" title="g_unichar_to_utf8 ()">g_unichar_to_utf8</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="<API key>.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="typedef_keyword">typedef</td>
<td class="function_name"><a class="link" href="<API key>.html#gunichar" title="gunichar">gunichar</a></td>
</tr>
<tr>
<td class="typedef_keyword">typedef</td>
<td class="function_name"><a class="link" href="<API key>.html#gunichar2" title="gunichar2">gunichar2</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="<API key>.html#<API key>:CAPS" title="<API key>"><API key></a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="<API key>.html#GUnicodeType" title="enum GUnicodeType">GUnicodeType</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="<API key>.html#<API key>:CAPS" title="<API key>"><API key></a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="<API key>.html#GUnicodeBreakType" title="enum GUnicodeBreakType">GUnicodeBreakType</a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript">GUnicodeScript</a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="<API key>.html#GNormalizeMode" title="enum GNormalizeMode">GNormalizeMode</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="<API key>.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include <glib.h>
</pre>
</div>
<div class="refsect1">
<a name="<API key>.description"></a><h2>Description</h2>
<p>This section describes a number of functions for dealing with
Unicode characters and strings. There are analogues of the
traditional <code class="literal">ctype.h</code> character classification and case conversion
functions, UTF-8 analogues of some string utility functions,
functions to perform normalization, case conversion and collation
on UTF-8 strings and finally functions to convert between the UTF-8,
UTF-16 and UCS-4 encodings of Unicode.</p>
<p>The implementations of the Unicode functions in GLib are based
on the Unicode Character Data tables, which are available from
<a class="ulink" href="http:
GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
GLib 2.30 supports Unicode 6.0.</p>
</div>
<div class="refsect1">
<a name="<API key>.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-unichar-validate"></a><h3>g_unichar_validate ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_validate (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>);</pre>
<p>Checks whether <em class="parameter"><code>ch</code></em>
is a valid Unicode character. Some possible
integer values of <em class="parameter"><code>ch</code></em>
will not be valid. 0 is considered a valid
character, though it's normally a string terminator.</p>
<div class="refsect3">
<a name="id-1.5.4.7.2.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.2.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>ch</code></em>
is a valid Unicode character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isalnum"></a><h3>g_unichar_isalnum ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isalnum (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is alphanumeric.
Given some UTF-8 text, obtain a character value
with <a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.3.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.3.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is an alphanumeric character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isalpha"></a><h3>g_unichar_isalpha ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isalpha (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is alphabetic (i.e. a letter).
Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.4.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.4.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is an alphabetic character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-iscntrl"></a><h3>g_unichar_iscntrl ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_iscntrl (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is a control character.
Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.5.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.5.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a control character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isdefined"></a><h3>g_unichar_isdefined ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isdefined (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a given character is assigned in the Unicode
standard.</p>
<div class="refsect3">
<a name="id-1.5.4.7.6.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.6.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character has an assigned value</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isdigit"></a><h3>g_unichar_isdigit ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isdigit (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is numeric (i.e. a digit). This
covers ASCII 0-9 and also digits in other languages/scripts. Given
some UTF-8 text, obtain a character value with <a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.7.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.7.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a digit</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isgraph"></a><h3>g_unichar_isgraph ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isgraph (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is printable and not a space
(returns <a class="link" href="<API key>.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> for control characters, format characters, and
spaces). <a class="link" href="<API key>.html#g-unichar-isprint" title="g_unichar_isprint ()"><code class="function">g_unichar_isprint()</code></a> is similar, but returns <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for
spaces. Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.8.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.8.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is printable unless it's a space</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-islower"></a><h3>g_unichar_islower ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_islower (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is a lowercase letter.
Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.9.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.9.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a lowercase letter</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-ismark"></a><h3>g_unichar_ismark ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_ismark (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is a mark (non-spacing mark,
combining mark, or enclosing mark in Unicode speak).
Given some UTF-8 text, obtain a character value
with <a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<p>Note: in most cases where isalpha characters are allowed,
ismark characters should be allowed to as they are essential
for writing most European languages as well as many non-Latin
scripts.</p>
<div class="refsect3">
<a name="id-1.5.4.7.10.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.10.7"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a mark character</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isprint"></a><h3>g_unichar_isprint ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isprint (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is printable.
Unlike <a class="link" href="<API key>.html#g-unichar-isgraph" title="g_unichar_isgraph ()"><code class="function">g_unichar_isgraph()</code></a>, returns <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for spaces.
Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.11.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.11.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is printable</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-ispunct"></a><h3>g_unichar_ispunct ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_ispunct (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is punctuation or a symbol.
Given some UTF-8 text, obtain a character value with
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.12.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.12.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a punctuation or symbol character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isspace"></a><h3>g_unichar_isspace ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isspace (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines whether a character is a space, tab, or line separator
(newline, carriage return, etc.). Given some UTF-8 text, obtain a
character value with <a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>.</p>
<p>(Note: don't use this to do word breaking; you have to use
Pango or equivalent to get word breaking right, the algorithm
is fairly complex.)</p>
<div class="refsect3">
<a name="id-1.5.4.7.13.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.13.7"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is a space character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-istitle"></a><h3>g_unichar_istitle ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_istitle (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a character is titlecase. Some characters in
Unicode which are composites, such as the DZ digraph
have three case variants instead of just two. The titlecase
form is used at the beginning of a word where only the
first letter is capitalized. The titlecase form of the DZ
digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.</p>
<div class="refsect3">
<a name="id-1.5.4.7.14.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.14.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character is titlecase</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isupper"></a><h3>g_unichar_isupper ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isupper (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a character is uppercase.</p>
<div class="refsect3">
<a name="id-1.5.4.7.15.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.15.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>c</code></em>
is an uppercase character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-isxdigit"></a><h3>g_unichar_isxdigit ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_isxdigit (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a character is a hexidecimal digit.</p>
<div class="refsect3">
<a name="id-1.5.4.7.16.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character.</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.16.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character is a hexadecimal digit</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-iswide"></a><h3>g_unichar_iswide ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_iswide (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a character is typically rendered in a double-width
cell.</p>
<div class="refsect3">
<a name="id-1.5.4.7.17.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.17.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character is wide</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a character is typically rendered in a double-width
cell under legacy East Asian locales. If a character is wide according to
<a class="link" href="<API key>.html#g-unichar-iswide" title="g_unichar_iswide ()"><code class="function">g_unichar_iswide()</code></a>, then it is also reported wide with this function, but
the converse is not necessarily true. See the
<a class="ulink" href="http:
for details.</p>
<p>If a character passes the <a class="link" href="<API key>.html#g-unichar-iswide" title="g_unichar_iswide ()"><code class="function">g_unichar_iswide()</code></a> test then it will also pass
this test, but not the other way around. Note that some characters may
pass both this test and <a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.18.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.18.7"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character is wide in legacy East Asian locales</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-12.html#api-index-2.12">2.12</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines if a given character typically takes zero width when rendered.
The return value is <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for all non-spacing and enclosing marks
(e.g., combining accents), format characters, zero-width
space, but not U+00AD SOFT HYPHEN.</p>
<p>A typical use of this function is with one of <a class="link" href="<API key>.html#g-unichar-iswide" title="g_unichar_iswide ()"><code class="function">g_unichar_iswide()</code></a> or
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a> to determine the number of cells a string occupies
when displayed on a grid display (terminals). However, note that not all
terminals support zero-width rendering of zero-width marks.</p>
<div class="refsect3">
<a name="id-1.5.4.7.19.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.19.7"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character has zero width</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-toupper"></a><h3>g_unichar_toupper ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
g_unichar_toupper (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Converts a character to uppercase.</p>
<div class="refsect3">
<a name="id-1.5.4.7.20.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.20.6"></a><h4>Returns</h4>
<p> the result of converting <em class="parameter"><code>c</code></em>
to uppercase.
If <em class="parameter"><code>c</code></em>
is not an lowercase or titlecase character,
or has no upper case equivalent <em class="parameter"><code>c</code></em>
is returned unchanged.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-tolower"></a><h3>g_unichar_tolower ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
g_unichar_tolower (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Converts a character to lower case.</p>
<div class="refsect3">
<a name="id-1.5.4.7.21.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character.</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.21.6"></a><h4>Returns</h4>
<p> the result of converting <em class="parameter"><code>c</code></em>
to lower case.
If <em class="parameter"><code>c</code></em>
is not an upperlower or titlecase character,
or has no lowercase equivalent <em class="parameter"><code>c</code></em>
is returned unchanged.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-totitle"></a><h3>g_unichar_totitle ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
g_unichar_totitle (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Converts a character to the titlecase.</p>
<div class="refsect3">
<a name="id-1.5.4.7.22.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.22.6"></a><h4>Returns</h4>
<p> the result of converting <em class="parameter"><code>c</code></em>
to titlecase.
If <em class="parameter"><code>c</code></em>
is not an uppercase or lowercase character,
<em class="parameter"><code>c</code></em>
is returned unchanged.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines the numeric value of a character as a decimal
digit.</p>
<div class="refsect3">
<a name="id-1.5.4.7.23.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.23.6"></a><h4>Returns</h4>
<p> If <em class="parameter"><code>c</code></em>
is a decimal digit (according to
<a class="link" href="<API key>.html#g-unichar-isdigit" title="g_unichar_isdigit ()"><code class="function">g_unichar_isdigit()</code></a>), its numeric value. Otherwise, -1.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines the numeric value of a character as a hexidecimal
digit.</p>
<div class="refsect3">
<a name="id-1.5.4.7.24.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.24.6"></a><h4>Returns</h4>
<p> If <em class="parameter"><code>c</code></em>
is a hex digit (according to
<a class="link" href="<API key>.html#g-unichar-isxdigit" title="g_unichar_isxdigit ()"><code class="function">g_unichar_isxdigit()</code></a>), its numeric value. Otherwise, -1.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-compose"></a><h3>g_unichar_compose ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_compose (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> a</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> b</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *ch</code></em>);</pre>
<p>Performs a single composition step of the
Unicode canonical composition algorithm.</p>
<p>This function includes algorithmic Hangul Jamo composition,
but it is not exactly the inverse of <a class="link" href="<API key>.html#g-unichar-decompose" title="g_unichar_decompose ()"><code class="function">g_unichar_decompose()</code></a>.
No composition can have either of <em class="parameter"><code>a</code></em>
or <em class="parameter"><code>b</code></em>
equal to zero.
To be precise, this function composes if and only if
there exists a Primary Composite P which is canonically
equivalent to the sequence <<em class="parameter"><code>a</code></em>
,<em class="parameter"><code>b</code></em>
>. See the Unicode
Standard for the definition of Primary Composite.</p>
<p>If <em class="parameter"><code>a</code></em>
and <em class="parameter"><code>b</code></em>
do not compose a new character, <em class="parameter"><code>ch</code></em>
is set to zero.</p>
<p>See
<a class="ulink" href="http://unicode.org/reports/tr15/" target="_top">UAX<span class="type">15</span></a>
for details.</p>
<div class="refsect3">
<a name="id-1.5.4.7.25.8"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>a</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>b</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>return location for the composed character</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.25.9"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the characters could be composed</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-decompose"></a><h3>g_unichar_decompose ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_unichar_decompose (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *a</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *b</code></em>);</pre>
<p>Performs a single decomposition step of the
Unicode canonical decomposition algorithm.</p>
<p>This function does not include compatibility
decompositions. It does, however, include algorithmic
Hangul Jamo decomposition, as well as 'singleton'
decompositions which replace a character by a single
other character. In the case of singletons *<em class="parameter"><code>b</code></em>
will
be set to zero.</p>
<p>If <em class="parameter"><code>ch</code></em>
is not decomposable, *<em class="parameter"><code>a</code></em>
is set to <em class="parameter"><code>ch</code></em>
and *<em class="parameter"><code>b</code></em>
is set to zero.</p>
<p>Note that the way Unicode decomposition pairs are
defined, it is guaranteed that <em class="parameter"><code>b</code></em>
would not decompose
further, but <em class="parameter"><code>a</code></em>
may itself decompose. To get the full
canonical decomposition for <em class="parameter"><code>ch</code></em>
, one would need to
recursively call this function on <em class="parameter"><code>a</code></em>
. Or use
<a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a>.</p>
<p>See
<a class="ulink" href="http://unicode.org/reports/tr15/" target="_top">UAX<span class="type">15</span></a>
for details.</p>
<div class="refsect3">
<a name="id-1.5.4.7.26.9"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>a</p></td>
<td class="<API key>"><p>return location for the first component of <em class="parameter"><code>ch</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>b</p></td>
<td class="<API key>"><p>return location for the second component of <em class="parameter"><code>ch</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.26.10"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the character could be decomposed</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> compat</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *result</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> result_len</code></em>);</pre>
<p>Computes the canonical or compatibility decomposition of a
Unicode character. For compatibility decomposition,
pass <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for <em class="parameter"><code>compat</code></em>
; for canonical decomposition
pass <a class="link" href="<API key>.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> for <em class="parameter"><code>compat</code></em>
.</p>
<p>The decomposed sequence is placed in <em class="parameter"><code>result</code></em>
. Only up to
<em class="parameter"><code>result_len</code></em>
characters are written into <em class="parameter"><code>result</code></em>
. The length
of the full decomposition (irrespective of <em class="parameter"><code>result_len</code></em>
) is
returned by the function. For canonical decomposition,
currently all decompositions are of length at most 4, but
this may change in the future (very unlikely though).
At any rate, Unicode does guarantee that a buffer of length
18 is always enough for both compatibility and canonical
decompositions, so that is the size recommended. This is provided
as <a class="link" href="<API key>.html#<API key>:CAPS" title="<API key>"><code class="literal"><API key></code></a>.</p>
<p>See
<a class="ulink" href="http://unicode.org/reports/tr15/" target="_top">UAX<span class="type">15</span></a>
for details.</p>
<div class="refsect3">
<a name="id-1.5.4.7.27.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>compat</p></td>
<td class="<API key>"><p>whether perform canonical or compatibility decomposition</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>result</p></td>
<td class="<API key>"><p> location to store decomposed result, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>result_len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>result</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.27.8"></a><h4>Returns</h4>
<p> the length of the full decomposition.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-type"></a><h3>g_unichar_type ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#GUnicodeType" title="enum GUnicodeType"><span class="returnvalue">GUnicodeType</span></a>
g_unichar_type (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Classifies a Unicode character by type.</p>
<div class="refsect3">
<a name="id-1.5.4.7.28.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.28.6"></a><h4>Returns</h4>
<p> the type of the character.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#GUnicodeBreakType" title="enum GUnicodeBreakType"><span class="returnvalue">GUnicodeBreakType</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Determines the break type of <em class="parameter"><code>c</code></em>
. <em class="parameter"><code>c</code></em>
should be a Unicode character
(to derive a character from UTF-8 encoded text, use
<a class="link" href="<API key>.html#g-utf8-get-char" title="g_utf8_get_char ()"><code class="function">g_utf8_get_char()</code></a>). The break type is used to find word and line
breaks ("text boundaries"), Pango implements the Unicode boundary
resolution algorithms and normally you would use a function such
as <code class="function">pango_break()</code> instead of caring about break types yourself.</p>
<div class="refsect3">
<a name="id-1.5.4.7.29.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.29.6"></a><h4>Returns</h4>
<p> the break type of <em class="parameter"><code>c</code></em>
</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> uc</code></em>);</pre>
<p>Determines the canonical combining class of a Unicode character.</p>
<div class="refsect3">
<a name="id-1.5.4.7.30.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>uc</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.30.6"></a><h4>Returns</h4>
<p> the combining class of the character</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *string</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> len</code></em>);</pre>
<p>Computes the canonical ordering of a string in-place.
This rearranges decomposed characters in the string
according to their combining classes. See the Unicode
manual for more information.</p>
<div class="refsect3">
<a name="id-1.5.4.7.31.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>string</p></td>
<td class="<API key>"><p>a UCS-4 encoded string.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>string</code></em>
to use.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> *result_len</code></em>);</pre>
<div class="warning">
<p><code class="literal"><API key></code> has been deprecated since version 2.30 and should not be used in newly-written code.</p>
<p>Use the more flexible <a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a>
instead.</p>
</div>
<p>Computes the canonical decomposition of a Unicode character.</p>
<div class="refsect3">
<a name="id-1.5.4.7.32.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>result_len</p></td>
<td class="<API key>"><p>location to store the length of the return value.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.32.7"></a><h4>Returns</h4>
<p> a newly allocated string of Unicode characters.
<em class="parameter"><code>result_len</code></em>
is set to the resulting length of the string.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *mirrored_ch</code></em>);</pre>
<p>In Unicode, some characters are "mirrored". This means that their
images are mirrored horizontally in text that is laid out from right
to left. For instance, "(" would become its mirror image, ")", in
right-to-left text.</p>
<p>If <em class="parameter"><code>ch</code></em>
has the Unicode mirrored property and there is another unicode
character that typically has a glyph that is the mirror image of <em class="parameter"><code>ch</code></em>
's
glyph and <em class="parameter"><code>mirrored_ch</code></em>
is set, it puts that character in the address
pointed to by <em class="parameter"><code>mirrored_ch</code></em>
. Otherwise the original character is put.</p>
<div class="refsect3">
<a name="id-1.5.4.7.33.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>mirrored_ch</p></td>
<td class="<API key>"><p>location to store the mirrored character</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.33.7"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <em class="parameter"><code>ch</code></em>
has a mirrored character, <a class="link" href="<API key>.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> otherwise</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-4.html#api-index-2.4">2.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="returnvalue">GUnicodeScript</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> ch</code></em>);</pre>
<p>Looks up the <a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="type">GUnicodeScript</span></a> for a particular character (as defined
by Unicode Standard Annex #24). No check is made for <em class="parameter"><code>ch</code></em>
being a
valid Unicode character; if you pass in invalid character, the
result is undefined.</p>
<p>This function is equivalent to <code class="function"><API key>()</code> and the
two are interchangeable.</p>
<div class="refsect3">
<a name="id-1.5.4.7.34.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>ch</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.34.7"></a><h4>Returns</h4>
<p> the <a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="type">GUnicodeScript</span></a> for the character.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="returnvalue">GUnicodeScript</span></a>
<API key> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint32" title="guint32"><span class="type">guint32</span></a> iso15924</code></em>);</pre>
<p>Looks up the Unicode script for <em class="parameter"><code>iso15924</code></em>
. ISO 15924 assigns four-letter
codes to scripts. For example, the code for Arabic is 'Arab'.
This function accepts four letter codes encoded as a <em class="parameter"><code>guint32</code></em>
in a
big-endian fashion. That is, the code expected for Arabic is
0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).</p>
<p>See
<a class="ulink" href="http://unicode.org/iso15924/codelists.html" target="_top">Codes for the representation of names of scripts</a>
for details.</p>
<div class="refsect3">
<a name="id-1.5.4.7.35.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>iso15924</p></td>
<td class="<API key>"><p>a Unicode script</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.35.7"></a><h4>Returns</h4>
<p> the Unicode script for <em class="parameter"><code>iso15924</code></em>
, or
of <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> if <em class="parameter"><code>iso15924</code></em>
is zero and
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> if <em class="parameter"><code>iso15924</code></em>
is unknown.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint32" title="guint32"><span class="returnvalue">guint32</span></a>
<API key> (<em class="parameter"><code><a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="type">GUnicodeScript</span></a> script</code></em>);</pre>
<p>Looks up the ISO 15924 code for <em class="parameter"><code>script</code></em>
. ISO 15924 assigns four-letter
codes to scripts. For example, the code for Arabic is 'Arab'. The
four letter codes are encoded as a <em class="parameter"><code>guint32</code></em>
by this function in a
big-endian fashion. That is, the code returned for Arabic is
0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).</p>
<p>See
<a class="ulink" href="http://unicode.org/iso15924/codelists.html" target="_top">Codes for the representation of names of scripts</a>
for details.</p>
<div class="refsect3">
<a name="id-1.5.4.7.36.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>script</p></td>
<td class="<API key>"><p>a Unicode script</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.36.7"></a><h4>Returns</h4>
<p> the ISO 15924 code for <em class="parameter"><code>script</code></em>
, encoded as an integer,
of zero if <em class="parameter"><code>script</code></em>
is <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> or
ISO 15924 code 'Zzzz' (script code for UNKNOWN) if <em class="parameter"><code>script</code></em>
is not understood.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-next-char"></a><h3>g_utf8_next_char()</h3>
<pre class="programlisting">#define g_utf8_next_char(p)</pre>
<p>Skips to the next character in a UTF-8 string. The string must be
valid; this macro is as fast as possible, and has no error-checking.
You would use this macro to iterate over a string character by
character. The macro returns the start of the next UTF-8 character.
Before using this macro, use <a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()"><code class="function">g_utf8_validate()</code></a> to validate strings
that may contain invalid UTF-8.</p>
<div class="refsect3">
<a name="id-1.5.4.7.37.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>Pointer to the start of a valid UTF-8 character</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-get-char"></a><h3>g_utf8_get_char ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
g_utf8_get_char (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>);</pre>
<p>Converts a sequence of bytes encoded as UTF-8 to a Unicode character.</p>
<p>If <em class="parameter"><code>p</code></em>
does not point to a valid UTF-8 encoded character, results
are undefined. If you are not sure that the bytes are complete
valid Unicode characters, you should use <a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a>
instead.</p>
<div class="refsect3">
<a name="id-1.5.4.7.38.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a pointer to Unicode character encoded as UTF-8</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.38.7"></a><h4>Returns</h4>
<p> the resulting character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a>
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> max_len</code></em>);</pre>
<p>Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
This function checks for incomplete characters, for invalid characters
such as characters that are out of the range of Unicode, and for
overlong encodings of valid characters.</p>
<div class="refsect3">
<a name="id-1.5.4.7.39.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a pointer to Unicode character encoded as UTF-8</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>max_len</p></td>
<td class="<API key>"><p>the maximum number of bytes to read, or -1, for no maximum or
if <em class="parameter"><code>p</code></em>
is nul-terminated</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.39.6"></a><h4>Returns</h4>
<p> the resulting character. If <em class="parameter"><code>p</code></em>
points to a partial
sequence at the end of a string that could begin a valid
character (or if <em class="parameter"><code>max_len</code></em>
is zero), returns (gunichar)-2;
otherwise, if <em class="parameter"><code>p</code></em>
does not point to a valid UTF-8 encoded
Unicode character, returns (gunichar)-1.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> offset</code></em>);</pre>
<p>Converts from an integer character offset to a pointer to a position
within the string.</p>
<p>Since 2.10, this function allows to pass a negative <em class="parameter"><code>offset</code></em>
to
step backwards. It is usually worth stepping backwards from the end
instead of forwards if <em class="parameter"><code>offset</code></em>
is in the last fourth of the string,
since moving forward is about 3 times faster than moving backward.</p>
<p>Note that this function doesn't abort when reaching the end of <em class="parameter"><code>str</code></em>
.
Therefore you should be sure that <em class="parameter"><code>offset</code></em>
is within string boundaries
before calling that function. Call <a class="link" href="<API key>.html#g-utf8-strlen" title="g_utf8_strlen ()"><code class="function">g_utf8_strlen()</code></a> when unsure.
This limitation exists as this function is called frequently during
text rendering and therefore has to be as fast as possible.</p>
<div class="refsect3">
<a name="id-1.5.4.7.40.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>offset</p></td>
<td class="<API key>"><p>a character offset within <em class="parameter"><code>str</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.40.8"></a><h4>Returns</h4>
<p> the resulting pointer</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="returnvalue">glong</span></a>
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *pos</code></em>);</pre>
<p>Converts from a pointer to position within a string to a integer
character offset.</p>
<p>Since 2.10, this function allows <em class="parameter"><code>pos</code></em>
to be before <em class="parameter"><code>str</code></em>
, and returns
a negative offset in this case.</p>
<div class="refsect3">
<a name="id-1.5.4.7.41.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>pos</p></td>
<td class="<API key>"><p>a pointer to a position within <em class="parameter"><code>str</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.41.7"></a><h4>Returns</h4>
<p> the resulting character offset</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-prev-char"></a><h3>g_utf8_prev_char ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_prev_char (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>);</pre>
<p>Finds the previous UTF-8 character in the string before <em class="parameter"><code>p</code></em>
.</p>
<p><em class="parameter"><code>p</code></em>
does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte. If <em class="parameter"><code>p</code></em>
might be the first
character of the string, you must use <a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a> instead.</p>
<div class="refsect3">
<a name="id-1.5.4.7.42.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a pointer to a position within a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.42.7"></a><h4>Returns</h4>
<p> a pointer to the found character</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *end</code></em>);</pre>
<p>Finds the start of the next UTF-8 character in the string after <em class="parameter"><code>p</code></em>
.</p>
<p><em class="parameter"><code>p</code></em>
does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.</p>
<div class="refsect3">
<a name="id-1.5.4.7.43.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a pointer to a position within a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>end</p></td>
<td class="<API key>"><p>a pointer to the byte following the end of the string,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to indicate that the string is nul-terminated</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.43.7"></a><h4>Returns</h4>
<p> a pointer to the found character or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>);</pre>
<p>Given a position <em class="parameter"><code>p</code></em>
with a UTF-8 encoded string <em class="parameter"><code>str</code></em>
, find the start
of the previous UTF-8 character starting before <em class="parameter"><code>p</code></em>
. Returns <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if no
UTF-8 characters are present in <em class="parameter"><code>str</code></em>
before <em class="parameter"><code>p</code></em>
.</p>
<p><em class="parameter"><code>p</code></em>
does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.</p>
<div class="refsect3">
<a name="id-1.5.4.7.44.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>pointer to the beginning of a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>pointer to some position within <em class="parameter"><code>str</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.44.7"></a><h4>Returns</h4>
<p> a pointer to the found character or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strlen"></a><h3>g_utf8_strlen ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="returnvalue">glong</span></a>
g_utf8_strlen (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> max</code></em>);</pre>
<p>Computes the length of the string in characters, not including
the terminating nul character. If the <em class="parameter"><code>max</code></em>
'th byte falls in the
middle of a character, the last (partial) character is not counted.</p>
<div class="refsect3">
<a name="id-1.5.4.7.45.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>pointer to the start of a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>max</p></td>
<td class="<API key>"><p>the maximum number of bytes to examine. If <em class="parameter"><code>max</code></em>
is less than 0, then the string is assumed to be
nul-terminated. If <em class="parameter"><code>max</code></em>
is 0, <em class="parameter"><code>p</code></em>
will not be examined and
may be <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. If <em class="parameter"><code>max</code></em>
is greater than 0, up to <em class="parameter"><code>max</code></em>
bytes are examined</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.45.6"></a><h4>Returns</h4>
<p> the length of the string in characters</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strncpy"></a><h3>g_utf8_strncpy ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strncpy (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *dest</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *src</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> n</code></em>);</pre>
<p>Like the standard C <code class="function">strncpy()</code> function, but copies a given number
of characters instead of a given number of bytes. The <em class="parameter"><code>src</code></em>
string
must be valid UTF-8 encoded text. (Use <a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()"><code class="function">g_utf8_validate()</code></a> on all
text before trying to use UTF-8 utility functions with it.)</p>
<div class="refsect3">
<a name="id-1.5.4.7.46.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>dest</p></td>
<td class="<API key>"><p>buffer to fill with characters from <em class="parameter"><code>src</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>src</p></td>
<td class="<API key>"><p>UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n</p></td>
<td class="<API key>"><p>character count</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.46.6"></a><h4>Returns</h4>
<p> <em class="parameter"><code>dest</code></em>
</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strchr"></a><h3>g_utf8_strchr ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strchr (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Finds the leftmost occurrence of the given Unicode character
in a UTF-8 encoded string, while limiting the search to <em class="parameter"><code>len</code></em>
bytes.
If <em class="parameter"><code>len</code></em>
is -1, allow unbounded search.</p>
<div class="refsect3">
<a name="id-1.5.4.7.47.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a nul-terminated UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>p</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.47.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the string does not contain the character,
otherwise, a pointer to the start of the leftmost occurrence
of the character in the string.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strrchr"></a><h3>g_utf8_strrchr ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strrchr (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *p</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>);</pre>
<p>Find the rightmost occurrence of the given Unicode character
in a UTF-8 encoded string, while limiting the search to <em class="parameter"><code>len</code></em>
bytes.
If <em class="parameter"><code>len</code></em>
is -1, allow unbounded search.</p>
<div class="refsect3">
<a name="id-1.5.4.7.48.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>p</p></td>
<td class="<API key>"><p>a nul-terminated UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>p</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.48.6"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the string does not contain the character,
otherwise, a pointer to the start of the rightmost occurrence
of the character in the string.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strreverse"></a><h3>g_utf8_strreverse ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strreverse (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Reverses a UTF-8 string. <em class="parameter"><code>str</code></em>
must be valid UTF-8 encoded text.
(Use <a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()"><code class="function">g_utf8_validate()</code></a> on all text before trying to use UTF-8
utility functions with it.)</p>
<p>This function is intended for programmatic uses of reversed strings.
It pays no attention to decomposed characters, combining marks, byte
order marks, directional indicators (LRM, LRO, etc) and similar
characters which might need special handling when reversing a string
for display purposes.</p>
<p>Note that unlike <a class="link" href="<API key>.html#g-strreverse" title="g_strreverse ()"><code class="function">g_strreverse()</code></a>, this function returns
newly-allocated memory, which should be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when
no longer needed.</p>
<div class="refsect3">
<a name="id-1.5.4.7.49.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>str</code></em>
to use, in bytes. If <em class="parameter"><code>len</code></em>
< 0,
then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.49.8"></a><h4>Returns</h4>
<p> a newly-allocated string which is the reverse of <em class="parameter"><code>str</code></em>
</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-2.html#api-index-2.2">2.2</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-substring"></a><h3>g_utf8_substring ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_substring (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> start_pos</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> end_pos</code></em>);</pre>
<p>Copies a substring out of a UTF-8 encoded string.
The substring will contain <em class="parameter"><code>end_pos</code></em>
- <em class="parameter"><code>start_pos</code></em>
characters.</p>
<div class="refsect3">
<a name="id-1.5.4.7.50.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>start_pos</p></td>
<td class="<API key>"><p>a character offset within <em class="parameter"><code>str</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>end_pos</p></td>
<td class="<API key>"><p>another character offset within <em class="parameter"><code>str</code></em>
</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.50.6"></a><h4>Returns</h4>
<p> a newly allocated copy of the requested
substring. Free with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when no longer needed.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-validate"></a><h3>g_utf8_validate ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_utf8_validate (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> max_len</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> **end</code></em>);</pre>
<p>Validates UTF-8 encoded text. <em class="parameter"><code>str</code></em>
is the text to validate;
if <em class="parameter"><code>str</code></em>
is nul-terminated, then <em class="parameter"><code>max_len</code></em>
can be -1, otherwise
<em class="parameter"><code>max_len</code></em>
should be the number of bytes to validate.
If <em class="parameter"><code>end</code></em>
is non-<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then the end of the valid range
will be stored there (i.e. the start of the first invalid
character if some bytes were invalid, or the end of the text
being validated otherwise).</p>
<p>Note that <a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()"><code class="function">g_utf8_validate()</code></a> returns <a class="link" href="<API key>.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if <em class="parameter"><code>max_len</code></em>
is
positive and any of the <em class="parameter"><code>max_len</code></em>
bytes are nul.</p>
<p>Returns <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if all of <em class="parameter"><code>str</code></em>
was valid. Many GLib and GTK+
routines require valid UTF-8 as input; so data read from a file
or the network should be checked with <a class="link" href="<API key>.html#g-utf8-validate" title="g_utf8_validate ()"><code class="function">g_utf8_validate()</code></a> before
doing anything else with it.</p>
<div class="refsect3">
<a name="id-1.5.4.7.51.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p> a pointer to character data. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=max_len][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>max_len</p></td>
<td class="<API key>"><p>max bytes to validate, or -1 to go until NUL</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>end</p></td>
<td class="<API key>"><p> return location for end of valid data. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>][<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.51.8"></a><h4>Returns</h4>
<p> <a class="link" href="<API key>.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the text was valid UTF-8</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strup"></a><h3>g_utf8_strup ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strup (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Converts all Unicode characters in the string that have a case
to uppercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string increasing. (For instance, the
German ess-zet will be changed to SS.)</p>
<div class="refsect3">
<a name="id-1.5.4.7.52.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.52.6"></a><h4>Returns</h4>
<p> a newly allocated string, with all characters
converted to uppercase. </p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-strdown"></a><h3>g_utf8_strdown ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_strdown (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Converts all Unicode characters in the string that have a case
to lowercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string changing.</p>
<div class="refsect3">
<a name="id-1.5.4.7.53.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.53.6"></a><h4>Returns</h4>
<p> a newly allocated string, with all characters
converted to lowercase. </p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-casefold"></a><h3>g_utf8_casefold ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_casefold (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Converts a string into a form that is independent of case. The
result will not correspond to any particular case, but can be
compared for equality or ordered with the results of calling
<a class="link" href="<API key>.html#g-utf8-casefold" title="g_utf8_casefold ()"><code class="function">g_utf8_casefold()</code></a> on other strings.</p>
<p>Note that calling <a class="link" href="<API key>.html#g-utf8-casefold" title="g_utf8_casefold ()"><code class="function">g_utf8_casefold()</code></a> followed by <a class="link" href="<API key>.html#g-utf8-collate" title="g_utf8_collate ()"><code class="function">g_utf8_collate()</code></a> is
only an approximation to the correct linguistic case insensitive
ordering, though it is a fairly good one. Getting this exactly
right would require a more sophisticated collation function that
takes case sensitivity into account. GLib does not currently
provide such a function.</p>
<div class="refsect3">
<a name="id-1.5.4.7.54.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.54.7"></a><h4>Returns</h4>
<p> a newly allocated string, that is a
case independent form of <em class="parameter"><code>str</code></em>
.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-normalize"></a><h3>g_utf8_normalize ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_normalize (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GNormalizeMode" title="enum GNormalizeMode"><span class="type">GNormalizeMode</span></a> mode</code></em>);</pre>
<p>Converts a string into canonical form, standardizing
such issues as whether a character with an accent
is represented as a base character and combining
accent or as a single precomposed character. The
string has to be valid UTF-8, otherwise <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is
returned. You should generally call <a class="link" href="<API key>.html#g-utf8-normalize" title="g_utf8_normalize ()"><code class="function">g_utf8_normalize()</code></a>
before comparing two Unicode strings.</p>
<p>The normalization mode <a class="link" href="<API key>.html#G-NORMALIZE-DEFAULT:CAPS"><code class="literal">G_NORMALIZE_DEFAULT</code></a> only
standardizes differences that do not affect the
text content, such as the above-mentioned accent
representation. <a class="link" href="<API key>.html#G-NORMALIZE-ALL:CAPS"><code class="literal">G_NORMALIZE_ALL</code></a> also standardizes
the "compatibility" characters in Unicode, such
as SUPERSCRIPT THREE to the standard forms
(in this case DIGIT THREE). Formatting information
may be lost but for most text operations such
characters should be considered the same.</p>
<p><a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> and <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a>
are like <a class="link" href="<API key>.html#G-NORMALIZE-DEFAULT:CAPS"><code class="literal">G_NORMALIZE_DEFAULT</code></a> and <a class="link" href="<API key>.html#G-NORMALIZE-ALL:CAPS"><code class="literal">G_NORMALIZE_ALL</code></a>,
but returned a result with composed forms rather
than a maximally decomposed form. This is often
useful if you intend to convert the string to
a legacy encoding or pass it to a system with
less capable Unicode handling.</p>
<div class="refsect3">
<a name="id-1.5.4.7.55.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>mode</p></td>
<td class="<API key>"><p>the type of normalization to perform.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.55.8"></a><h4>Returns</h4>
<p> a newly allocated string, that is the
normalized form of <em class="parameter"><code>str</code></em>
, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if <em class="parameter"><code>str</code></em>
is not
valid UTF-8.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-collate"></a><h3>g_utf8_collate ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
g_utf8_collate (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str1</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str2</code></em>);</pre>
<p>Compares two strings for ordering using the linguistically
correct rules for the <a class="link" href="glib-running.html#setlocale" title="Locale">current locale</a>.
When sorting a large number of strings, it will be significantly
faster to obtain collation keys with <a class="link" href="<API key>.html#g-utf8-collate-key" title="g_utf8_collate_key ()"><code class="function">g_utf8_collate_key()</code></a> and
compare the keys with <code class="function">strcmp()</code> when sorting instead of sorting
the original strings.</p>
<div class="refsect3">
<a name="id-1.5.4.7.56.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str1</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>str2</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.56.6"></a><h4>Returns</h4>
<p> < 0 if <em class="parameter"><code>str1</code></em>
compares before <em class="parameter"><code>str2</code></em>
,
0 if they compare equal, > 0 if <em class="parameter"><code>str1</code></em>
compares after <em class="parameter"><code>str2</code></em>
.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-collate-key"></a><h3>g_utf8_collate_key ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf8_collate_key (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Converts a string into a collation key that can be compared
with other collation keys produced by the same function using
<code class="function">strcmp()</code>. </p>
<p>The results of comparing the collation keys of two strings
with <code class="function">strcmp()</code> will always be the same as comparing the two
original keys with <a class="link" href="<API key>.html#g-utf8-collate" title="g_utf8_collate ()"><code class="function">g_utf8_collate()</code></a>.</p>
<p>Note that this function depends on the <a class="link" href="glib-running.html#setlocale" title="Locale">current locale</a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.57.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.57.8"></a><h4>Returns</h4>
<p> a newly allocated string. This string should
be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when you are done with it.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>"></a><h3><API key> ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
<API key> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> len</code></em>);</pre>
<p>Converts a string into a collation key that can be compared
with other collation keys produced by the same function using <code class="function">strcmp()</code>. </p>
<p>In order to sort filenames correctly, this function treats the dot '.'
as a special case. Most dictionary orderings seem to consider it
insignificant, thus producing the ordering "event.c" "eventgenerator.c"
"event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
would like to treat numbers intelligently so that "file1" "file10" "file5"
is sorted as "file1" "file5" "file10".</p>
<p>Note that this function depends on the <a class="link" href="glib-running.html#setlocale" title="Locale">current locale</a>.</p>
<div class="refsect3">
<a name="id-1.5.4.7.58.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>length of <em class="parameter"><code>str</code></em>
, in bytes, or -1 if <em class="parameter"><code>str</code></em>
is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.58.8"></a><h4>Returns</h4>
<p> a newly allocated string. This string should
be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when you are done with it.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-8.html#api-index-2.8">2.8</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-to-utf16"></a><h3>g_utf8_to_utf16 ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="returnvalue">gunichar2</span></a> *
g_utf8_to_utf16 (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from UTF-8 to UTF-16. A 0 character will be
added to the result after the converted text.</p>
<div class="refsect3">
<a name="id-1.5.4.7.59.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length (number of bytes) of <em class="parameter"><code>str</code></em>
to use.
If <em class="parameter"><code>len</code></em>
< 0, then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of bytes read,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. If <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> will be
returned in case <em class="parameter"><code>str</code></em>
contains a trailing partial character. If
an error occurs then the index of the invalid input is stored here. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a>
written, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value stored here does not include the
trailing 0. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.59.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UTF-16 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-to-ucs4"></a><h3>g_utf8_to_ucs4 ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
g_utf8_to_ucs4 (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from UTF-8 to a 32-bit fixed width
representation as UCS-4. A trailing 0 character will be added to the
string after the converted text.</p>
<div class="refsect3">
<a name="id-1.5.4.7.60.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>str</code></em>
to use, in bytes. If <em class="parameter"><code>len</code></em>
< 0,
then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of bytes read, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
If <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> will be
returned in case <em class="parameter"><code>str</code></em>
contains a trailing partial
character. If an error occurs then the index of the
invalid input is stored here. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of characters
written or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value here stored does not include the
trailing 0 character. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.60.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UCS-4 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf8-to-ucs4-fast"></a><h3>g_utf8_to_ucs4_fast ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
g_utf8_to_ucs4_fast (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>);</pre>
<p>Convert a string from UTF-8 to a 32-bit fixed width
representation as UCS-4, assuming valid UTF-8 input.
This function is roughly twice as fast as <a class="link" href="<API key>.html#g-utf8-to-ucs4" title="g_utf8_to_ucs4 ()"><code class="function">g_utf8_to_ucs4()</code></a>
but does no error checking on the input. A trailing 0 character
will be added to the string after the converted text.</p>
<div class="refsect3">
<a name="id-1.5.4.7.61.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-8 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length of <em class="parameter"><code>str</code></em>
to use, in bytes. If <em class="parameter"><code>len</code></em>
< 0,
then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store the number of
characters in the result, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.61.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UCS-4 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf16-to-ucs4"></a><h3>g_utf16_to_ucs4 ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="returnvalue">gunichar</span></a> *
g_utf16_to_ucs4 (<em class="parameter"><code>const <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from UTF-16 to UCS-4. The result will be
nul-terminated.</p>
<div class="refsect3">
<a name="id-1.5.4.7.62.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-16 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length (number of <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a>) of <em class="parameter"><code>str</code></em>
to use.
If <em class="parameter"><code>len</code></em>
< 0, then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of words read,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. If <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> will be
returned in case <em class="parameter"><code>str</code></em>
contains a trailing partial character. If
an error occurs then the index of the invalid input is stored here. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of characters
written, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value stored here does not include the trailing
0 character. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.62.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UCS-4 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-utf16-to-utf8"></a><h3>g_utf16_to_utf8 ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_utf16_to_utf8 (<em class="parameter"><code>const <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from UTF-16 to UTF-8. The result will be
terminated with a 0 byte.</p>
<p>Note that the input is expected to be already in native endianness,
an initial byte-order-mark character is not handled specially.
<a class="link" href="<API key>.html#g-convert" title="g_convert ()"><code class="function">g_convert()</code></a> can be used to convert a byte buffer of UTF-16 data of
ambiguous endianess.</p>
<p>Further note that this function does not validate the result
string; it may e.g. include embedded NUL characters. The only
validation done by this function is to ensure that the input can
be correctly interpreted as UTF-16, i.e. it doesn't contain
things unpaired surrogates.</p>
<div class="refsect3">
<a name="id-1.5.4.7.63.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UTF-16 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length (number of <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a>) of <em class="parameter"><code>str</code></em>
to use.
If <em class="parameter"><code>len</code></em>
< 0, then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of words read,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. If <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, then <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> will be
returned in case <em class="parameter"><code>str</code></em>
contains a trailing partial character. If
an error occurs then the index of the invalid input is stored here. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of bytes written,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value stored here does not include the trailing 0 byte. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.63.8"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UTF-8 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-ucs4-to-utf16"></a><h3>g_ucs4_to_utf16 ()</h3>
<pre class="programlisting"><a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="returnvalue">gunichar2</span></a> *
g_ucs4_to_utf16 (<em class="parameter"><code>const <a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from UCS-4 to UTF-16. A 0 character will be
added to the result after the converted text.</p>
<div class="refsect3">
<a name="id-1.5.4.7.64.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UCS-4 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length (number of characters) of <em class="parameter"><code>str</code></em>
to use.
If <em class="parameter"><code>len</code></em>
< 0, then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of bytes read,
or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. If an error occurs then the index of the invalid input
is stored here. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of <a class="link" href="<API key>.html#gunichar2" title="gunichar2"><span class="type">gunichar2</span></a>
written, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value stored here does not include the
trailing 0. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.64.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UTF-16 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-ucs4-to-utf8"></a><h3>g_ucs4_to_utf8 ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_ucs4_to_utf8 (<em class="parameter"><code>const <a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> *str</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> len</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_read</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#glong" title="glong"><span class="type">glong</span></a> *items_written</code></em>,
<em class="parameter"><code><a class="link" href="<API key>.html#GError" title="struct GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Convert a string from a 32-bit fixed width representation as UCS-4.
to UTF-8. The result will be terminated with a 0 byte.</p>
<div class="refsect3">
<a name="id-1.5.4.7.65.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="<API key>"><p>a UCS-4 encoded string</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>len</p></td>
<td class="<API key>"><p>the maximum length (number of characters) of <em class="parameter"><code>str</code></em>
to use.
If <em class="parameter"><code>len</code></em>
< 0, then the string is nul-terminated.</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items_read</p></td>
<td class="<API key>"><p> location to store number of characters
read, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>items_written</p></td>
<td class="<API key>"><p> location to store number of bytes
written or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. The value here stored does not include the
trailing 0 byte. </p></td>
<td class="<API key>"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="<API key>"><p>location to store the error occurring, or <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore
errors. Any of the errors in <a class="link" href="<API key>.html#GConvertError" title="enum GConvertError"><span class="type">GConvertError</span></a> other than
<a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a> may occur.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.65.6"></a><h4>Returns</h4>
<p> a pointer to a newly allocated UTF-8 string.
This value must be freed with <a class="link" href="<API key>.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>. If an error occurs,
<a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned and <em class="parameter"><code>error</code></em>
set. In that case, <em class="parameter"><code>items_read</code></em>
will be set to the position of the first invalid input character.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-unichar-to-utf8"></a><h3>g_unichar_to_utf8 ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
g_unichar_to_utf8 (<em class="parameter"><code><a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a> c</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *outbuf</code></em>);</pre>
<p>Converts a single character to UTF-8.</p>
<div class="refsect3">
<a name="id-1.5.4.7.66.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>c</p></td>
<td class="<API key>"><p>a Unicode character code</p></td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="parameter_name"><p>outbuf</p></td>
<td class="<API key>"><p>output buffer, must have at least 6 bytes of space.
If <a class="link" href="<API key>.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the length will be computed and returned
and nothing will be written to <em class="parameter"><code>outbuf</code></em>
.</p></td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.4.7.66.6"></a><h4>Returns</h4>
<p> number of bytes written</p>
</div>
</div>
</div>
<div class="refsect1">
<a name="<API key>.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="gunichar"></a><h3>gunichar</h3>
<pre class="programlisting">typedef guint32 gunichar;
</pre>
<p>A type which can hold any UTF-32 or UCS-4 character code,
also known as a Unicode code point.</p>
<p>If you want to produce the UTF-8 representation of a <a class="link" href="<API key>.html#gunichar" title="gunichar"><span class="type">gunichar</span></a>,
use <a class="link" href="<API key>.html#g-ucs4-to-utf8" title="g_ucs4_to_utf8 ()"><code class="function">g_ucs4_to_utf8()</code></a>. See also <a class="link" href="<API key>.html#g-utf8-to-ucs4" title="g_utf8_to_ucs4 ()"><code class="function">g_utf8_to_ucs4()</code></a> for the reverse
process.</p>
<p>To print/scan values of this type as integer, use
<a class="link" href="glib-Basic-Types.html#G-GINT32-MODIFIER:CAPS" title="G_GINT32_MODIFIER"><code class="literal">G_GINT32_MODIFIER</code></a> and/or <a class="link" href="glib-Basic-Types.html#G-GUINT32-FORMAT:CAPS" title="G_GUINT32_FORMAT"><code class="literal">G_GUINT32_FORMAT</code></a>.</p>
<p>The notation to express a Unicode code point in running text is
as a hexadecimal number with four to six digits and uppercase
letters, prefixed by the string "U+". Leading zeros are omitted,
unless the code point would have fewer than four hexadecimal digits.
For example, "U+0041 LATIN CAPITAL LETTER A". To print a code point
in the U+-notation, use the format string "U+%04"G_GINT32_FORMAT"X".
To scan, use the format string "U+%06"G_GINT32_FORMAT"X".</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3</pre></td>
<td class="listing_code"><pre class="programlisting">gunichar c<span class="gtkdoc opt">;</span>
<span class="function">sscanf</span> <span class="gtkdoc opt">(</span><span class="string">"U+0041"</span><span class="gtkdoc opt">,</span> <span class="string">"U+%06"</span>G_GINT32_FORMAT<span class="string">"X"</span><span class="gtkdoc opt">, &</span>c<span class="gtkdoc opt">)</span>
<span class="function"><a href="<API key>.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">"Read U+%04"</span>G_GINT32_FORMAT<span class="string">"X"</span><span class="gtkdoc opt">,</span> c<span class="gtkdoc opt">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
</div>
<hr>
<div class="refsect2">
<a name="gunichar2"></a><h3>gunichar2</h3>
<pre class="programlisting">typedef guint16 gunichar2;
</pre>
<p>A type which can hold any UTF-16 code
point<footnote id="<API key>">UTF-16 also has so called
<firstterm>surrogate pairs</firstterm> to encode characters beyond
the BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored
in a single gunichar2 field, but all GLib functions accepting gunichar2
arrays will correctly interpret surrogate pairs.</footnote>.</p>
<p>To print/scan values of this type to/from text you need to convert
to/from UTF-8, using <a class="link" href="<API key>.html#g-utf16-to-utf8" title="g_utf16_to_utf8 ()"><code class="function">g_utf16_to_utf8()</code></a>/<a class="link" href="<API key>.html#g-utf8-to-utf16" title="g_utf8_to_utf16 ()"><code class="function">g_utf8_to_utf16()</code></a>.</p>
<p>To print/scan values of this type as integer, use
<a class="link" href="glib-Basic-Types.html#G-GINT16-MODIFIER:CAPS" title="G_GINT16_MODIFIER"><code class="literal">G_GINT16_MODIFIER</code></a> and/or <a class="link" href="glib-Basic-Types.html#G-GUINT16-FORMAT:CAPS" title="G_GUINT16_FORMAT"><code class="literal">G_GUINT16_FORMAT</code></a>.</p>
</div>
<hr>
<div class="refsect2">
<a name="<API key>:CAPS"></a><h3><API key></h3>
<pre class="programlisting">#define <API key> 18 /* codepoints */
</pre>
<p>The maximum length (in codepoints) of a compatibility or canonical
decomposition of a single Unicode character.</p>
<p>This is as defined by Unicode 6.1.</p>
<p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GUnicodeType"></a><h3>enum GUnicodeType</h3>
<p>These are the possible character classifications from the
Unicode specification.
See <ulink url="http:
<div class="refsect3">
<a name="id-1.5.4.8.5.4"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="G-UNICODE-CONTROL:CAPS"></a>G_UNICODE_CONTROL</p></td>
<td class="<API key>">
<p>General category "Other, Control" (Cc)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-UNICODE-FORMAT:CAPS"></a>G_UNICODE_FORMAT</p></td>
<td class="<API key>">
<p>General category "Other, Format" (Cf)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Other, Not Assigned" (Cn)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Other, Private Use" (Co)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-UNICODE-SURROGATE:CAPS"></a>G_UNICODE_SURROGATE</p></td>
<td class="<API key>">
<p>General category "Other, Surrogate" (Cs)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Letter, Lowercase" (Ll)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Letter, Modifier" (Lm)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Letter, Other" (Lo)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Letter, Titlecase" (Lt)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Letter, Uppercase" (Lu)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Mark, Spacing" (Mc)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Mark, Enclosing" (Me)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Mark, Nonspacing" (Mn)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Number, Decimal Digit" (Nd)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Number, Letter" (Nl)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Number, Other" (No)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Connector" (Pc)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Dash" (Pd)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Close" (Pe)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Final quote" (Pf)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Initial quote" (Pi)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Other" (Po)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Punctuation, Open" (Ps)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Symbol, Currency" (Sc)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Symbol, Modifier" (Sk)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Symbol, Math" (Sm)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Symbol, Other" (So)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Separator, Line" (Zl)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Separator, Paragraph" (Zp)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>General category "Separator, Space" (Zs)</p>
</td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="<API key>:CAPS"></a><h3><API key></h3>
<pre class="programlisting">#define <API key> <API key>
</pre>
<div class="warning">
<p><code class="literal"><API key></code> has been deprecated since version 2.30 and should not be used in newly-written code.</p>
<p>Use <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a>.</p>
</div>
<p>Older name for <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a>.</p>
</div>
<hr>
<div class="refsect2">
<a name="GUnicodeBreakType"></a><h3>enum GUnicodeBreakType</h3>
<p>These are the possible line break classifications.</p>
<p>Since new unicode versions may add new types here, applications should be ready
to handle unknown values. They may be regarded as <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a>.</p>
<p>See <ulink url="http:
<div class="refsect3">
<a name="id-1.5.4.8.7.6"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mandatory Break (BK)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Carriage Return (CR)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Line Feed (LF)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Attached Characters and Combining Marks (CM)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Surrogates (SG)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Zero Width Space (ZW)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Inseparable (IN)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Non-breaking ("Glue") (GL)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Contingent Break Opportunity (CB)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Space (SP)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Break Opportunity After (BA)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Break Opportunity Before (BB)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Break Opportunity Before and After (B2)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hyphen (HY)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Nonstarter (NS)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Opening Punctuation (OP)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Closing Punctuation (CL)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ambiguous Quotation (QU)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Exclamation/Interrogation (EX)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ideographic (ID)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Numeric (NU)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Infix Separator (Numeric) (IS)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Symbols Allowing Break After (SY)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ordinary Alphabetic and Symbol Characters (AL)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Prefix (Numeric) (PR)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Postfix (Numeric) (PO)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Complex Content Dependent (South East Asian) (SA)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ambiguous (Alphabetic or Ideographic) (AI)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Unknown (XX)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Next Line (NL)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Word Joiner (WJ)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul L Jamo (JL)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul V Jamo (JV)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul T Jamo (JT)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul LV Syllable (H2)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul LVT Syllable (H3)</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Closing Parenthesis (CP). Since 2.28</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Conditional Japanese Starter (CJ). Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hebrew Letter (HL). Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Regional Indicator (RI). Since: 2.36</p>
</td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GUnicodeScript"></a><h3>enum GUnicodeScript</h3>
<p>The <a class="link" href="<API key>.html#GUnicodeScript" title="enum GUnicodeScript"><span class="type">GUnicodeScript</span></a> enumeration identifies different writing
systems. The values correspond to the names as defined in the
Unicode standard. The enumeration has been added in GLib 2.14,
and is interchangeable with <span class="type">PangoScript</span>.</p>
<p>Note that new types may be added in the future. Applications
should be ready to handle unknown values.
See <ulink
url="http:
<span class="type">24</span>: Script names</ulink>.</p>
<div class="refsect3">
<a name="id-1.5.4.8.8.5"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> a value never returned from <a class="link" href="<API key>.html#<API key>" title="<API key> ()"><code class="function"><API key>()</code></a></p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>a character used by multiple different scripts</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>a mark glyph that takes its script from the
base glyph to which it is attached</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Arabic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Armenian</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Bengali</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Bopomofo</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Cherokee</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Coptic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Cyrillic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Deseret</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Devanagari</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ethiopic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Georgian</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Gothic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Greek</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Gujarati</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Gurmukhi</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Han</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hangul</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hebrew</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hiragana</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Kannada</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Katakana</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Khmer</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Lao</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Latin</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Malayalam</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mongolian</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Myanmar</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ogham</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Old Italic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Oriya</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Runic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Sinhala</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Syriac</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tamil</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Telugu</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Thaana</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Thai</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tibetan</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Canadian Aboriginal</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-UNICODE-SCRIPT-YI:CAPS"></a>G_UNICODE_SCRIPT_YI</p></td>
<td class="<API key>">
<p>Yi</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tagalog</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Hanunoo</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Buhid</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tagbanwa</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Braille</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Cypriot</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Limbu</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Osmanya</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Shavian</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Linear B</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tai Le</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ugaritic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> New Tai Lue</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Buginese</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Glagolitic</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tifinagh</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Syloti Nagri</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Old Persian</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Kharoshthi</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>an unassigned code point</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Balinese</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Cuneiform</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Phoenician</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Phags-pa</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>N'Ko</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Kayah Li. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Lepcha. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Rejang. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Sundanese. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Saurashtra. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Cham. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Ol Chiki. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Vai. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Carian. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Lycian. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Lydian. Since 2.16.3</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Avestan. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Bamum. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Egyptian Hieroglpyhs. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Imperial Aramaic. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Inscriptional Pahlavi. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Inscriptional Parthian. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Javanese. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Kaithi. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Lisu. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Meetei Mayek. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p> Old South Arabian. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Old Turkic. Since 2.28</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Samaritan. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tai Tham. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tai Viet. Since 2.26</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Batak. Since 2.28</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Brahmi. Since 2.28</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mandaic. Since 2.28</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Chakma. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Meroitic Cursive. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Meroitic Hieroglyphs. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Miao. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Sharada. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Sora Sompeng. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Takri. Since: 2.32</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Bassa. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Caucasian Albanian. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Duployan. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Elbasan. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Grantha. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Kjohki. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Khudawadi, Sindhi. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Linear A. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mahajani. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Manichaean. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mende Kikakui. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Modi. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Mro. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Nabataean. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Old North Arabian. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Old Permic. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Pahawh Hmong. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Palmyrene. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Pau Cin Hau. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Psalter Pahlavi. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Siddham. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Tirhuta. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>Warang Citi. Since: 2.42</p>
</td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GNormalizeMode"></a><h3>enum GNormalizeMode</h3>
<p>Defines how a Unicode string is transformed in a canonical
form, standardizing such issues as whether a character with
an accent is represented as a base character and combining
accent or as a single precomposed character. Unicode strings
should generally be normalized before comparing them.</p>
<div class="refsect3">
<a name="id-1.5.4.8.9.4"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="<API key>">
<col width="200px" class="<API key>">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-DEFAULT:CAPS"></a>G_NORMALIZE_DEFAULT</p></td>
<td class="<API key>">
<p>standardize differences that do not affect the
text content, such as the above-mentioned accent representation</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-NFD:CAPS"></a>G_NORMALIZE_NFD</p></td>
<td class="<API key>">
<p>another name for <a class="link" href="<API key>.html#G-NORMALIZE-DEFAULT:CAPS"><code class="literal">G_NORMALIZE_DEFAULT</code></a></p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>like <a class="link" href="<API key>.html#G-NORMALIZE-DEFAULT:CAPS"><code class="literal">G_NORMALIZE_DEFAULT</code></a>, but with
composed forms rather than a maximally decomposed form</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-NFC:CAPS"></a>G_NORMALIZE_NFC</p></td>
<td class="<API key>">
<p>another name for <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a></p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-ALL:CAPS"></a>G_NORMALIZE_ALL</p></td>
<td class="<API key>">
<p>beyond <a class="link" href="<API key>.html#G-NORMALIZE-DEFAULT:CAPS"><code class="literal">G_NORMALIZE_DEFAULT</code></a> also standardize the
"compatibility" characters in Unicode, such as SUPERSCRIPT THREE
to the standard forms (in this case DIGIT THREE). Formatting
information may be lost but for most text operations such
characters should be considered the same</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-NFKD:CAPS"></a>G_NORMALIZE_NFKD</p></td>
<td class="<API key>">
<p>another name for <a class="link" href="<API key>.html#G-NORMALIZE-ALL:CAPS"><code class="literal">G_NORMALIZE_ALL</code></a></p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="<API key>:CAPS"></a><API key></p></td>
<td class="<API key>">
<p>like <a class="link" href="<API key>.html#G-NORMALIZE-ALL:CAPS"><code class="literal">G_NORMALIZE_ALL</code></a>, but with composed
forms rather than a maximally decomposed form</p>
</td>
<td class="<API key>"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-NORMALIZE-NFKC:CAPS"></a>G_NORMALIZE_NFKC</p></td>
<td class="<API key>">
<p>another name for <a class="link" href="<API key>.html#<API key>:CAPS"><code class="literal"><API key></code></a></p>
</td>
<td class="<API key>"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="refsect1">
<a name="<API key>.see-also"></a><h2>See Also</h2>
<p>g_locale_to_utf8(), <a class="link" href="<API key>.html#g-locale-from-utf8" title="g_locale_from_utf8 ()"><code class="function">g_locale_from_utf8()</code></a></p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.24</div>
</body>
</html>
|
package org.telegram.android.views.dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.AbsListView;
import android.widget.<API key>;
import android.widget.ListAdapter;
import android.widget.ListView;
import org.telegram.android.R;
import org.telegram.android.TelegramApplication;
import org.telegram.android.log.Logger;
import org.telegram.android.ui.FontController;
import org.telegram.android.ui.TextUtil;
public class <API key> extends ListView {
private static final String TAG = "<API key>";
private static final int DELTA = 26;
private static final long ANIMATION_DURATION = 200;
private static final int ACTIVATE_DELTA = 50;
private static final long UI_TIMEOUT = 900;
private TelegramApplication application;
private String visibleDate = null;
private int <API key> = -1;
private int timeDivMeasure;
private String visibleDateNext = null;
private int <API key> = -1;
private int timeDivMeasureNext;
private TextPaint timeDivPaint;
private Drawable serviceDrawable;
private Rect servicePadding;
private int offset;
private int oldHeight;
private long animationTime = 0;
private boolean isTimeVisible = false;
private Handler handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
Logger.d(TAG, "notify");
if (msg.what == 0) {
if (isTimeVisible) {
isTimeVisible = false;
scrollDistance = 0;
animationTime = SystemClock.uptimeMillis();
}
invalidate();
} else if (msg.what == 1) {
isTimeVisible = true;
invalidate();
}
}
};
private int scrollDistance;
public <API key>(Context context) {
super(context);
init();
}
public <API key>(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public <API key>(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public VisibleViewItem[] dump() {
int childCount = getChildCount();
int idCount = 0;
int headerCount = 0;
for (int i = 0; i < childCount; i++) {
int index = <API key>() + i;
long id = getItemIdAtPosition(index);
if (id > 0) {
idCount++;
} else {
headerCount++;
}
}
VisibleViewItem[] res = new VisibleViewItem[idCount];
int resIndex = 0;
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
int index = <API key>() + i;
long id = getItemIdAtPosition(index);
if (id > 0) {
int top = ((v == null) ? 0 : v.getTop()) - getPaddingTop();
res[resIndex++] = new VisibleViewItem(index + headerCount, top, id);
}
}
return res;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
VisibleViewItem[] items = null;
if (changed) {
items = dump();
}
super.onLayout(changed, l, t, r, b);
if (changed) {
final int changeDelta = (b - t) - oldHeight;
if (changeDelta < 0 && items.length > 0) {
final VisibleViewItem item = items[items.length - 1];
setSelectionFromTop(item.getIndex(), item.getTop() + changeDelta);
post(new Runnable() {
@Override
public void run() {
setSelectionFromTop(item.getIndex(), item.getTop() + changeDelta);
}
});
}
}
oldHeight = b - t;
}
private void init() {
application = (TelegramApplication) getContext().<API key>();
setOnScrollListener(new ScrollListener());
serviceDrawable = getResources().getDrawable(R.drawable.st_bubble_service);
servicePadding = new Rect();
serviceDrawable.getPadding(servicePadding);
timeDivPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
timeDivPaint.setTextSize(getSp(15));
timeDivPaint.setColor(0xffFFFFFF);
timeDivPaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
}
private void drawTime(Canvas canvas, int drawOffset, float alpha, boolean first) {
int w = first ? timeDivMeasure : timeDivMeasureNext;
serviceDrawable.setAlpha((int) (alpha * 255));
timeDivPaint.setAlpha((int) (alpha * 255));
serviceDrawable.setBounds(
getWidth() / 2 - w / 2 - servicePadding.left,
getPx(44 - 8) - serviceDrawable.getIntrinsicHeight() + drawOffset,
getWidth() / 2 + w / 2 + servicePadding.right,
getPx(44 - 8) + drawOffset);
serviceDrawable.draw(canvas);
canvas.drawText(first ? visibleDate : visibleDateNext, getWidth() / 2 - w / 2, getPx(44 - 17) + drawOffset, timeDivPaint);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
boolean isAnimated = false;
boolean isShown;
if (isTimeVisible) {
isShown = isTimeVisible;
} else {
isShown = SystemClock.uptimeMillis() - animationTime < ANIMATION_DURATION;
}
if (isShown) {
float animationRatio = 1.0f;
if (SystemClock.uptimeMillis() - animationTime < ANIMATION_DURATION) {
isAnimated = true;
animationRatio = (SystemClock.uptimeMillis() - animationTime) / ((float) ANIMATION_DURATION);
if (animationRatio > 1.0f) {
animationRatio = 1.0f;
}
if (!isTimeVisible) {
animationRatio = 1.0f - animationRatio;
}
}
int drawOffset = offset;
if (offset == 0) {
if (visibleDate != null) {
drawTime(canvas, drawOffset, 1.0f * animationRatio, true);
}
} else {
float ratio = Math.min(1.0f, Math.abs(offset / (float) getPx(DELTA)));
if (visibleDateNext != null) {
drawTime(canvas, drawOffset + getPx(DELTA), ratio * animationRatio, false);
}
if (visibleDate != null) {
drawTime(canvas, drawOffset, (1.0f - ratio) * animationRatio, true);
}
}
}
if (isAnimated) {
invalidate();
}
}
protected int getPx(float dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
}
protected int getSp(float sp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, getResources().getDisplayMetrics());
}
private class ScrollListener implements OnScrollListener {
private int state = SCROLL_STATE_IDLE;
private int lastVisibleItem = -1;
private int lastTop = 0;
private int lastScrollY = -1;
@Override
public void <API key>(AbsListView absListView, int i) {
if (i == SCROLL_STATE_FLING || i == <API key>) {
handler.removeMessages(0);
}
if (i == SCROLL_STATE_IDLE) {
handler.removeMessages(0);
handler.<API key>(0, UI_TIMEOUT);
}
state = i;
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// if (lastScrollY == -1) {
// lastScrollY = getScrollY();
// } else if (lastScrollY != getScrollY()) {
// lastScrollY = getScrollY();
// application.getImageController().doPause();
if (lastVisibleItem == -1 || lastVisibleItem != firstVisibleItem || state == SCROLL_STATE_IDLE) {
lastVisibleItem = firstVisibleItem;
lastTop = 0;
View view = getChildAt(0 + getHeaderViewsCount());
if (view != null) {
lastTop = view.getTop();
}
} else {
View view = getChildAt(0 + getHeaderViewsCount());
if (view != null) {
int topDelta = Math.abs(view.getTop() - lastTop);
lastTop = view.getTop();
scrollDistance += topDelta;
if (scrollDistance > getPx(ACTIVATE_DELTA) && !isTimeVisible) {
isTimeVisible = true;
animationTime = SystemClock.uptimeMillis();
handler.removeMessages(0);
}
}
}
// handler.removeMessages(0);
ListAdapter adapter = getAdapter();
if (adapter instanceof <API key>) {
adapter = ((<API key>) adapter).getWrappedAdapter();
}
if (adapter instanceof ConversationAdapter) {
if (firstVisibleItem == 0) {
visibleDate = null;
visibleDateNext = null;
<API key> = -1;
<API key> = -1;
View view = getChildAt(1);
if (view != null) {
offset = Math.min(view.getTop() - getPx(DELTA), 0);
if (adapter.getCount() > 0) {
int date = ((ConversationAdapter) adapter).getItemDate(0);
visibleDateNext = TextUtil.formatDateLong(date);
timeDivMeasureNext = (int) timeDivPaint.measureText(visibleDateNext);
}
}
return;
}
int <API key> = firstVisibleItem - getHeaderViewsCount();
if (<API key> >= 0 && <API key> < adapter.getCount()) {
int date = ((ConversationAdapter) adapter).getItemDate(<API key>);
int prevDate = date;
boolean isSameDays = true;
if (<API key> > 0 && <API key> + 2 < adapter.getCount()) {
prevDate = ((ConversationAdapter) adapter).getItemDate(<API key> + 1);
isSameDays = TextUtil.areSameDays(prevDate, date);
}
if (isSameDays) {
offset = 0;
} else {
View view = getChildAt(firstVisibleItem - <API key>);
if (view != null) {
offset = Math.min(view.getTop() - getPx(DELTA), 0);
}
if (!TextUtil.areSameDays(prevDate, System.currentTimeMillis() / 1000)) {
if (!TextUtil.areSameDays(prevDate, <API key>)) {
<API key> = prevDate;
visibleDateNext = TextUtil.formatDateLong(prevDate);
timeDivMeasureNext = (int) timeDivPaint.measureText(visibleDateNext);
}
} else {
visibleDateNext = null;
<API key> = -1;
}
}
if (!TextUtil.areSameDays(date, System.currentTimeMillis() / 1000)) {
if (!TextUtil.areSameDays(date, <API key>)) {
<API key> = date;
visibleDate = TextUtil.formatDateLong(date);
timeDivMeasure = (int) timeDivPaint.measureText(visibleDate);
}
} else {
visibleDate = null;
<API key> = -1;
}
}
}
}
}
}
|
#pragma once
#include <GLUL/Config.h>
#include <GLUL/Input/Event.h>
#include <GLUL/Input/Types.h>
#include <glm/vec2.hpp>
namespace GLUL {
namespace Input {
class GLUL_API MouseButtonEvent : public Event {
public:
MouseButtonEvent();
MouseButtonEvent(MouseButton button, Action action, float x, float y);
MouseButtonEvent(MouseButton button, Action action, const glm::vec2& position);
float getX() const;
float getY() const;
const glm::vec2& getPosition() const;
MouseButton getMouseButton() const;
Action getAction() const;
void setX(float x);
void setY(float y);
void setPosition(const glm::vec2& position);
void setMouseButton(MouseButton button);
void setAction(Action action);
public:
MouseButtonEvent* asMouseButtonEvent();
const MouseButtonEvent* asMouseButtonEvent() const;
private:
void _abstract() { }
MouseButton _button;
Action _action;
glm::vec2 _position;
};
}
}
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>FreeType-2.5.0 API Reference</title>
<style type="text/css">
body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
color: #000000;
background: #FFFFFF; }
p { text-align: justify; }
h1 { text-align: center; }
li { text-align: justify; }
td { padding: 0 0.5em 0 0.5em; }
td.left { padding: 0 0.5em 0 0.5em;
text-align: left; }
a:link { color: #0000EF; }
a:visited { color: #51188E; }
a:hover { color: #FF0000; }
span.keyword { font-family: monospace;
text-align: left;
white-space: pre;
color: darkblue; }
pre.colored { color: blue; }
ul.empty { list-style-type: none; }
</style>
</head>
<body>
<table align=center><tr><td><font size=-1>[<a href="ft2-index.html">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-1>[<a href="ft2-toc.html">TOC</a>]</font></td></tr></table>
<center><h1>FreeType-2.5.0 API Reference</h1></center>
<center><h1>
LCD Filtering
</h1></center>
<h2>Synopsis</h2>
<table align=center cellspacing=5 cellpadding=0 border=0>
<tr><td></td><td><a href="#FT_LcdFilter">FT_LcdFilter</a></td><td></td><td><a href="#<API key>"><API key></a></td></tr>
<tr><td></td><td><a href="#<API key>"><API key></a></td><td></td><td></td></tr>
</table><br><br>
<table align=center width="87%"><tr><td>
<p>The <a href="ft2-lcd_filtering.html#<API key>"><API key></a> API can be used to specify a low-pass filter which is then applied to LCD-optimized bitmaps generated through <a href="ft2-base_interface.html#FT_Render_Glyph">FT_Render_Glyph</a>. This is useful to reduce color fringes which would occur with unfiltered rendering.</p>
<p>Note that no filter is active by default, and that this function is <b>not</b> implemented in default builds of the library. You need to #define <API key> in your ‘ftoption.h’ file in order to activate it.</p>
<p>FreeType generates alpha coverage maps, which are linear by nature. For instance, the value 0x80 in bitmap representation means that (within numerical precision) 0x80/0xff fraction of that pixel is covered by the glyph's outline. The blending function for placing text over a background is</p>
<pre class="colored">
dst = alpha * src + (1 - alpha) * dst ,
</pre>
<p>which is known as OVER. However, when calculating the output of the OVER operator, the source colors should first be transformed to a linear color space, then alpha blended in that space, and transformed back to the output color space.</p>
<p>When linear light blending is used, the default FIR5 filtering weights (as given by <API key>) are no longer optimal, as they have been designed for black on white rendering while lacking gamma correction. To preserve color neutrality, weights for a FIR5 filter should be chosen according to two free parameters ‘a’ and ‘c’, and the FIR weights should be</p>
<pre class="colored">
[a - c, a + c, 2 * a, a + c, a - c] .
</pre>
<p>This formula generates equal weights for all the color primaries across the filter kernel, which makes it colorless. One suggested set of weights is</p>
<pre class="colored">
[0x10, 0x50, 0x60, 0x50, 0x10] ,
</pre>
<p>where ‘a’ has value 0x30 and ‘b’ value 0x20. The weights in filter may have a sum larger than 0x100, which increases coloration slightly but also improves contrast.</p>
</td></tr></table><br>
<table align=center width="75%"><tr><td>
<h4><a name="FT_LcdFilter">FT_LcdFilter</a></h4>
<table align=center width="87%"><tr><td>
Defined in FT_LCD_FILTER_H (freetype/ftlcdfil.h).
</td></tr></table><br>
<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>
<span class="keyword">typedef</span> <span class="keyword">enum</span> FT_LcdFilter_
{
<a href="ft2-lcd_filtering.html#FT_LcdFilter">FT_LCD_FILTER_NONE</a> = 0,
<a href="ft2-lcd_filtering.html#FT_LcdFilter"><API key></a> = 1,
<a href="ft2-lcd_filtering.html#FT_LcdFilter">FT_LCD_FILTER_LIGHT</a> = 2,
<a href="ft2-lcd_filtering.html#FT_LcdFilter"><API key></a> = 16,
FT_LCD_FILTER_MAX /* do not remove */
} <b>FT_LcdFilter</b>;
</pre></table><br>
<table align=center width="87%"><tr><td>
<p>A list of values to identify various types of LCD filters.</p>
</td></tr></table><br>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>values</b></em></td></tr><tr><td>
<p></p>
<table cellpadding=3 border=0>
<tr valign=top><td><b>FT_LCD_FILTER_NONE</b></td><td>
<p>Do not perform filtering. When used with subpixel rendering, this results in sometimes severe color fringes.</p>
</td></tr>
<tr valign=top><td><b><API key></b></td><td>
<p>The default filter reduces color fringes considerably, at the cost of a slight blurriness in the output.</p>
</td></tr>
<tr valign=top><td><b>FT_LCD_FILTER_LIGHT</b></td><td>
<p>The light filter is a variant that produces less blurriness at the cost of slightly more color fringes than the default one. It might be better, depending on taste, your monitor, or your personal vision.</p>
</td></tr>
<tr valign=top><td><b><API key></b></td><td>
<p>This filter corresponds to the original libXft color filter. It provides high contrast output but can exhibit really bad color fringes if glyphs are not extremely well hinted to the pixel grid. In other words, it only works well if the TrueType bytecode interpreter is enabled <b>and</b> high-quality hinted fonts are used.</p>
<p>This filter is only provided for comparison purposes, and might be disabled or stay unsupported in the future.</p>
</td></tr>
</table>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>since</b></em></td></tr><tr><td>
<p>2.3.0</p>
</td></tr></table>
</td></tr></table>
<hr width="75%">
<table align=center width="75%"><tr><td><font size=-2>[<a href="ft2-index.html">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-2>[<a href="ft2-toc.html">TOC</a>]</font></td></tr></table>
<table align=center width="75%"><tr><td>
<h4><a name="<API key>"><API key></a></h4>
<table align=center width="87%"><tr><td>
Defined in FT_LCD_FILTER_H (freetype/ftlcdfil.h).
</td></tr></table><br>
<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>
FT_EXPORT( <a href="ft2-basic_types.html#FT_Error">FT_Error</a> )
<b><API key></b>( <a href="ft2-base_interface.html#FT_Library">FT_Library</a> library,
<a href="ft2-lcd_filtering.html#FT_LcdFilter">FT_LcdFilter</a> filter );
</pre></table><br>
<table align=center width="87%"><tr><td>
<p>This function is used to apply color filtering to LCD decimated bitmaps, like the ones used when calling <a href="ft2-base_interface.html#FT_Render_Glyph">FT_Render_Glyph</a> with <a href="ft2-base_interface.html#FT_Render_Mode">FT_RENDER_MODE_LCD</a> or <a href="ft2-base_interface.html#FT_Render_Mode"><API key></a>.</p>
</td></tr></table><br>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>input</b></em></td></tr><tr><td>
<p></p>
<table cellpadding=3 border=0>
<tr valign=top><td><b>library</b></td><td>
<p>A handle to the target library instance.</p>
</td></tr>
<tr valign=top><td><b>filter</b></td><td>
<p>The filter type.</p>
<p>You can use <a href="ft2-lcd_filtering.html#FT_LcdFilter">FT_LCD_FILTER_NONE</a> here to disable this feature, or <a href="ft2-lcd_filtering.html#FT_LcdFilter"><API key></a> to use a default filter that should work well on most LCD screens.</p>
</td></tr>
</table>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>return</b></em></td></tr><tr><td>
<p>FreeType error code. 0 means success.</p>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>note</b></em></td></tr><tr><td>
<p>This feature is always disabled by default. Clients must make an explicit call to this function with a ‘filter’ value other than <a href="ft2-lcd_filtering.html#FT_LcdFilter">FT_LCD_FILTER_NONE</a> in order to enable it.</p>
<p>Due to <b>PATENTS</b> covering subpixel rendering, this function doesn't do anything except returning ‘<API key>’ if the configuration macro <API key> is not defined in your build of the library, which should correspond to all default builds of FreeType.</p>
<p>The filter affects glyph bitmaps rendered through <a href="ft2-base_interface.html#FT_Render_Glyph">FT_Render_Glyph</a>, <a href="<API key>.html#<API key>"><API key></a>, <a href="ft2-base_interface.html#FT_Load_Glyph">FT_Load_Glyph</a>, and <a href="ft2-base_interface.html#FT_Load_Char">FT_Load_Char</a>.</p>
<p>It does <i>not</i> affect the output of <a href="<API key>.html#FT_Outline_Render">FT_Outline_Render</a> and <a href="<API key>.html#<API key>"><API key></a>.</p>
<p>If this feature is activated, the dimensions of LCD glyph bitmaps are either larger or taller than the dimensions of the corresponding outline with regards to the pixel grid. For example, for <a href="ft2-base_interface.html#FT_Render_Mode">FT_RENDER_MODE_LCD</a>, the filter adds up to 3 pixels to the left, and up to 3 pixels to the right.</p>
<p>The bitmap offset values are adjusted correctly, so clients shouldn't need to modify their layout and glyph positioning code when enabling the filter.</p>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>since</b></em></td></tr><tr><td>
<p>2.3.0</p>
</td></tr></table>
</td></tr></table>
<hr width="75%">
<table align=center width="75%"><tr><td><font size=-2>[<a href="ft2-index.html">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-2>[<a href="ft2-toc.html">TOC</a>]</font></td></tr></table>
<table align=center width="75%"><tr><td>
<h4><a name="<API key>"><API key></a></h4>
<table align=center width="87%"><tr><td>
Defined in FT_LCD_FILTER_H (freetype/ftlcdfil.h).
</td></tr></table><br>
<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>
FT_EXPORT( <a href="ft2-basic_types.html#FT_Error">FT_Error</a> )
<b><API key></b>( <a href="ft2-base_interface.html#FT_Library">FT_Library</a> library,
<span class="keyword">unsigned</span> <span class="keyword">char</span> *weights );
</pre></table><br>
<table align=center width="87%"><tr><td>
<p>Use this function to override the filter weights selected by <a href="ft2-lcd_filtering.html#<API key>"><API key></a>. By default, FreeType uses the quintuple (0x00, 0x55, 0x56, 0x55, 0x00) for FT_LCD_FILTER_LIGHT, and (0x10, 0x40, 0x70, 0x40, 0x10) for <API key> and <API key>.</p>
</td></tr></table><br>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>input</b></em></td></tr><tr><td>
<p></p>
<table cellpadding=3 border=0>
<tr valign=top><td><b>library</b></td><td>
<p>A handle to the target library instance.</p>
</td></tr>
<tr valign=top><td><b>weights</b></td><td>
<p>A pointer to an array; the function copies the first five bytes and uses them to specify the filter weights.</p>
</td></tr>
</table>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>return</b></em></td></tr><tr><td>
<p>FreeType error code. 0 means success.</p>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>note</b></em></td></tr><tr><td>
<p>Due to <b>PATENTS</b> covering subpixel rendering, this function doesn't do anything except returning ‘<API key>’ if the configuration macro <API key> is not defined in your build of the library, which should correspond to all default builds of FreeType.</p>
<p>This function must be called after <a href="ft2-lcd_filtering.html#<API key>"><API key></a> to have any effect.</p>
</td></tr></table>
<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>since</b></em></td></tr><tr><td>
<p>2.4.0</p>
</td></tr></table>
</td></tr></table>
<hr width="75%">
<table align=center width="75%"><tr><td><font size=-2>[<a href="ft2-index.html">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-2>[<a href="ft2-toc.html">TOC</a>]</font></td></tr></table>
</body>
</html>
|
(function(b){"object"===typeof module&&module.exports?(b["default"]=b,module.exports=b):"function"===typeof define&&define.amd?define("highcharts/modules/sunburst",["highcharts"],function(q){b(q);b.Highcharts=q;return b}):b("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(b){function q(b,d,p,D){b.hasOwnProperty(d)||(b[d]=D.apply(null,p))}b=b?b._modules:{};q(b,"Mixins/DrawPoint.js",[],function(){var b=function(b){return"function"===typeof b},d=function(p){var d,u=this,l=u.graphic,w=p.animatableAttribs,
A=p.onComplete,g=p.css,k=p.renderer,V=null===(d=u.series)||void 0===d?void 0:d.options.animation;if(u.shouldDraw())l||(u.graphic=l=k[p.shapeType](p.shapeArgs).add(p.group)),l.css(g).attr(p.attribs).animate(w,p.isNew?!1:V,A);else if(l){var H=function(){u.graphic=l=l.destroy();b(A)&&A()};Object.keys(w).length?l.animate(w,void 0,function(){H()}):H()}};return{draw:d,drawPoint:function(b){(b.attribs=b.attribs||{})["class"]=this.getClassName();d.call(this,b)},isFn:b}});q(b,"Mixins/TreeSeries.js",[b["Core/Color/Color.js"],
b["Core/Utilities.js"]],function(b,d){var p=d.extend,D=d.isArray,u=d.isNumber,l=d.isObject,w=d.merge,A=d.pick;return{getColor:function(g,k){var l=k.index,d=k.mapOptionsToLevel,p=k.parentColor,u=k.parentColorIndex,K=k.series,C=k.colors,I=k.siblings,r=K.points,w=K.chart.options.chart,B;if(g){r=r[g.i];g=d[g.level]||{};if(d=r&&g.colorByPoint){var D=r.index%(C?C.length:w.colorCount);var L=C&&C[D]}if(!K.chart.styledMode){C=r&&r.options.color;w=g&&g.color;if(B=p)B=(B=g&&g.colorVariation)&&"brightness"===
B.key?b.parse(p).brighten(l/I*B.to).get():p;B=A(C,w,L,B,K.color)}var q=A(r&&r.options.colorIndex,g&&g.colorIndex,D,u,k.colorIndex)}return{color:B,colorIndex:q}},getLevelOptions:function(b){var k=null;if(l(b)){k={};var d=u(b.from)?b.from:1;var g=b.levels;var A={};var q=l(b.defaults)?b.defaults:{};D(g)&&(A=g.reduce(function(b,k){if(l(k)&&u(k.level)){var g=w({},k);var r="boolean"===typeof g.levelIsConstant?g.levelIsConstant:q.levelIsConstant;delete g.levelIsConstant;delete g.level;k=k.level+(r?0:d-1);
l(b[k])?p(b[k],g):b[k]=g}return b},{}));g=u(b.to)?b.to:1;for(b=0;b<=g;b++)k[b]=w({},q,l(A[b])?A[b]:{})}return k},setTreeValues:function H(b,d){var k=d.before,l=d.idRoot,u=d.mapIdToNode[l],C=d.points[b.i],w=C&&C.options||{},r=0,q=[];p(b,{levelDynamic:b.level-(("boolean"===typeof d.levelIsConstant?d.levelIsConstant:1)?0:u.level),name:A(C&&C.name,""),visible:l===b.id||("boolean"===typeof d.visible?d.visible:!1)});"function"===typeof k&&(b=k(b,d));b.children.forEach(function(k,l){var u=p({},d);p(u,{index:l,
siblings:b.children.length,visible:b.visible});k=H(k,u);q.push(k);k.visible&&(r+=k.val)});b.visible=0<r||b.visible;k=A(w.value,r);p(b,{children:q,childrenTotal:r,isLeaf:b.visible&&!r,val:k});return b},updateRootId:function(b){if(l(b)){var d=l(b.options)?b.options:{};d=A(b.rootNode,d.rootId,"");l(b.userOptions)&&(b.userOptions.rootId=d);b.rootNode=d}return d}}});q(b,"Mixins/ColorMapSeries.js",[b["Core/Globals.js"],b["Core/Series/Point.js"],b["Core/Utilities.js"]],function(b,d,p){var q=p.defined;return{colorMapPointMixin:{dataLabelOnNull:!0,
isValid:function(){return null!==this.value&&Infinity!==this.value&&-Infinity!==this.value},setState:function(b){d.prototype.setState.call(this,b);this.graphic&&this.graphic.attr({zIndex:"hover"===b?1:0})}},colorMapSeriesMixin:{pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:b.noop,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:b.seriesTypes.column.prototype.pointAttribs,colorAttribs:function(b){var d=
{};q(b.color)&&(d[this.colorProp||"fill"]=b.color);return d}}}});q(b,"Series/TreemapSeries.js",[b["Core/Series/Series.js"],b["Core/Color/Color.js"],b["Mixins/ColorMapSeries.js"],b["Mixins/DrawPoint.js"],b["Core/Globals.js"],b["Mixins/LegendSymbol.js"],b["Core/Series/Point.js"],b["Mixins/TreeSeries.js"],b["Core/Utilities.js"]],function(b,d,p,q,u,l,w,A,g){var k=b.seriesTypes,D=d.parse,H=p.colorMapSeriesMixin;d=u.noop;var Q=A.getColor,N=A.getLevelOptions,K=A.updateRootId,C=g.addEvent,I=g.correctFloat,
r=g.defined,R=g.error,B=g.extend,S=g.fireEvent,L=g.isArray,O=g.isNumber,P=g.isObject,M=g.isString,J=g.merge,T=g.objectEach,f=g.pick,h=g.stableSort,t=u.Series,y=function(a,c,e){e=e||this;T(a,function(b,m){c.call(e,b,m,a)})},E=function(a,c,e){e=e||this;a=c.call(e,a);!1!==a&&E(a,c,e)},n=!1;b.seriesType("treemap","scatter",{allowTraversingTree:!1,animationLimit:250,showInLegend:!1,marker:void 0,colorByPoint:!1,dataLabels:{defer:!1,enabled:!0,formatter:function(){var a=this&&this.point?this.point:{};return M(a.name)?
a.name:""},inside:!0,verticalAlign:"middle"},tooltip:{headerFormat:"",pointFormat:"<b>{point.name}</b>: {point.value}<br/>"},ignoreHiddenPoint:!0,layoutAlgorithm:"sliceAndDice",<API key>:"vertical",<API key>:!1,levelIsConstant:!0,drillUpButton:{position:{align:"right",x:-10,y:10}},traverseUpButton:{position:{align:"right",x:-10,y:10}},borderColor:"#e6e6e6",borderWidth:1,colorKey:"colorValue",opacity:.15,states:{hover:{borderColor:"#999999",brightness:k.heatmap?0:.1,
halo:!1,opacity:.75,shadow:!1}}},{pointArrayMap:["value"],directTouch:!0,optionalAxis:"colorAxis",getSymbol:d,parallelArrays:["x","y","value","colorValue"],colorKey:"colorValue",trackerGroups:["group","dataLabelsGroup"],getListOfParents:function(a,c){a=L(a)?a:[];var e=L(c)?c:[];c=a.reduce(function(a,c,e){c=f(c.parent,"");"undefined"===typeof a[c]&&(a[c]=[]);a[c].push(e);return a},{"":[]});y(c,function(a,c,b){""!==c&&-1===e.indexOf(c)&&(a.forEach(function(a){b[""].push(a)}),delete b[c])});return c},
getTree:function(){var a=this.data.map(function(a){return a.id});a=this.getListOfParents(this.data,a);this.nodeMap={};return this.buildNode("",-1,0,a)},hasData:function(){return!!this.processedXData.length},init:function(a,c){H&&(this.colorAttribs=H.colorAttribs);var e=C(this,"setOptions",function(a){a=a.userOptions;r(a.allowDrillToNode)&&!r(a.allowTraversingTree)&&(a.allowTraversingTree=a.allowDrillToNode,delete a.allowDrillToNode);r(a.drillUpButton)&&!r(a.traverseUpButton)&&(a.traverseUpButton=
a.drillUpButton,delete a.drillUpButton)});t.prototype.init.call(this,a,c);delete this.opacity;this.eventsToUnbind.push(e);this.options.allowTraversingTree&&this.eventsToUnbind.push(C(this,"click",this.onClickDrillToNode))},buildNode:function(a,c,e,b,m){var f=this,x=[],h=f.points[c],d=0,F;(b[a]||[]).forEach(function(c){F=f.buildNode(f.points[c].id,c,e+1,b,a);d=Math.max(F.height+1,d);x.push(F)});c={id:a,i:c,children:x,height:d,level:e,parent:m,visible:!1};f.nodeMap[c.id]=c;h&&(h.node=c);return c},setTreeValues:function(a){var c=
this,e=c.options,b=c.nodeMap[c.rootNode];e="boolean"===typeof e.levelIsConstant?e.levelIsConstant:!0;var m=0,U=[],v=c.points[a.i];a.children.forEach(function(a){a=c.setTreeValues(a);U.push(a);a.ignore||(m+=a.val)});h(U,function(a,c){return(a.sortIndex||0)-(c.sortIndex||0)});var d=f(v&&v.options.value,m);v&&(v.value=d);B(a,{children:U,childrenTotal:m,ignore:!(f(v&&v.visible,!0)&&0<d),isLeaf:a.visible&&!m,levelDynamic:a.level-(e?0:b.level),name:f(v&&v.name,""),sortIndex:f(v&&v.sortIndex,-d),val:d});
return a},<API key>:function(a,c){var e=this,b=e.options,m=e.mapOptionsToLevel[a.level+1],d=f(e[m&&m.layoutAlgorithm]&&m.layoutAlgorithm,b.layoutAlgorithm),v=b.<API key>,h=[];a=a.children.filter(function(a){return!a.ignore});m&&m.<API key>&&(c.direction="vertical"===m.<API key>?0:1);h=e[d](c,a);a.forEach(function(a,b){b=h[b];a.values=J(b,{val:a.childrenTotal,direction:v?1-c.direction:c.direction});a.pointValues=J(b,{x:b.x/e.axisRatio,y:100-
b.y-b.height,width:b.width/e.axisRatio});a.children.length&&e.<API key>(a,a.values)})},setPointValues:function(){var a=this,c=a.xAxis,e=a.yAxis,b=a.chart.styledMode;a.points.forEach(function(f){var m=f.node,x=m.pointValues;m=m.visible;if(x&&m){m=x.height;var d=x.width,h=x.x,t=x.y,n=b?0:(a.pointAttribs(f)["stroke-width"]||0)%2/2;x=Math.round(c.toPixels(h,!0))-n;d=Math.round(c.toPixels(h+d,!0))-n;h=Math.round(e.toPixels(t,!0))-n;m=Math.round(e.toPixels(t+m,!0))-n;f.shapeArgs={x:Math.min(x,
d),y:Math.min(h,m),width:Math.abs(d-x),height:Math.abs(m-h)};f.plotX=f.shapeArgs.x+f.shapeArgs.width/2;f.plotY=f.shapeArgs.y+f.shapeArgs.height/2}else delete f.plotX,delete f.plotY})},setColorRecursive:function(a,c,e,b,f){var m=this,x=m&&m.chart;x=x&&x.options&&x.options.colors;if(a){var d=Q(a,{colors:x,index:b,mapOptionsToLevel:m.mapOptionsToLevel,parentColor:c,parentColorIndex:e,series:m,siblings:f});if(c=m.points[a.i])c.color=d.color,c.colorIndex=d.colorIndex;(a.children||[]).forEach(function(c,
e){m.setColorRecursive(c,d.color,d.colorIndex,e,a.children.length)})}},algorithmGroup:function(a,c,e,b){this.height=a;this.width=c;this.plot=b;this.startDirection=this.direction=e;this.lH=this.nH=this.lW=this.nW=this.total=0;this.elArr=[];this.lP={total:0,lH:0,nH:0,lW:0,nW:0,nR:0,lR:0,aspectRatio:function(a,c){return Math.max(a/c,c/a)}};this.addElement=function(a){this.lP.total=this.elArr[this.elArr.length-1];this.total+=a;0===this.direction?(this.lW=this.nW,this.lP.lH=this.lP.total/this.lW,this.lP.lR=
this.lP.aspectRatio(this.lW,this.lP.lH),this.nW=this.total/this.height,this.lP.nH=this.lP.total/this.nW,this.lP.nR=this.lP.aspectRatio(this.nW,this.lP.nH)):(this.lH=this.nH,this.lP.lW=this.lP.total/this.lH,this.lP.lR=this.lP.aspectRatio(this.lP.lW,this.lH),this.nH=this.total/this.width,this.lP.nW=this.lP.total/this.nH,this.lP.nR=this.lP.aspectRatio(this.lP.nW,this.nH));this.elArr.push(a)};this.reset=function(){this.lW=this.nW=0;this.elArr=[];this.total=0}},algorithmCalcPoints:function(a,c,e,b){var f,
x,d,h,t=e.lW,n=e.lH,g=e.plot,k=0,y=e.elArr.length-1;if(c)t=e.nW,n=e.nH;else var G=e.elArr[e.elArr.length-1];e.elArr.forEach(function(a){if(c||k<y)0===e.direction?(f=g.x,x=g.y,d=t,h=a/d):(f=g.x,x=g.y,h=n,d=a/h),b.push({x:f,y:x,width:d,height:I(h)}),0===e.direction?g.y+=h:g.x+=d;k+=1});e.reset();0===e.direction?e.width-=t:e.height-=n;g.y=g.parent.y+(g.parent.height-e.height);g.x=g.parent.x+(g.parent.width-e.width);a&&(e.direction=1-e.direction);c||e.addElement(G)},<API key>:function(a,
c,e){var b=[],f=this,d,h={x:c.x,y:c.y,parent:c},t=0,g=e.length-1,n=new this.algorithmGroup(c.height,c.width,c.direction,h);e.forEach(function(e){d=e.val/c.val*c.height*c.width;n.addElement(d);n.lP.nR>n.lP.lR&&f.algorithmCalcPoints(a,!1,n,b,h);t===g&&f.algorithmCalcPoints(a,!0,n,b,h);t+=1});return b},algorithmFill:function(a,c,e){var b=[],f,d=c.direction,h=c.x,t=c.y,n=c.width,g=c.height,k,y,l,G;e.forEach(function(e){f=e.val/c.val*c.height*c.width;k=h;y=t;0===d?(G=g,l=f/G,n-=l,h+=l):(l=n,G=f/l,g-=G,
t+=G);b.push({x:k,y:y,width:l,height:G});a&&(d=1-d)});return b},strip:function(a,c){return this.<API key>(!1,a,c)},squarified:function(a,c){return this.<API key>(!0,a,c)},sliceAndDice:function(a,c){return this.algorithmFill(!0,a,c)},stripes:function(a,c){return this.algorithmFill(!1,a,c)},translate:function(){var a=this,c=a.options,e=K(a);t.prototype.translate.call(a);var b=a.tree=a.getTree();var f=a.nodeMap[e];a.<API key>(e);a.mapOptionsToLevel=N({from:f.level+
1,levels:c.levels,to:b.height,defaults:{levelIsConstant:a.options.levelIsConstant,colorByPoint:c.colorByPoint}});""===e||f&&f.children.length||(a.setRootNode("",!1),e=a.rootNode,f=a.nodeMap[e]);E(a.nodeMap[a.rootNode],function(c){var e=!1,b=c.parent;c.visible=!0;if(b||""===b)e=a.nodeMap[b];return e});E(a.nodeMap[a.rootNode].children,function(a){var c=!1;a.forEach(function(a){a.visible=!0;a.children.length&&(c=(c||[]).concat(a.children))});return c});a.setTreeValues(b);a.axisRatio=a.xAxis.len/a.yAxis.len;
a.nodeMap[""].pointValues=e={x:0,y:0,width:100,height:100};a.nodeMap[""].values=e=J(e,{width:e.width*a.axisRatio,direction:"vertical"===c.<API key>?0:1,val:b.val});a.<API key>(b,e);a.colorAxis||c.colorByPoint||a.setColorRecursive(a.tree);c.allowTraversingTree&&(c=f.pointValues,a.xAxis.setExtremes(c.x,c.x+c.width,!1),a.yAxis.setExtremes(c.y,c.y+c.height,!1),a.xAxis.setScale(),a.yAxis.setScale());a.setPointValues()},drawDataLabels:function(){var a=this,c=a.mapOptionsToLevel,
e,b;a.points.filter(function(a){return a.node.visible}).forEach(function(f){b=c[f.node.level];e={style:{}};f.node.isLeaf||(e.enabled=!1);b&&b.dataLabels&&(e=J(e,b.dataLabels),a._hasPointLabels=!0);f.shapeArgs&&(e.style.width=f.shapeArgs.width,f.dataLabel&&f.dataLabel.css({width:f.shapeArgs.width+"px"}));f.dlOptions=J(e,f.options.dataLabels)});t.prototype.drawDataLabels.call(this)},alignDataLabel:function(a,c,b){var e=b.style;!r(e.textOverflow)&&c.text&&c.getBBox().width>c.text.textWidth&&c.css({textOverflow:"ellipsis",
width:e.width+="px"});k.column.prototype.alignDataLabel.apply(this,arguments);a.dataLabel&&a.dataLabel.attr({zIndex:(a.node.zIndex||0)+1})},pointAttribs:function(a,c){var b=P(this.mapOptionsToLevel)?this.mapOptionsToLevel:{},d=a&&b[a.node.level]||{};b=this.options;var h=c&&b.states[c]||{},t=a&&a.getClassName()||"";a={stroke:a&&a.borderColor||d.borderColor||h.borderColor||b.borderColor,"stroke-width":f(a&&a.borderWidth,d.borderWidth,h.borderWidth,b.borderWidth),dashstyle:a&&a.borderDashStyle||d.borderDashStyle||
h.borderDashStyle||b.borderDashStyle,fill:a&&a.color||this.color};-1!==t.indexOf("<API key>")?(a.fill="none",a["stroke-width"]=0):-1!==t.indexOf("<API key>")?(c=f(h.opacity,b.opacity),a.fill=D(a.fill).setOpacity(c).get(),a.cursor="pointer"):-1!==t.indexOf("<API key>")?a.fill="none":c&&(a.fill=D(a.fill).brighten(h.brightness).get());return a},drawPoints:function(){var a=this,c=a.chart,b=c.renderer,f=c.styledMode,d=a.options,h=f?{}:d.shadow,t=d.borderRadius,
n=c.pointCount<d.animationLimit,g=d.allowTraversingTree;a.points.forEach(function(c){var e=c.node.levelDynamic,m={},x={},G={},k="level-group-"+c.node.level,l=!!c.graphic,y=n&&l,E=c.shapeArgs;c.shouldDraw()&&(t&&(x.r=t),J(!0,y?m:x,l?E:{},f?{}:a.pointAttribs(c,c.selected?"select":void 0)),a.colorAttribs&&f&&B(G,a.colorAttribs(c)),a[k]||(a[k]=b.g(k).attr({zIndex:1E3-(e||0)}).add(a.group),a[k].survive=!0));c.draw({animatableAttribs:m,attribs:x,css:G,group:a[k],renderer:b,shadow:h,shapeArgs:E,shapeType:"rect"});
g&&c.graphic&&(c.drillId=d.interactByLeaf?a.drillToByLeaf(c):a.drillToByGroup(c))})},onClickDrillToNode:function(a){var c=(a=a.point)&&a.drillId;M(c)&&(a.setState(""),this.setRootNode(c,!0,{trigger:"click"}))},drillToByGroup:function(a){var c=!1;1!==a.node.level-this.nodeMap[this.rootNode].level||a.node.isLeaf||(c=a.id);return c},drillToByLeaf:function(a){var c=!1;if(a.node.parent!==this.rootNode&&a.node.isLeaf)for(a=a.node;!c;)a=this.nodeMap[a.parent],a.parent===this.rootNode&&(c=a.id);return c},
drillUp:function(){var a=this.nodeMap[this.rootNode];a&&M(a.parent)&&this.setRootNode(a.parent,!0,{trigger:"traverseUpButton"})},drillToNode:function(a,c){R(32,!1,void 0,{"treemap.drillToNode":"use treemap.setRootNode"});this.setRootNode(a,c)},setRootNode:function(a,c,b){a=B({newRootId:a,previousRootId:this.rootNode,redraw:f(c,!0),series:this},b);S(this,"setRootNode",a,function(a){var c=a.series;c.idPreviousRoot=a.previousRootId;c.rootNode=a.newRootId;c.isDirty=!0;a.redraw&&c.chart.redraw()})},<API key>:function(a){var c=
this,b=c.options.traverseUpButton,d=f(b.text,c.nodeMap[a].name,"\u25c1 Back");if(""===a||c.is("sunburst")&&1===c.tree.children.length&&a===c.tree.children[0].id)c.drillUpButton&&(c.drillUpButton=c.drillUpButton.destroy());else if(this.drillUpButton)this.drillUpButton.placed=!1,this.drillUpButton.attr({text:d}).align();else{var h=(a=b.theme)&&a.states;this.drillUpButton=this.chart.renderer.button(d,0,0,function(){c.drillUp()},a,h&&h.hover,h&&h.select).addClass("<API key>").attr({align:b.position.align,
zIndex:7}).add().align(b.position,!1,b.relativeTo||"plotBox")}},buildKDTree:d,drawLegendSymbol:l.drawRectangle,getExtremes:function(){var a=t.prototype.getExtremes.call(this,this.colorValueData),c=a.dataMax;this.valueMin=a.dataMin;this.valueMax=c;return t.prototype.getExtremes.call(this)},getExtremesFromAll:!0,setState:function(a){this.options.inactiveOtherPoints=!0;t.prototype.setState.call(this,a,!1);this.options.inactiveOtherPoints=!1},utils:{recursive:E}},{draw:q.drawPoint,setVisible:k.pie.prototype.pointClass.prototype.setVisible,
getClassName:function(){var a=w.prototype.getClassName.call(this),c=this.series,b=c.options;this.node.level<=c.nodeMap[c.rootNode].level?a+=" <API key>":this.node.isLeaf||f(b.interactByLeaf,!b.allowTraversingTree)?this.node.isLeaf||(a+=" <API key>"):a+=" <API key>";return a},isValid:function(){return!(!this.id&&!O(this.value))},setState:function(a){w.prototype.setState.call(this,a);this.graphic&&this.graphic.attr({zIndex:"hover"===a?1:0})},shouldDraw:function(){return O(this.plotY)&&
null!==this.y}});C(u.Series,"afterBindAxes",function(){var a=this.xAxis,c=this.yAxis;if(a&&c)if(this.is("treemap")){var b={endOnTick:!1,gridLineWidth:0,lineWidth:0,min:0,dataMin:0,minPadding:0,max:100,dataMax:100,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};B(c.options,b);B(a.options,b);n=!0}else n&&(c.setOptions(c.userOptions),a.setOptions(a.userOptions),n=!1)});""});q(b,"Series/SunburstSeries.js",[b["Core/Series/Series.js"],b["Mixins/CenteredSeries.js"],b["Mixins/DrawPoint.js"],b["Core/Globals.js"],
b["Mixins/TreeSeries.js"],b["Core/Utilities.js"]],function(b,d,p,q,u,l){var w=b.seriesTypes,A=d.getCenter,g=d.<API key>,k=u.getColor,D=u.getLevelOptions,H=u.setTreeValues,Q=u.updateRootId,N=l.correctFloat,K=l.error,C=l.extend,I=l.isNumber,r=l.isObject,R=l.isString,B=l.merge,S=l.splat,L=q.Series,O=180/Math.PI,P=function(b,d){var f=[];if(I(b)&&I(d)&&b<=d)for(;b<=d;b++)f.push(b);return f},M=function(b,d){d=r(d)?d:{};var f=0,h;if(r(b)){var g=B({},b);b=I(d.from)?d.from:0;var n=I(d.to)?d.to:
0;var a=P(b,n);b=Object.keys(g).filter(function(c){return-1===a.indexOf(+c)});var c=h=I(d.diffRadius)?d.diffRadius:0;a.forEach(function(a){a=g[a];var b=a.levelSize.unit,e=a.levelSize.value;"weight"===b?f+=e:"percentage"===b?(a.levelSize={unit:"pixels",value:e/100*c},h-=a.levelSize.value):"pixels"===b&&(h-=e)});a.forEach(function(a){var c=g[a];"weight"===c.levelSize.unit&&(c=c.levelSize.value,g[a].levelSize={unit:"pixels",value:c/f*h})});b.forEach(function(a){g[a].levelSize={value:0,unit:"pixels"}})}return g},
J=function(b){var f=b.level;return{from:0<f?f:1,to:f+b.height}},T=function(b,d){var f=d.mapIdToNode[b.parent],h=d.series,g=h.chart,n=h.points[b.i];f=k(b,{colors:h.options.colors||g&&g.options.colors,colorIndex:h.colorIndex,index:d.index,mapOptionsToLevel:d.mapOptionsToLevel,parentColor:f&&f.color,parentColorIndex:f&&f.colorIndex,series:d.series,siblings:d.siblings});b.color=f.color;b.colorIndex=f.colorIndex;n&&(n.color=b.color,n.colorIndex=b.colorIndex,b.sliced=b.id!==d.idRoot?n.sliced:!1);return b};
d={drawDataLabels:q.noop,drawPoints:function(){var b=this,d=b.mapOptionsToLevel,g=b.shapeRoot,k=b.group,l=b.hasRendered,n=b.rootNode,a=b.idPreviousRoot,c=b.nodeMap,e=c[a],x=e&&e.shapeArgs;e=b.points;var m=b.startAndEndRadians,p=b.chart,v=p&&p.options&&p.options.chart||{},u="boolean"===typeof v.animation?v.animation:!0,q=b.center[3]/2,A=b.chart.renderer,w=!1,D=!1;if(v=!!(u&&l&&n!==a&&b.dataLabelsGroup)){b.dataLabelsGroup.attr({opacity:0});var H=function(){w=!0;b.dataLabelsGroup&&b.dataLabelsGroup.animate({opacity:1,
visibility:"visible"})}}e.forEach(function(e){var f=e.node,h=d[f.level];var t=e.shapeExisting||{};var y=f.shapeArgs||{},v=!(!f.visible||!f.shapeArgs);if(l&&u){var E={};var w={end:y.end,start:y.start,innerR:y.innerR,r:y.r,x:y.x,y:y.y};v?!e.graphic&&x&&(E=n===e.id?{start:m.start,end:m.end}:x.end<=y.start?{start:m.end,end:m.end}:{start:m.start,end:m.start},E.innerR=E.r=q):e.graphic&&(a===e.id?w={innerR:q,r:q}:g&&(w=g.end<=t.start?{innerR:q,r:q,start:m.end,end:m.end}:{innerR:q,r:q,start:m.start,end:m.start}));
t=E}else w=y,t={};E=[y.plotX,y.plotY];if(!e.node.isLeaf)if(n===e.id){var z=c[n];z=z.parent}else z=e.id;C(e,{shapeExisting:y,tooltipPos:E,drillId:z,name:""+(e.name||e.id||e.index),plotX:y.plotX,plotY:y.plotY,value:f.val,isNull:!v});z=e.options;f=r(y)?y:{};z=r(z)?z.dataLabels:{};h=S(r(h)?h.dataLabels:{})[0];h=B({style:{}},h,z);z=h.rotationMode;if(!I(h.rotation)){if("auto"===z||"circular"===z)if(1>e.innerArcLength&&e.outerArcLength>f.radius){var F=0;e.dataLabelPath&&"circular"===z&&(h.textPath={enabled:!0})}else 1<
e.innerArcLength&&e.outerArcLength>1.5*f.radius?"circular"===z?h.textPath={enabled:!0,attributes:{dy:5}}:z="parallel":(e.dataLabel&&e.dataLabel.textPathWrapper&&"circular"===z&&(h.textPath={enabled:!1}),z="perpendicular");"auto"!==z&&"circular"!==z&&(F=f.end-(f.end-f.start)/2);h.style.width="parallel"===z?Math.min(2.5*f.radius,(e.outerArcLength+e.innerArcLength)/2):f.radius;"perpendicular"===z&&e.series.chart.renderer.fontMetrics(h.style.fontSize).h>e.outerArcLength&&(h.style.width=1);h.style.width=
Math.max(h.style.width-2*(h.padding||0),1);F=F*O%180;"parallel"===z&&(F-=90);90<F?F-=180:-90>F&&(F+=180);h.rotation=F}h.textPath&&(0===e.shapeExisting.innerR&&h.textPath.enabled?(h.rotation=0,h.textPath.enabled=!1,h.style.width=Math.max(2*e.shapeExisting.r-2*(h.padding||0),1)):e.dlOptions&&e.dlOptions.textPath&&!e.dlOptions.textPath.enabled&&"circular"===z&&(h.textPath.enabled=!0),h.textPath.enabled&&(h.rotation=0,h.style.width=Math.max((e.outerArcLength+e.innerArcLength)/2-2*(h.padding||0),1)));
0===h.rotation&&(h.rotation=.001);e.dlOptions=h;if(!D&&v){D=!0;var G=H}e.draw({animatableAttribs:w,attribs:C(t,!p.styledMode&&b.pointAttribs(e,e.selected&&"select")),onComplete:G,group:k,renderer:A,shapeType:"arc",shapeArgs:y})});v&&D?(b.hasRendered=!1,b.options.dataLabels.defer=!0,L.prototype.drawDataLabels.call(b),b.hasRendered=!0,w&&H()):L.prototype.drawDataLabels.call(b)},pointAttribs:w.column.prototype.pointAttribs,layoutAlgorithm:function(b,d,g){var f=b.start,h=b.end-f,n=b.val,a=b.x,c=b.y,e=
g&&r(g.levelSize)&&I(g.levelSize.value)?g.levelSize.value:0,k=b.r,t=k+e,l=g&&I(g.slicedOffset)?g.slicedOffset:0;return(d||[]).reduce(function(b,d){var g=1/n*d.val*h,m=f+g/2,y=a+Math.cos(m)*l;m=c+Math.sin(m)*l;d={x:d.sliced?y:a,y:d.sliced?m:c,innerR:k,r:t,radius:e,start:f,end:f+g};b.push(d);f=d.end;return b},[])},setShapeArgs:function(b,d,g){var f=[],h=g[b.level+1];b=b.children.filter(function(b){return b.visible});f=this.layoutAlgorithm(d,b,h);b.forEach(function(b,a){a=f[a];var c=a.start+(a.end-a.start)/
2,e=a.innerR+(a.r-a.innerR)/2,d=a.end-a.start;e=0===a.innerR&&6.28<d?{x:a.x,y:a.y}:{x:a.x+Math.cos(c)*e,y:a.y+Math.sin(c)*e};var h=b.val?b.childrenTotal>b.val?b.childrenTotal:b.val:b.childrenTotal;this.points[b.i]&&(this.points[b.i].innerArcLength=d*a.innerR,this.points[b.i].outerArcLength=d*a.r);b.shapeArgs=B(a,{plotX:e.x,plotY:e.y+4*Math.abs(Math.cos(c))});b.values=B(a,{val:h});b.children.length&&this.setShapeArgs(b,b.values,g)},this)},translate:function(){var b=this,d=b.options,k=b.center=A.call(b),
l=b.startAndEndRadians=g(d.startAngle,d.endAngle),p=k[3]/2,n=k[2]/2-p,a=Q(b),c=b.nodeMap,e=c&&c[a],q={};b.shapeRoot=e&&e.shapeArgs;L.prototype.translate.call(b);var m=b.tree=b.getTree();b.<API key>(a);c=b.nodeMap;e=c[a];var r=R(e.parent)?e.parent:"";r=c[r];var v=J(e);var u=v.from,w=v.to;v=D({from:u,levels:b.options.levels,to:w,defaults:{colorByPoint:d.colorByPoint,dataLabels:d.dataLabels,levelIsConstant:d.levelIsConstant,levelSize:d.levelSize,slicedOffset:d.slicedOffset}});v=M(v,{diffRadius:n,
from:u,to:w});H(m,{before:T,idRoot:a,levelIsConstant:d.levelIsConstant,mapOptionsToLevel:v,mapIdToNode:c,points:b.points,series:b});d=c[""].shapeArgs={end:l.end,r:p,start:l.start,val:e.val,x:k[0],y:k[1]};this.setShapeArgs(r,d,v);b.mapOptionsToLevel=v;b.data.forEach(function(a){q[a.id]&&K(31,!1,b.chart);q[a.id]=!0});q={}},alignDataLabel:function(b,d,g){if(!g.textPath||!g.textPath.enabled)return w.treemap.prototype.alignDataLabel.apply(this,arguments)},animate:function(b){var d=this.chart,f=[d.plotWidth/
2,d.plotHeight/2],g=d.plotLeft,k=d.plotTop;d=this.group;b?(b={translateX:f[0]+g,translateY:f[1]+k,scaleX:.001,scaleY:.001,rotation:10,opacity:.01},d.attr(b)):(b={translateX:g,translateY:k,scaleX:1,scaleY:1,rotation:0,opacity:1},d.animate(b,this.options.animation))},utils:{calculateLevelSizes:M,getLevelFromAndTo:J,range:P}};p={draw:p.drawPoint,shouldDraw:function(){return!this.isNull},isValid:function(){return!0},getDataLabelPath:function(b){var d=this.series.chart.renderer,f=this.shapeExisting,g=
f.start,k=f.end,l=g+(k-g)/2;l=0>l&&l>-Math.PI||l>Math.PI;var a=f.r+(b.options.distance||0);g===-Math.PI/2&&N(k)===N(1.5*Math.PI)&&(g=-Math.PI+Math.PI/360,k=-Math.PI/360,l=!0);if(k-g>Math.PI){l=!1;var c=!0}this.dataLabelPath&&(this.dataLabelPath=this.dataLabelPath.destroy());this.dataLabelPath=d.arc({open:!0,longArc:c?1:0}).add(b);this.dataLabelPath.attr({start:l?g:k,end:l?k:g,clockwise:+l,x:f.x,y:f.y,r:(a+f.innerR)/2});return this.dataLabelPath}};"";b.seriesType("sunburst","treemap",{center:["50%",
"50%"],colorByPoint:!1,opacity:1,dataLabels:{allowOverlap:!0,defer:!0,rotationMode:"auto",style:{textOverflow:"ellipsis"}},rootId:void 0,levelIsConstant:!0,levelSize:{value:1,unit:"weight"},slicedOffset:10},d,p)});q(b,"masters/modules/sunburst.src.js",[],function(){})});
//# sourceMappingURL=sunburst.js.map
|
import _extends from "@babel/runtime/helpers/esm/extends";
import <API key> from "@babel/runtime/helpers/esm/<API key>";
import * as React from 'react';
import PropTypes from 'prop-types';
import { Transition } from '<API key>';
import useTheme from '../styles/useTheme';
import { reflow, getTransitionProps } from '../transitions/utils';
import useForkRef from '../utils/useForkRef';
function getScale(value) {
return `scale(${value}, ${value ** 2})`;
}
const styles = {
entering: {
opacity: 1,
transform: getScale(1)
},
entered: {
opacity: 1,
transform: 'none'
}
};
const Grow = React.forwardRef(function Grow(props, ref) {
const {
children,
in: inProp,
onEnter,
onExit,
style,
timeout = 'auto'
} = props,
other = <API key>(props, ["children", "in", "onEnter", "onExit", "style", "timeout"]);
const timer = React.useRef();
const autoTimeout = React.useRef();
const handleRef = useForkRef(children.ref, ref);
const theme = useTheme();
const handleEnter = (node, isAppearing) => {
reflow(node); // So the animation always start from the start.
const {
duration: transitionDuration,
delay
} = getTransitionProps({
style,
timeout
}, {
mode: 'enter'
});
let duration;
if (timeout === 'auto') {
duration = theme.transitions.<API key>(node.clientHeight);
autoTimeout.current = duration;
} else {
duration = transitionDuration;
}
node.style.transition = [theme.transitions.create('opacity', {
duration,
delay
}), theme.transitions.create('transform', {
duration: duration * 0.666,
delay
})].join(',');
if (onEnter) {
onEnter(node, isAppearing);
}
};
const handleExit = node => {
const {
duration: transitionDuration,
delay
} = getTransitionProps({
style,
timeout
}, {
mode: 'exit'
});
let duration;
if (timeout === 'auto') {
duration = theme.transitions.<API key>(node.clientHeight);
autoTimeout.current = duration;
} else {
duration = transitionDuration;
}
node.style.transition = [theme.transitions.create('opacity', {
duration,
delay
}), theme.transitions.create('transform', {
duration: duration * 0.666,
delay: delay || duration * 0.333
})].join(',');
node.style.opacity = '0';
node.style.transform = getScale(0.75);
if (onExit) {
onExit(node);
}
};
const addEndListener = (_, next) => {
if (timeout === 'auto') {
timer.current = setTimeout(next, autoTimeout.current || 0);
}
};
React.useEffect(() => {
return () => {
clearTimeout(timer.current);
};
}, []);
return /*#__PURE__*/React.createElement(Transition, _extends({
appear: true,
in: inProp,
onEnter: handleEnter,
onExit: handleExit,
addEndListener: addEndListener,
timeout: timeout === 'auto' ? null : timeout
}, other), (state, childProps) => {
return React.cloneElement(children, _extends({
style: _extends({
opacity: 0,
transform: getScale(0.75),
visibility: state === 'exited' && !inProp ? 'hidden' : undefined
}, styles[state], {}, style, {}, children.props.style),
ref: handleRef
}, childProps));
});
});
process.env.NODE_ENV !== "production" ? Grow.propTypes = {
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
/**
* A single child content element.
*/
children: PropTypes.element,
/**
* If `true`, show the component; triggers the enter or exit animation.
*/
in: PropTypes.bool,
/**
* @ignore
*/
onEnter: PropTypes.func,
/**
* @ignore
*/
onExit: PropTypes.func,
/**
* @ignore
*/
style: PropTypes.object,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*
* Set to 'auto' to automatically calculate transition time based on height.
*/
timeout: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({
appear: PropTypes.number,
enter: PropTypes.number,
exit: PropTypes.number
})])
} : void 0;
Grow.muiSupportAuto = true;
export default Grow;
|
import * as React from 'react';
declare class JqxGrid extends React.PureComponent<IGridProps, IState> {
protected static <API key>(props: IGridProps, state: IState): null | IState;
private _jqx;
private _id;
private _componentSelector;
constructor(props: IGridProps);
componentDidMount(): void;
componentDidUpdate(): void;
render(): React.ReactNode;
setOptions(options: IGridProps): void;
getOptions(option: string): any;
autoresizecolumns(type?: string): void;
autoresizecolumn(dataField: string, type?: string): void;
beginupdate(): void;
clear(): void;
createChart(type: string, dataSource?: any): void;
destroy(): void;
endupdate(): void;
ensurerowvisible(rowBoundIndex: number): void;
focus(): void;
getcolumnindex(dataField: string): number;
getcolumn(dataField: string): IGridGetColumn;
getcolumnproperty(dataField: string, propertyName: string): any;
getrowid(rowBoundIndex: number): string;
getrowdata(rowBoundIndex: number): any;
getrowdatabyid(rowID: string): any;
<API key>(rowID: string): number;
getrowboundindex(rowDisplayIndex: number): number;
getrows(): any[];
getboundrows(): any[];
getdisplayrows(): any[];
getdatainformation(): <API key>;
getsortinformation(): <API key>;
<API key>(): <API key>;
hidecolumn(dataField: string): void;
hideloadelement(): void;
hiderowdetails(rowBoundIndex: number): void;
iscolumnvisible(dataField: string): boolean;
iscolumnpinned(dataField: string): boolean;
localizestrings(localizationobject: <API key>): void;
pincolumn(dataField: string): void;
refreshdata(): void;
refresh(): void;
renderWidget(): void;
scrolloffset(top: number, left: number): void;
scrollposition(): IGridScrollPosition;
showloadelement(): void;
showrowdetails(rowBoundIndex: number): void;
setcolumnindex(dataField: string, index: number): void;
setcolumnproperty(dataField: string, propertyName: any, propertyValue: any): void;
showcolumn(dataField: string): void;
unpincolumn(dataField: string): void;
updatebounddata(type?: any): void;
updating(): boolean;
getsortcolumn(): string;
removesort(): void;
sortby(dataField: string, sortOrder: string): void;
addgroup(dataField: string): void;
cleargroups(): void;
collapsegroup(group: number | string): void;
collapseallgroups(): void;
expandallgroups(): void;
expandgroup(group: number | string): void;
getrootgroupscount(): number;
getgroup(groupIndex: number): IGridGetGroup;
insertgroup(groupIndex: number, dataField: string): void;
iscolumngroupable(): boolean;
removegroupat(groupIndex: number): void;
removegroup(dataField: string): void;
addfilter(dataField: string, filterGroup: any, refreshGrid?: boolean): void;
applyfilters(): void;
clearfilters(): void;
<API key>(): any;
getcolumnat(index: number): any;
removefilter(dataField: string, refreshGrid: boolean): void;
refreshfilterrow(): void;
gotopage(pagenumber: number): void;
gotoprevpage(): void;
gotonextpage(): void;
addrow(rowIds: any, data: any, rowPosition?: any): void;
begincelledit(rowBoundIndex: number, dataField: string): void;
beginrowedit(rowBoundIndex: number): void;
closemenu(): void;
deleterow(rowIds: string | number | Array<number | string>): void;
endcelledit(rowBoundIndex: number, dataField: string, confirmChanges: boolean): void;
endrowedit(rowBoundIndex: number, confirmChanges: boolean): void;
getcell(rowBoundIndex: number, datafield: string): IGridGetCell;
getcellatposition(left: number, top: number): IGridGetCell;
getcelltext(rowBoundIndex: number, dataField: string): string;
getcelltextbyid(rowID: string, dataField: string): string;
getcellvaluebyid(rowID: string, dataField: string): any;
getcellvalue(rowBoundIndex: number, dataField: string): any;
isBindingCompleted(): boolean;
openmenu(dataField: string): void;
setcellvalue(rowBoundIndex: number, dataField: string, value: any): void;
setcellvaluebyid(rowID: string, dataField: string, value: any): void;
showvalidationpopup(rowBoundIndex: number, dataField: string, validationMessage: string): void;
updaterow(rowIds: string | number | Array<number | string>, data: any): void;
clearselection(): void;
getselectedrowindex(): number;
<API key>(): number[];
getselectedcell(): <API key>;
getselectedcells(): <API key>[];
selectcell(rowBoundIndex: number, dataField: string): void;
selectallrows(): void;
selectrow(rowBoundIndex: number): void;
unselectrow(rowBoundIndex: number): void;
unselectcell(rowBoundIndex: number, dataField: string): void;
<API key>(dataField: string, aggregates: any[]): string;
refreshaggregates(): void;
renderaggregates(): void;
exportdata(dataType: string, fileName?: string, exportHeader?: boolean, rows?: number[], exportHiddenColumns?: boolean, serverURL?: string, charSet?: string): any;
exportview(dataType: string, fileName?: string): any;
openColumnChooser(columns?: any, header?: string): void;
getstate(): IGridGetState;
loadstate(stateobject: any): void;
savestate(): IGridGetState;
private _manageProps;
private _wireEvents;
}
export default JqxGrid;
export declare const jqx: any;
export declare const JQXLite: any;
interface IState {
lastProps: object;
}
export interface IGridCharting {
appendTo?: string;
colorScheme?: string;
dialog?: (width: number, height: number, header: string, position: any, enabled: boolean) => void;
formatSettings?: any;
ready?: any;
}
export interface IGridColumn {
text?: string;
datafield?: string;
displayfield?: string;
threestatecheckbox?: boolean;
sortable?: boolean;
filterable?: boolean;
filter?: (cellValue?: any, rowData?: any, dataField?: string, filterGroup?: any, defaultFilterResult?: any) => any;
buttonclick?: (row: number) => void;
hideable?: boolean;
hidden?: boolean;
groupable?: boolean;
menu?: boolean;
exportable?: boolean;
columngroup?: string;
enabletooltips?: boolean;
columntype?: 'number' | 'checkbox' | 'button' | 'numberinput' | 'dropdownlist' | 'combobox' | 'datetimeinput' | 'textbox' | 'rating' | 'progressbar' | 'template' | 'custom';
renderer?: (defaultText?: string, alignment?: string, height?: number) => string;
rendered?: (columnHeaderElement?: any) => void;
cellsrenderer?: (row?: number, columnfield?: string, value?: any, defaulthtml?: string, columnproperties?: any, rowdata?: any) => string;
aggregatesrenderer?: (aggregates?: any, column?: any, element?: any, summaryData?: any) => string;
validation?: (cell?: any, value?: number) => any;
createwidget?: (row: any, column: any, value: string, cellElement: any) => void;
initwidget?: (row: number, column: string, value: string, cellElement: any) => void;
createfilterwidget?: (column: any, htmlElement: HTMLElement, editor: any) => void;
createfilterpanel?: (datafield: string, filterPanel: any) => void;
initeditor?: (row: number, cellvalue: any, editor: any, celltext: any, pressedChar: string, callback: any) => void;
createeditor?: (row: number, cellvalue: any, editor: any, celltext: any, cellwidth: any, cellheight: any) => void;
destroyeditor?: (row: number, callback: any) => void;
geteditorvalue?: (row: number, cellvalue: any, editor: any) => any;
cellbeginedit?: (row: number, datafield: string, columntype: string, value: any) => boolean;
cellendedit?: (row: number, datafield: string, columntype: string, oldvalue: any, newvalue: any) => boolean;
cellvaluechanging?: (row: number, datafield: string, columntype: string, oldvalue: any, newvalue: any) => string | void;
<API key>?: (datafield: string, htmlElement: HTMLElement, popup: any, addRowCallback: any) => any;
<API key>?: (datafield: string, htmlElement: HTMLElement, popup: any) => void;
<API key>?: (datafield: string, htmlElement: HTMLElement) => void;
<API key>?: (datafield: string, htmlElement: HTMLElement) => any;
<API key>?: (htmlElement: HTMLElement) => void;
<API key>?: (datafield: string, value: any, rowValues: any) => boolean | object;
cellsformat?: string;
cellclassname?: any;
aggregates?: any;
align?: 'left' | 'center' | 'right';
cellsalign?: 'left' | 'center' | 'right';
width?: number | string;
minwidth?: any;
maxwidth?: any;
resizable?: boolean;
draggable?: boolean;
editable?: boolean;
classname?: string;
pinned?: boolean;
nullable?: boolean;
filteritems?: any;
filterdelay?: number;
filtertype?: 'textbox' | 'input' | 'checkedlist' | 'list' | 'number' | 'bool' | 'date' | 'range' | 'custom';
filtercondition?: 'EMPTY' | 'NOT_EMPTY' | 'CONTAINS' | '<API key>' | 'DOES_NOT_CONTAIN' | '<API key>' | 'STARTS_WITH' | '<API key>' | 'ENDS_WITH' | '<API key>' | 'EQUAL' | '<API key>' | 'NULL' | 'NOT_NULL' | 'EQUAL' | 'NOT_EQUAL' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'GREATER_THAN' | '<API key>' | 'NULL' | 'NOT_NULL';
}
export interface <API key> {
name?: string;
type?: 'string' | 'date' | 'int' | 'float' | 'number' | 'bool';
format?: string;
map?: string;
id?: string;
text?: string;
source?: any[];
}
export interface IGridSource {
url?: string;
data?: any;
localdata?: any;
datatype?: 'xml' | 'json' | 'jsonp' | 'tsv' | 'csv' | 'local' | 'array' | 'observablearray';
type?: 'GET' | 'POST';
id?: string;
root?: string;
record?: string;
datafields?: <API key>[];
pagenum?: number;
pagesize?: number;
pager?: (pagenum?: number, pagesize?: number, oldpagenum?: number) => any;
sortcolumn?: string;
sortdirection?: 'asc' | 'desc';
sort?: (column?: any, direction?: any) => void;
filter?: (filters?: any, recordsArray?: any) => void;
addrow?: (rowid?: any, rowdata?: any, position?: any, commit?: boolean) => void;
deleterow?: (rowid?: any, commit?: boolean) => void;
updaterow?: (rowid?: any, newdata?: any, commit?: any) => void;
processdata?: (data: any) => void;
formatdata?: (data: any) => any;
async?: boolean;
totalrecords?: number;
unboundmode?: boolean;
}
export interface IGridGetColumn {
datafield?: string;
displayfield?: string;
text?: string;
sortable?: boolean;
filterable?: boolean;
exportable?: boolean;
editable?: boolean;
groupable?: boolean;
resizable?: boolean;
draggable?: boolean;
classname?: string;
cellclassname?: any;
width?: number | string;
menu?: boolean;
}
export interface <API key> {
rowscount?: string;
sortinformation?: any;
sortcolumn?: any;
sortdirection?: any;
paginginformation?: any;
pagenum?: any;
pagesize?: any;
pagescount?: any;
}
export interface <API key> {
sortcolumn?: string;
sortdirection?: any;
}
export interface <API key> {
pagenum?: string;
pagesize?: any;
pagescount?: any;
}
export interface IGridDateNaming {
names?: string[];
namesAbbr?: string[];
namesShort?: string[];
}
export interface <API key> {
<API key>?: any;
<API key>?: any;
<API key>?: any;
<API key>?: any;
pagergotopagestring?: string;
pagershowrowsstring?: string;
pagerrangestring?: string;
<API key>?: string;
<API key>?: string;
sortascendingstring?: string;
<API key>?: string;
sortremovestring?: string;
firstDay?: number;
percentsymbol?: string;
currencysymbol?: string;
<API key>?: string;
decimalseparator?: string;
thousandsseparator?: string;
days?: IGridDateNaming;
months?: IGridDateNaming;
addrowstring?: string;
updaterowstring?: string;
deleterowstring?: string;
resetrowstring?: string;
<API key>?: string;
emptydatastring?: string;
}
export interface IGridScrollPosition {
top?: number;
left?: number;
}
export interface IGridGetGroup {
group?: number;
level?: number;
expanded?: number;
subgroups?: number;
subrows?: number;
}
export interface IGridGetCell {
value?: number;
row?: number;
column?: number;
}
export interface <API key> {
rowindex?: number;
datafield?: string;
}
export interface <API key> {
width?: number | string;
hidden?: boolean;
index?: number;
pinned?: boolean;
groupable?: boolean;
resizable?: boolean;
draggable?: boolean;
text?: string;
align?: string;
cellsalign?: string;
}
export interface IGridGetState {
width?: number | string;
height?: number | string;
pagenum?: number;
pagesize?: number;
pagesizeoptions?: string[];
sortcolumn?: any;
sortdirection?: any;
filters?: any;
groups?: any;
columns?: <API key>;
}
export interface <API key> {
menu?: any;
datafield?: any;
height?: any;
}
export interface <API key> {
menu?: any;
datafield?: any;
height?: any;
}
export interface IGridCellhover {
cellhtmlElement?: any;
x?: any;
y?: any;
}
export interface IGridGroupsrenderer {
text?: string;
group?: number;
expanded?: boolean;
data?: object;
}
export interface <API key> {
text?: any;
}
export interface <API key> {
event?: any;
}
export interface IGridScrollfeedback {
row?: object;
}
export interface IGridFilter {
cellValue?: any;
rowData?: any;
dataField?: string;
filterGroup?: any;
defaultFilterResult?: boolean;
}
export interface IGridRendertoolbar {
toolbar?: any;
}
export interface <API key> {
statusbar?: any;
}
interface IGridOptions {
altrows?: boolean;
altstart?: number;
altstep?: number;
autoshowloadelement?: boolean;
autoshowfiltericon?: boolean;
<API key>?: boolean;
showcolumnlines?: boolean;
showrowlines?: boolean;
<API key>?: boolean;
adaptive?: boolean;
adaptivewidth?: number;
clipboard?: boolean;
closeablegroups?: boolean;
columnsmenuwidth?: number;
columnmenuopening?: (menu?: <API key>['menu'], datafield?: <API key>['datafield'], height?: <API key>['height']) => boolean | void;
columnmenuclosing?: (menu?: <API key>['menu'], datafield?: <API key>['datafield'], height?: <API key>['height']) => boolean;
cellhover?: (cellhtmlElement?: IGridCellhover['cellhtmlElement'], x?: IGridCellhover['x'], y?: IGridCellhover['y']) => void;
<API key>?: boolean;
enableellipsis?: boolean;
enablemousewheel?: boolean;
enableanimations?: boolean;
enabletooltips?: boolean;
enablehover?: boolean;
<API key>?: boolean;
<API key>?: 'top' | 'bottom' | 'topAboveFilterRow';
<API key>?: number;
<API key>?: string;
<API key>?: 'popup' | 'columns';
filterrowheight?: number;
filtermode?: 'default' | 'excel';
groupsrenderer?: (text?: IGridGroupsrenderer['text'], group?: IGridGroupsrenderer['group'], expanded?: IGridGroupsrenderer['expanded'], data?: IGridGroupsrenderer['data']) => string;
groupcolumnrenderer?: (text?: <API key>['text']) => string;
<API key>?: boolean;
<API key>?: (event: <API key>['event']) => boolean;
pagerrenderer?: () => any[];
rtl?: boolean;
<API key>?: boolean;
<API key>?: boolean;
showfiltermenuitems?: boolean;
<API key>?: boolean;
<API key>?: boolean;
showsortmenuitems?: boolean;
showgroupmenuitems?: boolean;
<API key>?: boolean;
showheader?: boolean;
showgroupsheader?: boolean;
showaggregates?: boolean;
showgroupaggregates?: boolean;
showeverpresentrow?: boolean;
showfilterrow?: boolean;
showemptyrow?: boolean;
showstatusbar?: boolean;
statusbarheight?: number;
showtoolbar?: boolean;
showfilterbar?: boolean;
filterbarmode?: string;
selectionmode?: 'none' | 'singlerow' | 'multiplerows' | '<API key>' | 'singlecell' | 'multiplecells' | '<API key>' | '<API key>' | 'checkbox';
<API key>?: (type?: string, defaultconditions?: any) => any;
updatefilterpanel?: (filtertypedropdown1?: any, filtertypedropdown2?: any, <API key>?: any, filterinputfield1?: any, filterinputfield2?: any, filterbutton?: any, clearbutton?: any, columnfilter?: any, filtertype?: any, filterconditions?: any) => any;
theme?: string;
toolbarheight?: number;
autoheight?: boolean;
autorowheight?: boolean;
columnsheight?: number;
deferreddatafields?: string[];
groupsheaderheight?: number;
groupindentwidth?: number;
height?: number | string;
pagerheight?: number | string;
rowsheight?: number;
scrollbarsize?: number | string;
scrollmode?: 'default' | 'logical' | 'deferred';
scrollfeedback?: (row: IGridScrollfeedback['row']) => string;
width?: string | number;
autosavestate?: boolean;
autoloadstate?: boolean;
columns?: IGridColumn[];
enableSanitize?: boolean;
cardview?: boolean;
cardviewcolumns?: any;
cardheight?: number;
cardsize?: number;
columngroups?: any[];
columnsmenu?: boolean;
columnsresize?: boolean;
columnsautoresize?: boolean;
columnsreorder?: boolean;
charting?: IGridCharting;
disabled?: boolean;
editable?: boolean;
editmode?: 'click' | 'selectedcell' | 'selectedrow' | 'dblclick' | 'programmatic';
filter?: (cellValue?: IGridFilter['cellValue'], rowData?: IGridFilter['rowData'], dataField?: IGridFilter['dataField'], filterGroup?: IGridFilter['filterGroup'], defaultFilterResult?: IGridFilter['defaultFilterResult']) => any;
filterable?: boolean;
groupable?: boolean;
groups?: string[];
<API key>?: number;
<API key>?: number;
initrowdetails?: (index?: number, parentElement?: any, gridElement?: any, datarecord?: any) => void;
keyboardnavigation?: boolean;
localization?: <API key>;
pagesize?: number;
pagesizeoptions?: Array<number | string>;
pagermode?: 'simple' | 'default' | 'material';
pagerbuttonscount?: number;
pageable?: boolean;
autofill?: boolean;
rowdetails?: boolean;
rowdetailstemplate?: any;
ready?: () => void;
rendered?: (type: any) => void;
renderstatusbar?: (statusbar?: <API key>['statusbar']) => void;
rendertoolbar?: (toolbar?: IGridRendertoolbar['toolbar']) => void;
rendergridrows?: (params?: any) => any;
sortable?: boolean;
sortmode?: string;
selectedrowindex?: number;
selectedrowindexes?: number[];
source?: IGridSource;
sorttogglestates?: '0' | '1' | '2';
updatedelay?: number;
virtualmode?: boolean;
<API key>?: number;
<API key>?: number;
}
export interface IGridProps extends IGridOptions {
className?: string;
style?: React.CSSProperties;
onBindingcomplete?: (e?: Event) => void;
onColumnresized?: (e?: Event) => void;
onColumnreordered?: (e?: Event) => void;
onColumnclick?: (e?: Event) => void;
onCellclick?: (e?: Event) => void;
onCelldoubleclick?: (e?: Event) => void;
onCellselect?: (e?: Event) => void;
onCellunselect?: (e?: Event) => void;
onCellvaluechanged?: (e?: Event) => void;
onCellbeginedit?: (e?: Event) => void;
onCellendedit?: (e?: Event) => void;
onFilter?: (e?: Event) => void;
onGroupschanged?: (e?: Event) => void;
onGroupexpand?: (e?: Event) => void;
onGroupcollapse?: (e?: Event) => void;
onPagechanged?: (e?: Event) => void;
onPagesizechanged?: (e?: Event) => void;
onRowclick?: (e?: Event) => void;
onRowdoubleclick?: (e?: Event) => void;
onRowselect?: (e?: Event) => void;
onRowunselect?: (e?: Event) => void;
onRowexpand?: (e?: Event) => void;
onRowcollapse?: (e?: Event) => void;
onSort?: (e?: Event) => void;
}
|
"use strict";
exports.__esModule = true;
exports.default = void 0;
var React = <API key>(require("react"));
var _createElement = <API key>(require("../createElement"));
var _css = <API key>(require("../StyleSheet/css"));
var _pick = <API key>(require("../../modules/pick"));
var _useElementLayout = <API key>(require("../../hooks/useElementLayout"));
var _useMergeRefs = <API key>(require("../../modules/useMergeRefs"));
var _usePlatformMethods = <API key>(require("../../hooks/usePlatformMethods"));
var _useResponderEvents = <API key>(require("../../hooks/useResponderEvents"));
var _StyleSheet = <API key>(require("../StyleSheet"));
var <API key> = <API key>(require("../Text/TextAncestorContext"));
function <API key>(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function <API key>() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); <API key> = function <API key>() { return cache; }; return cache; }
function <API key>(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = <API key>(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var <API key> = Object.defineProperty && Object.<API key>; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = <API key> ? Object.<API key>(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var forwardPropsList = {
accessibilityLabel: true,
<API key>: true,
accessibilityRole: true,
accessibilityState: true,
accessibilityValue: true,
accessible: true,
children: true,
classList: true,
disabled: true,
<API key>: true,
nativeID: true,
onBlur: true,
onClick: true,
onClickCapture: true,
onContextMenu: true,
onFocus: true,
onKeyDown: true,
onKeyUp: true,
onTouchCancel: true,
<API key>: true,
onTouchEnd: true,
onTouchEndCapture: true,
onTouchMove: true,
onTouchMoveCapture: true,
onTouchStart: true,
onTouchStartCapture: true,
pointerEvents: true,
ref: true,
style: true,
testID: true,
// unstable
dataSet: true,
onMouseDown: true,
onMouseEnter: true,
onMouseLeave: true,
onMouseMove: true,
onMouseOver: true,
onMouseOut: true,
onMouseUp: true,
onScroll: true,
onWheel: true,
href: true,
rel: true,
target: true
};
var pickProps = function pickProps(props) {
return (0, _pick.default)(props, forwardPropsList);
};
var View = (0, React.forwardRef)(function (props, forwardedRef) {
var onLayout = props.onLayout,
<API key> = props.<API key>,
<API key> = props.<API key>,
onResponderEnd = props.onResponderEnd,
onResponderGrant = props.onResponderGrant,
onResponderMove = props.onResponderMove,
onResponderReject = props.onResponderReject,
onResponderRelease = props.onResponderRelease,
onResponderStart = props.onResponderStart,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>,
<API key> = props.<API key>;
if (process.env.NODE_ENV !== 'production') {
React.Children.toArray(props.children).forEach(function (item) {
if (typeof item === 'string') {
console.error("Unexpected text node: " + item + ". A text node cannot be a child of a <View>.");
}
});
}
var hasTextAncestor = (0, React.useContext)(<API key>.default);
var hostRef = (0, React.useRef)(null);
var classList = [classes.view];
var style = _StyleSheet.default.compose(hasTextAncestor && styles.inline, props.style);
(0, _useElementLayout.default)(hostRef, onLayout);
(0, _useResponderEvents.default)(hostRef, {
<API key>: <API key>,
<API key>: <API key>,
onResponderEnd: onResponderEnd,
onResponderGrant: onResponderGrant,
onResponderMove: onResponderMove,
onResponderReject: onResponderReject,
onResponderRelease: onResponderRelease,
onResponderStart: onResponderStart,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>,
<API key>: <API key>
});
var supportedProps = pickProps(props);
supportedProps.classList = classList;
supportedProps.style = style;
var platformMethodsRef = (0, _usePlatformMethods.default)(hostRef, supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
return (0, _createElement.default)('div', supportedProps);
});
View.displayName = 'View';
var classes = _css.default.create({
view: {
alignItems: 'stretch',
border: '0 solid black',
boxSizing: 'border-box',
display: 'flex',
flexBasis: 'auto',
flexDirection: 'column',
flexShrink: 0,
margin: 0,
minHeight: 0,
minWidth: 0,
padding: 0,
position: 'relative',
zIndex: 0
}
});
var styles = _StyleSheet.default.create({
inline: {
display: 'inline-flex'
}
});
var _default = View;
exports.default = _default;
module.exports = exports.default;
|
package org.eclipse.kura.net;
import java.util.Map;
import org.osgi.annotation.versioning.ProviderType;
import org.osgi.service.event.Event;
/**
* An event raised when a network interface has been removed from the system.
*
* @noextend This class is not intended to be subclassed by clients.
*/
@ProviderType
public class <API key> extends Event {
/** Topic of the <API key> */
public static final String <API key> = "org/eclipse/kura/net/NetworkEvent/interface/REMOVED";
/** Name of the property to access the network interface name */
public static final String <API key> = "network.interface";
public <API key>(Map<String, ?> properties) {
super(<API key>, properties);
}
/**
* Returns the name of the removed interface.
*
* @return
*/
public String getInterfaceName() {
return (String) getProperty(<API key>);
}
}
|
package invalid;
public class <API key> {
private Object field= foo();
public Object foo() {
return field;
}
}
|
#ifndef LANGUAGE_EXTERN_H
#define LANGUAGE_EXTERN_H
#include "<API key>.h"
#include <stdexcept>
#include <fstream>
#include <sstream>
#include "termprinter.h"
#include "termreader.h"
template <typename a>
tosca::StringTerm& PrintTerm(tosca::Context& ctx, tosca::StringTerm& category, a& term)
{
tosca::Term& t = dynamic_cast<tosca::Term&>(term);
return newStringTerm(ctx, tosca::PrintToString(t, true));
}
template <typename a>
a& ParseResource(tosca::Context& ctx, tosca::StringTerm& category, tosca::StringTerm& filename)
{
// TODO: user-defined category
std::fstream input(filename.Unbox().c_str(), std::ios_base::in);
tosca::TermParser parser(&input);
tosca::Term& term = parser.ParseTerm(ctx);
a& result = dynamic_cast<a&>(term);
category.Release();
filename.Release();
return result;
}
template <typename a, typename b>
b& Save(tosca::Context& ctx, tosca::StringTerm& category, tosca::StringTerm& filename, a& term,
tosca::MapTerm<tosca::StringTerm, tosca::StringTerm>& props, b& result)
{
// TODO: user-defined category.
//const std::string& ucat = category.Unbox();
//if (ucat == "" || ucat == "term")
{
std::fstream output(filename.Unbox().c_str(), std::ios_base::out);
tosca::Print(static_cast<tosca::Term&>(term), output, false);
}
category.Release();
filename.Release();
props.Release();
return result;
}
template <typename a>
a& ParseText(tosca::Context& ctx, tosca::StringTerm& category, tosca::StringTerm& content)
{
std::stringstream input(content.Unbox().c_str(), std::ios_base::in);
tosca::TermParser parser(&input);
tosca::Term& term = parser.ParseTerm(ctx);
a& result = dynamic_cast<a&>(term);
category.Release();
content.Release();
return result;
}
#endif
|
package org.rssowl.core.internal.persist.service;
import org.rssowl.core.persist.IEntity;
import org.rssowl.core.persist.event.ModelEvent;
import org.rssowl.core.persist.event.runnable.EventRunnable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
/**
* A {@link Map} of {@link ModelEvent} pointing to {@link EventRunnable}.
*/
public class EventsMap {
private static final EventsMap INSTANCE = new EventsMap();
private static class InternalMap extends HashMap<Class<? extends ModelEvent>, EventRunnable<? extends ModelEvent>> {
InternalMap() {
super();
}
}
private final ThreadLocal<InternalMap> fEvents = new ThreadLocal<InternalMap>();
private final ThreadLocal<Map<IEntity, ModelEvent>> fEventTemplatesMap = new ThreadLocal<Map<IEntity, ModelEvent>>();
private EventsMap() {
// Enforce singleton pattern
}
public final static EventsMap getInstance() {
return INSTANCE;
}
public final void putPersistEvent(ModelEvent event) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(event);
eventRunnable.<API key>(event);
}
public final void putUpdateEvent(ModelEvent event) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(event);
eventRunnable.<API key>(event);
}
public final void putRemoveEvent(ModelEvent event) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(event);
eventRunnable.<API key>(event);
}
public final boolean <API key>(Class<? extends ModelEvent> eventClass, IEntity entity) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(eventClass);
return eventRunnable.getPersistEvents().contains(entity);
}
public final boolean containsUpdateEvent(Class<? extends ModelEvent> eventClass, IEntity entity) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(eventClass);
return eventRunnable.getUpdateEvents().contains(entity);
}
public final boolean containsRemoveEvent(Class<? extends ModelEvent> eventClass, IEntity entity) {
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(eventClass);
return eventRunnable.getRemoveEvents().contains(entity);
}
private EventRunnable<? extends ModelEvent> getEventRunnable(Class<? extends ModelEvent> eventClass) {
InternalMap map = fEvents.get();
if (map == null) {
map = new InternalMap();
fEvents.set(map);
}
EventRunnable<? extends ModelEvent> eventRunnable = map.get(eventClass);
return eventRunnable;
}
private EventRunnable<? extends ModelEvent> getEventRunnable(ModelEvent event) {
Class<? extends ModelEvent> eventClass = event.getClass();
EventRunnable<? extends ModelEvent> eventRunnable = getEventRunnable(eventClass);
if (eventRunnable == null) {
eventRunnable = event.createEventRunnable();
fEvents.get().put(eventClass, eventRunnable);
}
return eventRunnable;
}
public EventRunnable<? extends ModelEvent> removeEventRunnable(Class<? extends ModelEvent> klass) {
InternalMap map = fEvents.get();
if (map == null)
return null;
EventRunnable<? extends ModelEvent> runnable = map.remove(klass);
return runnable;
}
public List<EventRunnable<?>> getEventRunnables() {
InternalMap map = fEvents.get();
if (map == null)
return new ArrayList<EventRunnable<?>>(0);
List<EventRunnable<?>> eventRunnables = new ArrayList<EventRunnable<?>>(map.size());
for (Map.Entry<Class<? extends ModelEvent>, EventRunnable<? extends ModelEvent>> entry : map.entrySet()) {
eventRunnables.add(entry.getValue());
}
return eventRunnables;
}
public List<EventRunnable<?>> <API key>() {
InternalMap map = fEvents.get();
if (map == null)
return new ArrayList<EventRunnable<?>>(0);
List<EventRunnable<?>> eventRunnables = getEventRunnables();
map.clear();
return eventRunnables;
}
public void putEventTemplate(ModelEvent event) {
Map<IEntity, ModelEvent> map = fEventTemplatesMap.get();
if (map == null) {
map = new IdentityHashMap<IEntity, ModelEvent>();
fEventTemplatesMap.set(map);
}
map.put(event.getEntity(), event);
}
public final Map<IEntity, ModelEvent> <API key>() {
Map<IEntity, ModelEvent> map = fEventTemplatesMap.get();
if (map == null)
return Collections.emptyMap();
return Collections.unmodifiableMap(fEventTemplatesMap.get());
}
public Map<IEntity, ModelEvent> <API key>() {
Map<IEntity, ModelEvent> map = fEventTemplatesMap.get();
fEventTemplatesMap.remove();
return map;
}
}
|
package org.eclipse.kura.web.shared.model;
import java.io.Serializable;
import java.util.Date;
import org.eclipse.kura.web.shared.DateUtils;
public class GwtDeviceConfig extends GwtBaseModel implements Serializable {
private static final long serialVersionUID = <API key>;
public GwtDeviceConfig() {
}
@Override
@SuppressWarnings({ "unchecked" })
public <X> X get(String property) {
if ("<API key>".equals(property)) {
return (X) DateUtils.formatDateTime((Date) get("lastEventOn"));
} else if ("uptimeFormatted".equals(property)) {
if (getUptime() == -1) {
return (X) "Unknown";
} else {
return (X) String.valueOf(getUptime());
}
} else {
return super.get(property);
}
}
public String getAccountName() {
return get("accountName");
}
public void setAccountName(String accountName) {
set("accountName", accountName);
}
public String getClientId() {
return (String) get("clientId");
}
public void setClientId(String clientId) {
set("clientId", clientId);
}
public Long getUptime() {
return (Long) get("uptime");
}
public String getUptimeFormatted() {
return (String) get("uptimeFormatted");
}
public void setUptime(Long uptime) {
set("uptime", uptime);
}
public String getGwtDeviceStatus() {
return (String) get("gwtDeviceStatus");
}
public void setGwtDeviceStatus(String gwtDeviceStatus) {
set("gwtDeviceStatus", gwtDeviceStatus);
}
public String getDisplayName() {
return (String) get("displayName");
}
public void setDisplayName(String displayName) {
set("displayName", displayName);
}
public String getModelName() {
return (String) get("modelName");
}
public void setModelName(String modelName) {
set("modelName", modelName);
}
public String getModelId() {
return (String) get("modelId");
}
public void setModelId(String modelId) {
set("modelId", modelId);
}
public String getPartNumber() {
return (String) get("partNumber");
}
public void setPartNumber(String partNumber) {
set("partNumber", partNumber);
}
public String getSerialNumber() {
return (String) get("serialNumber");
}
public void setSerialNumber(String serialNumber) {
set("serialNumber", serialNumber);
}
public String <API key>() {
return (String) get("availableProcessors");
}
public void <API key>(String availableProcessors) {
set("availableProcessors", availableProcessors);
}
public String getTotalMemory() {
return (String) get("totalMemory");
}
public void setTotalMemory(String totalMemory) {
set("totalMemory", totalMemory);
}
public String getFirmwareVersion() {
return (String) get("firmwareVersion");
}
public void setFirmwareVersion(String firmwareVersion) {
set("firmwareVersion", firmwareVersion);
}
public String getBiosVersion() {
return (String) get("biosVersion");
}
public void setBiosVersion(String biosVersion) {
set("biosVersion", biosVersion);
}
public String getOs() {
return (String) get("os");
}
public void setOs(String os) {
set("os", os);
}
public String getOsVersion() {
return (String) get("osVersion");
}
public void setOsVersion(String osVersion) {
set("osVersion", osVersion);
}
public String getOsArch() {
return (String) get("osArch");
}
public void setOsArch(String osArch) {
set("osArch", osArch);
}
public String getJvmName() {
return (String) get("jvmName");
}
public void setJvmName(String jvmName) {
set("jvmName", jvmName);
}
public String getJvmVersion() {
return (String) get("jvmVersion");
}
public void setJvmVersion(String jvmVersion) {
set("jvmVersion", jvmVersion);
}
public String getJvmProfile() {
return (String) get("jvmProfile");
}
public void setJvmProfile(String jvmProfile) {
set("jvmProfile", jvmProfile);
}
public String getOsgiFramework() {
return (String) get("osgiFramework");
}
public void setOsgiFramework(String osgiFramework) {
set("osgiFramework", osgiFramework);
}
public String <API key>() {
return (String) get("<API key>");
}
public void <API key>(String <API key>) {
set("<API key>", <API key>);
}
public String <API key>() {
return (String) get("connectionInterface");
}
public void <API key>(String connectionInterface) {
set("connectionInterface", connectionInterface);
}
public String getConnectionIp() {
return (String) get("connectionIp");
}
public void setConnectionIp(String connectionIp) {
set("connectionIp", connectionIp);
}
public String getAcceptEncoding() {
return (String) get("acceptEncoding");
}
public void setAcceptEncoding(String acceptEncoding) {
set("acceptEncoding", acceptEncoding);
}
public String <API key>() {
return (String) get("<API key>");
}
public void <API key>(String <API key>) {
set("<API key>", <API key>);
}
public Double getGpsLatitude() {
return (Double) get("gpsLatitude");
}
public void setGpsLatitude(Double gpsLatitude) {
set("gpsLatitude", gpsLatitude);
}
public Double getGpsLongitude() {
return (Double) get("gpsLongitude");
}
public void setGpsLongitude(Double gpsLongitude) {
set("gpsLongitude", gpsLongitude);
}
public Double getGpsAltitude() {
return (Double) get("gpsAltitude");
}
public void setGpsAltitude(Double gpsAltitude) {
set("gpsAltitude", gpsAltitude);
}
public String getGpsAddress() {
return (String) get("gpsAddress");
}
public void setGpsAddress(String gpsAddress) {
set("gpsAddress", gpsAddress);
}
public Date getLastEventOn() {
return (Date) get("lastEventOn");
}
public String <API key>() {
return (String) get("<API key>");
}
public void setLastEventOn(Date lastEventDate) {
set("lastEventOn", lastEventDate);
}
public String getLastEventType() {
return (String) get("lastEventType");
}
public void setLastEventType(String lastEventType) {
set("lastEventType", lastEventType);
}
public boolean isOnline() {
return getGwtDeviceStatus().compareTo("CONNECTED") == 0;
}
}
|
package org.opendaylight.controller.sal.connector.remoterpc;
import com.google.common.base.Optional;
import junit.framework.Assert;
import org.junit.*;
import org.opendaylight.controller.sal.connector.api.RpcRouter;
import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.<API key>;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.zeromq.ZMQ;
import zmq.Ctx;
import zmq.SocketBase;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ServerImplTest {
private static ZMQ.Context context;
private ServerImpl server;
private Broker.ProviderSession brokerSession;
private <API key> <API key>;
private <API key> listener;
ExecutorService pool;
//Server configuration
private final int HANDLER_COUNT = 2;
private final int HWM = 200;
private final int port = 5554;
//server address
private final String SERVER_ADDRESS = "tcp://localhost:5554";
//@BeforeClass
public static void init() {
context = ZMQ.context(1);
}
//@AfterClass
public static void destroy() {
MessagingUtil.closeZmqContext(context);
}
@Before
public void setup() throws <API key> {
context = ZMQ.context(1);
brokerSession = mock(Broker.ProviderSession.class);
<API key> = mock(<API key>.class);
listener = mock(<API key>.class);
server = new ServerImpl(port);
server.setBrokerSession(brokerSession);
RoutingTable<RpcRouter.RouteIdentifier, String> mockRoutingTable = new MockRoutingTable<String, String>();
Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> <API key> = Optional.fromNullable(mockRoutingTable);
when(<API key>.getRoutingTable()).thenReturn(<API key>);
when(brokerSession.<API key>(listener)).thenReturn(null);
when(brokerSession.getSupportedRpcs()).thenReturn(Collections.EMPTY_SET);
when(brokerSession.rpc(null, mock(CompositeNode.class))).thenReturn(null);
server.start();
Thread.sleep(5000);//wait for server to start
}
@After
public void tearDown() throws <API key> {
if (pool != null)
pool.shutdown();
if (server != null)
server.stop();
MessagingUtil.closeZmqContext(context);
Thread.sleep(5000);//wait for server to stop
Assert.assertEquals(ServerImpl.State.STOPPED, server.getStatus());
}
@Test
public void <API key>() throws Exception {
Optional<Broker.ProviderSession> mayBeBroker = server.getBrokerSession();
if (mayBeBroker.isPresent())
Assert.assertEquals(brokerSession, mayBeBroker.get());
else
Assert.fail("Broker does not exist in Remote RPC Server");
}
@Test
public void <API key>() throws Exception {
Assert.assertEquals(ServerImpl.State.STARTED, server.getStatus());
}
@Test
public void <API key>() throws Exception {
final int EXPECTED_COUNT = 2 + HANDLER_COUNT; //1 ROUTER + 1 DEALER + HANDLER_COUNT
Optional<ZMQ.Context> mayBeContext = server.getZmqContext();
if (mayBeContext.isPresent())
Assert.assertEquals(EXPECTED_COUNT, findSocketCount(mayBeContext.get()));
else
Assert.fail("ZMQ Context does not exist in Remote RPC Server");
}
@Test
public void <API key>() {
final String SERVER_THREAD_NAME = "remote-rpc-server";
final int EXPECTED_COUNT = 1;
List<Thread> serverThreads = findThreadsWithName(SERVER_THREAD_NAME);
Assert.assertEquals(EXPECTED_COUNT, serverThreads.size());
}
@Test
public void <API key>() {
//final String WORKER_THREAD_NAME = "remote-rpc-worker";
final int EXPECTED_COUNT = HANDLER_COUNT;
Optional<<API key>> <API key> = server.getHandler();
if (<API key>.isPresent()){
<API key> handler = <API key>.get();
ThreadPoolExecutor workerPool = handler.getWorkerPool();
Assert.assertEquals(EXPECTED_COUNT, workerPool.getPoolSize());
} else {
Assert.fail("Server is in illegal state. ServerHandler does not exist");
}
}
@Test
public void testStop() throws Exception {
}
@Test
public void testOnRouteUpdated() throws Exception {
}
@Test
public void testOnRouteDeleted() throws Exception {
}
private int findSocketCount(ZMQ.Context context)
throws <API key>, <API key> {
Field ctxField = context.getClass().getDeclaredField("ctx");
ctxField.setAccessible(true);
Ctx ctx = Ctx.class.cast(ctxField.get(context));
Field socketListField = ctx.getClass().getDeclaredField("sockets");
socketListField.setAccessible(true);
List<SocketBase> sockets = List.class.cast(socketListField.get(ctx));
return sockets.size();
}
private List<Thread> findThreadsWithName(String name) {
Thread[] threads = new Thread[Thread.activeCount()];
Thread.enumerate(threads);
List<Thread> foundThreads = new ArrayList();
for (Thread t : threads) {
if (t.getName().startsWith(name))
foundThreads.add(t);
}
return foundThreads;
}
}
|
package com.vogella.e4.appmodel.app.handlers;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
public class QuitHandler {
@Execute
public void execute(IWorkbench workbench, Shell shell){
if (MessageDialog.openConfirm(shell, "Confirmation",
"Do you want to exit?")) {
workbench.close();
}
}
}
|
package org.eclipse.che.ide.ext.git.client.compare;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.ext.git.client.compare.FileStatus.Status;
/**
* Describes changed in any way project files. Supports adding and removing items dynamically.
*
* @author Mykola Morhun
*/
public class MutableAlteredFiles extends AlteredFiles {
/**
* Parses raw git diff string and creates advanced representation.
*
* @param project the project under diff operation
* @param diff plain result of git diff operation
*/
public MutableAlteredFiles(Project project, String diff) {
super(project, diff);
}
/**
* Creates mutable altered files list based on changes from another project.
*
* @param project the project under diff operation
* @param alteredFiles changes from another project
*/
public MutableAlteredFiles(Project project, AlteredFiles alteredFiles) {
super(project, "");
this.<API key>.putAll(alteredFiles.<API key>);
this.alteredFilesList.addAll(alteredFiles.alteredFilesList);
}
/**
* Creates an empty list of altered files.
*
* @param project the project under diff operation
*/
public MutableAlteredFiles(Project project) {
super(project, "");
}
/**
* Adds or updates a file in altered file list. If given file is already exists does nothing.
*
* @param file full path to file and its name relatively to project root
* @param status git status of the file
* @return true if file was added or updated and false if the file is already exists in this list
*/
public boolean addFile(String file, Status status) {
if (status.equals(<API key>.get(file))) {
return false;
}
if (<API key>.put(file, status) == null) {
// it's not a status change, new file was added
alteredFilesList.add(file);
}
return true;
}
/**
* Removes given file from the altered files list. If given file isn't present does nothing.
*
* @param file full path to file and its name relatively to project root
* @return true if the file was deleted and false otherwise
*/
public boolean removeFile(String file) {
<API key>.remove(file);
return alteredFilesList.remove(file);
}
}
|
<!DOCTYPE HTML PUBLIC "-
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Thu Sep 12 10:51:18 BST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Uses of Interface com.hp.hpl.jena.rdf.model.ModelGraphInterface (Apache Jena)</title>
<meta name="date" content="2013-09-12">
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Interface com.hp.hpl.jena.rdf.model.ModelGraphInterface (Apache Jena)";
}
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="topNav"><a name="navbar_top">
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?com/hp/hpl/jena/rdf/model/class-use/ModelGraphInterface.html" target="_top">Frames</a></li>
<li><a href="ModelGraphInterface.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_top">
</a></div>
<div class="header">
<h2 title="Uses of Interface com.hp.hpl.jena.rdf.model.ModelGraphInterface" class="title">Uses of Interface<br>com.hp.hpl.jena.rdf.model.ModelGraphInterface</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="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</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="#com.hp.hpl.jena.ontology">com.hp.hpl.jena.ontology</a></td>
<td class="colLast">
<div class="block">
Provides a set of abstractions and convenience classes for accessing and manipluating ontologies
represented in RDF.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="#com.hp.hpl.jena.rdf.model">com.hp.hpl.jena.rdf.model</a></td>
<td class="colLast">
<div class="block">A package for creating and manipulating RDF graphs.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="#com.hp.hpl.jena.rdf.model.impl">com.hp.hpl.jena.rdf.model.impl</a></td>
<td class="colLast">
<div class="block">This package contains implementations of the interfaces defined
in the .model package, eg ModelCom for Model, ResourceImpl
for Resource, and so on.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="#com.hp.hpl.jena.util">com.hp.hpl.jena.util</a></td>
<td class="colLast">
<div class="block">
Miscellaneous collection of utility classes.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="com.hp.hpl.jena.ontology">
</a>
<h3>Uses of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in <a href="../../../../../../../com/hp/hpl/jena/ontology/package-summary.html">com.hp.hpl.jena.ontology</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subinterfaces, and an explanation">
<caption><span>Subinterfaces of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in <a href="../../../../../../../com/hp/hpl/jena/ontology/package-summary.html">com.hp.hpl.jena.ontology</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Interface and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>interface </code></td>
<td class="colLast"><code><strong><a href="../../../../../../../com/hp/hpl/jena/ontology/OntModel.html" title="interface in com.hp.hpl.jena.ontology">OntModel</a></strong></code>
<div class="block">
An enhanced view of a Jena model that is known to contain ontology
data, under a given ontology <a href="../../../../../../../com/hp/hpl/jena/ontology/Profile.html" title="interface in com.hp.hpl.jena.ontology"><code>vocabulary</code></a> (such as OWL).</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="com.hp.hpl.jena.rdf.model">
</a>
<h3>Uses of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in <a href="../../../../../../../com/hp/hpl/jena/rdf/model/package-summary.html">com.hp.hpl.jena.rdf.model</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subinterfaces, and an explanation">
<caption><span>Subinterfaces of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in <a href="../../../../../../../com/hp/hpl/jena/rdf/model/package-summary.html">com.hp.hpl.jena.rdf.model</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Interface and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>interface </code></td>
<td class="colLast"><code><strong><a href="../../../../../../../com/hp/hpl/jena/rdf/model/InfModel.html" title="interface in com.hp.hpl.jena.rdf.model">InfModel</a></strong></code>
<div class="block">An extension to the normal Model interface that supports access to any
underlying inference capability.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>interface </code></td>
<td class="colLast"><code><strong><a href="../../../../../../../com/hp/hpl/jena/rdf/model/Model.html" title="interface in com.hp.hpl.jena.rdf.model">Model</a></strong></code>
<div class="block">An RDF Model.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="com.hp.hpl.jena.rdf.model.impl">
</a>
<h3>Uses of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in com.hp.hpl.jena.rdf.model.impl</h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation">
<caption><span>Classes in com.hp.hpl.jena.rdf.model.impl that implement <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><strong>com.hp.hpl.jena.rdf.model.impl.ModelCom</strong></code>
<div class="block">Common methods for model implementations.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="com.hp.hpl.jena.util">
</a>
<h3>Uses of <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a> in <a href="../../../../../../../com/hp/hpl/jena/util/package-summary.html">com.hp.hpl.jena.util</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation">
<caption><span>Classes in <a href="../../../../../../../com/hp/hpl/jena/util/package-summary.html">com.hp.hpl.jena.util</a> that implement <a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">ModelGraphInterface</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><strong><a href="../../../../../../../com/hp/hpl/jena/util/MonitorModel.html" title="class in com.hp.hpl.jena.util">MonitorModel</a></strong></code>
<div class="block">Model wrapper which provides normal access to an underlying model but
also maintains a snapshot of the triples it was last known to contain.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="bottomNav"><a name="navbar_bottom">
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>">
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../com/hp/hpl/jena/rdf/model/ModelGraphInterface.html" title="interface in com.hp.hpl.jena.rdf.model">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?com/hp/hpl/jena/rdf/model/class-use/ModelGraphInterface.html" target="_top">Frames</a></li>
<li><a href="ModelGraphInterface.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_bottom">
</a></div>
<p class="legalCopy"><small>Licenced under the Apache License, Version 2.0</small></p>
</body>
</html>
|
package org.csstudio.trends.databrowser2.propsheet;
import org.csstudio.swt.rtplot.undo.<API key>;
import org.csstudio.trends.databrowser2.Activator;
import org.csstudio.trends.databrowser2.Messages;
import org.csstudio.trends.databrowser2.model.PVItem;
import org.csstudio.trends.databrowser2.preferences.Preferences;
import org.eclipse.jface.action.Action;
/** Action that configures PVs to use default archive data sources.
* @author Kay Kasemir
*/
public class <API key> extends Action
{
final private <API key> operations_manager;
final private PVItem pvs[];
/** Initialize
* @param shell Parent shell for dialog
* @param pvs PVs that should use default archives
*/
public <API key>(final <API key> operations_manager,
final PVItem pvs[])
{
super(Messages.UseDefaultArchives,
Activator.getDefault().getImageDescriptor("icons/archive.gif")); //$NON-NLS-1$
this.operations_manager = operations_manager;
this.pvs = pvs;
}
@Override
public void run()
{
new AddArchiveCommand(operations_manager, pvs, Preferences.getArchives(), true);
}
}
|
package MWC.GUI.Properties.Swing;
// $RCSfile: <API key>.java,v $
// @version $Revision: 1.3 $
// $Log: <API key>.java,v $
// Revision 1.3 2004/11/26 11:32:48 Ian.Mayo
// Moving closer, supporting checking for time resolution
// Revision 1.2 2004/05/25 15:29:37 Ian.Mayo
// Commit updates from home
// Revision 1.1.1.1 2004/03/04 20:31:20 ian
// no message
// Revision 1.1.1.1 2003/07/17 10:07:26 Ian.Mayo
// Initial import
// Revision 1.2 2002-05-28 09:25:47+01 ian_mayo
// after switch to new system
// Revision 1.1 2002-05-28 09:14:33+01 ian_mayo
// Initial revision
// Revision 1.1 2002-04-11 14:01:26+01 ian_mayo
// Initial revision
// Revision 1.1 2001-08-31 10:36:55+01 administrator
// Tidied up layout, so all data is displayed when editor panel is first opened
// Revision 1.0 2001-07-17 08:43:31+01 administrator
// Initial revision
// Revision 1.4 2001-07-12 12:06:59+01 novatech
// use tooltips to show the date format
// Revision 1.3 2001-01-21 21:38:23+00 novatech
// handle focusGained = select all text
// Revision 1.2 2001-01-17 09:41:37+00 novatech
// factor generic processing to parent class, and provide support for NULL values
// Revision 1.1 2001-01-03 13:42:39+00 novatech
// Initial revision
// Revision 1.1.1.1 2000/12/12 21:45:37 ianmayo
// initial version
// Revision 1.5 2000-10-09 13:35:47+01 ian_mayo
// Switched stack traces to go to log file
// Revision 1.4 2000-04-03 10:48:57+01 ian_mayo
// squeeze up the controls
// Revision 1.3 2000-02-02 14:25:07+00 ian_mayo
// correct package naming
// Revision 1.2 1999-11-23 11:05:03+00 ian_mayo
// further introduction of SWING components
// Revision 1.1 1999-11-16 16:07:19+00 ian_mayo
// Initial revision
// Revision 1.1 1999-11-16 16:02:29+00 ian_mayo
// Initial revision
// Revision 1.2 1999-11-11 18:16:09+00 ian_mayo
// new class, now working
// Revision 1.1 1999-10-12 15:36:48+01 ian_mayo
// Initial revision
// Revision 1.1 1999-08-26 10:05:48+01 administrator
// Initial revision
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import MWC.GUI.Dialogs.DialogFactory;
import MWC.GenericData.HiResDate;
import MWC.Utilities.TextFormatting.<API key>;
public class <API key> extends
MWC.GUI.Properties.DatePropertyEditor implements java.awt.event.FocusListener
{
// member variables
/**
* field to edit the date
*/
JTextField _theDate;
/**
* field to edit the time
*/
JTextField _theTime;
/**
* label to show the microsecodns
*/
JLabel _theMicrosTxt;
/**
* panel to hold everything
*/
JPanel _theHolder;
// constructor
// member functions
/**
* build the editor
*/
public java.awt.Component getCustomEditor()
{
_theHolder = new JPanel();
final java.awt.BorderLayout bl1 = new java.awt.BorderLayout();
bl1.setVgap(0);
bl1.setHgap(0);
final java.awt.BorderLayout bl2 = new java.awt.BorderLayout();
bl2.setVgap(0);
bl2.setHgap(0);
final JPanel lPanel = new JPanel();
lPanel.setLayout(bl1);
final JPanel rPanel = new JPanel();
rPanel.setLayout(bl2);
_theHolder.setLayout(new java.awt.GridLayout(0, 2));
_theDate = new JTextField();
_theDate.setToolTipText("Format: " + NULL_DATE);
_theTime = new JTextField();
_theTime.setToolTipText("Format: " + NULL_TIME);
lPanel.add("Center", new JLabel("Date:", JLabel.RIGHT));
lPanel.add("East", _theDate);
rPanel.add("Center", new JLabel("Time:", JLabel.RIGHT));
rPanel.add("East", _theTime);
_theHolder.add(lPanel);
_theHolder.add(rPanel);
// get the fields to select the full text when they're selected
_theDate.addFocusListener(this);
_theTime.addFocusListener(this);
// right, just see if we are in hi-res DTG editing mode
if (HiResDate.<API key>())
{
// ok, add a button to allow the user to enter DTG data
final JButton editMicros = new JButton("Micros");
editMicros.addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent e)
{
editMicrosPressed();
}
});
// ok, we'
_theMicrosTxt = new JLabel("..");
_theHolder.add(_theMicrosTxt);
_theHolder.add(editMicros);
}
resetData();
return _theHolder;
}
/**
* user wants to edit the microseconds. give him a popup
*/
void editMicrosPressed()
{
//To change body of created methods use File | Settings | File Templates.
final Integer res = DialogFactory.getInteger("Edit microseconds", "Enter microseconds",(int) _theMicros);
// did user enter anything?
if(res != null)
{
// store the data
_theMicros = res.intValue();
// and update the screen
resetData();
}
}
/**
* get the date text as a string
*/
protected String getDateText()
{
return _theDate.getText();
}
/**
* get the date text as a string
*/
protected String getTimeText()
{
return _theTime.getText();
}
/**
* set the date text in string form
*/
protected void setDateText(final String val)
{
if (_theHolder != null)
{
_theDate.setText(val);
}
}
/**
* set the time text in string form
*/
protected void setTimeText(final String val)
{
if (_theHolder != null)
{
_theTime.setText(val);
}
}
/**
* show the user how many microseconds there are
*
* @param val
*/
protected void setMicroText(final long val)
{
// output the number of microseconds
_theMicrosTxt.setText(<API key>.formatMicros(new HiResDate(0, val)) + " micros");
}
// focus listener support classes
/**
* Invoked when a component gains the keyboard focus.
*/
public void focusGained(final FocusEvent e)
{
final java.awt.Component c = e.getComponent();
if (c instanceof JTextField)
{
final JTextField jt = (JTextField) c;
jt.setSelectionStart(0);
jt.setSelectionEnd(jt.getText().length());
}
}
/**
* Invoked when a component loses the keyboard focus.
*/
public void focusLost(final FocusEvent e)
{
}
}
|
@defgroup cpPinJoint cpPinJoint
@{
const cpConstraintClass *cpPinJointGetClass(void);
@private
typedef struct cpPinJoint {
cpConstraint constraint;
cpVect anchr1, anchr2;
cpFloat dist;
cpVect r1, r2;
cpVect n;
cpFloat nMass;
cpFloat jnAcc;
cpFloat bias;
} cpPinJoint;
Allocate a pin joint.
cpPinJoint* cpPinJointAlloc(void);
Initialize a pin joint.
cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
Allocate and initialize a pin joint.
cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
<API key>(cpPinJoint, cpVect, anchr1, Anchr1)
<API key>(cpPinJoint, cpVect, anchr2, Anchr2)
<API key>(cpPinJoint, cpFloat, dist, Dist)
@}
|
#include "Polar/Polar.hpp"
#include "Engine/GlideSolvers/PolarCoefficients.hpp"
#include "Units/System.hpp"
#include <stdlib.h>
#include <cstdio>
PolarCoefficients
PolarInfo::<API key>() const
{
return PolarCoefficients::From3VW(v1, v2, v3, w1, w2, w3);
}
bool
PolarInfo::IsValid() const
{
return <API key>().IsValid();
}
void
PolarInfo::GetString(TCHAR* line, size_t size, bool include_v_no) const
{
fixed V1, V2, V3;
V1 = Units::ToUserUnit(v1, Unit::KILOMETER_PER_HOUR);
V2 = Units::ToUserUnit(v2, Unit::KILOMETER_PER_HOUR);
V3 = Units::ToUserUnit(v3, Unit::KILOMETER_PER_HOUR);
if (include_v_no)
_sntprintf(line, size, _T("%.0f,%.0f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f"),
(double)reference_mass, (double)max_ballast, (double)V1, (double)w1,
(double)V2, (double)w2, (double)V3, (double)w3,
(double)wing_area, (double)v_no);
else
_sntprintf(line, size, _T("%.0f,%.0f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f"),
(double)reference_mass, (double)max_ballast, (double)V1, (double)w1,
(double)V2, (double)w2, (double)V3, (double)w3,
(double)wing_area);
}
bool
PolarInfo::ReadString(const TCHAR *line)
{
PolarInfo polar;
// Example:
// *LS-3 WinPilot POLAR file: MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3
// 403, 101, 115.03, -0.86, 174.04, -1.76, 212.72, -3.4
if (line[0] == _T('*'))
/* a comment */
return false;
TCHAR *p;
polar.reference_mass = fixed(_tcstod(line, &p));
if (*p != _T(','))
return false;
polar.max_ballast = fixed(_tcstod(p + 1, &p));
if (*p != _T(','))
return false;
polar.v1 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR);
if (*p != _T(','))
return false;
polar.w1 = fixed(_tcstod(p + 1, &p));
if (*p != _T(','))
return false;
polar.v2 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR);
if (*p != _T(','))
return false;
polar.w2 = fixed(_tcstod(p + 1, &p));
if (*p != _T(','))
return false;
polar.v3 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR);
if (*p != _T(','))
return false;
polar.w3 = fixed(_tcstod(p + 1, &p));
polar.wing_area = (*p != _T(',')) ? fixed_zero : fixed(_tcstod(p + 1, &p));
polar.v_no = (*p != _T(',')) ? fixed_zero : fixed(_tcstod(p + 1, &p));
*this = polar;
return true;
}
|
package io.mycat.backend.postgresql;
import java.io.IOException;
import java.io.<API key>;
import java.nio.ByteBuffer;
import java.nio.channels.NetworkChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import io.mycat.backend.jdbc.ShowVariables;
import io.mycat.backend.mysql.CharsetUtil;
import io.mycat.backend.mysql.nio.<API key>;
import io.mycat.backend.mysql.nio.handler.ResponseHandler;
import io.mycat.backend.postgresql.packet.Query;
import io.mycat.backend.postgresql.packet.Terminate;
import io.mycat.backend.postgresql.utils.PIOUtils;
import io.mycat.backend.postgresql.utils.PacketUtils;
import io.mycat.backend.postgresql.utils.PgSqlApaterUtils;
import io.mycat.config.Isolations;
import io.mycat.net.<API key>;
import io.mycat.route.RouteResultsetNode;
import io.mycat.server.ServerConnection;
import io.mycat.server.parser.ServerParse;
import io.mycat.util.exception.<API key>;
/*************************************************************
* PostgreSQL Native Connection impl
*
* @author Coollf
*
*/
public class <API key> extends <API key> {
public static enum <API key> {
closed, connected, connecting
}
private static class StatusSync {
private final Boolean autocommit;
private final Integer charsetIndex;
private final String schema;
private final AtomicInteger synCmdCount;
private final Integer txtIsolation;
private final boolean xaStarted;
public StatusSync(boolean xaStarted, String schema, Integer charsetIndex, Integer txtIsolation,
Boolean autocommit, int synCount) {
super();
this.xaStarted = xaStarted;
this.schema = schema;
this.charsetIndex = charsetIndex;
this.txtIsolation = txtIsolation;
this.autocommit = autocommit;
this.synCmdCount = new AtomicInteger(synCount);
}
public boolean synAndExecuted(<API key> conn) {
int remains = synCmdCount.decrementAndGet();
if (remains == 0) {// syn command finished
this.<API key>(conn);
conn.metaDataSyned = true;
return false;
} else if (remains < 0) {
return true;
}
return false;
}
private void <API key>(<API key> conn)
{
conn.xaStatus = (xaStarted) ? 1 : 0;
if (schema != null) {
conn.schema = schema;
conn.oldSchema = conn.schema;
}
if (charsetIndex != null) {
conn.setCharset(CharsetUtil.getCharset(charsetIndex));
}
if (txtIsolation != null) {
conn.txIsolation = txtIsolation;
}
if (autocommit != null) {
conn.autocommit = autocommit;
}
}
}
private static final Query _COMMIT = new Query("commit");
private static final Query _ROLLBACK = new Query("rollback");
private static void getCharsetCommand(StringBuilder sb, int clientCharIndex) {
sb.append("SET names '").append(CharsetUtil.getCharset(clientCharIndex).toUpperCase()).append("';");
}
/**
* sql
*
* @param
* @param txIsolation
*/
private static void <API key>(StringBuilder sb, int txIsolation) {
switch (txIsolation) {
case Isolations.READ_UNCOMMITTED:
sb.append("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
return;
case Isolations.READ_COMMITTED:
sb.append("SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;");
return;
case Isolations.REPEATED_READ:
sb.append("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;");
return;
case Isolations.SERIALIZABLE:
sb.append("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;");
return;
default:
throw new <API key>("txIsolation:" + txIsolation);
}
}
private Object attachment;
private volatile boolean autocommit=true;
private volatile boolean borrowed;
protected volatile String charset = "utf8";
private volatile String currentXaTxId;
private volatile boolean fromSlaveDB;
private volatile boolean inTransaction = false;
private AtomicBoolean isQuit = new AtomicBoolean(false);
private volatile long lastTime;
private volatile boolean metaDataSyned = true;
private volatile boolean modifiedSQLExecuted = false;
private volatile String oldSchema;
private volatile String password;
private <API key> pool;
/***
* handler
*/
private volatile ResponseHandler responseHandler;
private volatile String schema;
// PostgreSQL
private volatile int serverSecretKey;
private volatile <API key> state = <API key>.connecting;
private volatile StatusSync statusSync;
private volatile int txIsolation;
private volatile String user;
private volatile int xaStatus;
public <API key>(NetworkChannel channel, boolean fromSlaveDB) {
super(channel);
this.fromSlaveDB = fromSlaveDB;
}
@Override
public void commit() {
ByteBuffer buf = this.allocate();
_COMMIT.write(buf);
this.write(buf);
}
@Override
public void execute(RouteResultsetNode rrn, ServerConnection sc, boolean autocommit) throws IOException {
int sqlType = rrn.getSqlType();
String orgin = rrn.getStatement();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{}{}", id, rrn.getStatement());
LOGGER.debug(orgin);
}
if (sqlType == ServerParse.SELECT || sqlType == ServerParse.SHOW) {
if (sqlType == ServerParse.SHOW) {
//SHOW
String _newSql = PgSqlApaterUtils.apater(orgin);
if(_newSql.trim().substring(0,4).equalsIgnoreCase("show")){
ShowVariables.execute(sc, orgin, this);
return;
}
} else if ("SELECT CONNECTION_ID()".equalsIgnoreCase(orgin)) {
ShowVariables.justReturnValue(sc, String.valueOf(sc.getId()), this);
return;
}
}
if (!modifiedSQLExecuted && rrn.isModifySQL()) {
modifiedSQLExecuted = true;
}
String xaTXID = sc.getSession2().getXaTXID();
synAndDoExecute(xaTXID, rrn, sc.getCharsetIndex(), sc.getTxIsolation(), autocommit);
}
@Override
public Object getAttachment() {
return attachment;
}
private void <API key>(StringBuilder sb, boolean autoCommit) {
if (autoCommit) {
sb.append(/*"SET autocommit=1;"*/"");//Fix bug PG9.0
} else {
sb.append("begin transaction;");
}
}
@Override
public long getLastTime() {
return lastTime;
}
public String getPassword() {
return password;
}
public <API key> getPool() {
return pool;
}
public ResponseHandler getResponseHandler() {
return responseHandler;
}
@Override
public String getSchema() {
return this.schema;
}
public int getServerSecretKey() {
return serverSecretKey;
}
public <API key> getState() {
return state;
}
@Override
public int getTxIsolation() {
return txIsolation;
}
public String getUser() {
return user;
}
@Override
public boolean isAutocommit() {
return autocommit;
}
@Override
public boolean isBorrowed() {
return borrowed;
}
@Override
public boolean isClosedOrQuit() {
return isClosed() || isQuit.get();
}
@Override
public boolean isFromSlaveDB() {
return fromSlaveDB;
}
public boolean isInTransaction() {
return inTransaction;
}
@Override
public boolean <API key>() {
return modifiedSQLExecuted;
}
@Override
public void onConnectFailed(Throwable t) {
if (handler instanceof <API key>) {
}
}
@Override
public void onConnectfinish() {
LOGGER.debug("");
try {
SocketChannel chan = (SocketChannel) this.channel;
ByteBuffer buf = PacketUtils.makeStartUpPacket(user, schema);
buf.flip();
chan.write(buf);
} catch (Exception e) {
LOGGER.error("Connected PostgreSQL Send StartUpPacket ERROR", e);
throw new RuntimeException(e);
}
}
protected final int getPacketLength(ByteBuffer buffer, int offset) {
// Pg mysql
return PIOUtils.redInteger4(buffer, offset + 1) + 1;
}
@Override
public void query(String query) throws <API key> {
RouteResultsetNode rrn = new RouteResultsetNode("default", ServerParse.SELECT, query);
synAndDoExecute(null, rrn, this.charsetIndex, this.txIsolation, true);
}
@Override
public void quit() {
if (isQuit.compareAndSet(false, true) && !isClosed()) {
if (state == <API key>.connected) {// PostgreSQL
Terminate terminate = new Terminate();
ByteBuffer buf = this.allocate();
terminate.write(buf);
write(buf);
} else {
close("normal");
}
}
}
/*******
* sql
*/
@Override
public void recordSql(String host, String schema, String statement) {
LOGGER.debug(String.format("executed sql: host=%s,schema=%s,statement=%s", host, schema, statement));
}
@Override
public void release() {
if (!metaDataSyned) {/*
* indicate connection not normalfinished ,and
* we can't know it's syn status ,so close it
*/
LOGGER.warn("can't sure connection syn result,so close it " + this);
this.responseHandler = null;
this.close("syn status unkown ");
return;
}
metaDataSyned = true;
attachment = null;
statusSync = null;
modifiedSQLExecuted = false;
setResponseHandler(null);
pool.releaseChannel(this);
}
@Override
public void rollback() {
ByteBuffer buf = this.allocate();
_ROLLBACK.write(buf);
this.write(buf);
}
@Override
public void setAttachment(Object attachment) {
this.attachment = attachment;
}
@Override
public void setBorrowed(boolean borrowed) {
this.borrowed = borrowed;
}
public void setInTransaction(boolean inTransaction) {
this.inTransaction = inTransaction;
}
@Override
public void setLastTime(long currentTimeMillis) {
this.lastTime = currentTimeMillis;
}
public void setPassword(String password) {
this.password = password;
}
public void setPool(<API key> pool) {
this.pool = pool;
}
@Override
public boolean setResponseHandler(ResponseHandler commandHandler) {
this.responseHandler = commandHandler;
return true;
}
@Override
public void setSchema(String newSchema) {
String curSchema = schema;
if (curSchema == null) {
this.schema = newSchema;
this.oldSchema = newSchema;
} else {
this.oldSchema = curSchema;
this.schema = newSchema;
}
}
public void setServerSecretKey(int serverSecretKey) {
this.serverSecretKey = serverSecretKey;
}
public void setState(<API key> state) {
this.state = state;
}
public void setUser(String user) {
this.user = user;
}
private void synAndDoExecute(String xaTxID, RouteResultsetNode rrn, int clientCharSetIndex, int clientTxIsoLation,
boolean clientAutoCommit) {
String xaCmd = null;
boolean conAutoComit = this.autocommit;
String conSchema = this.schema;
// never executed modify sql,so auto commit
boolean expectAutocommit = !modifiedSQLExecuted || isFromSlaveDB() || clientAutoCommit;
if (!expectAutocommit && xaTxID != null && xaStatus == 0) {
clientTxIsoLation = Isolations.SERIALIZABLE;
xaCmd = "XA START " + xaTxID + ';';
currentXaTxId = xaTxID;
}
int schemaSyn = conSchema.equals(oldSchema) ? 0 : 1;
int charsetSyn = (this.charsetIndex == clientCharSetIndex) ? 0 : 1;
int txIsoLationSyn = (txIsolation == clientTxIsoLation) ? 0 : 1;
int autoCommitSyn = (conAutoComit == expectAutocommit) ? 0 : 1;
int synCount = schemaSyn + charsetSyn + txIsoLationSyn + autoCommitSyn;
if (synCount == 0) {
String sql = rrn.getStatement();
Query query = new Query(PgSqlApaterUtils.apater(sql));
ByteBuffer buf = this.allocate();// XXX
query.write(buf);
this.write(buf);
return;
}
// TODO COOLLF . , ,
StringBuilder sb = new StringBuilder();
if (charsetSyn == 1) {
getCharsetCommand(sb, clientCharSetIndex);
}
if (txIsoLationSyn == 1) {
<API key>(sb, clientTxIsoLation);
}
if (autoCommitSyn == 1) {
<API key>(sb, expectAutocommit);
}
if (xaCmd != null) {
sb.append(xaCmd);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("con need syn ,total syn cmd " + synCount + " commands " + sb.toString() + "schema change:"
+ ("" != null) + " con:" + this);
}
metaDataSyned = false;
statusSync = new StatusSync(xaCmd != null, conSchema, clientCharSetIndex, clientTxIsoLation, expectAutocommit,
synCount);
String sql = sb.append(PgSqlApaterUtils.apater(rrn.getStatement())).toString();
if(LOGGER.isDebugEnabled()){
LOGGER.debug("con={}, SQL={}", this, sql);
}
Query query = new Query(sql);
ByteBuffer buf = allocate();// ByetBuffer
query.write(buf);
this.write(buf);
metaDataSyned = true;
}
public void close(String reason) {
if (!isClosed.get()) {
isQuit.set(true);
super.close(reason);
pool.connectionClosed(this);
if (this.responseHandler != null) {
this.responseHandler.connectionClose(this, reason);
responseHandler = null;
}
}
}
@Override
public boolean syncAndExcute() {
StatusSync sync = this.statusSync;
if (sync != null) {
boolean executed = sync.synAndExecuted(this);
if (executed) {
statusSync = null;
}
return executed;
}
return true;
}
@Override
public String toString() {
return "<API key> [id=" + id + ", host=" + host + ", port=" + port + ", localPort="
+ localPort + "]";
}
}
|
#include <linux/version.h>
#if (LINUX_VERSION_CODE < 0x020612)
#include <linux/config.h>
#endif
#if (LINUX_VERSION_CODE < 0x020500)
#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && ! defined(MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#endif
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#if (LINUX_VERSION_CODE >= 0x020600)
#include <linux/moduleparam.h>
#endif
#include <linux/stringify.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#if (LINUX_VERSION_CODE >= 0x020600)
#include <linux/dma-mapping.h>
#endif
#include <linux/bitops.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <linux/delay.h>
#include <asm/byteorder.h>
#include <asm/page.h>
#include <linux/time.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/if_vlan.h>
#if defined(CONFIG_VLAN_8021Q) || defined(<API key>)
#define BCM_VLAN 1
#endif
#ifdef NETIF_F_TSO
#include <net/ip.h>
#include <net/tcp.h>
#include <net/checksum.h>
#define BCM_TSO 1
#endif
#if (LINUX_VERSION_CODE >= 0x020600)
#include <linux/workqueue.h>
#endif
#ifndef BNX2_BOOT_DISK
#include <linux/crc32.h>
#endif
#include <linux/prefetch.h>
#include <linux/cache.h>
#include <linux/zlib.h>
#if (LINUX_VERSION_CODE >= 0x20617) && !defined(NETIF_F_MULTI_QUEUE)
#include <linux/log2.h>
#endif
#ifdef HAVE_AER
#include <linux/aer.h>
#endif
#if (LINUX_VERSION_CODE >= 0x020610)
#define BCM_CNIC 1
#include "cnic_if.h"
#endif
#include "bnx2_compat0.h"
#include "bnx2_compat.h"
#include "bnx2.h"
#include "bnx2_fw.h"
#include "bnx2_fw2.h"
#define DRV_MODULE_NAME "bnx2"
#define DRV_MODULE_VERSION "2.2.4f.v60.10"
#define DRV_MODULE_RELDATE "May 21, 2014"
#define RUN_AT(x) (jiffies + (x))
/* Time in jiffies before concluding the transmitter is hung. */
#if defined(__VMKLNX__)
/* On VMware ESX there is a possibility that that netdev watchdog thread
* runs before the reset task if the machine is loaded. If this occurs
* too many times, these premature watchdog triggers will cause a PSOD
* on a VMware ESX beta build */
#define TX_TIMEOUT (20*HZ)
#else
#define TX_TIMEOUT (5*HZ)
#endif /* defined(__VMKLNX__) */
#if defined(__VMKLNX__) && (<API key> >= 50000)
#include "cnic_register.h"
static int <API key>;
#endif /* defined(__VMKLNX__) && (<API key> >= 50000)*/
static char version[] __devinitdata =
"QLogic NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
MODULE_DESCRIPTION("QLogic NetXtreme II BCM5706/5708/5709/5716 Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_MODULE_VERSION);
static int disable_msi = 0;
static int debug;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) /* BNX2X_UPSTREAM */
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, " Default debug msglevel");
#endif
#if (LINUX_VERSION_CODE >= 0x20600)
module_param(disable_msi, int, 0);
MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
#endif
static int stop_on_tx_timeout = 0;
module_param(stop_on_tx_timeout, int, 0);
MODULE_PARM_DESC(stop_on_tx_timeout, "For debugging purposes, prevent a chip "
" reset when a tx timeout occurs");
#if defined(__VMKLNX__)
static int psod_on_tx_timeout;
module_param(psod_on_tx_timeout, int, 0);
MODULE_PARM_DESC(psod_on_tx_timeout, "For debugging purposes, crash the system "
" when a tx timeout occurs");
static int disable_msi_1shot = 0;
module_param(disable_msi_1shot, int, 0);
MODULE_PARM_DESC(disable_msi_1shot, "For debugging purposes, disable 1shot "
" MSI mode if set to value of 1");
#if (<API key> >= 55000)
static int disable_fw_dmp;
module_param(disable_fw_dmp, int, 0);
MODULE_PARM_DESC(disable_fw_dmp, "For debugging purposes, disable firmware "
"dump feature when set to value of 1");
#endif
#endif
#define BNX2_MAX_NIC 32
#ifdef <API key>
#define BNX2_OPTION_UNSET -1
#define BNX2_OPTION_ZERO 0
#define <API key>(bp) ((force_netq_param[bp->index] > 1) || \
(force_netq_param[bp->index] == \
BNX2_OPTION_UNSET))
#define <API key>(bp) (force_netq_param[bp->index] == 0)
static int __devinitdata force_netq_param[BNX2_MAX_NIC+1] =
{ [0 ... BNX2_MAX_NIC] = BNX2_OPTION_UNSET };
static unsigned int num_force_netq;
<API key>(force_netq, force_netq_param, int,
&num_force_netq, 0);
MODULE_PARM_DESC(force_netq, "Option used for 5709/5716 only: "
"Enforce the number of NetQueues per port "
"(allowed values: -1 to 7 queues: "
"1-7 will force the number of NetQueues for the "
" given device, "
"0 to disable NetQueue, "
"-1 to use the default driver NetQueues value) "
"[Maximum supported NIC's = 32] "
"[example usage: force_net=-1,0,1,2: "
"This corresponds to the first 5709/5716 to use "
"the default number of NetQueues, "
"disable NetQueue on the second 5709/5716, "
"use 1 NetQueue on the third 5709/5716"
"use 2 NetQueues on the fourth 5709/5716]");
#endif /* <API key> */
#if defined(__VMKLNX__) && (<API key> >= 55000)
#include <vmklinux_9/vmklinux_dump.h>
#define BNX2_DUMPNAME "bnx2_fwdmp"
static <API key> bnx2_fwdmp_dh;
static void *fwdmp_va_ptr;
static struct bnx2 *fwdmp_bp_ptr[BNX2_MAX_NIC];
static VMK_ReturnStatus bnx2_fwdmp_callback(void *cookie, vmk_Bool liveDump);
#endif
typedef enum {
BCM5706 = 0,
NC370T,
NC370I,
BCM5706S,
NC370F,
BCM5708,
BCM5708S,
BCM5709,
BCM5709S,
BCM5716,
BCM5716S,
} board_t;
/* indexed by board_t, above */
static struct {
char *name;
} board_info[] __devinitdata = {
{ "QLogic NetXtreme II BCM5706 1000Base-T" },
{ "HP NC370T Multifunction Gigabit Server Adapter" },
{ "HP NC370i Multifunction Gigabit Server Adapter" },
{ "QLogic NetXtreme II BCM5706 1000Base-SX" },
{ "HP NC370F Multifunction Gigabit Server Adapter" },
{ "QLogic NetXtreme II BCM5708 1000Base-T" },
{ "QLogic NetXtreme II BCM5708 1000Base-SX" },
{ "QLogic NetXtreme II BCM5709 1000Base-T" },
{ "QLogic NetXtreme II BCM5709 1000Base-SX" },
{ "QLogic NetXtreme II BCM5716 1000Base-T" },
{ "QLogic NetXtreme II BCM5716 1000Base-SX" },
};
static <API key>(bnx2_pci_tbl) = {
{ <API key>, <API key>,
PCI_VENDOR_ID_HP, 0x3101, 0, 0, NC370T },
{ <API key>, <API key>,
PCI_VENDOR_ID_HP, 0x3106, 0, 0, NC370I },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706 },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708 },
{ <API key>, <API key>,
PCI_VENDOR_ID_HP, 0x3102, 0, 0, NC370F },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 },
{ <API key>, <API key>,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S },
{ <API key>, 0x163b,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 },
{ <API key>, 0x163c,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716S },
{ 0, }
};
static const struct flash_spec flash_table[] =
{
#define BUFFERED_FLAGS (BNX2_NV_BUFFERED | BNX2_NV_TRANSLATE)
#define NONBUFFERED_FLAGS (BNX2_NV_WREN)
/* Slow EEPROM */
{0x00000000, 0x40830380, 0x009f0081, 0xa184a053, 0xaf000400,
BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
<API key>, SEEPROM_TOTAL_SIZE,
"EEPROM - slow"},
/* Expansion entry 0001 */
{0x08000002, 0x4b808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 0001"},
/* Saifun SA25F010 (non-buffered flash) */
/* strap, cfg1, & write1 need updates */
{0x04000001, 0x47808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>*2,
"Non-buffered flash (128kB)"},
/* Saifun SA25F020 (non-buffered flash) */
/* strap, cfg1, & write1 need updates */
{0x0c000003, 0x4f808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>*4,
"Non-buffered flash (256kB)"},
/* Expansion entry 0100 */
{0x11000000, 0x53808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 0100"},
/* Entry 0101: ST M45PE10 (non-buffered flash, TetonII B0) */
{0x19000002, 0x5b808201, 0x000500db, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>*2,
"Entry 0101: ST M45PE10 (128kB non-bufferred)"},
/* Entry 0110: ST M45PE20 (non-buffered flash)*/
{0x15000001, 0x57808201, 0x000500db, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>*4,
"Entry 0110: ST M45PE20 (256kB non-bufferred)"},
/* Saifun SA25F005 (non-buffered flash) */
/* strap, cfg1, & write1 need updates */
{0x1d000003, 0x5f808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>,
"Non-buffered flash (64kB)"},
/* Fast EEPROM */
{0x22000000, 0x62808380, 0x009f0081, 0xa184a053, 0xaf000400,
BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
<API key>, SEEPROM_TOTAL_SIZE,
"EEPROM - fast"},
/* Expansion entry 1001 */
{0x2a000002, 0x6b808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 1001"},
/* Expansion entry 1010 */
{0x26000001, 0x67808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 1010"},
/* ATMEL AT45DB011B (buffered flash) */
{0x2e000003, 0x6e808273, 0x00570081, 0x68848353, 0xaf000400,
BUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>,
"Buffered flash (128kB)"},
/* Expansion entry 1100 */
{0x33000000, 0x73808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 1100"},
/* Expansion entry 1101 */
{0x3b000002, 0x7b808201, 0x00050081, 0x03840253, 0xaf020406,
NONBUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 1101"},
/* Ateml Expansion entry 1110 */
{0x37000001, 0x76808273, 0x00570081, 0x68848353, 0xaf000400,
BUFFERED_FLAGS, <API key>, <API key>,
<API key>, 0,
"Entry 1110 (Atmel)"},
/* ATMEL AT45DB021B (buffered flash) */
{0x3f000003, 0x7e808273, 0x00570081, 0x68848353, 0xaf000400,
BUFFERED_FLAGS, <API key>, <API key>,
<API key>, <API key>*2,
"Buffered flash (256kB)"},
};
static const struct flash_spec flash_5709 = {
.flags = BNX2_NV_BUFFERED,
.page_bits = <API key>,
.page_size = <API key>,
.addr_mask = <API key>,
.total_size = <API key>*2,
.name = "5709 Buffered flash (256kB)",
};
MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
#if !defined(__VMKLNX__)
static void bnx2_init_napi(struct bnx2 *bp);
static void bnx2_del_napi(struct bnx2 *bp);
#else
static void __devinit bnx2_init_napi(struct bnx2 *bp);
static void __devexit bnx2_del_napi(struct bnx2 *bp);
#endif
static void <API key>(struct bnx2 *bp, u32 size);
#if defined(__VMKLNX__)
static int
bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget,
int check_queue);
#endif /* defined(__VMKLNX__) */
#if defined(<API key>)
static int bnx2_netqueue_ops(<API key> op, void *args);
static void <API key>(struct bnx2 *bp);
static void <API key>(struct bnx2 *bp);
static void <API key>(struct bnx2_napi *bnapi);
static int <API key>(struct bnx2 *bp);
static void <API key>(struct bnx2 *bp);
static void <API key>(struct bnx2 *bp);
static int <API key>(struct bnx2 *bp);
static void <API key>(struct bnx2 *bp);
static int <API key>(struct bnx2 *bp);
static void bnx2_close_netqueue(struct bnx2 *bp);
static void bnx2_start_netqueue(struct bnx2 *bp);
static void bnx2_stop_netqueue(struct bnx2 *bp);
static void <API key>(struct bnx2 * bp);
static inline u16 bnx2_get_hw_tx_cons(struct bnx2_napi *bnapi);
static inline u16 bnx2_get_hw_rx_cons(struct bnx2_napi *bnapi);
#ifdef BNX2_DEBUG
static u32 bnx2_read_ctx(struct bnx2 *bp, u32 offset);
#endif
static int <API key>(struct bnx2 *bp,
struct bnx2_napi *bnapi,
int index);
#define TRUE 1
#define FALSE 0
#define <API key>(bp, var) \
for (var = 1; var < bp->num_rx_rings; var++)
#define <API key>(bp, var) \
for (var = 1; var < bp->num_tx_rings; var++)
#define is_multi(bp) (bp->num_rx_ring > 1)
#endif /* defined(<API key>) */
#ifdef BNX2_BOOT_DISK
u32 ether_crc_le(size_t len, unsigned char const *p)
{
u32 crc = ~0;
int i;
#define CRCPOLY_LE 0xedb88320
while (len
crc ^= *p++;
for (i = 0; i < 8; i++)
crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
}
return crc;
}
#endif
static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
{
u32 diff;
/* Tell compiler to fetch tx_prod and tx_cons from memory. */
barrier();
/* The ring uses 256 indices for 255 entries, one of them
* needs to be skipped.
*/
diff = txr->tx_prod - txr->tx_cons;
if (unlikely(diff >= BNX2_TX_DESC_CNT)) {
diff &= 0xffff;
if (diff == BNX2_TX_DESC_CNT)
diff = <API key>;
}
return bp->tx_ring_size - diff;
}
static u32
bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
{
u32 val;
spin_lock_bh(&bp->indirect_lock);
BNX2_WR(bp, <API key>, offset);
val = BNX2_RD(bp, <API key>);
spin_unlock_bh(&bp->indirect_lock);
return val;
}
static void
bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val)
{
spin_lock_bh(&bp->indirect_lock);
BNX2_WR(bp, <API key>, offset);
BNX2_WR(bp, <API key>, val);
spin_unlock_bh(&bp->indirect_lock);
}
#if defined(__VMKLNX__)
static void
bnx2_reg_wr_ind_cfg(struct bnx2 *bp, u32 offset, u32 val)
{
struct pci_dev *pdev = bp->pdev;
spin_lock_bh(&bp->indirect_lock);
<API key>(pdev, <API key>, offset);
<API key>(pdev, <API key>, val);
spin_unlock_bh(&bp->indirect_lock);
}
#endif /* defined(__VMKLNX__) */
static void
bnx2_shmem_wr(struct bnx2 *bp, u32 offset, u32 val)
{
bnx2_reg_wr_ind(bp, bp->shmem_base + offset, val);
}
static u32
bnx2_shmem_rd(struct bnx2 *bp, u32 offset)
{
return bnx2_reg_rd_ind(bp, bp->shmem_base + offset);
}
static void
bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
{
offset += cid_addr;
spin_lock_bh(&bp->indirect_lock);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
int i;
BNX2_WR(bp, BNX2_CTX_CTX_DATA, val);
BNX2_WR(bp, BNX2_CTX_CTX_CTRL,
offset | <API key>);
for (i = 0; i < 5; i++) {
val = BNX2_RD(bp, BNX2_CTX_CTX_CTRL);
if ((val & <API key>) == 0)
break;
udelay(5);
}
} else {
BNX2_WR(bp, BNX2_CTX_DATA_ADR, offset);
BNX2_WR(bp, BNX2_CTX_DATA, val);
}
spin_unlock_bh(&bp->indirect_lock);
}
#ifdef BCM_CNIC
static int
bnx2_drv_ctl(struct net_device *dev, struct drv_ctl_info *info)
{
struct bnx2 *bp = netdev_priv(dev);
struct drv_ctl_io *io = &info->data.io;
switch (info->cmd) {
case DRV_CTL_IO_WR_CMD:
bnx2_reg_wr_ind(bp, io->offset, io->data);
break;
case DRV_CTL_IO_RD_CMD:
io->data = bnx2_reg_rd_ind(bp, io->offset);
break;
case DRV_CTL_CTX_WR_CMD:
bnx2_ctx_wr(bp, io->cid_addr, io->offset, io->data);
break;
default:
return -EINVAL;
}
return 0;
}
static void <API key>(struct bnx2 *bp)
{
struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
int sb_id;
if (bp->flags & <API key>) {
cp->drv_state |= <API key>;
bnapi->cnic_present = 0;
sb_id = bp->irq_nvecs;
cp->irq_arr[0].irq_flags |= CNIC_IRQ_FL_MSIX;
} else {
cp->drv_state &= ~<API key>;
bnapi->cnic_tag = bnapi->last_status_idx;
bnapi->cnic_present = 1;
sb_id = 0;
cp->irq_arr[0].irq_flags &= ~CNIC_IRQ_FL_MSIX;
}
cp->irq_arr[0].vector = bp->irq_tbl[sb_id].vector;
cp->irq_arr[0].status_blk = (void *)
((unsigned long) bnapi->status_blk.msi +
(<API key> * sb_id));
cp->irq_arr[0].status_blk_num = sb_id;
cp->num_irq = 1;
}
static int bnx2_register_cnic(struct net_device *dev, struct cnic_ops *ops,
void *data)
{
struct bnx2 *bp = netdev_priv(dev);
struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
if (ops == NULL)
return -EINVAL;
if (cp->drv_state & CNIC_DRV_STATE_REGD)
return -EBUSY;
if (!bnx2_reg_rd_ind(bp, <API key>))
return -ENODEV;
bp->cnic_data = data;
rcu_assign_pointer(bp->cnic_ops, ops);
cp->num_irq = 0;
cp->drv_state = CNIC_DRV_STATE_REGD;
<API key>(bp);
return 0;
}
static int <API key>(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
mutex_lock(&bp->cnic_lock);
cp->drv_state = 0;
bnapi->cnic_present = 0;
RCU_INIT_POINTER(bp->cnic_ops, NULL);
mutex_unlock(&bp->cnic_lock);
synchronize_rcu();
return 0;
}
#if defined(BNX2_INBOX)
struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)
#else /* !defined(BNX2_INBOX) */
static struct cnic_eth_dev *bnx2_cnic_probe2(struct net_device *dev)
#endif /* defined(BNX2_INBOX) */
{
struct bnx2 *bp = netdev_priv(dev);
struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
if (!cp->max_iscsi_conn)
return NULL;
cp->version = CNIC_ETH_DEV_VER;
cp->drv_owner = THIS_MODULE;
cp->chip_id = bp->chip_id;
cp->pdev = bp->pdev;
cp->io_base = bp->regview;
cp->drv_ctl = bnx2_drv_ctl;
cp->drv_register_cnic = bnx2_register_cnic;
cp->drv_unregister_cnic = <API key>;
return cp;
}
static void
bnx2_cnic_stop(struct bnx2 *bp)
{
struct cnic_ops *c_ops;
struct cnic_ctl_info info;
mutex_lock(&bp->cnic_lock);
c_ops = <API key>(bp->cnic_ops,
lockdep_is_held(&bp->cnic_lock));
if (c_ops) {
info.cmd = CNIC_CTL_STOP_CMD;
#if defined(__VMKLNX__)
<API key>(c_ops->cnic_owner->moduleID,
c_ops->cnic_ctl, bp->cnic_data, &info);
#else
c_ops->cnic_ctl(bp->cnic_data, &info);
#endif
}
mutex_unlock(&bp->cnic_lock);
}
static void
bnx2_cnic_start(struct bnx2 *bp)
{
struct cnic_ops *c_ops;
struct cnic_ctl_info info;
mutex_lock(&bp->cnic_lock);
c_ops = <API key>(bp->cnic_ops,
lockdep_is_held(&bp->cnic_lock));
if (c_ops) {
if (!(bp->flags & <API key>)) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
bnapi->cnic_tag = bnapi->last_status_idx;
}
info.cmd = CNIC_CTL_START_CMD;
#if defined(__VMKLNX__)
<API key>(c_ops->cnic_owner->moduleID,
c_ops->cnic_ctl, bp->cnic_data, &info);
#else
c_ops->cnic_ctl(bp->cnic_data, &info);
#endif
}
mutex_unlock(&bp->cnic_lock);
}
#else
static void
bnx2_cnic_stop(struct bnx2 *bp)
{
}
static void
bnx2_cnic_start(struct bnx2 *bp)
{
}
#endif
static int
bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
{
u32 val1;
int i, ret;
if (bp->phy_flags & <API key>) {
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
val1 &= ~<API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
udelay(40);
}
val1 = (bp->phy_addr << 21) | (reg << 16) |
<API key> | <API key> |
<API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
for (i = 0; i < 50; i++) {
udelay(10);
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_COMM);
if (!(val1 & <API key>)) {
udelay(5);
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_COMM);
val1 &= <API key>;
break;
}
}
if (val1 & <API key>) {
*val = 0x0;
ret = -EBUSY;
}
else {
*val = val1;
ret = 0;
}
if (bp->phy_flags & <API key>) {
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
val1 |= <API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
udelay(40);
}
return ret;
}
static int
bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
{
u32 val1;
int i, ret;
if (bp->phy_flags & <API key>) {
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
val1 &= ~<API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
udelay(40);
}
val1 = (bp->phy_addr << 21) | (reg << 16) | val |
<API key> |
<API key> | <API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
for (i = 0; i < 50; i++) {
udelay(10);
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_COMM);
if (!(val1 & <API key>)) {
udelay(5);
break;
}
}
if (val1 & <API key>)
ret = -EBUSY;
else
ret = 0;
if (bp->phy_flags & <API key>) {
val1 = BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
val1 |= <API key>;
BNX2_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
BNX2_RD(bp, BNX2_EMAC_MDIO_MODE);
udelay(40);
}
return ret;
}
static void
bnx2_disable_int(struct bnx2 *bp)
{
int i;
struct bnx2_napi *bnapi;
for (i = 0; i < bp->irq_nvecs; i++) {
bnapi = &bp->bnx2_napi[i];
BNX2_WR(bp, <API key>, bnapi->int_num |
<API key>);
}
BNX2_RD(bp, <API key>);
}
static void
bnx2_enable_int(struct bnx2 *bp)
{
int i;
struct bnx2_napi *bnapi;
for (i = 0; i < bp->irq_nvecs; i++) {
bnapi = &bp->bnx2_napi[i];
BNX2_WR(bp, <API key>, bnapi->int_num |
<API key> |
<API key> |
bnapi->last_status_idx);
BNX2_WR(bp, <API key>, bnapi->int_num |
<API key> |
bnapi->last_status_idx);
}
BNX2_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | <API key>);
}
static void
<API key>(struct bnx2 *bp)
{
int i;
atomic_inc(&bp->intr_sem);
if (!netif_running(bp->dev))
return;
bnx2_disable_int(bp);
for (i = 0; i < bp->irq_nvecs; i++)
#if (LINUX_VERSION_CODE >= 0x2051c)
synchronize_irq(bp->irq_tbl[i].vector);
#else
synchronize_irq();
#endif
}
static void
bnx2_napi_disable(struct bnx2 *bp)
{
#ifdef BNX2_NEW_NAPI
int i;
for (i = 0; i < bp->irq_nvecs; i++)
napi_disable(&bp->bnx2_napi[i].napi);
#else
netif_poll_disable(bp->dev);
#endif
}
static void
bnx2_napi_enable(struct bnx2 *bp)
{
#ifdef BNX2_NEW_NAPI
int i;
for (i = 0; i < bp->irq_nvecs; i++)
napi_enable(&bp->bnx2_napi[i].napi);
#else
netif_poll_enable(bp->dev);
#endif
}
#if defined(<API key>)
static void
<API key>(struct bnx2_napi *bnapi,
struct bnx2_tx_ring_info *txr)
{
struct bnx2 *bp = bnapi->bp;
rmb();
if ((bnx2_get_hw_tx_cons(bnapi) != txr->hw_tx_cons) ||
(bnapi->tx_packets_sent != bnapi-><API key>)) {
bnx2_tx_int(bp, bnapi, 100, 0);
msleep(1);
rmb();
}
}
static void
<API key>(struct bnx2 *bp)
{
int i;
struct bnx2_napi *bnapi;
struct bnx2_tx_ring_info *txr;
/* Flush default ring */
bnapi = &bp->bnx2_napi[0];
txr = &bnapi->tx_ring;
<API key>(bnapi, txr);
netdev_info(bp->dev, "flushed default TX queue\n");
/* Flush NetQ rings */
<API key>(bp, i) {
bnapi = &bp->bnx2_napi[i];
txr = &bnapi->tx_ring;
rmb();
<API key>(bnapi, txr);
netdev_info(bp->dev, "flushed TX queue %d\n", i);
}
}
static void
bnx2_netif_stop(struct bnx2 *bp, bool stop_cnic)
{
if (stop_cnic) {
#if defined(<API key>)
/* Note that queues allocated MUST be read before they
* got reset during stop_nequeue
*/
int tx_queues_allocated = bp-><API key>;
int rx_queues_allocated = bp-><API key>;
bnx2_stop_netqueue(bp);
if (rx_queues_allocated == 0 &&
tx_queues_allocated == bp->num_tx_rings - 1)
/* to avoid repeated callbacks from ESX host,
* we need to skip invalidating state in no
* rx queues are allocated.
*/
bp-><API key> = tx_queues_allocated;
else
<API key>(bp->dev);
#endif
bnx2_cnic_stop(bp);
}
if (netif_running(bp->dev)) {
bnx2_napi_disable(bp);
<API key>(bp);
netif_carrier_off(bp->dev); /* prevent tx timeout */
netif_tx_disable(bp->dev);
}
rmb();
#if defined(<API key>)
if (<API key>(bp))
<API key>(bp);
if (stop_cnic) {
/* if for whatever the reason, netqueue failed to stop in case
of chip getting stuck, we should force the netqueue to stop
since chip will go thru full reset afterward. */
if (<API key>(bp))
<API key>(bp);
}
#endif /* defined(<API key>) */
}
#else
static void
bnx2_netif_stop(struct bnx2 *bp, bool stop_cnic)
{
if (stop_cnic)
bnx2_cnic_stop(bp);
if (netif_running(bp->dev)) {
bnx2_napi_disable(bp);
<API key>(bp);
netif_carrier_off(bp->dev); /* prevent tx timeout */
netif_tx_disable(bp->dev);
}
}
#endif
static void
bnx2_netif_start(struct bnx2 *bp, bool start_cnic)
{
#if defined(__VMKLNX__) && defined(<API key>)
if (start_cnic && <API key>(bp)) {
bnx2_start_netqueue(bp);
/* we might have skipped invalidating netq state
* when stopping netq earlier to avoid repeated
* callbacks from ESX host. If so, we need to
* manually allocate the tx queues accordingly.
*/
if (bp-><API key>) {
int index;
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if (<API key>(bp, bnapi, index) !=
<API key>)
break;
}
BUG_ON(index - 1 != bp-><API key>);
bp-><API key> = 0;
}
}
#endif
if (atomic_dec_and_test(&bp->intr_sem)) {
if (netif_running(bp->dev)) {
<API key>(bp->dev);
spin_lock_bh(&bp->phy_lock);
if (bp->link_up)
netif_carrier_on(bp->dev);
spin_unlock_bh(&bp->phy_lock);
bnx2_napi_enable(bp);
bnx2_enable_int(bp);
if (start_cnic)
bnx2_cnic_start(bp);
}
}
}
static void
bnx2_free_tx_mem(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_tx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
if (txr->tx_desc_ring) {
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_free_coherent(&bp->pdev->dev, TXBD_RING_SIZE,
txr->tx_desc_ring,
txr->tx_desc_mapping);
#else
pci_free_consistent(bp->pdev, TXBD_RING_SIZE,
txr->tx_desc_ring,
txr->tx_desc_mapping);
#endif
txr->tx_desc_ring = NULL;
}
kfree(txr->tx_buf_ring);
txr->tx_buf_ring = NULL;
}
}
static void
bnx2_free_rx_mem(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_rx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
int j;
for (j = 0; j < bp->rx_max_ring; j++) {
if (rxr->rx_desc_ring[j])
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_free_coherent(&bp->pdev->dev, RXBD_RING_SIZE,
rxr->rx_desc_ring[j],
rxr->rx_desc_mapping[j]);
#else
pci_free_consistent(bp->pdev, RXBD_RING_SIZE,
rxr->rx_desc_ring[j],
rxr->rx_desc_mapping[j]);
#endif
rxr->rx_desc_ring[j] = NULL;
}
vfree(rxr->rx_buf_ring);
rxr->rx_buf_ring = NULL;
for (j = 0; j < bp->rx_max_pg_ring; j++) {
if (rxr->rx_pg_desc_ring[j])
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_free_coherent(&bp->pdev->dev, RXBD_RING_SIZE,
rxr->rx_pg_desc_ring[j],
rxr->rx_pg_desc_mapping[j]);
#else
pci_free_consistent(bp->pdev, RXBD_RING_SIZE,
rxr->rx_pg_desc_ring[j],
rxr->rx_pg_desc_mapping[j]);
#endif
rxr->rx_pg_desc_ring[j] = NULL;
}
vfree(rxr->rx_pg_ring);
rxr->rx_pg_ring = NULL;
}
}
static int
bnx2_alloc_tx_mem(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_tx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
txr->tx_buf_ring = kmalloc(SW_TXBD_RING_SIZE, GFP_KERNEL);
if (txr->tx_buf_ring == NULL)
return -ENOMEM;
memset(txr->tx_buf_ring, 0, SW_TXBD_RING_SIZE);
txr->tx_desc_ring =
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_alloc_coherent(&bp->pdev->dev, TXBD_RING_SIZE,
&txr->tx_desc_mapping, GFP_KERNEL);
#else
<API key>(bp->pdev, TXBD_RING_SIZE,
&txr->tx_desc_mapping);
#endif
if (txr->tx_desc_ring == NULL)
return -ENOMEM;
}
return 0;
}
static int
bnx2_alloc_rx_mem(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_rx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
int j;
rxr->rx_buf_ring =
vmalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
if (rxr->rx_buf_ring == NULL)
return -ENOMEM;
memset(rxr->rx_buf_ring, 0,
SW_RXBD_RING_SIZE * bp->rx_max_ring);
for (j = 0; j < bp->rx_max_ring; j++) {
rxr->rx_desc_ring[j] =
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_alloc_coherent(&bp->pdev->dev,
RXBD_RING_SIZE,
&rxr->rx_desc_mapping[j],
GFP_KERNEL);
#else
<API key>(bp->pdev, RXBD_RING_SIZE,
&rxr->rx_desc_mapping[j]);
#endif
if (rxr->rx_desc_ring[j] == NULL)
return -ENOMEM;
}
if (bp->rx_pg_ring_size) {
rxr->rx_pg_ring = vmalloc(SW_RXPG_RING_SIZE *
bp->rx_max_pg_ring);
if (rxr->rx_pg_ring == NULL)
return -ENOMEM;
memset(rxr->rx_pg_ring, 0, SW_RXPG_RING_SIZE *
bp->rx_max_pg_ring);
}
for (j = 0; j < bp->rx_max_pg_ring; j++) {
rxr->rx_pg_desc_ring[j] =
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_alloc_coherent(&bp->pdev->dev,
RXBD_RING_SIZE,
&rxr->rx_pg_desc_mapping[j],
GFP_KERNEL);
#else
<API key>(bp->pdev, RXBD_RING_SIZE,
&rxr->rx_pg_desc_mapping[j]);
#endif
if (rxr->rx_pg_desc_ring[j] == NULL)
return -ENOMEM;
}
}
return 0;
}
static void
bnx2_free_mem(struct bnx2 *bp)
{
int i;
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
bnx2_free_tx_mem(bp);
bnx2_free_rx_mem(bp);
for (i = 0; i < bp->ctx_pages; i++) {
if (bp->ctx_blk[i]) {
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_free_coherent(&bp->pdev->dev, BNX2_PAGE_SIZE,
bp->ctx_blk[i],
bp->ctx_blk_mapping[i]);
#else
pci_free_consistent(bp->pdev, BNX2_PAGE_SIZE,
bp->ctx_blk[i],
bp->ctx_blk_mapping[i]);
#endif
bp->ctx_blk[i] = NULL;
}
}
if (bnapi->status_blk.msi) {
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_free_coherent(&bp->pdev->dev, bp->status_stats_size,
bnapi->status_blk.msi,
bp->status_blk_mapping);
#else
pci_free_consistent(bp->pdev, bp->status_stats_size,
bnapi->status_blk.msi,
bp->status_blk_mapping);
#endif
bnapi->status_blk.msi = NULL;
bp->stats_blk = NULL;
}
}
static int
bnx2_alloc_mem(struct bnx2 *bp)
{
int i, status_blk_size, err;
struct bnx2_napi *bnapi;
void *status_blk;
/* Combine status and statistics blocks into one allocation. */
status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block));
#ifdef CONFIG_PCI_MSI
if (bp->flags & BNX2_FLAG_MSIX_CAP)
status_blk_size = L1_CACHE_ALIGN(<API key> *
<API key>);
#endif
bp->status_stats_size = status_blk_size +
sizeof(struct statistics_block);
#if (LINUX_VERSION_CODE >= 0x02061b)
status_blk = dma_alloc_coherent(&bp->pdev->dev, bp->status_stats_size,
&bp->status_blk_mapping, GFP_KERNEL);
#else
status_blk = <API key>(bp->pdev, bp->status_stats_size,
&bp->status_blk_mapping);
#endif
if (status_blk == NULL)
goto alloc_mem_err;
memset(status_blk, 0, bp->status_stats_size);
bnapi = &bp->bnx2_napi[0];
bnapi->status_blk.msi = status_blk;
bnapi->hw_tx_cons_ptr =
&bnapi->status_blk.msi-><API key>;
bnapi->hw_rx_cons_ptr =
&bnapi->status_blk.msi-><API key>;
if (bp->flags & BNX2_FLAG_MSIX_CAP) {
for (i = 1; i < bp->irq_nvecs; i++) {
struct status_block_msix *sblk;
bnapi = &bp->bnx2_napi[i];
sblk = (status_blk + <API key> * i);
bnapi->status_blk.msix = sblk;
bnapi->hw_tx_cons_ptr =
&sblk-><API key>;
bnapi->hw_rx_cons_ptr =
&sblk-><API key>;
bnapi->int_num = i << 24;
}
}
bp->stats_blk = status_blk + status_blk_size;
bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
/* NetQ uses CID 100, so we need 16K of context memory */
#if defined(<API key>)
bp->ctx_pages = 0x4000 / BNX2_PAGE_SIZE;
#else /* !defined(__VMKLNX__) */
bp->ctx_pages = 0x2000 / BNX2_PAGE_SIZE;
#endif /* defined(__VMKLNX__) */
if (bp->ctx_pages == 0)
bp->ctx_pages = 1;
for (i = 0; i < bp->ctx_pages; i++) {
#if (LINUX_VERSION_CODE >= 0x02061b)
bp->ctx_blk[i] = dma_alloc_coherent(&bp->pdev->dev,
BNX2_PAGE_SIZE,
&bp->ctx_blk_mapping[i],
GFP_KERNEL);
#else
bp->ctx_blk[i] = <API key>(bp->pdev,
BNX2_PAGE_SIZE,
&bp->ctx_blk_mapping[i]);
#endif
if (bp->ctx_blk[i] == NULL)
goto alloc_mem_err;
}
}
err = bnx2_alloc_rx_mem(bp);
if (err)
goto alloc_mem_err;
err = bnx2_alloc_tx_mem(bp);
if (err)
goto alloc_mem_err;
return 0;
alloc_mem_err:
bnx2_free_mem(bp);
return -ENOMEM;
}
static void
bnx2_report_fw_link(struct bnx2 *bp)
{
u32 fw_link_status = 0;
if (bp->phy_flags & <API key>)
return;
if (bp->link_up) {
u32 bmsr;
switch (bp->line_speed) {
case SPEED_10:
if (bp->duplex == DUPLEX_HALF)
fw_link_status = <API key>;
else
fw_link_status = <API key>;
break;
case SPEED_100:
if (bp->duplex == DUPLEX_HALF)
fw_link_status = <API key>;
else
fw_link_status = <API key>;
break;
case SPEED_1000:
if (bp->duplex == DUPLEX_HALF)
fw_link_status = <API key>;
else
fw_link_status = <API key>;
break;
case SPEED_2500:
if (bp->duplex == DUPLEX_HALF)
fw_link_status = <API key>;
else
fw_link_status = <API key>;
break;
}
fw_link_status |= <API key>;
if (bp->autoneg) {
fw_link_status |= <API key>;
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
if (!(bmsr & BMSR_ANEGCOMPLETE) ||
bp->phy_flags & <API key>)
fw_link_status |= <API key>;
else
fw_link_status |= <API key>;
}
}
else
fw_link_status = <API key>;
bnx2_shmem_wr(bp, BNX2_LINK_STATUS, fw_link_status);
}
static char *
bnx2_xceiver_str(struct bnx2 *bp)
{
return (bp->phy_port == PORT_FIBRE) ? "SerDes" :
((bp->phy_flags & <API key>) ? "Remote Copper" :
"Copper");
}
static void
bnx2_report_link(struct bnx2 *bp)
{
if (bp->link_up) {
netif_carrier_on(bp->dev);
netdev_info(bp->dev, "NIC %s Link is Up, %d Mbps %s duplex",
bnx2_xceiver_str(bp),
bp->line_speed,
bp->duplex == DUPLEX_FULL ? "full" : "half");
if (bp->flow_ctrl) {
if (bp->flow_ctrl & FLOW_CTRL_RX) {
pr_cont(", receive ");
if (bp->flow_ctrl & FLOW_CTRL_TX)
pr_cont("& transmit ");
}
else {
pr_cont(", transmit ");
}
pr_cont("flow control ON");
}
pr_cont("\n");
} else {
netif_carrier_off(bp->dev);
netdev_err(bp->dev, "NIC %s Link is Down\n",
bnx2_xceiver_str(bp));
}
bnx2_report_fw_link(bp);
}
static void
<API key>(struct bnx2 *bp)
{
u32 local_adv, remote_adv;
bp->flow_ctrl = 0;
if ((bp->autoneg & (AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) !=
(AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) {
if (bp->duplex == DUPLEX_FULL) {
bp->flow_ctrl = bp->req_flow_ctrl;
}
return;
}
if (bp->duplex != DUPLEX_FULL) {
return;
}
if ((bp->phy_flags & <API key>) &&
(BNX2_CHIP(bp) == BNX2_CHIP_5708)) {
u32 val;
bnx2_read_phy(bp, <API key>, &val);
if (val & <API key>)
bp->flow_ctrl |= FLOW_CTRL_TX;
if (val & <API key>)
bp->flow_ctrl |= FLOW_CTRL_RX;
return;
}
bnx2_read_phy(bp, bp->mii_adv, &local_adv);
bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
if (bp->phy_flags & <API key>) {
u32 new_local_adv = 0;
u32 new_remote_adv = 0;
if (local_adv & <API key>)
new_local_adv |= ADVERTISE_PAUSE_CAP;
if (local_adv & <API key>)
new_local_adv |= <API key>;
if (remote_adv & <API key>)
new_remote_adv |= ADVERTISE_PAUSE_CAP;
if (remote_adv & <API key>)
new_remote_adv |= <API key>;
local_adv = new_local_adv;
remote_adv = new_remote_adv;
}
/* See Table 28B-3 of 802.3ab-1999 spec. */
if (local_adv & ADVERTISE_PAUSE_CAP) {
if(local_adv & <API key>) {
if (remote_adv & ADVERTISE_PAUSE_CAP) {
bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
}
else if (remote_adv & <API key>) {
bp->flow_ctrl = FLOW_CTRL_RX;
}
}
else {
if (remote_adv & ADVERTISE_PAUSE_CAP) {
bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
}
}
}
else if (local_adv & <API key>) {
if ((remote_adv & ADVERTISE_PAUSE_CAP) &&
(remote_adv & <API key>)) {
bp->flow_ctrl = FLOW_CTRL_TX;
}
}
}
static int
bnx2_5709s_linkup(struct bnx2 *bp)
{
u32 val, speed;
bp->link_up = 1;
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, <API key>, &val);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
if ((bp->autoneg & AUTONEG_SPEED) == 0) {
bp->line_speed = bp->req_line_speed;
bp->duplex = bp->req_duplex;
return 0;
}
speed = val & <API key>;
switch (speed) {
case <API key>:
bp->line_speed = SPEED_10;
break;
case <API key>:
bp->line_speed = SPEED_100;
break;
case <API key>:
case <API key>:
bp->line_speed = SPEED_1000;
break;
case <API key>:
bp->line_speed = SPEED_2500;
break;
}
if (val & <API key>)
bp->duplex = DUPLEX_FULL;
else
bp->duplex = DUPLEX_HALF;
return 0;
}
static int
bnx2_5708s_linkup(struct bnx2 *bp)
{
u32 val;
bp->link_up = 1;
bnx2_read_phy(bp, <API key>, &val);
switch (val & <API key>) {
case <API key>:
bp->line_speed = SPEED_10;
break;
case <API key>:
bp->line_speed = SPEED_100;
break;
case <API key>:
bp->line_speed = SPEED_1000;
break;
case <API key>:
bp->line_speed = SPEED_2500;
break;
}
if (val & <API key>)
bp->duplex = DUPLEX_FULL;
else
bp->duplex = DUPLEX_HALF;
return 0;
}
static int
bnx2_5706s_linkup(struct bnx2 *bp)
{
u32 bmcr, local_adv, remote_adv, common;
bp->link_up = 1;
bp->line_speed = SPEED_1000;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (bmcr & BMCR_FULLDPLX) {
bp->duplex = DUPLEX_FULL;
}
else {
bp->duplex = DUPLEX_HALF;
}
if (!(bmcr & BMCR_ANENABLE)) {
return 0;
}
bnx2_read_phy(bp, bp->mii_adv, &local_adv);
bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
common = local_adv & remote_adv;
if (common & (ADVERTISE_1000XHALF | ADVERTISE_1000XFULL)) {
if (common & ADVERTISE_1000XFULL) {
bp->duplex = DUPLEX_FULL;
}
else {
bp->duplex = DUPLEX_HALF;
}
}
return 0;
}
static int
bnx2_copper_linkup(struct bnx2 *bp)
{
u32 bmcr;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (bmcr & BMCR_ANENABLE) {
u32 local_adv, remote_adv, common;
bnx2_read_phy(bp, MII_CTRL1000, &local_adv);
bnx2_read_phy(bp, MII_STAT1000, &remote_adv);
common = local_adv & (remote_adv >> 2);
if (common & ADVERTISE_1000FULL) {
bp->line_speed = SPEED_1000;
bp->duplex = DUPLEX_FULL;
}
else if (common & ADVERTISE_1000HALF) {
bp->line_speed = SPEED_1000;
bp->duplex = DUPLEX_HALF;
}
else {
bnx2_read_phy(bp, bp->mii_adv, &local_adv);
bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
common = local_adv & remote_adv;
if (common & ADVERTISE_100FULL) {
bp->line_speed = SPEED_100;
bp->duplex = DUPLEX_FULL;
}
else if (common & ADVERTISE_100HALF) {
bp->line_speed = SPEED_100;
bp->duplex = DUPLEX_HALF;
}
else if (common & ADVERTISE_10FULL) {
bp->line_speed = SPEED_10;
bp->duplex = DUPLEX_FULL;
}
else if (common & ADVERTISE_10HALF) {
bp->line_speed = SPEED_10;
bp->duplex = DUPLEX_HALF;
}
else {
bp->line_speed = 0;
bp->link_up = 0;
}
}
}
else {
if (bmcr & BMCR_SPEED100) {
bp->line_speed = SPEED_100;
}
else {
bp->line_speed = SPEED_10;
}
if (bmcr & BMCR_FULLDPLX) {
bp->duplex = DUPLEX_FULL;
}
else {
bp->duplex = DUPLEX_HALF;
}
}
return 0;
}
static void
<API key>(struct bnx2 *bp, u32 cid)
{
u32 val, rx_cid_addr = GET_CID_ADDR(cid);
val = <API key>;
val |= <API key>;
val |= 0x02 << 8;
if (bp->flow_ctrl & FLOW_CTRL_TX)
val |= <API key>;
bnx2_ctx_wr(bp, rx_cid_addr, BNX2_L2CTX_CTX_TYPE, val);
}
static void
<API key>(struct bnx2 *bp)
{
int i;
u32 cid;
for (i = 0, cid = RX_CID; i < bp->num_rx_rings; i++, cid++) {
if (i == 1)
cid = RX_RSS_CID;
<API key>(bp, cid);
}
}
static void
bnx2_set_mac_link(struct bnx2 *bp)
{
u32 val;
BNX2_WR(bp, <API key>, 0x2620);
if (bp->link_up && (bp->line_speed == SPEED_1000) &&
(bp->duplex == DUPLEX_HALF)) {
BNX2_WR(bp, <API key>, 0x26ff);
}
/* Configure the EMAC mode register. */
val = BNX2_RD(bp, BNX2_EMAC_MODE);
val &= ~(BNX2_EMAC_MODE_PORT | <API key> |
<API key> | <API key> |
<API key>);
if (bp->link_up) {
switch (bp->line_speed) {
case SPEED_10:
if (BNX2_CHIP(bp) != BNX2_CHIP_5706) {
val |= <API key>;
break;
}
/* fall through */
case SPEED_100:
val |= <API key>;
break;
case SPEED_2500:
val |= <API key>;
/* fall through */
case SPEED_1000:
val |= <API key>;
break;
}
}
else {
val |= <API key>;
}
/* Set the MAC to operate in the appropriate duplex mode. */
if (bp->duplex == DUPLEX_HALF)
val |= <API key>;
BNX2_WR(bp, BNX2_EMAC_MODE, val);
/* Enable/disable rx PAUSE. */
bp->rx_mode &= ~<API key>;
if (bp->flow_ctrl & FLOW_CTRL_RX)
bp->rx_mode |= <API key>;
BNX2_WR(bp, BNX2_EMAC_RX_MODE, bp->rx_mode);
/* Enable/disable tx PAUSE. */
val = BNX2_RD(bp, BNX2_EMAC_TX_MODE);
val &= ~<API key>;
if (bp->flow_ctrl & FLOW_CTRL_TX)
val |= <API key>;
BNX2_WR(bp, BNX2_EMAC_TX_MODE, val);
/* Acknowledge the interrupt. */
BNX2_WR(bp, BNX2_EMAC_STATUS, <API key>);
<API key>(bp);
}
static void
bnx2_enable_bmsr1(struct bnx2 *bp)
{
if ((bp->phy_flags & <API key>) &&
(BNX2_CHIP(bp) == BNX2_CHIP_5709))
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
}
static void
bnx2_disable_bmsr1(struct bnx2 *bp)
{
if ((bp->phy_flags & <API key>) &&
(BNX2_CHIP(bp) == BNX2_CHIP_5709))
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
}
static int
<API key>(struct bnx2 *bp)
{
u32 up1;
int ret = 1;
if (!(bp->phy_flags & <API key>))
return 0;
if (bp->autoneg & AUTONEG_SPEED)
bp->advertising |= <API key>;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, bp->mii_up1, &up1);
if (!(up1 & BCM5708S_UP1_2G5)) {
up1 |= BCM5708S_UP1_2G5;
bnx2_write_phy(bp, bp->mii_up1, up1);
ret = 0;
}
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
return ret;
}
static int
<API key>(struct bnx2 *bp)
{
u32 up1;
int ret = 0;
if (!(bp->phy_flags & <API key>))
return 0;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, bp->mii_up1, &up1);
if (up1 & BCM5708S_UP1_2G5) {
up1 &= ~BCM5708S_UP1_2G5;
bnx2_write_phy(bp, bp->mii_up1, up1);
ret = 1;
}
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
return ret;
}
static void
<API key>(struct bnx2 *bp)
{
u32 uninitialized_var(bmcr);
int err;
if (!(bp->phy_flags & <API key>))
return;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
u32 val;
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
if (!bnx2_read_phy(bp, <API key>, &val)) {
val &= ~<API key>;
val |= <API key> |
<API key>;
bnx2_write_phy(bp, <API key>, val);
}
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
err = bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
} else if (BNX2_CHIP(bp) == BNX2_CHIP_5708) {
err = bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (!err)
bmcr |= <API key>;
} else {
return;
}
if (err)
return;
if (bp->autoneg & AUTONEG_SPEED) {
bmcr &= ~BMCR_ANENABLE;
if (bp->req_duplex == DUPLEX_FULL)
bmcr |= BMCR_FULLDPLX;
}
bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
}
static void
<API key>(struct bnx2 *bp)
{
u32 uninitialized_var(bmcr);
int err;
if (!(bp->phy_flags & <API key>))
return;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
u32 val;
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
if (!bnx2_read_phy(bp, <API key>, &val)) {
val &= ~<API key>;
bnx2_write_phy(bp, <API key>, val);
}
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
<API key>);
err = bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
} else if (BNX2_CHIP(bp) == BNX2_CHIP_5708) {
err = bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (!err)
bmcr &= ~<API key>;
} else {
return;
}
if (err)
return;
if (bp->autoneg & AUTONEG_SPEED)
bmcr |= BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_ANRESTART;
bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
}
static void
<API key>(struct bnx2 *bp, int start)
{
u32 val;
bnx2_write_phy(bp, <API key>, <API key>);
bnx2_read_phy(bp, <API key>, &val);
if (start)
bnx2_write_phy(bp, <API key>, val & 0xff0f);
else
bnx2_write_phy(bp, <API key>, val | 0xc0);
}
static int
bnx2_set_link(struct bnx2 *bp)
{
u32 bmsr;
u8 link_up;
if (bp->loopback == MAC_LOOPBACK || bp->loopback == PHY_LOOPBACK) {
bp->link_up = 1;
return 0;
}
if (bp->phy_flags & <API key>)
return 0;
link_up = bp->link_up;
bnx2_enable_bmsr1(bp);
bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
bnx2_disable_bmsr1(bp);
if ((bp->phy_flags & <API key>) &&
(BNX2_CHIP(bp) == BNX2_CHIP_5706)) {
u32 val, an_dbg;
if (bp->phy_flags & <API key>) {
<API key>(bp, 0);
bp->phy_flags &= ~<API key>;
}
val = BNX2_RD(bp, BNX2_EMAC_STATUS);
bnx2_write_phy(bp, <API key>, MISC_SHDW_AN_DBG);
bnx2_read_phy(bp, <API key>, &an_dbg);
bnx2_read_phy(bp, <API key>, &an_dbg);
if ((val & <API key>) &&
!(an_dbg & <API key>))
bmsr |= BMSR_LSTATUS;
else
bmsr &= ~BMSR_LSTATUS;
}
if (bmsr & BMSR_LSTATUS) {
bp->link_up = 1;
if (bp->phy_flags & <API key>) {
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
bnx2_5706s_linkup(bp);
else if (BNX2_CHIP(bp) == BNX2_CHIP_5708)
bnx2_5708s_linkup(bp);
else if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_5709s_linkup(bp);
}
else {
bnx2_copper_linkup(bp);
}
<API key>(bp);
}
else {
if ((bp->phy_flags & <API key>) &&
(bp->autoneg & AUTONEG_SPEED))
<API key>(bp);
if (bp->phy_flags & <API key>) {
u32 bmcr;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
bmcr |= BMCR_ANENABLE;
bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
bp->phy_flags &= ~<API key>;
}
bp->link_up = 0;
}
if (bp->link_up != link_up) {
bnx2_report_link(bp);
}
bnx2_set_mac_link(bp);
return 0;
}
static int
bnx2_reset_phy(struct bnx2 *bp)
{
int i;
u32 reg;
bnx2_write_phy(bp, bp->mii_bmcr, BMCR_RESET);
#define PHY_RESET_MAX_WAIT 100
for (i = 0; i < PHY_RESET_MAX_WAIT; i++) {
udelay(10);
bnx2_read_phy(bp, bp->mii_bmcr, ®);
if (!(reg & BMCR_RESET)) {
udelay(20);
break;
}
}
if (i == PHY_RESET_MAX_WAIT) {
return -EBUSY;
}
return 0;
}
static u32
<API key>(struct bnx2 *bp)
{
u32 adv = 0;
if ((bp->req_flow_ctrl & (FLOW_CTRL_RX | FLOW_CTRL_TX)) ==
(FLOW_CTRL_RX | FLOW_CTRL_TX)) {
if (bp->phy_flags & <API key>) {
adv = <API key>;
}
else {
adv = ADVERTISE_PAUSE_CAP;
}
}
else if (bp->req_flow_ctrl & FLOW_CTRL_TX) {
if (bp->phy_flags & <API key>) {
adv = <API key>;
}
else {
adv = <API key>;
}
}
else if (bp->req_flow_ctrl & FLOW_CTRL_RX) {
if (bp->phy_flags & <API key>) {
adv = <API key> | <API key>;
}
else {
adv = ADVERTISE_PAUSE_CAP | <API key>;
}
}
return adv;
}
static int bnx2_fw_sync(struct bnx2 *, u32, int, int);
static int
<API key>(struct bnx2 *bp, u8 port)
__releases(&bp->phy_lock)
__acquires(&bp->phy_lock)
{
u32 speed_arg = 0, pause_adv;
pause_adv = <API key>(bp);
if (bp->autoneg & AUTONEG_SPEED) {
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
if (bp->advertising & <API key>)
speed_arg |= <API key>;
} else {
if (bp->req_line_speed == SPEED_2500)
speed_arg = <API key>;
else if (bp->req_line_speed == SPEED_1000)
speed_arg = <API key>;
else if (bp->req_line_speed == SPEED_100) {
if (bp->req_duplex == DUPLEX_FULL)
speed_arg = <API key>;
else
speed_arg = <API key>;
} else if (bp->req_line_speed == SPEED_10) {
if (bp->req_duplex == DUPLEX_FULL)
speed_arg = <API key>;
else
speed_arg = <API key>;
}
}
if (pause_adv & (<API key> | ADVERTISE_PAUSE_CAP))
speed_arg |= <API key>;
if (pause_adv & (<API key> | <API key>))
speed_arg |= <API key>;
if (port == PORT_TP)
speed_arg |= <API key> |
<API key>;
bnx2_shmem_wr(bp, BNX2_DRV_MB_ARG0, speed_arg);
spin_unlock_bh(&bp->phy_lock);
bnx2_fw_sync(bp, <API key>, 1, 0);
spin_lock_bh(&bp->phy_lock);
return 0;
}
static int
<API key>(struct bnx2 *bp, u8 port)
__releases(&bp->phy_lock)
__acquires(&bp->phy_lock)
{
u32 adv, bmcr;
u32 new_adv = 0;
if (bp->phy_flags & <API key>)
return <API key>(bp, port);
if (!(bp->autoneg & AUTONEG_SPEED)) {
u32 new_bmcr;
int force_link_down = 0;
if (bp->req_line_speed == SPEED_2500) {
if (!<API key>(bp))
force_link_down = 1;
} else if (bp->req_line_speed == SPEED_1000) {
if (<API key>(bp))
force_link_down = 1;
}
bnx2_read_phy(bp, bp->mii_adv, &adv);
adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
new_bmcr = bmcr & ~BMCR_ANENABLE;
new_bmcr |= BMCR_SPEED1000;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if (bp->req_line_speed == SPEED_2500)
<API key>(bp);
else if (bp->req_line_speed == SPEED_1000) {
<API key>(bp);
new_bmcr &= ~0x2000;
}
} else if (BNX2_CHIP(bp) == BNX2_CHIP_5708) {
if (bp->req_line_speed == SPEED_2500)
new_bmcr |= <API key>;
else
new_bmcr = bmcr & ~<API key>;
}
if (bp->req_duplex == DUPLEX_FULL) {
adv |= ADVERTISE_1000XFULL;
new_bmcr |= BMCR_FULLDPLX;
}
else {
adv |= ADVERTISE_1000XHALF;
new_bmcr &= ~BMCR_FULLDPLX;
}
if ((new_bmcr != bmcr) || (force_link_down)) {
/* Force a link down visible on the other side */
if (bp->link_up) {
bnx2_write_phy(bp, bp->mii_adv, adv &
~(ADVERTISE_1000XFULL |
ADVERTISE_1000XHALF));
bnx2_write_phy(bp, bp->mii_bmcr, bmcr |
BMCR_ANRESTART | BMCR_ANENABLE);
bp->link_up = 0;
netif_carrier_off(bp->dev);
bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
bnx2_report_link(bp);
}
bnx2_write_phy(bp, bp->mii_adv, adv);
bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
} else {
<API key>(bp);
bnx2_set_mac_link(bp);
}
return 0;
}
<API key>(bp);
if (bp->advertising & <API key>)
new_adv |= ADVERTISE_1000XFULL;
new_adv |= <API key>(bp);
bnx2_read_phy(bp, bp->mii_adv, &adv);
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
bp->serdes_an_pending = 0;
if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
/* Force a link down visible on the other side */
if (bp->link_up) {
bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
spin_unlock_bh(&bp->phy_lock);
bnx2_msleep(20);
spin_lock_bh(&bp->phy_lock);
}
bnx2_write_phy(bp, bp->mii_adv, new_adv);
bnx2_write_phy(bp, bp->mii_bmcr, bmcr | BMCR_ANRESTART |
BMCR_ANENABLE);
/* Speed up link-up time when the link partner
* does not autonegotiate which is very common
* in blade servers. Some blade servers use
* IPMI for kerboard input and it's important
* to minimize link disruptions. Autoneg. involves
* exchanging base pages plus 3 next pages and
* normally completes in about 120 msec.
*/
bp->current_interval = <API key>;
bp->serdes_an_pending = 1;
mod_timer(&bp->timer, jiffies + bp->current_interval);
} else {
<API key>(bp);
bnx2_set_mac_link(bp);
}
return 0;
}
#define <API key> \
(bp->phy_flags & <API key>) ? \
(<API key> | <API key>) :\
(<API key>)
#define <API key> \
(<API key> | <API key> | \
<API key> | <API key> | \
<API key>)
#define <API key> (ADVERTISE_10HALF | ADVERTISE_10FULL | \
ADVERTISE_100HALF | ADVERTISE_100FULL | ADVERTISE_CSMA)
#define PHY_ALL_1000_SPEED (ADVERTISE_1000HALF | ADVERTISE_1000FULL)
static void
<API key>(struct bnx2 *bp)
{
u32 link;
if (bp->phy_port == PORT_TP)
link = bnx2_shmem_rd(bp, <API key>);
else
link = bnx2_shmem_rd(bp, <API key>);
if (link & <API key>) {
bp->req_line_speed = 0;
bp->autoneg |= AUTONEG_SPEED;
bp->advertising = ADVERTISED_Autoneg;
if (link & <API key>)
bp->advertising |= <API key>;
if (link & <API key>)
bp->advertising |= <API key>;
if (link & <API key>)
bp->advertising |= <API key>;
if (link & <API key>)
bp->advertising |= <API key>;
if (link & <API key>)
bp->advertising |= <API key>;
if (link & <API key>)
bp->advertising |= <API key>;
} else {
bp->autoneg = 0;
bp->advertising = 0;
bp->req_duplex = DUPLEX_FULL;
if (link & <API key>) {
bp->req_line_speed = SPEED_10;
if (link & <API key>)
bp->req_duplex = DUPLEX_HALF;
}
if (link & <API key>) {
bp->req_line_speed = SPEED_100;
if (link & <API key>)
bp->req_duplex = DUPLEX_HALF;
}
if (link & <API key>)
bp->req_line_speed = SPEED_1000;
if (link & <API key>)
bp->req_line_speed = SPEED_2500;
}
}
static void
<API key>(struct bnx2 *bp)
{
if (bp->phy_flags & <API key>) {
<API key>(bp);
return;
}
bp->autoneg = AUTONEG_SPEED | AUTONEG_FLOW_CTRL;
bp->req_line_speed = 0;
if (bp->phy_flags & <API key>) {
u32 reg;
bp->advertising = <API key> | ADVERTISED_Autoneg;
reg = bnx2_shmem_rd(bp, <API key>);
reg &= <API key>;
if (reg == <API key>) {
bp->autoneg = 0;
bp->req_line_speed = bp->line_speed = SPEED_1000;
bp->req_duplex = DUPLEX_FULL;
}
} else
bp->advertising = <API key> | ADVERTISED_Autoneg;
}
static void
<API key>(struct bnx2 *bp)
{
u32 msg;
u32 addr;
spin_lock(&bp->indirect_lock);
msg = (u32) (++bp->fw_drv_pulse_wr_seq & <API key>);
addr = bp->shmem_base + BNX2_DRV_PULSE_MB;
BNX2_WR(bp, <API key>, addr);
BNX2_WR(bp, <API key>, msg);
spin_unlock(&bp->indirect_lock);
}
static void
<API key>(struct bnx2 *bp)
{
u32 msg;
u8 link_up = bp->link_up;
u8 old_port;
msg = bnx2_shmem_rd(bp, BNX2_LINK_STATUS);
if (msg & <API key>)
<API key>(bp);
msg &= ~<API key>;
if ((msg & <API key>) == <API key>)
bp->link_up = 0;
else {
u32 speed;
bp->link_up = 1;
speed = msg & <API key>;
bp->duplex = DUPLEX_FULL;
switch (speed) {
case <API key>:
bp->duplex = DUPLEX_HALF;
/* fall through */
case <API key>:
bp->line_speed = SPEED_10;
break;
case <API key>:
bp->duplex = DUPLEX_HALF;
/* fall through */
case <API key>:
/* fall through */
case <API key>:
bp->line_speed = SPEED_100;
break;
case <API key>:
bp->duplex = DUPLEX_HALF;
/* fall through */
case <API key>:
bp->line_speed = SPEED_1000;
break;
case <API key>:
bp->duplex = DUPLEX_HALF;
/* fall through */
case <API key>:
bp->line_speed = SPEED_2500;
break;
default:
bp->line_speed = 0;
break;
}
bp->flow_ctrl = 0;
if ((bp->autoneg & (AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) !=
(AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) {
if (bp->duplex == DUPLEX_FULL)
bp->flow_ctrl = bp->req_flow_ctrl;
} else {
if (msg & <API key>)
bp->flow_ctrl |= FLOW_CTRL_TX;
if (msg & <API key>)
bp->flow_ctrl |= FLOW_CTRL_RX;
}
old_port = bp->phy_port;
if (msg & <API key>)
bp->phy_port = PORT_FIBRE;
else
bp->phy_port = PORT_TP;
if (old_port != bp->phy_port)
<API key>(bp);
}
if (bp->link_up != link_up)
bnx2_report_link(bp);
bnx2_set_mac_link(bp);
}
static int
<API key>(struct bnx2 *bp)
{
u32 evt_code;
spin_lock(&bp->indirect_lock);
BNX2_WR(bp, <API key>,
bp->shmem_base + BNX2_FW_EVT_CODE_MB);
evt_code = BNX2_RD(bp, <API key>);
spin_unlock(&bp->indirect_lock);
switch (evt_code) {
case <API key>:
<API key>(bp);
break;
case <API key>:
default:
<API key>(bp);
break;
}
return 0;
}
static int
<API key>(struct bnx2 *bp)
__releases(&bp->phy_lock)
__acquires(&bp->phy_lock)
{
u32 bmcr;
u32 new_bmcr;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (bp->autoneg & AUTONEG_SPEED) {
u32 adv_reg, adv1000_reg;
u32 new_adv = 0;
u32 new_adv1000 = 0;
bnx2_read_phy(bp, bp->mii_adv, &adv_reg);
adv_reg &= (<API key> | ADVERTISE_PAUSE_CAP |
<API key>);
bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
adv1000_reg &= PHY_ALL_1000_SPEED;
new_adv = <API key>(bp->advertising);
new_adv |= ADVERTISE_CSMA;
new_adv |= <API key>(bp);
new_adv1000 |= <API key>(bp->advertising);
if ((adv1000_reg != new_adv1000) ||
(adv_reg != new_adv) ||
((bmcr & BMCR_ANENABLE) == 0)) {
bnx2_write_phy(bp, bp->mii_adv, new_adv);
bnx2_write_phy(bp, MII_CTRL1000, new_adv1000);
bnx2_write_phy(bp, bp->mii_bmcr, BMCR_ANRESTART |
BMCR_ANENABLE);
}
else if (bp->link_up) {
/* Flow ctrl may have changed from auto to forced */
/* or vice-versa. */
<API key>(bp);
bnx2_set_mac_link(bp);
}
return 0;
}
new_bmcr = 0;
if (bp->req_line_speed == SPEED_100) {
new_bmcr |= BMCR_SPEED100;
}
if (bp->req_duplex == DUPLEX_FULL) {
new_bmcr |= BMCR_FULLDPLX;
}
if (new_bmcr != bmcr) {
u32 bmsr;
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
if (bmsr & BMSR_LSTATUS) {
/* Force link down */
bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
spin_unlock_bh(&bp->phy_lock);
bnx2_msleep(50);
spin_lock_bh(&bp->phy_lock);
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
}
bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
/* Normally, the new speed is setup after the link has
* gone down and up again. In some cases, link will not go
* down so we need to set up the new speed here.
*/
if (bmsr & BMSR_LSTATUS) {
bp->line_speed = bp->req_line_speed;
bp->duplex = bp->req_duplex;
<API key>(bp);
bnx2_set_mac_link(bp);
}
} else {
<API key>(bp);
bnx2_set_mac_link(bp);
}
return 0;
}
static int
bnx2_setup_phy(struct bnx2 *bp, u8 port)
__releases(&bp->phy_lock)
__acquires(&bp->phy_lock)
{
if (bp->loopback == MAC_LOOPBACK)
return 0;
if (bp->phy_flags & <API key>) {
return <API key>(bp, port);
}
else {
return <API key>(bp);
}
}
static int
bnx2_init_5709s_phy(struct bnx2 *bp, int reset_phy)
{
u32 val;
bp->mii_bmcr = MII_BMCR + 0x10;
bp->mii_bmsr = MII_BMSR + 0x10;
bp->mii_bmsr1 = <API key>;
bp->mii_adv = MII_ADVERTISE + 0x10;
bp->mii_lpa = MII_LPA + 0x10;
bp->mii_up1 = MII_BNX2_OVER1G_UP1;
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_write_phy(bp, MII_BNX2_AER_AER, <API key>);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
if (reset_phy)
bnx2_reset_phy(bp);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, <API key>, &val);
val &= ~<API key>;
val |= <API key>;
/* NEMO temp. FIX */
if (bnx2_shmem_rd(bp, <API key>) & 0x80000000)
val |= (1 << 3);
bnx2_write_phy(bp, <API key>, val);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, MII_BNX2_OVER1G_UP1, &val);
if (bp->phy_flags & <API key>)
val |= BCM5708S_UP1_2G5;
else
val &= ~BCM5708S_UP1_2G5;
bnx2_write_phy(bp, MII_BNX2_OVER1G_UP1, val);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
bnx2_read_phy(bp, <API key>, &val);
val |= <API key> | <API key>;
bnx2_write_phy(bp, <API key>, val);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
val = <API key> | <API key> |
<API key>;
bnx2_write_phy(bp, <API key>, val);
bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, <API key>);
return 0;
}
static int
bnx2_init_5708s_phy(struct bnx2 *bp, int reset_phy)
{
u32 val;
if (reset_phy)
bnx2_reset_phy(bp);
bp->mii_up1 = BCM5708S_UP1;
bnx2_write_phy(bp, BCM5708S_BLK_ADDR, <API key>);
bnx2_write_phy(bp, BCM5708S_DIG_3_0, <API key>);
bnx2_write_phy(bp, BCM5708S_BLK_ADDR, <API key>);
bnx2_read_phy(bp, BCM5708S_1000X_CTL1, &val);
val |= <API key> | <API key>;
bnx2_write_phy(bp, BCM5708S_1000X_CTL1, val);
bnx2_read_phy(bp, BCM5708S_1000X_CTL2, &val);
val |= <API key>;
bnx2_write_phy(bp, BCM5708S_1000X_CTL2, val);
if (bp->phy_flags & <API key>) {
bnx2_read_phy(bp, BCM5708S_UP1, &val);
val |= BCM5708S_UP1_2G5;
bnx2_write_phy(bp, BCM5708S_UP1, val);
}
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>)) {
/* increase tx signal amplitude */
bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
<API key>);
bnx2_read_phy(bp, BCM5708S_TX_ACTL1, &val);
val &= ~<API key>;
bnx2_write_phy(bp, BCM5708S_TX_ACTL1, val);
bnx2_write_phy(bp, BCM5708S_BLK_ADDR, <API key>);
}
val = bnx2_shmem_rd(bp, <API key>) &
<API key>;
if (val) {
u32 is_backplane;
is_backplane = bnx2_shmem_rd(bp, <API key>);
if (is_backplane & <API key>) {
bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
<API key>);
bnx2_write_phy(bp, BCM5708S_TX_ACTL3, val);
bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
<API key>);
}
}
return 0;
}
static int
bnx2_init_5706s_phy(struct bnx2 *bp, int reset_phy)
{
if (reset_phy)
bnx2_reset_phy(bp);
bp->phy_flags &= ~<API key>;
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
BNX2_WR(bp, <API key>, 0x300);
if (bp->dev->mtu > 1500) {
u32 val;
/* Set extended packet length bit */
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, (val & 0xfff8) | 0x4000);
bnx2_write_phy(bp, 0x1c, 0x6c00);
bnx2_read_phy(bp, 0x1c, &val);
bnx2_write_phy(bp, 0x1c, (val & 0x3ff) | 0xec02);
}
else {
u32 val;
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, val & ~0x4007);
bnx2_write_phy(bp, 0x1c, 0x6c00);
bnx2_read_phy(bp, 0x1c, &val);
bnx2_write_phy(bp, 0x1c, (val & 0x3fd) | 0xec00);
}
return 0;
}
static int
<API key>(struct bnx2 *bp, int reset_phy)
{
u32 val;
if (reset_phy)
bnx2_reset_phy(bp);
if (bp->phy_flags & <API key>) {
bnx2_write_phy(bp, 0x18, 0x0c00);
bnx2_write_phy(bp, 0x17, 0x000a);
bnx2_write_phy(bp, 0x15, 0x310b);
bnx2_write_phy(bp, 0x17, 0x201f);
bnx2_write_phy(bp, 0x15, 0x9506);
bnx2_write_phy(bp, 0x17, 0x401f);
bnx2_write_phy(bp, 0x15, 0x14e2);
bnx2_write_phy(bp, 0x18, 0x0400);
}
if (bp->phy_flags & <API key>) {
bnx2_write_phy(bp, <API key>,
<API key> | 0x8);
bnx2_read_phy(bp, <API key>, &val);
val &= ~(1 << 8);
bnx2_write_phy(bp, <API key>, val);
}
if (bp->dev->mtu > 1500) {
/* Set extended packet length bit */
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, val | 0x4000);
bnx2_read_phy(bp, 0x10, &val);
bnx2_write_phy(bp, 0x10, val | 0x1);
}
else {
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, val & ~0x4007);
bnx2_read_phy(bp, 0x10, &val);
bnx2_write_phy(bp, 0x10, val & ~0x1);
}
/* ethernet@wirespeed & auto-mdix*/
bnx2_write_phy(bp, 0x18, 0x7007);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, val | (1 << 15) | (1 << 4) | (1 << 9));
return 0;
}
static int
bnx2_init_phy(struct bnx2 *bp, int reset_phy)
__releases(&bp->phy_lock)
__acquires(&bp->phy_lock)
{
u32 val;
int rc = 0;
bp->phy_flags &= ~<API key>;
bp->phy_flags |= <API key>;
bp->mii_bmcr = MII_BMCR;
bp->mii_bmsr = MII_BMSR;
bp->mii_bmsr1 = MII_BMSR;
bp->mii_adv = MII_ADVERTISE;
bp->mii_lpa = MII_LPA;
BNX2_WR(bp, <API key>, <API key>);
if (bp->phy_flags & <API key>)
goto setup_phy;
bnx2_read_phy(bp, MII_PHYSID1, &val);
bp->phy_id = val << 16;
bnx2_read_phy(bp, MII_PHYSID2, &val);
bp->phy_id |= val & 0xffff;
if (bp->phy_flags & <API key>) {
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
rc = bnx2_init_5706s_phy(bp, reset_phy);
else if (BNX2_CHIP(bp) == BNX2_CHIP_5708)
rc = bnx2_init_5708s_phy(bp, reset_phy);
else if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
rc = bnx2_init_5709s_phy(bp, reset_phy);
}
else {
rc = <API key>(bp, reset_phy);
}
setup_phy:
if (!rc)
rc = bnx2_setup_phy(bp, bp->phy_port);
return rc;
}
static int
<API key>(struct bnx2 *bp)
{
u32 mac_mode;
mac_mode = BNX2_RD(bp, BNX2_EMAC_MODE);
mac_mode &= ~BNX2_EMAC_MODE_PORT;
mac_mode |= <API key> | <API key>;
BNX2_WR(bp, BNX2_EMAC_MODE, mac_mode);
bp->link_up = 1;
return 0;
}
static int bnx2_test_link(struct bnx2 *);
static int
<API key>(struct bnx2 *bp)
{
u32 mac_mode;
int rc, i;
spin_lock_bh(&bp->phy_lock);
rc = bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK | BMCR_FULLDPLX |
BMCR_SPEED1000);
spin_unlock_bh(&bp->phy_lock);
if (rc)
return rc;
for (i = 0; i < 10; i++) {
if (bnx2_test_link(bp) == 0)
break;
bnx2_msleep(100);
}
mac_mode = BNX2_RD(bp, BNX2_EMAC_MODE);
mac_mode &= ~(BNX2_EMAC_MODE_PORT | <API key> |
<API key> | <API key> |
<API key>);
mac_mode |= <API key>;
BNX2_WR(bp, BNX2_EMAC_MODE, mac_mode);
bp->link_up = 1;
return 0;
}
static void
bnx2_dump_mcp_state(struct bnx2 *bp)
{
struct net_device *dev = bp->dev;
u32 mcp_p0, mcp_p1;
netdev_err(dev, "<
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
mcp_p0 = BNX2_MCP_STATE_P0;
mcp_p1 = BNX2_MCP_STATE_P1;
} else {
mcp_p0 = <API key>;
mcp_p1 = <API key>;
}
netdev_err(dev, "DEBUG: MCP_STATE_P0[%08x] MCP_STATE_P1[%08x]\n",
bnx2_reg_rd_ind(bp, mcp_p0), bnx2_reg_rd_ind(bp, mcp_p1));
netdev_err(dev, "DEBUG: MCP mode[%08x] state[%08x] evt_mask[%08x]\n",
bnx2_reg_rd_ind(bp, BNX2_MCP_CPU_MODE),
bnx2_reg_rd_ind(bp, BNX2_MCP_CPU_STATE),
bnx2_reg_rd_ind(bp, <API key>));
netdev_err(dev, "DEBUG: pc[%08x] pc[%08x] instr[%08x]\n",
bnx2_reg_rd_ind(bp, <API key>),
bnx2_reg_rd_ind(bp, <API key>),
bnx2_reg_rd_ind(bp, <API key>));
netdev_err(dev, "DEBUG: shmem states:\n");
netdev_err(dev, "DEBUG: drv_mb[%08x] fw_mb[%08x] link_status[%08x]",
bnx2_shmem_rd(bp, BNX2_DRV_MB),
bnx2_shmem_rd(bp, BNX2_FW_MB),
bnx2_shmem_rd(bp, BNX2_LINK_STATUS));
pr_cont(" drv_pulse_mb[%08x]\n", bnx2_shmem_rd(bp, BNX2_DRV_PULSE_MB));
netdev_err(dev, "DEBUG: dev_info_signature[%08x] reset_type[%08x]",
bnx2_shmem_rd(bp, <API key>),
bnx2_shmem_rd(bp, <API key>));
pr_cont(" condition[%08x]\n",
bnx2_shmem_rd(bp, <API key>));
DP_SHMEM_LINE(bp, <API key>);
DP_SHMEM_LINE(bp, 0x3cc);
DP_SHMEM_LINE(bp, 0x3dc);
DP_SHMEM_LINE(bp, 0x3ec);
netdev_err(dev, "DEBUG: 0x3fc[%08x]\n", bnx2_shmem_rd(bp, 0x3fc));
netdev_err(dev, "<
}
static int
bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int ack, int silent)
{
int i;
u32 val;
bp->fw_wr_seq++;
msg_data |= bp->fw_wr_seq;
bnx2_shmem_wr(bp, BNX2_DRV_MB, msg_data);
if (!ack)
return 0;
/* wait for an acknowledgement. */
for (i = 0; i < (<API key> / 10); i++) {
bnx2_msleep(10);
val = bnx2_shmem_rd(bp, BNX2_FW_MB);
if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ))
break;
}
if ((msg_data & BNX2_DRV_MSG_DATA) == <API key>)
return 0;
/* If we timed out, inform the firmware that this is the case. */
if ((val & BNX2_FW_MSG_ACK) != (msg_data & BNX2_DRV_MSG_SEQ)) {
msg_data &= ~BNX2_DRV_MSG_CODE;
msg_data |= <API key>;
bnx2_shmem_wr(bp, BNX2_DRV_MB, msg_data);
if (!silent) {
pr_err("fw sync timeout, reset code = %x\n", msg_data);
bnx2_dump_mcp_state(bp);
}
return -EBUSY;
}
if ((val & <API key>) != <API key>)
return -EIO;
return 0;
}
static int
<API key>(struct bnx2 *bp)
{
int i, ret = 0;
u32 val;
val = <API key> | <API key> | (1 << 12);
val |= (BNX2_PAGE_BITS - 8) << 16;
BNX2_WR(bp, BNX2_CTX_COMMAND, val);
for (i = 0; i < 10; i++) {
val = BNX2_RD(bp, BNX2_CTX_COMMAND);
if (!(val & <API key>))
break;
udelay(2);
}
if (val & <API key>)
return -EBUSY;
for (i = 0; i < bp->ctx_pages; i++) {
int j;
if (bp->ctx_blk[i])
memset(bp->ctx_blk[i], 0, BNX2_PAGE_SIZE);
else
return -ENOMEM;
BNX2_WR(bp, <API key>,
(bp->ctx_blk_mapping[i] & 0xffffffff) |
<API key>);
BNX2_WR(bp, <API key>,
(u64) bp->ctx_blk_mapping[i] >> 32);
BNX2_WR(bp, <API key>, i |
<API key>);
for (j = 0; j < 10; j++) {
val = BNX2_RD(bp, <API key>);
if (!(val & <API key>))
break;
udelay(5);
}
if (val & <API key>) {
ret = -EBUSY;
break;
}
}
return ret;
}
static void
bnx2_init_context(struct bnx2 *bp)
{
u32 vcid;
vcid = 96;
while (vcid) {
u32 vcid_addr, pcid_addr, offset;
int i;
vcid
if (BNX2_CHIP_ID(bp) == <API key>) {
u32 new_vcid;
vcid_addr = GET_PCID_ADDR(vcid);
if (vcid & 0x8) {
new_vcid = 0x60 + (vcid & 0xf0) + (vcid & 0x7);
}
else {
new_vcid = vcid;
}
pcid_addr = GET_PCID_ADDR(new_vcid);
}
else {
vcid_addr = GET_CID_ADDR(vcid);
pcid_addr = vcid_addr;
}
for (i = 0; i < (CTX_SIZE / PHY_CTX_SIZE); i++) {
vcid_addr += (i << PHY_CTX_SHIFT);
pcid_addr += (i << PHY_CTX_SHIFT);
BNX2_WR(bp, BNX2_CTX_VIRT_ADDR, vcid_addr);
BNX2_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
/* Zero out the context. */
for (offset = 0; offset < PHY_CTX_SIZE; offset += 4)
bnx2_ctx_wr(bp, vcid_addr, offset, 0);
}
}
}
static int
bnx2_alloc_bad_rbuf(struct bnx2 *bp)
{
u16 *good_mbuf;
u32 good_mbuf_cnt;
u32 val;
good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
if (good_mbuf == NULL)
return -ENOMEM;
BNX2_WR(bp, <API key>,
<API key>);
good_mbuf_cnt = 0;
/* Allocate a bunch of mbufs and save the good ones in an array. */
val = bnx2_reg_rd_ind(bp, BNX2_RBUF_STATUS1);
while (val & <API key>) {
bnx2_reg_wr_ind(bp, BNX2_RBUF_COMMAND,
<API key>);
val = bnx2_reg_rd_ind(bp, <API key>);
val &= <API key>;
/* The addresses with Bit 9 set are bad memory blocks. */
if (!(val & (1 << 9))) {
good_mbuf[good_mbuf_cnt] = (u16) val;
good_mbuf_cnt++;
}
val = bnx2_reg_rd_ind(bp, BNX2_RBUF_STATUS1);
}
/* Free the good ones back to the mbuf pool thus discarding
* all the bad ones. */
while (good_mbuf_cnt) {
good_mbuf_cnt
val = good_mbuf[good_mbuf_cnt];
val = (val << 9) | val | 1;
bnx2_reg_wr_ind(bp, <API key>, val);
}
kfree(good_mbuf);
return 0;
}
static void
bnx2_set_mac_addr(struct bnx2 *bp, u8 *mac_addr, u32 pos)
{
u32 val;
val = (mac_addr[0] << 8) | mac_addr[1];
BNX2_WR(bp, <API key> + (pos * 8), val);
val = (mac_addr[2] << 24) | (mac_addr[3] << 16) |
(mac_addr[4] << 8) | mac_addr[5];
BNX2_WR(bp, <API key> + (pos * 8), val);
}
static inline int
bnx2_alloc_rx_page(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index, gfp_t gfp)
{
dma_addr_t mapping;
struct bnx2_sw_pg *rx_pg = &rxr->rx_pg_ring[index];
struct bnx2_rx_bd *rxbd =
&rxr->rx_pg_desc_ring[BNX2_RX_RING(index)][BNX2_RX_IDX(index)];
struct page *page = alloc_page(gfp);
if (!page)
return -ENOMEM;
#if (LINUX_VERSION_CODE >= 0x02061b)
mapping = dma_map_page(&bp->pdev->dev, page, 0, PAGE_SIZE,
PCI_DMA_FROMDEVICE);
if (dma_mapping_error(&bp->pdev->dev, mapping)) {
#else
mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE,
PCI_DMA_FROMDEVICE);
if (<API key>(mapping)) {
#endif
__free_page(page);
return -EIO;
}
rx_pg->page = page;
dma_unmap_addr_set(rx_pg, mapping, mapping);
rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
rxbd->rx_bd_haddr_lo = (u64) mapping & 0xffffffff;
return 0;
}
static void
bnx2_free_rx_page(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index)
{
struct bnx2_sw_pg *rx_pg = &rxr->rx_pg_ring[index];
struct page *page = rx_pg->page;
if (!page)
return;
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(rx_pg, mapping),
PAGE_SIZE, PCI_DMA_FROMDEVICE);
#else
pci_unmap_page(bp->pdev, dma_unmap_addr(rx_pg, mapping), PAGE_SIZE,
PCI_DMA_FROMDEVICE);
#endif
__free_page(page);
rx_pg->page = NULL;
}
static inline int
bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index, gfp_t gfp)
{
struct sk_buff *skb;
struct bnx2_sw_bd *rx_buf = &rxr->rx_buf_ring[index];
dma_addr_t mapping;
struct bnx2_rx_bd *rxbd =
&rxr->rx_desc_ring[BNX2_RX_RING(index)][BNX2_RX_IDX(index)];
unsigned long align;
skb = __netdev_alloc_skb(bp->dev, bp->rx_buf_size, gfp);
if (skb == NULL) {
return -ENOMEM;
}
if (unlikely((align = (unsigned long) skb->data & (BNX2_RX_ALIGN - 1))))
skb_reserve(skb, BNX2_RX_ALIGN - align);
#if (LINUX_VERSION_CODE >= 0x02061b)
mapping = dma_map_single(&bp->pdev->dev, skb->data, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
if (dma_mapping_error(&bp->pdev->dev, mapping)) {
#else
mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
if (<API key>(mapping)) {
#endif
dev_kfree_skb(skb);
return -EIO;
}
rx_buf->skb = skb;
rx_buf->desc = (struct l2_fhdr *) skb->data;
dma_unmap_addr_set(rx_buf, mapping, mapping);
rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
rxbd->rx_bd_haddr_lo = (u64) mapping & 0xffffffff;
rxr->rx_prod_bseq += bp->rx_buf_use_size;
return 0;
}
static int
<API key>(struct bnx2 *bp, struct bnx2_napi *bnapi, u32 event)
{
struct status_block *sblk = bnapi->status_blk.msi;
u32 new_link_state, old_link_state;
int is_set = 1;
new_link_state = sblk->status_attn_bits & event;
old_link_state = sblk-><API key> & event;
if (new_link_state != old_link_state) {
if (new_link_state)
BNX2_WR(bp, <API key>, event);
else
BNX2_WR(bp, <API key>, event);
} else
is_set = 0;
return is_set;
}
static void
bnx2_phy_int(struct bnx2 *bp, struct bnx2_napi *bnapi)
{
spin_lock(&bp->phy_lock);
if (<API key>(bp, bnapi, <API key>))
bnx2_set_link(bp);
if (<API key>(bp, bnapi, <API key>))
<API key>(bp);
spin_unlock(&bp->phy_lock);
}
static inline u16
bnx2_get_hw_tx_cons(struct bnx2_napi *bnapi)
{
u16 cons;
/* Tell compiler that status block fields can change. */
barrier();
cons = *bnapi->hw_tx_cons_ptr;
barrier();
if (unlikely((cons & <API key>) == <API key>))
cons++;
return cons;
}
static int
#if defined(__VMKLNX__)
bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget,
int check_queue)
#else
bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
#endif
{
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
u16 hw_cons, sw_cons, sw_ring_cons;
#ifndef <API key>
int tx_pkt = 0;
#else
int tx_pkt = 0, index;
struct netdev_queue *txq;
index = (bnapi - bp->bnx2_napi);
txq = netdev_get_tx_queue(bp->dev, index);
#endif
hw_cons = bnx2_get_hw_tx_cons(bnapi);
sw_cons = txr->tx_cons;
while (sw_cons != hw_cons) {
struct bnx2_sw_tx_bd *tx_buf;
struct sk_buff *skb;
int i, last;
sw_ring_cons = BNX2_TX_RING_IDX(sw_cons);
tx_buf = &txr->tx_buf_ring[sw_ring_cons];
skb = tx_buf->skb;
/* prefetch skb_end_pointer() to speedup skb_shinfo(skb) */
prefetch(&skb->end);
#ifdef BCM_TSO
/* partial BD completions possible with TSO packets */
if (tx_buf->is_gso) {
u16 last_idx, last_ring_idx;
last_idx = sw_cons + tx_buf->nr_frags + 1;
last_ring_idx = sw_ring_cons + tx_buf->nr_frags + 1;
if (unlikely(last_ring_idx >= <API key>)) {
last_idx++;
}
if (((s16) ((s16) last_idx - (s16) hw_cons)) > 0) {
break;
}
}
#endif
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping),
skb_headlen(skb), PCI_DMA_TODEVICE);
#else
pci_unmap_single(bp->pdev, dma_unmap_addr(tx_buf, mapping),
skb_headlen(skb), PCI_DMA_TODEVICE);
#endif
tx_buf->skb = NULL;
last = tx_buf->nr_frags;
for (i = 0; i < last; i++) {
struct bnx2_sw_tx_bd *tx_buf;
sw_cons = BNX2_NEXT_TX_BD(sw_cons);
tx_buf = &txr->tx_buf_ring[BNX2_TX_RING_IDX(sw_cons)];
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_page(&bp->pdev->dev,
#else
pci_unmap_page(bp->pdev,
#endif
dma_unmap_addr(tx_buf, mapping),
skb_frag_size(&skb_shinfo(skb)->frags[i]),
PCI_DMA_TODEVICE);
}
sw_cons = BNX2_NEXT_TX_BD(sw_cons);
dev_kfree_skb(skb);
#if defined(<API key>)
bnapi->stats.tx_packets++;
bnapi->stats.tx_bytes += skb->len;
bnapi-><API key>++;
wmb();
#endif
tx_pkt++;
if (tx_pkt == budget)
break;
if (hw_cons == sw_cons)
hw_cons = bnx2_get_hw_tx_cons(bnapi);
}
txr->hw_tx_cons = hw_cons;
txr->tx_cons = sw_cons;
/* Need to make the tx_cons update visible to bnx2_start_xmit()
* before checking for <API key>(). Without the
* memory barrier, there is a small possibility that bnx2_start_xmit()
* will miss it and cause the queue to be stopped forever.
*/
smp_mb();
#if defined(<API key>)
if ((!check_queue) || (bp->netq_state & BNX2_NETQ_SUSPENDED))
return tx_pkt;
#endif
#ifndef <API key>
if (unlikely(netif_queue_stopped(bp->dev)) &&
(bnx2_tx_avail(bp, txr) > bp->tx_wake_thresh)) {
netif_tx_lock(bp->dev);
if ((netif_queue_stopped(bp->dev)) &&
(bnx2_tx_avail(bp, txr) > bp->tx_wake_thresh))
netif_wake_queue(bp->dev);
netif_tx_unlock(bp->dev);
}
#else
if (unlikely(<API key>(txq)) &&
(bnx2_tx_avail(bp, txr) > bp->tx_wake_thresh)) {
__netif_tx_lock(txq, smp_processor_id());
if ((<API key>(txq)) &&
(bnx2_tx_avail(bp, txr) > bp->tx_wake_thresh))
netif_tx_wake_queue(txq);
__netif_tx_unlock(txq);
}
#endif
return tx_pkt;
}
static void
<API key>(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
struct sk_buff *skb, int count)
{
struct bnx2_sw_pg *cons_rx_pg, *prod_rx_pg;
struct bnx2_rx_bd *cons_bd, *prod_bd;
int i;
u16 hw_prod, prod;
u16 cons = rxr->rx_pg_cons;
cons_rx_pg = &rxr->rx_pg_ring[cons];
/* The caller was unable to allocate a new page to replace the
* last one in the frags array, so we need to recycle that page
* and then free the skb.
*/
if (skb) {
struct page *page;
struct skb_shared_info *shinfo;
shinfo = skb_shinfo(skb);
shinfo->nr_frags
page = skb_frag_page(&shinfo->frags[shinfo->nr_frags]);
__skb_frag_set_page(&shinfo->frags[shinfo->nr_frags], NULL);
cons_rx_pg->page = page;
dev_kfree_skb(skb);
}
hw_prod = rxr->rx_pg_prod;
for (i = 0; i < count; i++) {
prod = BNX2_RX_PG_RING_IDX(hw_prod);
prod_rx_pg = &rxr->rx_pg_ring[prod];
cons_rx_pg = &rxr->rx_pg_ring[cons];
cons_bd = &rxr->rx_pg_desc_ring[BNX2_RX_RING(cons)]
[BNX2_RX_IDX(cons)];
prod_bd = &rxr->rx_pg_desc_ring[BNX2_RX_RING(prod)]
[BNX2_RX_IDX(prod)];
if (prod != cons) {
prod_rx_pg->page = cons_rx_pg->page;
cons_rx_pg->page = NULL;
dma_unmap_addr_set(prod_rx_pg, mapping,
dma_unmap_addr(cons_rx_pg, mapping));
prod_bd->rx_bd_haddr_hi = cons_bd->rx_bd_haddr_hi;
prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo;
}
cons = BNX2_RX_PG_RING_IDX(BNX2_NEXT_RX_BD(cons));
hw_prod = BNX2_NEXT_RX_BD(hw_prod);
}
rxr->rx_pg_prod = hw_prod;
rxr->rx_pg_cons = cons;
}
static inline void
bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
struct sk_buff *skb, u16 cons, u16 prod)
{
struct bnx2_sw_bd *cons_rx_buf, *prod_rx_buf;
struct bnx2_rx_bd *cons_bd, *prod_bd;
cons_rx_buf = &rxr->rx_buf_ring[cons];
prod_rx_buf = &rxr->rx_buf_ring[prod];
#if (LINUX_VERSION_CODE >= 0x02061b)
<API key>(&bp->pdev->dev,
#else
<API key>(bp->pdev,
#endif
dma_unmap_addr(cons_rx_buf, mapping),
BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH, PCI_DMA_FROMDEVICE);
rxr->rx_prod_bseq += bp->rx_buf_use_size;
prod_rx_buf->skb = skb;
prod_rx_buf->desc = (struct l2_fhdr *) skb->data;
if (cons == prod)
return;
dma_unmap_addr_set(prod_rx_buf, mapping,
dma_unmap_addr(cons_rx_buf, mapping));
cons_bd = &rxr->rx_desc_ring[BNX2_RX_RING(cons)][BNX2_RX_IDX(cons)];
prod_bd = &rxr->rx_desc_ring[BNX2_RX_RING(prod)][BNX2_RX_IDX(prod)];
prod_bd->rx_bd_haddr_hi = cons_bd->rx_bd_haddr_hi;
prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo;
}
static int
bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb,
unsigned int len, unsigned int hdr_len, dma_addr_t dma_addr,
u32 ring_idx)
{
int err;
u16 prod = ring_idx & 0xffff;
err = bnx2_alloc_rx_skb(bp, rxr, prod, GFP_ATOMIC);
if (unlikely(err)) {
bnx2_reuse_rx_skb(bp, rxr, skb, (u16) (ring_idx >> 16), prod);
if (hdr_len) {
unsigned int raw_len = len + 4;
int pages = PAGE_ALIGN(raw_len - hdr_len) >> PAGE_SHIFT;
<API key>(bp, rxr, NULL, pages);
}
return err;
}
skb_reserve(skb, BNX2_RX_OFFSET);
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
#else
pci_unmap_single(bp->pdev, dma_addr, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
#endif
if (hdr_len == 0) {
skb_put(skb, len);
return 0;
} else {
unsigned int i, frag_len, frag_size, pages;
struct bnx2_sw_pg *rx_pg;
u16 pg_cons = rxr->rx_pg_cons;
u16 pg_prod = rxr->rx_pg_prod;
frag_size = len + 4 - hdr_len;
pages = PAGE_ALIGN(frag_size) >> PAGE_SHIFT;
skb_put(skb, hdr_len);
for (i = 0; i < pages; i++) {
dma_addr_t mapping_old;
frag_len = min(frag_size, (unsigned int) PAGE_SIZE);
if (unlikely(frag_len <= 4)) {
unsigned int tail = 4 - frag_len;
rxr->rx_pg_cons = pg_cons;
rxr->rx_pg_prod = pg_prod;
<API key>(bp, rxr, NULL,
pages - i);
skb->len -= tail;
if (i == 0) {
skb->tail -= tail;
} else {
skb_frag_t *frag =
&skb_shinfo(skb)->frags[i - 1];
skb_frag_size_sub(frag, tail);
skb->data_len -= tail;
}
return 0;
}
rx_pg = &rxr->rx_pg_ring[pg_cons];
/* Don't unmap yet. If we're unable to allocate a new
* page, we need to recycle the page and the DMA addr.
*/
mapping_old = dma_unmap_addr(rx_pg, mapping);
if (i == pages - 1)
frag_len -= 4;
<API key>(skb, i, rx_pg->page, 0,
frag_len);
rx_pg->page = NULL;
err = bnx2_alloc_rx_page(bp, rxr,
BNX2_RX_PG_RING_IDX(pg_prod),
GFP_ATOMIC);
if (unlikely(err)) {
rxr->rx_pg_cons = pg_cons;
rxr->rx_pg_prod = pg_prod;
<API key>(bp, rxr, skb,
pages - i);
return err;
}
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_page(&bp->pdev->dev, mapping_old,
PAGE_SIZE, PCI_DMA_FROMDEVICE);
#else
pci_unmap_page(bp->pdev, mapping_old,
PAGE_SIZE, PCI_DMA_FROMDEVICE);
#endif
frag_size -= frag_len;
skb->data_len += frag_len;
skb->truesize += PAGE_SIZE;
skb->len += frag_len;
pg_prod = BNX2_NEXT_RX_BD(pg_prod);
pg_cons = BNX2_RX_PG_RING_IDX(BNX2_NEXT_RX_BD(pg_cons));
}
rxr->rx_pg_prod = pg_prod;
rxr->rx_pg_cons = pg_cons;
}
return 0;
}
static inline u16
bnx2_get_hw_rx_cons(struct bnx2_napi *bnapi)
{
u16 cons;
/* Tell compiler that status block fields can change. */
barrier();
cons = *bnapi->hw_rx_cons_ptr;
barrier();
if (unlikely((cons & <API key>) == <API key>))
cons++;
return cons;
}
static int
bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
{
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod;
struct l2_fhdr *rx_hdr;
int rx_pkt = 0, pg_ring_used = 0;
#if defined(<API key>)
int index = (bnapi - bp->bnx2_napi);
#endif
hw_cons = bnx2_get_hw_rx_cons(bnapi);
sw_cons = rxr->rx_cons;
sw_prod = rxr->rx_prod;
/* Memory barrier necessary as speculative reads of the rx
* buffer can be ahead of the index in the status block
*/
rmb();
while (sw_cons != hw_cons) {
unsigned int len, hdr_len;
u32 status;
struct bnx2_sw_bd *rx_buf, *next_rx_buf;
struct sk_buff *skb;
dma_addr_t dma_addr;
u16 vtag = 0;
int hw_vlan __maybe_unused = 0;
u16 next_ring_idx;
sw_ring_cons = BNX2_RX_RING_IDX(sw_cons);
sw_ring_prod = BNX2_RX_RING_IDX(sw_prod);
rx_buf = &rxr->rx_buf_ring[sw_ring_cons];
skb = rx_buf->skb;
prefetchw(skb);
next_ring_idx = BNX2_RX_RING_IDX(BNX2_NEXT_RX_BD(sw_cons));
next_rx_buf = &rxr->rx_buf_ring[next_ring_idx];
prefetch(next_rx_buf->desc);
rx_buf->skb = NULL;
dma_addr = dma_unmap_addr(rx_buf, mapping);
#if (LINUX_VERSION_CODE >= 0x02061b)
<API key>(&bp->pdev->dev, dma_addr,
#else
<API key>(bp->pdev, dma_addr,
#endif
BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH,
PCI_DMA_FROMDEVICE);
rx_hdr = rx_buf->desc;
len = rx_hdr->l2_fhdr_pkt_len;
status = rx_hdr->l2_fhdr_status;
hdr_len = 0;
if (status & <API key>) {
hdr_len = rx_hdr->l2_fhdr_ip_xsum;
pg_ring_used = 1;
} else if (len > bp->rx_jumbo_thresh) {
hdr_len = bp->rx_jumbo_thresh;
pg_ring_used = 1;
}
if (unlikely(status & (<API key> |
<API key> |
<API key> |
<API key> |
<API key>))) {
#if defined(<API key>)
bnapi->stats.rx_errors++;
if (status & <API key>)
bnapi->stats.rx_crc_errors++;
if (status &
(<API key> |
<API key>))
bnapi->stats.rx_frame_errors++;
#endif
bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons,
sw_ring_prod);
if (pg_ring_used) {
int pages;
pages = PAGE_ALIGN(len - hdr_len) >> PAGE_SHIFT;
<API key>(bp, rxr, NULL, pages);
}
goto next_rx;
}
len -= 4;
if (len <= bp->rx_copy_thresh) {
struct sk_buff *new_skb;
new_skb = netdev_alloc_skb(bp->dev, len + 6);
if (new_skb == NULL) {
bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons,
sw_ring_prod);
goto next_rx;
}
/* aligned copy */
#if (LINUX_VERSION_CODE >= 0x20616)
<API key>(skb,
BNX2_RX_OFFSET - 6,
new_skb->data, len + 6);
#else
memcpy(new_skb->data, skb->data + BNX2_RX_OFFSET - 6,
len + 6);
#endif
skb_reserve(new_skb, 6);
skb_put(new_skb, len);
bnx2_reuse_rx_skb(bp, rxr, skb,
sw_ring_cons, sw_ring_prod);
skb = new_skb;
} else if (unlikely(bnx2_rx_skb(bp, rxr, skb, len, hdr_len,
dma_addr, (sw_ring_cons << 16) | sw_ring_prod)))
goto next_rx;
if ((status & <API key>) &&
!(bp->rx_mode & <API key>)) {
vtag = rx_hdr->l2_fhdr_vlan_tag;
#ifdef NEW_VLAN
<API key>(skb, htons(ETH_P_8021Q), vtag);
#else
#ifdef BCM_VLAN
if (bp->vlgrp)
hw_vlan = 1;
else
#endif
{
struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
__skb_push(skb, 4);
bcm_memmove(ve, skb->data + 4, ETH_ALEN * 2);
ve->h_vlan_proto = htons(ETH_P_8021Q);
ve->h_vlan_TCI = htons(vtag);
len += 4;
}
#endif
}
skb->protocol = eth_type_trans(skb, bp->dev);
if ((len > (bp->dev->mtu + ETH_HLEN)) &&
(ntohs(skb->protocol) != 0x8100)) {
dev_kfree_skb(skb);
goto next_rx;
}
skb->ip_summed = CHECKSUM_NONE;
if (bp->rx_csum &&
(status & (<API key> |
<API key>))) {
if (likely((status & (<API key> |
<API key>)) == 0))
skb->ip_summed = <API key>;
}
#ifdef NETIF_F_RXHASH
if ((bp->dev->features & NETIF_F_RXHASH) &&
((status & <API key>) ==
<API key>))
skb->rxhash = rx_hdr->l2_fhdr_hash;
#endif
skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]);
#if defined(<API key>)
<API key>(skb,
<API key>(index));
#endif
#if defined(NETIF_F_GRO) && defined(BNX2_NEW_NAPI)
#if defined(BCM_VLAN) && !defined(NEW_VLAN)
if (hw_vlan)
vlan_gro_receive(&bnapi->napi, bp->vlgrp, vtag, skb);
else
#endif
napi_gro_receive(&bnapi->napi, skb);
#else
#ifdef BCM_VLAN
if (hw_vlan)
<API key>(skb, bp->vlgrp, vtag);
else
#endif
netif_receive_skb(skb);
#endif
#if (LINUX_VERSION_CODE < 0x02061b) || defined(__VMKLNX__)
bp->dev->last_rx = jiffies;
#endif
rx_pkt++;
#if defined(<API key>)
/* Update queue specific stats */
bnapi->stats.rx_packets++;
bnapi->stats.rx_bytes += len;
#endif
next_rx:
sw_cons = BNX2_NEXT_RX_BD(sw_cons);
sw_prod = BNX2_NEXT_RX_BD(sw_prod);
if ((rx_pkt == budget))
break;
/* Refresh hw_cons to see if there is new work */
if (sw_cons == hw_cons) {
hw_cons = bnx2_get_hw_rx_cons(bnapi);
rmb();
}
}
rxr->rx_cons = sw_cons;
rxr->rx_prod = sw_prod;
if (pg_ring_used)
BNX2_WR16(bp, rxr->rx_pg_bidx_addr, rxr->rx_pg_prod);
BNX2_WR16(bp, rxr->rx_bidx_addr, sw_prod);
BNX2_WR(bp, rxr->rx_bseq_addr, rxr->rx_prod_bseq);
mmiowb();
return rx_pkt;
}
#ifdef CONFIG_PCI_MSI
/* MSI ISR - The only difference between this and the INTx ISR
* is that the MSI interrupt is always serviced.
*/
static irqreturn_t
#if (LINUX_VERSION_CODE >= 0x20613) || (defined(__VMKLNX__) && (<API key> >= 40000))
bnx2_msi(int irq, void *dev_instance)
#else
bnx2_msi(int irq, void *dev_instance, struct pt_regs *regs)
#endif
{
struct bnx2_napi *bnapi = dev_instance;
struct bnx2 *bp = bnapi->bp;
prefetch(bnapi->status_blk.msi);
BNX2_WR(bp, <API key>,
#if defined(__VMKLNX__)
bnapi->int_num |
#endif
<API key> |
<API key>);
/* Return here if interrupt is disabled. */
if (unlikely(atomic_read(&bp->intr_sem) != 0))
return IRQ_HANDLED;
#ifdef BNX2_NEW_NAPI
napi_schedule(&bnapi->napi);
#else
netif_rx_schedule(bp->dev);
#endif
return IRQ_HANDLED;
}
static irqreturn_t
#if (LINUX_VERSION_CODE >= 0x20613) || (defined(__VMKLNX__) && (<API key> >= 40000))
bnx2_msi_1shot(int irq, void *dev_instance)
#else
bnx2_msi_1shot(int irq, void *dev_instance, struct pt_regs *regs)
#endif
{
struct bnx2_napi *bnapi = dev_instance;
struct bnx2 *bp = bnapi->bp;
prefetch(bnapi->status_blk.msi);
/* Return here if interrupt is disabled. */
if (unlikely(atomic_read(&bp->intr_sem) != 0))
return IRQ_HANDLED;
#ifdef BNX2_NEW_NAPI
napi_schedule(&bnapi->napi);
#else
netif_rx_schedule(bp->dev);
#endif
return IRQ_HANDLED;
}
#endif
static irqreturn_t
#if (LINUX_VERSION_CODE >= 0x20613) || (defined(__VMKLNX__) && (<API key> >= 40000))
bnx2_interrupt(int irq, void *dev_instance)
#else
bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
#endif
{
struct bnx2_napi *bnapi = dev_instance;
struct bnx2 *bp = bnapi->bp;
struct status_block *sblk = bnapi->status_blk.msi;
/* When using INTx, it is possible for the interrupt to arrive
* at the CPU before the status block posted prior to the
* interrupt. Reading a register will flush the status block.
* When using MSI, the MSI message will always complete after
* the status block write.
*/
if ((sblk->status_idx == bnapi->last_status_idx) &&
(BNX2_RD(bp, <API key>) &
<API key>))
return IRQ_NONE;
BNX2_WR(bp, <API key>,
<API key> |
<API key>);
/* Read back to deassert IRQ immediately to avoid too many
* spurious interrupts.
*/
BNX2_RD(bp, <API key>);
/* Return here if interrupt is shared and is disabled. */
if (unlikely(atomic_read(&bp->intr_sem) != 0))
return IRQ_HANDLED;
#ifdef BNX2_NEW_NAPI
if (napi_schedule_prep(&bnapi->napi)) {
bnapi->last_status_idx = sblk->status_idx;
__napi_schedule(&bnapi->napi);
}
#else
if (<API key>(bp->dev)) {
bnapi->last_status_idx = sblk->status_idx;
__netif_rx_schedule(bp->dev);
}
#endif
return IRQ_HANDLED;
}
static inline int
bnx2_has_fast_work(struct bnx2_napi *bnapi)
{
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
if ((bnx2_get_hw_rx_cons(bnapi) != rxr->rx_cons) ||
(bnx2_get_hw_tx_cons(bnapi) != txr->hw_tx_cons))
return 1;
return 0;
}
#define STATUS_ATTN_EVENTS (<API key> | \
<API key>)
static inline int
bnx2_has_work(struct bnx2_napi *bnapi)
{
struct status_block *sblk = bnapi->status_blk.msi;
if (bnx2_has_fast_work(bnapi))
return 1;
#ifdef BCM_CNIC
if (bnapi->cnic_present && (bnapi->cnic_tag != sblk->status_idx))
return 1;
#endif
if ((sblk->status_attn_bits & STATUS_ATTN_EVENTS) !=
(sblk-><API key> & STATUS_ATTN_EVENTS))
return 1;
return 0;
}
#ifdef CONFIG_PCI_MSI
static void
bnx2_chk_missed_msi(struct bnx2 *bp)
{
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
u32 msi_ctrl;
if (bnx2_has_work(bnapi)) {
msi_ctrl = BNX2_RD(bp, <API key>);
if (!(msi_ctrl & <API key>))
return;
if (bnapi->last_status_idx == bp->idle_chk_status_idx) {
BNX2_WR(bp, <API key>, msi_ctrl &
~<API key>);
BNX2_WR(bp, <API key>, msi_ctrl);
#if (LINUX_VERSION_CODE >= 0x20613) || (defined(__VMKLNX__) && (<API key> >= 40000))
bnx2_msi(bp->irq_tbl[0].vector, bnapi);
#else
bnx2_msi(bp->irq_tbl[0].vector, bnapi, NULL);
#endif
}
}
bp->idle_chk_status_idx = bnapi->last_status_idx;
}
#endif
#ifdef BCM_CNIC
static void bnx2_poll_cnic(struct bnx2 *bp, struct bnx2_napi *bnapi)
{
struct cnic_ops *c_ops;
if (!bnapi->cnic_present)
return;
rcu_read_lock();
c_ops = rcu_dereference(bp->cnic_ops);
if (c_ops)
bnapi->cnic_tag = c_ops->cnic_handler(bp->cnic_data,
bnapi->status_blk.msi);
rcu_read_unlock();
}
#endif
#ifdef BNX2_NEW_NAPI
static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi)
{
struct status_block *sblk = bnapi->status_blk.msi;
u32 status_attn_bits = sblk->status_attn_bits;
u32 <API key> = sblk-><API key>;
if ((status_attn_bits & STATUS_ATTN_EVENTS) !=
(<API key> & STATUS_ATTN_EVENTS)) {
bnx2_phy_int(bp, bnapi);
/* This is needed to take care of transient status
* during link changes.
*/
BNX2_WR(bp, BNX2_HC_COMMAND,
bp->hc_cmd | <API key>);
BNX2_RD(bp, BNX2_HC_COMMAND);
}
}
static int bnx2_poll_work(struct bnx2 *bp, struct bnx2_napi *bnapi,
int work_done, int budget)
{
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
if (bnx2_get_hw_tx_cons(bnapi) != txr->hw_tx_cons)
#if defined(__VMKLNX__)
bnx2_tx_int(bp, bnapi, 0, 1);
#else
bnx2_tx_int(bp, bnapi, 0);
#endif
if (bnx2_get_hw_rx_cons(bnapi) != rxr->rx_cons)
work_done += bnx2_rx_int(bp, bnapi, budget - work_done);
#if defined(__VMKLNX__)
wmb();
#endif
return work_done;
}
static int bnx2_poll_msix(struct napi_struct *napi, int budget)
{
struct bnx2_napi *bnapi = container_of(napi, struct bnx2_napi, napi);
struct bnx2 *bp = bnapi->bp;
int work_done = 0;
struct status_block_msix *sblk = bnapi->status_blk.msix;
while (1) {
work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
if (unlikely(work_done >= budget))
break;
bnapi->last_status_idx = sblk->status_idx;
/* status idx must be read before checking for more work. */
rmb();
if (likely(!bnx2_has_fast_work(bnapi))) {
napi_complete(napi);
BNX2_WR(bp, <API key>, bnapi->int_num |
<API key> |
bnapi->last_status_idx);
break;
}
}
return work_done;
}
static int bnx2_poll(struct napi_struct *napi, int budget)
{
struct bnx2_napi *bnapi = container_of(napi, struct bnx2_napi, napi);
struct bnx2 *bp = bnapi->bp;
int work_done = 0;
struct status_block *sblk = bnapi->status_blk.msi;
while (1) {
bnx2_poll_link(bp, bnapi);
work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
#if defined(<API key>)
if (<API key>(bp) &&
<API key>(bp))
<API key>(bnapi);
#endif
#ifdef BCM_CNIC
bnx2_poll_cnic(bp, bnapi);
#endif
/* bnapi->last_status_idx is used below to tell the hw how
* much work has been processed, so we must read it before
* checking for more work.
*/
bnapi->last_status_idx = sblk->status_idx;
if (unlikely(work_done >= budget))
break;
rmb();
if (likely(!bnx2_has_work(bnapi))) {
napi_complete(napi);
if (likely(bp->flags & <API key>)) {
BNX2_WR(bp, <API key>,
<API key> |
bnapi->last_status_idx);
break;
}
BNX2_WR(bp, <API key>,
<API key> |
<API key> |
bnapi->last_status_idx);
BNX2_WR(bp, <API key>,
<API key> |
bnapi->last_status_idx);
break;
}
}
return work_done;
}
#else
static int
bnx2_poll(struct net_device *dev, int *budget)
{
struct bnx2 *bp = netdev_priv(dev);
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
struct status_block *sblk = bnapi->status_blk.msi;
u32 status_attn_bits = sblk->status_attn_bits;
u32 <API key> = sblk-><API key>;
if ((status_attn_bits & STATUS_ATTN_EVENTS) !=
(<API key> & STATUS_ATTN_EVENTS)) {
bnx2_phy_int(bp, bnapi);
/* This is needed to take care of transient status
* during link changes.
*/
BNX2_WR(bp, BNX2_HC_COMMAND,
bp->hc_cmd | <API key>);
BNX2_RD(bp, BNX2_HC_COMMAND);
}
if (bnx2_get_hw_tx_cons(bnapi) != txr->hw_tx_cons)
#if defined(__VMKLNX__)
bnx2_tx_int(bp, bnapi, 0, 1);
#else
bnx2_tx_int(bp, bnapi, 0);
#endif
if (bnx2_get_hw_rx_cons(bnapi) != rxr->rx_cons) {
int orig_budget = *budget;
int work_done;
if (orig_budget > dev->quota)
orig_budget = dev->quota;
work_done = bnx2_rx_int(bp, bnapi, orig_budget);
*budget -= work_done;
dev->quota -= work_done;
}
#ifdef BCM_CNIC
bnx2_poll_cnic(bp, bnapi);
#endif
bnapi->last_status_idx = sblk->status_idx;
rmb();
if (!bnx2_has_work(bnapi)) {
netif_rx_complete(dev);
if (likely(bp->flags & <API key>)) {
BNX2_WR(bp, <API key>,
<API key> |
bnapi->last_status_idx);
return 0;
}
BNX2_WR(bp, <API key>,
<API key> |
<API key> |
bnapi->last_status_idx);
BNX2_WR(bp, <API key>,
<API key> |
bnapi->last_status_idx);
return 0;
}
return 1;
}
#endif
/* Called with rtnl_lock from vlan functions and also netif_tx_lock
* from set_multicast.
*/
static void
bnx2_set_rx_mode(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
u32 rx_mode, sort_mode;
#ifdef <API key>
#if (LINUX_VERSION_CODE >= 0x2061f)
struct netdev_hw_addr *ha;
#else
struct dev_addr_list *uc_ptr;
#endif
#endif
int i;
if (!netif_running(dev))
return;
spin_lock_bh(&bp->phy_lock);
rx_mode = bp->rx_mode & ~(<API key> |
<API key>);
sort_mode = 1 | <API key>;
#ifdef NEW_VLAN
if (!(dev->features & <API key>) &&
(bp->flags & <API key>))
rx_mode |= <API key>;
#else
#ifdef BCM_VLAN
if (!bp->vlgrp && (bp->flags & <API key>))
rx_mode |= <API key>;
#else
if (bp->flags & <API key>)
rx_mode |= <API key>;
#endif
#endif
if (dev->flags & IFF_PROMISC) {
/* Promiscuous mode. */
rx_mode |= <API key>;
sort_mode |= <API key> |
<API key>;
}
else if (dev->flags & IFF_ALLMULTI) {
for (i = 0; i < <API key>; i++) {
BNX2_WR(bp, <API key> + (i * 4),
0xffffffff);
}
sort_mode |= <API key>;
}
else {
/* Accept one or more multicast(s). */
#ifndef <API key>
struct dev_mc_list *mclist;
#endif
u32 mc_filter[<API key>];
u32 regidx;
u32 bit;
u32 crc;
memset(mc_filter, 0, 4 * <API key>);
#ifdef <API key>
<API key>(ha, dev) {
crc = ether_crc_le(ETH_ALEN, ha->addr);
#else
<API key>(mclist, dev) {
crc = ether_crc_le(ETH_ALEN, mclist->dmi_addr);
#endif
bit = crc & 0xff;
regidx = (bit & 0xe0) >> 5;
bit &= 0x1f;
mc_filter[regidx] |= (1 << bit);
}
for (i = 0; i < <API key>; i++) {
BNX2_WR(bp, <API key> + (i * 4),
mc_filter[i]);
}
sort_mode |= <API key>;
}
#ifdef <API key>
if (netdev_uc_count(dev) > <API key>) {
rx_mode |= <API key>;
sort_mode |= <API key> |
<API key>;
} else if (!(dev->flags & IFF_PROMISC)) {
#if (LINUX_VERSION_CODE < 0x2061f)
uc_ptr = dev->uc_list;
/* Add all entries into to the match filter list */
for (i = 0; i < dev->uc_count; i++) {
bnx2_set_mac_addr(bp, uc_ptr->da_addr,
i + <API key>);
sort_mode |= (1 <<
(i + <API key>));
uc_ptr = uc_ptr->next;
}
#else
i = 0;
<API key>(ha, dev) {
bnx2_set_mac_addr(bp, ha->addr,
i + <API key>);
sort_mode |= (1 <<
(i + <API key>));
i++;
}
#endif
}
#endif
if (rx_mode != bp->rx_mode) {
bp->rx_mode = rx_mode;
BNX2_WR(bp, BNX2_EMAC_RX_MODE, rx_mode);
}
BNX2_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
BNX2_WR(bp, BNX2_RPM_SORT_USER0, sort_mode);
BNX2_WR(bp, BNX2_RPM_SORT_USER0, sort_mode | <API key>);
spin_unlock_bh(&bp->phy_lock);
}
#define FW_BUF_SIZE 0x10000
static int
bnx2_gunzip_init(struct bnx2 *bp)
{
if ((bp->gunzip_buf = vmalloc(FW_BUF_SIZE)) == NULL)
goto gunzip_nomem1;
if ((bp->strm = kmalloc(sizeof(*bp->strm), GFP_KERNEL)) == NULL)
goto gunzip_nomem2;
bp->strm->workspace = kmalloc(<API key>(), GFP_KERNEL);
if (bp->strm->workspace == NULL)
goto gunzip_nomem3;
return 0;
gunzip_nomem3:
kfree(bp->strm);
bp->strm = NULL;
gunzip_nomem2:
vfree(bp->gunzip_buf);
bp->gunzip_buf = NULL;
gunzip_nomem1:
netdev_err(bp->dev, "Cannot allocate firmware buffer for "
"uncompression.\n");
return -ENOMEM;
}
static void
bnx2_gunzip_end(struct bnx2 *bp)
{
kfree(bp->strm->workspace);
kfree(bp->strm);
bp->strm = NULL;
if (bp->gunzip_buf) {
vfree(bp->gunzip_buf);
bp->gunzip_buf = NULL;
}
}
static int
bnx2_gunzip(struct bnx2 *bp, const u8 *zbuf,
int len, void **outbuf, int *outlen)
{
int rc;
bp->strm->next_in = zbuf;
bp->strm->avail_in = len;
bp->strm->next_out = bp->gunzip_buf;
bp->strm->avail_out = FW_BUF_SIZE;
rc = zlib_inflateInit2(bp->strm, -MAX_WBITS);
if (rc != Z_OK)
return rc;
rc = zlib_inflate(bp->strm, Z_FINISH);
*outlen = FW_BUF_SIZE - bp->strm->avail_out;
*outbuf = bp->gunzip_buf;
if ((rc != Z_OK) && (rc != Z_STREAM_END))
netdev_err(bp->dev, "Firmware decompression error: %s\n",
bp->strm->msg);
zlib_inflateEnd(bp->strm);
if (rc == Z_STREAM_END)
return 0;
return rc;
}
#if defined(__VMKLNX__)
struct <API key> {
u32 offset; /* Scratch pad offset to firmware version */
char *name; /* Name of the CPU */
};
#define <API key> 0x10
#define <API key> 0x410
static void
<API key>(struct bnx2 *bp)
{
/* Array of the firmware offset's + CPU strings */
const struct <API key> cpus_scratch[] = {
{ .offset = BNX2_TXP_SCRATCH + <API key>,
.name = "TXP" },
{ .offset = BNX2_TPAT_SCRATCH +
<API key>,
.name = "TPAT" },
{ .offset = BNX2_RXP_SCRATCH + <API key>,
.name = "RXP" },
{ .offset = BNX2_COM_SCRATCH + <API key>,
.name = "COM" },
{ .offset = BNX2_CP_SCRATCH + <API key>,
.name = "CP" },
/* There is no versioning for MCP firmware */
};
int i;
netdev_info(bp->dev, "CPU fw versions: ");
for (i = 0; i < ARRAY_SIZE(cpus_scratch); i++) {
/* The FW versions are 11 bytes long + 1 extra byte for
* the NULL termination */
char version[12];
int j;
/* Copy 4 bytes at a time */
for (j = 0; j < sizeof(version); j += 4) {
u32 val;
val = bnx2_reg_rd_ind(bp, cpus_scratch[i].offset + j);
val = be32_to_cpu(val);
memcpy(&version[j], &val, sizeof(val));
}
/* Force a NULL terminiated string */
version[11] = '\0';
printk("%s: '%s' ", cpus_scratch[i].name, version);
}
printk("\n");
}
#endif
static u32
rv2p_fw_fixup(u32 rv2p_proc, int idx, u32 loc, u32 rv2p_code)
{
switch (idx) {
case <API key>:
rv2p_code &= ~<API key>;
rv2p_code |= RV2P_BD_PAGE_SIZE;
break;
}
return rv2p_code;
}
static void
load_rv2p_fw(struct bnx2 *bp, __le32 *rv2p_code, u32 rv2p_code_len,
u32 rv2p_proc, u32 fixup_loc)
{
__le32 *rv2p_code_start = rv2p_code;
int i;
u32 val, cmd, addr;
if (rv2p_proc == RV2P_PROC1) {
cmd = <API key>;
addr = <API key>;
} else {
cmd = <API key>;
addr = <API key>;
}
for (i = 0; i < rv2p_code_len; i += 8) {
BNX2_WR(bp, <API key>, le32_to_cpu(*rv2p_code));
rv2p_code++;
BNX2_WR(bp, BNX2_RV2P_INSTR_LOW, le32_to_cpu(*rv2p_code));
rv2p_code++;
val = (i / 8) | cmd;
BNX2_WR(bp, addr, val);
}
rv2p_code = rv2p_code_start;
if (fixup_loc && ((fixup_loc * 4) < rv2p_code_len)) {
u32 code;
code = le32_to_cpu(*(rv2p_code + fixup_loc - 1));
BNX2_WR(bp, <API key>, code);
code = le32_to_cpu(*(rv2p_code + fixup_loc));
code = rv2p_fw_fixup(rv2p_proc, 0, fixup_loc, code);
BNX2_WR(bp, BNX2_RV2P_INSTR_LOW, code);
val = (fixup_loc / 2) | cmd;
BNX2_WR(bp, addr, val);
}
/* Reset the processor, un-stall is done later. */
if (rv2p_proc == RV2P_PROC1) {
BNX2_WR(bp, BNX2_RV2P_COMMAND, <API key>);
}
else {
BNX2_WR(bp, BNX2_RV2P_COMMAND, <API key>);
}
}
static int
load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg, struct fw_info *fw)
{
u32 offset;
u32 val;
int rc;
/* Halt the CPU. */
val = bnx2_reg_rd_ind(bp, cpu_reg->mode);
val |= cpu_reg->mode_value_halt;
bnx2_reg_wr_ind(bp, cpu_reg->mode, val);
bnx2_reg_wr_ind(bp, cpu_reg->state, cpu_reg->state_value_clear);
/* Load the Text area. */
offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
if (fw->gz_text) {
u32 text_len;
void *text;
rc = bnx2_gunzip(bp, fw->gz_text, fw->gz_text_len, &text,
&text_len);
if (rc)
return rc;
fw->text = text;
}
if (fw->text) {
int j;
for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
bnx2_reg_wr_ind(bp, offset, le32_to_cpu(fw->text[j]));
}
}
/* Load the Data area. */
offset = cpu_reg->spad_base + (fw->data_addr - cpu_reg->mips_view_base);
if (fw->data) {
int j;
for (j = 0; j < (fw->data_len / 4); j++, offset += 4) {
bnx2_reg_wr_ind(bp, offset, fw->data[j]);
}
}
/* Load the SBSS area. */
offset = cpu_reg->spad_base + (fw->sbss_addr - cpu_reg->mips_view_base);
if (fw->sbss_len) {
int j;
for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) {
bnx2_reg_wr_ind(bp, offset, 0);
}
}
/* Load the BSS area. */
offset = cpu_reg->spad_base + (fw->bss_addr - cpu_reg->mips_view_base);
if (fw->bss_len) {
int j;
for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
bnx2_reg_wr_ind(bp, offset, 0);
}
}
/* Load the Read-Only area. */
offset = cpu_reg->spad_base +
(fw->rodata_addr - cpu_reg->mips_view_base);
if (fw->rodata) {
int j;
for (j = 0; j < (fw->rodata_len / 4); j++, offset += 4) {
bnx2_reg_wr_ind(bp, offset, fw->rodata[j]);
}
}
/* Clear the pre-fetch instruction. */
bnx2_reg_wr_ind(bp, cpu_reg->inst, 0);
bnx2_reg_wr_ind(bp, cpu_reg->pc, fw->start_addr);
/* Start the CPU. */
val = bnx2_reg_rd_ind(bp, cpu_reg->mode);
val &= ~cpu_reg->mode_value_halt;
bnx2_reg_wr_ind(bp, cpu_reg->state, cpu_reg->state_value_clear);
bnx2_reg_wr_ind(bp, cpu_reg->mode, val);
return 0;
}
static int
bnx2_init_cpus(struct bnx2 *bp)
{
struct fw_info *fw;
int rc = 0, rv2p_len;
void *text;
const void *rv2p;
u32 text_len, fixup_loc;
if ((rc = bnx2_gunzip_init(bp)) != 0)
return rc;
/* Initialize the RV2P processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>)) {
rv2p = <API key>;
rv2p_len = sizeof(<API key>);
fixup_loc = <API key>;
} else {
rv2p = bnx2_xi_rv2p_proc1;
rv2p_len = sizeof(bnx2_xi_rv2p_proc1);
fixup_loc = <API key>;
}
} else {
rv2p = bnx2_rv2p_proc1;
rv2p_len = sizeof(bnx2_rv2p_proc1);
fixup_loc = <API key>;
}
rc = bnx2_gunzip(bp, rv2p, rv2p_len, &text, &text_len);
if (rc)
goto init_cpu_err;
load_rv2p_fw(bp, text, text_len, RV2P_PROC1, fixup_loc);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>)) {
rv2p = <API key>;
rv2p_len = sizeof(<API key>);
fixup_loc = <API key>;
} else {
rv2p = bnx2_xi_rv2p_proc2;
rv2p_len = sizeof(bnx2_xi_rv2p_proc2);
fixup_loc = <API key>;
}
} else {
rv2p = bnx2_rv2p_proc2;
rv2p_len = sizeof(bnx2_rv2p_proc2);
fixup_loc = <API key>;
}
rc = bnx2_gunzip(bp, rv2p, rv2p_len, &text, &text_len);
if (rc)
goto init_cpu_err;
load_rv2p_fw(bp, text, text_len, RV2P_PROC2, fixup_loc);
/* Initialize the RX Processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
fw = &bnx2_rxp_fw_09;
else
fw = &bnx2_rxp_fw_06;
rc = load_cpu_fw(bp, &cpu_reg_rxp, fw);
if (rc)
goto init_cpu_err;
/* Initialize the TX Processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
fw = &bnx2_txp_fw_09;
else
fw = &bnx2_txp_fw_06;
rc = load_cpu_fw(bp, &cpu_reg_txp, fw);
if (rc)
goto init_cpu_err;
/* Initialize the TX Patch-up Processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
fw = &bnx2_tpat_fw_09;
else
fw = &bnx2_tpat_fw_06;
rc = load_cpu_fw(bp, &cpu_reg_tpat, fw);
if (rc)
goto init_cpu_err;
/* Initialize the Completion Processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
fw = &bnx2_com_fw_09;
else
fw = &bnx2_com_fw_06;
rc = load_cpu_fw(bp, &cpu_reg_com, fw);
if (rc)
goto init_cpu_err;
/* Initialize the Command Processor. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
fw = &bnx2_cp_fw_09;
else
fw = &bnx2_cp_fw_06;
rc = load_cpu_fw(bp, &cpu_reg_cp, fw);
if (rc)
goto init_cpu_err;
#if defined(__VMKLNX__)
<API key>(bp);
#endif
init_cpu_err:
bnx2_gunzip_end(bp);
return rc;
}
static void
bnx2_setup_wol(struct bnx2 *bp)
{
int i;
u32 val, wol_msg;
if (bp->wol) {
u32 advertising;
u8 autoneg;
autoneg = bp->autoneg;
advertising = bp->advertising;
if (bp->phy_port == PORT_TP) {
bp->autoneg = AUTONEG_SPEED;
bp->advertising = <API key> |
<API key> |
<API key> |
<API key> |
ADVERTISED_Autoneg;
}
spin_lock_bh(&bp->phy_lock);
bnx2_setup_phy(bp, bp->phy_port);
spin_unlock_bh(&bp->phy_lock);
bp->autoneg = autoneg;
bp->advertising = advertising;
bnx2_set_mac_addr(bp, bp->dev->dev_addr, 0);
val = BNX2_RD(bp, BNX2_EMAC_MODE);
/* Enable port mode. */
val &= ~BNX2_EMAC_MODE_PORT;
val |= <API key> |
<API key> |
BNX2_EMAC_MODE_MPKT;
if (bp->phy_port == PORT_TP) {
val |= <API key>;
} else {
val |= <API key>;
if (bp->line_speed == SPEED_2500)
val |= <API key>;
}
BNX2_WR(bp, BNX2_EMAC_MODE, val);
/* receive all multicast */
for (i = 0; i < <API key>; i++) {
BNX2_WR(bp, <API key> + (i * 4),
0xffffffff);
}
BNX2_WR(bp, BNX2_EMAC_RX_MODE, <API key>);
val = 1 | <API key> | <API key>;
BNX2_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
BNX2_WR(bp, BNX2_RPM_SORT_USER0, val);
BNX2_WR(bp, BNX2_RPM_SORT_USER0, val | <API key>);
/* Need to enable EMAC and RPM for WOL. */
BNX2_WR(bp, <API key>,
<API key> |
<API key> |
<API key>);
val = BNX2_RD(bp, BNX2_RPM_CONFIG);
val &= ~<API key>;
BNX2_WR(bp, BNX2_RPM_CONFIG, val);
wol_msg = <API key>;
} else {
wol_msg = <API key>;
}
if (!(bp->flags & BNX2_FLAG_NO_WOL))
bnx2_fw_sync(bp, <API key> | wol_msg, 1, 0);
}
static int
<API key>(struct bnx2 *bp, pci_power_t state)
{
switch (state) {
case PCI_D0: {
u32 val;
pci_enable_wake(bp->pdev, PCI_D0, false);
pci_set_power_state(bp->pdev, PCI_D0);
val = BNX2_RD(bp, BNX2_EMAC_MODE);
val |= <API key> | <API key>;
val &= ~BNX2_EMAC_MODE_MPKT;
BNX2_WR(bp, BNX2_EMAC_MODE, val);
val = BNX2_RD(bp, BNX2_RPM_CONFIG);
val &= ~<API key>;
BNX2_WR(bp, BNX2_RPM_CONFIG, val);
break;
}
case PCI_D3hot: {
bnx2_setup_wol(bp);
pci_wake_from_d3(bp->pdev, bp->wol);
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>)) {
if (bp->wol)
pci_set_power_state(bp->pdev, PCI_D3hot);
} else {
pci_set_power_state(bp->pdev, PCI_D3hot);
}
/* No more memory access after this point until
* device is brought back to D0.
*/
break;
}
default:
return -EINVAL;
}
return 0;
}
static int
<API key>(struct bnx2 *bp)
{
u32 val;
int j;
/* Request access to the flash interface. */
BNX2_WR(bp, BNX2_NVM_SW_ARB, <API key>);
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
val = BNX2_RD(bp, BNX2_NVM_SW_ARB);
if (val & <API key>)
break;
udelay(5);
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
return 0;
}
static int
<API key>(struct bnx2 *bp)
{
int j;
u32 val;
/* Relinquish nvram interface. */
BNX2_WR(bp, BNX2_NVM_SW_ARB, <API key>);
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
val = BNX2_RD(bp, BNX2_NVM_SW_ARB);
if (!(val & <API key>))
break;
udelay(5);
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
return 0;
}
static int
<API key>(struct bnx2 *bp)
{
u32 val;
val = BNX2_RD(bp, BNX2_MISC_CFG);
BNX2_WR(bp, BNX2_MISC_CFG, val | <API key>);
if (bp->flash_info->flags & BNX2_NV_WREN) {
int j;
BNX2_WR(bp, BNX2_NVM_COMMAND, <API key>);
BNX2_WR(bp, BNX2_NVM_COMMAND,
<API key> | <API key>);
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
udelay(5);
val = BNX2_RD(bp, BNX2_NVM_COMMAND);
if (val & <API key>)
break;
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
}
return 0;
}
static void
<API key>(struct bnx2 *bp)
{
u32 val;
val = BNX2_RD(bp, BNX2_MISC_CFG);
BNX2_WR(bp, BNX2_MISC_CFG, val & ~<API key>);
}
static void
<API key>(struct bnx2 *bp)
{
u32 val;
val = BNX2_RD(bp, <API key>);
/* Enable both bits, even on read. */
BNX2_WR(bp, <API key>,
val | <API key> | <API key>);
}
static void
<API key>(struct bnx2 *bp)
{
u32 val;
val = BNX2_RD(bp, <API key>);
/* Disable both bits, even after read. */
BNX2_WR(bp, <API key>,
val & ~(<API key> |
<API key>));
}
static int
<API key>(struct bnx2 *bp, u32 offset)
{
u32 cmd;
int j;
if (bp->flash_info->flags & BNX2_NV_BUFFERED)
/* Buffered flash, no erase needed */
return 0;
/* Build an erase command */
cmd = <API key> | BNX2_NVM_COMMAND_WR |
<API key>;
/* Need to clear DONE bit separately. */
BNX2_WR(bp, BNX2_NVM_COMMAND, <API key>);
/* Address of the NVRAM to read from. */
BNX2_WR(bp, BNX2_NVM_ADDR, offset & <API key>);
/* Issue an erase command. */
BNX2_WR(bp, BNX2_NVM_COMMAND, cmd);
/* Wait for completion. */
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
u32 val;
udelay(5);
val = BNX2_RD(bp, BNX2_NVM_COMMAND);
if (val & <API key>)
break;
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
return 0;
}
static int
<API key>(struct bnx2 *bp, u32 offset, u8 *ret_val, u32 cmd_flags)
{
u32 cmd;
int j;
/* Build the command word. */
cmd = <API key> | cmd_flags;
/* Calculate an offset of a buffered flash, not needed for 5709. */
if (bp->flash_info->flags & BNX2_NV_TRANSLATE) {
offset = ((offset / bp->flash_info->page_size) <<
bp->flash_info->page_bits) +
(offset % bp->flash_info->page_size);
}
/* Need to clear DONE bit separately. */
BNX2_WR(bp, BNX2_NVM_COMMAND, <API key>);
/* Address of the NVRAM to read from. */
BNX2_WR(bp, BNX2_NVM_ADDR, offset & <API key>);
/* Issue a read command. */
BNX2_WR(bp, BNX2_NVM_COMMAND, cmd);
/* Wait for completion. */
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
u32 val;
udelay(5);
val = BNX2_RD(bp, BNX2_NVM_COMMAND);
if (val & <API key>) {
__be32 v = cpu_to_be32(BNX2_RD(bp, BNX2_NVM_READ));
memcpy(ret_val, &v, 4);
break;
}
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
return 0;
}
static int
<API key>(struct bnx2 *bp, u32 offset, u8 *val, u32 cmd_flags)
{
u32 cmd;
__be32 val32;
int j;
/* Build the command word. */
cmd = <API key> | BNX2_NVM_COMMAND_WR | cmd_flags;
/* Calculate an offset of a buffered flash, not needed for 5709. */
if (bp->flash_info->flags & BNX2_NV_TRANSLATE) {
offset = ((offset / bp->flash_info->page_size) <<
bp->flash_info->page_bits) +
(offset % bp->flash_info->page_size);
}
/* Need to clear DONE bit separately. */
BNX2_WR(bp, BNX2_NVM_COMMAND, <API key>);
memcpy(&val32, val, 4);
/* Write the data. */
BNX2_WR(bp, BNX2_NVM_WRITE, be32_to_cpu(val32));
/* Address of the NVRAM to write to. */
BNX2_WR(bp, BNX2_NVM_ADDR, offset & <API key>);
/* Issue the write command. */
BNX2_WR(bp, BNX2_NVM_COMMAND, cmd);
/* Wait for completion. */
for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
udelay(5);
if (BNX2_RD(bp, BNX2_NVM_COMMAND) & <API key>)
break;
}
if (j >= NVRAM_TIMEOUT_COUNT)
return -EBUSY;
return 0;
}
static int
bnx2_init_nvram(struct bnx2 *bp)
{
u32 val;
int j, entry_count, rc = 0;
const struct flash_spec *flash;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
bp->flash_info = &flash_5709;
goto get_flash_size;
}
/* Determine the selected interface. */
val = BNX2_RD(bp, BNX2_NVM_CFG1);
entry_count = ARRAY_SIZE(flash_table);
if (val & 0x40000000) {
/* Flash interface has been reconfigured */
for (j = 0, flash = &flash_table[0]; j < entry_count;
j++, flash++) {
if ((val & <API key>) ==
(flash->config1 & <API key>)) {
bp->flash_info = flash;
break;
}
}
}
else {
u32 mask;
/* Not yet been reconfigured */
if (val & (1 << 23))
mask = <API key>;
else
mask = FLASH_STRAP_MASK;
for (j = 0, flash = &flash_table[0]; j < entry_count;
j++, flash++) {
if ((val & mask) == (flash->strapping & mask)) {
bp->flash_info = flash;
/* Request access to the flash interface. */
if ((rc = <API key>(bp)) != 0)
return rc;
/* Enable access to flash interface */
<API key>(bp);
/* Reconfigure the flash interface */
BNX2_WR(bp, BNX2_NVM_CFG1, flash->config1);
BNX2_WR(bp, BNX2_NVM_CFG2, flash->config2);
BNX2_WR(bp, BNX2_NVM_CFG3, flash->config3);
BNX2_WR(bp, BNX2_NVM_WRITE1, flash->write1);
/* Disable access to flash interface */
<API key>(bp);
<API key>(bp);
break;
}
}
} /* if (val & 0x40000000) */
if (j == entry_count) {
bp->flash_info = NULL;
pr_alert("Unknown flash/EEPROM type\n");
return -ENODEV;
}
get_flash_size:
val = bnx2_shmem_rd(bp, <API key>);
val &= <API key>;
if (val)
bp->flash_size = val;
else
bp->flash_size = bp->flash_info->total_size;
return rc;
}
static int
bnx2_nvram_read(struct bnx2 *bp, u32 offset, u8 *ret_buf,
int buf_size)
{
int rc = 0;
u32 cmd_flags, offset32, len32, extra;
if (buf_size == 0)
return 0;
/* Request access to the flash interface. */
if ((rc = <API key>(bp)) != 0)
return rc;
/* Enable access to flash interface */
<API key>(bp);
len32 = buf_size;
offset32 = offset;
extra = 0;
cmd_flags = 0;
if (offset32 & 3) {
u8 buf[4];
u32 pre_len;
offset32 &= ~3;
pre_len = 4 - (offset & 3);
if (pre_len >= len32) {
pre_len = len32;
cmd_flags = <API key> |
<API key>;
}
else {
cmd_flags = <API key>;
}
rc = <API key>(bp, offset32, buf, cmd_flags);
if (rc)
return rc;
memcpy(ret_buf, buf + (offset & 3), pre_len);
offset32 += 4;
ret_buf += pre_len;
len32 -= pre_len;
}
if (len32 & 3) {
extra = 4 - (len32 & 3);
len32 = (len32 + 4) & ~3;
}
if (len32 == 4) {
u8 buf[4];
if (cmd_flags)
cmd_flags = <API key>;
else
cmd_flags = <API key> |
<API key>;
rc = <API key>(bp, offset32, buf, cmd_flags);
memcpy(ret_buf, buf, 4 - extra);
}
else if (len32 > 0) {
u8 buf[4];
/* Read the first word. */
if (cmd_flags)
cmd_flags = 0;
else
cmd_flags = <API key>;
rc = <API key>(bp, offset32, ret_buf, cmd_flags);
/* Advance to the next dword. */
offset32 += 4;
ret_buf += 4;
len32 -= 4;
while (len32 > 4 && rc == 0) {
rc = <API key>(bp, offset32, ret_buf, 0);
/* Advance to the next dword. */
offset32 += 4;
ret_buf += 4;
len32 -= 4;
}
if (rc)
return rc;
cmd_flags = <API key>;
rc = <API key>(bp, offset32, buf, cmd_flags);
memcpy(ret_buf, buf, 4 - extra);
}
/* Disable access to flash interface */
<API key>(bp);
<API key>(bp);
return rc;
}
static int
bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
int buf_size)
{
u32 written, offset32, len32;
u8 *buf, start[4], end[4], *align_buf = NULL, *flash_buffer = NULL;
int rc = 0;
int align_start, align_end;
buf = data_buf;
offset32 = offset;
len32 = buf_size;
align_start = align_end = 0;
if ((align_start = (offset32 & 3))) {
offset32 &= ~3;
len32 += align_start;
if (len32 < 4)
len32 = 4;
if ((rc = bnx2_nvram_read(bp, offset32, start, 4)))
return rc;
}
if (len32 & 3) {
align_end = 4 - (len32 & 3);
len32 += align_end;
if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4, end, 4)))
return rc;
}
if (align_start || align_end) {
align_buf = kmalloc(len32, GFP_KERNEL);
if (align_buf == NULL)
return -ENOMEM;
if (align_start) {
memcpy(align_buf, start, 4);
}
if (align_end) {
memcpy(align_buf + len32 - 4, end, 4);
}
memcpy(align_buf + align_start, data_buf, buf_size);
buf = align_buf;
}
if (!(bp->flash_info->flags & BNX2_NV_BUFFERED)) {
flash_buffer = kmalloc(264, GFP_KERNEL);
if (flash_buffer == NULL) {
rc = -ENOMEM;
goto nvram_write_end;
}
}
written = 0;
while ((written < len32) && (rc == 0)) {
u32 page_start, page_end, data_start, data_end;
u32 addr, cmd_flags;
int i;
/* Find the page_start addr */
page_start = offset32 + written;
page_start -= (page_start % bp->flash_info->page_size);
/* Find the page_end addr */
page_end = page_start + bp->flash_info->page_size;
/* Find the data_start addr */
data_start = (written == 0) ? offset32 : page_start;
/* Find the data_end addr */
data_end = (page_end > offset32 + len32) ?
(offset32 + len32) : page_end;
/* Request access to the flash interface. */
if ((rc = <API key>(bp)) != 0)
goto nvram_write_end;
/* Enable access to flash interface */
<API key>(bp);
cmd_flags = <API key>;
if (!(bp->flash_info->flags & BNX2_NV_BUFFERED)) {
int j;
/* Read the whole page into the buffer
* (non-buffer flash only) */
for (j = 0; j < bp->flash_info->page_size; j += 4) {
if (j == (bp->flash_info->page_size - 4)) {
cmd_flags |= <API key>;
}
rc = <API key>(bp,
page_start + j,
&flash_buffer[j],
cmd_flags);
if (rc)
goto nvram_write_end;
cmd_flags = 0;
}
}
/* Enable writes to flash interface (unlock write-protect) */
if ((rc = <API key>(bp)) != 0)
goto nvram_write_end;
/* Loop to write back the buffer data from page_start to
* data_start */
i = 0;
if (!(bp->flash_info->flags & BNX2_NV_BUFFERED)) {
/* Erase the page */
if ((rc = <API key>(bp, page_start)) != 0)
goto nvram_write_end;
/* Re-enable the write again for the actual write */
<API key>(bp);
for (addr = page_start; addr < data_start;
addr += 4, i += 4) {
rc = <API key>(bp, addr,
&flash_buffer[i], cmd_flags);
if (rc != 0)
goto nvram_write_end;
cmd_flags = 0;
}
}
/* Loop to write the new data from data_start to data_end */
for (addr = data_start; addr < data_end; addr += 4, i += 4) {
if ((addr == page_end - 4) ||
((bp->flash_info->flags & BNX2_NV_BUFFERED) &&
(addr == data_end - 4))) {
cmd_flags |= <API key>;
}
rc = <API key>(bp, addr, buf,
cmd_flags);
if (rc != 0)
goto nvram_write_end;
cmd_flags = 0;
buf += 4;
}
/* Loop to write back the buffer data from data_end
* to page_end */
if (!(bp->flash_info->flags & BNX2_NV_BUFFERED)) {
for (addr = data_end; addr < page_end;
addr += 4, i += 4) {
if (addr == page_end-4) {
cmd_flags = <API key>;
}
rc = <API key>(bp, addr,
&flash_buffer[i], cmd_flags);
if (rc != 0)
goto nvram_write_end;
cmd_flags = 0;
}
}
/* Disable writes to flash interface (lock write-protect) */
<API key>(bp);
/* Disable access to flash interface */
<API key>(bp);
<API key>(bp);
/* Increment written */
written += data_end - data_start;
}
nvram_write_end:
kfree(flash_buffer);
kfree(align_buf);
return rc;
}
static void
bnx2_init_fw_cap(struct bnx2 *bp)
{
u32 val, sig = 0;
bp->phy_flags &= ~<API key>;
bp->flags &= ~<API key>;
if (!(bp->flags & <API key>))
bp->flags |= <API key>;
val = bnx2_shmem_rd(bp, BNX2_FW_CAP_MB);
if ((val & <API key>) != <API key>)
return;
if ((val & <API key>) == <API key>) {
bp->flags |= <API key>;
sig |= <API key> | <API key>;
}
if ((bp->phy_flags & <API key>) &&
(val & <API key>)) {
u32 link;
bp->phy_flags |= <API key>;
link = bnx2_shmem_rd(bp, BNX2_LINK_STATUS);
if (link & <API key>)
bp->phy_port = PORT_FIBRE;
else
bp->phy_port = PORT_TP;
sig |= <API key> |
<API key>;
}
if (netif_running(bp->dev) && sig)
bnx2_shmem_wr(bp, BNX2_DRV_ACK_CAP_MB, sig);
}
#if defined(__VMKLNX__)
static void
<API key>(struct bnx2 *bp)
{
bnx2_reg_wr_ind_cfg(bp, <API key>,
<API key>);
bnx2_reg_wr_ind_cfg(bp, <API key>,
<API key>);
bnx2_reg_wr_ind_cfg(bp, <API key>, BNX2_MSIX_PBA_ADDR);
}
#endif /* defined(__VMKLNX__) */
static void
bnx2_setup_msix_tbl(struct bnx2 *bp)
{
BNX2_WR(bp, <API key>, <API key>);
BNX2_WR(bp, <API key>, <API key>);
BNX2_WR(bp, <API key>, BNX2_MSIX_PBA_ADDR);
}
static int
bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
{
u32 val;
int i, rc = 0;
u8 old_port;
/* Wait for the current PCI transaction to complete before
* issuing a reset. */
if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) ||
(BNX2_CHIP(bp) == BNX2_CHIP_5708)) {
BNX2_WR(bp, <API key>,
<API key> |
<API key> |
<API key> |
<API key>);
val = BNX2_RD(bp, <API key>);
udelay(5);
} else { /* 5709 */
val = BNX2_RD(bp, <API key>);
val &= ~<API key>;
BNX2_WR(bp, <API key>, val);
val = BNX2_RD(bp, <API key>);
for (i = 0; i < 100; i++) {
bnx2_msleep(1);
val = BNX2_RD(bp, <API key>);
if (!(val & <API key>))
break;
}
}
/* Wait for the firmware to tell us it is ok to issue a reset. */
bnx2_fw_sync(bp, <API key> | reset_code, 1, 1);
/* Deposit a driver reset signature so the firmware knows that
* this is a soft reset. */
bnx2_shmem_wr(bp, <API key>,
<API key>);
#if defined(__VMKLNX__)
#if (LINUX_VERSION_CODE >= 0x020611)
pci_save_state(bp->pdev);
#endif
#endif /* defined(__VMKLNX__) */
/* Do a dummy read to force the chip to complete all current transaction
* before we issue a reset. */
val = BNX2_RD(bp, BNX2_MISC_ID);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
BNX2_WR(bp, BNX2_MISC_COMMAND, <API key>);
BNX2_RD(bp, BNX2_MISC_COMMAND);
udelay(5);
val = <API key> |
<API key>;
BNX2_WR(bp, <API key>, val);
} else {
val = <API key> |
<API key> |
<API key>;
/* Chip reset. */
BNX2_WR(bp, <API key>, val);
/* Reading back any register after chip reset will hang the
* bus on 5706 A0 and A1. The msleep below provides plenty
* of margin for write posting.
*/
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>))
bnx2_msleep(20);
/* Reset takes approximate 30 usec */
for (i = 0; i < 10; i++) {
val = BNX2_RD(bp, <API key>);
if ((val & (<API key> |
<API key>)) == 0)
break;
udelay(10);
}
if (val & (<API key> |
<API key>)) {
pr_err("Chip reset did not complete\n");
return -EBUSY;
}
}
#if defined(__VMKLNX__)
if (bp->flags & <API key>)
<API key>(bp);
#if (LINUX_VERSION_CODE >= 0x020611)
pci_restore_state(bp->pdev);
#endif
#endif /* defined(__VMKLNX__) */
/* Make sure byte swapping is properly configured. */
val = BNX2_RD(bp, BNX2_PCI_SWAP_DIAG0);
if (val != 0x01020304) {
pr_err("Chip not in correct endian mode\n");
return -ENODEV;
}
/* Wait for the firmware to finish its initialization. */
rc = bnx2_fw_sync(bp, <API key> | reset_code, 1, 0);
if (rc)
return rc;
spin_lock_bh(&bp->phy_lock);
old_port = bp->phy_port;
bnx2_init_fw_cap(bp);
if ((bp->phy_flags & <API key>) &&
old_port != bp->phy_port)
<API key>(bp);
spin_unlock_bh(&bp->phy_lock);
if (BNX2_CHIP_ID(bp) == <API key>) {
/* Adjust the voltage regular to two steps lower. The default
* of this register is 0x0000000e. */
BNX2_WR(bp, <API key>, 0x000000fa);
/* Remove bad rbuf memory from the free pool. */
rc = bnx2_alloc_bad_rbuf(bp);
}
if (bp->flags & <API key>) {
bnx2_setup_msix_tbl(bp);
/* Prevent MSIX table reads and write from timing out */
BNX2_WR(bp, <API key>,
<API key>);
}
return rc;
}
static int
bnx2_init_chip(struct bnx2 *bp)
{
u32 val, mtu;
int rc, i;
/* Make sure the interrupt is not active. */
BNX2_WR(bp, <API key>, <API key>);
val = <API key> |
<API key> |
#ifdef __BIG_ENDIAN
<API key> |
#endif
<API key> |
DMA_READ_CHANS << 12 |
DMA_WRITE_CHANS << 16;
val |= (0x2 << 20) | (1 << 11);
if ((bp->flags & BNX2_FLAG_PCIX) && (bp->bus_speed_mhz == 133))
val |= (1 << 23);
if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) &&
(BNX2_CHIP_ID(bp) != <API key>) &&
!(bp->flags & BNX2_FLAG_PCIX))
val |= <API key>;
BNX2_WR(bp, BNX2_DMA_CONFIG, val);
if (BNX2_CHIP_ID(bp) == <API key>) {
val = BNX2_RD(bp, BNX2_TDMA_CONFIG);
val |= <API key>;
BNX2_WR(bp, BNX2_TDMA_CONFIG, val);
}
if (bp->flags & BNX2_FLAG_PCIX) {
u16 val16;
<API key>(bp->pdev, bp->pcix_cap + PCI_X_CMD,
&val16);
<API key>(bp->pdev, bp->pcix_cap + PCI_X_CMD,
val16 & ~PCI_X_CMD_ERO);
}
BNX2_WR(bp, <API key>,
<API key> |
<API key> |
<API key>);
/* Initialize context mapping and zero out the quick contexts. The
* context block must have already been enabled. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
rc = <API key>(bp);
if (rc)
return rc;
} else
bnx2_init_context(bp);
if ((rc = bnx2_init_cpus(bp)) != 0)
return rc;
bnx2_init_nvram(bp);
bnx2_set_mac_addr(bp, bp->dev->dev_addr, 0);
val = BNX2_RD(bp, BNX2_MQ_CONFIG);
val &= ~<API key>;
val |= <API key>;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
val |= <API key>;
if (BNX2_CHIP_REV(bp) == BNX2_CHIP_REV_Ax)
val |= <API key>;
}
BNX2_WR(bp, BNX2_MQ_CONFIG, val);
val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE);
BNX2_WR(bp, <API key>, val);
BNX2_WR(bp, <API key>, val);
val = (BNX2_PAGE_BITS - 8) << 24;
BNX2_WR(bp, BNX2_RV2P_CONFIG, val);
/* Configure page size. */
val = BNX2_RD(bp, BNX2_TBDR_CONFIG);
val &= ~<API key>;
val |= (BNX2_PAGE_BITS - 8) << 24 | 0x40;
BNX2_WR(bp, BNX2_TBDR_CONFIG, val);
val = bp->mac_addr[0] +
(bp->mac_addr[1] << 8) +
(bp->mac_addr[2] << 16) +
bp->mac_addr[3] +
(bp->mac_addr[4] << 8) +
(bp->mac_addr[5] << 16);
BNX2_WR(bp, <API key>, val);
/* Program the MTU. Also include 4 bytes for CRC32. */
mtu = bp->dev->mtu;
val = mtu + ETH_HLEN + ETH_FCS_LEN;
if (val > (<API key> + 4))
val |= <API key>;
BNX2_WR(bp, <API key>, val);
if (mtu < 1500)
mtu = 1500;
bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG, <API key>(mtu));
bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG2, <API key>(mtu));
bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG3, <API key>(mtu));
memset(bp->bnx2_napi[0].status_blk.msi, 0, bp->status_stats_size);
for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
bp->bnx2_napi[i].last_status_idx = 0;
bp->idle_chk_status_idx = 0xffff;
bp->rx_mode = <API key>;
/* Set up how to generate a link change interrupt. */
BNX2_WR(bp, <API key>, <API key>);
BNX2_WR(bp, <API key>,
(u64) bp->status_blk_mapping & 0xffffffff);
BNX2_WR(bp, <API key>, (u64) bp->status_blk_mapping >> 32);
BNX2_WR(bp, <API key>,
(u64) bp->stats_blk_mapping & 0xffffffff);
BNX2_WR(bp, <API key>,
(u64) bp->stats_blk_mapping >> 32);
BNX2_WR(bp, <API key>,
(bp-><API key> << 16) | bp->tx_quick_cons_trip);
BNX2_WR(bp, <API key>,
(bp-><API key> << 16) | bp->rx_quick_cons_trip);
BNX2_WR(bp, <API key>,
(bp->comp_prod_trip_int << 16) | bp->comp_prod_trip);
BNX2_WR(bp, BNX2_HC_TX_TICKS, (bp->tx_ticks_int << 16) | bp->tx_ticks);
BNX2_WR(bp, BNX2_HC_RX_TICKS, (bp->rx_ticks_int << 16) | bp->rx_ticks);
BNX2_WR(bp, BNX2_HC_COM_TICKS,
(bp->com_ticks_int << 16) | bp->com_ticks);
BNX2_WR(bp, BNX2_HC_CMD_TICKS,
(bp->cmd_ticks_int << 16) | bp->cmd_ticks);
if (bp->flags & <API key>)
BNX2_WR(bp, BNX2_HC_STATS_TICKS, 0);
else
BNX2_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks);
BNX2_WR(bp, <API key>, 0xbb8); /* 3ms */
if (BNX2_CHIP_ID(bp) == <API key>)
val = <API key>;
else {
val = <API key> | <API key> |
<API key>;
}
if (bp->flags & <API key>) {
BNX2_WR(bp, <API key>,
<API key>);
val |= <API key>;
}
if (bp->flags & <API key>)
val |= <API key> | <API key>;
BNX2_WR(bp, BNX2_HC_CONFIG, val);
if (bp->rx_ticks < 25)
bnx2_reg_wr_ind(bp, <API key>, 1);
else
bnx2_reg_wr_ind(bp, <API key>, 0);
for (i = 1; i < bp->irq_nvecs; i++) {
u32 base = ((i - 1) * <API key>) +
BNX2_HC_SB_CONFIG_1;
BNX2_WR(bp, base,
<API key> |
<API key> |
<API key>);
BNX2_WR(bp, base + <API key>,
(bp-><API key> << 16) |
bp->tx_quick_cons_trip);
BNX2_WR(bp, base + <API key>,
(bp->tx_ticks_int << 16) | bp->tx_ticks);
BNX2_WR(bp, base + <API key>,
(bp-><API key> << 16) |
bp->rx_quick_cons_trip);
BNX2_WR(bp, base + <API key>,
(bp->rx_ticks_int << 16) | bp->rx_ticks);
}
/* Clear internal stats counters. */
BNX2_WR(bp, BNX2_HC_COMMAND, <API key>);
BNX2_WR(bp, <API key>, STATUS_ATTN_EVENTS);
/* Initialize the receive filter. */
bnx2_set_rx_mode(bp->dev);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
val = BNX2_RD(bp, <API key>);
val |= <API key>;
BNX2_WR(bp, <API key>, val);
}
rc = bnx2_fw_sync(bp, <API key> | <API key>,
1, 0);
BNX2_WR(bp, <API key>, <API key>);
BNX2_RD(bp, <API key>);
udelay(20);
bp->hc_cmd = BNX2_RD(bp, BNX2_HC_COMMAND);
return rc;
}
static void
<API key>(struct bnx2 *bp)
{
struct bnx2_napi *bnapi;
struct bnx2_tx_ring_info *txr;
struct bnx2_rx_ring_info *rxr;
int i;
for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
bnapi = &bp->bnx2_napi[i];
txr = &bnapi->tx_ring;
rxr = &bnapi->rx_ring;
txr->tx_cons = 0;
txr->hw_tx_cons = 0;
rxr->rx_prod_bseq = 0;
rxr->rx_prod = 0;
rxr->rx_cons = 0;
rxr->rx_pg_prod = 0;
rxr->rx_pg_cons = 0;
}
}
static void
<API key>(struct bnx2 *bp, u32 cid, struct bnx2_tx_ring_info *txr)
{
u32 val, offset0, offset1, offset2, offset3;
u32 cid_addr = GET_CID_ADDR(cid);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
offset0 = BNX2_L2CTX_TYPE_XI;
offset1 = <API key>;
offset2 = <API key>;
offset3 = <API key>;
} else {
offset0 = BNX2_L2CTX_TYPE;
offset1 = BNX2_L2CTX_CMD_TYPE;
offset2 = <API key>;
offset3 = <API key>;
}
val = <API key> | <API key>;
bnx2_ctx_wr(bp, cid_addr, offset0, val);
val = <API key> | (8 << 16);
bnx2_ctx_wr(bp, cid_addr, offset1, val);
val = (u64) txr->tx_desc_mapping >> 32;
bnx2_ctx_wr(bp, cid_addr, offset2, val);
val = (u64) txr->tx_desc_mapping & 0xffffffff;
bnx2_ctx_wr(bp, cid_addr, offset3, val);
}
static void
bnx2_init_tx_ring(struct bnx2 *bp, int ring_num)
{
struct bnx2_tx_bd *txbd;
u32 cid = TX_CID;
struct bnx2_napi *bnapi;
struct bnx2_tx_ring_info *txr;
bnapi = &bp->bnx2_napi[ring_num];
txr = &bnapi->tx_ring;
if (ring_num == 0)
cid = TX_CID;
else
cid = TX_TSS_CID + ring_num - 1;
bp->tx_wake_thresh = bp->tx_ring_size / 2;
txbd = &txr->tx_desc_ring[<API key>];
txbd->tx_bd_haddr_hi = (u64) txr->tx_desc_mapping >> 32;
txbd->tx_bd_haddr_lo = (u64) txr->tx_desc_mapping & 0xffffffff;
txr->tx_prod = 0;
txr->tx_prod_bseq = 0;
txr->tx_bidx_addr = MB_GET_CID_ADDR(cid) + <API key>;
txr->tx_bseq_addr = MB_GET_CID_ADDR(cid) + <API key>;
<API key>(bp, cid, txr);
}
static void
<API key>(struct bnx2_rx_bd *rx_ring[], dma_addr_t dma[],
u32 buf_size, int num_rings)
{
int i;
struct bnx2_rx_bd *rxbd;
for (i = 0; i < num_rings; i++) {
int j;
rxbd = &rx_ring[i][0];
for (j = 0; j < <API key>; j++, rxbd++) {
rxbd->rx_bd_len = buf_size;
rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END;
}
if (i == (num_rings - 1))
j = 0;
else
j = i + 1;
rxbd->rx_bd_haddr_hi = (u64) dma[j] >> 32;
rxbd->rx_bd_haddr_lo = (u64) dma[j] & 0xffffffff;
}
}
static void
bnx2_init_rx_ring(struct bnx2 *bp, int ring_num)
{
int i;
u16 prod, ring_prod;
u32 cid, rx_cid_addr, val;
struct bnx2_napi *bnapi = &bp->bnx2_napi[ring_num];
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
if (ring_num == 0)
cid = RX_CID;
else
cid = RX_RSS_CID + ring_num - 1;
rx_cid_addr = GET_CID_ADDR(cid);
<API key>(rxr->rx_desc_ring, rxr->rx_desc_mapping,
bp->rx_buf_use_size, bp->rx_max_ring);
<API key>(bp, cid);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
val = BNX2_RD(bp, BNX2_MQ_MAP_L2_5);
BNX2_WR(bp, BNX2_MQ_MAP_L2_5, val | <API key>);
#if defined(<API key>)
/* Set in the RX context the proper CID location
* for the completion
*/
if(<API key>(bp))
bnx2_ctx_wr(bp, rx_cid_addr, 0x04, 1 << 16);
#endif
}
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, 0);
if (bp->rx_pg_ring_size) {
<API key>(rxr->rx_pg_desc_ring,
rxr->rx_pg_desc_mapping,
PAGE_SIZE, bp->rx_max_pg_ring);
val = (bp->rx_buf_use_size << 16) | PAGE_SIZE;
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, val);
bnx2_ctx_wr(bp, rx_cid_addr, BNX2_L2CTX_RBDC_KEY,
<API key> - ring_num);
val = (u64) rxr->rx_pg_desc_mapping[0] >> 32;
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, val);
val = (u64) rxr->rx_pg_desc_mapping[0] & 0xffffffff;
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, val);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
BNX2_WR(bp, BNX2_MQ_MAP_L2_3, <API key>);
}
val = (u64) rxr->rx_desc_mapping[0] >> 32;
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, val);
val = (u64) rxr->rx_desc_mapping[0] & 0xffffffff;
bnx2_ctx_wr(bp, rx_cid_addr, <API key>, val);
ring_prod = prod = rxr->rx_pg_prod;
for (i = 0; i < bp->rx_pg_ring_size; i++) {
if (bnx2_alloc_rx_page(bp, rxr, ring_prod, GFP_KERNEL) < 0) {
netdev_warn(bp->dev, "init'ed rx page ring %d with %d/%d pages only\n",
ring_num, i, bp->rx_pg_ring_size);
break;
}
prod = BNX2_NEXT_RX_BD(prod);
ring_prod = BNX2_RX_PG_RING_IDX(prod);
}
rxr->rx_pg_prod = prod;
ring_prod = prod = rxr->rx_prod;
for (i = 0; i < bp->rx_ring_size; i++) {
if (bnx2_alloc_rx_skb(bp, rxr, ring_prod, GFP_KERNEL) < 0) {
netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d skbs only\n",
ring_num, i, bp->rx_ring_size);
break;
}
prod = BNX2_NEXT_RX_BD(prod);
ring_prod = BNX2_RX_RING_IDX(prod);
}
rxr->rx_prod = prod;
rxr->rx_bidx_addr = MB_GET_CID_ADDR(cid) + <API key>;
rxr->rx_bseq_addr = MB_GET_CID_ADDR(cid) + <API key>;
rxr->rx_pg_bidx_addr = MB_GET_CID_ADDR(cid) + <API key>;
BNX2_WR16(bp, rxr->rx_pg_bidx_addr, rxr->rx_pg_prod);
BNX2_WR16(bp, rxr->rx_bidx_addr, prod);
BNX2_WR(bp, rxr->rx_bseq_addr, rxr->rx_prod_bseq);
}
static void
bnx2_init_all_rings(struct bnx2 *bp)
{
int i;
#if !defined(<API key>)
u32 val;
#endif
<API key>(bp);
BNX2_WR(bp, BNX2_TSCH_TSS_CFG, 0);
for (i = 0; i < bp->num_tx_rings; i++)
bnx2_init_tx_ring(bp, i);
if (bp->num_tx_rings > 1)
BNX2_WR(bp, BNX2_TSCH_TSS_CFG, ((bp->num_tx_rings - 1) << 24) |
(TX_TSS_CID << 7));
BNX2_WR(bp, <API key>, 0);
bnx2_reg_wr_ind(bp, <API key>, 0);
for (i = 0; i < bp->num_rx_rings; i++)
bnx2_init_rx_ring(bp, i);
#if !defined(<API key>)
if (bp->num_rx_rings > 1) {
u32 tbl_32 = 0;
for (i = 0; i < <API key>; i++) {
int shift = (i % 8) << 2;
tbl_32 |= (i % (bp->num_rx_rings - 1)) << shift;
if ((i % 8) == 7) {
BNX2_WR(bp, BNX2_RLUP_RSS_DATA, tbl_32);
BNX2_WR(bp, <API key>, (i >> 3) |
<API key> |
<API key> |
<API key>);
tbl_32 = 0;
}
}
val = <API key> |
<API key>;
BNX2_WR(bp, <API key>, val);
}
#endif
}
static u32 bnx2_find_max_ring(u32 ring_size, u32 max_size)
{
u32 max, num_rings = 1;
while (ring_size > <API key>) {
ring_size -= <API key>;
num_rings++;
}
/* round to next power of 2 */
max = max_size;
while ((max & num_rings) == 0)
max >>= 1;
if (num_rings != max)
max <<= 1;
return max;
}
static void
<API key>(struct bnx2 *bp, u32 size)
{
u32 rx_size, rx_space;
/* 8 for CRC and VLAN */
rx_size = bp->dev->mtu + ETH_HLEN + BNX2_RX_OFFSET + 8;
rx_space = SKB_DATA_ALIGN(rx_size + BNX2_RX_ALIGN) + NET_SKB_PAD +
sizeof(struct skb_shared_info);
bp->rx_copy_thresh = BNX2_RX_COPY_THRESH;
bp->rx_pg_ring_size = 0;
bp->rx_max_pg_ring = 0;
bp->rx_max_pg_ring_idx = 0;
#if !defined(__VMKLNX__)
if ((rx_space > PAGE_SIZE) && !(bp->flags & <API key>)) {
int pages = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT;
u32 jumbo_size = size * pages;
if (jumbo_size > <API key>)
jumbo_size = <API key>;
bp->rx_pg_ring_size = jumbo_size;
bp->rx_max_pg_ring = bnx2_find_max_ring(jumbo_size,
<API key>);
bp->rx_max_pg_ring_idx =
(bp->rx_max_pg_ring * BNX2_RX_DESC_CNT) - 1;
rx_size = BNX2_RX_COPY_THRESH + BNX2_RX_OFFSET;
bp->rx_copy_thresh = 0;
}
#endif
bp->rx_buf_use_size = rx_size;
/* hw alignment */
bp->rx_buf_size = bp->rx_buf_use_size + BNX2_RX_ALIGN;
bp->rx_jumbo_thresh = rx_size - BNX2_RX_OFFSET;
bp->rx_ring_size = size;
bp->rx_max_ring = bnx2_find_max_ring(size, BNX2_MAX_RX_RINGS);
bp->rx_max_ring_idx = (bp->rx_max_ring * BNX2_RX_DESC_CNT) - 1;
}
static void
bnx2_free_tx_skbs(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_tx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
int j;
if (txr->tx_buf_ring == NULL)
continue;
for (j = 0; j < BNX2_TX_DESC_CNT; ) {
struct bnx2_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j];
struct sk_buff *skb = tx_buf->skb;
int k, last;
if (skb == NULL) {
j = BNX2_NEXT_TX_BD(j);
continue;
}
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev,
#else
pci_unmap_single(bp->pdev,
#endif
dma_unmap_addr(tx_buf, mapping),
skb_headlen(skb),
PCI_DMA_TODEVICE);
tx_buf->skb = NULL;
last = tx_buf->nr_frags;
j = BNX2_NEXT_TX_BD(j);
for (k = 0; k < last; k++, j = BNX2_NEXT_TX_BD(j)) {
tx_buf = &txr->tx_buf_ring[BNX2_TX_RING_IDX(j)];
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_page(&bp->pdev->dev,
#else
pci_unmap_page(bp->pdev,
#endif
dma_unmap_addr(tx_buf, mapping),
skb_frag_size(&skb_shinfo(skb)->frags[k]),
PCI_DMA_TODEVICE);
}
dev_kfree_skb(skb);
}
}
}
static void
bnx2_free_rx_skbs(struct bnx2 *bp)
{
int i;
for (i = 0; i < bp->num_rx_rings; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
int j;
if (rxr->rx_buf_ring == NULL)
return;
for (j = 0; j < bp->rx_max_ring_idx; j++) {
struct bnx2_sw_bd *rx_buf = &rxr->rx_buf_ring[j];
struct sk_buff *skb = rx_buf->skb;
if (skb == NULL)
continue;
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev,
#else
pci_unmap_single(bp->pdev,
#endif
dma_unmap_addr(rx_buf, mapping),
bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
rx_buf->skb = NULL;
dev_kfree_skb(skb);
}
for (j = 0; j < bp->rx_max_pg_ring_idx; j++)
bnx2_free_rx_page(bp, rxr, j);
}
}
static void
bnx2_free_skbs(struct bnx2 *bp)
{
bnx2_free_tx_skbs(bp);
bnx2_free_rx_skbs(bp);
}
static int
bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
{
int rc;
rc = bnx2_reset_chip(bp, reset_code);
bnx2_free_skbs(bp);
if (rc)
return rc;
if ((rc = bnx2_init_chip(bp)) != 0)
return rc;
bnx2_init_all_rings(bp);
return 0;
}
static int
bnx2_init_nic(struct bnx2 *bp, int reset_phy)
{
int rc;
if ((rc = bnx2_reset_nic(bp, <API key>)) != 0)
return rc;
spin_lock_bh(&bp->phy_lock);
bnx2_init_phy(bp, reset_phy);
bnx2_set_link(bp);
if (bp->phy_flags & <API key>)
<API key>(bp);
spin_unlock_bh(&bp->phy_lock);
return 0;
}
static int
bnx2_shutdown_chip(struct bnx2 *bp)
{
u32 reset_code;
if (bp->flags & BNX2_FLAG_NO_WOL)
reset_code = <API key>;
else if (bp->wol)
reset_code = <API key>;
else
reset_code = <API key>;
return bnx2_reset_chip(bp, reset_code);
}
static int
bnx2_test_registers(struct bnx2 *bp)
{
int ret;
int i, is_5709;
static const struct {
u16 offset;
u16 flags;
#define BNX2_FL_NOT_5709 1
u32 rw_mask;
u32 ro_mask;
} reg_tbl[] = {
{ 0x006c, 0, 0x00000000, 0x0000003f },
{ 0x0090, 0, 0xffffffff, 0x00000000 },
{ 0x0094, 0, 0x00000000, 0x00000000 },
{ 0x0404, BNX2_FL_NOT_5709, 0x00003f00, 0x00000000 },
{ 0x0418, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x041c, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x0420, BNX2_FL_NOT_5709, 0x00000000, 0x80ffffff },
{ 0x0424, BNX2_FL_NOT_5709, 0x00000000, 0x00000000 },
{ 0x0428, BNX2_FL_NOT_5709, 0x00000000, 0x00000001 },
{ 0x0450, BNX2_FL_NOT_5709, 0x00000000, 0x0000ffff },
{ 0x0454, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x0458, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x0808, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x0854, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
{ 0x0868, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
{ 0x086c, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
{ 0x0870, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
{ 0x0874, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
{ 0x0c00, BNX2_FL_NOT_5709, 0x00000000, 0x00000001 },
{ 0x0c04, BNX2_FL_NOT_5709, 0x00000000, 0x03ff0001 },
{ 0x0c08, BNX2_FL_NOT_5709, 0x0f0ff073, 0x00000000 },
{ 0x1000, 0, 0x00000000, 0x00000001 },
{ 0x1004, BNX2_FL_NOT_5709, 0x00000000, 0x000f0001 },
{ 0x1408, 0, 0x01c00800, 0x00000000 },
{ 0x149c, 0, 0x8000ffff, 0x00000000 },
{ 0x14a8, 0, 0x00000000, 0x000001ff },
{ 0x14ac, 0, 0x0fffffff, 0x10000000 },
{ 0x14b0, 0, 0x00000002, 0x00000001 },
{ 0x14b8, 0, 0x00000000, 0x00000000 },
{ 0x14c0, 0, 0x00000000, 0x00000009 },
{ 0x14c4, 0, 0x00003fff, 0x00000000 },
{ 0x14cc, 0, 0x00000000, 0x00000001 },
{ 0x14d0, 0, 0xffffffff, 0x00000000 },
{ 0x1800, 0, 0x00000000, 0x00000001 },
{ 0x1804, 0, 0x00000000, 0x00000003 },
{ 0x2800, 0, 0x00000000, 0x00000001 },
{ 0x2804, 0, 0x00000000, 0x00003f01 },
{ 0x2808, 0, 0x0f3f3f03, 0x00000000 },
{ 0x2810, 0, 0xffff0000, 0x00000000 },
{ 0x2814, 0, 0xffff0000, 0x00000000 },
{ 0x2818, 0, 0xffff0000, 0x00000000 },
{ 0x281c, 0, 0xffff0000, 0x00000000 },
{ 0x2834, 0, 0xffffffff, 0x00000000 },
{ 0x2840, 0, 0x00000000, 0xffffffff },
{ 0x2844, 0, 0x00000000, 0xffffffff },
{ 0x2848, 0, 0xffffffff, 0x00000000 },
{ 0x284c, 0, 0xf800f800, 0x07ff07ff },
{ 0x2c00, 0, 0x00000000, 0x00000011 },
{ 0x2c04, 0, 0x00000000, 0x00030007 },
{ 0x3c00, 0, 0x00000000, 0x00000001 },
{ 0x3c04, 0, 0x00000000, 0x00070000 },
{ 0x3c08, 0, 0x00007f71, 0x07f00000 },
{ 0x3c0c, 0, 0x1f3ffffc, 0x00000000 },
{ 0x3c10, 0, 0xffffffff, 0x00000000 },
{ 0x3c14, 0, 0x00000000, 0xffffffff },
{ 0x3c18, 0, 0x00000000, 0xffffffff },
{ 0x3c1c, 0, 0xfffff000, 0x00000000 },
{ 0x3c20, 0, 0xffffff00, 0x00000000 },
{ 0x5004, 0, 0x00000000, 0x0000007f },
{ 0x5008, 0, 0x0f0007ff, 0x00000000 },
{ 0x5c00, 0, 0x00000000, 0x00000001 },
{ 0x5c04, 0, 0x00000000, 0x0003000f },
{ 0x5c08, 0, 0x00000003, 0x00000000 },
{ 0x5c0c, 0, 0x0000fff8, 0x00000000 },
{ 0x5c10, 0, 0x00000000, 0xffffffff },
{ 0x5c80, 0, 0x00000000, 0x0f7113f1 },
{ 0x5c84, 0, 0x00000000, 0x0000f333 },
{ 0x5c88, 0, 0x00000000, 0x00077373 },
{ 0x5c8c, 0, 0x00000000, 0x0007f737 },
{ 0x6808, 0, 0x0000ff7f, 0x00000000 },
{ 0x680c, 0, 0xffffffff, 0x00000000 },
{ 0x6810, 0, 0xffffffff, 0x00000000 },
{ 0x6814, 0, 0xffffffff, 0x00000000 },
{ 0x6818, 0, 0xffffffff, 0x00000000 },
{ 0x681c, 0, 0xffffffff, 0x00000000 },
{ 0x6820, 0, 0x00ff00ff, 0x00000000 },
{ 0x6824, 0, 0x00ff00ff, 0x00000000 },
{ 0x6828, 0, 0x00ff00ff, 0x00000000 },
{ 0x682c, 0, 0x03ff03ff, 0x00000000 },
{ 0x6830, 0, 0x03ff03ff, 0x00000000 },
{ 0x6834, 0, 0x03ff03ff, 0x00000000 },
{ 0x6838, 0, 0x03ff03ff, 0x00000000 },
{ 0x683c, 0, 0x0000ffff, 0x00000000 },
{ 0x6840, 0, 0x00000ff0, 0x00000000 },
{ 0x6844, 0, 0x00ffff00, 0x00000000 },
{ 0x684c, 0, 0xffffffff, 0x00000000 },
{ 0x6850, 0, 0x7f7f7f7f, 0x00000000 },
{ 0x6854, 0, 0x7f7f7f7f, 0x00000000 },
{ 0x6858, 0, 0x7f7f7f7f, 0x00000000 },
{ 0x685c, 0, 0x7f7f7f7f, 0x00000000 },
{ 0x6908, 0, 0x00000000, 0x0001ff0f },
{ 0x690c, 0, 0x00000000, 0x0ffe00f0 },
{ 0xffff, 0, 0x00000000, 0x00000000 },
};
ret = 0;
is_5709 = 0;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
is_5709 = 1;
for (i = 0; reg_tbl[i].offset != 0xffff; i++) {
u32 offset, rw_mask, ro_mask, save_val, val;
u16 flags = reg_tbl[i].flags;
if (is_5709 && (flags & BNX2_FL_NOT_5709))
continue;
offset = (u32) reg_tbl[i].offset;
rw_mask = reg_tbl[i].rw_mask;
ro_mask = reg_tbl[i].ro_mask;
save_val = readl(bp->regview + offset);
writel(0, bp->regview + offset);
val = readl(bp->regview + offset);
if ((val & rw_mask) != 0) {
goto reg_test_err;
}
if ((val & ro_mask) != (save_val & ro_mask)) {
goto reg_test_err;
}
writel(0xffffffff, bp->regview + offset);
val = readl(bp->regview + offset);
if ((val & rw_mask) != rw_mask) {
goto reg_test_err;
}
if ((val & ro_mask) != (save_val & ro_mask)) {
goto reg_test_err;
}
writel(save_val, bp->regview + offset);
continue;
reg_test_err:
writel(save_val, bp->regview + offset);
ret = -ENODEV;
break;
}
return ret;
}
static int
bnx2_do_mem_test(struct bnx2 *bp, u32 start, u32 size)
{
static const u32 test_pattern[] = { 0x00000000, 0xffffffff, 0x55555555,
0xaaaaaaaa , 0xaa55aa55, 0x55aa55aa };
int i;
for (i = 0; i < sizeof(test_pattern) / 4; i++) {
u32 offset;
for (offset = 0; offset < size; offset += 4) {
bnx2_reg_wr_ind(bp, start + offset, test_pattern[i]);
if (bnx2_reg_rd_ind(bp, start + offset) !=
test_pattern[i]) {
return -ENODEV;
}
}
}
return 0;
}
static int
bnx2_test_memory(struct bnx2 *bp)
{
int ret = 0;
int i;
static struct mem_entry {
u32 offset;
u32 len;
} mem_tbl_5706[] = {
{ 0x60000, 0x4000 },
{ 0xa0000, 0x3000 },
{ 0xe0000, 0x4000 },
{ 0x120000, 0x4000 },
{ 0x1a0000, 0x4000 },
{ 0x160000, 0x4000 },
{ 0xffffffff, 0 },
},
mem_tbl_5709[] = {
{ 0x60000, 0x4000 },
{ 0xa0000, 0x3000 },
{ 0xe0000, 0x4000 },
{ 0x120000, 0x4000 },
{ 0x1a0000, 0x4000 },
{ 0xffffffff, 0 },
};
struct mem_entry *mem_tbl;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
mem_tbl = mem_tbl_5709;
else
mem_tbl = mem_tbl_5706;
for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) {
if ((ret = bnx2_do_mem_test(bp, mem_tbl[i].offset,
mem_tbl[i].len)) != 0) {
return ret;
}
}
return ret;
}
#define BNX2_MAC_LOOPBACK 0
#define BNX2_PHY_LOOPBACK 1
static int
bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
{
unsigned int pkt_size, num_pkts, i;
struct sk_buff *skb, *rx_skb;
unsigned char *packet;
u16 rx_start_idx, rx_idx;
dma_addr_t map;
struct bnx2_tx_bd *txbd;
struct bnx2_sw_bd *rx_buf;
struct l2_fhdr *rx_hdr;
int ret = -ENODEV;
struct bnx2_napi *bnapi = &bp->bnx2_napi[0], *tx_napi;
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
struct bnx2_rx_ring_info *rxr = &bnapi->rx_ring;
tx_napi = bnapi;
txr = &tx_napi->tx_ring;
rxr = &bnapi->rx_ring;
if (loopback_mode == BNX2_MAC_LOOPBACK) {
bp->loopback = MAC_LOOPBACK;
<API key>(bp);
}
else if (loopback_mode == BNX2_PHY_LOOPBACK) {
if (bp->phy_flags & <API key>)
return 0;
bp->loopback = PHY_LOOPBACK;
<API key>(bp);
}
else
return -EINVAL;
pkt_size = min(bp->dev->mtu + ETH_HLEN, bp->rx_jumbo_thresh - 4);
skb = netdev_alloc_skb(bp->dev, pkt_size);
if (!skb)
return -ENOMEM;
packet = skb_put(skb, pkt_size);
memcpy(packet, bp->dev->dev_addr, 6);
memset(packet + 6, 0x0, 8);
for (i = 14; i < pkt_size; i++)
packet[i] = (unsigned char) (i & 0xff);
#if (LINUX_VERSION_CODE >= 0x02061b)
map = dma_map_single(&bp->pdev->dev, skb->data, pkt_size,
PCI_DMA_TODEVICE);
if (dma_mapping_error(&bp->pdev->dev, map)) {
#else
map = pci_map_single(bp->pdev, skb->data, pkt_size,
PCI_DMA_TODEVICE);
if (<API key>(map)) {
#endif
dev_kfree_skb(skb);
return -EIO;
}
BNX2_WR(bp, BNX2_HC_COMMAND,
bp->hc_cmd | <API key>);
BNX2_RD(bp, BNX2_HC_COMMAND);
udelay(5);
rx_start_idx = bnx2_get_hw_rx_cons(bnapi);
num_pkts = 0;
txbd = &txr->tx_desc_ring[BNX2_TX_RING_IDX(txr->tx_prod)];
txbd->tx_bd_haddr_hi = (u64) map >> 32;
txbd->tx_bd_haddr_lo = (u64) map & 0xffffffff;
txbd->tx_bd_mss_nbytes = pkt_size;
txbd-><API key> = TX_BD_FLAGS_START | TX_BD_FLAGS_END;
num_pkts++;
txr->tx_prod = BNX2_NEXT_TX_BD(txr->tx_prod);
txr->tx_prod_bseq += pkt_size;
BNX2_WR16(bp, txr->tx_bidx_addr, txr->tx_prod);
BNX2_WR(bp, txr->tx_bseq_addr, txr->tx_prod_bseq);
udelay(100);
BNX2_WR(bp, BNX2_HC_COMMAND,
bp->hc_cmd | <API key>);
BNX2_RD(bp, BNX2_HC_COMMAND);
udelay(5);
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev, map, pkt_size, PCI_DMA_TODEVICE);
#else
pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE);
#endif
dev_kfree_skb(skb);
if (bnx2_get_hw_tx_cons(tx_napi) != txr->tx_prod)
goto loopback_test_done;
rx_idx = bnx2_get_hw_rx_cons(bnapi);
if (rx_idx != rx_start_idx + num_pkts) {
goto loopback_test_done;
}
rx_buf = &rxr->rx_buf_ring[rx_start_idx];
rx_skb = rx_buf->skb;
rx_hdr = rx_buf->desc;
skb_reserve(rx_skb, BNX2_RX_OFFSET);
#if (LINUX_VERSION_CODE >= 0x02061b)
<API key>(&bp->pdev->dev,
#else
<API key>(bp->pdev,
#endif
dma_unmap_addr(rx_buf, mapping),
bp->rx_buf_size, PCI_DMA_FROMDEVICE);
if (rx_hdr->l2_fhdr_status &
(<API key> |
<API key> |
<API key> |
<API key> |
<API key>)) {
goto loopback_test_done;
}
if ((rx_hdr->l2_fhdr_pkt_len - 4) != pkt_size) {
goto loopback_test_done;
}
for (i = 14; i < pkt_size; i++) {
if (*(rx_skb->data + i) != (unsigned char) (i & 0xff)) {
goto loopback_test_done;
}
}
ret = 0;
loopback_test_done:
bp->loopback = 0;
return ret;
}
#define <API key> 1
#define <API key> 2
#define <API key> (<API key> | \
<API key>)
static int
bnx2_test_loopback(struct bnx2 *bp)
{
int rc = 0;
if (!netif_running(bp->dev))
return <API key>;
bnx2_reset_nic(bp, <API key>);
spin_lock_bh(&bp->phy_lock);
bnx2_init_phy(bp, 1);
spin_unlock_bh(&bp->phy_lock);
if (bnx2_run_loopback(bp, BNX2_MAC_LOOPBACK))
rc |= <API key>;
if (bnx2_run_loopback(bp, BNX2_PHY_LOOPBACK))
rc |= <API key>;
return rc;
}
#define NVRAM_SIZE 0x200
#define CRC32_RESIDUAL 0xdebb20e3
static int
bnx2_test_nvram(struct bnx2 *bp)
{
__be32 buf[NVRAM_SIZE / 4];
u8 *data = (u8 *) buf;
int rc = 0;
u32 magic, csum;
if ((rc = bnx2_nvram_read(bp, 0, data, 4)) != 0)
goto test_nvram_done;
magic = be32_to_cpu(buf[0]);
if (magic != 0x669955aa) {
rc = -ENODEV;
goto test_nvram_done;
}
if ((rc = bnx2_nvram_read(bp, 0x100, data, NVRAM_SIZE)) != 0)
goto test_nvram_done;
csum = ether_crc_le(0x100, data);
if (csum != CRC32_RESIDUAL) {
rc = -ENODEV;
goto test_nvram_done;
}
csum = ether_crc_le(0x100, data + 0x100);
if (csum != CRC32_RESIDUAL) {
rc = -ENODEV;
}
test_nvram_done:
return rc;
}
static int
bnx2_test_link(struct bnx2 *bp)
{
u32 bmsr;
if (!netif_running(bp->dev))
return -ENODEV;
if (bp->phy_flags & <API key>) {
int i;
for (i = 0; i < 6 && !bp->link_up; i++) {
if (<API key>(500))
break;
}
if (bp->link_up)
return 0;
return -ENODEV;
}
spin_lock_bh(&bp->phy_lock);
bnx2_enable_bmsr1(bp);
bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
bnx2_disable_bmsr1(bp);
spin_unlock_bh(&bp->phy_lock);
if (bmsr & BMSR_LSTATUS) {
return 0;
}
return -ENODEV;
}
static int
bnx2_test_intr(struct bnx2 *bp)
{
int i;
u16 status_idx;
if (!netif_running(bp->dev))
return -ENODEV;
status_idx = BNX2_RD(bp, <API key>) & 0xffff;
/* This register is not touched during run-time. */
BNX2_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | <API key>);
BNX2_RD(bp, BNX2_HC_COMMAND);
for (i = 0; i < 10; i++) {
if ((BNX2_RD(bp, <API key>) & 0xffff) !=
status_idx) {
break;
}
<API key>(10);
}
if (i < 10)
return 0;
return -ENODEV;
}
/* Determining link for parallel detection. */
static int
<API key>(struct bnx2 *bp)
{
u32 mode_ctl, an_dbg, exp;
if (bp->phy_flags & <API key>)
return 0;
bnx2_write_phy(bp, <API key>, MISC_SHDW_MODE_CTL);
bnx2_read_phy(bp, <API key>, &mode_ctl);
if (!(mode_ctl & <API key>))
return 0;
bnx2_write_phy(bp, <API key>, MISC_SHDW_AN_DBG);
bnx2_read_phy(bp, <API key>, &an_dbg);
bnx2_read_phy(bp, <API key>, &an_dbg);
if (an_dbg & (<API key> | <API key>))
return 0;
bnx2_write_phy(bp, <API key>, MII_EXPAND_REG1);
bnx2_read_phy(bp, <API key>, &exp);
bnx2_read_phy(bp, <API key>, &exp);
if (exp & <API key>) /* receiving CONFIG */
return 0;
return 1;
}
static void
<API key>(struct bnx2 *bp)
{
int check_link = 1;
spin_lock(&bp->phy_lock);
if (bp->serdes_an_pending) {
bp->serdes_an_pending
check_link = 0;
} else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
u32 bmcr;
bp->current_interval = BNX2_TIMER_INTERVAL;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (bmcr & BMCR_ANENABLE) {
if (<API key>(bp)) {
bmcr &= ~BMCR_ANENABLE;
bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX;
bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
bp->phy_flags |= <API key>;
}
}
}
else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
(bp->phy_flags & <API key>)) {
u32 phy2;
bnx2_write_phy(bp, 0x17, 0x0f01);
bnx2_read_phy(bp, 0x15, &phy2);
if (phy2 & 0x20) {
u32 bmcr;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
bmcr |= BMCR_ANENABLE;
bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
bp->phy_flags &= ~<API key>;
}
} else
bp->current_interval = BNX2_TIMER_INTERVAL;
if (check_link) {
u32 val;
bnx2_write_phy(bp, <API key>, MISC_SHDW_AN_DBG);
bnx2_read_phy(bp, <API key>, &val);
bnx2_read_phy(bp, <API key>, &val);
if (bp->link_up && (val & <API key>)) {
if (!(bp->phy_flags & <API key>)) {
<API key>(bp, 1);
bp->phy_flags |= <API key>;
} else
bnx2_set_link(bp);
} else if (!bp->link_up && !(val & <API key>))
bnx2_set_link(bp);
}
spin_unlock(&bp->phy_lock);
}
static void
<API key>(struct bnx2 *bp)
{
if (bp->phy_flags & <API key>)
return;
if ((bp->phy_flags & <API key>) == 0) {
bp->serdes_an_pending = 0;
return;
}
spin_lock(&bp->phy_lock);
if (bp->serdes_an_pending)
bp->serdes_an_pending
else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
u32 bmcr;
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
if (bmcr & BMCR_ANENABLE) {
<API key>(bp);
bp->current_interval = <API key>;
} else {
<API key>(bp);
bp->serdes_an_pending = 2;
bp->current_interval = BNX2_TIMER_INTERVAL;
}
} else
bp->current_interval = BNX2_TIMER_INTERVAL;
spin_unlock(&bp->phy_lock);
}
static void
bnx2_timer(unsigned long data)
{
struct bnx2 *bp = (struct bnx2 *) data;
if (!netif_running(bp->dev))
return;
if (atomic_read(&bp->intr_sem) != 0)
goto bnx2_restart_timer;
#ifdef CONFIG_PCI_MSI
if ((bp->flags & (BNX2_FLAG_USING_MSI | <API key>)) ==
BNX2_FLAG_USING_MSI)
bnx2_chk_missed_msi(bp);
#endif
<API key>(bp);
bp->stats_blk->stat_FwRxDrop =
bnx2_reg_rd_ind(bp, <API key>);
/* workaround occasional corrupted counters */
if ((bp->flags & <API key>) && bp->stats_ticks)
BNX2_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd |
<API key>);
if (bp->phy_flags & <API key>) {
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
<API key>(bp);
else
<API key>(bp);
}
bnx2_restart_timer:
mod_timer(&bp->timer, jiffies + bp->current_interval);
}
static int
bnx2_request_irq(struct bnx2 *bp)
{
unsigned long flags;
struct bnx2_irq *irq;
int rc = 0, i;
if (bp->flags & <API key>)
flags = 0;
else
flags = IRQF_SHARED;
#if defined(__VMKLNX__)
/*
* In ESX, bnx2 will setup int mode during .probe time. However, the dev->name
* will be finalized only when pci_announce_device is done. So, we assign
* irq->name here instead of in bnx2_setup_int_mode.
*/
strcpy(bp->irq_tbl[0].name, bp->dev->name);
if (bp->flags & <API key>) {
for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
snprintf(bp->irq_tbl[i].name, sizeof(bp->irq_tbl[i].name),
"%s-%d", bp->dev->name, i);
}
}
#endif
for (i = 0; i < bp->irq_nvecs; i++) {
irq = &bp->irq_tbl[i];
rc = request_irq(irq->vector, irq->handler, flags, irq->name,
&bp->bnx2_napi[i]);
if (rc)
break;
irq->requested = 1;
}
return rc;
}
#if defined(__VMKLNX__)
/* disable MSI/MSIX */
static void
bnx2_disable_msi(struct bnx2 *bp)
{
#ifdef CONFIG_PCI_MSI
if (bp->flags & BNX2_FLAG_USING_MSI)
pci_disable_msi(bp->pdev);
else if (bp->flags & <API key>)
pci_disable_msix(bp->pdev);
bp->flags &= ~(<API key> | <API key>);
#endif
}
#endif /* defined(__VMKLNX__) */
static void
__bnx2_free_irq(struct bnx2 *bp)
{
struct bnx2_irq *irq;
int i;
for (i = 0; i < bp->irq_nvecs; i++) {
irq = &bp->irq_tbl[i];
if (irq->requested)
free_irq(irq->vector, &bp->bnx2_napi[i]);
irq->requested = 0;
}
}
static void
bnx2_free_irq(struct bnx2 *bp)
{
__bnx2_free_irq(bp);
#if !defined(__VMKLNX__)
#ifdef CONFIG_PCI_MSI
if (bp->flags & BNX2_FLAG_USING_MSI)
pci_disable_msi(bp->pdev);
else if (bp->flags & <API key>)
pci_disable_msix(bp->pdev);
bp->flags &= ~(<API key> | <API key>);
#endif
#endif /* __VMKLNX__ */
}
#ifdef CONFIG_PCI_MSI
static void
bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
{
#ifdef BNX2_NEW_NAPI
int i, total_vecs, rc;
struct msix_entry msix_ent[BNX2_MAX_MSIX_VEC];
#if !defined(__VMKLNX__)
struct net_device *dev = bp->dev;
const int len = sizeof(bp->irq_tbl[0].name);
#endif
bnx2_setup_msix_tbl(bp);
BNX2_WR(bp, <API key>, <API key> - 1);
BNX2_WR(bp, <API key>, <API key>);
BNX2_WR(bp, <API key>, <API key>);
/* Need to flush the previous three writes to ensure MSI-X
* is setup properly */
BNX2_RD(bp, <API key>);
for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
msix_ent[i].entry = i;
msix_ent[i].vector = 0;
}
total_vecs = msix_vecs;
#ifdef BCM_CNIC
total_vecs++;
#endif
rc = -ENOSPC;
while (total_vecs >= BNX2_MIN_MSIX_VEC) {
rc = pci_enable_msix(bp->pdev, msix_ent, total_vecs);
if (rc <= 0)
break;
if (rc > 0)
total_vecs = rc;
}
if (rc != 0)
return;
msix_vecs = total_vecs;
#ifdef BCM_CNIC
msix_vecs
#endif
bp->irq_nvecs = msix_vecs;
bp->flags |= <API key> | <API key>;
#if defined(__VMKLNX__)
if (disable_msi_1shot)
bp->flags &= ~<API key>;
#endif
for (i = 0; i < total_vecs; i++) {
bp->irq_tbl[i].vector = msix_ent[i].vector;
#if !defined(__VMKLNX__)
snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i);
bp->irq_tbl[i].handler = bnx2_msi_1shot;
#else
if (disable_msi_1shot)
bp->irq_tbl[i].handler = bnx2_msi;
else
bp->irq_tbl[i].handler = bnx2_msi_1shot;
#endif
}
#endif
}
#endif
static int
bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
{
#ifdef CONFIG_PCI_MSI
#if defined(<API key>)
int cpus = num_online_cpus();
int msix_vecs = min(cpus, 4);
if (force_netq_param[bp->index] != BNX2_OPTION_UNSET)
msix_vecs = min(force_netq_param[bp->index], RX_MAX_RSS_RINGS);
/* Once is for the default queuue */
msix_vecs += 1;
#else
#if defined(__VMKLNX__)
/* If NetQueue is not enable then force the number of queues to 1 */
int msix_vecs = 1;
#else
int cpus = num_online_cpus();
int msix_vecs;
#endif /* defined(__VMKLNX__) */
#endif
#endif
#if !defined(__VMKLNX__)
if (!bp->num_req_rx_rings)
msix_vecs = max(cpus + 1, bp->num_req_tx_rings);
else if (!bp->num_req_tx_rings)
msix_vecs = max(cpus, bp->num_req_rx_rings);
else
msix_vecs = max(bp->num_req_rx_rings, bp->num_req_tx_rings);
msix_vecs = min(msix_vecs, RX_MAX_RINGS);
#endif
bp->irq_tbl[0].handler = bnx2_interrupt;
#if !defined(__VMKLNX__)
strcpy(bp->irq_tbl[0].name, bp->dev->name);
#endif
bp->irq_nvecs = 1;
bp->irq_tbl[0].vector = bp->pdev->irq;
#ifdef CONFIG_PCI_MSI
if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !dis_msi)
bnx2_enable_msix(bp, msix_vecs);
if ((bp->flags & BNX2_FLAG_MSI_CAP) && !dis_msi &&
!(bp->flags & <API key>)) {
if (pci_enable_msi(bp->pdev) == 0) {
bp->flags |= BNX2_FLAG_USING_MSI;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
bp->flags |= <API key>;
bp->irq_tbl[0].handler = bnx2_msi_1shot;
#if defined(__VMKLNX__)
if (disable_msi_1shot) {
bp->flags &= ~<API key>;
bp->irq_tbl[0].handler = bnx2_msi;
}
#endif
} else
bp->irq_tbl[0].handler = bnx2_msi;
bp->irq_tbl[0].vector = bp->pdev->irq;
}
}
#endif
#ifndef <API key>
bp->num_tx_rings = 1;
bp->num_rx_rings = bp->irq_nvecs;
#else
#if defined(__VMKLNX__)
#if defined(<API key>)
bp->num_tx_rings = bp->irq_nvecs;
bp->dev->real_num_tx_queues = bp->num_tx_rings;
#else
bp->num_tx_rings = 1;
#endif
bp->num_rx_rings = bp->irq_nvecs;
#else
if (!bp->num_req_tx_rings)
bp->num_tx_rings = <API key>(bp->irq_nvecs);
else
bp->num_tx_rings = min(bp->irq_nvecs, bp->num_req_tx_rings);
if (!bp->num_req_rx_rings)
bp->num_rx_rings = bp->irq_nvecs;
else
bp->num_rx_rings = min(bp->irq_nvecs, bp->num_req_rx_rings);
#endif
<API key>(bp->dev, bp->num_tx_rings);
#endif
return <API key>(bp->dev, bp->num_rx_rings);
}
/* Called with rtnl_lock */
static int
bnx2_open(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
int rc;
netif_carrier_off(dev);
bnx2_disable_int(bp);
#if !(defined __VMKLNX__)
rc = bnx2_setup_int_mode(bp, disable_msi);
if (rc)
goto open_err;
bnx2_init_napi(bp);
#endif /* !(defined __VMKLNX__) */
rc = bnx2_alloc_mem(bp);
if (rc)
goto open_err;
rc = bnx2_request_irq(bp);
if (rc)
goto open_err;
rc = bnx2_init_nic(bp, 1);
if (rc)
goto open_err;
#ifdef BNX2_NEW_NAPI
bnx2_napi_enable(bp);
#endif
mod_timer(&bp->timer, jiffies + bp->current_interval);
atomic_set(&bp->intr_sem, 0);
memset(bp->temp_stats_blk, 0, sizeof(struct statistics_block));
bnx2_enable_int(bp);
#ifdef CONFIG_PCI_MSI
if (bp->flags & BNX2_FLAG_USING_MSI) {
/* Test MSI to make sure it is working
* If MSI test fails, go back to INTx mode
*/
if (bnx2_test_intr(bp) != 0) {
netdev_warn(bp->dev, "No interrupt was generated using MSI, switching to INTx mode. Please report this failure to the PCI maintainer and include system chipset information.\n");
#ifdef BNX2_NEW_NAPI
bnx2_napi_disable(bp);
#endif
bnx2_disable_int(bp);
bnx2_free_irq(bp);
#if defined(__VMKLNX__)
bnx2_disable_msi(bp);
#endif
bnx2_setup_int_mode(bp, 1);
rc = bnx2_init_nic(bp, 0);
if (!rc)
rc = bnx2_request_irq(bp);
if (rc) {
del_timer_sync(&bp->timer);
goto open_err;
}
#ifdef BNX2_NEW_NAPI
bnx2_napi_enable(bp);
#endif
bnx2_enable_int(bp);
}
}
if (bp->flags & BNX2_FLAG_USING_MSI)
netdev_info(dev, "using MSI\n");
else if (bp->flags & <API key>)
netdev_info(dev, "using MSIX\n");
#endif
#if defined(<API key>)
if (<API key>(bp))
<API key>(bp);
#endif
<API key>(dev);
#if defined(__VMKLNX__)
if (bp->cnic_eth_dev.drv_state & CNIC_DRV_STATE_REGD) {
<API key>(bp);
bnx2_cnic_start(bp);
}
#endif
return 0;
open_err:
bnx2_free_skbs(bp);
bnx2_free_irq(bp);
bnx2_free_mem(bp);
#if !defined(__VMKLNX__)
bnx2_del_napi(bp);
#endif /* !(defined __VMKLNX__) */
return rc;
}
static void
#if defined(<API key>) || defined(INIT_WORK_NAR) || defined(<API key>) || (defined(__VMKLNX__) && (<API key> >= 40000))
bnx2_reset_task(struct work_struct *work)
#else
bnx2_reset_task(void *data)
#endif
{
#if defined(<API key>) || defined(INIT_WORK_NAR) || defined(<API key>) || (defined(__VMKLNX__) && (<API key> >= 40000))
struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
#else
struct bnx2 *bp = data;
#endif
int rc;
u16 pcicmd;
rtnl_lock();
if (!netif_running(bp->dev)) {
rtnl_unlock();
return;
}
bnx2_netif_stop(bp, true);
<API key>(bp->pdev, PCI_COMMAND, &pcicmd);
if (!(pcicmd & PCI_COMMAND_MEMORY)) {
/* in case PCI block has reset */
pci_restore_state(bp->pdev);
pci_save_state(bp->pdev);
}
rc = bnx2_init_nic(bp, 1);
if (rc) {
netdev_err(bp->dev, "failed to reset NIC, closing\n");
bnx2_napi_enable(bp);
dev_close(bp->dev);
#if defined(__VMKLNX__)
#if (<API key> >= 41000)
/* PR 533926
* This is a workaround to sync device status in dev->flags and
* dev->gflags. It is needed to avoid PSOD (due to double dev_close)
* on reboot.
*/
bp->dev->gflags &= ~IFF_DEV_IS_OPEN;
#endif
#endif
rtnl_unlock();
return;
}
atomic_set(&bp->intr_sem, 1);
bnx2_netif_start(bp, true);
rtnl_unlock();
}
#define BNX2_FTQ_ENTRY(ftq) { __stringify(ftq##FTQ_CTL), BNX2_##ftq##FTQ_CTL }
static const struct ftq_reg {
char *name;
u32 off;
} ftq_arr[] = {
BNX2_FTQ_ENTRY(RV2P_P),
BNX2_FTQ_ENTRY(RV2P_T),
BNX2_FTQ_ENTRY(RV2P_M),
BNX2_FTQ_ENTRY(TBDR_),
BNX2_FTQ_ENTRY(TSCH_),
BNX2_FTQ_ENTRY(TDMA_),
BNX2_FTQ_ENTRY(TXP_),
BNX2_FTQ_ENTRY(TPAT_),
BNX2_FTQ_ENTRY(TAS_),
BNX2_FTQ_ENTRY(RXP_C),
BNX2_FTQ_ENTRY(RXP_),
BNX2_FTQ_ENTRY(RLUP_),
BNX2_FTQ_ENTRY(COM_COMXQ_),
BNX2_FTQ_ENTRY(COM_COMTQ_),
BNX2_FTQ_ENTRY(COM_COMQ_),
BNX2_FTQ_ENTRY(CP_CPQ_),
BNX2_FTQ_ENTRY(RDMA_),
BNX2_FTQ_ENTRY(CSCH_CH_),
BNX2_FTQ_ENTRY(MCP_MCPQ_),
};
static void
bnx2_dump_ftq(struct bnx2 *bp)
{
int i;
u32 reg, bdidx, cid, valid;
struct net_device *dev = bp->dev;
netdev_err(dev, "<
for (i = 0; i < ARRAY_SIZE(ftq_arr); i++)
netdev_err(dev, "%s %08x\n", ftq_arr[i].name,
bnx2_reg_rd_ind(bp, ftq_arr[i].off));
netdev_err(dev, "CPU states:\n");
for (reg = BNX2_TXP_CPU_MODE; reg <= BNX2_CP_CPU_MODE; reg += 0x40000)
netdev_err(dev, "%06x mode %x state %x evt_mask %x pc %x pc %x instr %x\n",
reg, bnx2_reg_rd_ind(bp, reg),
bnx2_reg_rd_ind(bp, reg + 4),
bnx2_reg_rd_ind(bp, reg + 8),
bnx2_reg_rd_ind(bp, reg + 0x1c),
bnx2_reg_rd_ind(bp, reg + 0x1c),
bnx2_reg_rd_ind(bp, reg + 0x20));
netdev_err(dev, "<
netdev_err(dev, "<
netdev_err(dev, "TBDC free cnt: %ld\n",
BNX2_RD(bp, BNX2_TBDC_STATUS) & <API key>);
netdev_err(dev, "LINE CID BIDX CMD VALIDS\n");
for (i = 0; i < 0x20; i++) {
int j = 0;
BNX2_WR(bp, BNX2_TBDC_BD_ADDR, i);
BNX2_WR(bp, <API key>,
<API key>);
BNX2_WR(bp, BNX2_TBDC_COMMAND, <API key>);
while ((BNX2_RD(bp, BNX2_TBDC_COMMAND) &
<API key>) && j < 100)
j++;
cid = BNX2_RD(bp, BNX2_TBDC_CID);
bdidx = BNX2_RD(bp, BNX2_TBDC_BIDX);
valid = BNX2_RD(bp, <API key>);
netdev_err(dev, "%02x %06x %04lx %02x [%x]\n",
i, cid, bdidx & <API key>,
bdidx >> 24, (valid >> 8) & 0x0ff);
}
netdev_err(dev, "<
}
static void
bnx2_dump_state(struct bnx2 *bp)
{
struct net_device *dev = bp->dev;
u32 val1, val2;
<API key>(bp->pdev, PCI_COMMAND, &val1);
netdev_err(dev, "DEBUG: intr_sem[%x] PCI_CMD[%08x]\n",
atomic_read(&bp->intr_sem), val1);
<API key>(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &val1);
<API key>(bp->pdev, <API key>, &val2);
netdev_err(dev, "DEBUG: PCI_PM[%08x] PCI_MISC_CFG[%08x]\n", val1, val2);
netdev_err(dev, "DEBUG: EMAC_TX_STATUS[%08x] EMAC_RX_STATUS[%08x]\n",
BNX2_RD(bp, BNX2_EMAC_TX_STATUS),
BNX2_RD(bp, BNX2_EMAC_RX_STATUS));
netdev_err(dev, "DEBUG: RPM_MGMT_PKT_CTRL[%08x]\n",
BNX2_RD(bp, <API key>));
netdev_err(dev, "DEBUG: <API key>[%08x]\n",
BNX2_RD(bp, <API key>));
if (bp->flags & <API key>) {
int i;
netdev_err(dev, "DEBUG: PBA[%08x]\n",
BNX2_RD(bp, <API key>));
netdev_err(dev, "DEBUG: MSIX table:\n");
val1 = <API key>;
for (i = 0; i < bp->irq_nvecs; i++) {
netdev_err(dev, "DEBUG: [%d]: %08x %08x %08x %08x\n",
i, BNX2_RD(bp, val1),
BNX2_RD(bp, val1 + 4), BNX2_RD(bp, val1 + 8),
BNX2_RD(bp, val1 + 12));
val1 += 16;
}
}
}
static void
bnx2_tx_timeout(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
bnx2_dump_ftq(bp);
bnx2_dump_state(bp);
bnx2_dump_mcp_state(bp);
#if defined(__VMKLNX__)
if (psod_on_tx_timeout) {
msleep(100);
BUG_ON(1);
return;
}
#endif
if (stop_on_tx_timeout) {
netdev_err(dev, "prevent chip reset during tx timeout\n");
return;
}
/* This allows the netif to be shutdown gracefully before resetting */
#if (LINUX_VERSION_CODE >= 0x20600)
schedule_work(&bp->reset_task);
#else
schedule_task(&bp->reset_task);
#endif
}
#if defined(BCM_VLAN) && !defined(NEW_VLAN)
/* Called with rtnl_lock */
static void
<API key>(struct net_device *dev, struct vlan_group *vlgrp)
{
struct bnx2 *bp = netdev_priv(dev);
#if defined(__VMKLNX__) && (<API key> < 50000)
/* rtnl_lock() needed for ESX 4.0 and 4.1 only */
rtnl_lock();
#endif
if (netif_running(dev))
bnx2_netif_stop(bp, false);
bp->vlgrp = vlgrp;
if (netif_running(dev)) {
bnx2_set_rx_mode(dev);
if (bp->flags & <API key>)
bnx2_fw_sync(bp, <API key>, 0,
1);
bnx2_netif_start(bp, false);
}
#if defined(__VMKLNX__) && (<API key> < 50000)
rtnl_unlock();
#endif
}
#if (LINUX_VERSION_CODE < 0x20616)
/* Called with rtnl_lock */
static void
<API key>(struct net_device *dev, uint16_t vid)
{
struct bnx2 *bp = netdev_priv(dev);
#if defined(__VMKLNX__) && (<API key> < 50000)
/* rtnl_lock() needed for ESX 4.0 and 4.1 only */
rtnl_lock();
#endif
if (netif_running(dev))
bnx2_netif_stop(bp, false);
<API key>(bp->vlgrp, vid, NULL);
if (!netif_running(dev)) {
#if defined(__VMKLNX__) && (<API key> < 50000)
rtnl_unlock();
#endif
return;
}
bnx2_set_rx_mode(dev);
if (bp->flags & <API key>)
bnx2_fw_sync(bp, <API key>, 0, 1);
bnx2_netif_start(bp, false);
#if defined(__VMKLNX__) && (<API key> < 50000)
rtnl_unlock();
#endif
}
#endif
#endif
/* Called with netif_tx_lock.
* bnx2_tx_int() runs without netif_tx_lock unless it needs to call
* netif_wake_queue().
*/
static netdev_tx_t
bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
dma_addr_t mapping;
struct bnx2_tx_bd *txbd;
struct bnx2_sw_tx_bd *tx_buf;
u32 len, vlan_tag_flags, last_frag, mss;
u16 prod, ring_prod;
int i;
#ifndef <API key>
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
struct bnx2_tx_ring_info *txr = &bnapi->tx_ring;
#if defined(__VMKLNX__) && (<API key> < 50000)
/* Drop the packet if the queue has been stopped */
if (unlikely(netif_queue_stopped(dev))) {
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
#endif
#else
struct bnx2_napi *bnapi;
struct bnx2_tx_ring_info *txr;
struct netdev_queue *txq;
/* Determine which tx ring we will be placed on */
i = <API key>(skb);
bnapi = &bp->bnx2_napi[i];
txr = &bnapi->tx_ring;
txq = netdev_get_tx_queue(dev, i);
#if defined(__VMKLNX__) && (<API key> < 50000)
/* Drop the packet if the queue has been stopped */
if (unlikely(<API key>(txq))) {
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
#endif
#endif
if (unlikely(bnx2_tx_avail(bp, txr) <
(skb_shinfo(skb)->nr_frags + 1))) {
#ifndef <API key>
netif_stop_queue(dev);
#else
netif_tx_stop_queue(txq);
#endif
netdev_err(dev, "BUG! Tx ring full when queue awake!\n");
return NETDEV_TX_BUSY;
}
len = skb_headlen(skb);
prod = txr->tx_prod;
ring_prod = BNX2_TX_RING_IDX(prod);
vlan_tag_flags = 0;
if (skb->ip_summed == CHECKSUM_PARTIAL) {
vlan_tag_flags |= <API key>;
}
#ifdef BCM_VLAN
#ifdef NEW_VLAN
if (vlan_tx_tag_present(skb)) {
#else
if (bp->vlgrp && vlan_tx_tag_present(skb)) {
#endif
vlan_tag_flags |=
(<API key> | (vlan_tx_tag_get(skb) << 16));
}
#endif
#ifdef BCM_TSO
if ((mss = skb_shinfo(skb)->gso_size)) {
u32 tcp_opt_len;
struct iphdr *iph;
tcp_opt_len = tcp_optlen(skb);
if (<API key>(skb) + tcp_opt_len +
sizeof(struct tcphdr) + mss >= skb->len)
goto abort_tso;
vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
#ifndef BCM_NO_TSO6
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
u32 tcp_off = <API key>(skb) -
sizeof(struct ipv6hdr) - ETH_HLEN;
vlan_tag_flags |= ((tcp_opt_len >> 2) << 8) |
<API key>;
if (likely(tcp_off == 0))
vlan_tag_flags &= ~<API key>;
else {
tcp_off >>= 3;
vlan_tag_flags |= ((tcp_off & 0x3) <<
<API key>) |
((tcp_off & 0x10) <<
<API key>);
mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL;
}
} else
#endif
{
iph = ip_hdr(skb);
if (tcp_opt_len || (iph->ihl > 5)) {
vlan_tag_flags |= ((iph->ihl - 5) +
(tcp_opt_len >> 2)) << 8;
}
}
}
else
abort_tso:
#endif
{
mss = 0;
}
#if (LINUX_VERSION_CODE >= 0x02061b)
mapping = dma_map_single(&bp->pdev->dev, skb->data, len, PCI_DMA_TODEVICE);
if (dma_mapping_error(&bp->pdev->dev, mapping)) {
#else
mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
if (<API key>(mapping)) {
#endif
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
tx_buf = &txr->tx_buf_ring[ring_prod];
tx_buf->skb = skb;
dma_unmap_addr_set(tx_buf, mapping, mapping);
txbd = &txr->tx_desc_ring[ring_prod];
txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
txbd->tx_bd_mss_nbytes = len | (mss << 16);
txbd-><API key> = vlan_tag_flags | TX_BD_FLAGS_START;
last_frag = skb_shinfo(skb)->nr_frags;
tx_buf->nr_frags = last_frag;
tx_buf->is_gso = skb_is_gso(skb);
for (i = 0; i < last_frag; i++) {
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
prod = BNX2_NEXT_TX_BD(prod);
ring_prod = BNX2_TX_RING_IDX(prod);
txbd = &txr->tx_desc_ring[ring_prod];
len = skb_frag_size(frag);
mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, len,
DMA_TO_DEVICE);
#if (LINUX_VERSION_CODE >= 0x02061b)
if (dma_mapping_error(&bp->pdev->dev, mapping))
#else
if (<API key>(mapping))
#endif
goto dma_error;
dma_unmap_addr_set(&txr->tx_buf_ring[ring_prod], mapping,
mapping);
txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
txbd->tx_bd_mss_nbytes = len | (mss << 16);
txbd-><API key> = vlan_tag_flags;
}
txbd-><API key> |= TX_BD_FLAGS_END;
/* Sync BD data before updating TX mailbox */
wmb();
prod = BNX2_NEXT_TX_BD(prod);
txr->tx_prod_bseq += skb->len;
BNX2_WR16(bp, txr->tx_bidx_addr, prod);
BNX2_WR(bp, txr->tx_bseq_addr, txr->tx_prod_bseq);
mmiowb();
txr->tx_prod = prod;
#if (LINUX_VERSION_CODE <= 0x2061e) || defined(__VMKLNX__)
dev->trans_start = jiffies;
#endif
#if defined(<API key>)
bnapi->tx_packets_sent++;
wmb();
#endif
if (unlikely(bnx2_tx_avail(bp, txr) <= MAX_SKB_FRAGS)) {
#ifndef <API key>
netif_stop_queue(dev);
#else
netif_tx_stop_queue(txq);
#endif
/* netif_tx_stop_queue() must be done before checking
* tx index in bnx2_tx_avail() below, because in
* bnx2_tx_int(), we update tx index before checking for
* <API key>().
*/
smp_mb();
if (bnx2_tx_avail(bp, txr) > bp->tx_wake_thresh)
#ifndef <API key>
netif_wake_queue(dev);
#else
netif_tx_wake_queue(txq);
#endif
}
return NETDEV_TX_OK;
dma_error:
/* save value of frag that failed */
last_frag = i;
/* start back at beginning and unmap skb */
prod = txr->tx_prod;
ring_prod = BNX2_TX_RING_IDX(prod);
tx_buf = &txr->tx_buf_ring[ring_prod];
tx_buf->skb = NULL;
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping),
skb_headlen(skb), PCI_DMA_TODEVICE);
#else
pci_unmap_single(bp->pdev, dma_unmap_addr(tx_buf, mapping),
skb_headlen(skb), PCI_DMA_TODEVICE);
#endif
/* unmap remaining mapped pages */
for (i = 0; i < last_frag; i++) {
prod = BNX2_NEXT_TX_BD(prod);
ring_prod = BNX2_TX_RING_IDX(prod);
tx_buf = &txr->tx_buf_ring[ring_prod];
#if (LINUX_VERSION_CODE >= 0x02061b)
dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping),
#else
pci_unmap_page(bp->pdev, dma_unmap_addr(tx_buf, mapping),
#endif
skb_frag_size(&skb_shinfo(skb)->frags[i]),
PCI_DMA_TODEVICE);
}
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
/* Called with rtnl_lock */
static int
bnx2_close(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
#if defined(__VMKLNX__)
bnx2_cnic_stop(bp);
#endif /* defined(__VMKLNX__) */
<API key>(bp);
#ifdef BNX2_NEW_NAPI
bnx2_napi_disable(bp);
#endif
netif_tx_disable(bp->dev);
#if defined(<API key>)
bnx2_close_netqueue(bp);
#endif /* <API key> */
del_timer_sync(&bp->timer);
#if defined(<API key>)
if (bp->reset_failed == 0)
bnx2_shutdown_chip(bp);
#else /* <API key> */
bnx2_shutdown_chip(bp);
#endif /* <API key> */
bnx2_free_irq(bp);
bnx2_free_skbs(bp);
bnx2_free_mem(bp);
#if !defined(__VMKLNX__)
bnx2_del_napi(bp);
#endif
bp->link_up = 0;
netif_carrier_off(bp->dev);
return 0;
}
static void
bnx2_save_stats(struct bnx2 *bp)
{
u32 *hw_stats = (u32 *) bp->stats_blk;
u32 *temp_stats = (u32 *) bp->temp_stats_blk;
int i;
/* The 1st 10 counters are 64-bit counters */
for (i = 0; i < 20; i += 2) {
u32 hi;
u64 lo;
hi = temp_stats[i] + hw_stats[i];
lo = (u64) temp_stats[i + 1] + (u64) hw_stats[i + 1];
if (lo > 0xffffffff)
hi++;
temp_stats[i] = hi;
temp_stats[i + 1] = lo & 0xffffffff;
}
for ( ; i < sizeof(struct statistics_block) / 4; i++)
temp_stats[i] += hw_stats[i];
}
#define <API key>(ctr) \
(unsigned long) ((unsigned long) (ctr##_hi) << 32) + \
(unsigned long) (ctr
#define <API key>(ctr) \
(ctr
#if (BITS_PER_LONG == 64)
#define GET_64BIT_NET_STATS(ctr) \
<API key>(bp->stats_blk->ctr) + \
<API key>(bp->temp_stats_blk->ctr)
#else
#define GET_64BIT_NET_STATS(ctr) \
<API key>(bp->stats_blk->ctr) + \
<API key>(bp->temp_stats_blk->ctr)
#endif
#define GET_32BIT_NET_STATS(ctr) \
(unsigned long) (bp->stats_blk->ctr + \
bp->temp_stats_blk->ctr)
static struct net_device_stats *
bnx2_get_stats(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
struct net_device_stats *net_stats = &bp->net_stats;
if (bp->stats_blk == NULL)
return net_stats;
net_stats->rx_packets =
GET_64BIT_NET_STATS(<API key>) +
GET_64BIT_NET_STATS(<API key>) +
GET_64BIT_NET_STATS(<API key>);
net_stats->tx_packets =
GET_64BIT_NET_STATS(<API key>) +
GET_64BIT_NET_STATS(<API key>) +
GET_64BIT_NET_STATS(<API key>);
net_stats->rx_bytes =
GET_64BIT_NET_STATS(stat_IfHCInOctets);
net_stats->tx_bytes =
GET_64BIT_NET_STATS(stat_IfHCOutOctets);
net_stats->multicast =
GET_64BIT_NET_STATS(<API key>);
net_stats->collisions =
GET_32BIT_NET_STATS(<API key>);
net_stats->rx_length_errors =
GET_32BIT_NET_STATS(<API key>) +
GET_32BIT_NET_STATS(<API key>);
net_stats->rx_over_errors =
GET_32BIT_NET_STATS(<API key>) +
GET_32BIT_NET_STATS(<API key>);
net_stats->rx_frame_errors =
GET_32BIT_NET_STATS(<API key>);
net_stats->rx_crc_errors =
GET_32BIT_NET_STATS(<API key>);
net_stats->rx_errors = net_stats->rx_length_errors +
net_stats->rx_over_errors + net_stats->rx_frame_errors +
net_stats->rx_crc_errors;
net_stats->tx_aborted_errors =
GET_32BIT_NET_STATS(<API key>) +
GET_32BIT_NET_STATS(<API key>);
if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) ||
(BNX2_CHIP_ID(bp) == <API key>))
net_stats->tx_carrier_errors = 0;
else {
net_stats->tx_carrier_errors =
GET_32BIT_NET_STATS(<API key>);
}
net_stats->tx_errors =
GET_32BIT_NET_STATS(<API key>) +
net_stats->tx_aborted_errors +
net_stats->tx_carrier_errors;
net_stats->rx_missed_errors =
GET_32BIT_NET_STATS(<API key>) +
GET_32BIT_NET_STATS(<API key>) +
GET_32BIT_NET_STATS(stat_FwRxDrop);
return net_stats;
}
/* All ethtool functions called with rtnl_lock */
static int
bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct bnx2 *bp = netdev_priv(dev);
int support_serdes = 0, support_copper = 0;
cmd->supported = SUPPORTED_Autoneg;
if (bp->phy_flags & <API key>) {
support_serdes = 1;
support_copper = 1;
} else if (bp->phy_port == PORT_FIBRE)
support_serdes = 1;
else
support_copper = 1;
if (support_serdes) {
cmd->supported |= <API key> |
SUPPORTED_FIBRE;
if (bp->phy_flags & <API key>)
cmd->supported |= <API key>;
}
if (support_copper) {
cmd->supported |= <API key> |
<API key> |
<API key> |
<API key> |
<API key> |
SUPPORTED_TP;
}
spin_lock_bh(&bp->phy_lock);
cmd->port = bp->phy_port;
cmd->advertising = bp->advertising;
if (bp->autoneg & AUTONEG_SPEED) {
cmd->autoneg = AUTONEG_ENABLE;
} else {
cmd->autoneg = AUTONEG_DISABLE;
}
if (netif_carrier_ok(dev)) {
<API key>(cmd, bp->line_speed);
cmd->duplex = bp->duplex;
}
else {
<API key>(cmd, -1);
cmd->duplex = -1;
}
spin_unlock_bh(&bp->phy_lock);
cmd->transceiver = XCVR_INTERNAL;
cmd->phy_address = bp->phy_addr;
return 0;
}
static int
bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct bnx2 *bp = netdev_priv(dev);
u8 autoneg = bp->autoneg;
u8 req_duplex = bp->req_duplex;
u16 req_line_speed = bp->req_line_speed;
u32 advertising = bp->advertising;
int err = -EINVAL;
spin_lock_bh(&bp->phy_lock);
if (cmd->port != PORT_TP && cmd->port != PORT_FIBRE)
goto err_out_unlock;
if (cmd->port != bp->phy_port &&
!(bp->phy_flags & <API key>))
goto err_out_unlock;
/* If device is down, we can store the settings only if the user
* is setting the currently active port.
*/
if (!netif_running(dev) && cmd->port != bp->phy_port)
goto err_out_unlock;
if (cmd->autoneg == AUTONEG_ENABLE) {
autoneg |= AUTONEG_SPEED;
advertising = cmd->advertising;
if (cmd->port == PORT_TP) {
advertising &= <API key>;
if (!advertising)
advertising = <API key>;
} else {
advertising &= <API key>;
if (!advertising)
advertising = <API key>;
}
advertising |= ADVERTISED_Autoneg;
}
else {
if (cmd->port == PORT_FIBRE) {
if ((cmd->speed != SPEED_1000 &&
cmd->speed != SPEED_2500) ||
(cmd->duplex != DUPLEX_FULL))
goto err_out_unlock;
if (cmd->speed == SPEED_2500 &&
!(bp->phy_flags & <API key>))
goto err_out_unlock;
}
else if (cmd->speed == SPEED_1000 || cmd->speed == SPEED_2500)
goto err_out_unlock;
autoneg &= ~AUTONEG_SPEED;
req_line_speed = cmd->speed;
req_duplex = cmd->duplex;
advertising = 0;
}
bp->autoneg = autoneg;
bp->advertising = advertising;
bp->req_line_speed = req_line_speed;
bp->req_duplex = req_duplex;
err = 0;
/* If device is down, the new settings will be picked up when it is
* brought up.
*/
if (netif_running(dev))
err = bnx2_setup_phy(bp, cmd->port);
err_out_unlock:
spin_unlock_bh(&bp->phy_lock);
return err;
}
static void
bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
struct bnx2 *bp = netdev_priv(dev);
#if !defined(__VMKLNX__)
strcpy(info->driver, DRV_MODULE_NAME);
strcpy(info->version, DRV_MODULE_VERSION);
strcpy(info->bus_info, pci_name(bp->pdev));
strcpy(info->fw_version, bp->fw_version);
#else /* defined (__VMKLNX__) */
strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info));
strlcpy(info->fw_version, bp->fw_version, sizeof(info->fw_version));
#endif /* !defined(__VMKLNX__) */
#if defined(<API key>) && \
(<API key> >= 35000) && (<API key> < 40000)
info->eedump_len = bnx2_get_eeprom_len(dev);
#endif
}
#define BNX2_REGDUMP_LEN (32 * 1024)
static int
bnx2_get_regs_len(struct net_device *dev)
{
return BNX2_REGDUMP_LEN;
}
static void
bnx2_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)
{
u32 *p = _p, i, offset;
u8 *orig_p = _p;
struct bnx2 *bp = netdev_priv(dev);
static const u32 reg_boundaries[] = {
0x0000, 0x0098, 0x0400, 0x045c,
0x0800, 0x0880, 0x0c00, 0x0c10,
0x0c30, 0x0d08, 0x1000, 0x101c,
0x1040, 0x1048, 0x1080, 0x10a4,
0x1400, 0x1490, 0x1498, 0x14f0,
0x1500, 0x155c, 0x1580, 0x15dc,
0x1600, 0x1658, 0x1680, 0x16d8,
0x1800, 0x1820, 0x1840, 0x1854,
0x1880, 0x1894, 0x1900, 0x1984,
0x1c00, 0x1c0c, 0x1c40, 0x1c54,
0x1c80, 0x1c94, 0x1d00, 0x1d84,
0x2000, 0x2030, 0x23c0, 0x2400,
0x2800, 0x2820, 0x2830, 0x2850,
0x2b40, 0x2c10, 0x2fc0, 0x3058,
0x3c00, 0x3c94, 0x4000, 0x4010,
0x4080, 0x4090, 0x43c0, 0x4458,
0x4c00, 0x4c18, 0x4c40, 0x4c54,
0x4fc0, 0x5010, 0x53c0, 0x5444,
0x5c00, 0x5c18, 0x5c80, 0x5c90,
0x5fc0, 0x6000, 0x6400, 0x6428,
0x6800, 0x6848, 0x684c, 0x6860,
0x6888, 0x6910, 0x8000
};
regs->version = 0;
memset(p, 0, BNX2_REGDUMP_LEN);
if (!netif_running(bp->dev))
return;
i = 0;
offset = reg_boundaries[0];
p += offset;
while (offset < BNX2_REGDUMP_LEN) {
*p++ = BNX2_RD(bp, offset);
offset += 4;
if (offset == reg_boundaries[i + 1]) {
offset = reg_boundaries[i + 2];
p = (u32 *) (orig_p + offset);
i += 2;
}
}
}
static void
bnx2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
struct bnx2 *bp = netdev_priv(dev);
if (bp->flags & BNX2_FLAG_NO_WOL) {
wol->supported = 0;
wol->wolopts = 0;
}
else {
wol->supported = WAKE_MAGIC;
if (bp->wol)
wol->wolopts = WAKE_MAGIC;
else
wol->wolopts = 0;
}
memset(&wol->sopass, 0, sizeof(wol->sopass));
}
static int
bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
struct bnx2 *bp = netdev_priv(dev);
if (wol->wolopts & ~WAKE_MAGIC)
return -EINVAL;
if (wol->wolopts & WAKE_MAGIC) {
if (bp->flags & BNX2_FLAG_NO_WOL)
return -EINVAL;
bp->wol = 1;
}
else {
bp->wol = 0;
}
<API key>(&bp->pdev->dev, bp->wol);
return 0;
}
static u32 bnx2_get_msglevel(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
return bp->msg_enable;
}
static void bnx2_set_msglevel(struct net_device *dev, u32 value)
{
struct bnx2 *bp = netdev_priv(dev);
bp->msg_enable = value;
}
static int
bnx2_nway_reset(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
u32 bmcr;
if (!netif_running(dev))
return -EAGAIN;
if (!(bp->autoneg & AUTONEG_SPEED)) {
return -EINVAL;
}
spin_lock_bh(&bp->phy_lock);
if (bp->phy_flags & <API key>) {
int rc;
rc = <API key>(bp, bp->phy_port);
spin_unlock_bh(&bp->phy_lock);
return rc;
}
/* Force a link down visible on the other side */
if (bp->phy_flags & <API key>) {
bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
spin_unlock_bh(&bp->phy_lock);
bnx2_msleep(20);
spin_lock_bh(&bp->phy_lock);
bp->current_interval = <API key>;
bp->serdes_an_pending = 1;
mod_timer(&bp->timer, jiffies + bp->current_interval);
}
bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
bmcr &= ~BMCR_LOOPBACK;
bnx2_write_phy(bp, bp->mii_bmcr, bmcr | BMCR_ANRESTART | BMCR_ANENABLE);
spin_unlock_bh(&bp->phy_lock);
return 0;
}
static u32
bnx2_get_link(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
return bp->link_up;
}
#if (LINUX_VERSION_CODE >= 0x20418) || \
(defined(<API key>) && \
((<API key> >= 35000) && (<API key> < 40000)))
static int
bnx2_get_eeprom_len(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
if (bp->flash_info == NULL)
return 0;
return (int) bp->flash_size;
}
#endif
#ifdef ETHTOOL_GEEPROM
static int
bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
u8 *eebuf)
{
struct bnx2 *bp = netdev_priv(dev);
int rc;
/* parameters already validated in ethtool_get_eeprom */
rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
return rc;
}
#endif
#ifdef ETHTOOL_SEEPROM
static int
bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
u8 *eebuf)
{
struct bnx2 *bp = netdev_priv(dev);
int rc;
/* parameters already validated in ethtool_set_eeprom */
rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
return rc;
}
#endif
static int
bnx2_get_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
{
struct bnx2 *bp = netdev_priv(dev);
memset(coal, 0, sizeof(struct ethtool_coalesce));
coal->rx_coalesce_usecs = bp->rx_ticks;
coal-><API key> = bp->rx_quick_cons_trip;
coal-><API key> = bp->rx_ticks_int;
coal-><API key> = bp-><API key>;
coal->tx_coalesce_usecs = bp->tx_ticks;
coal-><API key> = bp->tx_quick_cons_trip;
coal-><API key> = bp->tx_ticks_int;
coal-><API key> = bp-><API key>;
coal-><API key> = bp->stats_ticks;
return 0;
}
static int
bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
{
struct bnx2 *bp = netdev_priv(dev);
uint32_t i;
bp->rx_ticks = (u16) coal->rx_coalesce_usecs;
if (bp->rx_ticks > 0x3ff) bp->rx_ticks = 0x3ff;
bp->rx_quick_cons_trip = (u16) coal-><API key>;
if (bp->rx_quick_cons_trip > 0xff) bp->rx_quick_cons_trip = 0xff;
bp->rx_ticks_int = (u16) coal-><API key>;
if (bp->rx_ticks_int > 0x3ff) bp->rx_ticks_int = 0x3ff;
bp-><API key> = (u16) coal-><API key>;
if (bp-><API key> > 0xff)
bp-><API key> = 0xff;
bp->tx_ticks = (u16) coal->tx_coalesce_usecs;
if (bp->tx_ticks > 0x3ff) bp->tx_ticks = 0x3ff;
bp->tx_quick_cons_trip = (u16) coal-><API key>;
if (bp->tx_quick_cons_trip > 0xff) bp->tx_quick_cons_trip = 0xff;
bp->tx_ticks_int = (u16) coal-><API key>;
if (bp->tx_ticks_int > 0x3ff) bp->tx_ticks_int = 0x3ff;
bp-><API key> = (u16) coal-><API key>;
if (bp-><API key> > 0xff) bp-><API key> =
0xff;
bp->stats_ticks = coal-><API key>;
if (bp->flags & <API key>) {
if (bp->stats_ticks != 0 && bp->stats_ticks != USEC_PER_SEC)
bp->stats_ticks = USEC_PER_SEC;
}
if (bp->stats_ticks > <API key>)
bp->stats_ticks = <API key>;
bp->stats_ticks &= <API key>;
if (netif_running(bp->dev)) {
#if (defined(__VMKLNX__) && (<API key> >= 55000))
BNX2_WR(bp, <API key>,
(bp-><API key> << 16) | bp->tx_quick_cons_trip);
BNX2_WR(bp, <API key>,
(bp-><API key> << 16) | bp->rx_quick_cons_trip);
BNX2_WR(bp, BNX2_HC_TX_TICKS, (bp->tx_ticks_int << 16) | bp->tx_ticks);
BNX2_WR(bp, BNX2_HC_RX_TICKS, (bp->rx_ticks_int << 16) | bp->rx_ticks);
if (bp->flags & <API key>)
BNX2_WR(bp, BNX2_HC_STATS_TICKS, 0);
else
BNX2_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks);
if (bp->rx_ticks < 25)
bnx2_reg_wr_ind(bp, <API key>, 1);
else
bnx2_reg_wr_ind(bp, <API key>, 0);
for (i = 1; i < bp->irq_nvecs; i++) {
u32 base = ((i - 1) * <API key>) +
BNX2_HC_SB_CONFIG_1;
BNX2_WR(bp, base,
<API key> |
<API key> |
<API key>);
BNX2_WR(bp, base + <API key>,
(bp-><API key> << 16) |
bp->tx_quick_cons_trip);
BNX2_WR(bp, base + <API key>,
(bp->tx_ticks_int << 16) | bp->tx_ticks);
BNX2_WR(bp, base + <API key>,
(bp-><API key> << 16) |
bp->rx_quick_cons_trip);
BNX2_WR(bp, base + <API key>,
(bp->rx_ticks_int << 16) | bp->rx_ticks);
}
#else
bnx2_netif_stop(bp, true);
bnx2_init_nic(bp, 0);
bnx2_netif_start(bp, true);
#endif /* defined(__VMKLNX__) && (<API key> >= 55000) */
}
return 0;
}
static void
bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
{
struct bnx2 *bp = netdev_priv(dev);
ering->rx_max_pending = <API key>;
ering-><API key> = <API key>;
ering->rx_pending = bp->rx_ring_size;
ering->rx_jumbo_pending = bp->rx_pg_ring_size;
ering->tx_max_pending = <API key>;
ering->tx_pending = bp->tx_ring_size;
}
static int
<API key>(struct bnx2 *bp, u32 rx, u32 tx, bool reset_irq)
{
int rc = 0;
#if defined(__VMKLNX__)
if(bp->reset_failed) {
netdev_err(bp->dev, "Previous error detected preventing MTU "
"change\n");
return -EIO;
}
#endif /* defined(__VMKLNX__) */
if (netif_running(bp->dev)) {
/* Reset will erase chipset stats; save them */
bnx2_save_stats(bp);
bnx2_netif_stop(bp, true);
#if defined(__VMKLNX__)
rc = bnx2_reset_chip(bp, <API key>);
/* Did the chip reset fail ? */
if (rc != 0) {
netdev_err(bp->dev, "chip reset failed during MTU "
"change\n");
bp->reset_failed = 1;
goto error;
}
bnx2_free_irq(bp);
#else /* !defined(__VMKLNX__) */
bnx2_reset_chip(bp, <API key>);
if (reset_irq) {
bnx2_free_irq(bp);
bnx2_del_napi(bp);
} else {
__bnx2_free_irq(bp);
}
#endif /* defined(__VMKLNX__) */
bnx2_free_skbs(bp);
bnx2_free_mem(bp);
}
<API key>(bp, rx);
bp->tx_ring_size = tx;
if (netif_running(bp->dev)) {
if (reset_irq) {
rc = bnx2_setup_int_mode(bp, disable_msi);
bnx2_init_napi(bp);
}
if (!rc)
rc = bnx2_alloc_mem(bp);
#if defined(<API key>)
if (rc) {
netdev_err(bp->dev, "failed alloc mem during MTU "
"change\n");
goto error;
}
rc = bnx2_request_irq(bp);
if (rc) {
netdev_err(bp->dev, "failed request irq during MTU "
"change %d\n", rc);
goto error;
}
rc = bnx2_init_nic(bp, 0);
if (rc) {
netdev_err(bp->dev, "failed init nic during MTU "
"change\n");
goto error;
}
#else /* !defined(<API key>) */
if (!rc)
rc = bnx2_request_irq(bp);
if (!rc)
rc = bnx2_init_nic(bp, 0);
if (rc) {
bnx2_napi_enable(bp);
dev_close(bp->dev);
#if defined(__VMKLNX__) && (<API key> == 41000)
/* PR 533926
* This is a workaround to sync device status in dev->flags and
* dev->gflags. It is needed to avoid PSOD (due to double dev_close)
* on reboot. In ESX5.0, the return value of this function will be
* checked by NICSetMTU, where gflags will be updated appropriately.
*/
bp->dev->gflags &= ~IFF_DEV_IS_OPEN;
#endif
return rc;
}
#endif /* defined(<API key>) */
#ifdef BCM_CNIC
mutex_lock(&bp->cnic_lock);
/* Let cnic know about the new status block. */
if (bp->cnic_eth_dev.drv_state & CNIC_DRV_STATE_REGD)
<API key>(bp);
mutex_unlock(&bp->cnic_lock);
#endif
bnx2_netif_start(bp, true);
}
return 0;
#if defined(__VMKLNX__)
error:
netif_carrier_off(bp->dev);
return rc;
#endif /* defined(__VMKLNX__) */
}
static int
bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
{
struct bnx2 *bp = netdev_priv(dev);
int rc;
if ((ering->rx_pending > <API key>) ||
(ering->tx_pending > <API key>) ||
(ering->tx_pending <= MAX_SKB_FRAGS)) {
return -EINVAL;
}
rc = <API key>(bp, ering->rx_pending, ering->tx_pending,
false);
return rc;
}
static void
bnx2_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
{
struct bnx2 *bp = netdev_priv(dev);
epause->autoneg = ((bp->autoneg & AUTONEG_FLOW_CTRL) != 0);
epause->rx_pause = ((bp->flow_ctrl & FLOW_CTRL_RX) != 0);
epause->tx_pause = ((bp->flow_ctrl & FLOW_CTRL_TX) != 0);
}
static int
bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
{
struct bnx2 *bp = netdev_priv(dev);
bp->req_flow_ctrl = 0;
if (epause->rx_pause)
bp->req_flow_ctrl |= FLOW_CTRL_RX;
if (epause->tx_pause)
bp->req_flow_ctrl |= FLOW_CTRL_TX;
if (epause->autoneg) {
bp->autoneg |= AUTONEG_FLOW_CTRL;
}
else {
bp->autoneg &= ~AUTONEG_FLOW_CTRL;
}
if (netif_running(dev)) {
spin_lock_bh(&bp->phy_lock);
bnx2_setup_phy(bp, bp->phy_port);
spin_unlock_bh(&bp->phy_lock);
}
return 0;
}
#ifndef NEW_ETHTOOL
static u32
bnx2_get_rx_csum(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
return bp->rx_csum;
}
static int
bnx2_set_rx_csum(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
bp->rx_csum = data;
return 0;
}
#ifdef BCM_TSO
static int
bnx2_set_tso(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
if (data) {
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
dev->features |= NETIF_F_TSO6;
} else
dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
NETIF_F_TSO_ECN);
return 0;
}
#endif
#endif
static struct {
char string[ETH_GSTRING_LEN];
} bnx2_stats_str_arr[] = {
{ "rx_bytes" },
{ "rx_error_bytes" },
{ "tx_bytes" },
{ "tx_error_bytes" },
{ "rx_ucast_packets" },
{ "rx_mcast_packets" },
{ "rx_bcast_packets" },
{ "tx_ucast_packets" },
{ "tx_mcast_packets" },
{ "tx_bcast_packets" },
{ "tx_mac_errors" },
{ "tx_carrier_errors" },
{ "rx_crc_errors" },
{ "rx_align_errors" },
{ "<API key>" },
{ "tx_multi_collisions" },
{ "tx_deferred" },
{ "<API key>" },
{ "tx_late_collisions" },
{ "tx_total_collisions" },
{ "rx_fragments" },
{ "rx_jabbers" },
{ "<API key>" },
{ "rx_oversize_packets" },
{ "rx_64_byte_packets" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "tx_64_byte_packets" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "<API key>" },
{ "rx_xon_frames" },
{ "rx_xoff_frames" },
{ "tx_xon_frames" },
{ "tx_xoff_frames" },
{ "rx_mac_ctrl_frames" },
{ "rx_filtered_packets" },
{ "rx_ftq_discards" },
{ "rx_discards" },
{ "rx_fw_discards" },
#if defined(<API key>)
{ "[0] rx_packets" },
{ "[0] rx_bytes" },
{ "[0] rx_errors" },
{ "[0] tx_packets" },
{ "[0] tx_bytes" },
{ "[1] rx_packets" },
{ "[1] rx_bytes" },
{ "[1] rx_errors" },
{ "[1] tx_packets" },
{ "[1] tx_bytes" },
{ "[2] rx_packets" },
{ "[2] rx_bytes" },
{ "[2] rx_errors" },
{ "[2] tx_packets" },
{ "[2] tx_bytes" },
{ "[3] rx_packets" },
{ "[3] rx_bytes" },
{ "[3] rx_errors" },
{ "[3] tx_packets" },
{ "[3] tx_bytes" },
{ "[4] rx_packets" },
{ "[4] rx_bytes" },
{ "[4] rx_errors" },
{ "[4] tx_packets" },
{ "[4] tx_bytes" },
{ "[5] rx_packets" },
{ "[5] rx_bytes" },
{ "[5] rx_errors" },
{ "[5] tx_packets" },
{ "[5] tx_bytes" },
{ "[6] rx_packets" },
{ "[6] rx_bytes" },
{ "[6] rx_errors" },
{ "[6] tx_packets" },
{ "[6] tx_bytes" },
{ "[7] rx_packets" },
{ "[7] rx_bytes" },
{ "[7] rx_errors" },
{ "[7] tx_packets" },
{ "[7] tx_bytes" },
{ "[8] rx_packets" },
{ "[8] rx_bytes" },
{ "[8] rx_errors" },
{ "[8] tx_packets" },
{ "[8] tx_bytes" },
#endif
};
#define BNX2_NUM_STATS ARRAY_SIZE(bnx2_stats_str_arr)
#if defined(<API key>)
#define BNX2_NUM_NETQ_STATS 45
#endif
#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4)
static const unsigned long <API key>[BNX2_NUM_STATS] = {
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(stat_OutXonSent),
STATS_OFFSET32(stat_OutXoffSent),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(<API key>),
STATS_OFFSET32(stat_FwRxDrop),
};
/* <API key> and <API key> are
* skipped because of errata.
*/
static u8 <API key>[BNX2_NUM_STATS] = {
8,0,8,8,8,8,8,8,8,8,
4,0,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,
};
static u8 <API key>[BNX2_NUM_STATS] = {
8,0,8,8,8,8,8,8,8,8,
4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,
};
#define BNX2_NUM_TESTS 6
static struct {
char string[ETH_GSTRING_LEN];
} bnx2_tests_str_arr[BNX2_NUM_TESTS] = {
{ "register_test (offline)" },
{ "memory_test (offline)" },
{ "loopback_test (offline)" },
{ "nvram_test (online)" },
{ "interrupt_test (online)" },
{ "link_test (online)" },
};
#ifdef ETHTOOL_GFLAGS
static int
bnx2_get_sset_count(struct net_device *dev, int sset)
{
switch (sset) {
case ETH_SS_TEST:
return BNX2_NUM_TESTS;
case ETH_SS_STATS:
return BNX2_NUM_STATS;
default:
return -EOPNOTSUPP;
}
}
#else
static int
<API key>(struct net_device *dev)
{
return BNX2_NUM_TESTS;
}
#endif
static void
bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
{
struct bnx2 *bp = netdev_priv(dev);
memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
if (etest->flags & ETH_TEST_FL_OFFLINE) {
int i;
bnx2_netif_stop(bp, true);
bnx2_reset_chip(bp, <API key>);
bnx2_free_skbs(bp);
if (bnx2_test_registers(bp) != 0) {
buf[0] = 1;
etest->flags |= ETH_TEST_FL_FAILED;
}
if (bnx2_test_memory(bp) != 0) {
buf[1] = 1;
etest->flags |= ETH_TEST_FL_FAILED;
}
if ((buf[2] = bnx2_test_loopback(bp)) != 0)
etest->flags |= ETH_TEST_FL_FAILED;
if (!netif_running(bp->dev))
bnx2_shutdown_chip(bp);
else {
bnx2_init_nic(bp, 1);
bnx2_netif_start(bp, true);
}
/* wait for link up */
for (i = 0; i < 7; i++) {
if (bp->link_up)
break;
<API key>(1000);
}
}
if (bnx2_test_nvram(bp) != 0) {
buf[3] = 1;
etest->flags |= ETH_TEST_FL_FAILED;
}
if (bnx2_test_intr(bp) != 0) {
buf[4] = 1;
etest->flags |= ETH_TEST_FL_FAILED;
}
if (bnx2_test_link(bp) != 0) {
buf[5] = 1;
etest->flags |= ETH_TEST_FL_FAILED;
}
}
static void
bnx2_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{
switch (stringset) {
case ETH_SS_STATS:
memcpy(buf, bnx2_stats_str_arr,
sizeof(bnx2_stats_str_arr));
break;
case ETH_SS_TEST:
memcpy(buf, bnx2_tests_str_arr,
sizeof(bnx2_tests_str_arr));
break;
}
}
#ifndef ETHTOOL_GFLAGS
static int
<API key>(struct net_device *dev)
{
return BNX2_NUM_STATS;
}
#endif
static void
<API key>(struct net_device *dev,
struct ethtool_stats *stats, u64 *buf)
{
struct bnx2 *bp = netdev_priv(dev);
int i;
u32 *hw_stats = (u32 *) bp->stats_blk;
u32 *temp_stats = (u32 *) bp->temp_stats_blk;
u8 *stats_len_arr = NULL;
if (hw_stats == NULL) {
memset(buf, 0, sizeof(u64) * BNX2_NUM_STATS);
return;
}
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>))
stats_len_arr = <API key>;
else
stats_len_arr = <API key>;
#if defined(<API key>)
for (i = 0; i < BNX2_NUM_STATS - BNX2_NUM_NETQ_STATS; i++) {
#else
for (i = 0; i < BNX2_NUM_STATS; i++) {
#endif
unsigned long offset;
if (stats_len_arr[i] == 0) {
/* skip this counter */
buf[i] = 0;
continue;
}
offset = <API key>[i];
if (stats_len_arr[i] == 4) {
/* 4-byte counter */
buf[i] = (u64) *(hw_stats + offset) +
*(temp_stats + offset);
continue;
}
/* 8-byte counter */
buf[i] = (((u64) *(hw_stats + offset)) << 32) +
*(hw_stats + offset + 1) +
(((u64) *(temp_stats + offset)) << 32) +
*(temp_stats + offset + 1);
}
#if defined(<API key>)
/* Copy over the NetQ specific statistics */
{
int j;
for (j = 0; j < BNX2_MAX_MSIX_VEC; j++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[j];
buf[i + (j*5) + 0] = (u64) (bnapi->stats.rx_packets);
buf[i + (j*5) + 1] = (u64) (bnapi->stats.rx_bytes);
buf[i + (j*5) + 2] = (u64) (bnapi->stats.rx_errors);
buf[i + (j*5) + 3] = (u64) (bnapi->stats.tx_packets);
buf[i + (j*5) + 4] = (u64) (bnapi->stats.tx_bytes);
}
}
#endif
}
#if (LINUX_VERSION_CODE < 0x30000)
static int
bnx2_phys_id(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
int i;
u32 save;
if (data == 0)
data = 2;
save = BNX2_RD(bp, BNX2_MISC_CFG);
BNX2_WR(bp, BNX2_MISC_CFG, <API key>);
for (i = 0; i < (data * 2); i++) {
if ((i % 2) == 0) {
BNX2_WR(bp, BNX2_EMAC_LED, <API key>);
}
else {
BNX2_WR(bp, BNX2_EMAC_LED, <API key> |
<API key> |
<API key> |
<API key> |
<API key> |
<API key>);
}
<API key>(500);
if (signal_pending(current))
break;
}
BNX2_WR(bp, BNX2_EMAC_LED, 0);
BNX2_WR(bp, BNX2_MISC_CFG, save);
return 0;
}
#else
static int
bnx2_set_phys_id(struct net_device *dev, enum <API key> state)
{
struct bnx2 *bp = netdev_priv(dev);
switch (state) {
case ETHTOOL_ID_ACTIVE:
bp->leds_save = BNX2_RD(bp, BNX2_MISC_CFG);
BNX2_WR(bp, BNX2_MISC_CFG, <API key>);
return 1; /* cycle on/off once per second */
case ETHTOOL_ID_ON:
BNX2_WR(bp, BNX2_EMAC_LED, <API key> |
<API key> |
<API key> |
<API key> |
<API key> |
<API key>);
break;
case ETHTOOL_ID_OFF:
BNX2_WR(bp, BNX2_EMAC_LED, <API key>);
break;
case ETHTOOL_ID_INACTIVE:
BNX2_WR(bp, BNX2_EMAC_LED, 0);
BNX2_WR(bp, BNX2_MISC_CFG, bp->leds_save);
break;
}
return 0;
}
#endif
#if (LINUX_VERSION_CODE >= 0x20418) && !defined(NEW_ETHTOOL)
static int
bnx2_set_tx_csum(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
#if (LINUX_VERSION_CODE < 0x2060c)
return bnx2_set_tx_hw_csum(dev, data);
#elif (LINUX_VERSION_CODE >= 0x20617)
return <API key>(dev, data);
#else
return <API key>(dev, data);
#endif
else
return <API key>(dev, data);
}
#endif
#if defined(NETIF_F_RXHASH) && !defined(NEW_ETHTOOL)
#if (LINUX_VERSION_CODE >= 0x20624)
static int
bnx2_set_flags(struct net_device *dev, u32 data)
{
return <API key>(dev, data, ETH_FLAG_RXHASH);
}
#else
static int
bnx2_set_flags(struct net_device *dev, u32 data)
{
if (data & (ETH_FLAG_LRO | ETH_FLAG_NTUPLE))
return -EOPNOTSUPP;
if (data & ETH_FLAG_RXHASH)
dev->features |= NETIF_F_RXHASH;
else
dev->features &= ~NETIF_F_RXHASH;
return 0;
}
#endif
#endif
#ifdef HAVE_FIX_FEATURES
static netdev_features_t
bnx2_fix_features(struct net_device *dev, netdev_features_t features)
{
struct bnx2 *bp = netdev_priv(dev);
if (!(bp->flags & <API key>))
features |= <API key>;
return features;
}
static int
bnx2_set_features(struct net_device *dev, netdev_features_t features)
{
struct bnx2 *bp = netdev_priv(dev);
/* TSO with VLAN tag won't work with current firmware */
if (features & <API key>)
dev->vlan_features |= (dev->hw_features & NETIF_F_ALL_TSO);
else
dev->vlan_features &= ~NETIF_F_ALL_TSO;
if ((!!(features & <API key>) !=
!!(bp->rx_mode & <API key>)) &&
netif_running(dev)) {
bnx2_netif_stop(bp, false);
dev->features = features;
bnx2_set_rx_mode(dev);
bnx2_fw_sync(bp, <API key>, 0, 1);
bnx2_netif_start(bp, false);
return 1;
}
return 0;
}
#endif
#if defined(ETHTOOL_GCHANNELS) && !defined(GET_ETHTOOL_OP_EXT)
static void bnx2_get_channels(struct net_device *dev,
struct ethtool_channels *channels)
{
struct bnx2 *bp = netdev_priv(dev);
u32 max_rx_rings = 1;
u32 max_tx_rings = 1;
if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) {
max_rx_rings = RX_MAX_RINGS;
max_tx_rings = TX_MAX_RINGS;
}
channels->max_rx = max_rx_rings;
channels->max_tx = max_tx_rings;
channels->max_other = 0;
channels->max_combined = 0;
channels->rx_count = bp->num_rx_rings;
channels->tx_count = bp->num_tx_rings;
channels->other_count = 0;
channels->combined_count = 0;
}
static int bnx2_set_channels(struct net_device *dev,
struct ethtool_channels *channels)
{
struct bnx2 *bp = netdev_priv(dev);
u32 max_rx_rings = 1;
u32 max_tx_rings = 1;
int rc = 0;
if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) {
max_rx_rings = RX_MAX_RINGS;
max_tx_rings = TX_MAX_RINGS;
}
if (channels->rx_count > max_rx_rings ||
channels->tx_count > max_tx_rings)
return -EINVAL;
bp->num_req_rx_rings = channels->rx_count;
bp->num_req_tx_rings = channels->tx_count;
if (netif_running(dev))
rc = <API key>(bp, bp->rx_ring_size,
bp->tx_ring_size, true);
return rc;
}
#endif
static struct ethtool_ops bnx2_ethtool_ops = {
.get_settings = bnx2_get_settings,
.set_settings = bnx2_set_settings,
.get_drvinfo = bnx2_get_drvinfo,
.get_regs_len = bnx2_get_regs_len,
.get_regs = bnx2_get_regs,
.get_wol = bnx2_get_wol,
.set_wol = bnx2_set_wol,
.get_msglevel = bnx2_get_msglevel,
.set_msglevel = bnx2_set_msglevel,
.nway_reset = bnx2_nway_reset,
.get_link = bnx2_get_link,
#if (LINUX_VERSION_CODE >= 0x20418)
.get_eeprom_len = bnx2_get_eeprom_len,
#endif
#ifdef ETHTOOL_GEEPROM
.get_eeprom = bnx2_get_eeprom,
#endif
#ifdef ETHTOOL_SEEPROM
.set_eeprom = bnx2_set_eeprom,
#endif
.get_coalesce = bnx2_get_coalesce,
.set_coalesce = bnx2_set_coalesce,
.get_ringparam = bnx2_get_ringparam,
.set_ringparam = bnx2_set_ringparam,
.get_pauseparam = bnx2_get_pauseparam,
.set_pauseparam = bnx2_set_pauseparam,
#ifndef NEW_ETHTOOL
.get_rx_csum = bnx2_get_rx_csum,
.set_rx_csum = bnx2_set_rx_csum,
.get_tx_csum = <API key>,
#if (LINUX_VERSION_CODE >= 0x20418)
.set_tx_csum = bnx2_set_tx_csum,
#endif
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
#ifdef BCM_TSO
.get_tso = ethtool_op_get_tso,
.set_tso = bnx2_set_tso,
#endif
#endif
#ifndef ETHTOOL_GFLAGS
.self_test_count = <API key>,
#endif
.self_test = bnx2_self_test,
.get_strings = bnx2_get_strings,
#if (LINUX_VERSION_CODE < 0x30000)
.phys_id = bnx2_phys_id,
#else
.set_phys_id = bnx2_set_phys_id,
#endif
#ifndef ETHTOOL_GFLAGS
.get_stats_count = <API key>,
#endif
.get_ethtool_stats = <API key>,
#ifdef ETHTOOL_GPERMADDR
#if (LINUX_VERSION_CODE < 0x020617)
.get_perm_addr = <API key>,
#endif
#endif
#ifdef ETHTOOL_GFLAGS
.get_sset_count = bnx2_get_sset_count,
#endif
#if defined(NETIF_F_RXHASH) && !defined(NEW_ETHTOOL)
.set_flags = bnx2_set_flags,
.get_flags = <API key>,
#endif
#if defined(ETHTOOL_GCHANNELS) && !defined(GET_ETHTOOL_OP_EXT)
.get_channels = bnx2_get_channels,
.set_channels = bnx2_set_channels,
#endif
};
#if defined(<API key>)
static int
bnx2_ioctl_cim(struct net_device *dev, struct ifreq *ifr)
{
struct bnx2 *bp = netdev_priv(dev);
void __user *useraddr = ifr->ifr_data;
struct bnx2_ioctl_req req;
int rc = 0;
u32 val;
if (copy_from_user(&req, useraddr, sizeof(req))) {
netdev_err(bp->dev, "bnx2_ioctl() could not copy from user");
return -EFAULT;
}
switch(req.cmd) {
case <API key>:
BNX2_DP(BNX2_MSG_ESX_IOCTL, "enable NIC\n");
rc = bnx2_open(bp->dev);
break;
case <API key>:
BNX2_DP(BNX2_MSG_ESX_IOCTL, "disable NIC\n");
rc = bnx2_close(bp->dev);
break;
case <API key>: {
struct <API key> *rd_req;
u32 mem_len;
#if defined(__VMKLNX__) && defined(<API key>)
mem_len = MB_GET_CID_ADDR(NETQUEUE_KCQ_CID + 2);
#else
mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1);
#endif
rd_req = &req.cmd_req.reg_read;
switch (rd_req->reg_access_type) {
case <API key>:
if (mem_len < rd_req->reg_offset) {
netdev_err(bp->dev,
"bnx2_ioctl() reg read: "
"out of range: "
"max reg: 0x%x req reg: 0x%x\n",
mem_len, rd_req->reg_offset);
rc = -EINVAL;
break;
}
val = BNX2_RD(bp, req.cmd_req.reg_read.reg_offset);
BNX2_DP(BNX2_MSG_ESX_IOCTL,
"reg read: reg: 0x%x value:0x%x\n",
rd_req->reg_offset, rd_req->reg_value);
rd_req->reg_value = val;
break;
case <API key>:
BNX2_DP(BNX2_MSG_ESX_IOCTL,
"PCI config reg read: reg: 0x%x value:0x%x\n",
rd_req->reg_offset, rd_req->reg_value);
<API key>(bp->pdev,
rd_req->reg_offset, &val);
rd_req->reg_value = val;
break;
case <API key>:
mem_len = 0x240800;
if (mem_len < rd_req->reg_offset) {
netdev_err(bp->dev,
"bnx2_ioctl() indirect reg read: "
"out of range: "
"max reg: 0x%x req reg: 0x%x\n",
mem_len, rd_req->reg_offset);
rc = -EINVAL;
break;
}
val = bnx2_reg_rd_ind(bp, rd_req->reg_offset);
BNX2_DP(BNX2_MSG_ESX_IOCTL,
"indirect reg read: reg: 0x%x value:0x%x",
rd_req->reg_offset,
rd_req->reg_value);
rd_req->reg_value = val;
break;
default:
netdev_err(bp->dev,
"invalid reg read access method: "
"access type: 0x%x req reg: 0x%x\n",
rd_req->reg_access_type, rd_req->reg_offset);
rc = -EINVAL;
break;
}
} case <API key>: {
struct <API key> *wr_req;
u32 mem_len;
#if defined(__VMKLNX__) && defined(<API key>)
mem_len = MB_GET_CID_ADDR(NETQUEUE_KCQ_CID + 2);
#else
mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1);
#endif
wr_req = &req.cmd_req.reg_write;
switch (wr_req->reg_access_type) {
case <API key>:
if (mem_len < req.cmd_req.reg_write.reg_offset) {
netdev_err(bp->dev,
"bnx2_ioctl() reg write: "
"out of range: max reg: 0x%x "
"req reg: 0x%x\n",
mem_len, req.cmd_req.reg_write.reg_offset);
rc = -EINVAL;
break;
}
BNX2_DP(BNX2_MSG_ESX_IOCTL,
"reg write: reg: 0x%x value:0x%x\n",
wr_req->reg_offset, wr_req->reg_value);
BNX2_WR(bp, wr_req->reg_offset, wr_req->reg_value);
break;
case <API key>:
netdev_info(bp->dev,
"bnx2_ioctl() PCI config reg write: "
"reg: 0x%x value:0x%x\n",
wr_req->reg_offset, wr_req->reg_value);
<API key>(bp->pdev, wr_req->reg_offset,
wr_req->reg_value);
break;
case <API key>:
mem_len = 0x240800;
if (mem_len < wr_req->reg_offset) {
netdev_err(bp->dev,
"bnx2_ioctl() indirect reg write: "
"out of range: "
"max reg: 0x%x req reg: 0x%x\n",
mem_len, wr_req->reg_offset);
rc = -EINVAL;
break;
}
bnx2_reg_wr_ind(bp, wr_req->reg_offset,
wr_req->reg_value);
BNX2_DP(BNX2_MSG_ESX_IOCTL,
"indirect reg write: reg: 0x%x value:0x%x\n",
wr_req->reg_offset, wr_req->reg_value);
wr_req->reg_value = val;
break;
default:
netdev_err(bp->dev,
"invalid reg write access method: "
"access type: 0x%x reg: 0x%x\n",
wr_req->reg_access_type,
wr_req->reg_offset);
rc = -EINVAL;
break;
}
} case <API key>:
BNX2_DP(BNX2_MSG_ESX_IOCTL, "get NIC param\n");
req.cmd_req.get_nic_param.mtu = dev->mtu;
memcpy(req.cmd_req.get_nic_param.current_mac_addr,
dev->dev_addr,
sizeof(req.cmd_req.get_nic_param.current_mac_addr));
break;
case <API key>:
BNX2_DP(BNX2_MSG_ESX_IOCTL, "get NIC status\n");
req.cmd_req.get_nic_status.nic_status = netif_running(dev);
break;
default:
netdev_warn(bp->dev, "bnx2_ioctl() unknown req.cmd: 0x%x\n",
req.cmd);
rc = -EINVAL;
}
if (rc == 0 &&
copy_to_user(useraddr, &req, sizeof(req))) {
netdev_err(bp->dev, "bnx2_ioctl() couldn't copy to user "
"bnx2_ioctl_req\n");
return -EFAULT;
}
return rc;
}
#endif /* <API key> */
/* Called with rtnl_lock */
static int
bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
#if (LINUX_VERSION_CODE >= 0x020607)
struct mii_ioctl_data *data = if_mii(ifr);
#else
struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_ifru;
#endif
struct bnx2 *bp = netdev_priv(dev);
int err;
switch(cmd) {
case SIOCGMIIPHY:
data->phy_id = bp->phy_addr;
/* fallthru */
case SIOCGMIIREG: {
u32 mii_regval;
if (bp->phy_flags & <API key>)
return -EOPNOTSUPP;
if (!netif_running(dev))
return -EAGAIN;
spin_lock_bh(&bp->phy_lock);
err = bnx2_read_phy(bp, data->reg_num & 0x1f, &mii_regval);
spin_unlock_bh(&bp->phy_lock);
data->val_out = mii_regval;
return err;
}
case SIOCSMIIREG:
#if defined(__VMKLNX__)
if (!capable(CAP_NET_ADMIN))
return -EPERM;
#endif
if (bp->phy_flags & <API key>)
return -EOPNOTSUPP;
if (!netif_running(dev))
return -EAGAIN;
spin_lock_bh(&bp->phy_lock);
err = bnx2_write_phy(bp, data->reg_num & 0x1f, data->val_in);
spin_unlock_bh(&bp->phy_lock);
return err;
#if defined(<API key>)
#define SIOBNX2CIM 0x89F0
case SIOBNX2CIM:
return bnx2_ioctl_cim(dev, ifr);
#endif /* <API key> */
default:
/* do nothing */
break;
}
return -EOPNOTSUPP;
}
#if defined(__VMKLNX__)
static int
bnx2_vmk_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
int rc;
#if (<API key> < 50000)
/* rtnl_lock() needed for ESX 4.0 and 4.1 only */
rtnl_lock();
#endif
rc = bnx2_ioctl(dev, ifr, cmd);
#if (<API key> < 50000)
rtnl_unlock();
#endif
return rc;
}
#endif
/* Called with rtnl_lock */
static int
<API key>(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
struct bnx2 *bp = netdev_priv(dev);
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
if (netif_running(dev))
bnx2_set_mac_addr(bp, bp->dev->dev_addr, 0);
return 0;
}
/* Called with rtnl_lock */
static int
bnx2_change_mtu(struct net_device *dev, int new_mtu)
{
struct bnx2 *bp = netdev_priv(dev);
if (((new_mtu + ETH_HLEN) > <API key>) ||
((new_mtu + ETH_HLEN) < <API key>))
return -EINVAL;
dev->mtu = new_mtu;
return (<API key>(bp, bp->rx_ring_size, bp->tx_ring_size,
false));
}
#if defined(__VMKLNX__)
static int
bnx2_vmk_change_mtu(struct net_device *dev, int new_mtu)
{
int rc;
#if (<API key> < 50000)
/* rtnl_lock() needed for ESX 4.0 and 4.1 only */
rtnl_lock();
#endif
rc = bnx2_change_mtu(dev, new_mtu);
#if (<API key> < 50000)
rtnl_unlock();
#endif
return rc;
}
#endif
#if defined(<API key>) || defined(<API key>)
static void
poll_bnx2(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
#if defined(<API key>) && (LINUX_VERSION_CODE < 0x020600)
if (netdump_mode) {
struct bnx2_irq *irq = &bp->irq_tbl[0];
irq_handler(irq->vector, &bp->bnx2_napi[0], NULL);
if (dev->poll_list.prev) {
int budget = 64;
bnx2_poll(dev, &budget);
}
}
else
#endif
{
int i;
for (i = 0; i < bp->irq_nvecs; i++) {
struct bnx2_irq *irq = &bp->irq_tbl[i];
disable_irq(irq->vector);
#if (LINUX_VERSION_CODE >= 0x20613) || (defined(__VMKLNX__) && (<API key> >= 40000))
irq->handler(irq->vector, &bp->bnx2_napi[i]);
#else
irq->handler(irq->vector, &bp->bnx2_napi[i], NULL);
#endif
enable_irq(irq->vector);
}
}
}
#endif
static void __devinit
bnx2_get_5709_media(struct bnx2 *bp)
{
u32 val = BNX2_RD(bp, <API key>);
u32 bond_id = val & <API key>;
u32 strap;
if (bond_id == <API key>)
return;
else if (bond_id == <API key>) {
bp->phy_flags |= <API key>;
return;
}
if (val & <API key>)
strap = (val & <API key>) >> 21;
else
strap = (val & <API key>) >> 8;
if (bp->func == 0) {
switch (strap) {
case 0x4:
case 0x5:
case 0x6:
bp->phy_flags |= <API key>;
return;
}
} else {
switch (strap) {
case 0x1:
case 0x2:
case 0x4:
bp->phy_flags |= <API key>;
return;
}
}
}
static void __devinit
bnx2_get_pci_speed(struct bnx2 *bp)
{
u32 reg;
reg = BNX2_RD(bp, <API key>);
if (reg & <API key>) {
u32 clkreg;
bp->flags |= BNX2_FLAG_PCIX;
clkreg = BNX2_RD(bp, <API key>);
clkreg &= <API key>;
switch (clkreg) {
case <API key>:
bp->bus_speed_mhz = 133;
break;
case <API key>:
bp->bus_speed_mhz = 100;
break;
case <API key>:
case <API key>:
bp->bus_speed_mhz = 66;
break;
case <API key>:
case <API key>:
bp->bus_speed_mhz = 50;
break;
case <API key>:
case <API key>:
case <API key>:
bp->bus_speed_mhz = 33;
break;
}
}
else {
if (reg & <API key>)
bp->bus_speed_mhz = 66;
else
bp->bus_speed_mhz = 33;
}
if (reg & <API key>)
bp->flags |= BNX2_FLAG_PCI_32BIT;
}
static void __devinit
<API key>(struct bnx2 *bp)
{
int rc, i, v0_len = 0;
u8 *data;
u8 *v0_str = NULL;
bool mn_match = false;
#define <API key> 0x300
#define BNX2_VPD_LEN 128
#define BNX2_MAX_VER_SLEN 30
data = kmalloc(256, GFP_KERNEL);
if (!data)
return;
rc = bnx2_nvram_read(bp, <API key>, data + BNX2_VPD_LEN,
BNX2_VPD_LEN);
if (rc)
goto vpd_done;
for (i = 0; i < BNX2_VPD_LEN; i += 4) {
data[i] = data[i + BNX2_VPD_LEN + 3];
data[i + 1] = data[i + BNX2_VPD_LEN + 2];
data[i + 2] = data[i + BNX2_VPD_LEN + 1];
data[i + 3] = data[i + BNX2_VPD_LEN];
}
for (i = 0; i <= BNX2_VPD_LEN - 3; ) {
unsigned char val = data[i];
unsigned int block_end;
if (val == 0x82 || val == 0x91) {
i = (i + 3 + (data[i + 1] + (data[i + 2] << 8)));
continue;
}
if (val != 0x90)
goto vpd_done;
block_end = (i + 3 + (data[i + 1] + (data[i + 2] << 8)));
i += 3;
if (block_end > BNX2_VPD_LEN)
goto vpd_done;
while (i < (block_end - 2)) {
int len = data[i + 2];
if (i + 3 + len > block_end)
goto vpd_done;
if (data[i] == 'M' && data[i + 1] == 'N') {
if (len != 4 ||
memcmp(&data[i + 3], "1028", 4))
goto vpd_done;
mn_match = true;
} else if (data[i] == 'V' && data[i + 1] == '0') {
if (len > BNX2_MAX_VER_SLEN)
goto vpd_done;
v0_len = len;
v0_str = &data[i + 3];
}
i += 3 + len;
if (mn_match && v0_str) {
memcpy(bp->fw_version, v0_str, v0_len);
bp->fw_version[v0_len] = ' ';
goto vpd_done;
}
}
goto vpd_done;
}
vpd_done:
kfree(data);
}
static int __devinit
bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
{
struct bnx2 *bp;
int rc, i, j;
u32 reg;
u64 dma_mask, persist_dma_mask;
int __maybe_unused err;
#if (LINUX_VERSION_CODE < 0x20610)
SET_MODULE_OWNER(dev);
#endif
#if (LINUX_VERSION_CODE >= 0x20419)
SET_NETDEV_DEV(dev, &pdev->dev);
#endif
bp = netdev_priv(dev);
bp->flags = 0;
bp->phy_flags = 0;
bp->temp_stats_blk =
kmalloc(sizeof(struct statistics_block), GFP_KERNEL);
if (bp->temp_stats_blk == NULL) {
rc = -ENOMEM;
goto err_out;
}
memset(bp->temp_stats_blk, 0, sizeof(struct statistics_block));
/* enable device (incl. PCI PM wakeup), and bus-mastering */
rc = pci_enable_device(pdev);
if (rc) {
dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n");
goto err_out;
}
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
dev_err(&pdev->dev,
"Cannot find PCI device base address, aborting\n");
rc = -ENODEV;
goto err_out_disable;
}
rc = pci_request_regions(pdev, DRV_MODULE_NAME);
if (rc) {
dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n");
goto err_out_disable;
}
pci_set_master(pdev);
bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
if (bp->pm_cap == 0) {
dev_err(&pdev->dev,
"Cannot find power management capability, aborting\n");
rc = -EIO;
goto err_out_release;
}
bp->dev = dev;
bp->pdev = pdev;
spin_lock_init(&bp->phy_lock);
spin_lock_init(&bp->indirect_lock);
#if defined(<API key>)
mutex_init(&bp->netq_lock);
#endif
#ifdef BCM_CNIC
mutex_init(&bp->cnic_lock);
#endif
#if (LINUX_VERSION_CODE >= 0x20600)
#if defined(<API key>) || defined(INIT_WORK_NAR) || defined(<API key>) || (defined(__VMKLNX__) && (<API key> >= 40000))
INIT_WORK(&bp->reset_task, bnx2_reset_task);
#else
INIT_WORK(&bp->reset_task, bnx2_reset_task, bp);
#endif
#else
INIT_TQUEUE(&bp->reset_task, bnx2_reset_task, bp);
#endif
#if defined(<API key>)
bp->regview = pci_iomap(pdev, 0, MB_GET_CID_ADDR(NETQUEUE_KCQ_CID + 2));
#else
bp->regview = pci_iomap(pdev, 0, MB_GET_CID_ADDR(TX_TSS_CID +
TX_MAX_TSS_RINGS + 1));
#endif
if (!bp->regview) {
dev_err(&pdev->dev, "Cannot map register space, aborting\n");
rc = -ENOMEM;
goto err_out_release;
}
/* Configure byte swap and enable write to the reg_window registers.
* Rely on CPU to do target byte swapping on big endian systems
* The chip's target access swapping will not swap all accesses
*/
BNX2_WR(bp, <API key>,
<API key> |
<API key>);
bp->chip_id = BNX2_RD(bp, BNX2_MISC_ID);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if (!pci_is_pcie(pdev)) {
dev_err(&pdev->dev, "Not PCIE, aborting\n");
rc = -EIO;
goto err_out_unmap;
}
bp->flags |= BNX2_FLAG_PCIE;
if (BNX2_CHIP_REV(bp) == BNX2_CHIP_REV_Ax)
bp->flags |= <API key>;
#if !defined(CONFIG_PPC64) && !defined(CONFIG_PPC32)
/* AER (Advanced Error Reporting) hooks */
err = <API key>(pdev);
if (!err)
bp->flags |= <API key>;
#endif
} else {
bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
if (bp->pcix_cap == 0) {
dev_err(&pdev->dev,
"Cannot find PCIX capability, aborting\n");
rc = -EIO;
goto err_out_unmap;
}
bp->flags |= <API key>;
}
#ifdef CONFIG_PCI_MSI
if (BNX2_CHIP(bp) == BNX2_CHIP_5709 && BNX2_CHIP_REV(bp) != BNX2_CHIP_REV_Ax) {
if (pci_find_capability(pdev, PCI_CAP_ID_MSIX))
bp->flags |= BNX2_FLAG_MSIX_CAP;
}
#endif
if (BNX2_CHIP_ID(bp) != <API key> && BNX2_CHIP_ID(bp) != <API key>) {
if (pci_find_capability(pdev, PCI_CAP_ID_MSI))
bp->flags |= BNX2_FLAG_MSI_CAP;
}
/* 5708 cannot support DMA addresses > 40-bit. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5708)
persist_dma_mask = dma_mask = DMA_BIT_MASK(40);
else
persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
/* Configure DMA attributes. */
if (pci_set_dma_mask(pdev, dma_mask) == 0) {
#if defined(__VMKLNX__) && (<API key> >= 50000)
if (BNX2_CHIP(bp) == BNX2_CHIP_5708)
dev->features |= NETIF_F_DMA40;
else
dev->features |= NETIF_F_HIGHDMA;
#else
dev->features |= NETIF_F_HIGHDMA;
#endif
rc = <API key>(pdev, persist_dma_mask);
if (rc) {
dev_err(&pdev->dev,
"<API key> failed, aborting\n");
goto err_out_unmap;
}
} else if ((rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) {
dev_err(&pdev->dev, "System does not support DMA, aborting\n");
goto err_out_unmap;
}
if (!(bp->flags & BNX2_FLAG_PCIE))
bnx2_get_pci_speed(bp);
/* 5706A0 may falsely detect SERR and PERR. */
if (BNX2_CHIP_ID(bp) == <API key>) {
reg = BNX2_RD(bp, PCI_COMMAND);
reg &= ~(PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
BNX2_WR(bp, PCI_COMMAND, reg);
}
else if ((BNX2_CHIP_ID(bp) == <API key>) &&
!(bp->flags & BNX2_FLAG_PCIX)) {
dev_err(&pdev->dev,
"5706 A1 can only be used in a PCIX bus, aborting\n");
goto err_out_unmap;
}
bnx2_init_nvram(bp);
reg = bnx2_reg_rd_ind(bp, <API key>);
if (bnx2_reg_rd_ind(bp, BNX2_MCP_TOE_ID) & <API key>)
bp->func = 1;
if ((reg & <API key>) ==
<API key>) {
u32 off = bp->func << 2;
bp->shmem_base = bnx2_reg_rd_ind(bp, BNX2_SHM_HDR_ADDR_0 + off);
} else
bp->shmem_base = <API key>;
/* Get the permanent MAC address. First we need to make sure the
* firmware is actually running.
*/
reg = bnx2_shmem_rd(bp, <API key>);
if ((reg & <API key>) !=
<API key>) {
dev_err(&pdev->dev, "Firmware not running, aborting\n");
rc = -ENODEV;
goto err_out_unmap;
}
<API key>(bp);
j = strlen(bp->fw_version);
reg = bnx2_shmem_rd(bp, <API key>);
for (i = 0; i < 3 && j < 24; i++) {
u8 num, k, skip0;
if (i == 0) {
bp->fw_version[j++] = 'b';
bp->fw_version[j++] = 'c';
bp->fw_version[j++] = ' ';
}
num = (u8) (reg >> (24 - (i * 8)));
for (k = 100, skip0 = 1; k >= 1; num %= k, k /= 10) {
if (num >= k || !skip0 || k == 1) {
bp->fw_version[j++] = (num / k) + '0';
skip0 = 0;
}
}
if (i != 2)
bp->fw_version[j++] = '.';
}
reg = bnx2_shmem_rd(bp, BNX2_PORT_FEATURE);
if (reg & <API key>)
bp->wol = 1;
if (reg & <API key>) {
bp->flags |= <API key>;
for (i = 0; i < 30; i++) {
reg = bnx2_shmem_rd(bp, <API key>);
if (reg & <API key>)
break;
bnx2_msleep(10);
}
}
reg = bnx2_shmem_rd(bp, <API key>);
reg &= <API key>;
if (reg != <API key> &&
reg != <API key>) {
u32 addr = bnx2_shmem_rd(bp, BNX2_MFW_VER_PTR);
if (j < 32)
bp->fw_version[j++] = ' ';
for (i = 0; i < 3 && j < 28; i++) {
reg = bnx2_reg_rd_ind(bp, addr + i * 4);
reg = be32_to_cpu(reg);
memcpy(&bp->fw_version[j], ®, 4);
j += 4;
}
}
reg = bnx2_shmem_rd(bp, <API key>);
bp->mac_addr[0] = (u8) (reg >> 8);
bp->mac_addr[1] = (u8) reg;
reg = bnx2_shmem_rd(bp, <API key>);
bp->mac_addr[2] = (u8) (reg >> 24);
bp->mac_addr[3] = (u8) (reg >> 16);
bp->mac_addr[4] = (u8) (reg >> 8);
bp->mac_addr[5] = (u8) reg;
bp->tx_ring_size = <API key>;
<API key>(bp, 255);
bp->rx_csum = 1;
bp-><API key> = 2;
bp->tx_quick_cons_trip = 20;
bp->tx_ticks_int = 18;
bp->tx_ticks = 80;
bp-><API key> = 2;
bp->rx_quick_cons_trip = 12;
bp->rx_ticks_int = 18;
bp->rx_ticks = 18;
bp->stats_ticks = USEC_PER_SEC & <API key>;
bp->current_interval = BNX2_TIMER_INTERVAL;
bp->phy_addr = 1;
/* Disable WOL support if we are running on a SERDES chip. */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
bnx2_get_5709_media(bp);
else if (BNX2_CHIP_BOND(bp) & <API key>)
bp->phy_flags |= <API key>;
bp->phy_port = PORT_TP;
if (bp->phy_flags & <API key>) {
bp->phy_port = PORT_FIBRE;
reg = bnx2_shmem_rd(bp, <API key>);
if (!(reg & <API key>)) {
bp->flags |= BNX2_FLAG_NO_WOL;
bp->wol = 0;
}
if (BNX2_CHIP(bp) == BNX2_CHIP_5706) {
/* Don't do parallel detect on this board because of
* some board problems. The link will not go down
* if we do parallel detect.
*/
if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
pdev->subsystem_device == 0x310c)
bp->phy_flags |= <API key>;
} else {
bp->phy_addr = 2;
if (reg & <API key>)
bp->phy_flags |= <API key>;
}
} else if (BNX2_CHIP(bp) == BNX2_CHIP_5706 ||
BNX2_CHIP(bp) == BNX2_CHIP_5708)
bp->phy_flags |= <API key>;
else if (BNX2_CHIP(bp) == BNX2_CHIP_5709 &&
(BNX2_CHIP_REV(bp) == BNX2_CHIP_REV_Ax ||
BNX2_CHIP_REV(bp) == BNX2_CHIP_REV_Bx))
bp->phy_flags |= <API key>;
bp->fw_wr_seq = bnx2_shmem_rd(bp, BNX2_FW_MB) & BNX2_FW_MSG_ACK;
bnx2_init_fw_cap(bp);
if ((BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>) ||
(BNX2_CHIP_ID(bp) == <API key>) ||
!(BNX2_RD(bp, BNX2_PCI_CONFIG_3) & <API key>)) {
bp->flags |= BNX2_FLAG_NO_WOL;
bp->wol = 0;
}
if (bp->flags & BNX2_FLAG_NO_WOL)
<API key>(&bp->pdev->dev, false);
else
<API key>(&bp->pdev->dev, bp->wol);
if (BNX2_CHIP_ID(bp) == <API key>) {
bp-><API key> =
bp->tx_quick_cons_trip;
bp->tx_ticks_int = bp->tx_ticks;
bp-><API key> =
bp->rx_quick_cons_trip;
bp->rx_ticks_int = bp->rx_ticks;
bp->comp_prod_trip_int = bp->comp_prod_trip;
bp->com_ticks_int = bp->com_ticks;
bp->cmd_ticks_int = bp->cmd_ticks;
}
#ifdef CONFIG_PCI_MSI
#if defined(__VMKLNX__)
/* PR496996: There is some additional setup needed for the P2P
* ServerWorks bridge with VID/DID of 0x1666/0x0036 when
* 5706 is plugged into an IBM system x3655 server and MSI
* is used. Since that workaround cannot be done using
* vmklinux api, we are disabling MSI on 5706 to avoid PSOD.
*/
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
disable_msi = 1;
#else /* !defined(__VMKLNX__) */
if (BNX2_CHIP(bp) == BNX2_CHIP_5706 && disable_msi == 0) {
struct pci_dev *amd_8132 = NULL;
while ((amd_8132 = pci_get_device(PCI_VENDOR_ID_AMD,
<API key>,
amd_8132))) {
u8 rev;
<API key>(amd_8132, PCI_REVISION_ID, &rev);
if (rev >= 0x10 && rev <= 0x13) {
disable_msi = 1;
pci_dev_put(amd_8132);
break;
}
}
}
#endif /* defined(__VMKLNX__) */
#endif
<API key>(bp);
bp->req_flow_ctrl = FLOW_CTRL_RX | FLOW_CTRL_TX;
init_timer(&bp->timer);
bp->timer.expires = RUN_AT(BNX2_TIMER_INTERVAL);
bp->timer.data = (unsigned long) bp;
bp->timer.function = bnx2_timer;
#ifdef BCM_CNIC
if (bnx2_shmem_rd(bp, <API key>) & <API key>)
bp->cnic_eth_dev.max_iscsi_conn =
(bnx2_shmem_rd(bp, BNX2_ISCSI_MAX_CONN) &
<API key>) >> <API key>;
bp->version = BNX2_DEV_VER;
#if defined(BNX2_INBOX)
bp->cnic_probe = bnx2_cnic_probe;
#else
bp->cnic_probe = bnx2_cnic_probe2;
#endif
#endif
#if (LINUX_VERSION_CODE >= 0x020611)
pci_save_state(pdev);
#endif
return 0;
err_out_unmap:
if (bp->flags & <API key>) {
<API key>(pdev);
bp->flags &= ~<API key>;
}
pci_iounmap(pdev, bp->regview);
bp->regview = NULL;
err_out_release:
pci_release_regions(pdev);
err_out_disable:
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
err_out:
return rc;
}
static char * __devinit
bnx2_bus_string(struct bnx2 *bp, char *str)
{
char *s = str;
if (bp->flags & BNX2_FLAG_PCIE) {
s += sprintf(s, "PCI Express");
} else {
s += sprintf(s, "PCI");
if (bp->flags & BNX2_FLAG_PCIX)
s += sprintf(s, "-X");
if (bp->flags & BNX2_FLAG_PCI_32BIT)
s += sprintf(s, " 32-bit");
else
s += sprintf(s, " 64-bit");
s += sprintf(s, " %dMHz", bp->bus_speed_mhz);
}
return str;
}
#if !defined(__VMKLNX__)
static void
bnx2_del_napi(struct bnx2 *bp)
#else
static void __devinit
bnx2_del_napi(struct bnx2 *bp)
#endif
{
#ifdef BNX2_NEW_NAPI
int i;
for (i = 0; i < bp->irq_nvecs; i++)
netif_napi_del(&bp->bnx2_napi[i].napi);
#endif
}
#if !defined(__VMKLNX__)
static void
bnx2_init_napi(struct bnx2 *bp)
#else
static void __devinit
bnx2_init_napi(struct bnx2 *bp)
#endif
{
int i;
for (i = 0; i < bp->irq_nvecs; i++) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
#ifdef BNX2_NEW_NAPI
int (*poll)(struct napi_struct *, int);
if (i == 0)
poll = bnx2_poll;
else
poll = bnx2_poll_msix;
netif_napi_add(bp->dev, &bp->bnx2_napi[i].napi, poll, 64);
#endif
bnapi->bp = bp;
}
#ifndef BNX2_NEW_NAPI
bp->dev->poll = bnx2_poll;
bp->dev->weight = 64;
#endif
}
#if defined(HAVE_NET_DEVICE_OPS) || (LINUX_VERSION_CODE >= 0x30000)
static const struct net_device_ops bnx2_netdev_ops = {
.ndo_open = bnx2_open,
.ndo_start_xmit = bnx2_start_xmit,
.ndo_stop = bnx2_close,
.ndo_get_stats = bnx2_get_stats,
.ndo_set_rx_mode = bnx2_set_rx_mode,
#if defined(__VMKLNX__)
.ndo_do_ioctl = bnx2_vmk_ioctl,
#else
.ndo_do_ioctl = bnx2_ioctl,
#endif
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = <API key>,
#if defined(__VMKLNX__)
.ndo_change_mtu = bnx2_vmk_change_mtu,
#else
.ndo_change_mtu = bnx2_change_mtu,
#endif
#ifdef HAVE_FIX_FEATURES
.ndo_fix_features = bnx2_fix_features,
.ndo_set_features = bnx2_set_features,
#endif
.ndo_tx_timeout = bnx2_tx_timeout,
#if defined(BCM_VLAN) && !defined(NEW_VLAN)
.<API key> = <API key>,
#endif
#if defined(<API key>) || defined(<API key>)
.ndo_poll_controller = poll_bnx2,
#endif
};
#endif
static inline void vlan_features_add(struct net_device *dev, unsigned long flags)
{
#if (LINUX_VERSION_CODE >= 0x2061a)
#ifdef BCM_VLAN
dev->vlan_features |= flags;
#endif
#endif
}
static int __devinit
bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int version_printed = 0;
struct net_device *dev;
struct bnx2 *bp;
int rc;
char str[40];
DECLARE_MAC_BUF(mac);
#if (defined(__VMKLNX__) && (<API key> >= 55000)) || \
(defined(<API key>))
static int index = 0;
#endif
if (version_printed++ == 0)
pr_info("%s", version);
/* dev zeroed in init_etherdev */
#if (LINUX_VERSION_CODE >= 0x20418)
#ifndef <API key>
dev = alloc_etherdev(sizeof(*bp));
#else
dev = alloc_etherdev_mq(sizeof(*bp), TX_MAX_RINGS);
#endif
#else
dev = init_etherdev(NULL, sizeof(*bp));
#endif
if (!dev)
return -ENOMEM;
rc = bnx2_init_board(pdev, dev);
if (rc < 0)
goto err_free;
#if !defined(HAVE_NET_DEVICE_OPS) && (LINUX_VERSION_CODE < 0x30000)
dev->open = bnx2_open;
dev->hard_start_xmit = bnx2_start_xmit;
dev->stop = bnx2_close;
dev->get_stats = bnx2_get_stats;
#ifdef <API key>
dev->set_rx_mode = bnx2_set_rx_mode;
#else
dev->set_multicast_list = bnx2_set_rx_mode;
#endif
#if defined(__VMKLNX__)
dev->do_ioctl = bnx2_vmk_ioctl;
#else
dev->do_ioctl = bnx2_ioctl;
#endif
dev->set_mac_address = <API key>;
#if defined(__VMKLNX__)
dev->change_mtu = bnx2_vmk_change_mtu;
#else
dev->change_mtu = bnx2_change_mtu;
#endif
dev->tx_timeout = bnx2_tx_timeout;
#ifdef BCM_VLAN
dev->vlan_rx_register = <API key>;
#if (LINUX_VERSION_CODE < 0x20616)
dev->vlan_rx_kill_vid = <API key>;
#endif
#endif
#if defined(<API key>) || defined(<API key>)
dev->poll_controller = poll_bnx2;
#endif
#else
dev->netdev_ops = &bnx2_netdev_ops;
#endif
dev->watchdog_timeo = TX_TIMEOUT;
dev->ethtool_ops = &bnx2_ethtool_ops;
bp = netdev_priv(dev);
/* NAPI add must be called in bnx2_init_one() on ESX so that the
* proper affinity will be assigned */
bp->msg_enable = debug;
#if defined(__VMKLNX__)
bnx2_setup_int_mode(bp, disable_msi);
bnx2_init_napi(bp);
#endif /* (__VMKLNX__)*/
pci_set_drvdata(pdev, dev);
memcpy(dev->dev_addr, bp->mac_addr, 6);
#ifdef ETHTOOL_GPERMADDR
memcpy(dev->perm_addr, bp->mac_addr, 6);
#endif
#ifdef NETIF_F_IPV6_CSUM
dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
#if defined(NETIF_F_GRO) && defined(BNX2_NEW_NAPI)
dev->features |= NETIF_F_GRO;
#endif
#ifdef NETIF_F_RXHASH
dev->features |= NETIF_F_RXHASH;
#endif
vlan_features_add(dev, NETIF_F_IP_CSUM | NETIF_F_SG);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
dev->features |= NETIF_F_IPV6_CSUM;
vlan_features_add(dev, NETIF_F_IPV6_CSUM);
}
#else
dev->features |= NETIF_F_SG;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
dev->features |= NETIF_F_HW_CSUM;
else
dev->features |= NETIF_F_IP_CSUM;
#endif
#ifdef BCM_VLAN
dev->features |= <API key> | <API key>;
#endif
#ifdef BCM_TSO
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
dev->features |= NETIF_F_TSO6;
vlan_features_add(dev, NETIF_F_TSO6);
}
#endif
#if defined(__VMKLNX__) && (<API key> >= 50000)
if (BNX2_CHIP(bp) == BNX2_CHIP_5706 ||
BNX2_CHIP(bp) == BNX2_CHIP_5708) {
dev->features |= NETIF_F_NO_SCHED;
}
#endif
#if (defined(__VMKLNX__) && (<API key> >= 55000)) || \
(defined(<API key>))
bp->index = index;
index++;
#endif
#if defined(<API key>)
/* If enabled register the NetQueue callbacks */
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if (<API key>(bp))
<API key>(dev, bnx2_netqueue_ops);
}
#endif
#if defined(__VMKLNX__) && (<API key> >= 55000)
fwdmp_bp_ptr[bp->index] = bp;
#endif
#if (LINUX_VERSION_CODE >= 0x20418)
if ((rc = register_netdev(dev))) {
dev_err(&pdev->dev, "Cannot register net device\n");
goto error;
}
#endif
netdev_info(dev, "%s (%c%d) %s found at mem %lx, IRQ %d, "
"node addr %s\n", board_info[ent->driver_data].name,
((BNX2_CHIP_ID(bp) & 0xf000) >> 12) + 'A',
((BNX2_CHIP_ID(bp) & 0x0ff0) >> 4),
bnx2_bus_string(bp, str), (long)pci_resource_start(pdev, 0),
bp->pdev->irq, print_mac(mac, dev->dev_addr));
#if defined(<API key>)
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
if (<API key>(bp)) {
netdev_info(bp->dev, "NetQueue Ops registered [%d]\n",
bp->index);
} else
netdev_info(bp->dev, "NetQueue Ops not registered "
"[%d]\n",
bp->index);
}
#endif
return 0;
error:
pci_iounmap(pdev, bp->regview);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
err_free:
#if (LINUX_VERSION_CODE >= 0x20418)
free_netdev(dev);
#else
unregister_netdev(dev);
kfree(dev);
#endif
return rc;
}
static void __devexit
bnx2_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
#if defined(__VMKLNX__)
bnx2_del_napi(bp);
bnx2_disable_msi(bp);
#endif /* !(defined __VMKLNX__) */
unregister_netdev(dev);
del_timer_sync(&bp->timer);
#if (LINUX_VERSION_CODE >= 0x20616) || defined(__VMKLNX__)
cancel_work_sync(&bp->reset_task);
#elif (LINUX_VERSION_CODE >= 0x20600)
<API key>();
#endif
pci_iounmap(bp->pdev, bp->regview);
kfree(bp->temp_stats_blk);
if (bp->flags & <API key>) {
<API key>(pdev);
bp->flags &= ~<API key>;
}
#if (LINUX_VERSION_CODE >= 0x20418)
free_netdev(dev);
#else
kfree(dev);
#endif
<API key>(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
}
static int
#ifdef SIMPLE_DEV_PM_OPS
bnx2_suspend(struct device *device)
#else
bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
#endif
{
#ifdef SIMPLE_DEV_PM_OPS
struct pci_dev *pdev = to_pci_dev(device);
#endif
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
#if (LINUX_VERSION_CODE >= 0x2060b) && !defined(SIMPLE_DEV_PM_OPS)
/* PCI register 4 needs to be saved whether netif_running() or not.
* MSI address and data need to be saved if using MSI and
* netif_running().
*/
pci_save_state(pdev);
#endif
if (netif_running(dev)) {
#if (LINUX_VERSION_CODE >= 0x20616) || defined(__VMKLNX__)
cancel_work_sync(&bp->reset_task);
#endif
bnx2_netif_stop(bp, true);
netif_device_detach(dev);
del_timer_sync(&bp->timer);
bnx2_shutdown_chip(bp);
__bnx2_free_irq(bp);
bnx2_free_skbs(bp);
}
#ifdef SIMPLE_DEV_PM_OPS
bnx2_setup_wol(bp);
#else
#if (LINUX_VERSION_CODE < 0x2060b)
<API key>(bp, state);
#else
<API key>(bp, pci_choose_state(pdev, state));
#endif
#endif
return 0;
}
static int
#ifdef SIMPLE_DEV_PM_OPS
bnx2_resume(struct device *device)
#else
bnx2_resume(struct pci_dev *pdev)
#endif
{
#ifdef SIMPLE_DEV_PM_OPS
struct pci_dev *pdev = to_pci_dev(device);
#endif
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
#if (LINUX_VERSION_CODE >= 0x2060b) && !defined(SIMPLE_DEV_PM_OPS)
pci_restore_state(pdev);
#endif
if (!netif_running(dev))
return 0;
<API key>(bp, PCI_D0);
netif_device_attach(dev);
bnx2_request_irq(bp);
bnx2_init_nic(bp, 1);
bnx2_netif_start(bp, true);
return 0;
}
#ifdef SIMPLE_DEV_PM_OPS
#ifdef CONFIG_PM_SLEEP
static SIMPLE_DEV_PM_OPS(bnx2_pm_ops, bnx2_suspend, bnx2_resume);
#define BNX2_PM_OPS (&bnx2_pm_ops)
#else
#define BNX2_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP */
#endif
#if !defined(__VMKLNX__)
#if (LINUX_VERSION_CODE >= 0x020611)
/**
* <API key> - called when PCI error is detected
* @pdev: Pointer to PCI device
* @state: The current pci connection state
*
* This function is called after a PCI bus error affecting
* this device has been detected.
*/
static pci_ers_result_t <API key>(struct pci_dev *pdev,
pci_channel_state_t state)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
rtnl_lock();
netif_device_detach(dev);
if (state == <API key>) {
rtnl_unlock();
return <API key>;
}
if (netif_running(dev)) {
bnx2_netif_stop(bp, true);
del_timer_sync(&bp->timer);
bnx2_reset_nic(bp, <API key>);
}
pci_disable_device(pdev);
rtnl_unlock();
/* Request a slot slot reset. */
return <API key>;
}
/**
* bnx2_io_slot_reset - called after the pci bus has been reset.
* @pdev: Pointer to PCI device
*
* Restart the card from scratch, as if from a cold-boot.
*/
static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
pci_ers_result_t result = <API key>;
int err = 0;
rtnl_lock();
if (pci_enable_device(pdev)) {
dev_err(&pdev->dev,
"Cannot re-enable PCI device after reset\n");
} else {
pci_set_master(pdev);
pci_restore_state(pdev);
pci_save_state(pdev);
if (netif_running(dev))
err = bnx2_init_nic(bp, 1);
if (!err)
result = <API key>;
}
if (result != <API key> && netif_running(dev)) {
bnx2_napi_enable(bp);
dev_close(bp->dev);
}
rtnl_unlock();
if (!(bp->flags & <API key>))
return result;
err = <API key>(pdev);
if (err) {
dev_err(&pdev->dev,
"<API key> failed 0x%0x\n",
err); /* non-fatal, continue */
}
return result;
}
/**
* bnx2_io_resume - called when traffic can start flowing again.
* @pdev: Pointer to PCI device
*
* This callback is called when the error recovery driver tells us that
* its OK to resume normal operation.
*/
static void bnx2_io_resume(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
rtnl_lock();
if (netif_running(dev))
bnx2_netif_start(bp, true);
netif_device_attach(dev);
rtnl_unlock();
}
static struct pci_error_handlers bnx2_err_handler = {
.error_detected = <API key>,
.slot_reset = bnx2_io_slot_reset,
.resume = bnx2_io_resume,
};
#endif
#endif
#if (LINUX_VERSION_CODE >= 0x02060c)
static void bnx2_shutdown(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp;
if (!dev)
return;
bp = netdev_priv(dev);
if (!bp)
return;
rtnl_lock();
if (netif_running(dev))
dev_close(bp->dev);
if (system_state == SYSTEM_POWER_OFF)
<API key>(bp, PCI_D3hot);
rtnl_unlock();
}
#endif
static struct pci_driver bnx2_pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = bnx2_pci_tbl,
.probe = bnx2_init_one,
.remove = __devexit_p(bnx2_remove_one),
#ifdef SIMPLE_DEV_PM_OPS
.driver.pm = BNX2_PM_OPS,
#else
.suspend = bnx2_suspend,
.resume = bnx2_resume,
#endif
#if !defined(__VMKLNX__)
#if (LINUX_VERSION_CODE >= 0x020611)
.err_handler = &bnx2_err_handler,
#endif
#endif
#if (LINUX_VERSION_CODE >= 0x02060c)
.shutdown = bnx2_shutdown,
#endif
};
static int __init bnx2_init(void)
{
int rc = 0;
#if defined(__VMKLNX__) && (<API key> >= 55000)
VMK_ReturnStatus status;
#endif
#if defined(<API key>)
int i;
/* sanity check the force_netq parameter */
for (i = 0; i < BNX2_MAX_NIC; i++) {
if((force_netq_param[i] < BNX2_OPTION_UNSET) ||
(force_netq_param[i] > 7)) {
pr_err("bnx2: please use a 'force_netq' "
"value between (-1 to 7), "
"0 to disable NetQueue, "
"-1 to use the default value "
"failure at index %d val: %d\n",
i, force_netq_param[i]);
rc = -EINVAL;
}
}
if(rc != 0)
return rc;
#endif
#if (LINUX_VERSION_CODE < 0x020613)
rc = pci_module_init(&bnx2_pci_driver);
#else
rc = pci_register_driver(&bnx2_pci_driver);
#endif
#if defined(__VMKLNX__) && (<API key> >= 50000)
#if defined(BNX2_INBOX)
if (<API key>("bnx2", bnx2_cnic_probe) < 0) {
#else /* !defined(BNX2_INBOX) */
if (<API key>("bnx2", bnx2_cnic_probe2) < 0) {
#endif /* defined(BNX2_INBOX) */
pr_warn("bnx2: Unable to register with CNIC adapter\n");
/*
* We won't call <API key>(&bnx2_pci_driver) here,
* because we still want to retain L2 funtion
* even if <API key> failed
*/
} else {
<API key> = 1;
}
#endif /* defined(__VMKLNX__) && (<API key> >= 50000) */
#if defined(__VMKLNX__) && (<API key> >= 55000)
if (!disable_fw_dmp) {
fwdmp_va_ptr = kzalloc(BNX2_FWDMP_SIZE, GFP_KERNEL);
if (!fwdmp_va_ptr)
pr_warn("bnx2: Unable to allocate memory "
"for firmware dump handler!\n");
else {
status = <API key>(BNX2_DUMPNAME,
bnx2_fwdmp_callback,
NULL,
BNX2_DUMPNAME,
&bnx2_fwdmp_dh);
if (status != VMK_OK)
pr_warn("bnx2: Unable to register firmware "
"dump handler (rc = 0x%x!)\n",
status);
}
}
#endif
return rc;
}
static void __exit bnx2_cleanup(void)
{
#if defined(__VMKLNX__)
#if (<API key> >= 55000)
if (bnx2_fwdmp_dh) {
VMK_ReturnStatus status;
status = <API key>(bnx2_fwdmp_dh);
if (status != VMK_OK) {
VMK_ASSERT(0);
} else {
pr_info("bnx2: firmware dump handler (%p)"
" unregistered!\n",
bnx2_fwdmp_dh);
}
}
kfree(fwdmp_va_ptr);
fwdmp_va_ptr = NULL;
#endif
#if (<API key> >= 50000)
if (<API key>) {
<API key>("bnx2");
<API key> = 0;
}
#endif
#endif /* defined(__VMKLNX__) */
<API key>(&bnx2_pci_driver);
}
module_init(bnx2_init);
module_exit(bnx2_cleanup);
#if defined(<API key>)
#ifdef BNX2_DEBUG
static u32 bnx2_read_ctx(struct bnx2 *bp, u32 offset)
{
int i;
if (BNX2_CHIP(bp) != BNX2_CHIP_5709) {
BNX2_WR(bp, BNX2_CTX_DATA_ADR, offset);
return BNX2_RD(bp, BNX2_CTX_DATA);
}
BNX2_WR(bp, BNX2_CTX_CTX_CTRL, offset | <API key>);
for (i = 0; i < 5; i++) {
udelay(5);
if (BNX2_RD(bp, BNX2_CTX_CTX_CTRL) & <API key>)
continue;
break;
}
return BNX2_RD(bp, BNX2_CTX_CTX_DATA);
}
static void dump_ctx(struct bnx2 *bp, u32 cid)
{
u32 addr = cid * 128;
int i;
for (i = 0; i < 8; i++) {
u32 val, val1, val2, val3;
val = bnx2_read_ctx(bp, addr);
val1 = bnx2_read_ctx(bp, addr+4);
val2 = bnx2_read_ctx(bp, addr+8);
val3 = bnx2_read_ctx(bp, addr+0xc);
netdev_err(bp->dev, "ctx %08x: %08x %08x %08x %08x\n",
addr, val, val1, val2, val3);
addr += 0x10;
}
}
#endif
#define <API key> msecs_to_jiffies(1000)
#define L2_KWQ_PAGE_CNT 1
#define L2_KCQ_PAGE_CNT 1
#define L2_KWQE_CNT (BNX2_PAGE_SIZE / sizeof(struct l2_kwqe))
#define L2_KCQE_CNT (BNX2_PAGE_SIZE / sizeof(struct l2_kcqe))
#define MAX_L2_KWQE_CNT (L2_KWQE_CNT - 1)
#define MAX_L2_KCQE_CNT (L2_KCQE_CNT - 1)
#define MAX_L2_KWQ_IDX ((L2_KWQ_PAGE_CNT * L2_KWQE_CNT) - 1)
#define MAX_L2_KCQ_IDX ((L2_KCQ_PAGE_CNT * L2_KCQE_CNT) - 1)
#define L2_KWQ_PG(x) (((x) & ~MAX_L2_KWQE_CNT) >> (BNX2_PAGE_BITS - 5))
#define L2_KWQ_IDX(x) ((x) & MAX_L2_KWQE_CNT)
#define L2_KCQ_PG(x) (((x) & ~MAX_L2_KCQE_CNT) >> (BNX2_PAGE_BITS - 5))
#define L2_KCQ_IDX(x) ((x) & MAX_L2_KCQE_CNT)
/*
* krnlq_context definition
*/
#define L2_KRNLQ_FLAGS 0x00000000
#define L2_KRNLQ_SIZE 0x00000000
#define L2_KRNLQ_TYPE 0x00000000
#define KRNLQ_FLAGS_PG_SZ (0xf<<0)
#define <API key> (0<<0)
#define <API key> (1<<0)
#define <API key> (2<<0)
#define <API key> (3<<0)
#define <API key> (4<<0)
#define <API key> (5<<0)
#define <API key> (6<<0)
#define <API key> (7<<0)
#define <API key> (8<<0)
#define <API key> (9<<0)
#define <API key> (10<<0)
#define <API key> (11<<0)
#define <API key> (12<<0)
#define <API key> (13<<0)
#define <API key> (1<<15)
#define <API key> ((((0x28 + 0x1f) & ~0x1f) / 0x20) << 16)
#define KRNLQ_TYPE_TYPE (0xf<<28)
#define <API key> (0<<28)
#define <API key> (6<<28)
#define L2_KRNLQ_HOST_QIDX 0x00000004
#define <API key> 0x00000008
#define <API key> 0x0000000c
#define <API key> 0x0000000c
#define <API key> 0x00000010
#define <API key> 0x00000014
#define <API key> 0x00000018
#define L2_KRNLQ_NX_PG_QIDX 0x00000018
#define <API key> 0x0000001c
#define L2_KRNLQ_QIDX_INCR 0x0000001c
#define <API key> 0x00000020
#define <API key> 0x00000024
#define BNX2_PG_CTX_MAP 0x1a0034
static int
<API key>(struct net_device *netdev, int index);
static int
<API key>(struct bnx2 *bp)
{
rmb();
return ((<API key>(bp)) &&
(bp->flags & <API key>) &&
(BNX2_CHIP(bp) == BNX2_CHIP_5709));
}
static inline u32
<API key>(struct bnx2 *bp)
{
return MAX_L2_KWQ_IDX -
((bp->netq_kwq_prod_idx - bp->netq_kwq_con_idx) &
MAX_L2_KWQ_IDX);
}
static int
<API key>(struct bnx2 *bp, struct l2_kwqe *wqes)
{
struct l2_kwqe *prod_qe;
u16 prod, sw_prod;
if (1 > <API key>(bp)) {
netdev_warn(bp->dev, "No kwq's available\n");
return -EAGAIN;
}
prod = bp->netq_kwq_prod_idx;
sw_prod = prod & MAX_L2_KWQ_IDX;
prod_qe = &bp->netq_kwq[L2_KWQ_PG(sw_prod)][L2_KWQ_IDX(sw_prod)];
memcpy(prod_qe, wqes, sizeof(struct l2_kwqe));
prod++;
sw_prod = prod & MAX_L2_KWQ_IDX;
bp->netq_kwq_prod_idx = prod;
barrier();
BNX2_WR16(bp, bp->netq_kwq_io_addr, bp->netq_kwq_prod_idx);
wmb();
mmiowb();
return 0;
}
static void
<API key>(struct bnx2 *bp, struct netq_dma *dma)
{
int i;
if (dma->pg_arr) {
for (i = 0; i < dma->num_pages; i++) {
if (dma->pg_arr[i]) {
pci_free_consistent(bp->pdev, BNX2_PAGE_SIZE,
dma->pg_arr[i],
dma->pg_map_arr[i]);
dma->pg_arr[i] = NULL;
}
}
}
if (dma->pgtbl) {
pci_free_consistent(bp->pdev, dma->pgtbl_size,
dma->pgtbl, dma->pgtbl_map);
dma->pgtbl = NULL;
}
kfree(dma->pg_arr);
dma->pg_arr = NULL;
dma->num_pages = 0;
}
static void
<API key>(struct bnx2 *bp)
{
<API key>(bp, &bp->netq_kwq_info);
<API key>(bp, &bp->netq_kcq_info);
}
static void
<API key>(struct bnx2 *bp,
struct netq_dma *dma)
{
int i;
u32 *page_table = dma->pgtbl;
for (i = 0; i < dma->num_pages; i++) {
/* Each entry needs to be in big endian format. */
*page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32);
page_table++;
*page_table = (u32) dma->pg_map_arr[i];
page_table++;
}
}
static int
<API key>(struct bnx2 *bp, struct netq_dma *dma,
int pages)
{
int i, size;
size = pages * (sizeof(void *) + sizeof(dma_addr_t));
dma->pg_arr = kzalloc(size, GFP_ATOMIC);
if (dma->pg_arr == NULL) {
netdev_err(bp->dev, "Couldn't alloc dma page array\n");
return -ENOMEM;
}
dma->pg_map_arr = (dma_addr_t *) (dma->pg_arr + pages);
dma->num_pages = pages;
for (i = 0; i < pages; i++) {
dma->pg_arr[i] = <API key>(bp->pdev,
BNX2_PAGE_SIZE,
&dma->pg_map_arr[i]);
if (dma->pg_arr[i] == NULL) {
netdev_err(bp->dev, "Couldn't alloc dma page\n");
goto error;
}
}
dma->pgtbl_size = ((pages * 8) + BNX2_PAGE_SIZE - 1) &
~(BNX2_PAGE_SIZE - 1);
dma->pgtbl = <API key>(bp->pdev, dma->pgtbl_size,
&dma->pgtbl_map);
if (dma->pgtbl == NULL)
goto error;
<API key>(bp, dma);
return 0;
error:
<API key>(bp, dma);
return -ENOMEM;
}
static int
<API key>(struct bnx2 *bp)
{
int ret;
ret = <API key>(bp, &bp->netq_kwq_info,
L2_KWQ_PAGE_CNT);
if (ret) {
netdev_err(bp->dev, "Couldn't alloc space for kwq\n");
goto error;
}
bp->netq_kwq = (struct l2_kwqe **) bp->netq_kwq_info.pg_arr;
ret = <API key>(bp, &bp->netq_kcq_info,
L2_KCQ_PAGE_CNT);
if (ret) {
netdev_err(bp->dev, "Couldn't alloc space for kwq\n");
goto error;
}
bp->netq_kcq = (struct l2_kcqe **) bp->netq_kcq_info.pg_arr;
return 0;
error:
<API key>(bp);
bp->netq_kwq = NULL;
bp->netq_kcq = NULL;
return ret;
}
static void
<API key>(struct bnx2 *bp, u32 cid)
{
u32 cid_addr;
int i;
cid_addr = GET_CID_ADDR(cid);
for (i = 0; i < CTX_SIZE; i += 4)
bnx2_ctx_wr(bp, cid_addr, i, 0);
}
static int
<API key>(struct bnx2 *bp, u16 hw_prod, u16 *sw_prod)
{
u16 i, ri, last;
struct l2_kcqe *kcqe;
int kcqe_cnt = 0, last_cnt = 0;
i = ri = last = *sw_prod;
ri &= MAX_L2_KCQ_IDX;
while ((i != hw_prod) && (kcqe_cnt < <API key>)) {
kcqe = &bp->netq_kcq[L2_KCQ_PG(ri)][L2_KCQ_IDX(ri)];
bp->netq_completed_kcq[kcqe_cnt++] = kcqe;
i = (i + 1);
ri = i & MAX_L2_KCQ_IDX;
if (likely(!(kcqe->flags & L2_KCQE_FLAGS_NEXT))) {
last_cnt = kcqe_cnt;
last = i;
}
}
*sw_prod = last;
return last_cnt;
}
static void
<API key>(struct bnx2_napi *bnapi, int num_cqes)
{
struct bnx2 *bp = bnapi->bp;
int i, j;
i = 0;
j = 1;
while (num_cqes) {
u32 kcqe_op_flag = bp->netq_completed_kcq[i]->opcode;
u32 kcqe_layer = bp->netq_completed_kcq[i]->flags &
<API key>;
while (j < num_cqes) {
u32 next_op = bp->netq_completed_kcq[i + j]->opcode;
if ((next_op & <API key>) != kcqe_layer)
break;
j++;
}
if (kcqe_layer != <API key>) {
netdev_err(bp->dev, "Unknown type of KCQE(0x%x)\n",
kcqe_op_flag);
goto end;
}
bp->netq_flags = kcqe_op_flag;
wake_up(&bp->netq_wait);
wmb();
end:
num_cqes -= j;
i += j;
j = 1;
}
return;
}
static void
<API key>(struct bnx2_napi *bnapi)
{
struct bnx2 *bp = bnapi->bp;
struct status_block *status_blk = bp->bnx2_napi[0].status_blk.msi;
u32 status_idx = status_blk->status_idx;
u16 hw_prod, sw_prod;
int kcqe_cnt;
bp->netq_kwq_con_idx = status_blk-><API key>;
hw_prod = status_blk-><API key>;
sw_prod = bp->netq_kcq_prod_idx;
/* Ensure that there is a NetQ kcq avaliable */
if (sw_prod == hw_prod)
return;
while (sw_prod != hw_prod) {
kcqe_cnt = <API key>(bp, hw_prod, &sw_prod);
if (kcqe_cnt == 0)
goto done;
<API key>(bnapi, kcqe_cnt);
/* Tell compiler that status_blk fields can change. */
barrier();
if (status_idx != status_blk->status_idx) {
status_idx = status_blk->status_idx;
bp->netq_kwq_con_idx = status_blk-><API key>;
hw_prod = status_blk-><API key>;
} else
break;
}
barrier();
done:
BNX2_WR16(bp, bp->netq_kcq_io_addr, sw_prod);
bp->netq_kcq_prod_idx = sw_prod;
bp-><API key> = status_idx;
}
static void
bnx2_close_netqueue(struct bnx2 *bp)
{
if (<API key>(bp) &&
(bp->netq_state == <API key>))
<API key>(bp);
if (<API key>(bp))
<API key>(bp);
if (<API key>(bp))
<API key>(bp);
<API key>(bp->dev);
}
static int
<API key>(struct bnx2 *bp)
{
return (((bp->netq_state & <API key>) ==
<API key>) &&
((bp->netq_state & BNX2_NETQ_HW_OPENED) ==
BNX2_NETQ_HW_OPENED));
}
static void
<API key>(struct bnx2 *bp)
{
u32 val;
/* Disable the CP and COM doorbells. These two processors polls the
* doorbell for a non zero value before running. This must be done
* after setting up the kernel queue contexts. This is for
* KQW/KCQ #1. */
val = bnx2_reg_rd_ind(bp, BNX2_CP_SCRATCH + 0x20);
val &= ~KWQ1_READY;
bnx2_reg_wr_ind(bp, BNX2_CP_SCRATCH + 0x20, val);
val = bnx2_reg_rd_ind(bp, BNX2_COM_SCRATCH + 0x20);
val &= ~KCQ1_READY;
bnx2_reg_wr_ind(bp, BNX2_COM_SCRATCH + 0x20, val);
barrier();
bp->netq_state &= ~<API key>;
wmb();
}
static void
<API key>(struct bnx2 * bp)
{
int index;
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if(bnapi->netq_state & <API key>) {
bnapi->rx_queue_active = FALSE;
bnapi->netq_state &= ~<API key>;
netdev_info(bp->dev, "NetQ force removed RX filter: %d\n", index);
}
if (bnapi->rx_queue_allocated == TRUE) {
bnapi->rx_queue_allocated = FALSE;
bp-><API key>
netdev_info(bp->dev, "Force free NetQ RX Queue %d\n", index);
}
}
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if(bnapi->tx_queue_allocated == TRUE) {
bnapi->tx_queue_allocated = FALSE;
bp-><API key>
netdev_info(bp->dev, "Force free NetQ TX Queue: 0x%x\n", index);
}
}
}
static void
bnx2_stop_netqueue(struct bnx2 *bp)
{
netif_tx_disable(bp->dev);
bp->dev->trans_start = jiffies; /* prevent tx timeout */
if (<API key>(bp) &&
(bp->netq_state & <API key>)) {
<API key>(bp);
}
<API key>(bp);
}
static void
<API key>(struct bnx2 *bp)
{
<API key>(bp);
<API key>(bp);
bp->netq_state &= ~BNX2_NETQ_HW_OPENED;
wmb();
}
static void
<API key>(struct bnx2 *bp)
{
/* Set the CP and COM doorbells. These two processors polls the
* doorbell for a non zero value before running. This must be done
* after setting up the kernel queue contexts. This is for
* KQW/KCQ 1. */
bnx2_reg_wr_ind(bp, BNX2_CP_SCRATCH + 0x20, KWQ1_READY);
bnx2_reg_wr_ind(bp, BNX2_COM_SCRATCH + 0x20, KCQ1_READY);
bp->netq_state |= <API key>;
wmb();
}
static void
<API key>(struct bnx2 *bp)
{
u32 val;
/* Initialize the bnx2 netqueue structures */
init_waitqueue_head(&bp->netq_wait);
val = BNX2_RD(bp, BNX2_MQ_CONFIG);
val &= ~<API key>;
if (BNX2_PAGE_BITS > 12)
val |= (12 - 8) << 4;
else
val |= (BNX2_PAGE_BITS - 8) << 4;
BNX2_WR(bp, BNX2_MQ_CONFIG, val);
BNX2_WR(bp, <API key>, (2 << 16) | 8);
BNX2_WR(bp, BNX2_HC_COM_TICKS, (64 << 16) | 220);
BNX2_WR(bp, BNX2_HC_CMD_TICKS, (64 << 16) | 220);
<API key>(bp, NETQUEUE_KWQ_CID);
<API key>(bp, NETQUEUE_KCQ_CID);
bp->netq_kwq_cid_addr = GET_CID_ADDR(NETQUEUE_KWQ_CID);
bp->netq_kwq_io_addr = MB_GET_CID_ADDR(NETQUEUE_KWQ_CID) +
L2_KRNLQ_HOST_QIDX;
bp->netq_kwq_prod_idx = 0;
bp->netq_kwq_con_idx = 0;
/* Initialize the kernel work queue context. */
val = <API key> | <API key> |
(BNX2_PAGE_BITS - 8) | <API key>;
bnx2_ctx_wr(bp, bp->netq_kwq_cid_addr, L2_KRNLQ_TYPE, val);
val = (BNX2_PAGE_SIZE / sizeof(struct l2_kwqe) - 1) << 16;
bnx2_ctx_wr(bp, bp->netq_kwq_cid_addr, <API key>, val);
val = ((BNX2_PAGE_SIZE / sizeof(struct l2_kwqe)) << 16) | L2_KWQ_PAGE_CNT;
bnx2_ctx_wr(bp, bp->netq_kwq_cid_addr, <API key>, val);
val = (u32) ((u64) bp->netq_kwq_info.pgtbl_map >> 32);
bnx2_ctx_wr(bp, bp->netq_kwq_cid_addr, <API key>, val);
val = (u32) bp->netq_kwq_info.pgtbl_map;
bnx2_ctx_wr(bp, bp->netq_kwq_cid_addr, <API key>, val);
bp->netq_kcq_cid_addr = GET_CID_ADDR(NETQUEUE_KCQ_CID);
bp->netq_kcq_io_addr = MB_GET_CID_ADDR(NETQUEUE_KCQ_CID) +
L2_KRNLQ_HOST_QIDX;
bp->netq_kcq_prod_idx = 0;
/* Initialize the kernel complete queue context. */
val = <API key> | <API key> |
(BNX2_PAGE_BITS - 8) | <API key>;
bnx2_ctx_wr(bp, bp->netq_kcq_cid_addr, L2_KRNLQ_TYPE, val);
val = (BNX2_PAGE_SIZE / sizeof(struct l2_kcqe) - 1) << 16;
bnx2_ctx_wr(bp, bp->netq_kcq_cid_addr, <API key>, val);
val = ((BNX2_PAGE_SIZE / sizeof(struct l2_kcqe)) << 16)|L2_KCQ_PAGE_CNT;
bnx2_ctx_wr(bp, bp->netq_kcq_cid_addr, <API key>, val);
val = (u32) ((u64) bp->netq_kcq_info.pgtbl_map >> 32);
bnx2_ctx_wr(bp, bp->netq_kcq_cid_addr, <API key>, val);
val = (u32) bp->netq_kcq_info.pgtbl_map;
bnx2_ctx_wr(bp, bp->netq_kcq_cid_addr, <API key>, val);
/* Enable Commnad Scheduler notification when we write to the
* host producer index of the kernel contexts. */
BNX2_WR(bp, <API key>, 2);
/* Enable Command Scheduler notification when we write to either
* the Send Queue or Receive Queue producer indexes of the kernel
* bypass contexts. */
BNX2_WR(bp, <API key>, 7);
BNX2_WR(bp, <API key>, 7);
/* Notify COM when the driver post an application buffer. */
BNX2_WR(bp, <API key>, 0x2000);
barrier();
}
static void
bnx2_start_netqueue(struct bnx2 *bp)
{
<API key>(bp);
<API key>(bp);
}
static int
<API key>(struct bnx2 *bp)
{
int err;
err = <API key>(bp);
if (err != 0) {
netdev_err(bp->dev, "Couldn't allocate netq resources\n");
return err;
}
bnx2_start_netqueue(bp);
bp->netq_state |= BNX2_NETQ_HW_OPENED;
wmb();
netdev_info(bp->dev, "NetQueue hardware support is enabled\n");
return 0;
}
static int
<API key>(<API key> *args)
{
args->features = <API key>;
args->features |= <API key>;
args->features |= <API key>;
return <API key>;
}
static int
<API key>(<API key> *args)
{
struct bnx2 *bp = netdev_priv(args->netdev);
/* workaround for packets duplicated */
if (bp->num_tx_rings + bp->num_rx_rings > 1)
bp->netq_enabled = 1;
if (args->type == <API key>) {
args->count = max_t(u16, bp->num_rx_rings - 1, 0);
netdev_info(args->netdev, "Using %d RX NetQ rings\n",
args->count);
return <API key>;
} else if (args->type == <API key>) {
args->count = max_t(u16, bp->num_tx_rings - 1, 0);
netdev_info(args->netdev, "Using %d TX NetQ rings\n",
args->count);
return <API key>;
} else {
netdev_err(args->netdev, "queue count: invalid queue type "
"0x%x\n", args->type);
return <API key>;
}
}
static int
<API key>(<API key> *args)
{
/* Only support 1 Mac filter per queue */
args->count = 1;
return <API key>;
}
static int
<API key>(struct bnx2 *bp,
struct bnx2_napi *bnapi,
int index)
{
/* We need to count the default ring as part of the number of RX rings
avaliable */
if (bp-><API key> >= (bp->num_rx_rings - 1)) {
netdev_warn(bp->dev, "Unable to allocate RX NetQueue <API key>(%d) >= Num NetQ's(%d)\n",
bp-><API key>, (bp->num_rx_rings - 1));
return <API key>;
}
if((bp->netq_state & <API key>) != <API key>) {
netdev_warn(bp->dev, "NetQueue hardware not running\n");
return <API key>;
}
if (!bnapi->rx_queue_allocated) {
int rc;
struct <API key> kwqe_alloc_rx;
/* Prepare the kwqe to be passed to the firmware */
memset(&kwqe_alloc_rx, 0, sizeof(kwqe_alloc_rx));
kwqe_alloc_rx.kwqe_flags = <API key>;
kwqe_alloc_rx.kwqe_opcode = <API key>;
kwqe_alloc_rx.queue_type = L2_NET_QUEUE;
kwqe_alloc_rx.qid = <API key>(index);
rc = <API key>(bp,
(struct l2_kwqe *)&kwqe_alloc_rx);
if (rc != 0) {
netdev_err(bp->dev, "Couldn't submit alloc rx kwqe\n");
return <API key>;
}
bp->netq_flags = 0;
wmb();
rc = wait_event_timeout(bp->netq_wait,
(bp->netq_flags &
<API key>),
<API key>);
if (rc != 0) {
bnapi->rx_queue_allocated = TRUE;
netdev_info(bp->dev, "RX NetQ allocated on %d\n",
index);
return <API key>;
} else {
netdev_info(bp->dev, "Timeout RX NetQ allocate on %d\n",
index);
return <API key>;
}
}
netdev_info(bp->dev, "No RX NetQueues avaliable!\n");
return <API key>;
}
static int
<API key>(struct net_device *netdev,
<API key> *p_qid,
struct napi_struct **napi_p)
{
int index;
struct bnx2 *bp = netdev_priv(netdev);
/* We need to count the default ring as part of the number of RX rings
avaliable */
if (bp-><API key> >= (bp->num_rx_rings - 1)) {
netdev_warn(bp->dev, "Unable to allocate RX NetQueue <API key>(%d) >= Num NetQ's(%d)\n",
bp-><API key>, (bp->num_rx_rings - 1));
return <API key>;
}
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if (!bnapi->rx_queue_allocated) {
int rc;
rc = <API key>(bp, bnapi, index);
if (rc == <API key>) {
bp-><API key>++;
*p_qid = <API key>(index);
*napi_p = &bnapi->napi;
return <API key>;
} else
return <API key>;
}
}
netdev_err(bp->dev, "No free RX NetQueues found!\n");
return <API key>;
}
static int
<API key>(struct bnx2 *bp,
struct bnx2_napi *bnapi,
int index)
{
if (bp-><API key> >= (bp->num_tx_rings - 1))
return <API key>;
if (!bnapi->tx_queue_allocated) {
bnapi->tx_queue_allocated = TRUE;
bp-><API key>++;
netdev_info(bp->dev, "TX NetQ allocated on %d\n", index);
return <API key>;
}
netdev_err(bp->dev, "tx queue already allocated!\n");
return <API key>;
}
static int
<API key>(struct net_device *netdev,
<API key> *p_qid,
u16 *queue_mapping)
{
int index;
struct bnx2 *bp = netdev_priv(netdev);
if (bp-><API key> >= (bp->num_tx_rings - 1))
return <API key>;
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if (!bnapi->tx_queue_allocated) {
int rc = <API key>(bp, bnapi, index);
*p_qid = <API key>(index);
*queue_mapping = index;
return rc;
}
}
netdev_err(bp->dev, "no free tx queues found!\n");
return <API key>;
}
static int
<API key>(<API key> *args)
{
struct net_device *netdev = args->netdev;
struct bnx2 *bp = netdev_priv(netdev);
if(bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to alloc NetQueue on failed reset "
"device\n");
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
if (args->type == <API key>) {
return <API key>(args->netdev,
&args->queueid,
&args->queue_mapping);
} else if (args->type == <API key>) {
return <API key>(args->netdev,
&args->queueid,
&args->napi);
} else {
netdev_err(bp->dev, "Trying to alloc invalid queue type: %x\n",
args->type);
return <API key>;
}
}
static int
<API key>(struct net_device *netdev,
<API key> qid)
{
struct bnx2 *bp = netdev_priv(netdev);
struct bnx2_napi *bnapi;
u16 index = <API key>(qid);
if (index > bp->num_tx_rings)
return <API key>;
bnapi = &bp->bnx2_napi[index];
if (bnapi->tx_queue_allocated != TRUE)
return <API key>;
bnapi->tx_queue_allocated = FALSE;
bp-><API key>
netdev_info(bp->dev, "Free NetQ TX Queue: 0x%x\n", index);
return <API key>;
}
static int
<API key>(struct net_device *netdev,
int index)
{
int rc;
struct bnx2 *bp = netdev_priv(netdev);
struct bnx2_napi *bnapi;
struct <API key> kwqe_free_rx;
if (index > bp->num_rx_rings) {
netdev_err(bp->dev, "Error Free NetQ RX Queue: "
"index(%d) > bp->num_rx_rings(%d)\n",
index, bp->num_rx_rings);
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
bnapi = &bp->bnx2_napi[index];
if (bnapi->rx_queue_allocated != TRUE) {
netdev_warn(bp->dev, "NetQ RX Queue %d already freed\n", index);
return <API key>;
}
memset(&kwqe_free_rx, 0, sizeof(kwqe_free_rx));
kwqe_free_rx.flags = <API key>;
kwqe_free_rx.opcode = <API key>;
kwqe_free_rx.qid = <API key>(index);
kwqe_free_rx.queue_type = L2_NET_QUEUE;
rc = <API key>(bp,
(struct l2_kwqe *) &kwqe_free_rx);
if (rc != 0) {
netdev_err(bp->dev, "Couldn't submit free rx kwqe\n");
return <API key>;
}
bp->netq_flags = 0;
wmb();
rc = wait_event_timeout(bp->netq_wait,
(bp->netq_flags &
<API key>),
<API key>);
if (rc != 0) {
bnapi->rx_queue_allocated = FALSE;
bp-><API key>
netdev_info(bp->dev, "Free NetQ RX Queue %d\n", index);
return <API key>;
} else {
netdev_err(bp->dev, "Timeout free NetQ RX Queue %d\n", index);
return <API key>;
}
}
static int
<API key>(<API key> *args)
{
struct bnx2 *bp = netdev_priv(args->netdev);
if(bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to free NetQueue on failed reset "
"device\n");
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
if (<API key>(args->queueid)) {
return <API key>(args->netdev, args->queueid);
} else if (<API key>(args->queueid)) {
return <API key>(args->netdev,
<API key>(args->queueid));
} else {
netdev_err(bp->dev, "free netq: invalid queue type: 0x%x\n",
args->queueid);
return <API key>;
}
}
static int
<API key>(<API key> *args)
{
int qid;
struct bnx2 *bp = netdev_priv(args->netdev);
qid = <API key>(args->queueid);
if (qid > bp->num_rx_rings)
return <API key>;
#ifdef CONFIG_PCI_MSI
args->vector = bp->bnx2_napi[qid].int_num;
#endif
return <API key>;
}
static int
<API key>(<API key> *args)
{
struct bnx2 *bp = netdev_priv(args->netdev);
if (args->type == <API key>) {
args->queueid = <API key>(0);
args->napi = &bp->bnx2_napi[0].napi;
return <API key>;
} else if (args->type == <API key>) {
args->queueid = <API key>(0);
args->queue_mapping = 0;
return <API key>;
} else
return <API key>;
}
static int
<API key>(struct bnx2 *bp, int index)
{
u16 fw_qid = <API key>(index);
struct bnx2_napi *bnapi;
struct <API key> <API key>;
int rc;
if(bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to remove RX filter NetQueue on "
"failed reset device\n");
return <API key>;
}
if (!<API key>(bp)) {
netdev_err(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
bnapi = &bp->bnx2_napi[index];
if (fw_qid > bp->num_rx_rings) {
netdev_info(bp->dev, "Free RX Filter NetQ: failed "
"qid(%d) > bp->num_rx_rings(%d)\n",
index, bp->num_rx_rings);
return <API key>;
}
memset(&<API key>, 0, sizeof(<API key>));
<API key>.flags = <API key>;
<API key>.opcode = <API key>;
<API key>.filter_type = L2_VM_FILTER_MAC;
<API key>.qid = fw_qid;
<API key>.filter_id = fw_qid + <API key>;
rc = <API key>(bp,
(struct l2_kwqe *) &<API key>);
if (rc != 0) {
netdev_err(bp->dev, "Couldn't submit rx filter kwqe\n");
return <API key>;
}
bp->netq_flags = 0;
wmb();
rc = wait_event_timeout(bp->netq_wait,
(bp->netq_flags &
<API key>),
<API key>);
if (rc != 0) {
bnapi->rx_queue_active = FALSE;
bnapi->netq_state &= ~<API key>;
netdev_info(bp->dev, "NetQ remove RX filter: %d\n", index);
return <API key>;
} else {
netdev_warn(bp->dev, "Timeout NetQ remove RX filter: %d\n",
index);
return <API key>;
}
}
static int
<API key>(<API key> *args)
{
struct bnx2 *bp = netdev_priv(args->netdev);
u16 index = <API key>(args->queueid);
struct bnx2_napi *bnapi;
if (bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to remove RX filter NetQueue on "
"failed reset device\n");
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
bnapi = &bp->bnx2_napi[index];
if (!<API key>(args->queueid)) {
netdev_err(bp->dev, "!<API key>: "
"qid: %d)\n", index);
return <API key>;
}
if (index > bp->num_rx_rings) {
netdev_err(bp->dev, "qid(%d) > bp->num_rx_rings(%d)\n",
index, bp->num_rx_rings);
return <API key>;
}
/* Only support one Mac filter per queue */
if (bnapi->rx_queue_active == 0) {
netdev_info(bp->dev, "bnapi->rx_queue_active(%d) == 0\n",
bnapi->rx_queue_active);
return <API key>;
}
return <API key>(bp, index);
}
static int
<API key>(struct bnx2 *bp, struct bnx2_napi *bnapi,
int index)
{
u16 fw_queueid = <API key>(index);
struct <API key> kwqe_set_rx_filter;
int rc;
DECLARE_MAC_BUF(mac);
if (bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to apply RX filter NetQueue on %d"
"failed reset device\n", index);
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
if (bnapi->rx_queue_active == TRUE || !bnapi->rx_queue_allocated) {
netdev_err(bp->dev, "apply filter: RX NetQ %d already active"
"bnapi->rx_queue_active(%d) || "
"!bnapi->rx_queue_allocated(%d)\n",
index, bnapi->rx_queue_active,
bnapi->rx_queue_allocated);
return <API key>;
}
bnx2_set_mac_addr(bp, bnapi->mac_filter_addr,
fw_queueid + QID_TO_PM_OFFSET);
memset(&kwqe_set_rx_filter, 0, sizeof(kwqe_set_rx_filter));
kwqe_set_rx_filter.flags = <API key>;
kwqe_set_rx_filter.opcode = <API key>;
kwqe_set_rx_filter.filter_id = fw_queueid + <API key>;
#if defined(__LITTLE_ENDIAN)
memcpy(&kwqe_set_rx_filter.mac_addr_hi, bnapi->mac_filter_addr, 2);
memcpy(&kwqe_set_rx_filter.mac_addr_lo, bnapi->mac_filter_addr + 2, 4);
#else
memcpy(&kwqe_set_rx_filter.mac_addr, bnapi->mac_filter_addr, 6);
#endif
if (bnapi->class == <API key>) {
kwqe_set_rx_filter.filter_type = L2_VM_FILTER_MAC;
} else {
kwqe_set_rx_filter.filter_type = <API key>;
kwqe_set_rx_filter.vlan = bnapi->vlan_id;
}
kwqe_set_rx_filter.qid = fw_queueid;
rc = <API key>(bp,
(struct l2_kwqe *) &kwqe_set_rx_filter);
if (rc != 0) {
netdev_err(bp->dev, "Couldn't submit rx filter kwqe\n");
return <API key>;
}
bp->netq_flags = 0;
wmb();
rc = wait_event_timeout(bp->netq_wait,
(bp->netq_flags &
<API key>),
<API key>);
if (rc != 0) {
bnapi->rx_queue_active = TRUE;
bnapi->netq_state |= <API key>;
netdev_info(bp->dev, "NetQ set RX Filter: %d [%s %d]\n",
index, print_mac(mac, bnapi->mac_filter_addr),
bnapi->vlan_id);
return <API key>;
} else {
netdev_info(bp->dev, "Timeout submitting NetQ set RX Filter: "
"%d [%s]\n",
index, print_mac(mac, bnapi->mac_filter_addr));
return <API key>;
}
}
static int
<API key>(<API key> *args)
{
u8 *macaddr;
struct bnx2_napi *bnapi;
struct bnx2 *bp = netdev_priv(args->netdev);
u16 index = <API key>(args->queueid);
<API key> class;
DECLARE_MAC_BUF(mac);
if (bp->reset_failed == 1) {
netdev_err(bp->dev, "Trying to apply RX filter NetQueue on %d"
"failed reset device\n", index);
return <API key>;
}
if (!<API key>(bp)) {
netdev_warn(bp->dev, "NetQueue hardware not running yet\n");
return <API key>;
}
if (!<API key>(args->queueid)) {
netdev_err(bp->dev, "invalid NetQ RX ID: %x\n", args->queueid);
return <API key>;
}
class = <API key>(&args->filter);
if ((class != <API key>) &&
(class != <API key>)) {
netdev_err(bp->dev, "recieved invalid RX NetQ filter: %x\n",
class);
return <API key>;
}
if (index > bp->num_rx_rings) {
netdev_err(bp->dev, "applying filter with invalid "
"RX NetQ %d ID\n", index);
return <API key>;
}
bnapi = &bp->bnx2_napi[index];
if (bnapi->rx_queue_active || !bnapi->rx_queue_allocated) {
netdev_err(bp->dev, "RX NetQ %d already active\n", index);
return <API key>;
}
macaddr = (void *)<API key>(&args->filter);
memcpy(bnapi->mac_filter_addr, macaddr, ETH_ALEN);
bnapi->vlan_id = <API key>(&args->filter);
bnapi->class = class;
/* Apply RX filter code here */
args->filterid = <API key>(index);
return <API key>(bp, bnapi, index);
}
static int
<API key>(<API key> *args)
{
u16 index = <API key>(args->queueid);
struct bnx2_napi *bnapi;
struct bnx2 *bp = netdev_priv(args->netdev);
bnapi = &bp->bnx2_napi[index];
args->stats = &bnapi->stats;
return <API key>;
}
static int
<API key>(<API key> *args)
{
return <API key>(args);
}
static void
<API key>(struct bnx2 *bp)
{
int index;
u16 num_tx = 0, num_rx = 0;
netdev_info(bp->dev, "Flushing NetQueues\n");
mutex_lock(&bp->netq_lock);
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if(bnapi->netq_state & <API key>) {
int rc = <API key>(bp, index);
if (rc == <API key>) {
netdev_err(bp->dev, "could not remove RX "
"filter during flush\n");
}
if(bnapi->rx_queue_allocated == TRUE) {
rc = <API key>(bp->dev, index);
if (rc == <API key>) {
num_rx++;
} else {
netdev_err(bp->dev, "couldn't free RX "
"queue %d during "
"flush\n", index);
}
}
}
}
<API key>(bp, index) {
struct bnx2_napi *bnapi = &bp->bnx2_napi[index];
if(bnapi->tx_queue_allocated == TRUE) {
<API key>(bp->dev, index);
}
num_tx++;
}
mutex_unlock(&bp->netq_lock);
netdev_info(bp->dev, "Flushed NetQueues: rx: %d tx: %d\n",
num_rx, num_tx);
}
static int
bnx2_netqueue_ops(<API key> op, void *args)
{
int rc;
struct bnx2 *bp;
if (op == <API key>)
return <API key>(
(<API key> *)args);
bp = netdev_priv(((<API key> *)args)->netdev);
if (!<API key>(bp) ||
!<API key>(bp))
return <API key>;
mutex_lock(&bp->netq_lock);
switch (op) {
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
case <API key>:
rc = <API key>(
(<API key> *)args);
break;
/* Unsupported for now */
case <API key>:
rc = <API key>;
break;
#if (<API key> >= 41000)
case <API key>:
rc = <API key>;
break;
case <API key>:
rc = <API key>;
break;
#if (<API key> >= 50000)
case <API key>:
rc = <API key>;
break;
#endif
#endif
default:
netdev_warn(bp->dev, "Unhandled NETQUEUE OP %d\n", op);
rc = <API key>;
}
mutex_unlock(&bp->netq_lock);
return rc;
}
#endif /* defined(<API key>) */
#if defined(__VMKLNX__)
#if (<API key> >= 55000)
static void
bnx2_dump(struct bnx2 *bp, u32 reg_offset, u32 *dest_addr, u32 word_cnt)
{
u32 *dst = dest_addr;
u32 i;
for (i = 0; i < word_cnt; i++) {
*dst++ = BNX2_RD(bp, reg_offset);
reg_offset += 4;
}
}
static void
bnx2_dump_ind(struct bnx2 *bp, u32 reg_offset, u32 *dest_addr, u32 word_cnt)
{
u32 *dst = dest_addr;
u32 i;
for (i = 0; i < word_cnt; i++) {
*dst++ = bnx2_reg_rd_ind(bp, reg_offset);
reg_offset += 4;
}
}
#define BNX2_CPU_ENTRY(offset, size) { offset, size }
static const struct cpu_data_reg {
u32 off;
u32 size;
} cpu_arr[] = {
BNX2_CPU_ENTRY(0, 3),
BNX2_CPU_ENTRY(0x1c, 8),
BNX2_CPU_ENTRY(0x48, 1),
BNX2_CPU_ENTRY(0x200, 32),
};
static u32 *
dump_cpu_state(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
u32 reg, i;
u32 cpu_size = 0;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
for (reg = BNX2_TXP_CPU_MODE; reg <= BNX2_CP_CPU_MODE; reg += 0x40000) {
/* make sure these are 64-bit align */
for (i = 0; i < ARRAY_SIZE(cpu_arr); i++)
cpu_size += cpu_arr[i].size * 4;
}
if ((dmp->fw_hdr.dmp_size + cpu_size + <API key>) >
BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = BNX2_FWDMP_CPU_DUMP;
*dst++ = cpu_size;
for (reg = BNX2_TXP_CPU_MODE; reg <= BNX2_CP_CPU_MODE; reg += 0x40000) {
/* make sure these are 64-bit align */
for (i = 0; i < ARRAY_SIZE(cpu_arr); i++) {
bnx2_dump_ind(bp, reg + cpu_arr[i].off,
dst, cpu_arr[i].size);
dst += cpu_arr[i].size;
}
}
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += cpu_size + <API key>;
return dst;
}
#define BNX2_FTQ_DATA_ENTRY(offset, cmdoff, size, dataoff) { BNX2_##offset, \
BNX2_##cmdoff, \
size, \
BNX2_##dataoff }
static const struct ftq_data_reg {
u32 off;
u32 cmdoff;
u32 size;
u32 dataoff;
} ftq_data_arr[] = {
BNX2_FTQ_DATA_ENTRY(TSCH_FTQ_CMD,
<API key>,
2, TSCH_TSCHQ),
BNX2_FTQ_DATA_ENTRY(TBDR_FTQ_CMD,
<API key>,
5, TBDR_TBDRQ),
BNX2_FTQ_DATA_ENTRY(TXP_FTQ_CMD,
TXP_FTQ_CMD_RD_DATA,
5, TXP_TXPQ),
BNX2_FTQ_DATA_ENTRY(TDMA_FTQ_CMD,
<API key>,
12, TDMA_TDMAQ),
BNX2_FTQ_DATA_ENTRY(TPAT_FTQ_CMD,
<API key>,
5, TPAT_TPATQ),
BNX2_FTQ_DATA_ENTRY(TAS_FTQ_CMD,
TAS_FTQ_CMD_RD_DATA,
4, TPAT_TPATQ),
BNX2_FTQ_DATA_ENTRY(RLUP_FTQ_COMMAND,
<API key>,
30, RLUP_RLUPQ),
BNX2_FTQ_DATA_ENTRY(RXP_FTQ_CMD,
RXP_FTQ_CMD_RD_DATA,
13, RXP_RXPQ),
BNX2_FTQ_DATA_ENTRY(RXP_CFTQ_CMD,
<API key>,
4, RXP_RXPCQ),
BNX2_FTQ_DATA_ENTRY(RV2P_MFTQ_CMD,
<API key>,
1, RV2P_RV2PMQ),
BNX2_FTQ_DATA_ENTRY(RV2P_TFTQ_CMD,
<API key>,
1, RV2P_RV2PTQ),
BNX2_FTQ_DATA_ENTRY(RV2P_PFTQ_CMD,
<API key>,
13, RV2P_RV2PPQ),
BNX2_FTQ_DATA_ENTRY(RDMA_FTQ_COMMAND,
<API key>,
13, RDMA_RDMAQ),
BNX2_FTQ_DATA_ENTRY(COM_COMQ_FTQ_CMD,
<API key>,
10, COM_COMQ),
BNX2_FTQ_DATA_ENTRY(COM_COMTQ_FTQ_CMD,
<API key>,
3, COM_COMTQ),
BNX2_FTQ_DATA_ENTRY(COM_COMXQ_FTQ_CMD,
<API key>,
4, COM_COMXQ),
BNX2_FTQ_DATA_ENTRY(CP_CPQ_FTQ_CMD,
<API key>,
1, CP_CPQ),
BNX2_FTQ_DATA_ENTRY(CSCH_CH_FTQ_COMMAND,
<API key>,
2, CSCH_CSQ),
BNX2_FTQ_DATA_ENTRY(MCP_MCPQ_FTQ_CMD,
<API key>,
5, MCP_MCPQ),
};
static u32 *
dump_ftq_ctrl_info(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
int i;
u32 ftq_size = 0;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
for (i = 0; i < ARRAY_SIZE(ftq_arr); i++)
ftq_size += 4;
for (i = 0; i < ARRAY_SIZE(ftq_data_arr); i++)
ftq_size += ftq_data_arr[i].size * 4;
if ((dmp->fw_hdr.dmp_size + ftq_size + <API key>) >
BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = BNX2_FWDMP_FTQ_DUMP;
*dst++ = ftq_size;
for (i = 0; i < ARRAY_SIZE(ftq_arr); i++)
*dst++ = bnx2_reg_rd_ind(bp, ftq_arr[i].off);
for (i = 0; i < ARRAY_SIZE(ftq_data_arr); i++) {
bnx2_reg_wr_ind(bp, ftq_data_arr[i].off,
ftq_data_arr[i].cmdoff);
bnx2_dump_ind(bp, ftq_data_arr[i].dataoff,
dst, ftq_data_arr[i].size);
dst += ftq_data_arr[i].size;
}
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += ftq_size + <API key>;
return dst;
}
#define BNX2_GRCBLK_SIZE 0x400
#define BNX2_GRC_ENTRY(offset) { BNX2_##offset }
static const struct grc_reg {
u32 off;
} grc_arr[] = {
BNX2_GRC_ENTRY(PCICFG_START),
BNX2_GRC_ENTRY(PCI_GRC_WINDOW_ADDR),
BNX2_GRC_ENTRY(MISC_COMMAND),
BNX2_GRC_ENTRY(DMA_COMMAND),
BNX2_GRC_ENTRY(CTX_COMMAND),
BNX2_GRC_ENTRY(EMAC_MODE),
BNX2_GRC_ENTRY(RPM_COMMAND),
BNX2_GRC_ENTRY(RCP_START),
BNX2_GRC_ENTRY(RLUP_COMMAND),
BNX2_GRC_ENTRY(CH_COMMAND),
BNX2_GRC_ENTRY(RV2P_COMMAND),
BNX2_GRC_ENTRY(RDMA_COMMAND),
BNX2_GRC_ENTRY(RBDC_COMMAND),
BNX2_GRC_ENTRY(MQ_COMMAND),
BNX2_GRC_ENTRY(TIMER_COMMAND),
BNX2_GRC_ENTRY(TSCH_COMMAND),
BNX2_GRC_ENTRY(TBDR_COMMAND),
BNX2_GRC_ENTRY(TBDC_COMMAND),
BNX2_GRC_ENTRY(TDMA_COMMAND),
BNX2_GRC_ENTRY(DBU_CMD),
BNX2_GRC_ENTRY(NVM_COMMAND),
BNX2_GRC_ENTRY(HC_COMMAND),
BNX2_GRC_ENTRY(DEBUG_COMMAND),
};
static u32 *dump_grc(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
u32 i;
u32 grc_size = 0;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
for (i = 0; i < ARRAY_SIZE(grc_arr); i++)
grc_size += BNX2_GRCBLK_SIZE;
if ((dmp->fw_hdr.dmp_size + grc_size + <API key>) >
BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = BNX2_FWDMP_GRC_DUMP;
*dst++ = grc_size;
for (i = 0; i < ARRAY_SIZE(grc_arr); i++) {
bnx2_dump(bp, grc_arr[i].off, dst, BNX2_GRCBLK_SIZE/4);
dst += BNX2_GRCBLK_SIZE/4;
}
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += grc_size + <API key>;
return dst;
}
#define BNX2_HSI_ENTRY(offset, size) { BNX2_##offset, BNX2_##size }
static const struct hsi_reg {
u32 off;
u32 size;
} hsi_arr[] = {
BNX2_HSI_ENTRY(CP_HSI_START, CP_HSI_SIZE),
BNX2_HSI_ENTRY(COM_HSI_START, COM_HSI_SIZE),
BNX2_HSI_ENTRY(RXP_HSI_START, RXP_HSI_SIZE),
BNX2_HSI_ENTRY(TXP_HSI_START, TXP_HSI_SIZE),
BNX2_HSI_ENTRY(TPAT_HSI_START, TPAT_HSI_SIZE),
};
static u32 *dump_hsi(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
u32 i;
u32 hsi_size = 0;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
for (i = 0; i < ARRAY_SIZE(hsi_arr); i++)
hsi_size += hsi_arr[i].size;
if ((dmp->fw_hdr.dmp_size + hsi_size + <API key>) >
BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = BNX2_FWDMP_HSI_DUMP;
*dst++ = hsi_size;
for (i = 0; i < ARRAY_SIZE(hsi_arr); i++) {
bnx2_dump_ind(bp, hsi_arr[i].off, dst, hsi_arr[i].size/4);
dst += hsi_arr[i].size/4;
}
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += hsi_size + <API key>;
return dst;
}
static u32 *
dump_mcp_info(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
u32 i;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = BNX2_FWDMP_MCP_DUMP;
*dst++ = BNX2_MCP_DUMP_SIZE;
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
*dst++ = bnx2_reg_rd_ind(bp, BNX2_MCP_STATE_P0);
*dst++ = bnx2_reg_rd_ind(bp, BNX2_MCP_STATE_P1);
} else {
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
}
*dst++ = bnx2_reg_rd_ind(bp, BNX2_MCP_CPU_MODE);
*dst++ = bnx2_reg_rd_ind(bp, BNX2_MCP_CPU_STATE);
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
*dst++ = bnx2_reg_rd_ind(bp, <API key>);
*dst++ = bnx2_shmem_rd(bp, BNX2_DRV_MB);
*dst++ = bnx2_shmem_rd(bp, BNX2_FW_MB);
*dst++ = bnx2_shmem_rd(bp, BNX2_LINK_STATUS);
*dst++ = bnx2_shmem_rd(bp, BNX2_DRV_PULSE_MB);
*dst++ = bnx2_shmem_rd(bp, <API key>);
*dst++ = bnx2_shmem_rd(bp, <API key>);
*dst++ = bnx2_shmem_rd(bp, <API key>);
for (i = 0; i < 16;) {
*dst++ = bnx2_shmem_rd(bp, <API key>);
i += 4;
}
for (i = 0; i < 16;) {
*dst++ = bnx2_shmem_rd(bp, 0x3cc);
i += 4;
}
for (i = 0; i < 16;) {
*dst++ = bnx2_shmem_rd(bp, 0x3dc);
i += 4;
}
for (i = 0; i < 16;) {
*dst++ = bnx2_shmem_rd(bp, 0x3ec);
i += 4;
}
*dst++ = bnx2_shmem_rd(bp, 0x3fc);
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += BNX2_MCP_DUMP_SIZE + <API key>;
return dst;
}
static u32 *dump_tbdc(struct bnx2 *bp, u32 *dst, struct bnx2_chip_core_dmp *dmp)
{
u32 i;
if (dmp->fw_hdr.dmp_size >= BNX2_FWDMP_SIZE)
return dst;
if ((dmp->fw_hdr.dmp_size + BNX2_TBDC_DUMP_SIZE +
<API key>) > BNX2_FWDMP_SIZE)
return dst;
*dst++ = BNX2_FWDMP_MARKER;
*dst++ = 0;
*dst++ = <API key>;
*dst++ = BNX2_TBDC_DUMP_SIZE;
for (i = 0; i < 0x20; i++) {
int j = 0;
BNX2_WR(bp, BNX2_TBDC_BD_ADDR, i);
BNX2_WR(bp, <API key>,
<API key>);
BNX2_WR(bp, BNX2_TBDC_COMMAND, <API key>);
while ((BNX2_RD(bp, BNX2_TBDC_COMMAND) &
<API key>) && j < 100)
j++;
*dst++ = BNX2_RD(bp, BNX2_TBDC_CID);
*dst++ = BNX2_RD(bp, BNX2_TBDC_BIDX);
*dst++ = BNX2_RD(bp, <API key>);
}
*dst++ = <API key>;
dmp->fw_hdr.dmp_size += BNX2_TBDC_DUMP_SIZE + <API key>;
return dst;
}
static VMK_ReturnStatus bnx2_fwdmp_callback(void *cookie, vmk_Bool liveDump)
{
VMK_ReturnStatus status = VMK_OK;
u32 idx;
u32 *dst;
struct bnx2_chip_core_dmp *dmp;
struct bnx2 *bp;
printk(KERN_INFO "FW dump for QLogic Nx2 Gigabit Ethernet Driver "
DRV_MODULE_NAME " v" DRV_MODULE_VERSION " ("
DRV_MODULE_RELDATE ")\n");
for (idx = 0; idx < BNX2_MAX_NIC; idx++) {
if (fwdmp_va_ptr && fwdmp_bp_ptr[idx]) {
/* dump chip information to buffer */
bp = fwdmp_bp_ptr[idx];
dmp = (struct bnx2_chip_core_dmp *)fwdmp_va_ptr;
snprintf(dmp->fw_hdr.name, sizeof(dmp->fw_hdr.name),
"%s", bp->dev->name);
dmp->fw_hdr.bp = (void *)bp;
dmp->fw_hdr.chip_id = bp->chip_id;
dmp->fw_hdr.len = sizeof(struct bnx2_fw_dmp_hdr);
dmp->fw_hdr.ver = 0x000700006;
dmp->fw_hdr.dmp_size = dmp->fw_hdr.len;
/* 1. dump all CPUs states */
dst = dmp->fw_dmp_buf;
dst = dump_cpu_state(bp, dst, dmp);
/* 2. dump all ftqs control information */
dst = dump_ftq_ctrl_info(bp, dst, dmp);
/* 3. dump mcp info */
dst = dump_mcp_info(bp, dst, dmp);
/* 4. dump tbdc contents */
dst = dump_tbdc(bp, dst, dmp);
/* 5. dump hsi section for all processors */
dst = dump_hsi(bp, dst, dmp);
/* 6. dump 32k grc registers */
dst = dump_grc(bp, dst, dmp);
status = vmklnx_dump_range(bnx2_fwdmp_dh,
fwdmp_va_ptr, dmp->fw_hdr.dmp_size);
if (status != VMK_OK) {
printk(KERN_ERR "
status, idx);
break;
}
}
}
return status;
}
#endif
/* The following debug buffers and exported routines are used by GDB to access
teton/xinan hardware registers when doing live debug over serial port. */
#define DBG_BUF_SZ 128
static u32 bnx2_dbg_buf[DBG_BUF_SZ];
static u32 <API key>(void __iomem *reg_view, u32 off)
{
u32 val;
writel(off, reg_view + <API key>);
val = readl(reg_view + <API key>);
return val;
}
void bnx2_dbg_read32_ind(void __iomem *reg_view, u32 off, u32 len)
{
u32 *buf = bnx2_dbg_buf;
if (len & 0x3)
len = (len + 3) & ~3;
if (len > DBG_BUF_SZ)
len = DBG_BUF_SZ;
while (len > 0) {
*buf = <API key>(reg_view, off);
buf++;
off += 4;
len -= 4;
}
}
EXPORT_SYMBOL(bnx2_dbg_read32_ind);
static u32 <API key>(void __iomem *reg_view, u32 off)
{
return readl(reg_view + off);
}
void bnx2_dbg_read32(void __iomem *reg_view, u32 off, u32 len)
{
u32 *buf = bnx2_dbg_buf;
if (len & 0x3)
len = (len + 3) & ~3;
if (len > DBG_BUF_SZ)
len = DBG_BUF_SZ;
while (len > 0) {
*buf = <API key>(reg_view, off);
buf++;
off += 4;
len -= 4;
}
}
EXPORT_SYMBOL(bnx2_dbg_read32);
void bnx2_dbg_write32(void __iomem *reg_view, u32 off, u32 val)
{
writel(val, reg_view + off);
}
EXPORT_SYMBOL(bnx2_dbg_write32);
void <API key>(void __iomem *reg_view, u32 off, u32 val)
{
writel(off, reg_view + <API key>);
writel(val, reg_view + <API key>);
}
EXPORT_SYMBOL(<API key>);
#endif /*__VMKLNX__ */
|
#ifndef FEATURE_H
#define FEATURE_H
#define SIP_NO_FILE
#include "qgis_core.h"
#include "pointset.h"
#include "labelposition.h" // for LabelPosition enum
#include "qgslabelfeature.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <QString>
/**
* \ingroup core
* \class pal::LabelInfo
* \note not available in Python bindings
*/
namespace pal
{
//! Optional additional info about label (for curved labels)
class CORE_EXPORT LabelInfo
{
public:
struct CharacterInfo
{
double width;
};
LabelInfo( int num, double height, double maxinangle = 20.0, double maxoutangle = -20.0 )
{
<API key> = maxinangle;
// outside angle should be negative
<API key> = maxoutangle > 0 ? -maxoutangle : maxoutangle;
label_height = height;
char_num = num;
char_info = new CharacterInfo[num];
}
~LabelInfo() { delete [] char_info; }
//! LabelInfo cannot be copied
LabelInfo( const LabelInfo &rh ) = delete;
//! LabelInfo cannot be copied
LabelInfo &operator=( const LabelInfo &rh ) = delete;
double <API key>;
double <API key>;
double label_height;
int char_num;
CharacterInfo *char_info = nullptr;
};
class LabelPosition;
class FeaturePart;
/**
* \ingroup core
* \brief Main class to handle feature
* \class pal::FeaturePart
* \note not available in Python bindings
*/
class CORE_EXPORT FeaturePart : public PointSet
{
public:
/**
* Creates a new generic feature.
* \param lf a pointer for a feature which contains the spatial entites
* \param geom a pointer to a GEOS geometry
*/
FeaturePart( QgsLabelFeature *lf, const GEOSGeometry *geom );
FeaturePart( const FeaturePart &other );
/**
* Delete the feature
*/
~FeaturePart() override;
/**
* Returns the parent feature.
*/
QgsLabelFeature *feature() { return mLF; }
/**
* Returns the layer that feature belongs to.
*/
Layer *layer();
/**
* Returns the unique ID of the feature.
*/
QgsFeatureId featureId() const;
/**
* Returns the maximum number of point candidates to generate for this feature.
*/
std::size_t <API key>() const;
/**
* Returns the maximum number of line candidates to generate for this feature.
*/
std::size_t <API key>() const;
/**
* Returns the maximum number of polygon candidates to generate for this feature.
*/
std::size_t <API key>() const;
/**
* Generates a list of candidate positions for labels for this feature.
*/
std::vector<std::unique_ptr<LabelPosition> > createCandidates( Pal *pal );
/**
* Generate candidates for point feature, located around a specified point.
* \param x x coordinate of the point
* \param y y coordinate of the point
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param angle orientation of the label
* \returns the number of generated candidates
*/
std::size_t <API key>( double x, double y, std::vector<std::unique_ptr<LabelPosition> > &lPos, double angle );
/**
* Generate one candidate over or offset the specified point.
* \param x x coordinate of the point
* \param y y coordinate of the point
* \param lPos pointer to an array of candidates, will be filled by generated candidate
* \param angle orientation of the label
* \returns the number of generated candidates (always 1)
*/
std::size_t <API key>( double x, double y, std::vector<std::unique_ptr<LabelPosition> > &lPos, double angle );
/**
* Creates a single candidate using the "point on sruface" algorithm.
*
* \note Unlike the other create candidates methods, this method
* bypasses the usual candidate filtering steps and ALWAYS returns a single candidate.
*/
std::unique_ptr< LabelPosition > <API key>( PointSet *mapShape );
/**
* Generates candidates following a prioritized list of predefined positions around a point.
* \param x x coordinate of the point
* \param y y coordinate of the point
* \param lPos pointer to an array of candidates, will be filled by generated candidate
* \param angle orientation of the label
* \returns the number of generated candidates
*/
std::size_t <API key>( double x, double y, std::vector<std::unique_ptr<LabelPosition> > &lPos, double angle );
/**
* Generate candidates for line feature.
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param mapShape a pointer to the line
* \param allowOverrun set to TRUE to allow labels to overrun features
* \param pal point to pal settings object, for cancellation support
* \returns the number of generated candidates
*/
std::size_t <API key>( std::vector<std::unique_ptr<LabelPosition> > &lPos, PointSet *mapShape, bool allowOverrun, Pal *pal );
/**
* Generate candidates for line feature, by trying to place candidates towards the middle of the longest
* straightish segments of the line. Segments closer to horizontal are preferred over vertical segments.
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param mapShape a pointer to the line
* \param pal point to pal settings object, for cancellation support
* \returns the number of generated candidates
*/
std::size_t <API key>( std::vector<std::unique_ptr<LabelPosition> > &lPos, PointSet *mapShape, Pal *pal );
/**
* Generate candidates for line feature, by trying to place candidates as close as possible to the line's midpoint.
* Candidates can "cut corners" if it helps them place near this mid point.
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param mapShape a pointer to the line
* \param initialCost initial cost for candidates generated using this method. If set, cost can be increased
* by a preset amount.
* \param pal point to pal settings object, for cancellation support
* \returns the number of generated candidates
*/
std::size_t <API key>( std::vector<std::unique_ptr<LabelPosition> > &lPos, PointSet *mapShape, double initialCost = 0.0, Pal *pal = nullptr );
/**
* Returns the label position for a curved label at a specific offset along a path.
* \param path_positions line path to place label on
* \param path_distances array of distances to each segment on path
* \param orientation can be 0 for automatic calculation of orientation, or -1/+1 for a specific label orientation
* \param distance distance to offset label along curve by
* \param reversed if TRUE label is reversed from lefttoright to righttoleft
* \param flip if TRUE label is placed on the other side of the line
* \returns calculated label position
*/
std::unique_ptr< LabelPosition > <API key>( PointSet *path_positions, double *path_distances,
int &orientation, double distance, bool &reversed, bool &flip );
/**
* Generate curved candidates for line features.
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param mapShape a pointer to the line
* \param allowOverrun set to TRUE to allow labels to overrun features
* \param pal point to pal settings object, for cancellation support
* \returns the number of generated candidates
*/
std::size_t <API key>( std::vector<std::unique_ptr<LabelPosition> > &lPos, PointSet *mapShape, bool allowOverrun, Pal *pal );
/**
* Generate candidates for polygon features.
* \param lPos pointer to an array of candidates, will be filled by generated candidates
* \param mapShape a pointer to the polygon
* \param pal point to pal settings object, for cancellation support
* \returns the number of generated candidates
*/
std::size_t <API key>( std::vector<std::unique_ptr<LabelPosition> > &lPos, PointSet *mapShape, Pal *pal );
/**
* Tests whether this feature part belongs to the same QgsLabelFeature as another
* feature part.
* \param part part to compare to
* \returns TRUE if both parts belong to same QgsLabelFeature
*/
bool <API key>( FeaturePart *part ) const;
#if 0
/**
* \brief Print feature information
* Print feature unique id, geometry type, points, and holes on screen
*/
void print();
#endif
/**
* Returns the width of the label, optionally taking an \a angle into account.
* \returns the width of the label
*/
double getLabelWidth( double angle = 0.0 ) const { return mLF->size( angle ).width(); }
/**
* Returns the height of the label, optionally taking an \a angle into account.
* \returns the hieght of the label
*/
double getLabelHeight( double angle = 0.0 ) const { return mLF->size( angle ).height(); }
/**
* Returns the distance from the anchor point to the label
* \returns the distance to the label
*/
double getLabelDistance() const { return mLF->distLabel(); }
//! Returns TRUE if the feature's label has a fixed rotation
bool hasFixedRotation() const { return mLF->hasFixedAngle(); }
//! Returns the fixed angle for the feature's label
double fixedAngle() const { return mLF->fixedAngle(); }
//! Returns TRUE if the feature's label has a fixed position
bool hasFixedPosition() const { return mLF->hasFixedPosition(); }
/**
* Returns TRUE if the feature's label should always been shown,
* even when it collides with other labels
*/
bool alwaysShow() const { return mLF->alwaysShow(); }
/**
* Returns the feature's obstacle settings.
*/
const <API key> &obstacleSettings() const { return mLF->obstacleSettings(); }
//! Returns the distance between repeating labels for this feature
double repeatDistance() const { return mLF->repeatDistance(); }
//! Gets number of holes (inner rings) - they are considered as obstacles
int getNumSelfObstacles() const { return mHoles.count(); }
//! Gets hole (inner ring) - considered as obstacle
FeaturePart *getSelfObstacle( int i ) { return mHoles.at( i ); }
//! Check whether this part is connected with some other part
bool isConnected( FeaturePart *p2 );
/**
* Merge other (connected) part with this one and save the result in this part (other is unchanged).
* Returns TRUE on success, FALSE if the feature wasn't modified */
bool <API key>( FeaturePart *other );
/**
* Increases the cost of the label candidates for this feature, based on the size of the feature.
*
* E.g. small lines or polygons get higher cost so that larger features are more likely to be labeled.
*/
void addSizePenalty( std::vector<std::unique_ptr<LabelPosition> > &lPos, double bbx[4], double bby[4] );
/**
* Calculates the priority for the feature. This will be the feature's priority if set,
* otherwise the layer's default priority.
*/
double calculatePriority() const;
//! Returns TRUE if feature's label must be displayed upright
bool showUprightLabels() const;
//! Returns TRUE if the next char position is found. The referenced parameters are updated.
bool nextCharPosition( double charWidth, double segmentLength, PointSet *path_positions, int &index, double &<API key>,
double &characterStartX, double &characterStartY, double &characterEndX, double &characterEndY ) const;
/**
* Returns the total number of repeating labels associated with this label.
* \see setTotalRepeats()
*/
int totalRepeats() const;
/**
* Returns the total number of repeating labels associated with this label.
* \see totalRepeats()
*/
void setTotalRepeats( int repeats );
protected:
QgsLabelFeature *mLF = nullptr;
QList<FeaturePart *> mHoles;
//! \brief read coordinates from a GEOS geom
void extractCoords( const GEOSGeometry *geom );
private:
LabelPosition::Quadrant quadrantFromOffset() const;
int mTotalRepeats = 0;
mutable std::size_t <API key> = 0;
mutable std::size_t <API key> = 0;
};
} // end namespace pal
#endif
|
<?php
// @<API key>
namespace Drupal\Tests\Component\Annotation\Doctrine;
use Drupal\Component\Annotation\Doctrine\DocParser;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\Annotation\Target;
use Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>;
use Drupal\Tests\Component\Annotation\Doctrine\Fixtures\ClassWithConstants;
use Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>;
use PHPUnit\Framework\TestCase;
class DocParserTest extends TestCase
{
public function <API key>()
{
$parser = $this->createTestParser();
// Nested arrays with nested annotations
$result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})');
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertNull($annot->value);
$this->assertEquals(3, count($annot->foo));
$this->assertEquals(1, $annot->foo[0]);
$this->assertEquals(2, $annot->foo[1]);
$this->assertTrue(is_array($annot->foo[2]));
$nestedArray = $annot->foo[2];
$this->assertTrue(isset($nestedArray['key']));
$this->assertTrue($nestedArray['key'] instanceof Name);
}
public function <API key>()
{
$parser = $this->createTestParser();
// Marker annotation
$result = $parser->parse("@Name");
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertNull($annot->value);
$this->assertNull($annot->foo);
// Associative arrays
$result = $parser->parse('@Name(foo={"key1" = "value1"})');
$annot = $result[0];
$this->assertNull($annot->value);
$this->assertTrue(is_array($annot->foo));
$this->assertTrue(isset($annot->foo['key1']));
// Numerical arrays
$result = $parser->parse('@Name({2="foo", 4="bar"})');
$annot = $result[0];
$this->assertTrue(is_array($annot->value));
$this->assertEquals('foo', $annot->value[2]);
$this->assertEquals('bar', $annot->value[4]);
$this->assertFalse(isset($annot->value[0]));
$this->assertFalse(isset($annot->value[1]));
$this->assertFalse(isset($annot->value[3]));
// Multiple values
$result = $parser->parse('@Name(@Name, @Name)');
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertTrue($annot->value[0] instanceof Name);
$this->assertTrue($annot->value[1] instanceof Name);
// Multiple types as values
$result = $parser->parse('@Name(foo="Bar", @Name, {"key1"="value1", "key2"="value2"})');
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertTrue($annot->value[0] instanceof Name);
$this->assertTrue(is_array($annot->value[1]));
$this->assertEquals('value1', $annot->value[1]['key1']);
$this->assertEquals('value2', $annot->value[1]['key2']);
// Complete docblock
$docblock = <<<DOCBLOCK
/**
* Some nifty class.
*
* @author Mr.X
* @Name(foo="bar")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(1, count($result));
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertEquals("bar", $annot->foo);
$this->assertNull($annot->value);
}
public function <API key>()
{
$parser = $this->createTestParser();
// Array as first value
$result = $parser->parse('@Name({"key1"="value1"})');
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertEquals('value1', $annot->value['key1']);
// Array as first value and additional values
$result = $parser->parse('@Name({"key1"="value1"}, foo="bar")');
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertEquals('value1', $annot->value['key1']);
$this->assertEquals('bar', $annot->foo);
}
public function <API key>()
{
$parser = new DocParser;
$parser-><API key>(true);
$docblock = <<<DOCBLOCK
/**
* Some nifty class.
*
* @package foo
* @subpackage bar
* @author Mr.X <mr@x.com>
* @Drupal\Tests\Component\Annotation\Doctrine\Name(foo="bar")
* @ignore
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(1, count($result));
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertEquals("bar", $annot->foo);
}
/**
* @group debug
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* Some nifty method.
*
* @since 2.0
* @Drupal\Tests\Component\Annotation\Doctrine\Name(foo="bar")
* @param string \$foo This is foo.
* @param mixed \$bar This is bar.
* @return string Foo and bar.
* @This is irrelevant
* @Marker
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(2, count($result));
$this->assertTrue(isset($result[0]));
$this->assertTrue(isset($result[1]));
$annot = $result[0];
$this->assertTrue($annot instanceof Name);
$this->assertEquals("bar", $annot->foo);
$marker = $result[1];
$this->assertTrue($marker instanceof Marker);
}
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* @<API key>("Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertNotNull($annot);
$this->assertTrue($annot instanceof <API key>);
$this->assertNull($annot->name);
$this->assertNotNull($annot->data);
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @<API key>(name="Some Name", data = "Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertNotNull($annot);
$this->assertTrue($annot instanceof <API key>);
$this->assertEquals($annot->name, "Some Name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @<API key>(data = "Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertNull($annot->name);
$docblock = <<<DOCBLOCK
/**
* @<API key>(name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertNull($annot->data);
$docblock = <<<DOCBLOCK
/**
* @<API key>("Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertNull($annot->name);
$docblock = <<<DOCBLOCK
/**
* @<API key>("Some data",name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @<API key>(name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @<API key>()
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertEquals(count($result), 1);
$this->assertTrue($result[0] instanceof <API key>);
}
public function <API key>()
{
$parser = new DocParser;
$parser->setImports(array(
'__NAMESPACE__' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures',
));
$class = new \ReflectionClass('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>');
$context = 'class ' . $class->getName();
$docComment = $class->getDocComment();
$parser->setTarget(Target::TARGET_CLASS);
$this->assertNotNull($parser->parse($docComment,$context));
$property = $class->getProperty('foo');
$docComment = $property->getDocComment();
$context = 'property ' . $class->getName() . "::\$" . $property->getName();
$parser->setTarget(Target::TARGET_PROPERTY);
$this->assertNotNull($parser->parse($docComment,$context));
$method = $class->getMethod('someFunction');
$docComment = $property->getDocComment();
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
$parser->setTarget(Target::TARGET_METHOD);
$this->assertNotNull($parser->parse($docComment,$context));
try {
$class = new \ReflectionClass('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>');
$context = 'class ' . $class->getName();
$docComment = $class->getDocComment();
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertNotNull($exc->getMessage());
}
try {
$class = new \ReflectionClass('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>');
$method = $class->getMethod('functionName');
$docComment = $method->getDocComment();
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
$parser->setTarget(Target::TARGET_METHOD);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertNotNull($exc->getMessage());
}
try {
$class = new \ReflectionClass('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>');
$property = $class->getProperty('foo');
$docComment = $property->getDocComment();
$context = 'property ' . $class->getName() . "::\$" . $property->getName();
$parser->setTarget(Target::TARGET_PROPERTY);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertNotNull($exc->getMessage());
}
}
public function <API key>()
{
//({attribute name}, {attribute value})
return array(
// mixed type
array('mixed', '"String Value"'),
array('mixed', 'true'),
array('mixed', 'false'),
array('mixed', '1'),
array('mixed', '1.2'),
array('mixed', '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll'),
// boolean type
array('boolean', 'true'),
array('boolean', 'false'),
// alias for internal type boolean
array('bool', 'true'),
array('bool', 'false'),
// integer type
array('integer', '0'),
array('integer', '1'),
array('integer', '123456789'),
array('integer', '9223372036854775807'),
// alias for internal type double
array('float', '0.1'),
array('float', '1.2'),
array('float', '123.456'),
// string type
array('string', '"String Value"'),
array('string', '"true"'),
array('string', '"123"'),
// array type
array('array', '{@<API key>}'),
array('array', '{@<API key>,@<API key>}'),
array('arrayOfIntegers', '1'),
array('arrayOfIntegers', '{1}'),
array('arrayOfIntegers', '{1,2,3,4}'),
array('arrayOfAnnotations', '@<API key>'),
array('arrayOfAnnotations', '{@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll}'),
array('arrayOfAnnotations', '{@<API key>, @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll}'),
// annotation instance
array('annotation', '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll'),
array('annotation', '@<API key>'),
);
}
public function <API key>()
{
//({attribute name}, {type declared type}, {attribute value} , {given type or class})
return array(
// boolean type
array('boolean','boolean','1','integer'),
array('boolean','boolean','1.2','double'),
array('boolean','boolean','"str"','string'),
array('boolean','boolean','{1,2,3}','array'),
array('boolean','boolean','@Name', 'an instance of Drupal\Tests\Component\Annotation\Doctrine\Name'),
// alias for internal type boolean
array('bool','bool', '1','integer'),
array('bool','bool', '1.2','double'),
array('bool','bool', '"str"','string'),
array('bool','bool', '{"str"}','array'),
// integer type
array('integer','integer', 'true','boolean'),
array('integer','integer', 'false','boolean'),
array('integer','integer', '1.2','double'),
array('integer','integer', '"str"','string'),
array('integer','integer', '{"str"}','array'),
array('integer','integer', '{1,2,3,4}','array'),
// alias for internal type double
array('float','float', 'true','boolean'),
array('float','float', 'false','boolean'),
array('float','float', '123','integer'),
array('float','float', '"str"','string'),
array('float','float', '{"str"}','array'),
array('float','float', '{12.34}','array'),
array('float','float', '{1,2,3}','array'),
// string type
array('string','string', 'true','boolean'),
array('string','string', 'false','boolean'),
array('string','string', '12','integer'),
array('string','string', '1.2','double'),
array('string','string', '{"str"}','array'),
array('string','string', '{1,2,3,4}','array'),
// annotation instance
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', 'true','boolean'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', 'false','boolean'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '12','integer'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '1.2','double'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{"str"}','array'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{1,2,3,4}','array'),
array('annotation','Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '@Name','an instance of Drupal\Tests\Component\Annotation\Doctrine\Name'),
);
}
public function <API key>()
{
//({attribute name}, {type declared type}, {attribute value} , {given type or class})
return array(
array('arrayOfIntegers', 'integer', 'true', 'boolean'),
array('arrayOfIntegers', 'integer', 'false', 'boolean'),
array('arrayOfIntegers', 'integer', '{true,true}', 'boolean'),
array('arrayOfIntegers', 'integer', '{1,true}', 'boolean'),
array('arrayOfIntegers', 'integer', '{1,2,1.2}', 'double'),
array('arrayOfIntegers', 'integer', '{1,2,"str"}', 'string'),
array('arrayOfStrings', 'string', 'true', 'boolean'),
array('arrayOfStrings', 'string', 'false', 'boolean'),
array('arrayOfStrings', 'string', '{true,true}', 'boolean'),
array('arrayOfStrings', 'string', '{"foo",true}', 'boolean'),
array('arrayOfStrings', 'string', '{"foo","bar",1.2}', 'double'),
array('arrayOfStrings', 'string', '1', 'integer'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', 'true', 'boolean'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', 'false', 'boolean'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll,true}', 'boolean'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll,true}', 'boolean'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll,1.2}', 'double'),
array('arrayOfAnnotations', 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll', '{@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll,@<API key>,"str"}', 'string'),
);
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute, $value)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::$invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
$result = $parser->parse($docblock, $context);
$this->assertTrue(sizeof($result) === 1);
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]);
$this->assertNotNull($result[0]->$attribute);
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute,$type,$value,$given)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
try {
$parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains("[Type Error] Attribute \"$attribute\" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage());
}
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute,$type,$value,$given)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
try {
$parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains("[Type Error] Attribute \"$attribute\" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage());
}
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute, $value)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::$invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
$result = $parser->parse($docblock, $context);
$this->assertTrue(sizeof($result) === 1);
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]);
$getter = "get".ucfirst($attribute);
$this->assertNotNull($result[0]->$getter());
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute,$type,$value,$given)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
try {
$parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains("[Type Error] Attribute \"$attribute\" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage());
}
}
/**
* @dataProvider <API key>
*/
public function <API key>($attribute,$type,$value,$given)
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(%s = %s)',$attribute, $value);
$parser->setTarget(Target::TARGET_PROPERTY);
try {
$parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains("[Type Error] Attribute \"$attribute\" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage());
}
}
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$parser->setTarget(Target::TARGET_PROPERTY);
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("Some Value", annot = @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>)';
$result = $parser->parse($docblock);
$this->assertTrue(sizeof($result) === 1);
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]);
$this->assertEquals("Some Value",$result[0]->getValue());
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]->getAnnot());
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("Some Value")';
try {
$result = $parser->parse($docblock,$context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains('Attribute "annot" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>. This value should not be null.', $exc->getMessage());
}
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(annot = @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>)';
try {
$result = $parser->parse($docblock,$context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains('Attribute "value" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage());
}
}
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$parser->setTarget(Target::TARGET_PROPERTY);
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("Some Value", annot = @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>)';
$result = $parser->parse($docblock);
$this->assertTrue(sizeof($result) === 1);
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]);
$this->assertEquals("Some Value", $result[0]->value);
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $result[0]->annot);
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("Some Value")';
try {
$result = $parser->parse($docblock,$context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains('Attribute "annot" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>. This value should not be null.', $exc->getMessage());
}
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(annot = @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>)';
try {
$result = $parser->parse($docblock,$context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertContains('Attribute "value" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage());
}
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> Attribute "value" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationEnum declared on property SomeClassName::invalidProperty. accept only [ONE, TWO, THREE], but got FOUR.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationEnum("FOUR")';
$parser-><API key>(false);
$parser->setTarget(Target::TARGET_PROPERTY);
$parser->parse($docblock, $context);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> Attribute "value" of @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key> declared on property SomeClassName::invalidProperty. accept only [<API key>::ONE, <API key>::TWO, <API key>::THREE], but got 4.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(4)';
$parser-><API key>(false);
$parser->setTarget(Target::TARGET_PROPERTY);
$parser->parse($docblock, $context);
}
/**
* @expectedException \<API key>
* @<API key> @Enum supports only scalar values "array" given.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("foo")';
$parser-><API key>(false);
$parser->parse($docblock);
}
/**
* @expectedException \<API key>
* @<API key> Undefined enumerator value "3" for literal "<API key>::THREE".
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = '@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>("foo")';
$parser-><API key>(false);
$parser->parse($docblock);
}
public function <API key>()
{
$provider[] = array(
'@<API key>(PHP_EOL)',
PHP_EOL
);
$provider[] = array(
'@<API key>(<API key>::INTEGER)',
<API key>::INTEGER
);
$provider[] = array(
'@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(<API key>::STRING)',
<API key>::STRING
);
$provider[] = array(
'@<API key>(Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::FLOAT)',
<API key>::FLOAT
);
$provider[] = array(
'@<API key>(ClassWithConstants::SOME_VALUE)',
ClassWithConstants::SOME_VALUE
);
$provider[] = array(
'@<API key>(ClassWithConstants::OTHER_KEY_)',
ClassWithConstants::OTHER_KEY_
);
$provider[] = array(
'@<API key>(ClassWithConstants::OTHER_KEY_2)',
ClassWithConstants::OTHER_KEY_2
);
$provider[] = array(
'@<API key>(Drupal\Tests\Component\Annotation\Doctrine\Fixtures\ClassWithConstants::SOME_VALUE)',
ClassWithConstants::SOME_VALUE
);
$provider[] = array(
'@<API key>(<API key>::SOME_VALUE)',
<API key>::SOME_VALUE
);
$provider[] = array(
'@<API key>(\Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::SOME_VALUE)',
<API key>::SOME_VALUE
);
$provider[] = array(
'@<API key>({<API key>::STRING, <API key>::INTEGER, <API key>::FLOAT})',
array(<API key>::STRING, <API key>::INTEGER, <API key>::FLOAT)
);
$provider[] = array(
'@<API key>({
<API key>::STRING = <API key>::INTEGER
})',
array(<API key>::STRING => <API key>::INTEGER)
);
$provider[] = array(
'@<API key>({
Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::SOME_KEY = <API key>::INTEGER
})',
array(<API key>::SOME_KEY => <API key>::INTEGER)
);
$provider[] = array(
'@<API key>({
\Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::SOME_KEY = <API key>::INTEGER
})',
array(<API key>::SOME_KEY => <API key>::INTEGER)
);
$provider[] = array(
'@<API key>({
<API key>::STRING = <API key>::INTEGER,
ClassWithConstants::SOME_KEY = ClassWithConstants::SOME_VALUE,
Drupal\Tests\Component\Annotation\Doctrine\Fixtures\ClassWithConstants::SOME_KEY = <API key>::SOME_VALUE
})',
array(
<API key>::STRING => <API key>::INTEGER,
ClassWithConstants::SOME_KEY => ClassWithConstants::SOME_VALUE,
ClassWithConstants::SOME_KEY => <API key>::SOME_VALUE
)
);
$provider[] = array(
'@<API key>(<API key>::class)',
'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>'
);
$provider[] = array(
'@<API key>({<API key>::class = <API key>::class})',
array('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>')
);
$provider[] = array(
'@<API key>(Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::class)',
'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>'
);
$provider[] = array(
'@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>(Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>::class)',
'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>'
);
return $provider;
}
/**
* @dataProvider <API key>
*/
public function <API key>($docblock, $expected)
{
$parser = $this->createTestParser();
$parser->setImports(array(
'classwithconstants' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\ClassWithConstants',
'<API key>' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>',
'<API key>' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>'
));
$result = $parser->parse($docblock);
$this->assertInstanceOf('\Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>', $annotation = $result[0]);
$this->assertEquals($expected, $annotation->value);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> The annotation @<API key> declared on does not accept any values, but got {"value":"Foo"}.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* @<API key>("Foo")
*/
DOCBLOCK;
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docblock);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> The annotation @<API key> declared on does not accept any values, but got {"value":"Foo"}.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* @<API key>(value = "Foo")
*/
DOCBLOCK;
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docblock);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> Expected namespace separator or identifier, got ')' at position 24 in class @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'class ' . 'SomeClassName';
$docblock = <<<DOCBLOCK
/**
* @Drupal\Tests\Component\Annotation\Doctrine\Fixtures\<API key>()
*/
DOCBLOCK;
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docblock,$context);
}
/**
* @expectedException \<API key>
* @<API key> Invalid Target "Foo". Available targets: [ALL, CLASS, METHOD, PROPERTY, ANNOTATION]
*/
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'class ' . 'SomeClassName';
$docblock = <<<DOCBLOCK
/**
* @<API key>()
*/
DOCBLOCK;
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docblock,$context);
}
/**
* @expectedException \<API key>
* @<API key> @Target expects either a string value, or an array of strings, "NULL" given.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$context = 'class ' . 'SomeClassName';
$docblock = <<<DOCBLOCK
/**
* @<API key>()
*/
DOCBLOCK;
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($docblock,$context);
}
/**
* @group DDC-575
*/
public function <API key>()
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* @Name
*
* Will trigger error.
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertInstanceOf("Drupal\Tests\Component\Annotation\Doctrine\Name", $result[0]);
$docblock = <<<DOCBLOCK
/**
* @Name
* @Marker
*
* Will trigger error.
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertInstanceOf("Drupal\Tests\Component\Annotation\Doctrine\Name", $result[0]);
}
/**
* @group DDC-77
*/
public function <API key>()
{
$parser = new DocParser();
$parser-><API key>(true);
$result = $parser->parse("@param");
$this->assertEquals(0, count($result));
}
/**
* @group DCOM-168
*/
public function <API key>()
{
$parser = new DocParser();
$parser-><API key>(true);
$parser-><API key>(array('<API key>' => true));
$result = $parser->parse('@<API key>');
$this->assertEquals(0, count($result));
}
* @<API key> Expected PlainValue, got ''' at position 10.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$parser->parse("@Name(foo='bar')");
}
/**
* @group DCOM-41
*/
public function <API key>()
{
$parser = new DocParser();
$result = $parser->parse("'@'");
$this->assertEquals(0, count($result));
}
/**
* @group DCOM-41
* @expectedException \Doctrine\Common\Annotations\AnnotationException
*/
public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifierInNestedAnnotation()
{
$parser = new DocParser();
$parser->parse("@Drupal\Tests\Component\Annotation\Doctrine\Name(@')");
}
/**
* @group DCOM-56
*/
public function <API key>()
{
$this->assertFalse(class_exists('Drupal\Tests\Component\Annotation\Doctrine\Fixture\Annotation\Autoload', false), 'Pre-condition: Drupal\Tests\Component\Annotation\Doctrine\Fixture\Annotation\Autoload not allowed to be loaded.');
$parser = new DocParser();
AnnotationRegistry::<API key>('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\Annotation', __DIR__ . '/../../../../');
$parser->setImports(array(
'autoload' => 'Drupal\Tests\Component\Annotation\Doctrine\Fixtures\Annotation\Autoload',
));
$annotations = $parser->parse('@Autoload');
$this->assertEquals(1, count($annotations));
$this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\Annotation\Autoload', $annotations[0]);
}
public function createTestParser()
{
$parser = new DocParser();
$parser-><API key>(true);
$parser->setImports(array(
'name' => 'Drupal\Tests\Component\Annotation\Doctrine\Name',
'__NAMESPACE__' => 'Drupal\Tests\Component\Annotation\Doctrine',
));
return $parser;
}
/**
* @group DDC-78
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> Expected PlainValue, got ''' at position 10 in class \Drupal\Tests\Component\Annotation\Doctrine\Name
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
*/
public function <API key>()
{
$parser = $this->createTestParser();
$parser->parse("@Name(foo='bar')", "class \Drupal\Tests\Component\Annotation\Doctrine\Name");
}
/**
* @group DDC-183
*/
public function <API key>()
{
$docblock = <<<DOCBLOCK
/**
* @test at.
*/
class A {
}
DOCBLOCK;
//$lexer = new \Doctrine\Common\Annotations\Lexer();
//$lexer->setInput(trim($docblock, '/ *'));
//var_dump($lexer);
try {
$parser = $this->createTestParser();
$result = $parser->parse($docblock);
$this->assertTrue(is_array($result) && empty($result));
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
/**
* @group DCOM-14
*/
public function <API key>()
{
$docblock = <<<DOCBLOCK
/**
* @throws \RuntimeException
*/
class A {
}
DOCBLOCK;
try {
$parser = $this->createTestParser();
$result = $parser->parse($docblock);
$this->assertTrue(is_array($result) && empty($result));
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
/**
* @group DCOM-38
*/
public function testCastInt()
{
$parser = $this->createTestParser();
$result = $parser->parse("@Name(foo=1234)");
$annot = $result[0];
$this->assertInternalType('int', $annot->foo);
}
/**
* @group DCOM-38
*/
public function testCastNegativeInt()
{
$parser = $this->createTestParser();
$result = $parser->parse("@Name(foo=-1234)");
$annot = $result[0];
$this->assertInternalType('int', $annot->foo);
}
/**
* @group DCOM-38
*/
public function testCastFloat()
{
$parser = $this->createTestParser();
$result = $parser->parse("@Name(foo=1234.345)");
$annot = $result[0];
$this->assertInternalType('float', $annot->foo);
}
/**
* @group DCOM-38
*/
public function <API key>()
{
$parser = $this->createTestParser();
$result = $parser->parse("@Name(foo=-1234.345)");
$annot = $result[0];
$this->assertInternalType('float', $annot->foo);
$result = $parser->parse("@Marker(-1234.345)");
$annot = $result[0];
$this->assertInternalType('float', $annot->value);
}
public function <API key>()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('This test requires PHP 5.6 or lower.');
}
require '<API key>.php';
$parser = $this->createTestParser();
$result = $parser->parse('@Drupal\Tests\Component\Annotation\Doctrine\True');
$this->assertTrue($result[0] instanceof True);
$result = $parser->parse('@Drupal\Tests\Component\Annotation\Doctrine\False');
$this->assertTrue($result[0] instanceof False);
$result = $parser->parse('@Drupal\Tests\Component\Annotation\Doctrine\Null');
$this->assertTrue($result[0] instanceof Null);
$result = $parser->parse('@True');
$this->assertTrue($result[0] instanceof True);
$result = $parser->parse('@False');
$this->assertTrue($result[0] instanceof False);
$result = $parser->parse('@Null');
$this->assertTrue($result[0] instanceof Null);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> [Creation Error] The annotation @<API key> declared on some class does not have a property named "invalidaProperty". Available properties: data, name
*/
public function <API key>()
{
$docblock = <<<DOCBLOCK
/**
* @<API key>(invalidaProperty = "Some val")
*/
DOCBLOCK;
$this->createTestParser()->parse($docblock, 'some class');
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_IDENTIFIER or Doctrine\Common\Annotations\DocLexer::T_TRUE or Doctrine\Common\Annotations\DocLexer::T_FALSE or Doctrine\Common\Annotations\DocLexer::T_NULL, got '3.42' at position 5.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$parser->parse('@Foo\3.42');
}
public function <API key>()
{
$parser = $this->createTestParser();
$annots = $parser->parse('@Name({
"Foo",
"Bar",
})');
$this->assertEquals(1, count($annots));
$this->assertEquals(array('Foo', 'Bar'), $annots[0]->value);
}
public function <API key>()
{
$parser = $this->createTestParser();
$annots = $parser->parse('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\Annotation\<API key>');
$this->assertEquals(1, count($annots));
$this->assertEquals('bar', $annots[0]->foo);
}
public function testArrayWithColon()
{
$parser = $this->createTestParser();
$annots = $parser->parse('@Name({"foo": "bar"})');
$this->assertEquals(1, count($annots));
$this->assertEquals(array('foo' => 'bar'), $annots[0]->value);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @<API key> [Semantical Error] Couldn't find constant foo.
*/
public function <API key>()
{
$parser = $this->createTestParser();
$parser->parse('@Name(foo: "bar")');
}
/**
* Tests parsing empty arrays.
*/
public function testEmptyArray()
{
$parser = $this->createTestParser();
$annots = $parser->parse('@Name({"foo": {}})');
$this->assertEquals(1, count($annots));
$this->assertEquals(array('foo' => array()), $annots[0]->value);
}
public function testKeyHasNumber()
{
$parser = $this->createTestParser();
$annots = $parser->parse('@SettingsAnnotation(foo="test", bar2="test")');
$this->assertEquals(1, count($annots));
$this->assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings);
}
/**
* @group 44
*/
public function <API key>()
{
$result = $this->createTestParser()->parse('@Drupal\Tests\Component\Annotation\Doctrine\Name(foo="""bar""")');
$this->assertCount(1, $result);
$this->assertTrue($result[0] instanceof Name);
$this->assertEquals('"bar"', $result[0]->foo);
}
}
/** @Annotation */
class SettingsAnnotation
{
public $settings;
public function __construct($settings)
{
$this->settings = $settings;
}
}
/** @Annotation */
class <API key>
{
public $data;
public $name;
}
/** @Annotation */
class <API key>
{
function __construct()
{
$this->data = "Some data";
}
public $data;
public $name;
}
/** @Annotation */
class <API key>{}
/**
* @Annotation
* @Target("Foo")
*/
class <API key>{}
/**
* @Annotation
* @Target
*/
class <API key>{}
/** @Annotation */
class <API key> extends \Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationTargetAll
{
}
/** @Annotation */
class Name extends \Doctrine\Common\Annotations\Annotation {
public $foo;
}
/** @Annotation */
class Marker {
public $value;
}
namespace Drupal\Tests\Component\Annotation\Doctrine\FooBar;
/** @Annotation */
class Name extends \Doctrine\Common\Annotations\Annotation {
}
|
#include "<API key>.h"
#include "MoveSpline.h"
#include "ByteBuffer.h"
namespace Movement
{
inline void operator << (ByteBuffer& b, const Vector3& v)
{
b << v.x << v.y << v.z;
}
inline void operator >> (ByteBuffer& b, Vector3& v)
{
b >> v.x >> v.y >> v.z;
}
enum MonsterMoveType
{
MonsterMoveNormal = 0,
MonsterMoveStop = 1,
<API key> = 2,
<API key> = 3,
<API key> = 4
};
void PacketBuilder::<API key>(const MoveSpline& move_spline, ByteBuffer& data)
{
MoveSplineFlag splineflags = move_spline.splineflags;
data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
data << move_spline.spline.getPoint(move_spline.spline.first());
data << move_spline.GetId();
switch (splineflags & MoveSplineFlag::Mask_Final_Facing)
{
case MoveSplineFlag::Final_Target:
data << uint8(<API key>);
data << move_spline.facing.target;
break;
case MoveSplineFlag::Final_Angle:
data << uint8(<API key>);
data << move_spline.facing.angle;
break;
case MoveSplineFlag::Final_Point:
data << uint8(<API key>);
data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z;
break;
default:
data << uint8(MonsterMoveNormal);
break;
}
// add fake Enter_Cycle flag - needed for client-side cyclic movement (client will erase first spline vertex after first cycle done)
splineflags.enter_cycle = move_spline.isCyclic();
data << uint32(splineflags & uint32(~MoveSplineFlag::<API key>));
if (splineflags.animation)
{
data << splineflags.getAnimationId();
data << move_spline.effect_start_time;
}
data << move_spline.Duration();
if (splineflags.parabolic)
{
data << move_spline.<API key>;
data << move_spline.effect_start_time;
}
}
void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data)
{
data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
data << pos;
data << splineId;
data << uint8(MonsterMoveStop);
}
void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
{
uint32 last_idx = spline.getPointCount() - 3;
const Vector3 * real_path = &spline.getPoint(1);
data << last_idx;
data << real_path[last_idx]; // destination
if (last_idx > 1)
{
Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
Vector3 offset;
// first and last points already appended
for (uint32 i = 1; i < last_idx; ++i)
{
offset = middle - real_path[i];
data.appendPackXYZ(offset.x, offset.y, offset.z);
}
}
}
void WriteCatmullRomPath(const Spline<int32>& spline, ByteBuffer& data)
{
uint32 count = spline.getPointCount() - 3;
data << count;
data.append<Vector3>(&spline.getPoint(2), count);
}
void <API key>(const Spline<int32>& spline, ByteBuffer& data)
{
uint32 count = spline.getPointCount() - 3;
data << uint32(count + 1);
data << spline.getPoint(1); // fake point, client will erase it from the spline after first cycle done
data.append<Vector3>(&spline.getPoint(1), count);
}
void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, ByteBuffer& data)
{
<API key>(move_spline, data);
const Spline<int32>& spline = move_spline.spline;
MoveSplineFlag splineflags = move_spline.splineflags;
if (splineflags & MoveSplineFlag::Mask_CatmullRom)
{
if (splineflags.cyclic)
<API key>(spline, data);
else
WriteCatmullRomPath(spline, data);
}
else
WriteLinearPath(spline, data);
}
void PacketBuilder::WriteCreate(const MoveSpline& move_spline, ByteBuffer& data)
{
//WriteClientStatus(mov, data);
//data.append<float>(&mov.m_float_values[SpeedWalk], SpeedMaxCount);
//if (mov.SplineEnabled())
{
MoveSplineFlag const& splineFlags = move_spline.splineflags;
data << splineFlags.raw();
if (splineFlags.final_angle)
{
data << move_spline.facing.angle;
}
else if (splineFlags.final_target)
{
data << move_spline.facing.target;
}
else if (splineFlags.final_point)
{
data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z;
}
data << move_spline.timePassed();
data << move_spline.Duration();
data << move_spline.GetId();
data << float(1.f); // splineInfo.duration_mod; added in 3.1
data << float(1.f); // splineInfo.duration_mod_next; added in 3.1
data << move_spline.<API key>; // added in 3.1
data << move_spline.effect_start_time; // added in 3.1
uint32 nodes = move_spline.getPath().size();
data << nodes;
data.append<Vector3>(&move_spline.getPath()[0], nodes);
data << uint8(move_spline.spline.mode()); // added in 3.1
data << (move_spline.isCyclic() ? Vector3::zero() : move_spline.FinalDestination());
}
}
}
|
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/setup.h>
#include <asm/mach/time.h>
#include <asm/mach/arch.h>
#include <asm/mach-types.h>
#include <asm/hardware/gic.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/localtimer.h>
#include <mach/hardware.h>
#include <linux/i2c.h>
#include <linux/i2c/ft5306_ts.h>
#include <linux/i2c/lis3dh.h>
#include <linux/i2c/ltr_558als.h>
#include <linux/akm8975.h>
#include <linux/spi/spi.h>
#include <mach/board.h>
#include <mach/serial_sprd.h>
#include <mach/adi.h>
#include <mach/adc.h>
#include "../devices.h"
#include <linux/gpio.h>
#include <linux/mpu.h>
#include <linux/akm8975.h>
#include <linux/irq.h>
#include <mach/sci.h>
#include <mach/hardware.h>
#include <mach/regs_glb.h>
#include <mach/regs_ahb.h>
#include <mach/pinmap.h>
/* IRQ's for the multi sensor board */
#define MPUIRQ_GPIO 212
extern void __init sc8825_reserve(void);
extern void __init sci_map_io(void);
extern void __init sc8825_init_irq(void);
extern void __init sc8825_timer_init(void);
extern int __init <API key>(void);
extern int __init sci_clock_init(void);
#ifdef <API key>
extern int __init <API key>(void);
#endif
static struct platform_device rfkill_device;
static struct platform_device kb_backlight_device;
static struct platform_device *devices[] __initdata = {
&sprd_serial_device0,
&sprd_serial_device1,
&sprd_serial_device2,
&sprd_device_rtc,
&sprd_nand_device,
&sprd_lcd_device0,
&<API key>,
&sprd_i2c_device0,
&sprd_i2c_device1,
&sprd_i2c_device2,
&sprd_i2c_device3,
&sprd_spi0_device,
&sprd_spi1_device,
&sprd_spi2_device,
&sprd_keypad_device,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&sprd_battery_device,
#ifdef CONFIG_ANDROID_PMEM
&sprd_pmem_device,
&<API key>,
#endif
#ifdef CONFIG_ION
&sprd_ion_dev,
#endif
&sprd_emmc_device,
&sprd_sdio0_device,
&sprd_sdio1_device,
&sprd_sdio2_device,
&sprd_vsp_device,
&sprd_dcam_device,
&sprd_scale_device,
&<API key>,
&sprd_sensor_device,
&sprd_isp_device,
&sprd_ahb_bm0_device,
&sprd_ahb_bm1_device,
&sprd_ahb_bm2_device,
&sprd_ahb_bm3_device,
&sprd_ahb_bm4_device,
&sprd_axi_bm0_device,
&sprd_axi_bm1_device,
&sprd_axi_bm2_device,
#ifdef CONFIG_SIPC
&<API key>,
&<API key>,
&sprd_slog_td_device,
&sprd_stty_td_device,
#endif
&kb_backlight_device,
&rfkill_device,
};
/* RFKILL */
static struct resource rfkill_resources[] = {
{
.name = "bt_reset",
.start = GPIO_BT_RESET,
.end = GPIO_BT_RESET,
.flags = IORESOURCE_IO,
},
};
static struct platform_device rfkill_device = {
.name = "rfkill",
.id = -1,
.num_resources = ARRAY_SIZE(rfkill_resources),
.resource = rfkill_resources,
};
/* keypad backlight */
static struct platform_device kb_backlight_device = {
.name = "keyboard-backlight",
.id = -1,
};
static struct sys_timer sc8825_timer = {
.init = sc8825_timer_init,
};
static int calibration_mode = false;
static int __init calibration_start(char *str)
{
if(str)
pr_info("modem calibartion:%s\n", str);
calibration_mode = true;
return 1;
}
__setup("calibration=", calibration_start);
int in_calibration(void)
{
return (calibration_mode == true);
}
EXPORT_SYMBOL(in_calibration);
static void __init sprd_add_otg_device(void)
{
/*
* if in calibrtaion mode, we do nothing, modem will handle everything
*/
if (calibration_mode)
return;
<API key>(&sprd_otg_device);
}
static struct serial_data plat_data0 = {
.wakeup_type = <API key>,
.clk = 48000000,
};
static struct serial_data plat_data1 = {
.wakeup_type = <API key>,
.clk = 26000000,
};
static struct serial_data plat_data2 = {
.wakeup_type = <API key>,
.clk = 26000000,
};
static struct <API key> ft5x0x_ts_info = {
.irq_gpio_number = GPIO_TOUCH_IRQ,
.reset_gpio_number = GPIO_TOUCH_RESET,
.vdd_name = "vdd28",
};
static struct <API key> ltr558_pls_info = {
.irq_gpio_number = GPIO_PLSENSOR_IRQ,
};
static struct <API key> lis3dh_plat_data = {
.poll_interval = 10,
.min_interval = 10,
.g_range = LIS3DH_ACC_G_2G,
.axis_map_x = 1,
.axis_map_y = 0,
.axis_map_z = 2,
.negate_x = 0,
.negate_y = 0,
.negate_z = 1
};
struct <API key> akm8975_platform_d = {
.mag_low_x = -20480,
.mag_high_x = 20479,
.mag_low_y = -20480,
.mag_high_y = 20479,
.mag_low_z = -20480,
.mag_high_z = 20479,
};
static struct mpu_platform_data <API key> = {
.int_config = 0x00,
.level_shifter = 0,
.orientation = { -1, 0, 0,
0, -1, 0,
0, 0, +1 },
.sec_slave_type = <API key>,
.sec_slave_id = COMPASS_ID_AK8963,
.secondary_i2c_addr = 0x0C,
.<API key> = { 0, -1, 0,
1, 0, 0,
0, 0, 1 },
.key = {0xec, 0x06, 0x17, 0xdf, 0x77, 0xfc, 0xe6, 0xac,
0x7b, 0x6f, 0x12, 0x8a, 0x1d, 0x63, 0x67, 0x37},
};
static struct i2c_board_info i2c2_boardinfo[] = {
{ I2C_BOARD_INFO(LIS3DH_ACC_I2C_NAME, LIS3DH_ACC_I2C_ADDR),
.platform_data = &lis3dh_plat_data,
},
{ I2C_BOARD_INFO("mpu9150", 0x68),
.irq = MPUIRQ_GPIO,
.platform_data = &<API key>,
},
{ I2C_BOARD_INFO(LTR558_I2C_NAME, LTR558_I2C_ADDR),
.platform_data = <r558_pls_info,
},
{ I2C_BOARD_INFO("BEKEN_FM", 0x70),
},
/* { I2C_BOARD_INFO(AKM8975_I2C_NAME, AKM8975_I2C_ADDR),
.platform_data = &akm8975_platform_d,
},*/
};
static struct i2c_board_info i2c1_boardinfo[] = {
{I2C_BOARD_INFO("sensor_main",0x3C),},
{I2C_BOARD_INFO("sensor_sub",0x21),},
};
static struct i2c_board_info i2c0_boardinfo[] = {
{
I2C_BOARD_INFO(FT5206_TS_DEVICE, FT5206_TS_ADDR),
.platform_data = &ft5x0x_ts_info,
},
};
static int <API key>(void)
{
<API key>(2, i2c2_boardinfo, ARRAY_SIZE(i2c2_boardinfo));
<API key>(1, i2c1_boardinfo, ARRAY_SIZE(i2c1_boardinfo));
<API key>(0, i2c0_boardinfo, ARRAY_SIZE(i2c0_boardinfo));
return 0;
}
struct platform_device <API key> = {
.name = "speaker-pa",
.id = -1,
};
static int <API key>(u32 cmd, void *data)
{
int ret = 0;
if (cmd < 0) {
/* get speaker amplifier status : enabled or disabled */
ret = 0;
} else {
/* set speaker amplifier */
}
return ret;
}
const char * <API key>[] = {
/*supply source, consumer0, consumer1, ..., NULL */
"vdd28", "iic_vdd", "ctp_vdd", NULL,
"vddsd0", "tflash_vcc", NULL,
"vddsim0", "nfc_vcc", NULL,
"vddsim1", "sim_vcc", NULL,
NULL,
};
int __init <API key>(void)
{
static struct platform_device <API key> = {
.name = "sprd-regulator",
.id = -1,
.dev = {.platform_data = <API key>},
};
return <API key>(&<API key>);
}
int __init <API key>(void)
{
/* FIXME: Force disable all unused clocks */
sci_glb_clr(REG_AHB_AHB_CTL0,
BIT_AXIBUSMON2_EB |
BIT_AXIBUSMON1_EB |
BIT_AXIBUSMON0_EB |
// BIT_EMC_EB |
// BIT_AHB_ARCH_EB |
// BIT_SPINLOCK_EB |
BIT_SDIO2_EB |
BIT_EMMC_EB |
// BIT_DISPC_EB |
BIT_G3D_EB |
BIT_SDIO1_EB |
BIT_DRM_EB |
BIT_BUSMON4_EB |
BIT_BUSMON3_EB |
BIT_BUSMON2_EB |
BIT_ROT_EB |
BIT_VSP_EB |
BIT_ISP_EB |
BIT_BUSMON1_EB |
BIT_DCAM_MIPI_EB |
BIT_CCIR_EB |
BIT_NFC_EB |
BIT_BUSMON0_EB |
// BIT_DMA_EB |
// BIT_USBD_EB |
BIT_SDIO0_EB |
// BIT_LCDC_EB |
BIT_CCIR_IN_EB |
BIT_DCAM_EB |
0);
sci_glb_clr(REG_AHB_AHB_CTL2,
// BIT_DISPMTX_CLK_EN |
BIT_MMMTX_CLK_EN |
// <API key>|
// <API key>|
BIT_ISP_CORE_CLK_EN |
BIT_VSP_CORE_CLK_EN |
<API key>|
0);
sci_glb_clr(REG_AHB_AHB_CTL3,
// BIT_CLK_ULPI_EN |
// BIT_CLK_USB_REF_EN |
0);
sci_glb_clr(REG_GLB_GEN0,
BIT_IC3_EB |
BIT_IC2_EB |
BIT_IC1_EB |
// BIT_RTC_TMR_EB |
// BIT_RTC_SYST0_EB |
BIT_RTC_KPD_EB |
BIT_IIS1_EB |
// BIT_RTC_EIC_EB |
BIT_UART2_EB |
// BIT_UART1_EB |
BIT_UART0_EB |
// BIT_SYST0_EB |
BIT_SPI1_EB |
BIT_SPI0_EB |
// BIT_SIM1_EB |
// BIT_EPT_EB |
BIT_CCIR_MCLK_EN |
// BIT_PINREG_EB |
BIT_IIS0_EB |
// BIT_MCU_DSP_RST |
// BIT_EIC_EB |
BIT_KPD_EB |
BIT_EFUSE_EB |
// BIT_ADI_EB |
// BIT_GPIO_EB |
BIT_I2C0_EB |
// BIT_SIM0_EB |
// BIT_TMR_EB |
BIT_SPI2_EB |
BIT_UART3_EB |
0);
sci_glb_clr(REG_AHB_CA5_CFG,
// BIT_CA5_CLK_DBG_EN |
0);
sci_glb_clr(REG_GLB_GEN1,
BIT_AUDIF_AUTO_EN |
BIT_VBC_EN |
BIT_AUD_TOP_EB |
BIT_AUD_IF_EB |
BIT_CLK_AUX1_EN |
BIT_CLK_AUX0_EN |
0);
sci_glb_clr(REG_GLB_CLK_EN,
BIT_PWM3_EB |
//BIT_PWM2_EB |
BIT_PWM1_EB |
// BIT_PWM0_EB |
0);
sci_glb_clr(REG_GLB_PCTRL,
// BIT_MCU_MPLL_EN |
// BIT_MCU_TDPLL_EN |
// BIT_MCU_DPLL_EN |
BIT_MCU_GPLL_EN); /* clk_gpu */
sci_glb_set(REG_GLB_TD_PLL_CTL,
// <API key> | /* clk_384m */
// <API key> | /* clk_256m */
// <API key> | /* clk_192m */
// <API key> | /* clk_153p6m */
0);
printk("sc8825 clock module early init ok\n");
return 0;
}
static void __init sc8825_init_machine(void)
{
#ifdef <API key>
<API key>();
#endif
sci_adc_init((void __iomem *)ADC_BASE);
<API key>();
sprd_add_otg_device();
<API key>(&sprd_serial_device0,(const void*)&plat_data0,sizeof(plat_data0));
<API key>(&sprd_serial_device1,(const void*)&plat_data1,sizeof(plat_data1));
<API key>(&sprd_serial_device2,(const void*)&plat_data2,sizeof(plat_data2));
<API key>(devices, ARRAY_SIZE(devices));
<API key>();
}
extern void <API key>(void);
static void __init sc8825_init_early(void)
{
/* earlier init request than irq and timer */
<API key>();
<API key>();
sci_adi_init();
}
/*
* Setup the memory banks.
*/
static void __init sc8825_fixup(struct machine_desc *desc,
struct tag *tags, char **cmdline, struct meminfo *mi)
{
}
MACHINE_START(SC8825OPENPHONE, "sc8825")
.reserve = sc8825_reserve,
.map_io = sci_map_io,
.fixup = sc8825_fixup,
.init_early = sc8825_init_early,
.init_irq = sc8825_init_irq,
.timer = &sc8825_timer,
.init_machine = sc8825_init_machine,
MACHINE_END
|
#include <linux/init.h>
#include <linux/export.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/ioport.h>
#include <linux/io.h>
#include <linux/dma-mapping.h>
#include <linux/compiler.h>
#include <linux/stddef.h>
#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/acpi.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/mmc/host.h>
#include <linux/mmc/pm.h>
#include <linux/mmc/sdhci.h>
#include "sdhci.h"
enum {
SDHCI_ACPI_SD_CD = BIT(0),
<API key> = BIT(1),
};
struct sdhci_acpi_chip {
const struct sdhci_ops *ops;
unsigned int quirks;
unsigned int quirks2;
unsigned long caps;
unsigned int caps2;
mmc_pm_flag_t pm_caps;
};
struct sdhci_acpi_slot {
const struct sdhci_acpi_chip *chip;
unsigned int quirks;
unsigned int quirks2;
unsigned long caps;
unsigned int caps2;
mmc_pm_flag_t pm_caps;
unsigned int flags;
};
struct sdhci_acpi_host {
struct sdhci_host *host;
const struct sdhci_acpi_slot *slot;
struct platform_device *pdev;
bool use_runtime_pm;
};
static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag)
{
return c->slot && (c->slot->flags & flag);
}
static int <API key>(struct sdhci_host *host)
{
return 0;
}
static void <API key>(struct sdhci_host *host)
{
u8 reg;
reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
reg |= 0x10;
sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
/* For eMMC, minimum is 1us but give it 9us for good measure */
udelay(9);
reg &= ~0x10;
sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
/* For eMMC, minimum is 200us but give it 300us for good measure */
usleep_range(300, 1000);
}
static const struct sdhci_ops sdhci_acpi_ops_dflt = {
.enable_dma = <API key>,
};
static const struct sdhci_ops sdhci_acpi_ops_int = {
.enable_dma = <API key>,
.hw_reset = <API key>,
};
static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
.ops = &sdhci_acpi_ops_int,
};
static const struct sdhci_acpi_slot <API key> = {
.chip = &sdhci_acpi_chip_int,
.caps = MMC_CAP_8_BIT_DATA | <API key> | MMC_CAP_HW_RESET,
.caps2 = <API key>,
.flags = <API key>,
};
static const struct sdhci_acpi_slot <API key> = {
.quirks2 = <API key>,
.caps = <API key> | <API key>,
.flags = <API key>,
.pm_caps = MMC_PM_KEEP_POWER,
};
static const struct sdhci_acpi_slot <API key> = {
.flags = SDHCI_ACPI_SD_CD | <API key>,
.quirks2 = <API key>,
};
struct sdhci_acpi_uid_slot {
const char *hid;
const char *uid;
const struct sdhci_acpi_slot *slot;
};
static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
{ "80860F14" , "1" , &<API key> },
{ "80860F14" , "3" , &<API key> },
{ "INT33BB" , "2" , &<API key> },
{ "INT33C6" , NULL, &<API key> },
{ "PNP0D40" },
{ },
};
static const struct acpi_device_id sdhci_acpi_ids[] = {
{ "80860F14" },
{ "INT33BB" },
{ "INT33C6" },
{ "PNP0D40" },
{ },
};
MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
static const struct sdhci_acpi_slot *<API key>(const char *hid,
const char *uid)
{
const struct sdhci_acpi_uid_slot *u;
for (u = sdhci_acpi_uids; u->hid; u++) {
if (strcmp(u->hid, hid))
continue;
if (!u->uid)
return u->slot;
if (uid && !strcmp(u->uid, uid))
return u->slot;
}
return NULL;
}
static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(acpi_handle handle,
const char *hid)
{
const struct sdhci_acpi_slot *slot;
struct acpi_device_info *info;
const char *uid = NULL;
acpi_status status;
status = <API key>(handle, &info);
if (!ACPI_FAILURE(status) && (info->valid & ACPI_VALID_UID))
uid = info->unique_id.string;
slot = <API key>(hid, uid);
kfree(info);
return slot;
}
#ifdef CONFIG_PM_RUNTIME
static irqreturn_t sdhci_acpi_sd_cd(int irq, void *dev_id)
{
mmc_detect_change(dev_id, msecs_to_jiffies(200));
return IRQ_HANDLED;
}
static int <API key>(struct device *dev, struct mmc_host *mmc)
{
struct gpio_desc *desc;
unsigned long flags;
int err, irq;
desc = <API key>(dev, "sd_cd", 0);
if (IS_ERR(desc)) {
err = PTR_ERR(desc);
goto out;
}
err = <API key>(desc);
if (err)
goto out_free;
irq = gpiod_to_irq(desc);
if (irq < 0) {
err = irq;
goto out_free;
}
flags = IRQF_TRIGGER_RISING | <API key>;
err = devm_request_irq(dev, irq, sdhci_acpi_sd_cd, flags, "sd_cd", mmc);
if (err)
goto out_free;
return 0;
out_free:
devm_gpiod_put(dev, desc);
out:
dev_warn(dev, "failed to setup card detect wake up\n");
return err;
}
#else
static int <API key>(struct device *dev, struct mmc_host *mmc)
{
return 0;
}
#endif
static int sdhci_acpi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
acpi_handle handle = ACPI_HANDLE(dev);
struct acpi_device *device;
struct sdhci_acpi_host *c;
struct sdhci_host *host;
struct resource *iomem;
resource_size_t len;
const char *hid;
int err;
if (acpi_bus_get_device(handle, &device))
return -ENODEV;
if (acpi_bus_get_status(device) || !device->status.present)
return -ENODEV;
hid = acpi_device_hid(device);
iomem = <API key>(pdev, IORESOURCE_MEM, 0);
if (!iomem)
return -ENOMEM;
len = resource_size(iomem);
if (len < 0x100)
dev_err(dev, "Invalid iomem size!\n");
if (!<API key>(dev, iomem->start, len, dev_name(dev)))
return -ENOMEM;
host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host));
if (IS_ERR(host))
return PTR_ERR(host);
c = sdhci_priv(host);
c->host = host;
c->slot = sdhci_acpi_get_slot(handle, hid);
c->pdev = pdev;
c->use_runtime_pm = sdhci_acpi_flag(c, <API key>);
<API key>(pdev, c);
host->hw_name = "ACPI";
host->ops = &sdhci_acpi_ops_dflt;
host->irq = platform_get_irq(pdev, 0);
host->ioaddr = <API key>(dev, iomem->start,
resource_size(iomem));
if (host->ioaddr == NULL) {
err = -ENOMEM;
goto err_free;
}
if (!dev->dma_mask) {
u64 dma_mask;
if (sdhci_readl(host, SDHCI_CAPABILITIES) & SDHCI_CAN_64BIT) {
/* 64-bit DMA is not supported at present */
dma_mask = DMA_BIT_MASK(32);
} else {
dma_mask = DMA_BIT_MASK(32);
}
err = <API key>(dev, dma_mask);
if (err)
goto err_free;
}
if (c->slot) {
if (c->slot->chip) {
host->ops = c->slot->chip->ops;
host->quirks |= c->slot->chip->quirks;
host->quirks2 |= c->slot->chip->quirks2;
host->mmc->caps |= c->slot->chip->caps;
host->mmc->caps2 |= c->slot->chip->caps2;
host->mmc->pm_caps |= c->slot->chip->pm_caps;
}
host->quirks |= c->slot->quirks;
host->quirks2 |= c->slot->quirks2;
host->mmc->caps |= c->slot->caps;
host->mmc->caps2 |= c->slot->caps2;
host->mmc->pm_caps |= c->slot->pm_caps;
}
host->mmc->caps2 |= <API key>;
err = sdhci_add_host(host);
if (err)
goto err_free;
if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
if (<API key>(dev, host->mmc))
c->use_runtime_pm = false;
}
if (c->use_runtime_pm) {
<API key>(dev);
<API key>(dev, 1);
<API key>(dev, 50);
<API key>(dev);
pm_runtime_enable(dev);
}
return 0;
err_free:
sdhci_free_host(c->host);
return err;
}
static int sdhci_acpi_remove(struct platform_device *pdev)
{
struct sdhci_acpi_host *c = <API key>(pdev);
struct device *dev = &pdev->dev;
int dead;
if (c->use_runtime_pm) {
pm_runtime_get_sync(dev);
pm_runtime_disable(dev);
<API key>(dev);
}
dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0);
sdhci_remove_host(c->host, dead);
sdhci_free_host(c->host);
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int sdhci_acpi_suspend(struct device *dev)
{
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
return sdhci_suspend_host(c->host);
}
static int sdhci_acpi_resume(struct device *dev)
{
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
return sdhci_resume_host(c->host);
}
#else
#define sdhci_acpi_suspend NULL
#define sdhci_acpi_resume NULL
#endif
#ifdef CONFIG_PM_RUNTIME
static int <API key>(struct device *dev)
{
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
return <API key>(c->host);
}
static int <API key>(struct device *dev)
{
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
return <API key>(c->host);
}
static int <API key>(struct device *dev)
{
return 0;
}
#else
#define <API key> NULL
#define <API key> NULL
#define <API key> NULL
#endif
static const struct dev_pm_ops sdhci_acpi_pm_ops = {
.suspend = sdhci_acpi_suspend,
.resume = sdhci_acpi_resume,
.runtime_suspend = <API key>,
.runtime_resume = <API key>,
.runtime_idle = <API key>,
};
static struct platform_driver sdhci_acpi_driver = {
.driver = {
.name = "sdhci-acpi",
.owner = THIS_MODULE,
.acpi_match_table = sdhci_acpi_ids,
.pm = &sdhci_acpi_pm_ops,
},
.probe = sdhci_acpi_probe,
.remove = sdhci_acpi_remove,
};
<API key>(sdhci_acpi_driver);
MODULE_DESCRIPTION("Secure Digital Host Controller Interface ACPI driver");
MODULE_AUTHOR("Adrian Hunter");
MODULE_LICENSE("GPL v2");
|
<?php
/**
* @file
* Contains \Drupal\commerce\<API key>.
*/
namespace Drupal\commerce;
/**
* Defines the interface for availability checkers.
*/
interface <API key> {
/**
* Determines whether the checker applies to the given purchasable entity.
*
* @param \Drupal\commerce\<API key> $entity
* The purchasable entity.
*
* @return bool
* TRUE if the checker applies to the given purchasable entity, FALSE
* otherwise.
*/
public function applies(<API key> $entity);
/**
* Checks the availability of the given purchasable entity.
*
* @param \Drupal\commerce\<API key> $entity
* The purchasable entity.
* @param int $quantity
* The quantity.
*
* @return bool|null
* TRUE if the entity is available, FALSE if it's unavailable,
* or NULL if it has no opinion.
*/
public function check(<API key> $entity, $quantity = 1);
}
|
<?php
/**
* Class that holds processed (created and updated) host and template IDs during the current import.
*/
class <API key> {
/**
* @var array with created and updated hosts.
*/
protected $hostIds = array();
/**
* @var array with created and updated templates.
*/
protected $templateIds = array();
/**
* Add host IDs that have been created and updated.
*
* @param array $hostIds
*/
public function addHostIds(array $hostIds) {
foreach ($hostIds as $hostId) {
$this->hostIds[$hostId] = $hostId;
}
}
/**
* Add template IDs that have been created and updated.
*
* @param array $templateIds
*/
public function addTemplateIds(array $templateIds) {
foreach ($templateIds as $templateId) {
$this->templateIds[$templateId] = $templateId;
}
}
/**
* Checks if host has been created and updated during the current import.
*
* @param string $hostId
*
* @return bool
*/
public function isHostProcessed($hostId) {
return isset($this->hostIds[$hostId]);
}
/**
* Checks if template has been created and updated during the current import.
*
* @param string $templateId
*
* @return bool
*/
public function isTemplateProcessed($templateId) {
return isset($this->templateIds[$templateId]);
}
/**
* Get array of created and updated hosts IDs.
*
* @return array
*/
public function getHostIds() {
return array_values($this->hostIds);
}
/**
* Get array of created and updated template IDs.
*
* @return array
*/
public function getTemplateIds() {
return array_values($this->templateIds);
}
}
|
// <API key>: GPL-2.0-or-later
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <glib.h>
#include "lib/bluetooth.h"
#include "lib/sco.h"
#include "lib/mgmt.h"
#include "monitor/bt.h"
#include "emulator/bthost.h"
#include "emulator/hciemu.h"
#include "src/shared/tester.h"
#include "src/shared/mgmt.h"
struct test_data {
const void *test_data;
struct mgmt *mgmt;
uint16_t mgmt_index;
struct hciemu *hciemu;
enum hciemu_type hciemu_type;
unsigned int io_id;
bool disable_esco;
bool enable_codecs;
};
struct sco_client_data {
int expect_err;
const uint8_t *send_data;
uint16_t data_len;
};
static void print_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
tester_print("%s%s", prefix, str);
}
static void read_info_callback(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
const struct mgmt_rp_read_info *rp = param;
char addr[18];
uint16_t manufacturer;
uint32_t supported_settings, current_settings;
tester_print("Read Info callback");
tester_print(" Status: 0x%02x", status);
if (status || !param) {
<API key>();
return;
}
ba2str(&rp->bdaddr, addr);
manufacturer = btohs(rp->manufacturer);
supported_settings = btohl(rp->supported_settings);
current_settings = btohl(rp->current_settings);
tester_print(" Address: %s", addr);
tester_print(" Version: 0x%02x", rp->version);
tester_print(" Manufacturer: 0x%04x", manufacturer);
tester_print(" Supported settings: 0x%08x", supported_settings);
tester_print(" Current settings: 0x%08x", current_settings);
tester_print(" Class: 0x%02x%02x%02x",
rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
tester_print(" Name: %s", rp->name);
tester_print(" Short name: %s", rp->short_name);
if (strcmp(hciemu_get_address(data->hciemu), addr)) {
<API key>();
return;
}
<API key>();
}
static void <API key>(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
tester_print("Index Added callback");
tester_print(" Index: 0x%04x", index);
data->mgmt_index = index;
mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
read_info_callback, NULL, NULL);
}
static void <API key>(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
tester_print("Index Removed callback");
tester_print(" Index: 0x%04x", index);
if (index != data->mgmt_index)
return;
<API key>(data->mgmt, data->mgmt_index);
mgmt_unref(data->mgmt);
data->mgmt = NULL;
<API key>();
}
static void <API key>(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
if (status != MGMT_STATUS_SUCCESS) {
tester_warn("Failed to enable codecs");
tester_setup_failed();
return;
}
tester_print("Enabled codecs");
}
static void <API key>(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
tester_print("Read Index List callback");
tester_print(" Status: 0x%02x", status);
if (status || !param) {
<API key>();
return;
}
mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
<API key>, NULL, NULL);
mgmt_register(data->mgmt, <API key>, MGMT_INDEX_NONE,
<API key>, NULL, NULL);
data->hciemu = hciemu_new(HCIEMU_TYPE_BREDRLE);
if (!data->hciemu) {
tester_warn("Failed to setup HCI emulation");
<API key>();
return;
}
if (tester_use_debug())
hciemu_set_debug(data->hciemu, print_debug, "hciemu: ", NULL);
tester_print("New hciemu instance created");
if (data->disable_esco) {
uint8_t *features;
tester_print("Disabling eSCO packet type support");
features = hciemu_get_features(data->hciemu);
if (features)
features[3] &= ~0x80;
}
}
static void test_pre_setup(const void *test_data)
{
struct test_data *data = tester_get_data();
data->mgmt = mgmt_new_default();
if (!data->mgmt) {
tester_warn("Failed to setup management interface");
<API key>();
return;
}
if (tester_use_debug())
mgmt_set_debug(data->mgmt, print_debug, "mgmt: ", NULL);
mgmt_send(data->mgmt, <API key>, MGMT_INDEX_NONE, 0, NULL,
<API key>, NULL, NULL);
}
static void test_post_teardown(const void *test_data)
{
struct test_data *data = tester_get_data();
hciemu_unref(data->hciemu);
data->hciemu = NULL;
}
static void test_data_free(void *test_data)
{
struct test_data *data = test_data;
if (data->io_id > 0)
g_source_remove(data->io_id);
free(data);
}
#define test_sco_full(name, data, setup, func, _disable_esco, _enable_codecs) \
do { \
struct test_data *user; \
user = malloc(sizeof(struct test_data)); \
if (!user) \
break; \
user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
user->io_id = 0; \
user->test_data = data; \
user->disable_esco = _disable_esco; \
user->enable_codecs = _enable_codecs; \
tester_add_full(name, data, \
test_pre_setup, setup, func, NULL, \
test_post_teardown, 2, user, test_data_free); \
} while (0)
#define test_sco(name, data, setup, func) \
test_sco_full(name, data, setup, func, false, false)
#define test_sco_11(name, data, setup, func) \
test_sco_full(name, data, setup, func, true, false)
#define test_offload_sco(name, data, setup, func) \
test_sco_full(name, data, setup, func, false, true)
static const struct sco_client_data connect_success = {
.expect_err = 0
};
static const struct sco_client_data connect_failure = {
.expect_err = EOPNOTSUPP
};
const uint8_t data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
static const struct sco_client_data <API key> = {
.expect_err = 0,
.data_len = sizeof(data),
.send_data = data
};
static void <API key>(uint16_t opcode, uint8_t status,
const void *param, uint8_t len,
void *user_data)
{
if (opcode != <API key>)
return;
tester_print("Client set connectable status 0x%02x", status);
if (status)
tester_setup_failed();
else
<API key>();
}
static void <API key>(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
struct bthost *bthost;
if (status != MGMT_STATUS_SUCCESS) {
tester_setup_failed();
return;
}
tester_print("Controller powered on");
bthost = <API key>(data->hciemu);
<API key>(bthost, <API key>, data);
<API key>(bthost, 0x03);
}
static void setup_powered(const void *test_data)
{
struct test_data *data = tester_get_data();
unsigned char param[] = { 0x01 };
tester_print("Powering on controller");
mgmt_send(data->mgmt, <API key>, data->mgmt_index,
sizeof(param), param,
NULL, NULL, NULL);
mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index,
sizeof(param), param, NULL, NULL, NULL);
mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
sizeof(param), param, NULL, NULL, NULL);
if (data->enable_codecs) {
/* <API key> */
static const uint8_t uuid[16] = {
0xaf, 0x29, 0xc6, 0x66, 0xac, 0x5f, 0x1a, 0x88,
0xb9, 0x4f, 0x7f, 0xee, 0xce, 0x5a, 0x69, 0xa6,
};
struct <API key> cp;
memset(&cp, 0, sizeof(cp));
memcpy(cp.uuid, uuid, 16);
cp.action = 1;
tester_print("Enabling codecs");
mgmt_send(data->mgmt, <API key>, data->mgmt_index,
sizeof(cp), &cp, <API key>, NULL, NULL);
}
mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
sizeof(param), param,
<API key>, NULL, NULL);
}
static void test_framework(const void *test_data)
{
tester_test_passed();
}
static void test_socket(const void *test_data)
{
int sk;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
tester_test_failed();
return;
}
close(sk);
tester_test_passed();
}
static void <API key>(const void *test_data)
{
int sk, err;
socklen_t len;
char buffer[255];
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
tester_test_failed();
return;
}
len = sizeof(buffer);
memset(buffer, 0, len);
err = getsockopt(sk, SOL_BLUETOOTH, BT_CODEC, buffer, &len);
if (err < 0) {
tester_warn("Can't get socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
tester_test_passed();
end:
close(sk);
}
static void <API key>(const void *test_data)
{
int sk, err;
char buffer[255];
struct bt_codecs *codecs;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
tester_test_failed();
return;
}
memset(buffer, 0, sizeof(buffer));
codecs = (void *)buffer;
codecs->codecs[0].id = 0x05;
codecs->num_codecs = 1;
codecs->codecs[0].data_path_id = 1;
codecs->codecs[0].num_caps = 0x00;
err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer));
if (err < 0) {
tester_warn("Can't set socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
tester_test_passed();
end:
close(sk);
}
static void test_getsockopt(const void *test_data)
{
int sk, err;
socklen_t len;
struct bt_voice voice;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
tester_test_failed();
return;
}
len = sizeof(voice);
memset(&voice, 0, len);
err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len);
if (err < 0) {
tester_warn("Can't get socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
if (voice.setting != BT_VOICE_CVSD_16BIT) {
tester_warn("Invalid voice setting");
tester_test_failed();
goto end;
}
tester_test_passed();
end:
close(sk);
}
static void test_setsockopt(const void *test_data)
{
int sk, err;
socklen_t len;
struct bt_voice voice;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
tester_test_failed();
goto end;
}
len = sizeof(voice);
memset(&voice, 0, len);
err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len);
if (err < 0) {
tester_warn("Can't get socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
if (voice.setting != BT_VOICE_CVSD_16BIT) {
tester_warn("Invalid voice setting");
tester_test_failed();
goto end;
}
memset(&voice, 0, sizeof(voice));
voice.setting = <API key>;
err = setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice));
if (err < 0) {
tester_warn("Can't set socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
len = sizeof(voice);
memset(&voice, 0, len);
err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len);
if (err < 0) {
tester_warn("Can't get socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
if (voice.setting != <API key>) {
tester_warn("Invalid voice setting");
tester_test_failed();
goto end;
}
tester_test_passed();
end:
close(sk);
}
static int create_sco_sock(struct test_data *data)
{
const uint8_t *central_bdaddr;
struct sockaddr_sco addr;
int sk, err;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_NONBLOCK,
BTPROTO_SCO);
if (sk < 0) {
err = -errno;
tester_warn("Can't create socket: %s (%d)", strerror(errno),
errno);
return err;
}
central_bdaddr = <API key>(data->hciemu);
if (!central_bdaddr) {
tester_warn("No central bdaddr");
return -ENODEV;
}
memset(&addr, 0, sizeof(addr));
addr.sco_family = AF_BLUETOOTH;
bacpy(&addr.sco_bdaddr, (void *) central_bdaddr);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
err = -errno;
tester_warn("Can't bind socket: %s (%d)", strerror(errno),
errno);
close(sk);
return err;
}
return sk;
}
static int connect_sco_sock(struct test_data *data, int sk)
{
const uint8_t *client_bdaddr;
struct sockaddr_sco addr;
int err;
client_bdaddr = <API key>(data->hciemu);
if (!client_bdaddr) {
tester_warn("No client bdaddr");
return -ENODEV;
}
memset(&addr, 0, sizeof(addr));
addr.sco_family = AF_BLUETOOTH;
bacpy(&addr.sco_bdaddr, (void *) client_bdaddr);
err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) {
err = -errno;
tester_warn("Can't connect socket: %s (%d)", strerror(errno),
errno);
return err;
}
return 0;
}
static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct sco_client_data *scodata = data->test_data;
int err, sk_err, sk;
socklen_t len = sizeof(sk_err);
data->io_id = 0;
sk = <API key>(io);
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
err = -errno;
else
err = -sk_err;
if (err < 0)
tester_warn("Connect failed: %s (%d)", strerror(-err), -err);
else
tester_print("Successfully connected");
if (scodata->send_data) {
ssize_t ret;
tester_print("Writing %u bytes of data", scodata->data_len);
ret = write(sk, scodata->send_data, scodata->data_len);
if (scodata->data_len != ret) {
tester_warn("Failed to write %u bytes: %zu %s (%d)",
scodata->data_len, ret, strerror(errno),
errno);
err = -errno;
}
}
if (-err != scodata->expect_err)
tester_test_failed();
else
tester_test_passed();
return FALSE;
}
static void test_connect(const void *test_data)
{
struct test_data *data = tester_get_data();
GIOChannel *io;
int sk;
sk = create_sco_sock(data);
if (sk < 0) {
tester_test_failed();
return;
}
if (connect_sco_sock(data, sk) < 0) {
close(sk);
tester_test_failed();
return;
}
io = <API key>(sk);
<API key>(io, TRUE);
data->io_id = g_io_add_watch(io, G_IO_OUT, sco_connect_cb, NULL);
g_io_channel_unref(io);
tester_print("Connect in progress");
}
static void test_connect_transp(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct sco_client_data *scodata = data->test_data;
int sk, err;
struct bt_voice voice;
sk = create_sco_sock(data);
if (sk < 0) {
tester_test_failed();
return;
}
memset(&voice, 0, sizeof(voice));
voice.setting = <API key>;
err = setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice));
if (err < 0) {
tester_warn("Can't set socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
err = connect_sco_sock(data, sk);
tester_warn("Connect returned %s (%d), expected %s (%d)",
strerror(-err), -err,
strerror(scodata->expect_err), scodata->expect_err);
if (-err != scodata->expect_err)
tester_test_failed();
else
tester_test_passed();
end:
close(sk);
}
static void <API key>(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct sco_client_data *scodata = data->test_data;
int sk, err;
int len;
char buffer[255];
struct bt_codecs *codecs;
sk = create_sco_sock(data);
if (sk < 0) {
tester_test_failed();
return;
}
len = sizeof(buffer);
memset(buffer, 0, len);
codecs = (void *)buffer;
codecs->codecs[0].id = 0x05;
codecs->num_codecs = 1;
codecs->codecs[0].data_path_id = 1;
codecs->codecs[0].num_caps = 0x00;
err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer));
if (err < 0) {
tester_warn("Can't set socket option : %s (%d)",
strerror(errno), errno);
tester_test_failed();
goto end;
}
err = connect_sco_sock(data, sk);
tester_warn("Connect returned %s (%d), expected %s (%d)",
strerror(-err), -err,
strerror(scodata->expect_err), scodata->expect_err);
if (-err != scodata->expect_err)
tester_test_failed();
else
tester_test_passed();
end:
close(sk);
}
int main(int argc, char *argv[])
{
tester_init(&argc, &argv);
test_sco("Basic Framework - Success", NULL, setup_powered,
test_framework);
test_sco("Basic SCO Socket - Success", NULL, setup_powered,
test_socket);
test_sco("Basic SCO Get Socket Option - Success", NULL, setup_powered,
test_getsockopt);
test_sco("Basic SCO Set Socket Option - Success", NULL, setup_powered,
test_setsockopt);
test_sco("eSCO CVSD - Success", &connect_success, setup_powered,
test_connect);
test_sco("eSCO mSBC - Success", &connect_success, setup_powered,
test_connect_transp);
test_sco_11("SCO CVSD 1.1 - Success", &connect_success, setup_powered,
test_connect);
test_sco_11("SCO mSBC 1.1 - Failure", &connect_failure, setup_powered,
test_connect_transp);
test_sco("SCO CVSD Send - Success", &<API key>,
setup_powered, test_connect);
test_offload_sco("Basic SCO Get Socket Option - Offload - Success",
NULL, setup_powered, <API key>);
test_offload_sco("Basic SCO Set Socket Option - Offload - Success",
NULL, setup_powered, <API key>);
test_offload_sco("eSCO mSBC - Offload - Success",
&connect_success, setup_powered, <API key>);
return tester_run();
}
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DB_ENV->rep_get_clockskew()</title>
<link rel="stylesheet" href="apiReference.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB C API Reference" />
<link rel="up" href="rep.html" title="Chapter 10. Replication Methods" />
<link rel="prev" href="repelect.html" title="DB_ENV->rep_elect()" />
<link rel="next" href="repget_config.html" title="DB_ENV->rep_get_config()" />
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">DB_ENV->rep_get_clockskew()</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="repelect.html">Prev</a> </td>
<th width="60%" align="center">Chapter 10.
Replication Methods
</th>
<td width="20%" align="right"> <a accesskey="n" href="repget_config.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="repget_clockskew"></a>DB_ENV->rep_get_clockskew()</h2>
</div>
</div>
</div>
<pre class="programlisting">#include <db.h>
int
DB_ENV->rep_get_clockskew(DB_ENV *env,
u_int32_t *fast_clockp, u_int32_t *slow_clockp); </pre>
<p>
The <code class="methodname">DB_ENV->rep_get_clockskew()</code> method returns the current clock skew ratio
values, as set by the <a class="xref" href="repclockskew.html" title="DB_ENV->rep_set_clockskew()">DB_ENV->rep_set_clockskew()</a>
method.
</p>
<p>
The <code class="methodname">DB_ENV->rep_get_clockskew()</code> method may be called at any time
during the life of the application.
</p>
<p>
The <code class="methodname">DB_ENV->rep_get_clockskew()</code> <span>
<span>
method returns a non-zero error value on failure and 0 on success.
</span>
</span>
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3891622"></a>Parameters</h3>
</div>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3891611"></a>fast_clockp</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>fast_clockp</strong></span> parameter references
memory into which the value for the fastest clock in the group of
sites is copied.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3891226"></a>slow_clockp</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>slow_clockp</strong></span> parameter references
memory into which the value for the slowest clock in the group of
sites is copied.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3891280"></a>Class</h3>
</div>
</div>
</div>
<p>
<a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a>
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3891071"></a>See Also</h3>
</div>
</div>
</div>
<p>
<a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a>,
<a class="xref" href="repclockskew.html" title="DB_ENV->rep_set_clockskew()">DB_ENV->rep_set_clockskew()</a>
</p>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="repelect.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="rep.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="repget_config.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">DB_ENV->rep_elect() </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> DB_ENV->rep_get_config()</td>
</tr>
</table>
</div>
</body>
</html>
|
/* global include */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <net/if_arp.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <sys/uio.h>
/* local include */
#include "check_api.h"
#include "vrrp_netlink.h"
#include "vrrp_if.h"
#include "logger.h"
#include "memory.h"
#include "scheduler.h"
#include "utils.h"
/* Global vars */
nl_handle_t nl_kernel; /* Kernel reflection channel */
nl_handle_t nl_cmd; /* Command channel */
/* Create a socket to netlink interface_t */
int
netlink_socket(nl_handle_t *nl, unsigned long groups)
{
socklen_t addr_len;
int ret;
memset(nl, 0, sizeof (*nl));
nl->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (nl->fd < 0) {
log_message(LOG_INFO, "Netlink: Cannot open netlink socket : (%s)",
strerror(errno));
return -1;
}
ret = fcntl(nl->fd, F_SETFL, O_NONBLOCK);
if (ret < 0) {
log_message(LOG_INFO,
"Netlink: Cannot set netlink socket flags : (%s)",
strerror(errno));
close(nl->fd);
return -1;
}
memset(&nl->snl, 0, sizeof (nl->snl));
nl->snl.nl_family = AF_NETLINK;
nl->snl.nl_groups = groups;
ret = bind(nl->fd, (struct sockaddr *) &nl->snl, sizeof (nl->snl));
if (ret < 0) {
log_message(LOG_INFO, "Netlink: Cannot bind netlink socket : (%s)",
strerror(errno));
close(nl->fd);
return -1;
}
addr_len = sizeof (nl->snl);
ret = getsockname(nl->fd, (struct sockaddr *) &nl->snl, &addr_len);
if (ret < 0 || addr_len != sizeof (nl->snl)) {
log_message(LOG_INFO, "Netlink: Cannot getsockname : (%s)",
strerror(errno));
close(nl->fd);
return -1;
}
if (nl->snl.nl_family != AF_NETLINK) {
log_message(LOG_INFO, "Netlink: Wrong address family %d",
nl->snl.nl_family);
close(nl->fd);
return -1;
}
nl->seq = time(NULL);
/* Set default rcvbuf size */
<API key>(&nl->fd, IF_DEFAULT_BUFSIZE);
if (nl->fd < 0)
return -1;
return ret;
}
/* Close a netlink socket */
int
netlink_close(nl_handle_t *nl)
{
/* First of all release pending thread */
thread_cancel(nl->thread);
close(nl->fd);
return 0;
}
/* Set netlink socket channel as blocking */
int
netlink_set_block(nl_handle_t *nl, int *flags)
{
if ((*flags = fcntl(nl->fd, F_GETFL, 0)) < 0) {
log_message(LOG_INFO, "Netlink: Cannot F_GETFL socket : (%s)",
strerror(errno));
return -1;
}
*flags &= ~O_NONBLOCK;
if (fcntl(nl->fd, F_SETFL, *flags) < 0) {
log_message(LOG_INFO, "Netlink: Cannot F_SETFL socket : (%s)",
strerror(errno));
return -1;
}
return 0;
}
/* Set netlink socket channel as non-blocking */
int
<API key>(nl_handle_t *nl, int *flags)
{
*flags |= O_NONBLOCK;
if (fcntl(nl->fd, F_SETFL, *flags) < 0) {
log_message(LOG_INFO, "Netlink: Cannot F_SETFL socket : (%s)",
strerror(errno));
return -1;
}
return 0;
}
/* iproute2 utility function */
int
addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data)
{
int len = RTA_LENGTH(4);
struct rtattr *rta;
if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen)
return -1;
rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;
rta->rta_len = len;
memcpy(RTA_DATA(rta), &data, 4);
n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
return 0;
}
int
addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
{
int len = RTA_LENGTH(alen);
struct rtattr *rta;
if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen)
return -1;
rta = (struct rtattr *) (((char *) n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;
rta->rta_len = len;
memcpy(RTA_DATA(rta), data, alen);
n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
return 0;
}
int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
const void *data, int alen)
{
struct rtattr *subrta;
int len = RTA_LENGTH(alen);
if (RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len) > maxlen) {
return -1;
}
subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len));
subrta->rta_type = type;
subrta->rta_len = len;
memcpy(RTA_DATA(subrta), data, alen);
rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len);
return 0;
}
static void
parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta, int len)
{
while (RTA_OK(rta, len)) {
if (rta->rta_type <= max)
tb[rta->rta_type] = rta;
rta = RTA_NEXT(rta, len);
}
}
char *
netlink_scope_n2a(int scope)
{
if (scope == 0)
return "global";
if (scope == 255)
return "nowhere";
if (scope == 254)
return "host";
if (scope == 253)
return "link";
if (scope == 200)
return "site";
return "unknown";
}
int
netlink_scope_a2n(char *scope)
{
if (!strcmp(scope, "global"))
return 0;
if (!strcmp(scope, "nowhere"))
return 255;
if (!strcmp(scope, "host"))
return 254;
if (!strcmp(scope, "link"))
return 253;
if (!strcmp(scope, "site"))
return 200;
return -1;
}
/*
* Reflect base interface flags on VMAC interface.
* VMAC interfaces should never update it own flags, only be reflected
* by the base interface flags.
*/
static void
vmac_reflect_flags(struct ifinfomsg *ifi)
{
interface_t *ifp;
/* find the VMAC interface (if any) */
ifp = <API key>(ifi->ifi_index);
/* if found, reflect base interface flags on VMAC interface */
if (ifp) {
ifp->flags = ifi->ifi_flags;
}
}
/* Our netlink parser */
static int
netlink_parse_info(int (*filter) (struct sockaddr_nl *, struct nlmsghdr *),
nl_handle_t *nl, struct nlmsghdr *n)
{
int status;
int ret = 0;
int error;
while (1) {
char buf[4096];
struct iovec iov = { buf, sizeof buf };
struct sockaddr_nl snl;
struct msghdr msg =
{ (void *) &snl, sizeof snl, &iov, 1, NULL, 0, 0 };
struct nlmsghdr *h;
status = recvmsg(nl->fd, &msg, 0);
if (status < 0) {
if (errno == EINTR)
continue;
if (errno == EWOULDBLOCK || errno == EAGAIN)
break;
log_message(LOG_INFO, "Netlink: Received message overrun (%m)");
continue;
}
if (status == 0) {
log_message(LOG_INFO, "Netlink: EOF");
return -1;
}
if (msg.msg_namelen != sizeof snl) {
log_message(LOG_INFO,
"Netlink: Sender address length error: length %d",
msg.msg_namelen);
return -1;
}
for (h = (struct nlmsghdr *) buf; NLMSG_OK(h, status);
h = NLMSG_NEXT(h, status)) {
/* Finish of reading. */
if (h->nlmsg_type == NLMSG_DONE)
return ret;
/* Error handling. */
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr *) NLMSG_DATA(h);
/*
* If error == 0 then this is a netlink ACK.
* return if not related to multipart message.
*/
if (err->error == 0) {
if (!(h->nlmsg_flags & NLM_F_MULTI))
return 0;
continue;
}
if (h->nlmsg_len < NLMSG_LENGTH(sizeof (struct nlmsgerr))) {
log_message(LOG_INFO,
"Netlink: error: message truncated");
return -1;
}
if (n && (err->error == -EEXIST) &&
((n->nlmsg_type == RTM_NEWROUTE) ||
(n->nlmsg_type == RTM_NEWADDR)))
return 0;
log_message(LOG_INFO,
"Netlink: error: %s, type=(%u), seq=%u, pid=%d",
strerror(-err->error),
err->msg.nlmsg_type,
err->msg.nlmsg_seq, err->msg.nlmsg_pid);
return -1;
}
/* Skip unsolicited messages from cmd channel */
if (nl != &nl_cmd && h->nlmsg_pid == nl_cmd.snl.nl_pid)
continue;
error = (*filter) (&snl, h);
if (error < 0) {
log_message(LOG_INFO, "Netlink: filter function error");
ret = error;
}
}
/* After error care. */
if (msg.msg_flags & MSG_TRUNC) {
log_message(LOG_INFO, "Netlink: error: message truncated");
continue;
}
if (status) {
log_message(LOG_INFO, "Netlink: error: data remnant size %d",
status);
return -1;
}
}
return ret;
}
/* Out talk filter */
static int
netlink_talk_filter(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
log_message(LOG_INFO, "Netlink: ignoring message type 0x%04x",
h->nlmsg_type);
return 0;
}
/* send message to netlink kernel socket, then receive response */
int
netlink_talk(nl_handle_t *nl, struct nlmsghdr *n)
{
int status;
int ret, flags;
struct sockaddr_nl snl;
struct iovec iov = { (void *) n, n->nlmsg_len };
struct msghdr msg = { (void *) &snl, sizeof snl, &iov, 1, NULL, 0, 0 };
memset(&snl, 0, sizeof snl);
snl.nl_family = AF_NETLINK;
n->nlmsg_seq = ++nl->seq;
/* Request Netlink acknowledgement */
n->nlmsg_flags |= NLM_F_ACK;
/* Send message to netlink interface. */
status = sendmsg(nl->fd, &msg, 0);
if (status < 0) {
log_message(LOG_INFO, "Netlink: sendmsg() error: %s",
strerror(errno));
return -1;
}
/* Set blocking flag */
ret = netlink_set_block(nl, &flags);
if (ret < 0)
log_message(LOG_INFO, "Netlink: Warning, couldn't set "
"blocking flag to netlink socket...");
status = netlink_parse_info(netlink_talk_filter, nl, n);
/* Restore previous flags */
if (ret == 0)
<API key>(nl, &flags);
return status;
}
/* Fetch a specific type information from netlink kernel */
static int
netlink_request(nl_handle_t *nl, int family, int type)
{
int status;
struct sockaddr_nl snl;
struct {
struct nlmsghdr nlh;
struct rtgenmsg g;
} req;
/* Cleanup the room */
memset(&snl, 0, sizeof (snl));
snl.nl_family = AF_NETLINK;
req.nlh.nlmsg_len = sizeof (req);
req.nlh.nlmsg_type = type;
req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
req.nlh.nlmsg_pid = 0;
req.nlh.nlmsg_seq = ++nl->seq;
req.g.rtgen_family = family;
status = sendto(nl->fd, (void *) &req, sizeof (req)
, 0, (struct sockaddr *) &snl, sizeof (snl));
if (status < 0) {
log_message(LOG_INFO, "Netlink: sendto() failed: %s",
strerror(errno));
return -1;
}
return 0;
}
/* Netlink interface link lookup filter */
static int
<API key>(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
struct ifinfomsg *ifi;
struct rtattr *tb[IFLA_MAX + 1];
interface_t *ifp;
int i, len;
char *name;
ifi = NLMSG_DATA(h);
if (h->nlmsg_type != RTM_NEWLINK)
return 0;
len = h->nlmsg_len - NLMSG_LENGTH(sizeof (struct ifinfomsg));
if (len < 0)
return -1;
/* Interface name lookup */
memset(tb, 0, sizeof (tb));
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
if (tb[IFLA_IFNAME] == NULL)
return -1;
name = (char *) RTA_DATA(tb[IFLA_IFNAME]);
/* Return if loopback */
if (ifi->ifi_type == ARPHRD_LOOPBACK)
return 0;
/* Skip it if already exist */
ifp = if_get_by_ifname(name);
if (ifp) {
if (!ifp->vmac) {
vmac_reflect_flags(ifi);
ifp->flags = ifi->ifi_flags;
}
return 0;
}
/* Fill the interface structure */
ifp = (interface_t *) MALLOC(sizeof(interface_t));
memcpy(ifp->ifname, name, strlen(name));
ifp->ifindex = ifi->ifi_index;
ifp->mtu = *(int *) RTA_DATA(tb[IFLA_MTU]);
ifp->hw_type = ifi->ifi_type;
if (!ifp->vmac) {
vmac_reflect_flags(ifi);
ifp->flags = ifi->ifi_flags;
ifp->base_ifindex = ifi->ifi_index;
}
if (tb[IFLA_ADDRESS]) {
int hw_addr_len = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
if (hw_addr_len > IF_HWADDR_MAX)
log_message(LOG_ERR, "MAC address for %s is too large: %d",
name, hw_addr_len);
else {
ifp->hw_addr_len = hw_addr_len;
memcpy(ifp->hw_addr, RTA_DATA(tb[IFLA_ADDRESS]),
hw_addr_len);
for (i = 0; i < hw_addr_len; i++)
if (ifp->hw_addr[i] != 0)
break;
if (i == hw_addr_len)
ifp->hw_addr_len = 0;
else
ifp->hw_addr_len = hw_addr_len;
}
}
/* Queue this new interface_t */
if_add_queue(ifp);
return 0;
}
/*
* Netlink interface address lookup filter
* We need to handle multiple primary address and
* multiple secondary address to the same interface.
*/
static int
<API key>(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
struct ifaddrmsg *ifa;
struct rtattr *tb[IFA_MAX + 1];
interface_t *ifp;
int len;
void *addr;
ifa = NLMSG_DATA(h);
/* Only IPV4 are valid us */
if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6)
return 0;
if (h->nlmsg_type != RTM_NEWADDR && h->nlmsg_type != RTM_DELADDR)
return 0;
len = h->nlmsg_len - NLMSG_LENGTH(sizeof (struct ifaddrmsg));
if (len < 0)
return -1;
memset(tb, 0, sizeof (tb));
parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len);
/* Fetch interface_t */
ifp = if_get_by_ifindex(ifa->ifa_index);
if (!ifp)
return 0;
if (tb[IFA_LOCAL] == NULL)
tb[IFA_LOCAL] = tb[IFA_ADDRESS];
if (tb[IFA_ADDRESS] == NULL)
tb[IFA_ADDRESS] = tb[IFA_LOCAL];
/* local interface address */
addr = (tb[IFA_LOCAL] ? RTA_DATA(tb[IFA_LOCAL]) : NULL);
if (addr == NULL)
return -1;
/* If no address is set on interface then set the first time */
if (ifa->ifa_family == AF_INET) {
if (!ifp->sin_addr.s_addr)
ifp->sin_addr = *(struct in_addr *) addr;
} else {
if (!ifp->sin6_addr.s6_addr16[0] && ifa->ifa_scope == RT_SCOPE_LINK)
ifp->sin6_addr = *(struct in6_addr *) addr;
}
#ifdef _WITH_LVS_
/* Refresh checkers state */
<API key>(ifa->ifa_family, addr,
(h->nlmsg_type == RTM_NEWADDR) ? 1 : 0);
#endif
return 0;
}
/* Interfaces lookup bootstrap function */
int
<API key>(void)
{
nl_handle_t nlh;
int status = 0;
int ret, flags;
if (netlink_socket(&nlh, 0) < 0)
return -1;
/* Set blocking flag */
ret = netlink_set_block(&nlh, &flags);
if (ret < 0)
log_message(LOG_INFO, "Netlink: Warning, couldn't set "
"blocking flag to netlink socket...");
/* Interface lookup */
if (netlink_request(&nlh, AF_PACKET, RTM_GETLINK) < 0) {
status = -1;
goto end_int;
}
status = netlink_parse_info(<API key>, &nlh, NULL);
end_int:
netlink_close(&nlh);
return status;
}
/* Adresses lookup bootstrap function */
static int
<API key>(void)
{
nl_handle_t nlh;
int status = 0;
int ret, flags;
if (netlink_socket(&nlh, 0) < 0)
return -1;
/* Set blocking flag */
ret = netlink_set_block(&nlh, &flags);
if (ret < 0)
log_message(LOG_INFO, "Netlink: Warning, couldn't set "
"blocking flag to netlink socket...");
/* IPv4 Address lookup */
if (netlink_request(&nlh, AF_INET, RTM_GETADDR) < 0) {
status = -1;
goto end_addr;
}
status = netlink_parse_info(<API key>, &nlh, NULL);
/* IPv6 Address lookup */
if (netlink_request(&nlh, AF_INET6, RTM_GETADDR) < 0) {
status = -1;
goto end_addr;
}
status = netlink_parse_info(<API key>, &nlh, NULL);
end_addr:
netlink_close(&nlh);
return status;
}
/* Netlink flag Link update */
static int
<API key>(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
struct ifinfomsg *ifi;
struct rtattr *tb[IFLA_MAX + 1];
interface_t *ifp;
int len;
ifi = NLMSG_DATA(h);
if (!(h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK))
return 0;
len = h->nlmsg_len - NLMSG_LENGTH(sizeof (struct ifinfomsg));
if (len < 0)
return -1;
/* Interface name lookup */
memset(tb, 0, sizeof (tb));
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
if (tb[IFLA_IFNAME] == NULL)
return -1;
/* ignore loopback device */
if (ifi->ifi_type == ARPHRD_LOOPBACK)
return 0;
/* find the interface_t */
ifp = if_get_by_ifindex(ifi->ifi_index);
if (!ifp)
return -1;
/*
* Update flags.
* VMAC interfaces should never update it own flags, only be reflected
* by the base interface flags.
*/
if (!ifp->vmac) {
vmac_reflect_flags(ifi);
ifp->flags = ifi->ifi_flags;
}
return 0;
}
/* Netlink kernel message reflection */
static int
<API key>(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
switch (h->nlmsg_type) {
case RTM_NEWLINK:
case RTM_DELLINK:
return <API key>(snl, h);
break;
case RTM_NEWADDR:
case RTM_DELADDR:
return <API key>(snl, h);
break;
default:
log_message(LOG_INFO,
"Kernel is reflecting an unknown netlink nlmsg_type: %d",
h->nlmsg_type);
break;
}
return 0;
}
int
kernel_netlink(thread_t * thread)
{
nl_handle_t *nl = THREAD_ARG(thread);
if (thread->type != THREAD_READ_TIMEOUT)
netlink_parse_info(<API key>, nl, NULL);
nl->thread = thread_add_read(master, kernel_netlink, nl, nl->fd,
NETLINK_TIMER);
return 0;
}
void
kernel_netlink_init(void)
{
unsigned long groups;
/* Start with a netlink address lookup */
<API key>();
/*
* Prepare netlink kernel broadcast channel
* subscribtion. We subscribe to LINK and ADDR
* netlink broadcast messages.
*/
groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
netlink_socket(&nl_kernel, groups);
if (nl_kernel.fd > 0) {
log_message(LOG_INFO, "Registering Kernel netlink reflector");
nl_kernel.thread = thread_add_read(master, kernel_netlink, &nl_kernel, nl_kernel.fd,
NETLINK_TIMER);
} else
log_message(LOG_INFO, "Error while registering Kernel netlink reflector channel");
/* Prepare netlink command channel. */
netlink_socket(&nl_cmd, 0);
if (nl_cmd.fd > 0)
log_message(LOG_INFO, "Registering Kernel netlink command channel");
else
log_message(LOG_INFO, "Error while registering Kernel netlink cmd channel");
}
void
<API key>(void)
{
netlink_close(&nl_kernel);
netlink_close(&nl_cmd);
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace BarcodeLib.Symbologies
{
class ISBN : BarcodeCommon, IBarcode
{
public ISBN(string input)
{
Raw_Data = input;
}
<summary>
Encode the raw data using the Bookland/ISBN algorithm.
</summary>
private string <API key>()
{
if (!BarcodeLib.Barcode.CheckNumericOnly(Raw_Data))
Error("EBOOKLANDISBN-1: Numeric Data Only");
string type = "UNKNOWN";
if (Raw_Data.Length == 10 || Raw_Data.Length == 9)
{
if (Raw_Data.Length == 10) Raw_Data = Raw_Data.Remove(9, 1);
Raw_Data = "978" + Raw_Data;
type = "ISBN";
}
else if (Raw_Data.Length == 12 && Raw_Data.StartsWith("978"))
{
type = "<API key>";
}//else if
else if (Raw_Data.Length == 13 && Raw_Data.StartsWith("978"))
{
type = "BOOKLAND-CHECKDIGIT";
Raw_Data = Raw_Data.Remove(12, 1);
}//else if
//check to see if its an unknown type
if (type == "UNKNOWN") Error("EBOOKLANDISBN-2: Invalid input. Must start with 978 and be length must be 9, 10, 12, 13 characters.");
EAN13 ean13 = new EAN13(Raw_Data);
return ean13.Encoded_Value;
}//<API key>
#region IBarcode Members
public string Encoded_Value
{
get { return <API key>(); }
}
#endregion
}
}
|
CKEDITOR.plugins.setLang( 'basicstyles', 'en-gb', {
bold: 'Bold',
italic: 'Italic',
strike: 'Strike Through',
subscript: 'Subscript',
superscript: 'Superscript',
underline: 'Underline'
} );
|
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.int_watch.conf 13957 2005-12-20 15:33:08Z tanders $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/<API key>.h>
#include "statPPTP.h"
#include "triton.h"
/*
* The variables we want to tie the relevant OIDs to.
* The agent will handle all GET and (if applicable) SET requests
* to these variables automatically, changing the values as needed.
*/
void pptp_get_stat(unsigned int **, unsigned int **);
static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statPPTP(void)
{
<API key> *reg;
<API key> *winfo;
static oid <API key>[] = { 1,3,6,1,4,1,8072,100,1,3,1 };
static oid statPPTPActive_oid[] = { 1,3,6,1,4,1,8072,100,1,3,2 };
/*
* a debugging statement. Run the agent with -DstatPPTP to see
* the output of this debugging statement.
*/
DEBUGMSGTL(("statPPTP", "Initializing the statPPTP module\n"));
if (!<API key>("pptp"))
return;
pptp_get_stat(&stat_starting, &stat_active);
/*
* Register scalar watchers for each of the MIB objects.
* The ASN type and RO/RW status are taken from the MIB definition,
* but can be adjusted if needed.
*
* In most circumstances, the scalar watcher will handle all
* of the necessary processing. But the NULL parameter in the
* <API key>() call can be used to
* supply a user-provided handler if necessary.
*
* This approach can also be used to handle Counter64, string-
* and OID-based watched scalars (although variable-sized writeable
* objects will need some more specialised initialisation).
*/
DEBUGMSGTL(("statPPTP",
"Initializing statPPTPStarting scalar integer. Default value = %d\n",
0));
reg = <API key>(
"statPPTPStarting", NULL,
<API key>, OID_LENGTH(<API key>),
HANDLER_CAN_RONLY);
winfo = <API key>(
stat_starting, sizeof(*stat_starting),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (<API key>( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPTPStarting" );
}
DEBUGMSGTL(("statPPTP",
"Initializing statPPTPActive scalar integer. Default value = %d\n",
0));
reg = <API key>(
"statPPTPActive", NULL,
statPPTPActive_oid, OID_LENGTH(statPPTPActive_oid),
HANDLER_CAN_RONLY);
winfo = <API key>(
stat_active, sizeof(*stat_active),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (<API key>( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPTPActive" );
}
DEBUGMSGTL(("statPPTP",
"Done initalizing statPPTP module\n"));
}
|
.ultb3-box {
width: 100%;
display: block;
position: relative;
background: #f2f2f2;
overflow: hidden
}
img.ultb3-img {
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
max-width: none;
width: auto !important;
float: none;
margin: 0 auto;
display: block;
position: absolute;
z-index: 1;
-webkit-transition: all 300ms linear;
transition: all 300ms linear
}
.ultb3-box-overlay {
background: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2
}
.ultb3-info {
padding: 25px;
position: relative;
z-index: 5
}
.ultb3-info.ib3-info-center {
text-align: center
}
.ultb3-info.ib3-info-right {
text-align: right
}
img.ultb3-img.<API key> {
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%)
}
img.ultb3-img.ultb3-img-top-right {
left: auto;
right: 0
}
img.ultb3-img.<API key> {
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%)
}
img.ultb3-img.ultb3-img-center {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
img.ultb3-img.<API key> {
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
left: auto;
right: 0
}
img.ultb3-img.<API key>,
img.ultb3-img.<API key>,
img.ultb3-img.<API key> {
top: auto;
bottom: 0
}
img.ultb3-img.<API key> {
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%)
}
img.ultb3-img.<API key> {
right: 0;
left: auto
}
.ultb3-title {
font-size: 40px;
color: #252525;
line-height: 1.35em;
margin-bottom: 5px
}
.ultb3-desc {
font-size: 20px;
line-height: 1.5em;
margin-bottom: 10px
}
a.ultb3-btn {
display: inline-block;
color: #0483d9;
text-align: center;
font-size: 20px;
padding: 15px 25px;
-<API key>: 30px;
border-radius: 30px;
border: 2px solid #0483d9;
position: relative;
text-decoration: none;
-webkit-transition: all .2s;
transition: all .2s
}
a.ultb3-btn i {
position: absolute;
left: auto;
right: 25px;
top: 50%;
opacity: 0;
width: auto;
height: auto;
font-size: inherit !important;
-webkit-transition: all .25s;
transition: all .25s;
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%)
}
a.ultb3-btn:hover i {
right: 20px;
opacity: 1
}
a.ultb3-btn:hover {
padding-right: 45px
}
a.ultb3-btn:hover;
a.ultb3-btn:focus;
a.ultb3-btn:active;
a.ultb3-btn:visited {
text-decoration: none;
color: inherit;
outline: 0
}
.ultb3-hover-1 .ultb3-img.ultb3-img-top-left,
.ultb3-hover-1 .ultb3-img.<API key>,
.ultb3-hover-1 .ultb3-img.ultb3-img-top-right {
top: -50px
}
.ultb3-hover-1:hover .ultb3-img.ultb3-img-top-left,
.ultb3-hover-1:hover .ultb3-img.<API key>,
.ultb3-hover-1:hover .ultb3-img.ultb3-img-top-right {
top: 0
}
.ultb3-hover-1 .ultb3-img.<API key> {
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%)
}
.ultb3-hover-1:hover .ultb3-img.<API key> {
-webkit-transform: translateY(-25%);
-ms-transform: translateY(-25%);
transform: translateY(-25%)
}
.ultb3-hover-1 .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
.ultb3-hover-1:hover .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -25%);
-ms-transform: translate(-50%, -25%);
transform: translate(-50%, -25%)
}
.ultb3-hover-1 .ultb3-img.<API key> {
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%)
}
.ultb3-hover-1:hover .ultb3-img.<API key> {
-webkit-transform: translateY(-25%);
-ms-transform: translateY(-25%);
transform: translateY(-25%)
}
.ultb3-hover-1 .ultb3-img.<API key>,
.ultb3-hover-1 .ultb3-img.<API key>,
.ultb3-hover-1 .ultb3-img.<API key> {
bottom: 0
}
.ultb3-hover-1:hover .ultb3-img.<API key>,
.ultb3-hover-1:hover .ultb3-img.<API key>,
.ultb3-hover-1:hover .ultb3-img.<API key> {
bottom: -50px
}
.ultb3-hover-2 .ultb3-img.ultb3-img-top-left,
.ultb3-hover-2 .ultb3-img.<API key>,
.ultb3-hover-2 .ultb3-img.ultb3-img-top-right {
top: 0
}
.ultb3-hover-2:hover .ultb3-img.ultb3-img-top-left,
.ultb3-hover-2:hover .ultb3-img.<API key>,
.ultb3-hover-2:hover .ultb3-img.ultb3-img-top-right {
top: -50px
}
.ultb3-hover-2 .ultb3-img.<API key> {
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%)
}
.ultb3-hover-2:hover .ultb3-img.<API key> {
-webkit-transform: translateY(-75%);
-ms-transform: translateY(-75%);
transform: translateY(-75%)
}
.ultb3-hover-2 .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
.ultb3-hover-2:hover .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -75%);
-ms-transform: translate(-50%, -75%);
transform: translate(-50%, -75%)
}
.ultb3-hover-2 .ultb3-img.<API key> {
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%)
}
.ultb3-hover-2:hover .ultb3-img.<API key> {
-webkit-transform: translateY(-75%);
-ms-transform: translateY(-75%);
transform: translateY(-75%)
}
.ultb3-hover-2 .ultb3-img.<API key>,
.ultb3-hover-2 .ultb3-img.<API key>,
.ultb3-hover-2 .ultb3-img.<API key> {
bottom: -50px
}
.ultb3-hover-2:hover .ultb3-img.<API key>,
.ultb3-hover-2:hover .ultb3-img.<API key>,
.ultb3-hover-2:hover .ultb3-img.<API key> {
bottom: 0
}
.ultb3-hover-3 .ultb3-img.ultb3-img-top-left,
.ultb3-hover-3 .ultb3-img.<API key> {
left: 0
}
.ultb3-hover-3:hover .ultb3-img.ultb3-img-top-left,
.ultb3-hover-3:hover .ultb3-img.<API key> {
left: -50px
}
.ultb3-hover-3 .ultb3-img.<API key> {
-webkit-transform: translateX(-25%);
-ms-transform: translateX(-25%);
transform: translateX(-25%)
}
.ultb3-hover-3:hover .ultb3-img.<API key> {
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%)
}
.ultb3-hover-3 .ultb3-img.ultb3-img-top-right,
.ultb3-hover-3 .ultb3-img.<API key> {
right: -50px
}
.ultb3-hover-3:hover .ultb3-img.ultb3-img-top-right,
.ultb3-hover-3:hover .ultb3-img.<API key> {
right: 0
}
.ultb3-hover-3 .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
.ultb3-hover-3:hover .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-75%, -50%);
-ms-transform: translate(-75%, -50%);
transform: translate(-75%, -50%)
}
.ultb3-hover-3 .ultb3-img.<API key> {
-webkit-transform: translate(25%, -50%);
-ms-transform: translate(25%, -50%);
transform: translate(25%, -50%)
}
.ultb3-hover-3:hover .ultb3-img.<API key> {
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%)
}
.ultb3-hover-3 .ultb3-img.<API key> {
left: 0
}
.ultb3-hover-3:hover .ultb3-img.<API key> {
left: -50px
}
.ultb3-hover-3 .ultb3-img.<API key> {
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%)
}
.ultb3-hover-3:hover .ultb3-img.<API key> {
-webkit-transform: translate(-75%);
-ms-transform: translate(-75%);
transform: translate(-75%)
}
.ultb3-hover-4 .ultb3-img.ultb3-img-top-left,
.ultb3-hover-4 .ultb3-img.<API key> {
left: -50px
}
.ultb3-hover-4:hover .ultb3-img.ultb3-img-top-left,
.ultb3-hover-4:hover .ultb3-img.<API key> {
left: 0
}
.ultb3-hover-4 .ultb3-img.<API key> {
-webkit-transform: translateX(-75%);
-ms-transform: translateX(-75%);
transform: translateX(-75%)
}
.ultb3-hover-4:hover .ultb3-img.<API key> {
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%)
}
.ultb3-hover-4 .ultb3-img.ultb3-img-top-right,
.ultb3-hover-4 .ultb3-img.<API key> {
right: 0
}
.ultb3-hover-4:hover .ultb3-img.ultb3-img-top-right,
.ultb3-hover-4:hover .ultb3-img.<API key> {
right: -50px
}
.ultb3-hover-4 .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
.ultb3-hover-4:hover .ultb3-img.ultb3-img-center {
-webkit-transform: translate(-25%, -50%);
-ms-transform: translate(-25%, -50%);
transform: translate(-25%, -50%)
}
.ultb3-hover-4 .ultb3-img.<API key> {
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%)
}
.ultb3-hover-4:hover .ultb3-img.<API key> {
-webkit-transform: translate(25%, -50%);
-ms-transform: translate(25%, -50%);
transform: translate(25%, -50%)
}
.ultb3-hover-4 .ultb3-img.<API key> {
left: -50px
}
.ultb3-hover-4:hover .ultb3-img.<API key> {
left: 0
}
.ultb3-hover-4 .ultb3-img.<API key> {
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%)
}
.ultb3-hover-4:hover .ultb3-img.<API key> {
transform: translate(-25%);
-webkit-transform: translate(-25%);
-moz-transform: translate(-25%);
-ms-transform: translate(-25%);
-o-transform: translate(-25%)
}
.ultb3-hover-5 .ultb3-img {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1)
}
.ultb3-hover-5:hover .ultb3-img {
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1)
}
.ultb3-hover-6 .ultb3-img {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1
}
.ultb3-hover-6:hover .ultb3-img {
-webkit-transform: scale(2.5);
-ms-transform: scale(2.5);
transform: scale(2.5);
opacity: 0
}
|
package mdbtools.libmdb06util;
/**
* @author calvin
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class mdbver
{
public static void main(String[] args)
{
}
}
|
class Optimizer <API key> {
private:
IR* _ir;
public:
Optimizer(IR* ir);
IR* ir() const { return _ir; }
// optimizations
void <API key>();
void eliminate_blocks();
void <API key>();
};
|
namespace Server.Items
{
public class DestroyingAngel : BaseReagent, ICommodity
{
int ICommodity.DescriptionNumber { get { return LabelNumber; } }
bool ICommodity.IsDeedable { get { return true; } }
[Constructable]
public DestroyingAngel() : this( 1 )
{
}
[Constructable]
public DestroyingAngel( int amount ) : base( 0xE1F )
{
Stackable = true;
Weight = 0.0;
Amount = amount;
Name = "Destroying Angel";
Hue = 0x290;
}
public DestroyingAngel( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class PetrafiedWood : BaseReagent, ICommodity
{
int ICommodity.DescriptionNumber { get { return LabelNumber; } }
bool ICommodity.IsDeedable { get { return true; } }
[Constructable]
public PetrafiedWood() : this( 1 )
{
}
[Constructable]
public PetrafiedWood( int amount ) : base( 0x97A )
{
Stackable = true;
Weight = 0.0;
Amount = amount;
Name = "Petrafied Wood";
Hue = 0x46C;
}
public PetrafiedWood( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class SpringWater : BaseReagent, ICommodity
{
int ICommodity.DescriptionNumber { get { return LabelNumber; } }
bool ICommodity.IsDeedable { get { return true; } }
[Constructable]
public SpringWater() : this( 1 )
{
}
[Constructable]
public SpringWater( int amount ) : base( 0xE24 )
{
Stackable = true;
Weight = 0.0;
Amount = amount;
Name = "Spring Water";
Hue = 0x47F;
}
public SpringWater( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}
|
/**
* Drupal-specific JS helper functions and utils. Not to be confused with the
* Recline library, which should live in your libraries directory.
*/
;(function ($) {
// Constants.
var MAX_LABEL_WIDTH = 77;
var LABEL_MARGIN = 5;
// Undefined variables.
var dataset, views, datasetOptions, fileSize, fileType, router;
var <API key>, state, $explorer, dataExplorer, maxSizePreview;
var datastoreStatus;
// Create drupal behavior
Drupal.behaviors.Recline = {
attach: function (context) {
$explorer = $('.data-explorer');
// Local scoped variables.
Drupal.settings.recline = Drupal.settings.recline || {};
fileSize = Drupal.settings.recline.fileSize;
fileType = Drupal.settings.recline.fileType;
maxSizePreview = Drupal.settings.recline.maxSizePreview;
datastoreStatus = Drupal.settings.recline.datastoreStatus;
<API key> = {
grid: Drupal.settings.recline.grid,
graph: Drupal.settings.recline.graph,
map: Drupal.settings.recline.map
};
// This is the very basic state collection.
state = recline.View.parseQueryString(decodeURIComponent(window.location.hash));
if ('#map' in state) {
state.currentView = 'map';
} else if ('#graph' in state) {
state.currentView = 'graph';
}
// Init the explorer.
init();
// Attach toogle event.
$('.recline-embed a.embed-link').on('click', function(){
$(this).parents('.recline-embed').find('.embed-code-wrapper').toggle();
return false;
});
}
}
// make Explorer creation / initialization in a function so we can call it
// again and again
function createExplorer (dataset, state, settings) {
// Remove existing data explorer view.
dataExplorer && dataExplorer.remove();
var $el = $('<div />');
$el.appendTo($explorer);
var views = [];
if (settings.grid) {
views.push({
id: 'grid',
label: 'Grid',
view: new recline.View.SlickGrid({
model: dataset
})
});
}
if (settings.graph) {
state.graphOptions = {
xaxis: {
tickFormatter: tickFormatter(dataset),
},
hooks:{
processOffset: [processOffset(dataset)],
bindEvents: [bindEvents],
}
};
views.push({
id: 'graph',
label: 'Graph',
view: new recline.View.Graph({
model: dataset,
state: state
})
});
}
if (settings.map) {
views.push({
id: 'map',
label: 'Map',
view: new recline.View.Map({
model: dataset,
options: {
mapTilesURL: '//stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png',
}
})
});
}
// Multiview settings
var multiviewOptions = {
model: dataset,
el: $el,
state: state,
views: views
};
// Getting base embed url.
var urlBaseEmbed = $('.embed-code').text();
var iframeOptions = {src: urlBaseEmbed, width:850, height:400};
// Attaching router to dataexplorer state.
dataExplorer = new recline.View.MultiView(multiviewOptions);
router = new recline.DeepLink.Router(dataExplorer);
// Adding router listeners.
var changeEmbedCode = getEmbedCode(iframeOptions);
router.on('init', changeEmbedCode);
router.on('stateChange', changeEmbedCode);
// Add map dependency just for map views.
_.each(dataExplorer.pageViews, function(item, index){
if(item.id && item.id === 'map'){
var map = dataExplorer.pageViews[index].view.map;
router.addDependency(new recline.DeepLink.Deps.Map(map, router));
}
});
// Start to track state chages.
router.start();
$.event.trigger('createDataExplorer');
return views;
}
// Returns the dataset configuration.
function getDatasetOptions () {
var datasetOptions = {};
var delimiter = Drupal.settings.recline.delimiter;
var file = Drupal.settings.recline.file;
var uuid = Drupal.settings.recline.uuid;
// Get correct file location, make sure not local
file = (getOrigin(window.location) !== getOrigin(file)) ? '/node/' + Drupal.settings.recline.uuid + '/data' : file;
// Select the backend to use
switch(getBackend(datastoreStatus, fileType)) {
case 'csv':
datasetOptions = {
backend: 'csv',
url: file,
delimiter: delimiter
};
break;
case 'tsv':
datasetOptions = {
backend: 'csv',
url: file,
delimiter: delimiter
};
break;
case 'txt':
datasetOptions = {
backend: 'csv',
url: file,
delimiter: delimiter
};
break;
case 'ckan':
datasetOptions = {
endpoint: 'api',
id: uuid,
backend: 'ckan'
};
break;
case 'xls':
datasetOptions = {
backend: 'xls',
url: file
};
break;
case 'dataproxy':
datasetOptions = {
url: file,
backend: 'dataproxy'
};
break;
default:
showError('File type ' + fileType + ' not supported for preview.');
break;
}
return datasetOptions;
}
// Correct for fact that IE does not provide .origin
function getOrigin(u) {
var url = parseURL(u);
return url.protocol + '//' + url.hostname + (url.port ? (':' + url.port) : '');
}
// Parse a simple URL string to get its properties
function parseURL(url) {
var parser = document.createElement('a');
parser.href = url;
return {
protocol: parser.protocol,
hostname: parser.hostname,
port: parser.port,
pathname: parser.pathname,
search: parser.search,
hash: parser.hash,
host: parser.host
}
}
// Retrieve a backend given a file type and and a datastore status.
function getBackend (datastoreStatus, fileType) {
// If it's inside the datastore then we use the dkan API
if (datastoreStatus) return 'ckan';
var formats = {
'csv': ['text/csv', 'csv'],
'xls': ['application/vnd.ms-excel', 'application/vnd.<API key>.spreadsheetml.sheet'],
'tsv': ['text/<API key>', 'text/tsv', 'tsv', 'tab'],
'txt': ['text/plain', 'txt'],
};
var backend = _.findKey(formats, function(format) { return _.include(format, fileType) });
// If the backend is a txt but the delimiter is not a tab, we don't need
// to show it using the backend.
if (Drupal.settings.recline.delimiter !== "\t" && backend === 'txt') {return '';}
// If the backend is an xls but the browser version is prior 9 then
// we need to fallback to dataproxy
if (backend === 'xls' && document.documentMode < 9) return 'dataproxy';
return backend;
}
// Displays an error retrieved from the response object.
function showRequestError (response) {
// Actually dkan doesn't provide standarization over
// error handling responses. For example: if you request
// unexistent resources it will retrive an array with a
// message inside.
// Recline backends will return an object with an error.
try {
var ro = (typeof response === 'string') ? JSON.parse(response) : response;
if(ro.error) {
showError(ro.error.message)
} else if(ro instanceof Array) {
showError(ro[0]);
}
} catch (error) {
showError(response);
}
}
// Displays an error.
function showError (message) {
$explorer.html('<div class="messages error">' + message + '</div>');
}
// Creates the embed code.
function getEmbedCode (options){
return function(state){
var iframeOptions = _.clone(options);
var iframeTmpl = _.template('<iframe width="<%= width %>" height="<%= height %>" src="<%= src %>" frameborder="0"></iframe>');
var previewTmpl = _.template('<%= src %>');
_.extend(iframeOptions, {src: iframeOptions.src + '#' + (state.serializedState || '')});
var html = iframeTmpl(iframeOptions);
$('.embed-code').text(html);
var preview = previewTmpl(iframeOptions);
$('.preview-code').text(preview);
};
}
// Creates the preview url code.
function getPreviewCode (options){
return function(state){
var previewOptions = _.clone(options);
var previewTmpl = _.template('<%= src %>');
_.extend(previewOptions, {src: previewOptions.src + '#' + (state.serializedState || '')});
var html = previewTmpl(previewOptions);
$('.preview-url').text(html);
};
}
// Check if a chart has their axis inverted.
function isInverted (){
return dataExplorer.pageViews[1].view.state.attributes.graphType === 'bars';
}
// Computes the width of a chart.
function computeWidth (plot, labels) {
var biggerLabel = '';
for( var i = 0; i < labels.length; i++){
if(labels[i].length > biggerLabel.length && !_.isUndefined(labels[i])){
biggerLabel = labels[i];
}
}
var canvas = plot.getCanvas();
var ctx = canvas.getContext('2d');
ctx.font = 'sans-serif smaller';
return ctx.measureText(biggerLabel).width;
}
// Resize a chart.
function resize (plot) {
var itemWidth = computeWidth(plot, _.pluck(plot.getXAxes()[0].ticks, 'label'));
var graph = dataExplorer.pageViews[1];
if(!isInverted() && $('#<API key>').is(':checked')){
var canvasWidth = Math.min(itemWidth + LABEL_MARGIN, MAX_LABEL_WIDTH) * plot.getXAxes()[0].ticks.length;
var canvasContainerWith = $('.panel.graph').parent().width();
if(canvasWidth < canvasContainerWith){
canvasWidth = canvasContainerWith;
}
$('.panel.graph').width(canvasWidth);
$('.recline-flot').css({overflow:'auto'});
}else{
$('.recline-flot').css({overflow:'hidden'});
$('.panel.graph').css({width: '100%'});
}
plot.resize();
plot.setupGrid();
plot.draw();
}
// Bind events after chart resizes.
function bindEvents (plot, eventHolder) {
var p = plot || dataExplorer.pageViews[1].view.plot;
resize(p);
setTimeout(addCheckbox, 0);
}
// Compute the chart offset to display ticks properly.
function processOffset (dataset) {
return function(plot, offset) {
if(dataExplorer.pageViews[1].view.xvaluesAreIndex){
var series = plot.getData();
for (var i = 0; i < series.length; i++) {
var numTicks = Math.min(dataset.records.length, 200);
var ticks = [];
for (var j = 0; j < dataset.records.length; j++) {
ticks.push(parseInt(j, 10));
}
if(isInverted()){
series[i].yaxis.options.ticks = ticks;
}else{
series[i].xaxis.options.ticks = ticks;
}
}
}
};
}
// Format ticks base on previews computations.
function tickFormatter (dataset){
return function (x) {
x = parseInt(x, 10);
try {
if(isInverted()) return x;
var field = dataExplorer.pageViews[1].view.state.get('group');
var label = dataset.records.models[x].get(field) || '';
if(!moment(String(label)).isValid() && !isNaN(parseInt(label, 10))){
label = parseInt(label, 10) - 1;
}
return label;
} catch(e) {
return x;
}
};
}
// Add checkbox to control resize behavior.
function addCheckbox () {
$control = $('.form-stacked:visible').find('#<API key>');
if(!$control.length){
$form = $('.form-stacked');
$checkboxDiv = $('<div class="checkbox"></div>').appendTo($form);
$label = $('<label />', { 'for': '<API key>', text: 'Resize graph to prevent label overlapping' }).appendTo($checkboxDiv);
$label.prepend($('<input />', { type: 'checkbox', id: '<API key>', value: '' }));
$control = $('#<API key>');
$control.on('change', function(){
resize(dataExplorer.pageViews[1].view.plot);
});
}
}
// Init the multiview.
function init () {
if(fileSize < maxSizePreview || datastoreStatus) {
dataset = new recline.Model.Dataset(getDatasetOptions());
dataset.fetch().fail(showRequestError);
views = createExplorer(dataset, state, <API key>);
views.forEach(function(view) { view.id === 'map' && view.view.redraw('refresh') });
} else {
showError('File was too large or unavailable for preview.');
}
}
})(jQuery);
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http:
<html xmlns="http:
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;url=help.php?module=questionnaire&file=fieldlength.html" />
<title>redirect</title>
</head>
<body>
<p>
</p>
</body>
</html>
|
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/fsl_devices.h>
#include <linux/mutex.h>
#include <linux/mipi_csi2.h>
#include <linux/pwm.h>
#include <media/v4l2-chip-ident.h>
#include <media/v4l2-int-device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/soc-dapm.h>
#include <asm/mach-types.h>
//#include <mach/audmux.h>
#include <linux/slab.h>
#include "mxc_v4l2_capture.h"
#define CODEC_CLOCK 16500000
/* SSI clock sources */
#define IMX_SSP_SYS_CLK 0
#define <API key> 2800000
#define <API key> 1500000
#define <API key> 1800000
#define MIN_FPS 30
#define MAX_FPS 60
#define DEFAULT_FPS 60
#define TC358743_XCLK_MIN 27000000
#define TC358743_XCLK_MAX 42000000
#define <API key> 0x0
#define <API key> 0x0
#define <API key> 0x0f //0x10
#define TC_VOLTAGE_ANALOG 2800000
#define <API key> 1500000
#define <API key> 1800000
enum tc358743_mode {
tc358743_mode_INIT, /*only for sensor init*/
tc358743_mode_INIT1, /*only for sensor init*/
<API key>,
<API key>,
<API key>,
<API key>,
tc358743_mode_INIT2, /*only for sensor init*/
tc358743_mode_INIT3, /*only for sensor init*/
tc358743_mode_INIT4, /*only for sensor init*/
tc358743_mode_INIT5, /*only for sensor init*/
tc358743_mode_INIT6, /*only for sensor init*/
<API key>,
tc358743_mode_MAX ,
};
enum tc358743_frame_rate {
tc358743_60_fps,
tc358743_30_fps,
tc358743_max_fps
};
struct reg_value {
u16 u16RegAddr;
u32 u32Val;
u32 u32Mask;
u8 u8Length;
u32 u32Delay_ms;
};
struct tc358743_mode_info {
enum tc358743_mode mode;
u32 width;
u32 height;
u32 vformat;
u32 fps;
u32 lanes;
u32 freq;
struct reg_value *init_data_ptr;
u32 init_data_size;
__u32 flags;
};
static struct delayed_work det_work;
static struct sensor_data tc358743_data;
static int pwn_gpio, rst_gpio;
static struct regulator *io_regulator;
static struct regulator *core_regulator;
static struct regulator *analog_regulator;
static struct regulator *gpo_regulator;
static u16 hpd_active = 1;
#define <API key> 100
#define <API key> 2000
#define MAX_BOUNCE 5
static DEFINE_MUTEX(access_lock);
static int det_work_disable = 0;
static int det_work_timeout = <API key>;
static u32 hdmi_mode = 0, lock = 0, bounce = 0, fps = 0, audio = 2;
static int tc358743_init_mode(enum tc358743_frame_rate frame_rate,
enum tc358743_mode mode);
static int tc358743_toggle_hpd(int active);
static void tc_standby(s32 enable)
{
if (gpio_is_valid(pwn_gpio))
gpio_set_value(pwn_gpio, enable ? 1 : 0);
pr_debug("tc_standby: powerdown=%x, power_gp=0x%x\n", enable, pwn_gpio);
msleep(2);
}
static void tc_reset(void)
{
/* camera reset */
gpio_set_value(rst_gpio, 1);
/* camera power dowmn */
if (gpio_is_valid(pwn_gpio)) {
gpio_set_value(pwn_gpio, 1);
msleep(5);
gpio_set_value(pwn_gpio, 0);
}
msleep(5);
gpio_set_value(rst_gpio, 0);
msleep(1);
gpio_set_value(rst_gpio, 1);
msleep(20);
if (gpio_is_valid(pwn_gpio))
gpio_set_value(pwn_gpio, 1);
}
static int tc_power_on(struct device *dev)
{
int ret = 0;
io_regulator = devm_regulator_get(dev, "DOVDD");
if (!IS_ERR(io_regulator)) {
<API key>(io_regulator,
<API key>,
<API key>);
ret = regulator_enable(io_regulator);
if (ret) {
pr_err("%s:io set voltage error\n", __func__);
return ret;
} else {
dev_dbg(dev,
"%s:io set voltage ok\n", __func__);
}
} else {
pr_err("%s: cannot get io voltage error\n", __func__);
io_regulator = NULL;
}
core_regulator = devm_regulator_get(dev, "DVDD");
if (!IS_ERR(core_regulator)) {
<API key>(core_regulator,
<API key>,
<API key>);
ret = regulator_enable(core_regulator);
if (ret) {
pr_err("%s:core set voltage error\n", __func__);
return ret;
} else {
dev_dbg(dev,
"%s:core set voltage ok\n", __func__);
}
} else {
core_regulator = NULL;
pr_err("%s: cannot get core voltage error\n", __func__);
}
analog_regulator = devm_regulator_get(dev, "AVDD");
if (!IS_ERR(analog_regulator)) {
<API key>(analog_regulator,
TC_VOLTAGE_ANALOG,
TC_VOLTAGE_ANALOG);
ret = regulator_enable(analog_regulator);
if (ret) {
pr_err("%s:analog set voltage error\n",
__func__);
return ret;
} else {
dev_dbg(dev,
"%s:analog set voltage ok\n", __func__);
}
} else {
analog_regulator = NULL;
pr_err("%s: cannot get analog voltage error\n", __func__);
}
return ret;
}
static void det_work_enable(int i)
{
mutex_lock(&access_lock);
if (i) {
det_work_timeout = <API key>;
<API key>(&(det_work), msecs_to_jiffies(det_work_timeout));
det_work_disable = 0;
} else {
det_work_disable = 1;
det_work_timeout = <API key>;
}
mutex_unlock(&access_lock);
pr_debug("%s: %d %d\n", __func__, det_work_disable, det_work_timeout);
}
static u8 cHDMIEDID[256] = {
/* FIXME! This is the edid that my ASUS HDMI monitor returns */
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x04, 0x69, 0xf3, 0x24, 0xd6, 0x12, 0x00, 0x00,
0x16, 0x16, 0x01, 0x03, 0x80, 0x34, 0x1d, 0x78, 0x2a, 0xc7, 0x20, 0xa4, 0x55, 0x49, 0x99, 0x27,
0x13, 0x50, 0x54, 0xbf, 0xef, 0x00, 0x71, 0x4f, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00, 0xb3, 0x00,
0xd1, 0xc0, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
0x45, 0x00, 0x09, 0x25, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xff, 0x00, 0x43, 0x36, 0x4c,
0x4d, 0x54, 0x46, 0x30, 0x30, 0x34, 0x38, 0x32, 0x32, 0x0a, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x37,
0x4b, 0x1e, 0x55, 0x10, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
0x00, 0x41, 0x53, 0x55, 0x53, 0x20, 0x56, 0x48, 0x32, 0x34, 0x32, 0x48, 0x0a, 0x20, 0x01, 0x78,
0x02, 0x03, 0x22, 0x71, 0x4f, 0x01, 0x02, 0x03, 0x11, 0x12, 0x13, 0x04, 0x14, 0x05, 0x0e, 0x0f,
0x1d, 0x1e, 0x1f, 0x10, 0x23, 0x09, 0x07, 0x01, 0x83, 0x01, 0x00, 0x00, 0x65, 0x03, 0x0c, 0x00,
0x10, 0x00, 0x8c, 0x0a, 0xd0, 0x8a, 0x20, 0xe0, 0x2d, 0x10, 0x10, 0x3e, 0x96, 0x00, 0x09, 0x25,
0x21, 0x00, 0x00, 0x18, 0x01, 0x1d, 0x00, 0x72, 0x51, 0xd0, 0x1e, 0x20, 0x6e, 0x28, 0x55, 0x00,
0x09, 0x25, 0x21, 0x00, 0x00, 0x1e, 0x01, 0x1d, 0x00, 0xbc, 0x52, 0xd0, 0x1e, 0x20, 0xb8, 0x28,
0x55, 0x40, 0x09, 0x25, 0x21, 0x00, 0x00, 0x1e, 0x8c, 0x0a, 0xd0, 0x90, 0x20, 0x40, 0x31, 0x20,
0x0c, 0x40, 0x55, 0x00, 0x09, 0x25, 0x21, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73,
};
/*!
* Maintains the information on the current state of the sesor.
*/
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000004, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000040, 0x00000000, 2, 0},
{0x0014, 0x00000000, 0x00000000, 2, 0},
{0x0016, 0x000005ff, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000402d, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000e00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000801, 0x00000000, 4, 0},
{0x021c, 0x00000001, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004800, 0x00000000, 4, 0},
{0x0228, 0x00000005, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa300be82, 0x00000000, 4, 0},
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0},
{0x8512, 0x000000fe, 0x00000000, 1, 0},
{0x8514, 0x00000000, 0x00000000, 1, 0},
{0x8515, 0x00000000, 0x00000000, 1, 0},
{0x8516, 0x00000000, 0x00000000, 1, 0},
// HDMI Audio RefClk (26 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0},
{0x8540, 0x0000008c, 0x00000000, 1, 0},
{0x8541, 0x0000000a, 0x00000000, 1, 0},
{0x8630, 0x000000b0, 0x00000000, 1, 0},
{0x8631, 0x0000001e, 0x00000000, 1, 0},
{0x8632, 0x00000004, 0x00000000, 1, 0},
{0x8670, 0x00000001, 0x00000000, 1, 0},
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0},
{0x85cb, 0x00000001, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0},
// {0x8544, 0x00000000, 0x00000000, 1, 1000},
// {0x8544, 0x00000001, 0x00000000, 1, 100},
{0x8545, 0x00000031, 0x00000000, 1, 0},
{0x8546, 0x0000002d, 0x00000000, 1, 0},
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// Video settings
{0x8573, 0x00000081, 0x00000000, 1, 0},
{0x8571, 0x00000002, 0x00000000, 1, 0},
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
// {0x8651, 0x00000003, 0x00000000, 1, 0}, // Inverted LRCK polarity - (Sony) format
{0x8652, 0x00000002, 0x00000000, 1, 0}, // Left-justified I2S (Phillips) format
// {0x8652, 0x00000000, 0x00000000, 1, 0}, // Right-justified (Sony) format
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0},
{0x870b, 0x0000002c, 0x00000000, 1, 0},
{0x870c, 0x00000053, 0x00000000, 1, 0},
{0x870d, 0x00000001, 0x00000000, 1, 0},
{0x870e, 0x00000030, 0x00000000, 1, 0},
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0},
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000004, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0014, 0x0000ffff, 0x00000000, 2, 0},
{0x0016, 0x000005ff, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x00004062, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000d00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000701, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000005, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa300be86, 0x00000000, 4, 0},
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0},
{0x8512, 0x000000fe, 0x00000000, 1, 0},
{0x8514, 0x00000000, 0x00000000, 1, 0},
{0x8515, 0x00000000, 0x00000000, 1, 0},
{0x8516, 0x00000000, 0x00000000, 1, 0},
// HDMI Audio RefClk (26 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0},
{0x8540, 0x00000a8c, 0x00000000, 1, 0},
{0x8630, 0x00041eb0, 0x00000000, 1, 0},
{0x8670, 0x00000001, 0x00000000, 1, 0},
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0},
{0x8544, 0x00000000, 0x00000000, 1, 0},
{0x8545, 0x00000031, 0x00000000, 1, 0},
{0x8546, 0x0000002d, 0x00000000, 1, 0},
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0},
{0x85cb, 0x00000001, 0x00000000, 1, 0},
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// RGB --> YUV Conversion
// {0x8574, 0x00000000, 0x00000000, 1, 0},
{0x8573, 0x00000081, 0x00000000, 1, 0},
{0x8571, 0x00000002, 0x00000000, 1, 0},
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
{0x8652, 0x00000002, 0x00000000, 1, 0},
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0},
{0x870b, 0x0000002c, 0x00000000, 1, 0},
{0x870c, 0x00000053, 0x00000000, 1, 0},
{0x870d, 0x00000001, 0x00000000, 1, 0},
{0x870e, 0x00000030, 0x00000000, 1, 0},
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0},
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000405c, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000e00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000801, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000006, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x00000007, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a2, 0x00000000, 4, 0},
// 1280x720 colorbar
{0x000a, 0x00000a00, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 128 pixel black - repeat 128 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(128<<16)},
// 128 pixel blue - repeat 64 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel red - repeat 64 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel pink - repeat 64 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel green - repeat 64 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel light blue - repeat 64 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel yellow - repeat 64 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel white - repeat 64 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(64<<16)},
// 720 lines
{0x7090, 0x000002cf, 0x00000000, 2, 0},
{0x7092, 0x00000580, 0x00000000, 2, 0},
{0x7094, 0x00000010, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000405c, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000e00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000801, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000006, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x0000001F, 0x00000000, 4, 0}, //{0x0234, 0x00000007, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a6, 0x00000000, 4, 0}, //{0x0500, 0xa30080a2, 0x00000000, 4, 0},
// 1280x720 colorbar
{0x000a, 0x00000a00, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 128 pixel black - repeat 128 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(128<<16)},
// 128 pixel blue - repeat 64 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel red - repeat 64 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel pink - repeat 64 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel green - repeat 64 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel light blue - repeat 64 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel yellow - repeat 64 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel white - repeat 64 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(64<<16)},
// 720 lines
{0x7090, 0x000002cf, 0x00000000, 2, 0},
{0x7092, 0x00000300, 0x00000000, 2, 0}, //{0x7092, 0x00000580, 0x00000000, 2, 0},
{0x7094, 0x00000010, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x00004050, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001800, 0x00000000, 4, 0},
{0x0214, 0x00000002, 0x00000000, 4, 0},
{0x0218, 0x00001102, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000003, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000007, 0x00000000, 4, 0},
{0x022c, 0x00000001, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a6, 0x00000000, 4, 0},
// 1280x720 colorbar
{0x000a, 0x00000800, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 128 pixel black - repeat 128 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(128<<16)},
// 128 pixel blue - repeat 64 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel red - repeat 64 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel pink - repeat 64 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel green - repeat 64 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel light blue - repeat 64 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel yellow - repeat 64 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel white - repeat 64 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(64<<16)},
// 720 lines
{0x0020, 0x0000406f, 0x00000000, 2, 100},
{0x7090, 0x000002cf, 0x00000000, 2, 0},
{0x7092, 0x00000540, 0x00000000, 2, 0},
{0x7094, 0x00000010, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x000080c7, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001e00, 0x00000000, 4, 0},
{0x0214, 0x00000003, 0x00000000, 4, 0},
{0x0218, 0x00001402, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000003, 0x00000000, 4, 0},
{0x0224, 0x00004a00, 0x00000000, 4, 0},
{0x0228, 0x00000008, 0x00000000, 4, 0},
{0x022c, 0x00000002, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a6, 0x00000000, 4, 0},
// 1280x720 colorbar
{0x000a, 0x00000a00, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 128 pixel black - repeat 128 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(128<<16)},
// 128 pixel blue - repeat 64 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel red - repeat 64 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel pink - repeat 64 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel green - repeat 64 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel light blue - repeat 64 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel yellow - repeat 64 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel white - repeat 64 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(64<<16)},
// 720 lines
{0x7090, 0x000002cf, 0x00000000, 2, 0},
{0x7092, 0x000006b8, 0x00000000, 2, 0},
{0x7094, 0x00000010, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x000080c7, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001e00, 0x00000000, 4, 0},
{0x0214, 0x00000003, 0x00000000, 4, 0},
{0x0218, 0x00001402, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000003, 0x00000000, 4, 0},
{0x0224, 0x00004a00, 0x00000000, 4, 0},
{0x0228, 0x00000008, 0x00000000, 4, 0},
{0x022c, 0x00000002, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0}, //non-continuous clock
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a6, 0x00000000, 4, 0},
// 1920x1023 colorbar
{0x000a, 0x00000f00, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 128 pixel black - repeat 128 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(128<<16)},
// 128 pixel blue - repeat 64 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel red - repeat 64 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel pink - repeat 64 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel green - repeat 64 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel light blue - repeat 64 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel yellow - repeat 64 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(64<<16)},
// 128 pixel white - repeat 64 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(64<<16)},
// 1023 lines
{0x7090, 0x000003fe, 0x00000000, 2, 0},
{0x7092, 0x000004d8, 0x00000000, 2, 0},
{0x7094, 0x0000002d, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x00008073, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
// {0x014c, 0x00000000, 0x00000000, 4, 0},
// {0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001200, 0x00000000, 4, 0},
{0x0214, 0x00000002, 0x00000000, 4, 0},
{0x0218, 0x00000b02, 0x00000000, 4, 0},
{0x021c, 0x00000001, 0x00000000, 4, 0},
{0x0220, 0x00000103, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000008, 0x00000000, 4, 0},
{0x022c, 0x00000002, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000000, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xA3008082, 0x00000000, 4, 0},
// 640x480 colorbar
{0x000a, 0x00000500, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 80 pixel black - repeate 80 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(80<<16)},
// 80 pixel blue - repeate 40 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel red - repeate 40 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel pink - repeate 40 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel green - repeate 40 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel light blue - repeate 40 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel yellow - repeate 40 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel white - repeate 40 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(40<<16)},
// 480 lines
{0x7090, 0x000001df, 0x00000000, 2, 0},
{0x7092, 0x00000898, 0x00000000, 2, 0},
{0x7094, 0x00000285, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0010, 0x0000001e, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000404F, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001800, 0x00000000, 4, 0},
{0x0214, 0x00000002, 0x00000000, 4, 0},
{0x0218, 0x00001102, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000003, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000007, 0x00000000, 4, 0},
{0x022c, 0x00000001, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xA30080A2, 0x00000000, 4, 0},
// 640x480 colorbar
{0x000a, 0x00000500, 0x00000000, 2, 0},
{0x7080, 0x00000082, 0x00000000, 2, 0},
// 80 pixel black - repeate 80 times
{0x7000, 0x0000007f, 0x00000000, 2, (1<<24)|(80<<16)},
// 80 pixel blue - repeate 40 times
{0x7000, 0x000000ff, 0x00000000, 2, 0},
{0x7000, 0x00000000, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel red - repeate 40 times
{0x7000, 0x00000000, 0x00000000, 2, 0},
{0x7000, 0x000000ff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel pink - repeate 40 times
{0x7000, 0x00007fff, 0x00000000, 2, 0},
{0x7000, 0x00007fff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel green - repeate 40 times
{0x7000, 0x00007f00, 0x00000000, 2, 0},
{0x7000, 0x00007f00, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel light blue - repeate 40 times
{0x7000, 0x0000c0ff, 0x00000000, 2, 0},
{0x7000, 0x0000c000, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel yellow - repeate 40 times
{0x7000, 0x0000ff00, 0x00000000, 2, 0},
{0x7000, 0x0000ffff, 0x00000000, 2, (2<<24)|(40<<16)},
// 80 pixel white - repeate 40 times
{0x7000, 0x0000ff7f, 0x00000000, 2, 0},
{0x7000, 0x0000ff7f, 0x00000000, 2, (2<<24)|(40<<16)},
// 480 lines
{0x7090, 0x000001df, 0x00000000, 2, 0},
{0x7092, 0x00000700, 0x00000000, 2, 0},
{0x7094, 0x00000010, 0x00000000, 2, 0},
{0x7080, 0x00000083, 0x00000000, 2, 0},
};
//480p RGB2YUV442
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000004, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000040, 0x00000000, 2, 0},
// {0x000a, 0x000005a0, 0x00000000, 2, 0},
// {0x0010, 0x0000001e, 0x00000000, 2, 0},
{0x0014, 0x00000000, 0x00000000, 2, 0},
{0x0016, 0x000005ff, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000405c, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000d00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000701, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000005, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xA30080A2, 0x00000000, 4, 0},
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0},
{0x8512, 0x000000fe, 0x00000000, 1, 0},
{0x8514, 0x00000000, 0x00000000, 1, 0},
{0x8515, 0x00000000, 0x00000000, 1, 0},
{0x8516, 0x00000000, 0x00000000, 1, 0},
// HDMI Audio RefClk (26 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0},
{0x8540, 0x00000a8c, 0x00000000, 1, 0},
{0x8630, 0x00041eb0, 0x00000000, 1, 0},
{0x8670, 0x00000001, 0x00000000, 1, 0},
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0},
{0x8544, 0x00000000, 0x00000000, 1, 100},
// {0x8544, 0x00000001, 0x00000000, 1, 100},
{0x8545, 0x00000031, 0x00000000, 1, 0},
{0x8546, 0x0000002d, 0x00000000, 1, 0},
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0},
{0x85cb, 0x00000001, 0x00000000, 1, 0},
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// RGB --> YUV Conversion
{0x8573, 0x00000081, 0x00000000, 1, 0},
{0x8571, 0x00000002, 0x00000000, 1, 0},
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
{0x8652, 0x00000002, 0x00000000, 1, 0},
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0},
{0x870b, 0x0000002c, 0x00000000, 1, 0},
{0x870c, 0x00000053, 0x00000000, 1, 0},
{0x870d, 0x00000001, 0x00000000, 1, 0},
{0x870e, 0x00000030, 0x00000000, 1, 0},
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0},
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0},
};
//480p RGB2YUV442
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000004, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000040, 0x00000000, 2, 0},
{0x000a, 0x000005a0, 0x00000000, 2, 0},
// {0x0010, 0x0000001e, 0x00000000, 2, 0},
{0x0014, 0x00000000, 0x00000000, 2, 0},
{0x0016, 0x000005ff, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x0000405b, 0x00000000, 2, 0},
{0x0022, 0x00000613, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00000d00, 0x00000000, 4, 0},
{0x0214, 0x00000001, 0x00000000, 4, 0},
{0x0218, 0x00000701, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000001, 0x00000000, 4, 0},
{0x0224, 0x00004000, 0x00000000, 4, 0},
{0x0228, 0x00000005, 0x00000000, 4, 0},
{0x022c, 0x00000000, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xA30080A2, 0x00000000, 4, 0},
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0},
{0x8512, 0x000000fe, 0x00000000, 1, 0},
{0x8514, 0x00000000, 0x00000000, 1, 0},
{0x8515, 0x00000000, 0x00000000, 1, 0},
{0x8516, 0x00000000, 0x00000000, 1, 0},
// HDMI Audio RefClk (27 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0},
{0x8540, 0x00000a8c, 0x00000000, 1, 0},
{0x8630, 0x00041eb0, 0x00000000, 1, 0},
{0x8670, 0x00000001, 0x00000000, 1, 0},
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0},
{0x8544, 0x00000000, 0x00000000, 1, 100},
// {0x8544, 0x00000001, 0x00000000, 1, 100},
{0x8545, 0x00000031, 0x00000000, 1, 0},
{0x8546, 0x0000002d, 0x00000000, 1, 0},
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0},
{0x85cb, 0x00000001, 0x00000000, 1, 0},
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// RGB --> YUV Conversion
{0x8573, 0x00000081, 0x00000000, 1, 0},
{0x8571, 0x00000002, 0x00000000, 1, 0},
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
{0x8652, 0x00000002, 0x00000000, 1, 0},
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0},
{0x870b, 0x0000002c, 0x00000000, 1, 0},
{0x870c, 0x00000053, 0x00000000, 1, 0},
{0x870d, 0x00000001, 0x00000000, 1, 0},
{0x870e, 0x00000030, 0x00000000, 1, 0},
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0},
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0},
{0x0004, 0x00000084, 0x00000000, 2, 0},
{0x0002, 0x00000f00, 0x00000000, 2, 100},
{0x0002, 0x00000000, 0x00000000, 2, 1000},
{0x0006, 0x00000000, 0x00000000, 2, 0},
{0x0014, 0x00000000, 0x00000000, 2, 0},
{0x0016, 0x000005ff, 0x00000000, 2, 0},
// Program CSI Tx PLL
{0x0020, 0x000080c7, 0x00000000, 2, 0},
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0},
{0x0144, 0x00000000, 0x00000000, 4, 0},
{0x0148, 0x00000000, 0x00000000, 4, 0},
{0x014c, 0x00000000, 0x00000000, 4, 0},
{0x0150, 0x00000000, 0x00000000, 4, 0},
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001e00, 0x00000000, 4, 0},
{0x0214, 0x00000003, 0x00000000, 4, 0},
{0x0218, 0x00001402, 0x00000000, 4, 0},
{0x021c, 0x00000000, 0x00000000, 4, 0},
{0x0220, 0x00000003, 0x00000000, 4, 0},
{0x0224, 0x00004a00, 0x00000000, 4, 0},
{0x0228, 0x00000008, 0x00000000, 4, 0},
{0x022c, 0x00000002, 0x00000000, 4, 0},
{0x0234, 0x0000001f, 0x00000000, 4, 0},
{0x0238, 0x00000001, 0x00000000, 4, 0},
{0x0204, 0x00000001, 0x00000000, 4, 0},
{0x0518, 0x00000001, 0x00000000, 4, 0},
{0x0500, 0xa30080a6, 0x00000000, 4, 0},
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0},
{0x8512, 0x000000fe, 0x00000000, 1, 0},
{0x8514, 0x00000000, 0x00000000, 1, 0},
{0x8515, 0x00000000, 0x00000000, 1, 0},
{0x8516, 0x00000000, 0x00000000, 1, 0},
// HDMI Audio RefClk (27 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0},
{0x8540, 0x00000a8c, 0x00000000, 1, 0},
{0x8630, 0x00041eb0, 0x00000000, 1, 0},
{0x8670, 0x00000001, 0x00000000, 1, 0},
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0},
{0x8544, 0x00000010, 0x00000000, 1, 100},
{0x8545, 0x00000031, 0x00000000, 1, 0},
{0x8546, 0x0000002d, 0x00000000, 1, 0},
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0},
{0x85cb, 0x00000001, 0x00000000, 1, 0},
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// RGB --> YUV Conversion
{0x8571, 0x00000002, 0x00000000, 1, 0},
{0x8573, 0x00000081, 0x00000000, 1, 0},
{0x8576, 0x00000060, 0x00000000, 1, 0},
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
{0x8652, 0x00000002, 0x00000000, 1, 0},
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0},
{0x870b, 0x0000002c, 0x00000000, 1, 0},
{0x870c, 0x00000053, 0x00000000, 1, 0},
{0x870d, 0x00000001, 0x00000000, 1, 0},
{0x870e, 0x00000030, 0x00000000, 1, 0},
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0},
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0},
};
static struct reg_value <API key>[] = {
{0x7080, 0x00000000, 0x00000000, 2, 0}, // IR control resister
{0x0004, 0x00000084, 0x00000000, 2, 0}, // Internal Generated output pattern,Do not send InfoFrame data out to CSI2,Audio output to CSI2-TX i/f,I2C address index increments on every data byte transfer, disable audio and video TX buffers
{0x0002, 0x00000f00, 0x00000000, 2, 100},//0}, // Reset devices and set normal operatio (not sleep)
{0x0002, 0x00000000, 0x00000000, 2, 1000},//0}, // Clear reset bits
{0x0006, 0x000001f8, 0x00000000, 2, 0}, // FIFO level = 1f8 = 504
{0x0014, 0x00000000, 0x00000000, 2, 0}, // Clear interrupt status bits
{0x0016, 0x000005ff, 0x00000000, 2, 0}, // Mask audio mute, CSI-TX, and the other interrups
// Program CSI Tx PLL
//{0x0020, 0x000080c7, 0x00000000, 2, 0}, // Input divider setting = 0x8 -> Division ratio = (PRD3..0) + 1 = 9, Feedback divider setting = 0xc7 -> Division ratio = (FBD8...0) + 1 = 200
{0x0020, 0x000080c7, 0x00000000, 2, 0}, // Input divider setting = 0x8 -> Division ratio = (PRD3..0) + 1 = 9, Feedback divider setting = 0xc7 -> Division ratio = (FBD8...0) + 1 = 200
{0x0022, 0x00000213, 0x00000000, 2, 0},
// CSI Tx PHY (32-bit Registers)
{0x0140, 0x00000000, 0x00000000, 4, 0}, // Clock Lane DPHY Control: Bypass Lane Enable from PPI Layer enable.
{0x0144, 0x00000000, 0x00000000, 4, 0}, // Data Lane 0 DPHY Control: Bypass Lane Enable from PPI Layer enable.
{0x0148, 0x00000000, 0x00000000, 4, 0}, // Data Lane 1 DPHY Control: Bypass Lane Enable from PPI Layer enable.
{0x014c, 0x00000000, 0x00000000, 4, 0}, // Data Lane 2 DPHY Control: Bypass Lane Enable from PPI Layer enable.
{0x0150, 0x00000000, 0x00000000, 4, 0}, // Data Lane 3 DPHY Control: Bypass Lane Enable from PPI Layer enable.
// CSI Tx PPI (32-bit Registers)
{0x0210, 0x00001e00, 0x00000000, 4, 0}, // LINEINITCNT: Line Initialization Wait Counter = 0x1e00 = 7680
{0x0214, 0x00000003, 0x00000000, 4, 0}, // LPTXTIMECNT: SYSLPTX Timing Generation Counter = 3
{0x0218, 0x00001402, 0x00000000, 4, 0}, // TCLK_HEADERCNT: TCLK_ZERO Counter = 0x14 = 20, TCLK_PREPARE Counter = 0x02 = 2
{0x021c, 0x00000000, 0x00000000, 4, 0}, // TCLK_TRAILCNT: TCLK_TRAIL Counter = 0
{0x0220, 0x00000003, 0x00000000, 4, 0}, // THS_HEADERCNT: THS_ZERO Counter = 0, THS_PREPARE Counter = 3
{0x0224, 0x00004a00, 0x00000000, 4, 0}, // TWAKEUP: TWAKEUP Counter = 0x4a00 = 18944
{0x0228, 0x00000008, 0x00000000, 4, 0}, // TCLK_POSTCNT: TCLK_POST Counter = 8
{0x022c, 0x00000002, 0x00000000, 4, 0}, // THS_TRAILCNT: THS_TRAIL Counter = 2
{0x0234, 0x0000001f, 0x00000000, 4, 0}, // HSTXVREGEN: Enable voltage regulators for lanes and clk
{0x0238, 0x00000001, 0x00000000, 4, 0}, // TXOPTIONCNTRL: Set Continuous Clock Mode
{0x0204, 0x00000001, 0x00000000, 4, 0}, // PPI STARTCNTRL: start PPI function
{0x0518, 0x00000001, 0x00000000, 4, 0}, // CSI_START: start
{0x0500, 0xa30080a6, 0x00000000, 4, 0}, // CSI Configuration Register: set register 0x040C with data 0x80a6 (CSI MOde, Disables the HTX_TO timer, High-Speed data transfer is performed to Tx, DSCClk Stays in HS mode when Data Lane goes to LP, 4 Data Lanes,The EOT packet is automatically granted at the end of HS transfer then is transmitted)
// HDMI Interrupt Mask
{0x8502, 0x00000001, 0x00000000, 1, 0}, // SYSTEM INTERRUPT: clear DDC power change detection interrupt
{0x8512, 0x000000fe, 0x00000000, 1, 0}, // SYS INTERRUPT MASK: DDC power change detection interrupt not masked
{0x8514, 0x00000000, 0x00000000, 1, 0}, // PACKET INTERRUPT MASK: unmask all
{0x8515, 0x00000000, 0x00000000, 1, 0}, // CBIT INTERRUPT MASK: unmask all
{0x8516, 0x00000000, 0x00000000, 1, 0}, // AUDIO INTERRUPT MASK: unmask all
// HDMI Audio RefClk (27 MHz)
{0x8531, 0x00000001, 0x00000000, 1, 0}, // PHY CONTROL0: 27MHz, DDC5V detection operation.
{0x8540, 0x00000a8c, 0x00000000, 1, 0}, // SYS FREQ0 Register: 27MHz
{0x8630, 0x00041eb0, 0x00000000, 1, 0}, // Audio FS Lock Detect Control: for 27MHz
{0x8670, 0x00000001, 0x00000000, 1, 0}, // AUDIO PLL Setting: For REFCLK = 27MHz
// HDMI PHY
{0x8532, 0x00000080, 0x00000000, 1, 0},
{0x8536, 0x00000040, 0x00000000, 1, 0},
{0x853f, 0x0000000a, 0x00000000, 1, 0},
// HDMI System
{0x8543, 0x00000032, 0x00000000, 1, 0}, // DDC CONTROL: DDC_ACK output terminal H active, DDC5V_active detect delay 200ms
{0x8544, 0x00000010, 0x00000000, 1, 100}, // HPD Control Register: HOTPLUG output ON/OFF control mode = DDC5V detection interlock
{0x8545, 0x00000031, 0x00000000, 1, 0}, // ANA CONTROL: PLL charge pump setting for Audio = normal, DAC/PLL power ON/OFF setting for Audio = ON
{0x8546, 0x0000002d, 0x00000000, 1, 0}, // AVMUTE CONTROL: AVM_CTL = 0x2d
// EDID
{0x85c7, 0x00000001, 0x00000000, 1, 0}, // EDID MODE REGISTER: nternal EDID-RAM & DDC2B mode
{0x85cb, 0x00000001, 0x00000000, 1, 0}, // EDID Length REGISTER 2: EDID data size stored in RAM (upper address bits) = 0x1 (Size = 0x100 = 256)
// HDCP Setting
{0x85d1, 0x00000001, 0x00000000, 1, 0},
{0x8560, 0x00000024, 0x00000000, 1, 0},
{0x8563, 0x00000011, 0x00000000, 1, 0},
{0x8564, 0x0000000f, 0x00000000, 1, 0},
// RGB --> YUV Conversion
{0x8571, 0x00000002, 0x00000000, 1, 0},
{0x8573, 0x000000c1, 0x00000000, 1, 0}, // VOUT SET2 REGISTER: 422 fixed output, Video Output 422 conversion mode selection 000: During 444 input, 3tap filter; during 422 input, simple decimation, Enable RGB888 to YUV422 Conversion (Fixed Color output)
{0x8574, 0x00000008, 0x00000000, 1, 0}, // VOUT SET3 REGISTER (VOUT_SET3): Follow register bit 0x8573[7] setting
{0x8576, 0x00000060, 0x00000000, 1, 0}, // VOUT_COLOR: Output Color = 601 YCbCr Limited, Input Pixel Repetition judgment = automatic, Input Pixel Repetition HOST setting = no repetition
// HDMI Audio In Setting
{0x8600, 0x00000000, 0x00000000, 1, 0},
{0x8602, 0x000000f3, 0x00000000, 1, 0},
{0x8603, 0x00000002, 0x00000000, 1, 0},
{0x8604, 0x0000000c, 0x00000000, 1, 0},
{0x8606, 0x00000005, 0x00000000, 1, 0},
{0x8607, 0x00000000, 0x00000000, 1, 0},
{0x8620, 0x00000022, 0x00000000, 1, 0},
{0x8640, 0x00000001, 0x00000000, 1, 0},
{0x8641, 0x00000065, 0x00000000, 1, 0},
{0x8642, 0x00000007, 0x00000000, 1, 0},
{0x8652, 0x00000002, 0x00000000, 1, 0},
{0x8665, 0x00000010, 0x00000000, 1, 0},
// InfoFrame Extraction
{0x8709, 0x000000ff, 0x00000000, 1, 0}, // PACKET INTERRUPT MODE: all enable
{0x870b, 0x0000002c, 0x00000000, 1, 0}, // NO PACKET LIMIT: NO_ACP_LIMIT = 0x2, NO_AVI_LIMIT = 0xC
{0x870c, 0x00000053, 0x00000000, 1, 0}, // When VS receive interrupt is detected, VS storage register automatic clear, When ACP receive interrupt is detected, ACP storage register automatic clear, When AVI receive interrupt occurs, judge input video signal with RGB and no Repetition, When AVI receive interrupt is detected, AVI storage register automatic clear.
{0x870d, 0x00000001, 0x00000000, 1, 0}, // ERROR PACKET LIMIT: Packet continuing receive error occurrence detection threshold = 1
{0x870e, 0x00000030, 0x00000000, 1, 0}, // NO PACKET LIMIT:
{0x9007, 0x00000010, 0x00000000, 1, 0},
{0x854a, 0x00000001, 0x00000000, 1, 0}, // Initialization completed flag
// Output Control
{0x0004, 0x00000cf7, 0x00000000, 2, 0}, // Configuration Control Register: Power Island Normal, I2S/TDM clock are free running, Enable 2 Audio channels, Audio channel number Auto detect by HW, I2S/TDM Data no delay, Select YCbCr422 8-bit (HDMI YCbCr422 12-bit data format), Send InfoFrame data out to CSI2, Audio output to I2S i/f (valid for 2 channel only), I2C address index increments on every data byte transfer, Audio and Video tx buffres enable.
};
/* list of image formats supported by TCM825X sensor */
static const struct v4l2_fmtdesc tc358743_formats[] = {
{
.description = "RGB888 (RGB24)",
.pixelformat = V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
.flags = MIPI_DT_RGB888 // 0x24
},
{
.description = "RAW12 (Y/CbCr 4:2:0)",
.pixelformat = V4L2_PIX_FMT_UYVY, /* 12 Y/CbCr 4:2:0 */
.flags = MIPI_DT_RAW12 // 0x2c
},
{
.description = "YUV 4:2:2 8-bit",
.pixelformat = V4L2_PIX_FMT_YUYV, /* 8 8-bit color */
.flags = MIPI_DT_YUV422 // 0x1e /* UYVY... */
},
};
static struct tc358743_mode_info <API key>[2][tc358743_mode_MAX] = {
[0][<API key>] =
{<API key>, 1280, 720, 12, 0, 4, 133,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][<API key>] =
{<API key>, 1920, 1080, 15, 0x0b, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT1] =
{tc358743_mode_INIT1, 1280, 720, 12, 0, 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT2] =
{tc358743_mode_INIT2, 1280, 720, 12, 0, 4, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT] =
{tc358743_mode_INIT, 640, 480, 6, 1, 2, 108,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT4] =
{tc358743_mode_INIT4, 640, 480, 6, 1, 2, 174,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT3] =
{tc358743_mode_INIT3, 1024, 720, 6, 1, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][<API key>] =
{<API key>, 1280, 720, 12, (0x3e)<<8|(0x3c), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[0][<API key>] =
{<API key>, 720, 480, 6, (0x02)<<8|(0x00), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[0][<API key>] =
{<API key>, 640, 480, 6, (0x02)<<8|(0x00), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[0][tc358743_mode_INIT5] =
{tc358743_mode_INIT5, 1280, 720, 12, 0, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[0][tc358743_mode_INIT6] =
{tc358743_mode_INIT6, 1920, 1023, 15, 0, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][<API key>] =
{<API key>, 1280, 720, 12, 0, 4, 133,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][<API key>] =
{<API key>, 1920, 1080, 15, 0xa, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT1] =
{tc358743_mode_INIT1, 1280, 720, 12, 0, 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT2] =
{tc358743_mode_INIT2, 1280, 720, 12, 0, 4, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT] =
{tc358743_mode_INIT, 640, 480, 6, 1, 2, 108,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT4] =
{tc358743_mode_INIT4, 640, 480, 6, 1, 2, 174,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT3] =
{tc358743_mode_INIT3, 1024, 720, 6, 1, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][<API key>] =
{<API key>, 1280, 720, 12, (0x3e)<<8|(0x3c), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[1][<API key>] =
{<API key>, 720, 480, 6, (0x02)<<8|(0x00), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[0][<API key>] =
{<API key>, 640, 480, 1, (0x02)<<8|(0x00), 2, 125,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422,
},
[1][tc358743_mode_INIT5] =
{tc358743_mode_INIT5, 1280, 720, 12, 0, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
[1][tc358743_mode_INIT6] =
{tc358743_mode_INIT6, 1920, 1023, 15, 0, 4, 300,
<API key>,
ARRAY_SIZE(<API key>),
MIPI_DT_YUV422
},
};
static int tc358743_probe(struct i2c_client *adapter,
const struct i2c_device_id *device_id);
static int tc358743_remove(struct i2c_client *client);
static s32 tc358743_read_reg(u16 reg, u32 *val);
static s32 tc358743_write_reg(u16 reg, u32 val, int len);
static const struct i2c_device_id tc358743_id[] = {
{"tc358743_mipi", 0},
{},
};
MODULE_DEVICE_TABLE(i2c, tc358743_id);
static struct i2c_driver tc358743_i2c_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "tc358743_mipi",
},
.probe = tc358743_probe,
.remove = tc358743_remove,
.id_table = tc358743_id,
};
struct _reg_size
{
u16 startaddr, endaddr;
int size;
}
<API key> [] =
{
{0x0000, 0x005a, 2},
{0x0140, 0x0150, 4},
{0x0204, 0x0238, 4},
{0x040c, 0x0418, 4},
{0x044c, 0x0454, 4},
{0x0500, 0x0518, 4},
{0x0600, 0x06cc, 4},
{0x7000, 0x7100, 2},
{0x8500, 0x8bff, 1},
{0x8c00, 0x8fff, 4},
{0x9000, 0x90ff, 1},
{0x9100, 0x92ff, 1},
{0, 0, 0},
};
static s32 tc358743_write_reg(u16 reg, u32 val, int len)
{
int i = 0;
u32 data = val;
u8 au8Buf[6] = {0};
int size = 0;
while (0 != <API key>[i].startaddr ||
0 != <API key>[i].endaddr ||
0 != <API key>[i].size) {
if (<API key>[i].startaddr <= reg
&& <API key>[i].endaddr >= reg) {
size = <API key>[i].size;
break;
}
i++;
}
if (!size) {
pr_err("%s:write reg error:reg=%x is not found\n",__func__, reg);
return -1;
}
if (size == 3) {
size = 2;
} else if (size != len) {
pr_err("%s:write reg len error:reg=%x %d instead of %d\n",
__func__, reg, len, size);
return 0;
}
while (len > 0) {
i = 0;
au8Buf[i++] = (reg >> 8) & 0xff;
au8Buf[i++] = reg & 0xff;
while (size
{
au8Buf[i++] = (u8)data;
data >>= 8;
}
if (i2c_master_send(tc358743_data.i2c_client, au8Buf, i) < 0) {
pr_err("%s:write reg error:reg=%x,val=%x\n",
__func__, reg, val);
return -1;
}
len -= (u8)size;
reg += (u16)size;
}
return 0;
}
static s32 tc358743_read_reg(u16 reg, u32 *val)
{
u8 au8RegBuf[2] = {0};
u32 u32RdVal = 0;
int i=0;
int size = 0;
while (0 != <API key>[i].startaddr ||
0 != <API key>[i].endaddr ||
0 != <API key>[i].size) {
if (<API key>[i].startaddr <= reg &&
<API key>[i].endaddr >= reg) {
size = <API key>[i].size;
break;
}
i++;
}
if (!size)
return -1;
au8RegBuf[0] = reg >> 8;
au8RegBuf[1] = reg & 0xff;
if (2 != i2c_master_send(tc358743_data.i2c_client, au8RegBuf, 2)) {
pr_err("%s:read reg error:reg=%x\n",
__func__, reg);
return -1;
}
if (size /*of(u32RdVal)*/ != i2c_master_recv(tc358743_data.i2c_client, (char *)&u32RdVal, size /*of(u32RdVal)*/)) {
pr_err("%s:read reg error:reg=%x,val=%x\n",
__func__, reg, u32RdVal);
return -1;
}
*val = u32RdVal;
return size;
}
static int tc358743_write_edid(u8 *edid, int len)
{
int i = 0, off = 0;
u8 au8Buf[8+2] = {0};
int size = 0;
u16 reg;
reg = 0x8C00;
off = 0;
size = ARRAY_SIZE(au8Buf)-2;
pr_debug("Write EDID: %d (%d)\n", len, size);
while (len > 0) {
i = 0;
au8Buf[i++] = (reg >> 8) & 0xff;
au8Buf[i++] = reg & 0xff;
while (i < ARRAY_SIZE(au8Buf)) {
au8Buf[i++] = edid[off++];
}
if (i2c_master_send(tc358743_data.i2c_client, au8Buf, i) < 0) {
pr_err("%s:write reg error:reg=%x,val=%x\n",
__func__, reg, off);
return -1;
}
len -= (u8)size;
reg += (u16)size;
}
pr_debug("Activate EDID\n");
tc358743_write_reg(0x85c7, 0x01, 1);
tc358743_write_reg(0x85ca, 0x00, 1);
tc358743_write_reg(0x85cb, 0x01, 1);
return 0;
}
static int tc358743_reset(struct sensor_data *sensor)
{
u32 tgt_fps; /* target frames per secound */
enum tc358743_frame_rate frame_rate = tc358743_60_fps;
int ret = -1;
det_work_enable(0);
while (ret) {
tc_standby(1);
mdelay(100);
tc_standby(0);
mdelay(1000);
tgt_fps = sensor->streamcap.timeperframe.denominator /
sensor->streamcap.timeperframe.numerator;
if (tgt_fps == 60)
frame_rate = tc358743_60_fps;
else if (tgt_fps == 30)
frame_rate = tc358743_30_fps;
pr_debug("%s: capture mode: %d extended mode: %d fps: %d\n", __func__,sensor->streamcap.capturemode, sensor->streamcap.extendedmode, tgt_fps);
ret = tc358743_init_mode(frame_rate,
sensor->streamcap.capturemode);
if (ret)
pr_err("%s: Fail to init tc35874! - retry\n", __func__);
}
det_work_enable(1);
return ret;
}
void mipi_csi2_swreset(struct mipi_csi2_info *info);
#include "../../../../mxc/mipi/mxc_mipi_csi2.h"
static int tc358743_init_mode(enum tc358743_frame_rate frame_rate,
enum tc358743_mode mode)
{
struct reg_value *pModeSetting = NULL;
s32 i = 0;
s32 iModeSettingArySize = 0;
register u32 RepeateLines = 0;
register int RepeateTimes = 0;
register u32 Delay_ms = 0;
register u16 RegAddr = 0;
register u32 Mask = 0;
register u32 Val = 0;
u8 Length;
u32 RegVal = 0;
int retval = 0;
void *mipi_csi2_info;
u32 mipi_reg;
u32 mipi_reg_test[10];
pr_debug("%s rate: %d mode: %d\n", __func__, frame_rate, mode);
if ((mode > tc358743_mode_MAX || mode < 0)
&& (mode != tc358743_mode_INIT)) {
pr_debug("%s Wrong tc358743 mode detected! %d. Set mode 0\n", __func__, mode);
mode = 0;
}
mipi_csi2_info = mipi_csi2_get_info();
pr_debug("%s rate: %d mode: %d, info %p\n", __func__, frame_rate, mode, mipi_csi2_info);
/* initial mipi dphy */
tc358743_toggle_hpd(!hpd_active);
if (mipi_csi2_info) {
pr_debug("%s: mipi_csi2_info:\n"
"mipi_en: %d\n"
"ipu_id: %d\n"
"csi_id: %d\n"
"v_channel: %d\n"
"lanes: %d\n"
"datatype: %d\n"
"dphy_clk: %p\n"
"pixel_clk: %p\n"
"mipi_csi2_base:%p\n"
"pdev: %p\n"
, __func__,
((struct mipi_csi2_info *)mipi_csi2_info)->mipi_en,
((struct mipi_csi2_info *)mipi_csi2_info)->ipu_id,
((struct mipi_csi2_info *)mipi_csi2_info)->csi_id,
((struct mipi_csi2_info *)mipi_csi2_info)->v_channel,
((struct mipi_csi2_info *)mipi_csi2_info)->lanes,
((struct mipi_csi2_info *)mipi_csi2_info)->datatype,
((struct mipi_csi2_info *)mipi_csi2_info)->dphy_clk,
((struct mipi_csi2_info *)mipi_csi2_info)->pixel_clk,
((struct mipi_csi2_info *)mipi_csi2_info)->mipi_csi2_base,
((struct mipi_csi2_info *)mipi_csi2_info)->pdev
);
if (!<API key>(mipi_csi2_info))
mipi_csi2_enable(mipi_csi2_info);
if (<API key>(mipi_csi2_info)) {
int ifmt;
if (<API key>[frame_rate][mode].lanes != 0) {
pr_debug("%s Change lanes: from %d to %d\n", __func__, ((struct mipi_csi2_info *)mipi_csi2_info)->lanes, <API key>[frame_rate][mode].lanes);
((struct mipi_csi2_info *)mipi_csi2_info)->lanes = <API key>[frame_rate][mode].lanes;
((struct mipi_csi2_info *)mipi_csi2_info)->lanes = <API key>[frame_rate][mode].lanes;
}
pr_debug("Now Using %d lanes\n",mipi_csi2_set_lanes(mipi_csi2_info));
/*Only reset MIPI CSI2 HW at sensor initialize*/
if (!hdmi_mode) // is this during reset
mipi_csi2_reset(mipi_csi2_info);
pr_debug("%s format: %x\n", __func__, tc358743_data.pix.pixelformat);
for (ifmt = 0; ifmt < ARRAY_SIZE(tc358743_formats); ifmt++)
if (<API key>[frame_rate][mode].flags == tc358743_formats[ifmt].flags) {
tc358743_data.pix.pixelformat = tc358743_formats[ifmt].pixelformat;
pr_debug("%s: %s (%x, %x)\n", __func__, tc358743_formats[ifmt].description, tc358743_data.pix.pixelformat, tc358743_formats[ifmt].flags);
<API key>(mipi_csi2_info, tc358743_formats[ifmt].flags);
break;
}
if (ifmt >= ARRAY_SIZE(tc358743_formats)) {
pr_err("currently this sensor format (0x%x) can not be supported!\n", tc358743_data.pix.pixelformat);
return -1;
}
} else {
pr_err("Can not enable mipi csi2 driver!\n");
return -1;
}
} else {
pr_err("Fail to get mipi_csi2_info!\n");
return -1;
}
{
pModeSetting =
<API key>[frame_rate][mode].init_data_ptr;
iModeSettingArySize =
<API key>[frame_rate][mode].init_data_size;
tc358743_data.pix.width =
<API key>[frame_rate][mode].width;
tc358743_data.pix.height =
<API key>[frame_rate][mode].height;
pr_debug("%s: Set %d regs from %p for frs %d mode %d with width %d height %d\n", __func__,
iModeSettingArySize,
pModeSetting,
frame_rate,
mode,
tc358743_data.pix.width,
tc358743_data.pix.height);
for (i = 0; i < iModeSettingArySize; ++i) {
pModeSetting = <API key>[frame_rate][mode].init_data_ptr + i;
Delay_ms = pModeSetting->u32Delay_ms & (0xffff);
RegAddr = pModeSetting->u16RegAddr;
Val = pModeSetting->u32Val;
Mask = pModeSetting->u32Mask;
Length = pModeSetting->u8Length;
if (Mask) {
retval = tc358743_read_reg(RegAddr, &RegVal);
if (retval < 0)
break;
RegVal &= ~(u8)Mask;
Val &= Mask;
Val |= RegVal;
}
retval = tc358743_write_reg(RegAddr, Val, Length);
if (retval < 0)
break;
if (Delay_ms)
msleep(Delay_ms);
if (0 != ((pModeSetting->u32Delay_ms>>16) & (0xff))) {
if (!RepeateTimes) {
RepeateTimes = (pModeSetting->u32Delay_ms>>16) & (0xff);
RepeateLines = (pModeSetting->u32Delay_ms>>24) & (0xff);
}
if (--RepeateTimes > 0) {
i -= RepeateLines;
}
}
}
if (retval < 0) {
pr_err("%s: Fail to write REGS to tc35874!\n", __func__);
goto err;
}
}
if (!hdmi_mode) // is this during reset
if ((retval = tc358743_write_edid(cHDMIEDID, ARRAY_SIZE(cHDMIEDID))))
pr_err("%s: Fail to write EDID to tc35874!\n", __func__);
tc358743_toggle_hpd(hpd_active);
if (mipi_csi2_info) {
unsigned int i = 0;
/* wait for mipi sensor ready */
mipi_reg = <API key>(mipi_csi2_info);
while ((mipi_reg == 0x200) && (i < 10)) {
mipi_reg_test[i] = mipi_reg;
mipi_reg = <API key>(mipi_csi2_info);
i++;
msleep(10);
}
if (i >= 10) {
pr_err("mipi csi2 can not receive sensor clk!\n");
return -1;
}
{
int j;
for (j = 0; j < i; j++)
{
pr_debug("%d mipi csi2 dphy status %x\n", j, mipi_reg_test[j]);
}
}
i = 0;
/* wait for mipi stable */
mipi_reg = <API key>(mipi_csi2_info);
while ((mipi_reg != 0x0) && (i < 10)) {
mipi_reg_test[i] = mipi_reg;
mipi_reg = <API key>(mipi_csi2_info);
i++;
msleep(10);
}
if (i >= 10) {
pr_err("mipi csi2 can not reveive data correctly!\n");
return -1;
}
{
int j;
for (j = 0; j < i; j++) {
pr_debug("%d mipi csi2 err1 %x\n", j, mipi_reg_test[j]);
}
}
}
err:
return (retval>0)?0:retval;
}
static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
{
pr_debug("%s\n", __func__);
if (s == NULL) {
pr_err(" ERROR!! no slave device set!\n");
return -1;
}
memset(p, 0, sizeof(*p));
p->u.bt656.clock_curr = TC358743_XCLK_MIN; //tc358743_data.mclk;
pr_debug("%s: clock_curr=mclk=%d\n", __func__, tc358743_data.mclk);
p->if_type = V4L2_IF_TYPE_BT656;
p->u.bt656.mode = <API key>;
p->u.bt656.clock_min = TC358743_XCLK_MIN;
p->u.bt656.clock_max = TC358743_XCLK_MAX;
p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */
return 0;
}
/*!
* ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl
* @s: pointer to standard V4L2 device structure
* @on: indicates power mode (on or off)
*
* Turns the power on or off, depending on the value of on and returns the
* appropriate error code.
*/
static int ioctl_s_power(struct v4l2_int_device *s, int on)
{
struct sensor_data *sensor = s->priv;
pr_debug("%s: %d\n", __func__, on);
if (on && !sensor->on) {
if (io_regulator)
if (regulator_enable(io_regulator) != 0)
return -EIO;
if (core_regulator)
if (regulator_enable(core_regulator) != 0)
return -EIO;
if (gpo_regulator)
if (regulator_enable(gpo_regulator) != 0)
return -EIO;
if (analog_regulator)
if (regulator_enable(analog_regulator) != 0)
return -EIO;
/* Make sure power on */
tc_standby(0);
} else if (!on && sensor->on) {
if (analog_regulator)
regulator_disable(analog_regulator);
if (core_regulator)
regulator_disable(core_regulator);
if (io_regulator)
regulator_disable(io_regulator);
if (gpo_regulator)
regulator_disable(gpo_regulator);
if (!hdmi_mode)
tc358743_reset(sensor);
}
sensor->on = on;
return 0;
}
/*!
* ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl
* @s: pointer to standard V4L2 device structure
* @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
*
* Returns the sensor's video CAPTURE parameters.
*/
static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
{
struct sensor_data *sensor = s->priv;
struct v4l2_captureparm *cparm = &a->parm.capture;
int ret = 0;
pr_debug("%s type: %x\n", __func__, a->type);
switch (a->type) {
/* This is the only case currently handled. */
case <API key>:
memset(a, 0, sizeof(*a));
a->type = <API key>;
cparm->capability = sensor->streamcap.capability;
cparm->timeperframe = sensor->streamcap.timeperframe;
cparm->capturemode = sensor->streamcap.capturemode;
cparm->extendedmode = sensor->streamcap.extendedmode;
ret = 0;
break;
/* These are all the possible cases. */
case <API key>:
case <API key>:
case <API key>:
case <API key>:
case <API key>:
case <API key>:
ret = -EINVAL;
break;
default:
pr_debug(" type is unknown - %d\n", a->type);
ret = -EINVAL;
break;
}
det_work_enable(1);
pr_debug("%s done %d\n", __func__, ret);
return ret;
}
static int tc358743_toggle_hpd(int active)
{
int ret = 0;
if (active) {
ret += tc358743_write_reg(0x8544, 0x00, 1);
mdelay(500);
ret += tc358743_write_reg(0x8544, 0x10, 1);
} else {
ret += tc358743_write_reg(0x8544, 0x10, 1);
mdelay(500);
ret += tc358743_write_reg(0x8544, 0x00, 1);
}
return ret;
}
/*!
* ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl
* @s: pointer to standard V4L2 device structure
* @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
*
* Configures the sensor to use the input parameters, if possible. If
* not possible, reverts to the old parameters and returns the
* appropriate error code.
*/
static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
{
struct sensor_data *sensor = s->priv;
struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe;
u32 tgt_fps; /* target frames per secound */
enum tc358743_frame_rate frame_rate = tc358743_60_fps, frame_rate_now = tc358743_60_fps;
int ret = 0;
pr_debug("%s\n", __func__);
det_work_enable(0);
/* Make sure power on */
tc_standby(0);
switch (a->type) {
/* This is the only case currently handled. */
case <API key>:
/* Check that the new frame rate is allowed. */
if ((timeperframe->numerator == 0) ||
(timeperframe->denominator == 0)) {
timeperframe->denominator = DEFAULT_FPS;
timeperframe->numerator = 1;
}
tgt_fps = timeperframe->denominator /
timeperframe->numerator;
if (tgt_fps > MAX_FPS) {
timeperframe->denominator = MAX_FPS;
timeperframe->numerator = 1;
} else if (tgt_fps < MIN_FPS) {
timeperframe->denominator = MIN_FPS;
timeperframe->numerator = 1;
}
/* Actual frame rate we use */
tgt_fps = timeperframe->denominator /
timeperframe->numerator;
if (tgt_fps == 60)
frame_rate = tc358743_60_fps;
else if (tgt_fps == 30)
frame_rate = tc358743_30_fps;
else {
pr_err(" The camera frame rate is not supported!\n");
ret = -EINVAL;
break;
}
if ((u32)a->parm.capture.capturemode > tc358743_mode_MAX) {
a->parm.capture.capturemode = 0;
pr_debug("%s: Forse extended mode: %d \n", __func__,(u32)a->parm.capture.capturemode);
}
tgt_fps = sensor->streamcap.timeperframe.denominator /
sensor->streamcap.timeperframe.numerator;
if (tgt_fps == 60)
frame_rate_now = tc358743_60_fps;
else if (tgt_fps == 30)
frame_rate_now = tc358743_30_fps;
if (frame_rate_now != frame_rate ||
sensor->streamcap.capturemode != (u32)a->parm.capture.capturemode ||
sensor->streamcap.extendedmode != (u32)a->parm.capture.extendedmode) {
sensor->streamcap.timeperframe = *timeperframe;
sensor->streamcap.capturemode =
(u32)a->parm.capture.capturemode;
sensor->streamcap.extendedmode =
(u32)a->parm.capture.extendedmode;
pr_debug("%s: capture mode: %d extended mode: %d \n", __func__,sensor->streamcap.capturemode, sensor->streamcap.extendedmode);
ret = tc358743_init_mode(frame_rate,
sensor->streamcap.capturemode);
} else {
pr_debug("%s: Keep current settings\n", __func__);
}
break;
/* These are all the possible cases. */
case <API key>:
case <API key>:
case <API key>:
case <API key>:
case <API key>:
case <API key>:
pr_debug(" type is not " \
"<API key> but %d\n",
a->type);
ret = -EINVAL;
break;
default:
pr_debug(" type is unknown - %d\n", a->type);
ret = -EINVAL;
break;
}
if (ret)
det_work_enable(1);
return ret;
}
/*!
* ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl
* @s: pointer to standard V4L2 device structure
* @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
*
* If the requested control is supported, returns the control's current
* value from the video_control[] array. Otherwise, returns -EINVAL
* if the control is not supported.
*/
static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)
{
int ret = 0;
pr_debug("%s\n", __func__);
switch (vc->id) {
case V4L2_CID_BRIGHTNESS:
vc->value = tc358743_data.brightness;
break;
case V4L2_CID_HUE:
vc->value = tc358743_data.hue;
break;
case V4L2_CID_CONTRAST:
vc->value = tc358743_data.contrast;
break;
case V4L2_CID_SATURATION:
vc->value = tc358743_data.saturation;
break;
case <API key>:
vc->value = tc358743_data.red;
break;
case <API key>:
vc->value = tc358743_data.blue;
break;
case V4L2_CID_EXPOSURE:
vc->value = tc358743_data.ae_mode;
break;
default:
ret = -EINVAL;
}
return ret;
}
/*!
* ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl
* @s: pointer to standard V4L2 device structure
* @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
*
* If the requested control is supported, sets the control's current
* value in HW (and updates the video_control[] array). Otherwise,
* returns -EINVAL if the control is not supported.
*/
static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)
{
int retval = 0;
pr_debug("In tc358743:ioctl_s_ctrl %d\n",
vc->id);
switch (vc->id) {
case V4L2_CID_BRIGHTNESS:
break;
case V4L2_CID_CONTRAST:
break;
case V4L2_CID_SATURATION:
break;
case V4L2_CID_HUE:
break;
case <API key>:
break;
case <API key>:
break;
case <API key>:
break;
case <API key>:
break;
case V4L2_CID_GAMMA:
break;
case V4L2_CID_EXPOSURE:
break;
case V4L2_CID_AUTOGAIN:
break;
case V4L2_CID_GAIN:
break;
case V4L2_CID_HFLIP:
break;
case V4L2_CID_VFLIP:
break;
default:
retval = -EPERM;
break;
}
return retval;
}
int get_pixelformat(int index)
{
int ifmt;
for (ifmt = 0; ifmt < ARRAY_SIZE(tc358743_formats); ifmt++)
if (<API key>[0][index].flags == tc358743_formats[ifmt].flags)
break;
if (ifmt == ARRAY_SIZE(tc358743_formats))
ifmt = 0; /* Default = RBG888 */
return ifmt;
}
/*!
* <API key> - V4L2 sensor interface handler for
* <API key> ioctl
* @s: pointer to standard V4L2 device structure
* @fsize: standard V4L2 <API key> ioctl structure
*
* Return 0 if successful, otherwise -EINVAL.
*/
static int <API key>(struct v4l2_int_device *s,
struct v4l2_frmsizeenum *fsize)
{
pr_debug("%s, INDEX: %d\n", __func__,fsize->index);
if (fsize->index > tc358743_mode_MAX)
return -EINVAL;
fsize->pixel_format = tc358743_formats[get_pixelformat(fsize->index)].pixelformat;
fsize->discrete.width =
<API key>[0][fsize->index].width;
fsize->discrete.height =
<API key>[0][fsize->index].height;
pr_debug("%s %d:%d format: %x\n", __func__, fsize->discrete.width, fsize->discrete.height, fsize->pixel_format);
return 0;
}
/*!
* ioctl_g_chip_ident - V4L2 sensor interface handler for
* <API key> ioctl
* @s: pointer to standard V4L2 device structure
* @id: pointer to int
*
* Return 0.
*/
static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id)
{
((struct v4l2_dbg_chip_ident *)id)->match.type =
<API key>;
strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name,
"tc358743_mipi");
return 0;
}
/*!
* ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT
* @s: pointer to standard V4L2 device structure
*/
static int ioctl_init(struct v4l2_int_device *s)
{
pr_debug("%s\n", __func__);
return 0;
}
/*!
* ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT
* @s: pointer to standard V4L2 device structure
* @fmt: pointer to standard V4L2 fmt description structure
*
* Return 0.
*/
static int ioctl_enum_fmt_cap(struct v4l2_int_device *s,
struct v4l2_fmtdesc *fmt)
{
pr_debug("%s\n", __func__);
if (fmt->index > tc358743_mode_MAX)
return -EINVAL;
fmt->pixelformat = tc358743_formats[get_pixelformat(fmt->index)].pixelformat;
pr_debug("%s: format: %x\n", __func__, fmt->pixelformat);
return 0;
}
static int ioctl_try_fmt_cap(struct v4l2_int_device *s,
struct v4l2_format *f)
{
struct sensor_data *sensor = s->priv;
u32 tgt_fps; /* target frames per secound */
enum tc358743_frame_rate frame_rate;
// enum image_size isize;
int ifmt;
struct v4l2_pix_format *pix = &f->fmt.pix;
pr_debug("%s\n", __func__);
tgt_fps = sensor->streamcap.timeperframe.denominator /
sensor->streamcap.timeperframe.numerator;
if (tgt_fps == 60) {
frame_rate = tc358743_60_fps;
} else if (tgt_fps == 30) {
frame_rate = tc358743_30_fps;
} else {
pr_debug("%s: %d fps (%d,%d) is not supported\n", __func__, tgt_fps, sensor->streamcap.timeperframe.denominator,sensor->streamcap.timeperframe.numerator);
return -EINVAL;
}
tc358743_data.pix.width = pix->width = <API key>[frame_rate][sensor->streamcap.capturemode].width;
tc358743_data.pix.height = pix->height = <API key>[frame_rate][sensor->streamcap.capturemode].height;
for (ifmt = 0; ifmt < ARRAY_SIZE(tc358743_formats); ifmt++)
if (<API key>[frame_rate][sensor->streamcap.capturemode].flags == tc358743_formats[ifmt].flags)
break;
if (ifmt == ARRAY_SIZE(tc358743_formats))
ifmt = 0; /* Default = RBG888 */
tc358743_data.pix.pixelformat = pix->pixelformat = tc358743_formats[ifmt].pixelformat;
pix->field = V4L2_FIELD_NONE;
pix->bytesperline = pix->width * 4;
pix->sizeimage = pix->bytesperline * pix->height;
pix->priv = 0;
switch (pix->pixelformat) {
case V4L2_PIX_FMT_UYVY:
default:
pix->colorspace = <API key>;
break;
}
{
u32 u32val;
int ret = tc358743_read_reg(0x8520,&u32val);
pr_debug("SYS_STATUS: 0x%x, ret val: %d \n",u32val,ret);
ret = tc358743_read_reg(0x8521,&u32val);
pr_debug("VI_STATUS0: 0x%x, ret val: %d \n",u32val,ret);
ret = tc358743_read_reg(0x8522,&u32val);
pr_debug("VI_STATUS1: 0x%x, ret val: %d \n",u32val,ret);
ret = tc358743_read_reg(0x8525,&u32val);
pr_debug("VI_STATUS2: 0x%x, ret val: %d \n",u32val,ret);
ret = tc358743_read_reg(0x8528,&u32val);
pr_debug("VI_STATUS3: 0x%x, ret val: %d \n",u32val,ret);
pr_debug("%s %d:%d format: %x\n", __func__, pix->width, pix->height, pix->pixelformat);
}
return 0;
}
/*!
* ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap
* @s: pointer to standard V4L2 device structure
* @f: pointer to standard V4L2 v4l2_format structure
*
* Returns the sensor's current pixel format in the v4l2_format
* parameter.
*/
static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
{
pr_debug("%s\n", __func__);
return ioctl_try_fmt_cap(s, f);
}
/*!
* ioctl_dev_init - V4L2 sensor interface handler for <API key>
* @s: pointer to standard V4L2 device structure
*
* Initialise the device when slave attaches to the master.
*/
static int ioctl_dev_init(struct v4l2_int_device *s)
{
struct sensor_data *sensor = s->priv;
u32 tgt_xclk; /* target xclk */
u32 tgt_fps; /* target frames per secound */
int ret = 0;
enum tc358743_frame_rate frame_rate;
void *mipi_csi2_info;
pr_debug("%s\n", __func__);
tc358743_data.on = true;
/* mclk */
tgt_xclk = tc358743_data.mclk;
tgt_xclk = min(tgt_xclk, (u32)TC358743_XCLK_MAX);
tgt_xclk = max(tgt_xclk, (u32)TC358743_XCLK_MIN);
tc358743_data.mclk = tgt_xclk;
pr_debug("%s: Setting mclk to %d MHz\n", __func__, tc358743_data.mclk / 1000000);
// set_mclk_rate(&tc358743_data.mclk, tc358743_data.mclk_source);
// pr_debug("%s: After mclk to %d MHz\n", __func__, tc358743_data.mclk / 1000000);
/* Default camera frame rate is set in probe */
tgt_fps = sensor->streamcap.timeperframe.denominator /
sensor->streamcap.timeperframe.numerator;
if (tgt_fps == 60)
frame_rate = tc358743_60_fps;
else if (tgt_fps == 30)
frame_rate = tc358743_30_fps;
else
return -EINVAL;
mipi_csi2_info = mipi_csi2_get_info();
/* enable mipi csi2 */
if (mipi_csi2_info) {
mipi_csi2_enable(mipi_csi2_info);
} else {
pr_err("Fail to get mipi_csi2_info!\n");
return -EPERM;
}
pr_debug("%s done\n", __func__);
return ret;
}
/*!
* ioctl_dev_exit - V4L2 sensor interface handler for <API key>
* @s: pointer to standard V4L2 device structure
*
* Delinitialise the device when slave detaches to the master.
*/
static int ioctl_dev_exit(struct v4l2_int_device *s)
{
void *mipi_csi2_info;
mipi_csi2_info = mipi_csi2_get_info();
/* disable mipi csi2 */
if (mipi_csi2_info)
if (<API key>(mipi_csi2_info))
mipi_csi2_disable(mipi_csi2_info);
return 0;
}
/*!
* This structure defines all the ioctls for this module and links them to the
* enumeration.
*/
static struct v4l2_int_ioctl_desc tc358743_ioctl_desc[] = {
{<API key>, (v4l2_int_ioctl_func*) ioctl_dev_init},
{<API key>, ioctl_dev_exit},
{<API key>, (v4l2_int_ioctl_func*) ioctl_s_power},
{<API key>, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
{<API key>,
(v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
{<API key>,
(v4l2_int_ioctl_func *)ioctl_try_fmt_cap},
{<API key>, (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
{<API key>, (v4l2_int_ioctl_func *) ioctl_g_parm},
{<API key>, (v4l2_int_ioctl_func *) ioctl_s_parm},
{<API key>, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
{<API key>, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
{<API key>,
(v4l2_int_ioctl_func *) <API key>},
{<API key>,
(v4l2_int_ioctl_func *) ioctl_g_chip_ident},
};
static struct v4l2_int_slave tc358743_slave = {
.ioctls = tc358743_ioctl_desc,
.num_ioctls = ARRAY_SIZE(tc358743_ioctl_desc),
};
static struct v4l2_int_device tc358743_int_device = {
.module = THIS_MODULE,
.name = "tc358743",
.type = v4l2_int_type_slave,
.u = {
.slave = &tc358743_slave,
},
};
#ifdef AUDIO_ENABLE
struct imx_ssi {
struct platform_device *ac97_dev;
struct snd_soc_dai *imx_ac97;
struct clk *clk;
void __iomem *base;
int irq;
int fiq_enable;
unsigned int offset;
unsigned int flags;
void (*ac97_reset) (struct snd_ac97 *ac97);
void (*ac97_warm_reset)(struct snd_ac97 *ac97);
struct imx_pcm_dma_params dma_params_rx;
struct imx_pcm_dma_params dma_params_tx;
int enabled;
struct platform_device *soc_platform_pdev;
struct platform_device *<API key>;
};
#define SSI_SCR 0x10
#define SSI_SRCR 0x20
#define SSI_STCCR 0x24
#define SSI_SRCCR 0x28
#define <API key> (0 << 5)
#define <API key> (1 << 5)
#define <API key> (2 << 5)
#define SSI_I2S_MODE_MASK (3 << 5)
#define SSI_SCR_SYN (1 << 4)
#define SSI_SRCR_RSHFD (1 << 4)
#define SSI_SRCR_RSCKP (1 << 3)
#define SSI_SRCR_RFSI (1 << 2)
#define SSI_SRCR_REFS (1 << 0)
#define SSI_STCCR_WL(x) ((((x) - 2) >> 1) << 13)
#define SSI_STCCR_WL_MASK (0xf << 13)
#define SSI_SRCCR_WL(x) ((((x) - 2) >> 1) << 13)
#define SSI_SRCCR_WL_MASK (0xf << 13)
/* Audio setup */
static int <API key>(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
<API key> |
<API key>);
if (ret) {
pr_err("%s: failed set cpu dai format\n", __func__);
return ret;
}
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
<API key> |
<API key>);
if (ret) {
pr_err("%s: failed set codec dai format\n", __func__);
return ret;
}
ret = <API key>(codec_dai, 0,
CODEC_CLOCK, SND_SOC_CLOCK_OUT);
if (ret) {
pr_err("%s: failed setting codec sysclk\n", __func__);
return ret;
}
<API key>(cpu_dai, 0xffffffc, 0xffffffc, 2, 0);
ret = <API key>(cpu_dai, IMX_SSP_SYS_CLK, 0,
SND_SOC_CLOCK_IN);
if (ret) {
pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n");
return ret;
}
#if 1
// clear SSI_SRCR_RXBIT0 and SSI_SRCR_RSHFD in order to push Right-justified MSB data fro
{
struct imx_ssi *ssi = <API key>(cpu_dai);
u32 scr = 0, srcr = 0, stccr = 0, srccr = 0;
pr_debug("%s: base %p\n", __func__, (void *)ssi->base);
scr = readl(ssi->base + SSI_SCR);
pr_debug("%s: SSI_SCR before: %p\n", __func__, (void *)scr);
writel(scr, ssi->base + SSI_SCR);
pr_debug("%s: SSI_SCR after: %p\n", __func__, (void *)scr);
srcr = readl(ssi->base + SSI_SRCR);
pr_debug("%s: SSI_SRCR before: %p\n", __func__, (void *)srcr);
writel(srcr, ssi->base + SSI_SRCR);
pr_debug("%s: SSI_SRCR after: %p\n", __func__, (void *)srcr);
stccr = readl(ssi->base + SSI_STCCR);
pr_debug("%s: SSI_STCCR before: %p\n", __func__, (void *)stccr);
stccr &= ~SSI_STCCR_WL_MASK;
stccr |= SSI_STCCR_WL(16);
writel(stccr, ssi->base + SSI_STCCR);
pr_debug("%s: SSI_STCCR after: %p\n", __func__, (void *)stccr);
srccr = readl(ssi->base + SSI_SRCCR);
pr_debug("%s: SSI_SRCCR before: %p\n", __func__, (void *)srccr);
srccr &= ~SSI_SRCCR_WL_MASK;
srccr |= SSI_SRCCR_WL(16);
writel(srccr, ssi->base + SSI_SRCCR);
pr_debug("%s: SSI_SRCCR after: %p\n", __func__, (void *)srccr);
}
#endif
return 0;
}
/* Headphones jack detection DAPM pins */
static struct snd_soc_jack_pin hs_jack_pins_a[] = {
};
/* imx_3stack card dapm widgets */
static struct snd_soc_dapm_widget <API key>[] = {
};
static struct snd_kcontrol_new <API key>[] = {
};
/* imx_3stack machine connections to the codec pins */
static struct snd_soc_dapm_route audio_map_a[] = {
};
static int <API key>(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
int ret;
struct snd_soc_jack *hs_jack;
struct snd_soc_jack_pin *hs_jack_pins;
int hs_jack_pins_size;
struct snd_soc_dapm_widget *<API key>;
int <API key>;
struct snd_kcontrol_new *<API key>;
int <API key>;
struct snd_soc_dapm_route *audio_map;
int audio_map_size;
int gpio_num = -1;
char *gpio_name;
pr_debug("%s started\n", __func__);
hs_jack_pins = hs_jack_pins_a;
hs_jack_pins_size = ARRAY_SIZE(hs_jack_pins_a);
<API key> = <API key>;
<API key> = ARRAY_SIZE(<API key>);
<API key> = <API key>;
<API key> = ARRAY_SIZE(<API key>);
audio_map = audio_map_a;
audio_map_size = ARRAY_SIZE(audio_map_a);
gpio_num = -1; //card_a_gpio_num;
gpio_name = NULL;
ret = <API key>(codec, <API key>,
<API key>);
if (ret) {
pr_err("%s: <API key> failed. err = %d\n", __func__, ret);
return ret;
}
/* Add imx_3stack specific widgets */
<API key>(&codec->dapm, <API key>,
<API key>);
/* Set up imx_3stack specific audio path audio_map */
<API key>(&codec->dapm, audio_map, audio_map_size);
<API key>(&codec->dapm, hs_jack_pins->pin);
snd_soc_dapm_sync(&codec->dapm);
hs_jack = kzalloc(sizeof(struct snd_soc_jack), GFP_KERNEL);
ret = snd_soc_jack_new(codec, hs_jack_pins->pin,
SND_JACK_HEADPHONE, hs_jack);
if (ret) {
pr_err("%s: snd_soc_jack_new failed. err = %d\n", __func__, ret);
return ret;
}
ret = <API key>(hs_jack,hs_jack_pins_size,
hs_jack_pins);
if (ret) {
pr_err("%s: <API key>. err = %d\n", __func__, ret);
return ret;
}
return 0;
}
static struct snd_soc_ops <API key> = {
.hw_params = <API key>,
};
static struct snd_soc_dai_link imxpac_tc358743_dai = {
.name = "tc358743",
.stream_name = "TC358743",
.codec_dai_name = "tc358743-hifi",
.platform_name = "imx-pcm-audio.2",
.codec_name = "tc358743_mipi.1-000f",
.cpu_dai_name = "imx-ssi.2",
.init = <API key>,
.ops = &<API key>,
};
static struct snd_soc_card imxpac_tc358743 = {
.name = "<API key>",
.dai_link = &imxpac_tc358743_dai,
.num_links = 1,
};
static struct platform_device *<API key>;
static struct platform_device *<API key>;
static int imx_audmux_config(int slave, int master)
{
unsigned int ptcr, pdcr;
slave = slave - 1;
master = master - 1;
/* SSI0 mastered by port 5 */
ptcr = <API key> |
<API key> |
<API key>(master | 0x8) |
<API key> |
<API key> |
<API key>(master | 0x8) |
<API key> |
<API key>(master | 0x8) |
<API key>(master | 0x8);
pdcr = <API key>(master);
<API key>(slave, ptcr, pdcr);
ptcr = <API key>;
pdcr = <API key>(master);
<API key>(master, ptcr, pdcr);
return 0;
}
static int __devinit imx_tc358743_probe(struct platform_device *pdev)
{
struct <API key> *plat = pdev->dev.platform_data;
int ret = 0;
imx_audmux_config(plat->src_port, plat->ext_port);
ret = -EINVAL;
if (plat->init && plat->init())
return ret;
printk("%s %d %s\n",__func__,__LINE__,pdev->name);
return 0;
}
static int imx_tc358743_remove(struct platform_device *pdev)
{
struct <API key> *plat = pdev->dev.platform_data;
if (plat->finit)
plat->finit();
return 0;
}
static struct platform_driver <API key> = {
.probe = imx_tc358743_probe,
.remove = imx_tc358743_remove,
.driver = {
.name = "imx-tc358743",
},
};
/* Codec setup */
static int <API key>(struct snd_soc_codec *codec)
{
return 0;
}
static int <API key>(struct snd_soc_codec *codec)
{
return 0;
}
static int <API key>(struct snd_soc_codec *codec, pm_message_t state)
{
// <API key>(codec, SND_SOC_BIAS_OFF);
return 0;
}
static int <API key>(struct snd_soc_codec *codec)
{
// <API key>(codec, <API key>);
return 0;
}
static int <API key>(struct snd_soc_codec *codec,
enum snd_soc_bias_level level)
{
return 0;
}
static const u8 tc358743_reg[0] = {
};
static struct <API key> <API key> = {
.set_bias_level = <API key>,
.reg_cache_size = ARRAY_SIZE(tc358743_reg),
.reg_word_size = sizeof(u8),
.reg_cache_default = tc358743_reg,
.probe = <API key>,
.remove = <API key>,
.suspend = <API key>,
.resume = <API key>,
};
#define AIC3X_RATES <API key>
#define AIC3X_FORMATS (<API key> | <API key> | \
<API key>)
static int tc358743_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
return 0;
}
static int tc358743_mute(struct snd_soc_dai *dai, int mute)
{
return 0;
}
static int <API key>(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
return 0;
}
static int <API key>(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
return 0;
}
static struct snd_soc_dai_ops tc358743_dai_ops = {
.hw_params = tc358743_hw_params,
.digital_mute = tc358743_mute,
.set_sysclk = <API key>,
.set_fmt = <API key>,
};
static struct snd_soc_dai_driver tc358743_dai = {
.name = "tc358743-hifi",
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 2,
.rates = AIC3X_RATES,
.formats = AIC3X_FORMATS,},
.ops = &tc358743_dai_ops,
.symmetric_rates = 1,
};
#endif
static char tc358743_mode_list[16][12] =
{
"None",
"VGA",
"240p/480i",
"288p/576i",
"W240p/480i",
"W288p/576i",
"480p",
"576p",
"W480p",
"W576p",
"WW480p",
"WW576p",
"720p",
"1035i",
"1080i",
"1080p"
};
static char tc358743_fps_list[tc358743_max_fps+1] =
{
[tc358743_60_fps] = 60,
[tc358743_30_fps] = 30,
[tc358743_max_fps] = 0
};
static int tc358743_audio_list[16] =
{
44100,
0,
48000,
32000,
22050,
384000,
24000,
352800,
88200,
768000,
96000,
705600,
176400,
0,
192000,
0
};
static char str_on[80];
static void report_netlink(void)
{
char *envp[2];
envp[0] = &str_on[0];
envp[1] = NULL;
sprintf(envp[0], "HDMI RX: %d (%s) %d %d", (unsigned char)hdmi_mode & 0xf, tc358743_mode_list[(unsigned char)hdmi_mode & 0xf], tc358743_fps_list[fps], tc358743_audio_list[audio]);
kobject_uevent_env(&(tc358743_data.i2c_client->dev.kobj), KOBJ_CHANGE, envp);
det_work_timeout = <API key>;
pr_debug("%s: HDMI RX (%d) mode: %s fps: %d (%d, %d) audio: %d\n", __func__, (unsigned char)hdmi_mode, tc358743_mode_list[(unsigned char)hdmi_mode & 0xf], fps, bounce, det_work_timeout, tc358743_audio_list[audio]);
}
static void det_worker(struct work_struct *work)
{
u32 u32val;
u16 reg;
int ret;
mutex_lock(&access_lock);
if (!det_work_disable) {
reg = 0x8621;
ret = tc358743_read_reg(reg, &u32val);
if (ret > 0) {
if (audio != (((unsigned char)u32val) & 0x0f)) {
audio = ((unsigned char)u32val) & 0x0f;
report_netlink();
}
}
reg = 0x852f;
ret = tc358743_read_reg(reg, &u32val);
if (ret > 0) {
while (1) {
if (u32val & <API key>) {
lock = u32val & <API key>;
reg = 0x8521;
ret = tc358743_read_reg(reg, &u32val);
if (ret < 0) {
pr_err("%s: Error reading mode\n", __func__);
}
} else {
if (lock) { // check if it is realy un-plug
lock = 0;
u32val = 0x0;
hdmi_mode = 0xF0; // fake mode to detect un-plug if mode was not detected before.
}
}
if ((unsigned char)hdmi_mode != (unsigned char)u32val) {
if (u32val)
det_work_timeout = <API key>;
else
det_work_timeout = <API key>;
bounce = MAX_BOUNCE;
pr_debug("%s: HDMI RX (%d != %d) mode: %s fps: %d (%d, %d)\n", __func__, (unsigned char)hdmi_mode, (unsigned char)u32val, tc358743_mode_list[(unsigned char)hdmi_mode & 0xf], fps, bounce, det_work_timeout);
hdmi_mode = u32val;
} else if (bounce) {
bounce
det_work_timeout = <API key>;
}
if (1 == bounce) {
if (hdmi_mode >= 0xe) {
reg = 0x852f;
ret = tc358743_read_reg(reg, &u32val);
if (ret > 0)
fps = ((((unsigned char)u32val) & 0x0f) > 0xa)? tc358743_60_fps: tc358743_30_fps;
}
reg = 0x8621;
ret = tc358743_read_reg(reg, &u32val);
if (ret > 0) {
audio = ((unsigned char)u32val) & 0x0f;
report_netlink();
}
}
break;
}
} else {
pr_err("%s: Error reading lock\n", __func__);
}
} else {
det_work_timeout = <API key>;
}
mutex_unlock(&access_lock);
<API key>(&(det_work), msecs_to_jiffies(det_work_timeout));
}
static irqreturn_t <API key>(int irq, void *data)
{
pr_debug("%s: IRQ %d\n", __func__, tc358743_data.i2c_client->irq);
<API key>(&(det_work), msecs_to_jiffies(det_work_timeout));
return IRQ_HANDLED;
}
/*!
* tc358743 I2C probe function
*
* @param adapter struct i2c_adapter *
* @return Error code indicating success or failure
*/
#define DUMP_LENGTH 256
static u16 regoffs = 0;
static ssize_t <API key>(struct device *dev,
struct device_attribute *attr, char *buf)
{
int i, len = 0;
int retval;
u32 u32val;
mutex_lock(&access_lock);
for (i=0; i<DUMP_LENGTH; ) {
retval = tc358743_read_reg(regoffs+i, &u32val);
if (retval < 0) {
u32val =0xff;
retval = 1;
}
while (retval
if (0 == (i & 0xf))
len += sprintf(buf+len, "\n%04X:", regoffs+i);
len += sprintf(buf+len, " %02X", u32val&0xff);
u32val >>= 8;
i++;
}
}
mutex_unlock(&access_lock);
len += sprintf(buf+len, "\n");
return len;
}
static DEVICE_ATTR(regdump, S_IRUGO, <API key>, NULL);
static ssize_t <API key>(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
u32 val;
int retval;
retval = sscanf(buf, "%x", &val);
if (1 == retval)
regoffs = (u16)val;
return count;
}
static ssize_t <API key>(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += sprintf(buf+len, "0x%04X\n", regoffs);
return len;
}
static DEVICE_ATTR(regoffs, S_IRUGO|S_IWUSR, <API key>, <API key>);
static ssize_t tc358743_store_hpd(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
u32 val;
int retval;
retval = sscanf(buf, "%d", &val);
if (1 == retval)
hpd_active = (u16)val;
return count;
}
static ssize_t tc358743_show_hpd(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += sprintf(buf+len, "%d\n", hpd_active);
return len;
}
static DEVICE_ATTR(hpd, S_IRUGO|S_IWUSR, tc358743_show_hpd, tc358743_store_hpd);
static ssize_t <API key>(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += sprintf(buf+len, "%d\n", hdmi_mode);
return len;
}
static DEVICE_ATTR(hdmirx, S_IRUGO, <API key>, NULL);
static ssize_t tc358743_show_fps(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += sprintf(buf+len, "%d\n", tc358743_fps_list[fps]);
return len;
}
static DEVICE_ATTR(fps, S_IRUGO, tc358743_show_fps, NULL);
#ifdef AUDIO_ENABLE
static ssize_t tc358743_show_audio(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += sprintf(buf+len, "%d\n", tc358743_audio_list[audio]);
return len;
}
static DEVICE_ATTR(audio, S_IRUGO, tc358743_show_audio, NULL);
#endif
static int tc358743_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct pwm_device *pwm;
struct device *dev = &client->dev;
int retval;
struct regmap *gpr;
struct sensor_data *sensor = &tc358743_data;
u32 u32val;
/* request power down pin */
pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0);
if (!gpio_is_valid(pwn_gpio)) {
dev_warn(dev, "no sensor pwdn pin available");
} else {
retval = <API key>(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH,
"tc_mipi_pwdn");
if (retval < 0) {
dev_warn(dev, "request of pwn_gpio failed");
return retval;
}
}
/* request reset pin */
rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0);
if (!gpio_is_valid(rst_gpio)) {
dev_warn(dev, "no sensor reset pin available");
return -EINVAL;
}
retval = <API key>(dev, rst_gpio, GPIOF_OUT_INIT_HIGH,
"tc_mipi_reset");
if (retval < 0) {
dev_warn(dev, "request of tc_mipi_reset failed");
return retval;
}
/* Set initial values for the sensor struct. */
memset(sensor, 0, sizeof(*sensor));
sensor->sensor_clk = devm_clk_get(dev, "csi_mclk");
if (IS_ERR(sensor->sensor_clk)) {
/* assuming clock enabled by default */
sensor->sensor_clk = NULL;
dev_err(dev, "clock-frequency missing or invalid\n");
return PTR_ERR(sensor->sensor_clk);
}
retval = <API key>(dev->of_node, "mclk",
&(sensor->mclk));
if (retval) {
dev_err(dev, "mclk missing or invalid\n");
return retval;
}
retval = <API key>(dev->of_node, "mclk_source",
(u32 *) &(sensor->mclk_source));
if (retval) {
dev_err(dev, "mclk_source missing or invalid\n");
return retval;
}
retval = <API key>(dev->of_node, "ipu_id",
&sensor->ipu_id);
if (retval) {
dev_err(dev, "ipu_id missing or invalid\n");
return retval;
}
retval = <API key>(dev->of_node, "csi_id",
&(sensor->csi));
if (retval) {
dev_err(dev, "csi id missing or invalid\n");
return retval;
}
if (((unsigned)sensor->ipu_id > 1) || ((unsigned)sensor->csi > 1)) {
dev_err(dev, "invalid ipu/csi\n");
return -EINVAL;
}
clk_prepare_enable(sensor->sensor_clk);
sensor->io_init = tc_reset;
sensor->i2c_client = client;
sensor->pix.pixelformat = tc358743_formats[0].pixelformat;
sensor->streamcap.capability = <API key> |
<API key>;
sensor->streamcap.capturemode = 0;
sensor->streamcap.extendedmode = <API key>;
sensor->streamcap.timeperframe.denominator = DEFAULT_FPS;
sensor->streamcap.timeperframe.numerator = 1;
sensor->pix.width = <API key>[0][sensor->streamcap.capturemode].width;
sensor->pix.height = <API key>[0][sensor->streamcap.capturemode].height;
pr_debug("%s: format: %x, capture mode: %d extended mode: %d fps: %d width: %d height: %d\n",__func__,
sensor->pix.pixelformat,
sensor->streamcap.capturemode, sensor->streamcap.extendedmode,
sensor->streamcap.timeperframe.denominator *
sensor->streamcap.timeperframe.numerator,
sensor->pix.width,
sensor->pix.height);
pwm = pwm_get(dev, NULL);
if (!IS_ERR(pwm)) {
dev_info(dev, "found pwm%d, period=%d\n", pwm->pwm, pwm->period);
pwm_config(pwm, pwm->period >> 1, pwm->period);
pwm_enable(pwm);
}
tc_power_on(dev);
tc_reset();
tc_standby(0);
retval = tc358743_read_reg(<API key>, &u32val);
if (retval < 0) {
pr_err("%s:cannot find camera\n", __func__);
retval = -ENODEV;
goto err4;
}
gpr = <API key>("fsl,imx6q-iomuxc-gpr");
if (!IS_ERR(gpr)) {
if (<API key>("fsl,imx6q")) {
if (sensor->csi == sensor->ipu_id) {
int mask = sensor->csi ? (1 << 20) : (1 << 19);
regmap_update_bits(gpr, IOMUXC_GPR1, mask, 0);
}
} else if (<API key>("fsl,imx6dl")) {
int mask = sensor->csi ? (7 << 3) : (7 << 0);
int val = sensor->csi ? (3 << 3) : (0 << 0);
if (sensor->ipu_id) {
dev_err(dev, "invalid ipu\n");
return -EINVAL;
}
regmap_update_bits(gpr, IOMUXC_GPR13, mask, val);
}
} else {
pr_err("%s: failed to find fsl,imx6q-iomux-gpr regmap\n",
__func__);
}
tc358743_int_device.priv = sensor;
//retval = device_create_file(&client->dev, &dev_attr_audio);
retval = device_create_file(&client->dev, &dev_attr_fps);
retval = device_create_file(&client->dev, &dev_attr_hdmirx);
retval = device_create_file(&client->dev, &dev_attr_hpd);
retval = device_create_file(&client->dev, &dev_attr_regoffs);
retval = device_create_file(&client->dev, &dev_attr_regdump);
if (retval) {
pr_err("%s: create bin file failed, error=%d\n",
__func__, retval);
goto err4;
}
#ifdef AUDIO_ENABLE
/* Audio setup */
retval = <API key>(&client->dev,
&<API key>, &tc358743_dai, 1);
if (retval) {
pr_err("%s: register failed, error=%d\n",
__func__, retval);
goto err4;
}
retval = <API key>(&<API key>);
if (retval) {
pr_err("%s: Platform driver register failed, error=%d\n",
__func__, retval);
goto err4;
}
<API key> = <API key>("soc-audio", 5);
if (!<API key>) {
pr_err("%s: Platform device allocation failed, error=%d\n",
__func__, retval);
goto err4;
}
<API key>(<API key>, &imxpac_tc358743);
retval = platform_device_add(<API key>);
if (retval) {
pr_err("%s: Platform device add failed, error=%d\n",
__func__, retval);
platform_device_put(<API key>);
goto err4;
}
#endif
#if 1
INIT_DELAYED_WORK(&(det_work), det_worker);
if (sensor->i2c_client->irq) {
retval = request_irq(sensor->i2c_client->irq, <API key>,
IRQF_SHARED | <API key>,
"tc358743_det", sensor);
if (retval < 0)
dev_warn(&sensor->i2c_client->dev,
"cound not request det irq %d\n",
sensor->i2c_client->irq);
}
<API key>(&(det_work), msecs_to_jiffies(det_work_timeout));
#endif
retval = tc358743_reset(sensor);
tc_standby(1);
retval = <API key>(&tc358743_int_device);
if (retval) {
pr_err("%s: <API key> failed, error=%d\n",
__func__, retval);
goto err4;
}
pr_debug("%s: finished, error=%d\n",
__func__, retval);
return retval;
err4:
pr_err("%s: failed, error=%d\n",
__func__, retval);
return retval;
}
/*!
* tc358743 I2C detach function
*
* @param client struct i2c_client *
* @return Error code indicating success or failure
*/
static int tc358743_remove(struct i2c_client *client)
{
// Stop delayed work
<API key>(&(det_work));
// Remove IRQ
if (tc358743_data.i2c_client->irq) {
free_irq(tc358743_data.i2c_client->irq, &tc358743_data);
}
/*Remove sysfs entries*/
device_remove_file(&client->dev, &dev_attr_fps);
device_remove_file(&client->dev, &dev_attr_hdmirx);
device_remove_file(&client->dev, &dev_attr_hpd);
device_remove_file(&client->dev, &dev_attr_regoffs);
device_remove_file(&client->dev, &dev_attr_regdump);
<API key>(&tc358743_int_device);
if (gpo_regulator) {
regulator_disable(gpo_regulator);
regulator_put(gpo_regulator);
}
if (analog_regulator) {
regulator_disable(analog_regulator);
regulator_put(analog_regulator);
}
if (core_regulator) {
regulator_disable(core_regulator);
regulator_put(core_regulator);
}
if (io_regulator) {
regulator_disable(io_regulator);
regulator_put(io_regulator);
}
return 0;
}
/*!
* tc358743 init function
* Called by insmod tc358743_camera.ko.
*
* @return Error code indicating success or failure
*/
static __init int tc358743_init(void)
{
int err;
err = i2c_add_driver(&tc358743_i2c_driver);
if (err != 0)
pr_err("%s:driver registration failed, error=%d\n",
__func__, err);
return err;
}
/*!
* tc358743 cleanup function
* Called on rmmod tc358743_camera.ko
*
* @return Error code indicating success or failure
*/
static void __exit tc358743_clean(void)
{
i2c_del_driver(&tc358743_i2c_driver);
}
module_init(tc358743_init);
module_exit(tc358743_clean);
MODULE_AUTHOR("Panasonic Avionics Corp.");
MODULE_DESCRIPTION("Toshiba TC358743 HDMI-to-CSI2 Bridge MIPI Input Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
MODULE_ALIAS("CSI");
|
<?php
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
exit("Do not access this file directly.");
if (!class_exists ("<API key>"))
{
/**
* AliPay IPN Handler.
*
* @package s2Member\AliPay
* @since 1.5
*/
class <API key>
{
/**
* Handles AliPay IPN URL processing.
*
* @package s2Member\AliPay
* @since 1.5
*
* @attaches-to ``add_action("init");``
*
* @return null|inner Return-value of inner routine.
*/
public static function alipay_notify ()
{
if (!empty($_POST["notify_type"]) && preg_match ("/^trade_status_sync$/i", $_POST["notify_type"]))
{
return <API key>::alipay_notify ();
}
}
}
}
?>
|
<?php
class WPForms_Preview {
/**
* Primary class constructor.
*
* @since 1.1.5
*/
public function __construct() {
// Maybe load a preview page
add_action( 'init', array( $this, 'init' ) );
// Hide preview page from admin
add_action( 'pre_get_posts', array( $this, 'form_preview_hide' ) );
}
/**
* Determing if the user should see a preview page, if so, party on.
*
* @since 1.1.5
*/
public function init() {
// Check for preview param with allowed values
if ( empty( $_GET['wpforms_preview'] ) || !in_array( $_GET['wpforms_preview'], array( 'print', 'form' ) ) ) {
return;
}
// Check for authenticated user with correct capabilities
if ( !is_user_logged_in() || !current_user_can( apply_filters( 'wpforms_manage_cap', 'manage_options' ) ) ) {
return;
}
// Print preview
if ( 'print' == $_GET['wpforms_preview'] && !empty( $_GET['entry_id'] ) ) {
$this->print_preview();
}
// Form preview
if ( 'form' == $_GET['wpforms_preview'] && !empty( $_GET['form_id'] ) ) {
$this->form_preview();
}
}
/**
* Print Preview.
*
* @since 1.1.5
*/
public function print_preview() {
// Load entry details
$entry = wpforms()->entry->get( absint( $_GET['entry_id'] ) );
// Double check that we found a real entry
if ( ! $entry || empty( $entry ) ) {
return;
}
// Get form details
$form_data = wpforms()->form->get( $entry->form_id, array( 'content_only' => true ) );
// Double check that we found a valid entry
if ( ! $form_data || empty( $form_data ) ) {
return;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>WPForms Print Preview - <?php echo ucfirst( sanitize_text_field( $form_data['settings']['form_title'] ) ); ?> </title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex,nofollow,noarchive">
<link rel="stylesheet" href="<?php echo includes_url('css/buttons.min.css'); ?>" type="text/css">
<link rel="stylesheet" href="<?php echo WPFORMS_PLUGIN_URL; ?>assets/css/wpforms-preview.css" type="text/css">
<script type="text/javascript" src="<?php echo includes_url('js/jquery/jquery.js'); ?>"></script>
<script type="text/javascript" src="<?php echo WPFORMS_PLUGIN_URL; ?>assets/js/wpforms-preview.js"></script>
</head>
<body class="wp-core-ui">
<div class="wpforms-preview" id="print">
<h1>
<?php echo sanitize_text_field( $form_data['settings']['form_title'] ); ?> <span> - <?php printf( __( 'Entry #%d', 'wpforms' ), absint( $entry->entry_id ) ); ?></span>
<div class="buttons">
<a href="" class="button button-secondary close-window">Close</a>
<a href="" class="button button-primary print">Print</a>
</div>
</h1>
<?php
$fields = apply_filters( '<API key>', wpforms_decode( $entry->fields ), $entry, $form_data );
if ( empty( $fields ) ) {
// Whoops, no fields! This shouldn't happen under normal use cases.
echo '<p class="no-fields">' . __( 'This entry does not have any fields', 'wpforms' ) . '</p>';
} else {
echo '<div class="fields">';
// Display the fields and their values
foreach ( $fields as $key => $field ) {
$field_value = apply_filters( '<API key>', wp_strip_all_tags( $field['value'] ), $field, $form_data );
$field_class = sanitize_html_class( 'wpforms-field-' . $field['type'] );
$field_class .= empty( $field_value ) ? ' empty' : '';
echo '<div class="wpforms-entry-field ' . $field_class . '">';
// Field name
echo '<p class="<API key>">';
echo !empty( $field['name'] ) ? wp_strip_all_tags( $field['name'] ) : sprintf( __( 'Field ID #%d', 'wpforms' ), absint( $field['id'] ) );
echo '</p>';
// Field value
echo '<p class="<API key>">';
echo !empty( $field_value ) ? nl2br( make_clickable( $field_value ) ) : __( 'Empty', 'wpforms' );
echo '</p>';
echo '</div>';
}
echo '</div>';
}
?>
</div><!-- .wrap -->
<p class="site"><a href="<?php echo home_url(); ?>"><?php echo get_bloginfo( 'name'); ?></a></p>
</body>
<?php
exit();
}
/**
* Check if preview page exists, if not create it.
*
* @since 1.1.9
*/
public function form_preview_check() {
if ( !is_admin() )
return;
// Verify page exits
$preview = get_option( '<API key>' );
if ( $preview ) {
$preview_page = get_post( $preview );
// Check to see if the visibility has been changed, if so correct it
if ( !empty( $preview_page ) && 'private' != $preview_page->post_status ) {
$preview_page->post_status = 'private';
wp_update_post( $preview_page );
return;
} elseif ( !empty( $preview_page ) ) {
return;
}
}
// Create the custom preview page
$content = '<p>' . __( 'This is the WPForms preview page. All your form previews will be handled on this page.', 'wpforms' ) . '</p>';
$content .= '<p>' . __( 'The page is set to private, so it is not publically accessible. Please do not delete this page :) .', 'wpforms' ) . '</p>';
$args = array(
'post_type' => 'page',
'post_name' => 'wpforms-preview',
'post_author' => 1,
'post_title' => __( 'WPForms Preview', 'wpforms' ),
'post_status' => 'private',
'post_content' => $content,
'comment_status' => 'closed'
);
$id = wp_insert_post( $args );
if ( $id ) {
update_option( '<API key>', $id );
}
}
/**
* Preview page URL.
*
* @since 1.1.9
* @param int $form_id
* @return string
*/
public function form_preview_url( $form_id ) {
$id = get_option( '<API key>' );
if ( ! $id ) {
return home_url();
}
$url = get_permalink( $id );
if ( ! $url ) {
return home_url();
}
return add_query_arg( array( 'wpforms_preview' => 'form', 'form_id' => absint( $form_id ) ), $url );
}
/**
* Fires when form preview might be detected.
*
* @since 1.1.9
*/
public function form_preview() {
add_filter( 'the_posts', array( $this, 'form_preview_query' ), 10, 2 );
}
/**
* Tweak the page content for form preview page requests.
*
* @since 1.1.9
* @param array $posts
* @param object $query
* @return array
*/
public function form_preview_query( $posts, $query ) {
// One last cap check, just for fun.
if ( !is_user_logged_in() || !current_user_can( apply_filters( 'wpforms_manage_cap', 'manage_options' ) ) ) {
return $posts;
}
// Only target main query
if ( ! $query->is_main_query() ) {
return $posts;
}
// If our queried object ID does not match the preview page ID, return early.
$preview_id = absint( get_option( '<API key>' ) );
$queried = $query-><API key>();
if ( $queried && $queried != $preview_id && isset( $query->query_vars['page_id'] ) && $preview_id != $query->query_vars['page_id'] ) {
return $posts;
}
// Get the form details
$form = wpforms()->form->get( absint( $_GET['form_id'] ), array( 'content_only' => true ) );
if ( ! $form || empty( $form ) ) {
return $posts;
}
// Customize the page content
$title = sanitize_text_field( $form['settings']['form_title'] );
$shortcode = '[wpforms id="' . absint( $form['id'] ) . '"]';
$content = __( 'This is a preview of your form. This page not publically accessible.', 'wpforms' );
if ( !empty( $_GET['new_window'] ) ) {
$content .= ' <a href="javascript:window.close();">' . __( 'Close this window', 'wpforms' ) . '.</a>';
}
$posts[0]->post_title = $title . __( ' Preview', 'wpforms' );
$posts[0]->post_content = $content . $shortcode;
$posts[0]->post_status = 'public';
return $posts;
}
/**
* Hide the preview page from admin
*
* @since 1.2.3
* @param object $query
*/
function form_preview_hide( $query ) {
if( $query->is_main_query() && is_admin() && isset( $query->query_vars['post_type'] ) && 'page' == $query->query_vars['post_type'] ) {
$wpforms_preview = intval( get_option( '<API key>' ) );
if( $wpforms_preview ) {
$exclude = $query->query_vars['post__not_in'];
$exclude[] = $wpforms_preview;
$query->set( 'post__not_in', $exclude );
}
}
}
}
|
package raw
import (
"fmt"
"../../platforms/common"
)
type FieldMacros struct {}
func (FieldMacros) DecodeDW0() {
macro := common.GetMacro()
// Do not decode, print as is.
macro.Add(fmt.Sprintf("0x%0.8x", macro.Register(common.PAD_CFG_DW0).ValueGet()))
}
func (FieldMacros) DecodeDW1() {
macro := common.GetMacro()
// Do not decode, print as is.
macro.Add(fmt.Sprintf("0x%0.8x", macro.Register(common.PAD_CFG_DW1).ValueGet()))
}
// GenerateString - generates the entire string of bitfield macros.
func (bitfields FieldMacros) GenerateString() {
macro := common.GetMacro()
macro.Add("_PAD_CFG_STRUCT(").Id().Add(", ")
bitfields.DecodeDW0()
macro.Add(", ")
bitfields.DecodeDW1()
macro.Add("),")
}
|
#ifndef __SOUND_PCM_H
#define __SOUND_PCM_H
#include <sound/asound.h>
#include <sound/memalloc.h>
#include <sound/minors.h>
#include <linux/poll.h>
#include <linux/mm.h>
#include <linux/bitops.h>
#include <linux/pm_qos.h>
#define <API key>(substream) ((substream)->private_data)
#define snd_pcm_chip(pcm) ((pcm)->private_data)
#if defined(CONFIG_SND_PCM_OSS) || defined(<API key>)
#include <sound/pcm_oss.h>
#endif
/*
* Hardware (lowlevel) section
*/
struct snd_pcm_hardware {
unsigned int info; /* SNDRV_PCM_INFO_* */
u64 formats; /* SNDRV_PCM_FMTBIT_* */
unsigned int rates; /* SNDRV_PCM_RATE_* */
unsigned int rate_min; /* min rate */
unsigned int rate_max; /* max rate */
unsigned int channels_min; /* min channels */
unsigned int channels_max; /* max channels */
size_t buffer_bytes_max; /* max buffer size */
size_t period_bytes_min; /* min period size */
size_t period_bytes_max; /* max period size */
unsigned int periods_min; /* min # of periods */
unsigned int periods_max; /* max # of periods */
size_t fifo_size; /* fifo size in bytes */
};
struct snd_pcm_substream;
struct snd_pcm_ops {
int (*open)(struct snd_pcm_substream *substream);
int (*close)(struct snd_pcm_substream *substream);
int (*ioctl)(struct snd_pcm_substream * substream,
unsigned int cmd, void *arg);
int (*hw_params)(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params);
int (*hw_free)(struct snd_pcm_substream *substream);
int (*prepare)(struct snd_pcm_substream *substream);
int (*trigger)(struct snd_pcm_substream *substream, int cmd);
snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
int (*wall_clock)(struct snd_pcm_substream *substream,
struct timespec *audio_ts);
int (*copy)(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos,
void __user *buf, snd_pcm_uframes_t count);
int (*silence)(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, snd_pcm_uframes_t count);
struct page *(*page)(struct snd_pcm_substream *substream,
unsigned long offset);
int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma);
int (*ack)(struct snd_pcm_substream *substream);
};
#if defined(<API key>)
#define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
#else
#define SNDRV_PCM_DEVICES 8
#endif
#define <API key> ((void *)0)
#define <API key> ((void *)1)
#define <API key> 0
#define <API key> 1
#define <API key> 2
#define <API key> 3
#define <API key> 4
#define <API key> 0
#define <API key> 1
#define <API key> 3
#define <API key> 4
#define <API key> 5
#define <API key> 6
#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
/* If you change this don't forget to change rates[] table in pcm_native.c */
#define SNDRV_PCM_RATE_5512 (1<<0) /* 5512Hz */
#define SNDRV_PCM_RATE_8000 (1<<1) /* 8000Hz */
#define <API key> (1<<2) /* 11025Hz */
#define <API key> (1<<3) /* 16000Hz */
#define <API key> (1<<4) /* 22050Hz */
#define <API key> (1<<5) /* 32000Hz */
#define <API key> (1<<6) /* 44100Hz */
#define <API key> (1<<7) /* 48000Hz */
#define <API key> (1<<8) /* 64000Hz */
#define <API key> (1<<9) /* 88200Hz */
#define <API key> (1<<10) /* 96000Hz */
#define <API key> (1<<11) /* 176400Hz */
#define <API key> (1<<12) /* 192000Hz */
#define <API key> (1<<13) /* 352800Hz */
#define <API key> (1<<14) /* 384000Hz */
#define <API key> (1<<30) /* continuous range */
#define SNDRV_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */
#define <API key> (SNDRV_PCM_RATE_8000|<API key>|\
<API key>|<API key>|\
<API key>|<API key>)
#define <API key> (<API key>|<API key>)
#define <API key> (<API key>|<API key>|\
<API key>|<API key>)
#define <API key> (<API key>|<API key>|\
<API key>)
#define <API key> (<API key>|\
<API key>|\
<API key>)
#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
#define <API key> _SNDRV_PCM_FMTBIT(S16_LE)
#define <API key> _SNDRV_PCM_FMTBIT(S16_BE)
#define <API key> _SNDRV_PCM_FMTBIT(U16_LE)
#define <API key> _SNDRV_PCM_FMTBIT(U16_BE)
#define <API key> _SNDRV_PCM_FMTBIT(S24_LE)
#define <API key> _SNDRV_PCM_FMTBIT(S24_BE)
#define <API key> _SNDRV_PCM_FMTBIT(U24_LE)
#define <API key> _SNDRV_PCM_FMTBIT(U24_BE)
#define <API key> _SNDRV_PCM_FMTBIT(S32_LE)
#define <API key> _SNDRV_PCM_FMTBIT(S32_BE)
#define <API key> _SNDRV_PCM_FMTBIT(U32_LE)
#define <API key> _SNDRV_PCM_FMTBIT(U32_BE)
#define <API key> _SNDRV_PCM_FMTBIT(FLOAT_LE)
#define <API key> _SNDRV_PCM_FMTBIT(FLOAT_BE)
#define <API key> _SNDRV_PCM_FMTBIT(FLOAT64_LE)
#define <API key> _SNDRV_PCM_FMTBIT(FLOAT64_BE)
#define <API key> _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
#define <API key> _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
#define <API key> _SNDRV_PCM_FMTBIT(MU_LAW)
#define <API key> _SNDRV_PCM_FMTBIT(A_LAW)
#define <API key> _SNDRV_PCM_FMTBIT(IMA_ADPCM)
#define <API key> _SNDRV_PCM_FMTBIT(MPEG)
#define <API key> _SNDRV_PCM_FMTBIT(GSM)
#define <API key> _SNDRV_PCM_FMTBIT(SPECIAL)
#define <API key> _SNDRV_PCM_FMTBIT(S24_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(U24_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(S24_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(U24_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(S20_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(U20_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(S20_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(U20_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(S18_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(U18_3LE)
#define <API key> _SNDRV_PCM_FMTBIT(S18_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(U18_3BE)
#define <API key> _SNDRV_PCM_FMTBIT(G723_24)
#define <API key> _SNDRV_PCM_FMTBIT(G723_24_1B)
#define <API key> _SNDRV_PCM_FMTBIT(G723_40)
#define <API key> _SNDRV_PCM_FMTBIT(G723_40_1B)
#define <API key> _SNDRV_PCM_FMTBIT(DSD_U8)
#define <API key> _SNDRV_PCM_FMTBIT(DSD_U16_LE)
#define <API key> _SNDRV_PCM_FMTBIT(DSD_U32_LE)
#define <API key> _SNDRV_PCM_FMTBIT(DSD_U16_BE)
#define <API key> _SNDRV_PCM_FMTBIT(DSD_U32_BE)
#ifdef SNDRV_LITTLE_ENDIAN
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
//#define <API key> <API key>
//#define <API key> <API key>
#endif
#ifdef SNDRV_BIG_ENDIAN
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#endif
struct snd_pcm_file {
struct snd_pcm_substream *substream;
int no_compat_mmap;
};
struct snd_pcm_hw_rule;
typedef int (*<API key>)(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule);
struct snd_pcm_hw_rule {
unsigned int cond;
<API key> func;
int var;
int deps[4];
void *private;
};
struct <API key> {
struct snd_mask masks[<API key> -
<API key> + 1];
struct snd_interval intervals[<API key> -
<API key> + 1];
unsigned int rules_num;
unsigned int rules_all;
struct snd_pcm_hw_rule *rules;
};
static inline struct snd_mask *constrs_mask(struct <API key> *constrs,
snd_pcm_hw_param_t var)
{
return &constrs->masks[var - <API key>];
}
static inline struct snd_interval *constrs_interval(struct <API key> *constrs,
snd_pcm_hw_param_t var)
{
return &constrs->intervals[var - <API key>];
}
struct snd_ratnum {
unsigned int num;
unsigned int den_min, den_max, den_step;
};
struct snd_ratden {
unsigned int num_min, num_max, num_step;
unsigned int den;
};
struct <API key> {
int nrats;
struct snd_ratnum *rats;
};
struct <API key> {
int nrats;
struct snd_ratden *rats;
};
struct <API key> {
unsigned int count;
const unsigned int *list;
unsigned int mask;
};
struct snd_pcm_hwptr_log;
struct snd_pcm_runtime {
/* -- Status -- */
struct snd_pcm_substream *trigger_master;
struct timespec trigger_tstamp; /* trigger timestamp */
int overrange;
snd_pcm_uframes_t avail_max;
snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */
snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */
unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */
unsigned long <API key>; /* buffer time in jiffies */
snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */
u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */
/* -- HW params -- */
snd_pcm_access_t access; /* access mode */
snd_pcm_format_t format; /* SNDRV_PCM_FORMAT_* */
snd_pcm_subformat_t subformat; /* subformat */
unsigned int rate; /* rate in Hz */
unsigned int channels; /* channels */
snd_pcm_uframes_t period_size; /* period size */
unsigned int periods; /* periods */
snd_pcm_uframes_t buffer_size; /* buffer size */
snd_pcm_uframes_t min_align; /* Min alignment for the format */
size_t byte_align;
unsigned int frame_bits;
unsigned int sample_bits;
unsigned int info;
unsigned int rate_num;
unsigned int rate_den;
unsigned int no_period_wakeup: 1;
/* -- SW params -- */
int tstamp_mode; /* mmap timestamp is updated */
unsigned int period_step;
snd_pcm_uframes_t start_threshold;
snd_pcm_uframes_t stop_threshold;
snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
noise is nearest than this */
snd_pcm_uframes_t silence_size; /* Silence filling size */
snd_pcm_uframes_t boundary; /* pointers wrap point */
snd_pcm_uframes_t silence_start; /* starting pointer to silence area */
snd_pcm_uframes_t silence_filled; /* size filled with silence */
union snd_pcm_sync_id sync; /* hardware synchronization ID */
/* -- mmap -- */
struct snd_pcm_mmap_status *status;
struct <API key> *control;
/* -- locking / scheduling -- */
snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */
wait_queue_head_t sleep; /* poll sleep */
wait_queue_head_t tsleep; /* transfer sleep */
struct fasync_struct *fasync;
/* -- private section -- */
void *private_data;
void (*private_free)(struct snd_pcm_runtime *runtime);
/* -- hardware description -- */
struct snd_pcm_hardware hw;
struct <API key> hw_constraints;
/* -- interrupt callbacks -- */
void (*transfer_ack_begin)(struct snd_pcm_substream *substream);
void (*transfer_ack_end)(struct snd_pcm_substream *substream);
/* -- timer -- */
unsigned int timer_resolution; /* timer resolution */
int tstamp_type; /* timestamp type */
/* -- DMA -- */
unsigned char *dma_area; /* DMA area */
dma_addr_t dma_addr; /* physical bus address (not accessible from main CPU) */
size_t dma_bytes; /* size of DMA area */
struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */
#if defined(CONFIG_SND_PCM_OSS) || defined(<API key>)
/* -- OSS things -- */
struct snd_pcm_oss_runtime oss;
#endif
#ifdef <API key>
struct snd_pcm_hwptr_log *hwptr_log;
#endif
};
struct snd_pcm_group { /* keep linked substreams */
spinlock_t lock;
struct list_head substreams;
int count;
};
struct pid;
struct snd_pcm_substream {
struct snd_pcm *pcm;
struct snd_pcm_str *pstr;
void *private_data; /* copied from pcm->private_data */
int number;
char name[32]; /* substream name */
int stream; /* stream (direction) */
struct pm_qos_request latency_pm_qos_req; /* pm_qos request */
size_t buffer_bytes_max; /* limit ring buffer size */
struct snd_dma_buffer dma_buffer;
size_t dma_max;
/* -- hardware operations -- */
const struct snd_pcm_ops *ops;
/* -- runtime information -- */
struct snd_pcm_runtime *runtime;
/* -- timer section -- */
struct snd_timer *timer; /* timer */
unsigned timer_running: 1; /* time is running */
/* -- next substream -- */
struct snd_pcm_substream *next;
/* -- linked substreams -- */
struct list_head link_list; /* linked list member */
struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */
struct snd_pcm_group *group; /* pointer to current group */
/* -- assigned files -- */
void *file;
int ref_count;
atomic_t mmap_count;
unsigned int f_flags;
void (*pcm_release)(struct snd_pcm_substream *);
struct pid *pid;
#if defined(CONFIG_SND_PCM_OSS) || defined(<API key>)
/* -- OSS things -- */
struct <API key> oss;
#endif
#ifdef <API key>
struct snd_info_entry *proc_root;
struct snd_info_entry *proc_info_entry;
struct snd_info_entry *<API key>;
struct snd_info_entry *<API key>;
struct snd_info_entry *proc_status_entry;
struct snd_info_entry *proc_prealloc_entry;
struct snd_info_entry *<API key>;
#endif
/* misc flags */
unsigned int hw_opened: 1;
};
#define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
struct snd_pcm_str {
int stream; /* stream (direction) */
struct snd_pcm *pcm;
/* -- substreams -- */
unsigned int substream_count;
unsigned int substream_opened;
struct snd_pcm_substream *substream;
#if defined(CONFIG_SND_PCM_OSS) || defined(<API key>)
/* -- OSS things -- */
struct snd_pcm_oss_stream oss;
#endif
#ifdef <API key>
struct snd_info_entry *proc_root;
struct snd_info_entry *proc_info_entry;
#ifdef <API key>
unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */
struct snd_info_entry *<API key>;
#endif
#endif
struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
};
struct snd_pcm {
struct snd_card *card;
struct list_head list;
int device; /* device number */
unsigned int info_flags;
unsigned short dev_class;
unsigned short dev_subclass;
char id[64];
char name[80];
struct snd_pcm_str streams[2];
struct mutex open_mutex;
wait_queue_head_t open_wait;
void *private_data;
void (*private_free) (struct snd_pcm *pcm);
struct device *dev; /* actual hw device this belongs to */
bool internal; /* pcm is for internal use only */
#if defined(CONFIG_SND_PCM_OSS) || defined(<API key>)
struct snd_pcm_oss oss;
#endif
};
struct snd_pcm_notify {
int (*n_register) (struct snd_pcm * pcm);
int (*n_disconnect) (struct snd_pcm * pcm);
int (*n_unregister) (struct snd_pcm * pcm);
struct list_head list;
};
/*
* Registering
*/
extern const struct file_operations snd_pcm_f_ops[2];
int snd_pcm_new(struct snd_card *card, const char *id, int device,
int playback_count, int capture_count,
struct snd_pcm **rpcm);
int <API key>(struct snd_card *card, const char *id, int device,
int playback_count, int capture_count,
struct snd_pcm **rpcm);
int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);
/*
* Native I/O
*/
extern rwlock_t snd_pcm_link_rwlock;
int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);
int snd_pcm_info_user(struct snd_pcm_substream *substream,
struct snd_pcm_info __user *info);
int snd_pcm_status(struct snd_pcm_substream *substream,
struct snd_pcm_status *status);
int snd_pcm_start(struct snd_pcm_substream *substream);
int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
int snd_pcm_drain_done(struct snd_pcm_substream *substream);
#ifdef CONFIG_PM
int snd_pcm_suspend(struct snd_pcm_substream *substream);
int snd_pcm_suspend_all(struct snd_pcm *pcm);
#endif
int <API key>(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int <API key>(struct snd_pcm *pcm, int stream, struct file *file,
struct snd_pcm_substream **rsubstream);
void <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm *pcm, int stream, struct file *file,
struct snd_pcm_substream **rsubstream);
void <API key>(struct snd_pcm_substream *substream);
void <API key>(void *client, void *data);
int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);
#ifdef CONFIG_SND_DEBUG
void snd_pcm_debug_name(struct snd_pcm_substream *substream,
char *name, size_t len);
#else
static inline void
snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
{
*buf = 0;
}
#endif
/*
* PCM library
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
return substream->group != &substream->self_group;
}
static inline void snd_pcm_stream_lock(struct snd_pcm_substream *substream)
{
read_lock(&snd_pcm_link_rwlock);
spin_lock(&substream->self_group.lock);
}
static inline void <API key>(struct snd_pcm_substream *substream)
{
spin_unlock(&substream->self_group.lock);
read_unlock(&snd_pcm_link_rwlock);
}
static inline void <API key>(struct snd_pcm_substream *substream)
{
read_lock_irq(&snd_pcm_link_rwlock);
spin_lock(&substream->self_group.lock);
}
static inline void <API key>(struct snd_pcm_substream *substream)
{
spin_unlock(&substream->self_group.lock);
read_unlock_irq(&snd_pcm_link_rwlock);
}
#define <API key>(substream, flags) \
do { \
read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \
spin_lock(&substream->self_group.lock); \
} while (0)
#define <API key>(substream, flags) \
do { \
spin_unlock(&substream->self_group.lock); \
<API key>(&snd_pcm_link_rwlock, (flags)); \
} while (0)
#define <API key>(s, substream) \
list_for_each_entry(s, &substream->group->substreams, link_list)
static inline int snd_pcm_running(struct snd_pcm_substream *substream)
{
return (substream->runtime->status->state == <API key> ||
(substream->runtime->status->state == <API key> &&
substream->stream == <API key>));
}
static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size)
{
return size * 8 / runtime->sample_bits;
}
static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size)
{
return size * 8 / runtime->frame_bits;
}
static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size)
{
return size * runtime->sample_bits / 8;
}
static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size)
{
return size * runtime->frame_bits / 8;
}
static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes)
{
return bytes % runtime->byte_align == 0;
}
static inline size_t <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return frames_to_bytes(runtime, runtime->buffer_size);
}
static inline size_t <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return frames_to_bytes(runtime, runtime->period_size);
}
/*
* result is: 0 ... (boundary - 1)
*/
static inline snd_pcm_uframes_t <API key>(struct snd_pcm_runtime *runtime)
{
snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr;
if (avail < 0)
avail += runtime->boundary;
else if ((snd_pcm_uframes_t) avail >= runtime->boundary)
avail -= runtime->boundary;
return avail;
}
/*
* result is: 0 ... (boundary - 1)
*/
static inline snd_pcm_uframes_t <API key>(struct snd_pcm_runtime *runtime)
{
snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr;
if (avail < 0)
avail += runtime->boundary;
return avail;
}
static inline snd_pcm_sframes_t <API key>(struct snd_pcm_runtime *runtime)
{
return runtime->buffer_size - <API key>(runtime);
}
static inline snd_pcm_sframes_t <API key>(struct snd_pcm_runtime *runtime)
{
return runtime->buffer_size - <API key>(runtime);
}
/**
* <API key> - check whether the playback buffer is available
* @substream: the pcm substream instance
*
* Checks whether enough free space is available on the playback buffer.
*
* Return: Non-zero if available, or zero if not.
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return <API key>(runtime) >= runtime->control->avail_min;
}
/**
* <API key> - check whether the capture buffer is available
* @substream: the pcm substream instance
*
* Checks whether enough capture data is available on the capture buffer.
*
* Return: Non-zero if available, or zero if not.
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return <API key>(runtime) >= runtime->control->avail_min;
}
/**
* <API key> - check whether any data exists on the playback buffer
* @substream: the pcm substream instance
*
* Checks whether any data exists on the playback buffer.
*
* Return: Non-zero if any data exists, or zero if not. If stop_threshold
* is bigger or equal to boundary, then this function returns always non-zero.
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
if (runtime->stop_threshold >= runtime->boundary)
return 1;
return <API key>(runtime) < runtime->buffer_size;
}
/**
* <API key> - check whether the playback buffer is empty
* @substream: the pcm substream instance
*
* Checks whether the playback buffer is empty.
*
* Return: Non-zero if empty, or zero if not.
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return <API key>(runtime) >= runtime->buffer_size;
}
/**
* <API key> - check whether the capture buffer is empty
* @substream: the pcm substream instance
*
* Checks whether the capture buffer is empty.
*
* Return: Non-zero if empty, or zero if not.
*/
static inline int <API key>(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return <API key>(runtime) == 0;
}
static inline void <API key>(struct snd_pcm_substream *substream,
struct snd_pcm_substream *master)
{
substream->runtime->trigger_master = master;
}
static inline int hw_is_mask(int var)
{
return var >= <API key> &&
var <= <API key>;
}
static inline int hw_is_interval(int var)
{
return var >= <API key> &&
var <= <API key>;
}
static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
return ¶ms->masks[var - <API key>];
}
static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
return ¶ms->intervals[var - <API key>];
}
static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
return ¶ms->masks[var - <API key>];
}
static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
return ¶ms->intervals[var - <API key>];
}
#define params_channels(p) \
(hw_param_interval_c((p), <API key>)->min)
#define params_rate(p) \
(hw_param_interval_c((p), <API key>)->min)
#define params_period_size(p) \
(hw_param_interval_c((p), <API key>)->min)
#define params_periods(p) \
(hw_param_interval_c((p), <API key>)->min)
#define params_buffer_size(p) \
(hw_param_interval_c((p), <API key>)->min)
#define params_buffer_bytes(p) \
(hw_param_interval_c((p), <API key>)->min)
int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c);
void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c);
void <API key>(const struct snd_interval *a, const struct snd_interval *b,
unsigned int k, struct snd_interval *c);
void <API key>(const struct snd_interval *a, unsigned int k,
const struct snd_interval *b, struct snd_interval *c);
int snd_interval_list(struct snd_interval *i, unsigned int count,
const unsigned int *list, unsigned int mask);
int snd_interval_ratnum(struct snd_interval *i,
unsigned int rats_count, struct snd_ratnum *rats,
unsigned int *nump, unsigned int *denp);
void <API key>(struct snd_pcm_hw_params *params);
void <API key>(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);
int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
u_int32_t mask);
int <API key>(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
u_int64_t mask);
int <API key>(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
unsigned int min, unsigned int max);
int <API key>(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
const struct <API key> *l);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
struct <API key> *r);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
struct <API key> *r);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
unsigned int width,
unsigned int msbits);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
unsigned long step);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var);
int <API key>(struct snd_pcm_runtime *runtime,
unsigned int base_rate);
int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime,
unsigned int cond,
int var,
<API key> func, void *private,
int dep, ...);
int <API key>(snd_pcm_format_t format);
int <API key>(snd_pcm_format_t format);
int <API key>(snd_pcm_format_t format);
int <API key>(snd_pcm_format_t format);
int <API key>(snd_pcm_format_t format);
#if 0 /* just for DocBook */
/**
* <API key> - Check the PCM format is CPU-endian
* @format: the format to check
*
* Return: 1 if the given PCM format is CPU-endian, 0 if
* opposite, or a negative error code if endian not specified.
*/
int <API key>(snd_pcm_format_t format);
#endif /* DocBook */
#ifdef SNDRV_LITTLE_ENDIAN
#define <API key>(format) <API key>(format)
#else
#define <API key>(format) <API key>(format)
#endif
int <API key>(snd_pcm_format_t format); /* in bits */
int <API key>(snd_pcm_format_t format); /* in bits */
ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
const unsigned char *<API key>(snd_pcm_format_t format);
int <API key>(snd_pcm_format_t format, void *buf, unsigned int frames);
snd_pcm_format_t <API key>(int width, int unsigned, int big_endian);
void snd_pcm_set_ops(struct snd_pcm * pcm, int direction,
const struct snd_pcm_ops *ops);
void snd_pcm_set_sync(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg);
int <API key>(struct snd_pcm_substream *substream,
struct snd_pcm_runtime *runtime);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream);
void <API key>(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr);
void <API key>(struct snd_pcm_substream *substream);
snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream,
const void __user *buf,
snd_pcm_uframes_t frames);
snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream,
void __user *buf, snd_pcm_uframes_t frames);
snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream,
void __user **bufs, snd_pcm_uframes_t frames);
snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream,
void __user **bufs, snd_pcm_uframes_t frames);
extern const struct <API key> snd_pcm_known_rates;
int <API key>(struct snd_pcm_runtime *runtime);
unsigned int <API key>(unsigned int rate);
unsigned int <API key>(unsigned int rate_bit);
unsigned int <API key>(unsigned int rates_a,
unsigned int rates_b);
static inline void <API key>(struct snd_pcm_substream *substream,
struct snd_dma_buffer *bufp)
{
struct snd_pcm_runtime *runtime = substream->runtime;
if (bufp) {
runtime->dma_buffer_p = bufp;
runtime->dma_area = bufp->area;
runtime->dma_addr = bufp->addr;
runtime->dma_bytes = bufp->bytes;
} else {
runtime->dma_buffer_p = NULL;
runtime->dma_area = NULL;
runtime->dma_addr = 0;
runtime->dma_bytes = 0;
}
}
/*
* Timer interface
*/
void <API key>(struct snd_pcm_substream *substream);
void snd_pcm_timer_init(struct snd_pcm_substream *substream);
void snd_pcm_timer_done(struct snd_pcm_substream *substream);
static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
struct timespec *tv)
{
if (runtime->tstamp_type == <API key>)
<API key>(tv);
else
getnstimeofday(tv);
}
/*
* Memory
*/
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm *pcm);
int <API key>(struct snd_pcm_substream *substream,
int type, struct device *data,
size_t size, size_t max);
int <API key>(struct snd_pcm *pcm,
int type, void *data,
size_t size, size_t max);
int <API key>(struct snd_pcm_substream *substream, size_t size);
int <API key>(struct snd_pcm_substream *substream);
int <API key>(struct snd_pcm_substream *substream,
size_t size, gfp_t gfp_flags);
int <API key>(struct snd_pcm_substream *substream);
struct page *<API key>(struct snd_pcm_substream *substream,
unsigned long offset);
#if 0 /* for kernel-doc */
/**
* <API key> - allocate virtual DMA buffer
* @substream: the substream to allocate the buffer to
* @size: the requested buffer size, in bytes
*
* Allocates the PCM substream buffer using vmalloc(), i.e., the memory is
* contiguous in kernel virtual space, but not in physical memory. Use this
* if the buffer is accessed by kernel code but not by device DMA.
*
* Return: 1 if the buffer was changed, 0 if not changed, or a negative error
* code.
*/
static int <API key>
(struct snd_pcm_substream *substream, size_t size);
/**
* <API key> - allocate 32-bit-addressable buffer
* @substream: the substream to allocate the buffer to
* @size: the requested buffer size, in bytes
*
* This function works like <API key>(), but uses
* vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory.
*
* Return: 1 if the buffer was changed, 0 if not changed, or a negative error
* code.
*/
static int <API key>
(struct snd_pcm_substream *substream, size_t size);
#endif
#define <API key>(subs, size) \
<API key> \
(subs, size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO)
#define <API key>(subs, size) \
<API key> \
(subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO)
#define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
#ifdef <API key>
/*
* SG-buffer handling
*/
#define <API key>(substream) \
snd_pcm_get_dma_buf(substream)->private_data
struct page *<API key>(struct snd_pcm_substream *substream,
unsigned long offset);
#else /* !SND_DMA_SGBUF */
/*
* fake using a continuous buffer
*/
#define <API key> NULL
#endif /* SND_DMA_SGBUF */
static inline dma_addr_t
<API key>(struct snd_pcm_substream *substream, unsigned int ofs)
{
return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs);
}
static inline void *
<API key>(struct snd_pcm_substream *substream, unsigned int ofs)
{
return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs);
}
static inline unsigned int
<API key>(struct snd_pcm_substream *substream,
unsigned int ofs, unsigned int size)
{
return <API key>(snd_pcm_get_dma_buf(substream), ofs, size);
}
/* handle mmap counter - PCM mmap callback should handle this counter properly */
static inline void <API key>(struct vm_area_struct *area)
{
struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
atomic_inc(&substream->mmap_count);
}
static inline void <API key>(struct vm_area_struct *area)
{
struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
atomic_dec(&substream->mmap_count);
}
int <API key>(struct snd_pcm_substream *substream,
struct vm_area_struct *area);
/* mmap for io-memory area */
#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
#define <API key> SNDRV_PCM_INFO_MMAP
int <API key>(struct snd_pcm_substream *substream, struct vm_area_struct *area);
#else
#define <API key> 0
#define <API key> NULL
#endif
#define <API key> NULL
static inline void <API key>(int dma, size_t *max)
{
*max = dma < 4 ? 64 * 1024 : 128 * 1024;
}
/*
* Misc
*/
#define <API key> (<API key>|\
(<API key><<8)|\
(<API key><<8)|\
(<API key><<24))
#define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
const char *snd_pcm_format_name(snd_pcm_format_t format);
/**
* snd_pcm_stream_str - Get a string naming the direction of a stream
* @substream: the pcm substream instance
*
* Return: A string naming the direction of the stream.
*/
static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
{
if (substream->stream == <API key>)
return "Playback";
else
return "Capture";
}
/*
* PCM channel-mapping control API
*/
/* array element of channel maps */
struct snd_pcm_chmap_elem {
unsigned char channels;
unsigned char map[15];
};
/* channel map information; retrieved via snd_kcontrol_chip() */
struct snd_pcm_chmap {
struct snd_pcm *pcm; /* assigned PCM instance */
int stream; /* PLAYBACK or CAPTURE */
struct snd_kcontrol *kctl;
const struct snd_pcm_chmap_elem *chmap;
unsigned int max_channels;
unsigned int channel_mask; /* optional: active channels bitmask */
void *private_data; /* optional: private data pointer */
};
/* get the PCM substream assigned to the given chmap info */
static inline struct snd_pcm_substream *
<API key>(struct snd_pcm_chmap *info, unsigned int idx)
{
struct snd_pcm_substream *s;
for (s = info->pcm->streams[info->stream].substream; s; s = s->next)
if (s->number == idx)
return s;
return NULL;
}
/* ALSA-standard channel maps (RL/RR prior to C/LFE) */
extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[];
/* Other world's standard channel maps (C/LFE prior to RL/RR) */
extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[];
/* bit masks to be passed to snd_pcm_chmap.channel_mask field */
#define <API key> ((1U << 2) | (1U << 4))
#define <API key> (<API key> | (1U << 6))
#define <API key> (<API key> | (1U << 8))
int <API key>(struct snd_pcm *pcm, int stream,
const struct snd_pcm_chmap_elem *chmap,
int max_channels,
unsigned long private_value,
struct snd_pcm_chmap **info_ret);
/* Strong-typed conversion of pcm_format to bitwise */
static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
{
return 1ULL << (__force int) pcm_format;
}
#endif /* __SOUND_PCM_H */
|
<?php
/**
* Tax rate resource model
*
* @category Mage
* @package Mage_Tax
* @author Magento Core Team <core@magentocommerce.com>
*/
class <API key> extends <API key>
{
}
|
package java.util.logging;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.<API key>;
import java.io.Writer;
/**
* A <code>StreamHandler</code> publishes <code>LogRecords</code> to
* a instances of <code>java.io.OutputStream</code>.
*
* @author Sascha Brawer (brawer@acm.org)
*/
public class StreamHandler
extends Handler
{
private OutputStream out;
private Writer writer;
/**
* Indicates the current state of this StreamHandler. The value
* should be one of STATE_FRESH, STATE_PUBLISHED, or STATE_CLOSED.
*/
private int streamState = STATE_FRESH;
/**
* streamState having this value indicates that the StreamHandler
* has been created, but the publish(LogRecord) method has not been
* called yet. If the StreamHandler has been constructed without an
* OutputStream, writer will be null, otherwise it is set to a
* freshly created OutputStreamWriter.
*/
private static final int STATE_FRESH = 0;
/**
* streamState having this value indicates that the publish(LocRecord)
* method has been called at least once.
*/
private static final int STATE_PUBLISHED = 1;
/**
* streamState having this value indicates that the close() method
* has been called.
*/
private static final int STATE_CLOSED = 2;
/**
* Creates a <code>StreamHandler</code> without an output stream.
* Subclasses can later use {@link
* #setOutputStream(java.io.OutputStream)} to associate an output
* stream with this StreamHandler.
*/
public StreamHandler()
{
this(null, null);
}
/**
* Creates a <code>StreamHandler</code> that formats log messages
* with the specified Formatter and publishes them to the specified
* output stream.
*
* @param out the output stream to which the formatted log messages
* are published.
*
* @param formatter the <code>Formatter</code> that will be used
* to format log messages.
*/
public StreamHandler(OutputStream out, Formatter formatter)
{
this(out, "java.util.logging.StreamHandler", Level.INFO,
formatter, SimpleFormatter.class);
}
StreamHandler(
OutputStream out,
String propertyPrefix,
Level defaultLevel,
Formatter formatter, Class <API key>)
{
this.level = LogManager.getLevelProperty(propertyPrefix + ".level",
defaultLevel);
this.filter = (Filter) LogManager.getInstanceProperty(
propertyPrefix + ".filter",
/* must be instance of */ Filter.class,
/* default: new instance of */ null);
if (formatter != null)
this.formatter = formatter;
else
this.formatter = (Formatter) LogManager.getInstanceProperty(
propertyPrefix + ".formatter",
/* must be instance of */ Formatter.class,
/* default: new instance of */ <API key>);
try
{
String enc = LogManager.getLogManager().getProperty(propertyPrefix
+ ".encoding");
/* make sure enc actually is a valid encoding */
if ((enc != null) && (enc.length() > 0))
new String(new byte[0], enc);
this.encoding = enc;
}
catch (Exception _)
{
}
if (out != null)
{
try
{
changeWriter(out, getEncoding());
}
catch (<API key> uex)
{
/* This should never happen, since the validity of the encoding
* name has been checked above.
*/
throw new RuntimeException(uex.getMessage());
}
}
}
private void checkOpen()
{
if (streamState == STATE_CLOSED)
throw new <API key>(this.toString() + " has been closed");
}
private void checkFresh()
{
checkOpen();
if (streamState != STATE_FRESH)
throw new <API key>("some log records have been published to " + this);
}
private void changeWriter(OutputStream out, String encoding)
throws <API key>
{
OutputStreamWriter writer;
/* The logging API says that a null encoding means the default
* platform encoding. However, java.io.OutputStreamWriter needs
* another constructor for the default platform encoding,
* passing null would throw an exception.
*/
if (encoding == null)
writer = new OutputStreamWriter(out);
else
writer = new OutputStreamWriter(out, encoding);
/* Closing the stream has side effects -- do this only after
* creating a new writer has been successful.
*/
if ((streamState != STATE_FRESH) || (this.writer != null))
close();
this.writer = writer;
this.out = out;
this.encoding = encoding;
streamState = STATE_FRESH;
}
public void setEncoding(String encoding)
throws SecurityException, <API key>
{
super.setEncoding(encoding);
checkFresh();
/* If out is null, setEncoding is being called before an output
* stream has been set. In that case, we need to check that the
* encoding is valid, and remember it if this is the case. Since
* this is exactly what the inherited implementation of
* Handler.setEncoding does, we can delegate.
*/
if (out != null)
{
/* The logging API says that a null encoding means the default
* platform encoding. However, java.io.OutputStreamWriter needs
* another constructor for the default platform encoding, passing
* null would throw an exception.
*/
if (encoding == null)
writer = new OutputStreamWriter(out);
else
writer = new OutputStreamWriter(out, encoding);
}
}
protected void setOutputStream(OutputStream out)
throws SecurityException
{
LogManager.getLogManager().checkAccess();
/* Throw a <API key> if out is null. */
out.getClass();
try
{
changeWriter(out, getEncoding());
}
catch (<API key> ex)
{
/* This seems quite unlikely to happen, unless the underlying
* implementation of java.io.OutputStreamWriter changes its
* mind (at runtime) about the set of supported character
* encodings.
*/
throw new RuntimeException(ex.getMessage());
}
}
/**
* Publishes a <code>LogRecord</code> to the associated output
* stream, provided the record passes all tests for being loggable.
* The <code>StreamHandler</code> will localize the message of the
* log record and substitute any message parameters.
*
* <p>Most applications do not need to call this method directly.
* Instead, they will use use a {@link Logger}, which will create
* LogRecords and distribute them to registered handlers.
*
* <p>In case of an I/O failure, the <code>ErrorManager</code>
* of this <code>Handler</code> will be informed, but the caller
* of this method will not receive an exception.
*
* <p>If a log record is being published to a
* <code>StreamHandler</code> that has been closed earlier, the Sun
* J2SE 1.4 reference can be observed to silently ignore the
* call. The GNU implementation, however, intentionally behaves
* differently by informing the <code>ErrorManager</code> associated
* with this <code>StreamHandler</code>. Since the condition
* indicates a programming error, the programmer should be
* informed. It also seems extremely unlikely that any application
* would depend on the exact behavior in this rather obscure,
* erroneous case -- especially since the API specification does not
* prescribe what is supposed to happen.
*
* @param record the log event to be published.
*/
public void publish(LogRecord record)
{
String formattedMessage;
if (!isLoggable(record))
return;
if (streamState == STATE_FRESH)
{
try
{
writer.write(formatter.getHead(this));
}
catch (java.io.IOException ex)
{
reportError(null, ex, ErrorManager.WRITE_FAILURE);
return;
}
catch (Exception ex)
{
reportError(null, ex, ErrorManager.GENERIC_FAILURE);
return;
}
streamState = STATE_PUBLISHED;
}
try
{
formattedMessage = formatter.format(record);
}
catch (Exception ex)
{
reportError(null, ex, ErrorManager.FORMAT_FAILURE);
return;
}
try
{
writer.write(formattedMessage);
}
catch (Exception ex)
{
reportError(null, ex, ErrorManager.WRITE_FAILURE);
}
}
/**
* Checks whether or not a <code>LogRecord</code> would be logged
* if it was passed to this <code>StreamHandler</code> for publication.
*
* <p>The <code>StreamHandler</code> implementation first checks
* whether a writer is present and the handler's level is greater
* than or equal to the severity level threshold. In a second step,
* if a {@link Filter} has been installed, its {@link
* Filter#isLoggable(LogRecord) isLoggable} method is
* invoked. Subclasses of <code>StreamHandler</code> can override
* this method to impose their own constraints.
*
* @param record the <code>LogRecord</code> to be checked.
*
* @return <code>true</code> if <code>record</code> would
* be published by {@link #publish(LogRecord) publish},
* <code>false</code> if it would be discarded.
*
* @see #setLevel(Level)
* @see #setFilter(Filter)
* @see Filter#isLoggable(LogRecord)
*
* @throws <API key> if <code>record</code> is
* <code>null</code>. */
public boolean isLoggable(LogRecord record)
{
return (writer != null) && super.isLoggable(record);
}
/**
* Forces any data that may have been buffered to the underlying
* output device.
*
* <p>In case of an I/O failure, the <code>ErrorManager</code>
* of this <code>Handler</code> will be informed, but the caller
* of this method will not receive an exception.
*
* <p>If a <code>StreamHandler</code> that has been closed earlier
* is closed a second time, the Sun J2SE 1.4 reference can be
* observed to silently ignore the call. The GNU implementation,
* however, intentionally behaves differently by informing the
* <code>ErrorManager</code> associated with this
* <code>StreamHandler</code>. Since the condition indicates a
* programming error, the programmer should be informed. It also
* seems extremely unlikely that any application would depend on the
* exact behavior in this rather obscure, erroneous case --
* especially since the API specification does not prescribe what is
* supposed to happen.
*/
public void flush()
{
try
{
checkOpen();
if (writer != null)
writer.flush();
}
catch (Exception ex)
{
reportError(null, ex, ErrorManager.FLUSH_FAILURE);
}
}
public void close()
throws SecurityException
{
LogManager.getLogManager().checkAccess();
try
{
/* Although flush also calls checkOpen, it catches
* any exceptions and reports them to the ErrorManager
* as flush failures. However, we want to report
* a closed stream as a close failure, not as a
* flush failure here. Therefore, we call checkOpen()
* before flush().
*/
checkOpen();
flush();
if (writer != null)
{
if (formatter != null)
{
/* Even if the StreamHandler has never published a record,
* it emits head and tail upon closing. An earlier version
* of the GNU Classpath implementation did not emitted
* anything. However, this had caused XML log files to be
* entirely empty instead of containing no log records.
*/
if (streamState == STATE_FRESH)
writer.write(formatter.getHead(this));
if (streamState != STATE_CLOSED)
writer.write(formatter.getTail(this));
}
streamState = STATE_CLOSED;
writer.close();
}
}
catch (Exception ex)
{
reportError(null, ex, ErrorManager.CLOSE_FAILURE);
}
}
}
|
.njg-tooltip{
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
color: #fff;
font-family: sans-serif;
font-size: 13px;
padding: 5px 10px;
padding: 5px 10px;
position: absolute;
top: -2000px;
}
.njg-overlay{
background: #fbfbfb;
border-radius: 2px;
border: 1px solid #ccc;
color: #6d6357;
font-family: Arial, sans-serif;
font-family: sans-serif;
font-size: 14px;
height: auto;
max-width: 400px;
min-width: 200px;
padding: 0 15px;
right: 10px;
top: 10px;
width: auto;
}
.njg-metadata{
background: #fbfbfb;
border-radius: 2px;
border: 1px solid #ccc;
color: #6d6357;
display: none;
font-family: Arial, sans-serif;
font-family: sans-serif;
font-size: 14px;
height: auto;
left: 10px;
max-width: 500px;
min-width: 200px;
padding: 0 15px;
top: 10px;
width: auto;
}
.njg-node{
stroke-opacity: 0.5;
stroke-width: 7px;
stroke: #fff;
}
.njg-node:hover,
.njg-node.njg-open {
stroke: rgba(0, 0, 0, 0.2);
}
.njg-link{
cursor: pointer;
stroke: #999;
stroke-width: 2;
stroke-opacity: 0.25;
}
.njg-link:hover,
.njg-link.njg-open{
stroke-width: 4 !important;
stroke-opacity: 0.5;
}
|
package test.css.controls.api;
import org.junit.Test;
import client.test.Keywords;
import client.test.Smoke;
import org.junit.BeforeClass;
import org.junit.Before;
import test.javaclient.shared.TestBase;
import static test.css.controls.ControlPage.ScrollPanes;
import test.javaclient.shared.screenshots.ScreenshotUtils;
/**
* Generated test
*/
public class <API key> extends TestBase {
{
ScreenshotUtils.<API key>(0.003f);
}
@BeforeClass
public static void runUI() {
test.css.controls.api.APIStylesApp.main(null);
}
@Before
public void createPage () {
((test.css.controls.api.APIStylesApp)getApplication()).open(ScrollPanes);
}
/**
* test ScrollPane with css: -fx-border-color
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-COLOR", true);
}
/**
* test ScrollPane with css: -fx-border-width
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-WIDTH", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-WIDTH-dotted", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-WIDTH-dashed", true);
}
/**
* test ScrollPane with css: -fx-border-inset
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-INSET", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-STYLE-DASHED", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "BORDER-STYLE-DOTTED", true);
}
/**
* test ScrollPane with css: -fx-image-border
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "IMAGE-BORDER", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "IMAGE-BORDER-INSETS", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "<API key>", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "<API key>", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "<API key>", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "IMAGE-BORDER-ROUND", true);
}
/**
* test ScrollPane with css: -<API key>
*/
@Test
public void <API key>() throws Exception {
<API key>(ScrollPanes.name(), "IMAGE-BORDER-SPACE", true);
}
public String getName() {
return "ControlCss";
}
}
|
<?php
/**
* @file
* Contains \Drupal\Console\Command\Debug\UpdateCommand.
*/
namespace Drupal\Console\Command\Debug;
use Drupal\Console\Command\Shared\UpdateTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Core\Command\Command;
use Drupal\Core\Update\UpdateRegistry;
use Drupal\Console\Utils\Site;
class UpdateCommand extends Command
{
use UpdateTrait;
/**
* @var Site
*/
protected $site;
/**
* @var UpdateRegistry
*/
protected $postUpdateRegistry;
/**
* DebugCommand constructor.
*
* @param Site $site
* @param UpdateRegistry $postUpdateRegistry
*/
public function __construct(
Site $site,
UpdateRegistry $postUpdateRegistry
) {
$this->site = $site;
$this->postUpdateRegistry = $postUpdateRegistry;
parent::__construct();
}
/**
* @inheritdoc
*/
protected function configure()
{
$this
->setName('debug:update')
->setDescription($this->trans('commands.debug.update.description'))
->setAliases(['du']);
}
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->site->loadLegacyFile('/core/includes/update.inc');
$this->site->loadLegacyFile('/core/includes/install.inc');
drupal_load_updates();
<API key>();
$requirements = <API key>();
$severity = <API key>($requirements);
$updates = <API key>();
$postUpdates = $this->postUpdateRegistry-><API key>();
$this->getIo()->newLine();
if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING)) {
$this-><API key>($requirements);
} elseif (empty($updates) && empty($postUpdates)) {
$this->getIo()->info($this->trans('commands.debug.update.messages.no-updates'));
} else {
$this->showUpdateTable($updates, $this->trans('commands.debug.update.messages.module-list'));
$this->showPostUpdateTable($postUpdates, $this->trans('commands.debug.update.messages.<API key>'));
}
}
/**
* @param $requirements
*/
private function <API key>($requirements)
{
$this->getIo()->info($this->trans('commands.debug.update.messages.requirements-error'));
$tableHeader = [
$this->trans('commands.debug.update.messages.severity'),
$this->trans('commands.debug.update.messages.title'),
$this->trans('commands.debug.update.messages.value'),
$this->trans('commands.debug.update.messages.description'),
];
$tableRows = [];
foreach ($requirements as $requirement) {
$minimum = in_array(
$requirement['minimum schema'],
[REQUIREMENT_ERROR, REQUIREMENT_WARNING]
);
if ((isset($requirement['minimum schema'])) && ($minimum)) {
$tableRows[] = [
$requirement['severity'],
$requirement['title'],
$requirement['value'],
$requirement['description'],
];
}
}
$this->getIo()->table($tableHeader, $tableRows);
}
}
|
/* This file is automatically generated. DO NOT EDIT! */
#ifndef _newfile_h
#define _newfile_h
off_t sf_byte (sf_file file);
/*< Count the file data size (in bytes) >*/
sf_file sf_tmpfile(char *format);
/*< Create an temporary (rw mode) file structure. Lives within the program >*/
void sf_filefresh(sf_file file);
/*< used for temporary file only to recover the dataname >*/
void sf_filecopy(sf_file file, sf_file src, sf_datatype type);
/*< copy the content in src->stream to file->stream >*/
void sf_tmpfileclose (sf_file file);
/*< close a file and free allocated space >*/
#endif
|
<?php
//no direct accees
defined ('_JEXEC') or die ('restricted aceess');
class <API key> extends SppagebuilderAddons{
public function render() {
$class = (isset($this->addon->settings->class) && $this->addon->settings->class) ? $this->addon->settings->class : '';
return '<div class="sppb-empty-space ' . $class . ' clearfix"></div>';
}
public function css() {
$addon_id = '#sppb-addon-' . $this->addon->id;
$gap = (isset($this->addon->settings->gap) && $this->addon->settings->gap) ? 'padding-bottom: ' . (int) $this->addon->settings->gap . 'px;': '';
if($gap) {
$css = $addon_id . ' .sppb-empty-space {';
$css .= $gap;
$css .= '}';
}
return $css;
}
}
|
<?
require_once("../../lib/bd/basedatosAdo.php");
class mysreportes
{
var $rep;
var $bd;
function mysreportes()
{
$this->rep="";
$this->bd=new basedatosAdo();
}
function sqlreporte()
{
$sql="select refcom as referencia, codpre as <API key>, monimp as monto from cpimpcom order by refcom";
return $sql;
}
function getAncho($pos)
{
$anchos=array();
$anchos[0]=75;
$anchos[1]=60;
$anchos[2]=20;
$anchos[3]=30;
$anchos[4]=30;
$anchos[5]=30;
$anchos[6]=30;
/* $anchos[7]=30;
$anchos[8]=30;
$anchos[9]=30;
$anchos[10]=30;
$anchos[11]=30;*/
return $anchos[$pos];
}
function getAncho2($pos)
{
$anchos2=array();
$anchos2[0]=20;
$anchos2[1]=20;
$anchos2[2]=20;
$anchos2[3]=20;
$anchos2[4]=40;
$anchos2[5]=30;
$anchos2[6]=30;
$anchos2[7]=30;
$anchos2[8]=30;
$anchos2[9]=30;
$anchos2[10]=30;
$anchos2[11]=30;
return $anchos2[$pos];
}
}
?>
|
const express = require('express');
const path = require('path');
const compression = require('compression');
const <API key> = require('<API key>');
const <API key> = require('<API key>');
const webpack = require('webpack');
// Dev middleware
const addDevMiddlewares = (app, options) => {
const compiler = webpack(options);
const middleware = <API key>(compiler, {
noInfo: true,
publicPath: options.output.publicPath,
silent: true,
});
app.use(middleware);
app.use(<API key>(compiler));
// Since <API key> uses memory-fs internally to store build
// artifacts, we use it instead
const fs = middleware.fileSystem;
app.get('*', (req, res) => {
const file = fs.readFileSync(path.join(compiler.outputPath, 'index.html'));
res.send(file.toString());
});
};
// Production middlewares
const addProdMiddlewares = (app, options) => {
// compression middleware compresses your server responses which makes them
// smaller (applies also to assets). You can read more about that technique
app.use(compression());
app.use(options.output.publicPath, express.static(options.output.path));
app.get('*', (req, res) => res.sendFile(path.join(options.output.path, 'index.html')));
};
/**
* Front-end middleware
*/
module.exports = (options) => {
const isProd = process.env.NODE_ENV === 'production';
const app = express();
if (isProd) {
addProdMiddlewares(app, options);
} else {
addDevMiddlewares(app, options);
}
return app;
};
|
import unittest
from PyFoam.Basics.MatplotlibTimelines import MatplotlibTimelines
theSuite=unittest.TestSuite()
|
/* $Id: VBoxUsbRt.cpp $ */
/** @file
* VBox USB R0 runtime
*/
#include "VBoxUsbCmn.h"
#include "../cmn/VBoxUsbIdc.h"
#include "../cmn/VBoxUsbTool.h"
#include <VBox/usblib-win.h>
#include <iprt/assert.h>
#include <VBox/log.h>
#define _USBD_
#define <API key> 0x00000008
#define VBOXUSB_MAGIC 0xABCF1423
typedef struct VBOXUSB_URB_CONTEXT
{
PURB pUrb;
PMDL pMdlBuf;
PVBOXUSBDEV_EXT pDevExt;
PVOID pOut;
ULONG ulTransferType;
ULONG ulMagic;
} VBOXUSB_URB_CONTEXT, * <API key>;
typedef struct VBOXUSB_SETUP
{
uint8_t bmRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} VBOXUSB_SETUP, *PVBOXUSB_SETUP;
static bool <API key>(PVBOXUSBDEV_EXT pDevExt, PFILE_OBJECT pFObj)
{
bool bRc = ASMAtomicCmpXchgPtr(&pDevExt->Rt.pOwner, pFObj, NULL);
if (bRc)
{
Log((__FUNCTION__": pDevExt (0x%x) Owner(0x%x) acquired\n", pFObj));
}
else
{
Log((__FUNCTION__": pDevExt (0x%x) Owner(0x%x) FAILED!!\n", pFObj));
}
return bRc;
}
static bool <API key>(PVBOXUSBDEV_EXT pDevExt, PFILE_OBJECT pFObj)
{
bool bRc = ASMAtomicCmpXchgPtr(&pDevExt->Rt.pOwner, NULL, pFObj);
if (bRc)
{
Log((__FUNCTION__": pDevExt (0x%x) Owner(0x%x) released\n", pFObj));
}
else
{
Log((__FUNCTION__": pDevExt (0x%x) Owner(0x%x) release: is NOT an owner\n", pFObj));
}
return bRc;
}
static bool vboxUsbRtCtxIsOwner(PVBOXUSBDEV_EXT pDevExt, PFILE_OBJECT pFObj)
{
PFILE_OBJECT pOwner = (PFILE_OBJECT)ASMAtomicReadPtr((void *volatile *)(&pDevExt->Rt.pOwner));
return pOwner == pFObj;
}
static NTSTATUS vboxUsbRtIdcSubmit(ULONG uCtl, void *pvBuffer)
{
/* we just reuse the standard usb tooling for simplicity here */
NTSTATUS Status = <API key>(g_VBoxUsbGlobals.RtIdc.pDevice, uCtl, pvBuffer, NULL);
Assert(Status == STATUS_SUCCESS);
return Status;
}
static NTSTATUS vboxUsbRtIdcInit()
{
UNICODE_STRING UniName;
<API key>(&UniName, <API key>);
NTSTATUS Status = <API key>(&UniName, FILE_ALL_ACCESS, &g_VBoxUsbGlobals.RtIdc.pFile, &g_VBoxUsbGlobals.RtIdc.pDevice);
if (NT_SUCCESS(Status))
{
VBOXUSBIDC_VERSION Version;
vboxUsbRtIdcSubmit(<API key>, &Version);
if (NT_SUCCESS(Status))
{
if (Version.u32Major == <API key>
&& Version.u32Minor >= <API key>)
return STATUS_SUCCESS;
AssertFailed();
}
else
{
AssertFailed();
}
/* this will as well dereference the dev obj */
ObDereferenceObject(g_VBoxUsbGlobals.RtIdc.pFile);
}
else
{
AssertFailed();
}
memset(&g_VBoxUsbGlobals.RtIdc, 0, sizeof (g_VBoxUsbGlobals.RtIdc));
return Status;
}
static VOID vboxUsbRtIdcTerm()
{
Assert(g_VBoxUsbGlobals.RtIdc.pFile);
Assert(g_VBoxUsbGlobals.RtIdc.pDevice);
ObDereferenceObject(g_VBoxUsbGlobals.RtIdc.pFile);
memset(&g_VBoxUsbGlobals.RtIdc, 0, sizeof (g_VBoxUsbGlobals.RtIdc));
}
static NTSTATUS <API key>(PDEVICE_OBJECT pPDO, HVBOXUSBIDCDEV *phDev)
{
<API key> Start;
Start.u.pPDO = pPDO;
*phDev = NULL;
NTSTATUS Status = vboxUsbRtIdcSubmit(<API key>, &Start);
Assert(Status == STATUS_SUCCESS);
if (!NT_SUCCESS(Status))
return Status;
*phDev = Start.u.hDev;
return STATUS_SUCCESS;
}
static NTSTATUS <API key>(HVBOXUSBIDCDEV hDev)
{
<API key> Stop;
Stop.hDev = hDev;
NTSTATUS Status = vboxUsbRtIdcSubmit(<API key>, &Stop);
Assert(Status == STATUS_SUCCESS);
return Status;
}
DECLHIDDEN(NTSTATUS) <API key>()
{
return vboxUsbRtIdcInit();
}
DECLHIDDEN(VOID) <API key>()
{
vboxUsbRtIdcTerm();
}
DECLHIDDEN(NTSTATUS) vboxUsbRtInit(PVBOXUSBDEV_EXT pDevExt)
{
RtlZeroMemory(&pDevExt->Rt, sizeof (pDevExt->Rt));
NTSTATUS Status = <API key>(pDevExt->pPDO, &GUID_CLASS_VBOXUSB,
NULL, /* IN PUNICODE_STRING ReferenceString OPTIONAL */
&pDevExt->Rt.IfName);
Assert(Status == STATUS_SUCCESS);
if (NT_SUCCESS(Status))
{
Status = <API key>(pDevExt->pPDO, &pDevExt->Rt.hMonDev);
Assert(Status == STATUS_SUCCESS);
if (NT_SUCCESS(Status))
{
Assert(pDevExt->Rt.hMonDev);
return STATUS_SUCCESS;
}
NTSTATUS tmpStatus = <API key>(&pDevExt->Rt.IfName, FALSE);
Assert(tmpStatus == STATUS_SUCCESS);
if (NT_SUCCESS(tmpStatus))
{
<API key>(&pDevExt->Rt.IfName);
}
}
return Status;
}
/**
* Free cached USB device/configuration descriptors
*
* @param pDevExt USB DevExt pointer
*/
static void <API key>(PVBOXUSBDEV_EXT pDevExt)
{
if (pDevExt->Rt.devdescr)
{
vboxUsbMemFree(pDevExt->Rt.devdescr);
pDevExt->Rt.devdescr = NULL;
}
for (ULONG i = 0; i < VBOXUSBRT_MAX_CFGS; ++i)
{
if (pDevExt->Rt.cfgdescr[i])
{
vboxUsbMemFree(pDevExt->Rt.cfgdescr[i]);
pDevExt->Rt.cfgdescr[i] = NULL;
}
}
}
/**
* Free per-device interface info
*
* @param pDevExt USB DevExt pointer
* @param fAbortPipes If true, also abort any open pipes
*/
static void <API key>(PVBOXUSBDEV_EXT pDevExt, BOOLEAN fAbortPipes)
{
unsigned i;
unsigned j;
/*
* Free old interface info
*/
if (pDevExt->Rt.pVBIfaceInfo)
{
for (i=0;i<pDevExt->Rt.uNumInterfaces;i++)
{
if (pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo)
{
if (fAbortPipes)
{
for(j=0; j<pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->NumberOfPipes; j++)
{
Log(("Aborting Pipe %d handle %x address %x\n", j,
pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j].PipeHandle,
pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j].EndpointAddress));
<API key>(pDevExt->pLowerDO, pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j].PipeHandle, FALSE);
}
}
vboxUsbMemFree(pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo);
}
pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo = NULL;
if (pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo)
vboxUsbMemFree(pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo);
pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo = NULL;
}
vboxUsbMemFree(pDevExt->Rt.pVBIfaceInfo);
pDevExt->Rt.pVBIfaceInfo = NULL;
}
}
DECLHIDDEN(VOID) vboxUsbRtClear(PVBOXUSBDEV_EXT pDevExt)
{
<API key>(pDevExt);
<API key>(pDevExt, FALSE);
}
DECLHIDDEN(NTSTATUS) vboxUsbRtRm(PVBOXUSBDEV_EXT pDevExt)
{
if (!pDevExt->Rt.IfName.Buffer)
return STATUS_SUCCESS;
NTSTATUS Status = <API key>(pDevExt->Rt.hMonDev);
Assert(Status == STATUS_SUCCESS);
Status = <API key>(&pDevExt->Rt.IfName, FALSE);
Assert(Status == STATUS_SUCCESS);
if (NT_SUCCESS(Status))
{
<API key>(&pDevExt->Rt.IfName);
pDevExt->Rt.IfName.Buffer = NULL;
}
return Status;
}
DECLHIDDEN(NTSTATUS) vboxUsbRtStart(PVBOXUSBDEV_EXT pDevExt)
{
NTSTATUS Status = <API key>(&pDevExt->Rt.IfName, TRUE);
Assert(Status == STATUS_SUCCESS);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt)
{
NTSTATUS Status = <API key>;
// uint32_t uTotalLength;
// unsigned i;
/* Read device descriptor */
Assert(!pDevExt->Rt.devdescr);
pDevExt->Rt.devdescr = (<API key>)vboxUsbMemAlloc(sizeof (<API key>));
if (pDevExt->Rt.devdescr)
{
memset(pDevExt->Rt.devdescr, 0, sizeof (<API key>));
Status = <API key>(pDevExt->pLowerDO, pDevExt->Rt.devdescr, sizeof (<API key>), <API key>, 0, 0, RT_INDEFINITE_WAIT);
if (NT_SUCCESS(Status))
{
Assert(pDevExt->Rt.devdescr->bNumConfigurations > 0);
<API key> pDr = (<API key>)vboxUsbMemAlloc(sizeof (<API key>));
Assert(pDr);
if (pDr)
{
UCHAR i = 0;
for (; i < pDevExt->Rt.devdescr->bNumConfigurations; ++i)
{
Status = <API key>(pDevExt->pLowerDO, pDr, sizeof (<API key>), <API key>, i, 0, RT_INDEFINITE_WAIT);
if (!NT_SUCCESS(Status))
{
break;
}
USHORT uTotalLength = pDr->wTotalLength;
pDevExt->Rt.cfgdescr[i] = (<API key>)vboxUsbMemAlloc(uTotalLength);
if (!pDevExt->Rt.cfgdescr[i])
{
Status = <API key>;
break;
}
Status = <API key>(pDevExt->pLowerDO, pDevExt->Rt.cfgdescr[i], uTotalLength, <API key>, i, 0, RT_INDEFINITE_WAIT);
if (!NT_SUCCESS(Status))
{
break;
}
}
vboxUsbMemFree(pDr);
if (NT_SUCCESS(Status))
return Status;
/* recources will be freed in <API key> below */
}
}
<API key>(pDevExt);
}
/* shoud be only on fail here */
Assert(!NT_SUCCESS(Status));
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
PUSBSUP_CLAIMDEV pDev = (PUSBSUP_CLAIMDEV)pIrp->AssociatedIrp.SystemBuffer;
ULONG cbOut = 0;
NTSTATUS Status = STATUS_SUCCESS;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pDev
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pDev)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != sizeof (*pDev))
{
AssertFailed();
Status = <API key>;
break;
}
if (!<API key>(pDevExt, pFObj))
{
AssertFailed();
pDev->fClaimed = false;
cbOut = sizeof (*pDev);
break;
}
<API key>(pDevExt);
Status = <API key>(pDevExt);
if (NT_SUCCESS(Status))
{
pDev->fClaimed = true;
cbOut = sizeof (*pDev);
}
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, cbOut);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
NTSTATUS Status= STATUS_SUCCESS;
if (vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
<API key>(pDevExt);
bool bRc = <API key>(pDevExt, pFObj);
Assert(bRc);
}
else
{
AssertFailed();
Status = <API key>;
}
<API key>(pIrp, STATUS_SUCCESS, 0);
<API key>(pDevExt);
return STATUS_SUCCESS;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt)
{
NTSTATUS Status = <API key>;
<API key> pDr = (<API key>)vboxUsbMemAllocZ(sizeof (<API key>));
if (pDr)
{
Status = <API key>(pDevExt->pLowerDO, pDr, sizeof(*pDr), <API key>, 0, 0, RT_INDEFINITE_WAIT);
if (NT_SUCCESS(Status))
{
pDevExt->Rt.idVendor = pDr->idVendor;
pDevExt->Rt.idProduct = pDr->idProduct;
pDevExt->Rt.bcdDevice = pDr->bcdDevice;
pDevExt->Rt.szSerial[0] = 0;
if (pDr->iSerialNumber
#ifdef DEBUG
|| pDr->iProduct || pDr->iManufacturer
#endif
)
{
int langId;
Status = <API key>(pDevExt->pLowerDO, &langId, RT_INDEFINITE_WAIT);
if (NT_SUCCESS(Status))
{
Status = <API key>(pDevExt->pLowerDO, pDevExt->Rt.szSerial, sizeof (pDevExt->Rt.szSerial), pDr->iSerialNumber, langId, RT_INDEFINITE_WAIT);
}
else
{
Status = STATUS_SUCCESS;
}
}
}
vboxUsbMemFree(pDr);
}
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PUSBSUP_GETDEV pDev = (PUSBSUP_GETDEV)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status = STATUS_SUCCESS;
ULONG cbOut = 0;
/* don't check for owner since this request is allowed for non-owners as well */
if (pDev && pSl->Parameters.DeviceIoControl.InputBufferLength == sizeof (*pDev)
&& pSl->Parameters.DeviceIoControl.OutputBufferLength == sizeof (*pDev))
{
Status = <API key>(pDevExt->pLowerDO, &pDevExt->Rt.fIsHighSpeed);
if (NT_SUCCESS(Status))
{
pDev->hDevice = pDevExt->Rt.hMonDev;
pDev->fAttached = true;
pDev->fHiSpeed = pDevExt->Rt.fIsHighSpeed;
cbOut = sizeof (*pDev);
}
}
else
{
Status = <API key>;
}
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, cbOut);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
PUSBSUP_GETDEV pDev = (PUSBSUP_GETDEV)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status = STATUS_SUCCESS;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if (pIrp->AssociatedIrp.SystemBuffer
|| pSl->Parameters.DeviceIoControl.InputBufferLength
|| pSl->Parameters.DeviceIoControl.OutputBufferLength)
{
AssertFailed();
Status = <API key>;
break;
}
Status = <API key>(pDevExt->pLowerDO, <API key>, NULL, NULL);
Assert(NT_SUCCESS(Status));
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static <API key> <API key>(PVBOXUSBDEV_EXT pDevExt, uint8_t uConfiguration)
{
<API key> pCfgDr = NULL;
for (ULONG i = 0; i < VBOXUSBRT_MAX_CFGS; ++i)
{
if (pDevExt->Rt.cfgdescr[i])
{
if (pDevExt->Rt.cfgdescr[i]->bConfigurationValue == uConfiguration)
{
pCfgDr = pDevExt->Rt.cfgdescr[i];
break;
}
}
}
return pCfgDr;
}
static NTSTATUS vboxUsbRtSetConfig(PVBOXUSBDEV_EXT pDevExt, uint8_t uConfiguration)
{
PURB pUrb = NULL;
NTSTATUS Status = STATUS_SUCCESS;
uint32_t i;
if (!uConfiguration)
{
pUrb = <API key>(<API key>, sizeof (struct <API key>));
if(!pUrb)
{
AssertMsgFailed((__FUNCTION__": VBoxUsbToolUrbAlloc failed\n"));
return <API key>;
}
<API key>(pDevExt, TRUE);
pUrb-><API key>.<API key> = NULL;
Status = VBoxUsbToolUrbPost(pDevExt->pLowerDO, pUrb, RT_INDEFINITE_WAIT);
if(NT_SUCCESS(Status) && USBD_SUCCESS(pUrb->UrbHeader.Status))
{
pDevExt->Rt.hConfiguration = pUrb-><API key>.ConfigurationHandle;
pDevExt->Rt.uConfigValue = uConfiguration;
}
else
{
AssertMsgFailed((__FUNCTION__": VBoxUsbToolUrbPost failed Status (0x%x), usb Status (0x%x)\n", Status, pUrb->UrbHeader.Status));
}
VBoxUsbToolUrbFree(pUrb);
return Status;
}
<API key> pCfgDr = <API key>(pDevExt, uConfiguration);
if (!pCfgDr)
{
AssertMsgFailed((__FUNCTION__": <API key> did not find cfg (%d)\n", uConfiguration));
return <API key>;
}
<API key> pIfLe = (<API key>)vboxUsbMemAllocZ((pCfgDr->bNumInterfaces + 1) * sizeof(<API key>));
if (!pIfLe)
{
AssertMsgFailed((__FUNCTION__": vboxUsbMemAllocZ for pIfLe failed\n"));
return <API key>;
}
for (i = 0; i < pCfgDr->bNumInterfaces; i++)
{
pIfLe[i].InterfaceDescriptor = <API key>(pCfgDr, pCfgDr, i, 0, -1, -1, -1);
if (!pIfLe[i].InterfaceDescriptor)
{
AssertMsgFailed((__FUNCTION__": interface %d not found\n", i));
Status = <API key>;
break;
}
}
if (NT_SUCCESS(Status))
{
pUrb = <API key>(pCfgDr, pIfLe);
if (pUrb)
{
Status = VBoxUsbToolUrbPost(pDevExt->pLowerDO, pUrb, RT_INDEFINITE_WAIT);
if (NT_SUCCESS(Status) && USBD_SUCCESS(pUrb->UrbHeader.Status))
{
<API key>(pDevExt, FALSE);
pDevExt->Rt.hConfiguration = pUrb-><API key>.ConfigurationHandle;
pDevExt->Rt.uConfigValue = uConfiguration;
pDevExt->Rt.uNumInterfaces = pCfgDr->bNumInterfaces;
pDevExt->Rt.pVBIfaceInfo = (VBOXUSB_IFACE_INFO*)vboxUsbMemAllocZ(pDevExt->Rt.uNumInterfaces * sizeof (VBOXUSB_IFACE_INFO));
if (pDevExt->Rt.pVBIfaceInfo)
{
Assert(NT_SUCCESS(Status));
for (i = 0; i < pDevExt->Rt.uNumInterfaces; i++)
{
uint32_t <API key> = sizeof (struct <API key>) + ((pIfLe[i].Interface->NumberOfPipes > 0) ? (pIfLe[i].Interface->NumberOfPipes - 1) : 0) * sizeof(<API key>);
pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo = (<API key>)vboxUsbMemAlloc(<API key>);
if (!pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo)
{
AssertMsgFailed((__FUNCTION__": vboxUsbMemAlloc failed\n"));
Status = <API key>;
break;
}
if (pIfLe[i].Interface->NumberOfPipes > 0)
{
pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo = (VBOXUSB_PIPE_INFO *)vboxUsbMemAlloc(pIfLe[i].Interface->NumberOfPipes * sizeof(VBOXUSB_PIPE_INFO));
if (!pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo)
{
AssertMsgFailed((__FUNCTION__": vboxUsbMemAlloc failed\n"));
Status = STATUS_NO_MEMORY;
break;
}
}
else
{
pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo = NULL;
}
*pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo = *pIfLe[i].Interface;
for (ULONG j = 0; j < pIfLe[i].Interface->NumberOfPipes; j++)
{
pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j] = pIfLe[i].Interface->Pipes[j];
pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo[j].EndpointAddress = pIfLe[i].Interface->Pipes[j].EndpointAddress;
pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo[j].NextScheduledFrame = 0;
}
}
// if (NT_SUCCESS(Status))
}
else
{
AssertMsgFailed((__FUNCTION__": vboxUsbMemAllocZ failed\n"));
Status = STATUS_NO_MEMORY;
}
}
else
{
AssertMsgFailed((__FUNCTION__": VBoxUsbToolUrbPost failed Status (0x%x), usb Status (0x%x)\n", Status, pUrb->UrbHeader.Status));
}
ExFreePool(pUrb);
}
else
{
AssertMsgFailed((__FUNCTION__": <API key> failed\n"));
Status = <API key>;
}
}
vboxUsbMemFree(pIfLe);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
PUSBSUP_SET_CONFIG pCfg = (PUSBSUP_SET_CONFIG)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status = STATUS_SUCCESS;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pCfg
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pCfg)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != 0)
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
break;
}
Status = vboxUsbRtSetConfig(pDevExt, pCfg->bConfigurationValue);
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, uint32_t InterfaceNumber, int AlternateSetting)
{
if (!pDevExt->Rt.uConfigValue)
{
AssertMsgFailed((__FUNCTION__": Can't select an interface without an active configuration\n"));
return <API key>;
}
if (InterfaceNumber >= pDevExt->Rt.uNumInterfaces)
{
AssertMsgFailed((__FUNCTION__": InterfaceNumber %d too high!!\n", InterfaceNumber));
return <API key>;
}
<API key> pCfgDr = <API key>(pDevExt, pDevExt->Rt.uConfigValue);
if (!pCfgDr)
{
AssertMsgFailed((__FUNCTION__": configuration %d not found!!\n", pDevExt->Rt.uConfigValue));
return <API key>;
}
<API key> pIfDr = <API key>(pCfgDr, pCfgDr, InterfaceNumber, AlternateSetting, -1, -1, -1);
if (!pIfDr)
{
AssertMsgFailed((__FUNCTION__": invalid interface %d or alternate setting %d\n", InterfaceNumber, AlternateSetting));
return STATUS_UNSUCCESSFUL;
}
USHORT uUrbSize = <API key>(pIfDr->bNumEndpoints);
ULONG <API key> = <API key>(pIfDr->bNumEndpoints);
NTSTATUS Status = STATUS_SUCCESS;
PURB pUrb = <API key>(0, uUrbSize);
if (!pUrb)
{
AssertMsgFailed((__FUNCTION__": VBoxUsbToolUrbAlloc failed\n"));
return STATUS_NO_MEMORY;
}
/*
* Free old interface and pipe info, allocate new again
*/
if (pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo)
{
/* Clear pipes associated with the interface, else Windows may hang. */
for(ULONG i = 0; i < pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo->NumberOfPipes; i++)
{
<API key>(pDevExt->pLowerDO, pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo->Pipes[i].PipeHandle, FALSE);
}
vboxUsbMemFree(pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo);
}
if (pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo)
{
vboxUsbMemFree(pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo);
}
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo = (<API key>)vboxUsbMemAlloc(<API key>);
if (pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo)
{
if (pIfDr->bNumEndpoints > 0)
{
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo = (VBOXUSB_PIPE_INFO*)vboxUsbMemAlloc(pIfDr->bNumEndpoints * sizeof(VBOXUSB_PIPE_INFO));
if (!pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo)
{
AssertMsgFailed(("VBoxUSBSetInterface: ExAllocatePool failed!\n"));
Status = STATUS_NO_MEMORY;
}
}
else
{
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo = NULL;
}
if (NT_SUCCESS(Status))
{
<API key>(pUrb, uUrbSize, pDevExt->Rt.hConfiguration, InterfaceNumber, AlternateSetting);
pUrb->UrbSelectInterface.Interface.Length = <API key>(pIfDr->bNumEndpoints);
Status = VBoxUsbToolUrbPost(pDevExt->pLowerDO, pUrb, RT_INDEFINITE_WAIT);
if (NT_SUCCESS(Status) && USBD_SUCCESS(pUrb->UrbHeader.Status))
{
<API key> *pIfInfo = &pUrb->UrbSelectInterface.Interface;
memcpy(pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo, pIfInfo, <API key>(pIfDr->bNumEndpoints));
Assert(pIfInfo->NumberOfPipes == pIfDr->bNumEndpoints);
for(ULONG i = 0; i < pIfInfo->NumberOfPipes; i++)
{
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pInterfaceInfo->Pipes[i] = pIfInfo->Pipes[i];
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo[i].EndpointAddress = pIfInfo->Pipes[i].EndpointAddress;
pDevExt->Rt.pVBIfaceInfo[InterfaceNumber].pPipeInfo[i].NextScheduledFrame = 0;
}
}
else
{
AssertMsgFailed((__FUNCTION__": VBoxUsbToolUrbPost failed Status (0x%x) usb Status (0x%x)\n", Status, pUrb->UrbHeader.Status));
}
}
}
else
{
AssertMsgFailed(("VBoxUSBSetInterface: ExAllocatePool failed!\n"));
Status = STATUS_NO_MEMORY;
}
VBoxUsbToolUrbFree(pUrb);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
<API key> pIf = (<API key>)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pIf
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pIf)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != 0)
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
break;
}
Status = <API key>(pDevExt, pIf->bInterfaceNumber, pIf->bAlternateSetting);
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static HANDLE <API key>(PVBOXUSBDEV_EXT pDevExt, uint32_t EndPointAddress)
{
for (ULONG i = 0; i < pDevExt->Rt.uNumInterfaces; i++)
{
for (ULONG j = 0; j < pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->NumberOfPipes; j++)
{
/* Note that bit 7 determines pipe direction, but is still significant
* because endpoints may be numbered like 0x01, 0x81, 0x02, 0x82 etc.
*/
if (pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j].EndpointAddress == EndPointAddress)
return pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->Pipes[j].PipeHandle;
}
}
return 0;
}
static VBOXUSB_PIPE_INFO* <API key>(PVBOXUSBDEV_EXT pDevExt, uint32_t EndPointAddress)
{
for (ULONG i = 0; i < pDevExt->Rt.uNumInterfaces; i++)
{
for (ULONG j = 0; j < pDevExt->Rt.pVBIfaceInfo[i].pInterfaceInfo->NumberOfPipes; j++)
{
if (pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo[j].EndpointAddress == EndPointAddress)
return &pDevExt->Rt.pVBIfaceInfo[i].pPipeInfo[j];
}
}
return NULL;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, uint32_t EndPointAddress, bool fReset)
{
NTSTATUS Status = <API key>(pDevExt->pLowerDO, <API key>(pDevExt, EndPointAddress), fReset);
if (!NT_SUCCESS(Status))
{
AssertMsgFailed((__FUNCTION__": <API key> failed Status (0x%x)\n", Status));
}
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
<API key> pCe = (<API key>)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pCe
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pCe)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != 0)
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
break;
}
Status = <API key>(pDevExt, pCe->bEndpoint, TRUE);
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
<API key> pCe = (<API key>)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pCe
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pCe)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != 0)
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
break;
}
Status = <API key>(pDevExt, pCe->bEndpoint, FALSE);
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PDEVICE_OBJECT pDevObj, IRP *pIrp, void *pvContext)
{
if (!pvContext)
{
AssertMsgFailed((__FUNCTION__": context is NULL\n"));
pIrp->IoStatus.Information = 0;
return <API key>;
}
<API key> pContext = (<API key>)pvContext;
if (pContext->ulMagic != VBOXUSB_MAGIC)
{
AssertMsgFailed((__FUNCTION__": Invalid context magic\n"));
pIrp->IoStatus.Information = 0;
return <API key>;
}
PURB pUrb = pContext->pUrb;
PMDL pMdlBuf = pContext->pMdlBuf;
PUSBSUP_URB pUrbInfo = (PUSBSUP_URB)pContext->pOut;
PVBOXUSBDEV_EXT pDevExt = pContext->pDevExt;
if (!pUrb || !pMdlBuf || !pUrbInfo | !pDevExt)
{
AssertMsgFailed((__FUNCTION__": Invalid args\n"));
if (pDevExt)
<API key>(pDevExt);
pIrp->IoStatus.Information = 0;
return <API key>;
}
NTSTATUS Status = pIrp->IoStatus.Status;
if (Status == STATUS_SUCCESS)
{
switch(pUrb->UrbHeader.Status)
{
case USBD_STATUS_CRC:
pUrbInfo->error = USBSUP_XFER_CRC;
break;
case USBD_STATUS_SUCCESS:
pUrbInfo->error = USBSUP_XFER_OK;
break;
case <API key>:
pUrbInfo->error = USBSUP_XFER_STALL;
break;
case <API key>:
case <API key>:
AssertMsgFailed((__FUNCTION__": sw error, urb Status (0x%x)\n", pUrb->UrbHeader.Status));
case <API key>:
default:
pUrbInfo->error = USBSUP_XFER_DNR;
break;
}
switch(pContext->ulTransferType)
{
case <API key>:
case <API key>:
pUrbInfo->len = pUrb->UrbControlTransfer.<API key>;
if (pContext->ulTransferType == <API key>)
{
/* <API key> is a control transfer, but it is special
* the first 8 bytes of the buffer is the setup packet so the real
* data length is therefore urb->len - 8
*/
pUrbInfo->len += sizeof (pUrb->UrbControlTransfer.SetupPacket);
}
break;
case <API key>:
pUrbInfo->len = pUrb-><API key>.<API key>;
break;
case <API key>:
case <API key>:
if (pUrbInfo->dir == USBSUP_DIRECTION_IN && pUrbInfo->error == USBSUP_XFER_OK
&& !(pUrbInfo->flags & <API key>)
&& pUrbInfo->len > pUrb-><API key>.<API key>
)
{
/* If we don't use the <API key> flag, the returned buffer lengths are
* wrong for short transfers (always a multiple of max packet size?). So we just figure
* out if this was a data underrun on our own.
*/
pUrbInfo->error = <API key>;
}
pUrbInfo->len = pUrb-><API key>.<API key>;
break;
default:
break;
}
}
else
{
pUrbInfo->len = 0;
Log((__FUNCTION__": URB failed Status (0x%x) urb Status (0x%x)\n", Status, pUrb->UrbHeader.Status));
#ifdef DEBUG
switch(pContext->ulTransferType)
{
case <API key>:
case <API key>:
LogRel(("Ctrl/Msg length=%d\n", pUrb->UrbControlTransfer.<API key>));
break;
case <API key>:
LogRel(("ISOC length=%d\n", pUrb-><API key>.<API key>));
break;
case <API key>:
case <API key>:
LogRel(("BULK/INTR length=%d\n", pUrb-><API key>.<API key>));
break;
}
#endif
switch(pUrb->UrbHeader.Status)
{
case USBD_STATUS_CRC:
pUrbInfo->error = USBSUP_XFER_CRC;
Status = STATUS_SUCCESS;
break;
case <API key>:
pUrbInfo->error = USBSUP_XFER_STALL;
Status = STATUS_SUCCESS;
break;
case <API key>:
pUrbInfo->error = USBSUP_XFER_DNR;
Status = STATUS_SUCCESS;
break;
case ((USBD_STATUS)0xC0010000L): // <API key> - too bad usbdi.h and usb.h aren't consistent!
// TODO: What the heck are we really supposed to do here?
pUrbInfo->error = USBSUP_XFER_STALL;
Status = STATUS_SUCCESS;
break;
case <API key>: // This one really shouldn't happen
case <API key>:
pUrbInfo->error = USBSUP_XFER_NAC;
Status = STATUS_SUCCESS;
break;
default:
AssertMsgFailed((__FUNCTION__": err Status (0x%x) (0x%x)\n", Status, pUrb->UrbHeader.Status));
pUrbInfo->error = USBSUP_XFER_DNR;
Status = STATUS_SUCCESS;
break;
}
}
// For isochronous transfers, always update the individual packets
if (pContext->ulTransferType == <API key>)
{
Assert(pUrbInfo->numIsoPkts == pUrb-><API key>.NumberOfPackets);
for (ULONG i = 0; i < pUrbInfo->numIsoPkts; ++i)
{
Assert(pUrbInfo->aIsoPkts[i].off == pUrb-><API key>.IsoPacket[i].Offset);
pUrbInfo->aIsoPkts[i].cb = (uint16_t)pUrb-><API key>.IsoPacket[i].Length;
switch (pUrb-><API key>.IsoPacket[i].Status)
{
case USBD_STATUS_SUCCESS:
pUrbInfo->aIsoPkts[i].stat = USBSUP_XFER_OK;
break;
case <API key>:
pUrbInfo->aIsoPkts[i].stat = USBSUP_XFER_NAC;
break;
default:
pUrbInfo->aIsoPkts[i].stat = USBSUP_XFER_STALL;
break;
}
}
}
MmUnlockPages(pMdlBuf);
IoFreeMdl(pMdlBuf);
vboxUsbMemFree(pContext);
<API key>(pDevExt);
Assert(pIrp->IoStatus.Status != STATUS_IO_TIMEOUT);
pIrp->IoStatus.Information = sizeof(*pUrbInfo);
pIrp->IoStatus.Status = Status;
return <API key>;
}
static NTSTATUS vboxUsbRtUrbSend(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp, PUSBSUP_URB pUrbInfo)
{
NTSTATUS Status = STATUS_SUCCESS;
<API key> pContext = NULL;
PMDL pMdlBuf = NULL;
ULONG cbUrb;
Assert(pUrbInfo);
if (pUrbInfo->type == <API key>)
{
Assert(pUrbInfo->numIsoPkts <= 8);
cbUrb = GET_ISO_URB_SIZE(pUrbInfo->numIsoPkts);
}
else
cbUrb = sizeof (URB);
do
{
pContext = (<API key>)vboxUsbMemAllocZ(cbUrb + sizeof (VBOXUSB_URB_CONTEXT));
if (!pContext)
{
AssertMsgFailed((__FUNCTION__": vboxUsbMemAlloc failed\n"));
Status = <API key>;
break;
}
PURB pUrb = (PURB)(pContext + 1);
HANDLE hPipe = NULL;
if (pUrbInfo->ep)
{
hPipe = <API key>(pDevExt, pUrbInfo->ep | ((pUrbInfo->dir == USBSUP_DIRECTION_IN) ? 0x80 : 0x00));
if (!hPipe)
{
AssertMsgFailed((__FUNCTION__": <API key> failed for endpoint (0x%x)\n", pUrbInfo->ep));
Status = <API key>;
break;
}
}
pMdlBuf = IoAllocateMdl(pUrbInfo->buf, (ULONG)pUrbInfo->len, FALSE, FALSE, NULL);
if (!pMdlBuf)
{
AssertMsgFailed((__FUNCTION__": IoAllocateMdl failed for buffer (0x%p) length (%d)\n", pUrbInfo->buf, pUrbInfo->len));
Status = <API key>;
break;
}
__try
{
MmProbeAndLockPages(pMdlBuf, KernelMode, IoModifyAccess);
}
__except(<API key>)
{
Status = GetExceptionCode();
IoFreeMdl(pMdlBuf);
pMdlBuf = NULL;
AssertMsgFailed((__FUNCTION__": Exception Code (0x%x)\n", Status));
break;
}
/* For some reason, passing a MDL in the URB does not work reliably. Notably
* the iPhone when used with iTunes fails.
*/
PVOID pBuffer = <API key>(pMdlBuf, NormalPagePriority);
if (!pBuffer)
{
AssertMsgFailed((__FUNCTION__": <API key> failed\n"));
Status = <API key>;
break;
}
switch (pUrbInfo->type)
{
case <API key>:
case <API key>:
{
pUrb->UrbHeader.Function = <API key>;
pUrb->UrbHeader.Length = sizeof (struct <API key>);
pUrb->UrbControlTransfer.PipeHandle = hPipe;
pUrb->UrbControlTransfer.<API key> = (ULONG)pUrbInfo->len;
pUrb->UrbControlTransfer.TransferFlags = ((pUrbInfo->dir == USBSUP_DIRECTION_IN) ? <API key> : <API key>);
pUrb->UrbControlTransfer.UrbLink = 0;
if (!hPipe)
pUrb->UrbControlTransfer.TransferFlags |= <API key>;
if (pUrbInfo->type == <API key>)
{
/* <API key> is a control transfer, but it is special
* the first 8 bytes of the buffer is the setup packet so the real
* data length is therefore pUrb->len - 8
*/
PVBOXUSB_SETUP pSetup = (PVBOXUSB_SETUP)pUrb->UrbControlTransfer.SetupPacket;
memcpy(pUrb->UrbControlTransfer.SetupPacket, pBuffer, min(sizeof (pUrb->UrbControlTransfer.SetupPacket), pUrbInfo->len));
if (pUrb->UrbControlTransfer.<API key> <= sizeof (pUrb->UrbControlTransfer.SetupPacket))
pUrb->UrbControlTransfer.<API key> = 0;
else
pUrb->UrbControlTransfer.<API key> -= sizeof (pUrb->UrbControlTransfer.SetupPacket);
pUrb->UrbControlTransfer.TransferBuffer = (uint8_t *)pBuffer + sizeof(pUrb->UrbControlTransfer.SetupPacket);
pUrb->UrbControlTransfer.TransferBufferMDL = 0;
pUrb->UrbControlTransfer.TransferFlags |= <API key>;
}
else
{
pUrb->UrbControlTransfer.TransferBuffer = 0;
pUrb->UrbControlTransfer.TransferBufferMDL = pMdlBuf;
}
break;
}
case <API key>:
{
Assert(pUrbInfo->dir == USBSUP_DIRECTION_IN || pUrbInfo->type == <API key>);
Assert(hPipe);
VBOXUSB_PIPE_INFO *pPipeInfo = <API key>(pDevExt, pUrbInfo->ep | ((pUrbInfo->dir == USBSUP_DIRECTION_IN) ? 0x80 : 0x00));
if (pPipeInfo == NULL)
{
/* Can happen if the isoc request comes in too early or late. */
AssertMsgFailed((__FUNCTION__": pPipeInfo not found\n"));
Status = <API key>;
break;
}
pUrb->UrbHeader.Function = <API key>;
pUrb->UrbHeader.Length = (USHORT)cbUrb;
pUrb-><API key>.PipeHandle = hPipe;
pUrb-><API key>.<API key> = (ULONG)pUrbInfo->len;
pUrb-><API key>.TransferBufferMDL = 0;
pUrb-><API key>.TransferBuffer = pBuffer;
pUrb-><API key>.TransferFlags = ((pUrbInfo->dir == USBSUP_DIRECTION_IN) ? <API key> : <API key>);
pUrb-><API key>.TransferFlags |= <API key>; // May be implied already
pUrb-><API key>.NumberOfPackets = pUrbInfo->numIsoPkts;
pUrb-><API key>.ErrorCount = 0;
pUrb-><API key>.UrbLink = 0;
Assert(pUrbInfo->numIsoPkts == pUrb-><API key>.NumberOfPackets);
for (ULONG i = 0; i < pUrbInfo->numIsoPkts; ++i)
{
pUrb-><API key>.IsoPacket[i].Offset = pUrbInfo->aIsoPkts[i].off;
pUrb-><API key>.IsoPacket[i].Length = pUrbInfo->aIsoPkts[i].cb;
}
/* We have to schedule the URBs ourselves. There is an ASAP flag but
* that can only be reliably used after pipe creation/reset, ie. it's
* almost completely useless.
*/
ULONG iFrame, iStartFrame;
<API key>(pDevExt->pLowerDO, pIrp, &iFrame);
iFrame += 2;
iStartFrame = pPipeInfo->NextScheduledFrame;
if ((iFrame < iStartFrame) || (iStartFrame > iFrame + 512))
iFrame = iStartFrame;
pPipeInfo->NextScheduledFrame = iFrame + pUrbInfo->numIsoPkts;
pUrb-><API key>.StartFrame = iFrame;
break;
}
case <API key>:
case <API key>:
{
Assert(pUrbInfo->dir != <API key>);
Assert(pUrbInfo->dir == USBSUP_DIRECTION_IN || pUrbInfo->type == <API key>);
Assert(hPipe);
pUrb->UrbHeader.Function = <API key>;
pUrb->UrbHeader.Length = sizeof (struct <API key>);
pUrb-><API key>.PipeHandle = hPipe;
pUrb-><API key>.<API key> = (ULONG)pUrbInfo->len;
pUrb-><API key>.TransferBufferMDL = 0;
pUrb-><API key>.TransferBuffer = pBuffer;
pUrb-><API key>.TransferFlags = ((pUrbInfo->dir == USBSUP_DIRECTION_IN) ? <API key> : <API key>);
if (pUrb-><API key>.TransferFlags & <API key>)
pUrb-><API key>.TransferFlags |= (<API key>);
pUrb-><API key>.UrbLink = 0;
break;
}
default:
{
AssertFailed();
Status = <API key>;
break;
}
}
if (!NT_SUCCESS(Status))
{
break;
}
pContext->pDevExt = pDevExt;
pContext->pMdlBuf = pMdlBuf;
pContext->pUrb = pUrb;
pContext->pOut = pUrbInfo;
pContext->ulTransferType = pUrbInfo->type;
pContext->ulMagic = VBOXUSB_MAGIC;
PIO_STACK_LOCATION pSl = <API key>(pIrp);
pSl->MajorFunction = <API key>;
pSl->Parameters.DeviceIoControl.IoControlCode = <API key>;
pSl->Parameters.Others.Argument1 = pUrb;
pSl->Parameters.Others.Argument2 = NULL;
<API key>(pIrp, <API key>, pContext, TRUE, TRUE, TRUE);
IoMarkIrpPending(pIrp);
Status = IoCallDriver(pDevExt->pLowerDO, pIrp);
AssertMsg(NT_SUCCESS(Status), (__FUNCTION__": IoCallDriver failed Status (0x%x)\n", Status));
return STATUS_PENDING;
} while (0);
Assert(!NT_SUCCESS(Status));
if (pMdlBuf)
{
MmUnlockPages(pMdlBuf);
IoFreeMdl(pMdlBuf);
}
if (pContext)
vboxUsbMemFree(pContext);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
PUSBSUP_URB pUrbInfo = (PUSBSUP_URB)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status;
do
{
if (!pFObj)
{
AssertFailed();
Status = <API key>;
break;
}
if (!vboxUsbRtCtxIsOwner(pDevExt, pFObj))
{
AssertFailed();
Status = <API key>;
break;
}
if ( !pUrbInfo
|| pSl->Parameters.DeviceIoControl.InputBufferLength != sizeof (*pUrbInfo)
|| pSl->Parameters.DeviceIoControl.OutputBufferLength != sizeof (*pUrbInfo))
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
break;
}
return vboxUsbRtUrbSend(pDevExt, pIrp, pUrbInfo);
} while (0);
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, 0);
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
<API key>(pIrp, STATUS_SUCCESS, 0);
<API key>(pDevExt);
return STATUS_SUCCESS;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PUSBSUP_VERSION pVer= (PUSBSUP_VERSION)pIrp->AssociatedIrp.SystemBuffer;
NTSTATUS Status = STATUS_SUCCESS;
if (pVer && pSl->Parameters.DeviceIoControl.InputBufferLength == 0
&& pSl->Parameters.DeviceIoControl.OutputBufferLength == sizeof (*pVer))
{
pVer->u32Major = <API key>;
pVer->u32Minor = <API key>;
}
else
{
AssertMsgFailed((__FUNCTION__": <API key>\n"));
Status = <API key>;
}
Assert(Status != STATUS_PENDING);
<API key>(pIrp, Status, sizeof (*pVer));
<API key>(pDevExt);
return Status;
}
static NTSTATUS <API key>(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
<API key>(pIrp, <API key>, 0);
<API key>(pDevExt);
return <API key>;
}
DECLHIDDEN(NTSTATUS) vboxUsbRtCreate(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
if (!pFObj)
{
AssertFailed();
return <API key>;
}
return STATUS_SUCCESS;
}
DECLHIDDEN(NTSTATUS) vboxUsbRtClose(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
PFILE_OBJECT pFObj = pSl->FileObject;
Assert(pFObj);
<API key>(pDevExt, pFObj);
return STATUS_SUCCESS;
}
DECLHIDDEN(NTSTATUS) vboxUsbRtDispatch(PVBOXUSBDEV_EXT pDevExt, PIRP pIrp)
{
PIO_STACK_LOCATION pSl = <API key>(pIrp);
switch (pSl->Parameters.DeviceIoControl.IoControlCode)
{
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
case <API key>:
{
return <API key>(pDevExt, pIrp);
}
default:
{
return <API key>(pDevExt, pIrp);
}
}
}
|
#ifndef _ASM_X86_ELF_H
#define _ASM_X86_ELF_H
/*
* ELF register definitions..
*/
#include <asm/ptrace.h>
#include <asm/user.h>
#include <asm/auxvec.h>
typedef unsigned long elf_greg_t;
#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
typedef struct user_i387_struct elf_fpregset_t;
#ifdef __i386__
typedef struct user_fxsr_struct elf_fpxregset_t;
#define R_386_NONE 0
#define R_386_32 1
#define R_386_PC32 2
#define R_386_GOT32 3
#define R_386_PLT32 4
#define R_386_COPY 5
#define R_386_GLOB_DAT 6
#define R_386_JMP_SLOT 7
#define R_386_RELATIVE 8
#define R_386_GOTOFF 9
#define R_386_GOTPC 10
#define R_386_NUM 11
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_386
#else
/* x86-64 relocation types */
#define R_X86_64_NONE 0 /* No reloc */
#define R_X86_64_64 1 /* Direct 64 bit */
#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
#define R_X86_64_PLT32 4 /* 32 bit PLT address */
#define R_X86_64_COPY 5 /* Copy symbol at runtime */
#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
#define R_X86_64_RELATIVE 8 /* Adjust by program base */
#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative
offset to GOT */
#define R_X86_64_32 10 /* Direct 32 bit zero extended */
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
#define R_X86_64_16 12 /* Direct 16 bit zero extended */
#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
#define R_X86_64_8 14 /* Direct 8 bit sign extended */
#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
#define R_X86_64_NUM 16
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_X86_64
#endif
#include <asm/vdso.h>
extern unsigned int vdso_enabled;
/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define elf_check_arch_ia32(x) \
(((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
#include <asm/processor.h>
#include <asm/system.h>
#ifdef CONFIG_X86_32
#include <asm/desc.h>
#define elf_check_arch(x) elf_check_arch_ia32(x)
/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx
contains a pointer to a function which might be registered using `atexit'.
This provides a mean for the dynamic linker to call DT_FINI functions for
shared libraries that have been loaded before the code runs.
A value of 0 tells we have no such handler.
We might as well make sure everything else is cleared too (except for %esp),
just to make things more deterministic.
*/
#define ELF_PLAT_INIT(_r, load_addr) \
do { \
_r->bx = 0; _r->cx = 0; _r->dx = 0; \
_r->si = 0; _r->di = 0; _r->bp = 0; \
_r->ax = 0; \
} while (0)
/*
* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
* now struct_user_regs, they are different)
*/
#define <API key>(pr_reg, regs) \
do { \
pr_reg[0] = regs->bx; \
pr_reg[1] = regs->cx; \
pr_reg[2] = regs->dx; \
pr_reg[3] = regs->si; \
pr_reg[4] = regs->di; \
pr_reg[5] = regs->bp; \
pr_reg[6] = regs->ax; \
pr_reg[7] = regs->ds & 0xffff; \
pr_reg[8] = regs->es & 0xffff; \
pr_reg[9] = regs->fs & 0xffff; \
pr_reg[11] = regs->orig_ax; \
pr_reg[12] = regs->ip; \
pr_reg[13] = regs->cs & 0xffff; \
pr_reg[14] = regs->flags; \
pr_reg[15] = regs->sp; \
pr_reg[16] = regs->ss & 0xffff; \
} while (0);
#define ELF_CORE_COPY_REGS(pr_reg, regs) \
do { \
<API key>(pr_reg, regs);\
pr_reg[10] = get_user_gs(regs); \
} while (0);
#define <API key>(pr_reg, regs) \
do { \
<API key>(pr_reg, regs);\
savesegment(gs, pr_reg[10]); \
} while (0);
#define ELF_PLATFORM (utsname()->machine)
#define <API key>() do { } while (0)
#else /* CONFIG_X86_32 */
/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define elf_check_arch(x) \
((x)->e_machine == EM_X86_64)
#define <API key>(x) elf_check_arch_ia32(x)
static inline void elf_common_init(struct thread_struct *t,
struct pt_regs *regs, const u16 ds)
{
regs->ax = regs->bx = regs->cx = regs->dx = 0;
regs->si = regs->di = regs->bp = 0;
regs->r8 = regs->r9 = regs->r10 = regs->r11 = 0;
regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
t->fs = t->gs = 0;
t->fsindex = t->gsindex = 0;
t->ds = t->es = ds;
}
#define ELF_PLAT_INIT(_r, load_addr) \
elf_common_init(¤t->thread, _r, 0)
#define <API key>(regs, load_addr) \
elf_common_init(¤t->thread, regs, __USER_DS)
void start_thread_ia32(struct pt_regs *regs, u32 new_ip, u32 new_sp);
#define compat_start_thread start_thread_ia32
void <API key>(void);
#define <API key>(ex) <API key>()
#define COMPAT_ELF_PLATFORM ("i686")
/*
* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
* now struct_user_regs, they are different). Assumes current is the process
* getting dumped.
*/
#define ELF_CORE_COPY_REGS(pr_reg, regs) \
do { \
unsigned v; \
(pr_reg)[0] = (regs)->r15; \
(pr_reg)[1] = (regs)->r14; \
(pr_reg)[2] = (regs)->r13; \
(pr_reg)[3] = (regs)->r12; \
(pr_reg)[4] = (regs)->bp; \
(pr_reg)[5] = (regs)->bx; \
(pr_reg)[6] = (regs)->r11; \
(pr_reg)[7] = (regs)->r10; \
(pr_reg)[8] = (regs)->r9; \
(pr_reg)[9] = (regs)->r8; \
(pr_reg)[10] = (regs)->ax; \
(pr_reg)[11] = (regs)->cx; \
(pr_reg)[12] = (regs)->dx; \
(pr_reg)[13] = (regs)->si; \
(pr_reg)[14] = (regs)->di; \
(pr_reg)[15] = (regs)->orig_ax; \
(pr_reg)[16] = (regs)->ip; \
(pr_reg)[17] = (regs)->cs; \
(pr_reg)[18] = (regs)->flags; \
(pr_reg)[19] = (regs)->sp; \
(pr_reg)[20] = (regs)->ss; \
(pr_reg)[21] = current->thread.fs; \
(pr_reg)[22] = current->thread.gs; \
asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \
asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \
asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \
asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \
} while (0);
/* I'm not sure if we can use '-' here */
#define ELF_PLATFORM ("x86_64")
extern void <API key>(void);
extern unsigned int sysctl_vsyscall32;
extern int force_personality32;
#endif /* !CONFIG_X86_32 */
#define <API key>
#define ELF_EXEC_PAGESIZE 4096
/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
use of this is to invoke "./ld.so someprog" to test out a new version of
the loader. We need to make sure that it is out of the way of the program
that it will "exec", and that there is sufficient room for the brk. */
#ifdef CONFIG_PAX_SEGMEXEC
#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
#else
#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
#endif
#ifdef CONFIG_PAX_ASLR
#ifdef CONFIG_X86_32
#define PAX_ELF_ET_DYN_BASE 0x10000000UL
#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
#else
#define PAX_ELF_ET_DYN_BASE 0x400000UL
#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
#endif
#endif
/* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. This could be done in user space,
but it's not easy, and we've already done it here. */
#define ELF_HWCAP (boot_cpu_data.x86_capability[0])
/* This yields a string that ld.so will use to load implementation
specific libraries for optimization. This is more specific in
intent than poking at uname or /proc/cpuinfo.
For the moment, we have only optimizations for the Intel generations,
but that could change... */
#define SET_PERSONALITY(ex) <API key>()
/*
* An executable for which <API key>() returns TRUE will
* have the READ_IMPLIES_EXEC personality flag set automatically.
*/
#define <API key>(ex, executable_stack) \
(executable_stack != EXSTACK_DISABLE_X)
struct task_struct;
#define ARCH_DLINFO_IA32(vdso_enabled) \
do { \
if (vdso_enabled) { \
NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
} \
} while (0)
#ifdef CONFIG_X86_32
#define STACK_RND_MASK (0x7ff)
#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
#define ARCH_DLINFO ARCH_DLINFO_IA32(vdso_enabled)
/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
#else /* CONFIG_X86_32 */
#define VDSO_HIGH_BASE 0xffffe000U /* CONFIG_COMPAT_VDSO address */
/* 1GB for 64bit, 8MB for 32bit */
#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
#define ARCH_DLINFO \
do { \
NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
} while (0)
#define AT_SYSINFO 32
#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(sysctl_vsyscall32)
#define <API key> (TASK_UNMAPPED_BASE + 0x1000000)
#endif /* !CONFIG_X86_32 */
#define VDSO_CURRENT_BASE (current->mm->context.vdso)
#define VDSO_ENTRY \
((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
struct linux_binprm;
#define <API key> 1
extern int <API key>(struct linux_binprm *bprm,
int uses_interp);
extern int <API key>(struct linux_binprm *, int exstack);
#define <API key> <API key>
#endif /* _ASM_X86_ELF_H */
|
// Vampire - A code for atomistic simulation of magnetic materials
// Email:richard.evans@york.ac.uk
// This program is free software; you can redistribute it and/or modify
// (at your option) any later version.
// This program is distributed in the hope that it will be useful, but
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
// Headers
#include "errors.hpp"
#include "demag.hpp"
#include "voronoi.hpp"
#include "material.hpp"
#include "sim.hpp"
#include "random.hpp"
#include "vio.hpp"
#include "vmath.hpp"
#include "vmpi.hpp"
#include <cmath>
#include <iostream>
#include <sstream>
// Namespace material_parameters
namespace mp{
// Material Container
//const int max_materials=100;
int num_materials=1;
std::vector <materials_t> material(1);
//Input Integration parameters
double dt_SI;
double gamma_SI = 1.76E11;
//Derived Integration parameters
double dt;
double half_dt;
// Unrolled material parameters for speed
std::vector <double> MaterialMuSSIArray(0);
std::vector <zkval_t> <API key>(0);
std::vector <zkten_t> <API key>(0);
std::vector <double> <API key>(0);
std::vector <double> <API key>(0);
std::vector <double> <API key>(0);
std::vector <double> <API key>(0);
@brief Function to initialise program variables prior to system creation.
@section License
Use of this code, either in source or compiled form, is subject to license from the authors.
Copyright \htmlonly © \endhtmlonly Richard Evans, 2009-2010. All Rights Reserved.
@section Information
@author Richard Evans, rfle500@york.ac.uk
@version 1.0
@date 19/01/2010
@param[in] infile Main input file name for system initialisation
@return EXIT_SUCCESS
@internal
Created: 19/01/2010
Revision:
=====================================================================================
int initialise(std::string const infile){
// check calling of routine if error checking is activated
if(err::check==true){std::cout << "<API key> has been called" << std::endl;}
if(vmpi::my_rank==0){
std::cout << "================================================================================" << std::endl;
std::cout << "Initialising system variables" << std::endl;
}
// Setup default system settings
mp::default_system();
// Read values from input files
int iostat = vin::read(infile);
if(iostat==EXIT_FAILURE){
terminaltextcolor(RED);
std::cerr << "Error - input file \'" << infile << "\' not found, exiting" << std::endl;
terminaltextcolor(WHITE);
err::vexit();
}
// Print out material properties
//mp::material[0].print();
// Check for keyword parameter overide
if(cs::single_spin==true){
mp::single_spin_system();
}
// Set derived system parameters
mp::<API key>();
// Return
return EXIT_SUCCESS;
}
int default_system(){
// Initialise system creation flags to zero
for (int i=0;i<10;i++){
cs::<API key>[i] = 0;
sim::<API key>[i] = 0;
}
// Set system dimensions !Angstroms
cs::unit_cell_size[0] = 3.0;
cs::unit_cell_size[1] = 3.0;
cs::unit_cell_size[2] = 3.0;
cs::system_dimensions[0] = 100.0;
cs::system_dimensions[1] = 100.0;
cs::system_dimensions[2] = 100.0;
cs::particle_scale = 50.0;
cs::particle_spacing = 10.0;
cs::<API key>=0;
cs::crystal_structure = "sc";
// Voronoi Variables
create_voronoi::voronoi_sd=0.1;
create_voronoi::parity=0;
// Setup Hamiltonian Flags
sim::<API key>[0] = 1; /// Exchange
sim::<API key>[1] = 1; /// Anisotropy
sim::<API key>[2] = 1; /// Applied
sim::<API key>[3] = 1; /// Thermal
sim::<API key>[4] = 0; /// Dipolar
//Integration parameters
dt_SI = 1.0e-15; // seconds
dt = dt_SI*mp::gamma_SI; // Must be set before Hth
half_dt = 0.5*dt;
// Material Definitions
num_materials=1;
material.resize(num_materials);
// Material 0
material[0].name="Co";
material[0].alpha=0.1;
material[0].Jij_matrix_SI[0]=-11.2e-21;
material[0].mu_s_SI=1.5*9.27400915e-24;
material[0].Ku1_SI=-4.644e-24;
material[0].gamma_rel=1.0;
material[0].element="Ag ";
// Disable Error Checking
err::check=false;
// Initialise random number generator
mtrandom::grnd.seed(2106975519);
return EXIT_SUCCESS;
}
int single_spin_system(){
// Reset system creation flags to zero
for (int i=0;i<10;i++){
cs::<API key>[i] = 0;
}
// Set system dimensions !Angstroms
cs::unit_cell_size[0] = 3.0;
cs::unit_cell_size[1] = 3.0;
cs::unit_cell_size[2] = 3.0;
cs::system_dimensions[0] = 2.0;
cs::system_dimensions[1] = 2.0;
cs::system_dimensions[2] = 2.0;
cs::particle_scale = 50.0;
cs::particle_spacing = 10.0;
cs::<API key>=0;
cs::crystal_structure = "sc";
// Turn off multi-spin Flags
sim::<API key>[0] = 0; /// Exchange
sim::<API key>[4] = 0; /// Dipolar
// MPI Mode (Homogeneous execution)
//vmpi::mpi_mode=0;
//<API key>::<API key>=2; // Unit cells
//<API key>::mpi_comms_identify=false;
return EXIT_SUCCESS;
}
// Simple function to check for valid input for hysteresis loop parameters
void <API key>(){
// Only applies to hysteresis loop programs, all others return
if(sim::program!=12) return;
double min=sim::Hmin;
double max=sim::Hmax;
double inc=sim::Hinc;
if(min>=0 && max>=0 && inc>0){
if(max<min){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum and maximum fields are both positive, but minimum > maximum with a positive increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum and maximum fields are both positive, but minimum > maximum with a positive increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
}
else if(min>=0 && max>=0 && inc<0){
if(max>min){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum and maximum fields are both positive, but maximum > minimum with a negative increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum and maximum fields are both positive, but maximum > minimum with a negative increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
}
else if(min>=0 && max<0 && inc>0){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum field is positive and maximum field is negative with a positive increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum field is positive and maximum field is negative with a positive increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
else if(min<0 && max>=0 && inc<0){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum field is negative and maximum field is positive with a negative increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum field is negative and maximum field is positive with a negative increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
else if(min<0 && max<0 && inc<0){
if(max>min){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum and maximum fields are both negative, but minimum < maximum with a negative increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum and maximum fields are both negative, but minimum < maximum with a negative increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
}
else if(min<0 && max<0 && inc>0){
if(max<min){
if(vmpi::my_rank==0){
terminaltextcolor(RED);
std::cout << "Error in hysteresis-loop parameters:" << std::endl;
std::cout << "\t sim:<API key> = " << min << std::endl;
std::cout << "\t sim:<API key> = " << max << std::endl;
std::cout << "\t sim:<API key> = " << inc << std::endl;
std::cout << "Minimum and maximum fields are both negative, but maximum < minimum with a positive increment, causing an infinite loop. Exiting." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error in hysteresis-loop parameters:" << std::endl;
zlog << zTs() << "\t sim:<API key> = " << min << std::endl;
zlog << zTs() << "\t sim:<API key> = " << max << std::endl;
zlog << zTs() << "\t sim:<API key> = " << inc << std::endl;
zlog << zTs() << "Minimum and maximum fields are both positive, but maximum < minimum with a positive increment, causing an infinite loop. Exiting." << std::endl;
err::vexit();
}
}
}
return;
}
int <API key>(){
// Set integration constants
mp::dt = mp::dt_SI*mp::gamma_SI; // Must be set before Hth
mp::half_dt = 0.5*mp::dt;
// Check to see if field direction is set by angle
if(sim::<API key>){
sim::H_vec[0]=sin(sim::<API key>*M_PI/180.0)*cos(sim::<API key>*M_PI/180.0);
sim::H_vec[1]=sin(sim::<API key>*M_PI/180.0)*sin(sim::<API key>*M_PI/180.0);
sim::H_vec[2]=cos(sim::<API key>*M_PI/180.0);
}
// Check for valid particle array offsets
if(cs::<API key> >= cs::system_dimensions[0]){
terminaltextcolor(RED);
std::cerr << "Warning: requested <API key> is greater than system dimensions." << std::endl;
std::cerr << "Info: This will probably lead to no particles being created and generate an error." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Warning: requested <API key> is greater than system dimensions." << std::endl;
zlog << zTs() << "Info: This will probably lead to no particles being created and generate an error." << std::endl;
}
if(cs::<API key> >= cs::system_dimensions[1]){
terminaltextcolor(RED);
std::cerr << "Warning: requested <API key> is greater than system dimensions." << std::endl;
std::cerr << "Info: This will probably lead to no particles being created and generate an error." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Warning: requested <API key> is greater than system dimensions." << std::endl;
zlog << zTs() << "Info: This will probably lead to no particles being created and generate an error." << std::endl;
}
<API key>();
// Ensure H vector is unit length
// **RE edit 21.11.12 - no longer necessary as value checked on user input**
//double mod_H=1.0/sqrt(sim::H_vec[0]*sim::H_vec[0]+sim::H_vec[1]*sim::H_vec[1]+sim::H_vec[2]*sim::H_vec[2]);
//sim::H_vec[0]*=mod_H;
//sim::H_vec[1]*=mod_H;
//sim::H_vec[2]*=mod_H;
// Calculate moment, magnetisation, and anisotropy constants
/*for(int mat=0;mat<mp::num_materials;mat++){
double V=cs::unit_cell_size[0]*cs::unit_cell_size[1]*cs::unit_cell_size[2];
// Set magnetisation from mu_s and a
if(material[mat].moment_flag==true){
//material[mat].magnetisation=<API key>*material[mat].mu_s_SI/V;
}
// Set mu_s from magnetisation and a
else {
//material[mat].mu_s_SI=material[mat].magnetisation*V/<API key>;
}
// Set K as energy/atom
if(material[mat].anis_flag==false){
material[mat].Ku1_SI=material[mat].Ku1_SI*V/<API key>;
std::cout << "setting " << material[mat].Ku1_SI << std::endl;
}
}*/
const string blank="";
// Check for symmetry of exchange matrix
for(int mi = 0; mi < mp::num_materials; mi++){
for(int mj = 0; mj < mp::num_materials; mj++){
// Check for non-zero value (avoids divide by zero)
if(fabs(material[mi].Jij_matrix_SI[mj]) > 0.0){
// Calculate ratio of i->j / j-> exchange constants
double ratio = material[mj].Jij_matrix_SI[mi]/material[mi].Jij_matrix_SI[mj];
// Check that ratio ~ 1.0 for symmetric exchange interactions
if( (ratio < 0.99999) || (ratio > 1.00001) ){
// Error found - report to user and terminate program
terminaltextcolor(RED);
std::cerr << "Error! Non-symmetric exchange interactions for materials " << mi+1 << " and " << mj+1 << ". Exiting" << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Error! Non-symmetric exchange interactions for materials " << mi+1 << " and " << mj+1 << std::endl;
zlog << zTs() << "\tmaterial[" << mi+1 << "]:exchange-matrix[" << mj+1 << "] = " << material[mi].Jij_matrix_SI[mj] << std::endl;
zlog << zTs() << "\tmaterial[" << mj+1 << "]:exchange-matrix[" << mi+1 << "] = " << material[mj].Jij_matrix_SI[mi] << std::endl;
zlog << zTs() << "\tThe definition of Heisenberg exchange requires that these values are the same. Exiting." << std::endl;
err::vexit();
}
}
}
}
// Set derived material parameters
for(int mat=0;mat<mp::num_materials;mat++){
mp::material[mat].one_oneplusalpha_sq = -mp::material[mat].gamma_rel/(1.0+mp::material[mat].alpha*mp::material[mat].alpha);
mp::material[mat].<API key> = mp::material[mat].alpha*mp::material[mat].one_oneplusalpha_sq;
for(int j=0;j<mp::num_materials;j++){
material[mat].Jij_matrix[j] = mp::material[mat].Jij_matrix_SI[j]/mp::material[mat].mu_s_SI;
}
mp::material[mat].Ku = mp::material[mat].Ku1_SI/mp::material[mat].mu_s_SI;
mp::material[mat].Ku2 = mp::material[mat].Ku2_SI/mp::material[mat].mu_s_SI;
mp::material[mat].Ku3 = mp::material[mat].Ku3_SI/mp::material[mat].mu_s_SI;
mp::material[mat].Klatt = mp::material[mat].Klatt_SI/mp::material[mat].mu_s_SI;
mp::material[mat].Kc = mp::material[mat].Kc1_SI/mp::material[mat].mu_s_SI;
mp::material[mat].Ks = mp::material[mat].Ks_SI/mp::material[mat].mu_s_SI;
mp::material[mat].H_th_sigma = sqrt(2.0*mp::material[mat].alpha*1.3806503e-23/
(mp::material[mat].mu_s_SI*mp::material[mat].gamma_rel*dt));
// Rename un-named materials with material id
std::string defname="material
if(mp::material[mat].name==defname){
std::stringstream newname;
newname << "material" << mat+1;
mp::material[mat].name=newname.str();
}
// initialise lattice anisotropy initialisation
if(sim::<API key>==true) mp::material[mat].lattice_anisotropy.<API key>();
// output interpolated data to file
//mp::material[mat].lattice_anisotropy.<API key>(mat);
}
// Check for which anisotropy function(s) are to be used
if(sim::TensorAnisotropy==true){
sim::<API key>=false; // turn off scalar anisotropy calculation
// loop over materials and convert all scalar anisotropy to tensor (along z)
for(int mat=0;mat<mp::num_materials; mat++){
const double one_o_mu=1.0/mp::material[mat].mu_s_SI;
// If tensor is unset
if(mp::material.at(mat).KuVec_SI.size()==0){
const double ex = mp::material.at(mat).<API key>.at(0);
const double ey = mp::material.at(mat).<API key>.at(1);
const double ez = mp::material.at(mat).<API key>.at(2);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ex*ex);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ex*ey);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ex*ez);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ey*ex);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ey*ey);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ey*ez);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ez*ex);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ez*ey);
mp::material.at(mat).KuVec.push_back(mp::material[mat].Ku*ez*ez);
}
else if(mp::material.at(mat).KuVec_SI.size()==9){
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(0)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(1)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(2)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(3)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(4)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(5)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(6)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(7)*one_o_mu);
mp::material.at(mat).KuVec.push_back(mp::material.at(mat).KuVec_SI.at(8)*one_o_mu);
}
}
}
// Unroll anisotropy values for speed
if(sim::<API key>==true){
zlog << zTs() << "Setting scalar uniaxial anisotropy." << std::endl;
// Set global anisotropy type
sim::AnisotropyType=0;
<API key>.resize(mp::num_materials);
for(int mat=0;mat<mp::num_materials; mat++) <API key>[mat].K=mp::material[mat].Ku;
}
else if(sim::TensorAnisotropy==true){
zlog << zTs() << "Setting tensor uniaxial anisotropy." << std::endl;
// Set global anisotropy type
sim::AnisotropyType=1;
<API key>.resize(mp::num_materials);
for(int mat=0;mat<mp::num_materials; mat++){
<API key>[mat].K[0][0]=mp::material.at(mat).KuVec.at(0);
<API key>[mat].K[0][1]=mp::material.at(mat).KuVec.at(1);
<API key>[mat].K[0][2]=mp::material.at(mat).KuVec.at(2);
<API key>[mat].K[1][0]=mp::material.at(mat).KuVec.at(3);
<API key>[mat].K[1][1]=mp::material.at(mat).KuVec.at(4);
<API key>[mat].K[1][2]=mp::material.at(mat).KuVec.at(5);
<API key>[mat].K[2][0]=mp::material.at(mat).KuVec.at(6);
<API key>[mat].K[2][1]=mp::material.at(mat).KuVec.at(7);
<API key>[mat].K[2][2]=mp::material.at(mat).KuVec.at(8);
}
}
// Unroll second order uniaxial anisotropy values for speed
if(sim::<API key>==true){
zlog << zTs() << "Setting scalar second order uniaxial anisotropy." << std::endl;
mp::<API key>.resize(mp::num_materials);
for(int mat=0;mat<mp::num_materials; mat++) mp::<API key>.at(mat)=mp::material[mat].Ku2;
}
// Unroll sixth order uniaxial anisotropy values for speed
if(sim::<API key>==true){
zlog << zTs() << "Setting scalar sixth order uniaxial anisotropy." << std::endl;
mp::<API key>.resize(mp::num_materials);
for(int mat=0;mat<mp::num_materials; mat++) mp::<API key>.at(mat)=mp::material[mat].Ku3;
}
// Unroll spherical harmonic anisotropy constants for speed
if(sim::spherical_harmonics==true){
zlog << zTs() << "Setting spherical harmonics for uniaxial anisotropy" << std::endl;
mp::<API key>.resize(3*mp::num_materials);
for(int mat=0; mat<mp::num_materials; mat++){
mp::<API key>.at(3*mat+0)=mp::material[mat].sh2/mp::material[mat].mu_s_SI;
mp::<API key>.at(3*mat+1)=mp::material[mat].sh4/mp::material[mat].mu_s_SI;
mp::<API key>.at(3*mat+2)=mp::material[mat].sh6/mp::material[mat].mu_s_SI;
}
}
// Unroll cubic anisotropy values for speed
if(sim::<API key>==true){
zlog << zTs() << "Setting scalar cubic anisotropy." << std::endl;
<API key>.resize(mp::num_materials);
for(int mat=0;mat<mp::num_materials; mat++) <API key>.at(mat)=mp::material[mat].Kc;
}
// Loop over materials to check for invalid input and warn appropriately
for(int mat=0;mat<mp::num_materials;mat++){
const double lmin=material[mat].min;
const double lmax=material[mat].max;
for(int nmat=0;nmat<mp::num_materials;nmat++){
if(nmat!=mat){
double min=material[nmat].min;
double max=material[nmat].max;
if(((lmin>min) && (lmin<max)) || ((lmax>min) && (lmax<max))){
terminaltextcolor(RED);
std::cerr << "Warning: Overlapping material heights found. Check log for details." << std::endl;
terminaltextcolor(WHITE);
zlog << zTs() << "Warning: material " << mat+1 << " overlaps material " << nmat+1 << "." << std::endl;
zlog << zTs() << "If you have defined geometry then this may be OK, or possibly you meant to specify alloy keyword instead." << std::endl;
zlog << zTs() << "
zlog << zTs() << " Material "<< mat+1 << ":minimum-height = " << lmin << std::endl;
zlog << zTs() << " Material "<< mat+1 << ":maximum-height = " << lmax << std::endl;
zlog << zTs() << " Material "<< nmat+1 << ":minimum-height = " << min << std::endl;
zlog << zTs() << " Material "<< nmat+1 << ":maximum-height = " << max << std::endl;
}
}
}
}
return EXIT_SUCCESS;
}
} // end of namespace mp
|
--DDD
function c47198668.initial_effect(c)
--pendulum summon
aux.<API key>(c)
--atk up
local e2=Effect.CreateEffect(c)
e2:SetType(<API key>)
e2:SetRange(LOCATION_PZONE)
e2:SetProperty(<API key>)
e2:SetCountLimit(1)
e2:SetTarget(c47198668.atktg1)
e2:SetOperation(c47198668.atkop1)
c:RegisterEffect(e2)
--atk up
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_ATKCHANGE)
e3:SetType(EFFECT_TYPE_FIELD+<API key>)
e3:SetCode(EVENT_DESTROYED)
e3:SetRange(LOCATION_MZONE)
e3:SetProperty(<API key>+<API key>)
e3:SetCountLimit(1)
e3:SetCost(c47198668.atkcost)
e3:SetTarget(c47198668.atktg2)
e3:SetOperation(c47198668.atkop2)
c:RegisterEffect(e3)
--indes
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(<API key>)
e4:SetProperty(<API key>)
e4:SetRange(LOCATION_MZONE)
e4:SetValue(c47198668.efilter)
c:RegisterEffect(e4)
end
function c47198668.filter1(c)
return c:IsFaceup() and c:IsSetCard(0xaf)
end
function c47198668.atktg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c47198668.filter1(chkc) end
if chk==0 then return Duel.IsExistingTarget(c47198668.filter1,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c47198668.filter1,tp,LOCATION_MZONE,0,1,1,nil)
end
function c47198668.atkop1(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(<API key>)
e1:SetCode(<API key>)
e1:SetValue(800)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
function c47198668.filter2(c,e,tp)
return c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:IsType(TYPE_MONSTER)
and c:IsPreviousLocation(LOCATION_MZONE) and c:<API key>()==tp
and c:IsLocation(LOCATION_GRAVE+LOCATION_REMOVED) and c:IsCanBeEffectTarget(e)
end
function c47198668.atkcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not e:GetHandler():IsDirectAttacked() end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(<API key>+EFFECT_FLAG_OATH)
e1:SetCode(<API key>)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c47198668.atktg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return eg:IsContains(chkc) and c47198668.filter2(chkc,e,tp) end
if chk==0 then return eg:IsExists(c47198668.filter2,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local g=eg:FilterSelect(tp,c47198668.filter2,1,1,nil,e,tp)
Duel.SetTargetCard(g)
end
function c47198668.atkop2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(<API key>)
e1:SetValue(tc:GetBaseAttack())
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
function c47198668.efilter(e,re,rp)
if not re:IsActiveType(TYPE_SPELL+TYPE_TRAP) then return false end
if not re:IsHasProperty(<API key>) then return true end
local g=Duel.GetChainInfo(0,<API key>)
return not g:IsContains(e:GetHandler())
end
|
#ifndef __iLBC_LPC_DECODE_H
#define __iLBC_LPC_DECODE_H
void <API key>(
float *a, /* (o) lpc coefficients for a sub-frame */
float *lsf1, /* (i) first lsf coefficient vector */
float *lsf2, /* (i) second lsf coefficient vector */
float coef, /* (i) interpolation weight */
int length /* (i) length of lsf vectors */
);
void SimplelsfDEQ(
float *lsfdeq, /* (o) dequantized lsf coefficients */
int *index, /* (i) quantization index */
int lpc_n /* (i) number of LPCs */
);
void <API key>(
float *syntdenum, /* (o) synthesis filter coefficients */
float *weightdenum, /* (o) weighting denumerator
coefficients */
float *lsfdeq, /* (i) dequantized lsf coefficients */
int length, /* (i) length of lsf coefficient vector */
iLBC_Dec_Inst_t *iLBCdec_inst
/* (i) the decoder state structure */
);
#endif
|
(function( $ ) {
wp.customize( 'blogname', function( value ) {
value.bind( function( to ) {
$( '.site-title a' ).text( to );
} );
} );
wp.customize( 'blogdescription', function( value ) {
value.bind( function( to ) {
$( '.site-description' ).text( to );
} );
} );
})( jQuery );
|
#!/bin/python
import os, subprocess
import logging
from autotest.client import test
from autotest.client.shared import error, software_manager
sm = software_manager.SoftwareManager()
class sblim_sfcb(test.test):
"""
Autotest module for testing basic functionality
of sblim_sfcb
@author Wang Tao <wangttao@cn.ibm.com>
"""
version = 1
nfail = 0
path = ''
def initialize(self, test_path=''):
"""
Sets the overall failure counter for the test.
"""
self.nfail = 0
if not sm.check_installed('gcc'):
logging.debug("gcc missing - trying to install")
sm.install('gcc')
ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path))
ret_val.communicate()
if ret_val.returncode != 0:
self.nfail += 1
logging.info('\n Test initialize successfully')
def run_once(self, test_path=''):
"""
Trigger test run
"""
try:
os.environ["LTPBIN"] = "%s/shared" %(test_path)
ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path))
ret_val.communicate()
if ret_val.returncode != 0:
self.nfail += 1
except error.CmdError, e:
self.nfail += 1
logging.error("Test Failed: %s", e)
def postprocess(self):
if self.nfail != 0:
logging.info('\n nfails is non-zero')
raise error.TestError('\nTest failed')
else:
logging.info('\n Test completed successfully ')
|
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "halls_of_reflection.h"
#include "Player.h"
enum Yells
{
SAY_JAINA_INTRO_1 = 0,
SAY_JAINA_INTRO_2 = 1,
SAY_JAINA_INTRO_3 = 2,
SAY_JAINA_INTRO_4 = 3,
SAY_JAINA_INTRO_5 = 4,
SAY_JAINA_INTRO_6 = 5,
SAY_JAINA_INTRO_7 = 6,
SAY_JAINA_INTRO_8 = 7,
SAY_JAINA_INTRO_9 = 8,
SAY_JAINA_INTRO_10 = 9,
SAY_JAINA_INTRO_11 = 10,
SAY_JAINA_INTRO_END = 11,
<API key> = 0,
<API key> = 1,
<API key> = 2,
<API key> = 3,
<API key> = 4,
<API key> = 5,
<API key> = 6,
<API key> = 7,
<API key> = 8,
<API key> = 0,
<API key> = 1,
<API key> = 2,
<API key> = 3,
<API key> = 4,
<API key> = 5,
<API key> = 6,
<API key> = 7,
<API key> = 8,
<API key> = 9,
<API key> = 10,
<API key> = 11,
<API key> = 12,
<API key> = 13,
<API key> = 14,
<API key> = 15,
SAY_LK_INTRO_1 = 0,
SAY_LK_INTRO_2 = 1,
SAY_LK_INTRO_3 = 2,
SAY_FALRIC_INTRO_1 = 5,
SAY_FALRIC_INTRO_2 = 6,
SAY_MARWYN_INTRO_1 = 4
};
enum Events
{
EVENT_NONE,
EVENT_START_INTRO,
EVENT_SKIP_INTRO,
EVENT_INTRO_A2_1,
EVENT_INTRO_A2_2,
EVENT_INTRO_A2_3,
EVENT_INTRO_A2_4,
EVENT_INTRO_A2_5,
EVENT_INTRO_A2_6,
EVENT_INTRO_A2_7,
EVENT_INTRO_A2_8,
EVENT_INTRO_A2_9,
EVENT_INTRO_A2_10,
EVENT_INTRO_A2_11,
EVENT_INTRO_A2_12,
EVENT_INTRO_A2_13,
EVENT_INTRO_A2_14,
EVENT_INTRO_A2_15,
EVENT_INTRO_A2_16,
EVENT_INTRO_A2_17,
EVENT_INTRO_A2_18,
EVENT_INTRO_A2_19,
EVENT_INTRO_H2_1,
EVENT_INTRO_H2_2,
EVENT_INTRO_H2_3,
EVENT_INTRO_H2_4,
EVENT_INTRO_H2_5,
EVENT_INTRO_H2_6,
EVENT_INTRO_H2_7,
EVENT_INTRO_H2_8,
EVENT_INTRO_H2_9,
EVENT_INTRO_H2_10,
EVENT_INTRO_H2_11,
EVENT_INTRO_H2_12,
EVENT_INTRO_H2_13,
EVENT_INTRO_H2_14,
EVENT_INTRO_H2_15,
EVENT_INTRO_LK_1,
EVENT_INTRO_LK_2,
EVENT_INTRO_LK_3,
EVENT_INTRO_LK_4,
EVENT_INTRO_LK_5,
EVENT_INTRO_LK_6,
EVENT_INTRO_LK_7,
EVENT_INTRO_LK_8,
EVENT_INTRO_LK_9,
EVENT_INTRO_END,
};
enum eEnum
{
ACTION_START_INTRO,
ACTION_SKIP_INTRO,
<API key> = 24710,
<API key> = 24712,
<API key> = 24500,
<API key> = 24802,
};
const Position <API key>[]=
{
{5283.234863f, 1990.946777f, 707.695679f, 0.929097f}, // 2 Loralen Follows
{5408.031250f, 2102.918213f, 707.695251f, 0.792756f}, // 9 Sylvanas Follows
{5401.866699f, 2110.837402f, 707.695251f, 0.800610f}, // 10 Loralen follows
};
const Position SpawnPos = {5262.540527f, 1949.693726f, 707.695007f, 0.808736f}; // Jaina/Sylvanas Beginning Position
const Position MoveThronePos = {5306.952148f, 1998.499023f, 709.341431f, 1.277278f}; // Jaina/Sylvanas walks to throne
const Position UtherSpawnPos = {5308.310059f, 2003.857178f, 709.341431f, 4.650315f};
const Position LichKingSpawnPos = {5362.917480f, 2062.307129f, 707.695374f, 3.945812f};
const Position <API key> = {5312.080566f, 2009.172119f, 709.341431f, 3.973301f}; // Lich King walks to throne
const Position LichKingMoveAwayPos = {5400.069824f, 2102.7131689f, 707.69525f, 0.843803f}; // Lich King walks away
class <API key> : public CreatureScript
{
private:
bool m_isSylvana;
public:
<API key>(bool isSylvana, const char* name) : CreatureScript(name), m_isSylvana(isSylvana) { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
case <API key>+1:
player->CLOSE_GOSSIP_MENU();
if (creature->AI())
creature->AI()->DoAction(ACTION_START_INTRO);
creature->RemoveFlag(UNIT_NPC_FLAGS, <API key>);
break;
case <API key>+2:
player->CLOSE_GOSSIP_MENU();
if (creature->AI())
creature->AI()->DoAction(ACTION_SKIP_INTRO);
creature->RemoveFlag(UNIT_NPC_FLAGS, <API key>);
break;
}
return true;
}
bool OnGossipHello(Player* player, Creature* creature)
{
if (creature->isQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
QuestStatus status = player->GetQuestStatus(m_isSylvana ? <API key> : <API key>);
if (status == <API key> || status == <API key>)
player->ADD_GOSSIP_ITEM( 0, "Can you remove the sword?", GOSSIP_SENDER_MAIN, <API key>+1);
// once last quest is completed, she offers this shortcut of the starting event
status = player->GetQuestStatus(m_isSylvana ? <API key> : <API key>);
if (status == <API key> || status == <API key>)
player->ADD_GOSSIP_ITEM( 0, "Dark Lady, I think I hear Arthas coming. Whatever you're going to do, do it quickly.", GOSSIP_SENDER_MAIN, <API key>+2);
player->SEND_GOSSIP_MENU(<API key>, creature->GetGUID());
return true;
}
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
// AI of Part1: handle the intro till start of gauntlet event.
struct <API key> : public ScriptedAI
{
<API key>(Creature* creature) : ScriptedAI(creature)
{
instance = me->GetInstanceScript();
}
InstanceScript* instance;
uint64 utherGUID;
uint64 lichkingGUID;
EventMap events;
void Reset()
{
events.Reset();
utherGUID = 0;
lichkingGUID = 0;
me->SetFlag(UNIT_NPC_FLAGS, <API key>);
me->SetStandState(<API key>);
me->SetVisible(true);
}
void DoAction(const int32 actionId)
{
switch (actionId)
{
case ACTION_START_INTRO:
events.ScheduleEvent(EVENT_START_INTRO, 0);
break;
case ACTION_SKIP_INTRO:
events.ScheduleEvent(EVENT_SKIP_INTRO, 0);
break;
}
}
void UpdateAI(const uint32 diff)
{
events.Update(diff);
switch (events.ExecuteEvent())
{
case EVENT_START_INTRO:
me->GetMotionMaster()->MovePoint(0, MoveThronePos);
// Begining of intro is differents between fActions as the speech sequence and timers are differents.
if (instance->GetData(<API key>) == ALLIANCE)
events.ScheduleEvent(EVENT_INTRO_A2_1, 0);
else
events.ScheduleEvent(EVENT_INTRO_H2_1, 0);
break;
// A2 Intro Events
case EVENT_INTRO_A2_1:
Talk(SAY_JAINA_INTRO_3);
events.ScheduleEvent(EVENT_INTRO_A2_2, 5000);
break;
case EVENT_INTRO_A2_2:
Talk(SAY_JAINA_INTRO_4);
events.ScheduleEvent(EVENT_INTRO_A2_3, 10000);
break;
case EVENT_INTRO_A2_3:
// TODO: she's doing some kind of spell casting emote
instance->HandleGameObject(instance->GetData64(DATA_FROSTMOURNE), true);
events.ScheduleEvent(EVENT_INTRO_A2_4, 10000);
break;
case EVENT_INTRO_A2_4:
// spawn UTHER during speach 2
if (Creature* uther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, <API key>))
{
uther->GetMotionMaster()->MoveIdle();
uther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
utherGUID = uther->GetGUID();
}
events.ScheduleEvent(EVENT_INTRO_A2_5, 2000);
break;
case EVENT_INTRO_A2_5:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_6, 3000);
break;
case EVENT_INTRO_A2_6:
Talk(SAY_JAINA_INTRO_5);
events.ScheduleEvent(EVENT_INTRO_A2_7, 6000);
break;
case EVENT_INTRO_A2_7:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_8, 6500);
break;
case EVENT_INTRO_A2_8:
Talk(SAY_JAINA_INTRO_6);
events.ScheduleEvent(EVENT_INTRO_A2_9, 2000);
break;
case EVENT_INTRO_A2_9:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_10, 9000);
break;
case EVENT_INTRO_A2_10:
Talk(SAY_JAINA_INTRO_7);
events.ScheduleEvent(EVENT_INTRO_A2_11, 5000);
break;
case EVENT_INTRO_A2_11:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_12, 11000);
break;
case EVENT_INTRO_A2_12:
Talk(SAY_JAINA_INTRO_8);
events.ScheduleEvent(EVENT_INTRO_A2_13, 4000);
break;
case EVENT_INTRO_A2_13:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_14, 12500);
break;
case EVENT_INTRO_A2_14:
Talk(SAY_JAINA_INTRO_9);
events.ScheduleEvent(EVENT_INTRO_A2_15, 10000);
break;
case EVENT_INTRO_A2_15:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_16, 22000);
break;
case EVENT_INTRO_A2_16:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_A2_17, 4000);
break;
case EVENT_INTRO_A2_17:
Talk(SAY_JAINA_INTRO_10);
events.ScheduleEvent(EVENT_INTRO_A2_18, 2000);
break;
case EVENT_INTRO_A2_18:
if (Creature* uther = me->GetCreature(*me, utherGUID))
{
uther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
uther->AI()->Talk(<API key>);
}
events.ScheduleEvent(EVENT_INTRO_A2_19, 11000);
break;
case EVENT_INTRO_A2_19:
Talk(SAY_JAINA_INTRO_11);
events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
break;
// H2 Intro Events
case EVENT_INTRO_H2_1:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_2, 8000);
break;
case EVENT_INTRO_H2_2:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_3, 6000);
break;
case EVENT_INTRO_H2_3:
Talk(<API key>);
// TODO: she's doing some kind of spell casting emote
events.ScheduleEvent(EVENT_INTRO_H2_4, 6000);
break;
case EVENT_INTRO_H2_4:
// spawn UTHER during speach 2
if (Creature* uther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, <API key>))
{
uther->GetMotionMaster()->MoveIdle();
uther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
utherGUID = uther->GetGUID();
}
events.ScheduleEvent(EVENT_INTRO_H2_5, 2000);
break;
case EVENT_INTRO_H2_5:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_6, 11000);
break;
case EVENT_INTRO_H2_6:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_7, 3000);
break;
case EVENT_INTRO_H2_7:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_8, 6000);
break;
case EVENT_INTRO_H2_8:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_9, 5000);
break;
case EVENT_INTRO_H2_9:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_10, 19000);
break;
case EVENT_INTRO_H2_10:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_11, 1500);
break;
case EVENT_INTRO_H2_11:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_12, 19500);
break;
case EVENT_INTRO_H2_12:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_13, 2000);
break;
case EVENT_INTRO_H2_13:
if (Creature* uther = me->GetCreature(*me, utherGUID))
{
uther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
uther->AI()->Talk(<API key>);
}
events.ScheduleEvent(EVENT_INTRO_H2_14, 12000);
break;
case EVENT_INTRO_H2_14:
if (Creature* uther = me->GetCreature(*me, utherGUID))
uther->AI()->Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_H2_15, 8000);
break;
case EVENT_INTRO_H2_15:
Talk(<API key>);
events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
break;
// Remaining Intro Events common for both faction
case EVENT_INTRO_LK_1:
// Spawn LK in front of door, and make him move to the sword.
if (Creature* lichking = me->SummonCreature(NPC_LICH_KING_EVENT, LichKingSpawnPos, <API key>))
{
lichking->GetMotionMaster()->MovePoint(0, <API key>);
lichking->SetReactState(REACT_PASSIVE);
lichkingGUID = lichking->GetGUID();
}
if (Creature* uther = me->GetCreature(*me, utherGUID))
{
if (instance->GetData(<API key>) == ALLIANCE)
uther->AI()->Talk(<API key>);
else
uther->AI()->Talk(<API key>);
}
events.ScheduleEvent(EVENT_INTRO_LK_2, 11000);
break;
case EVENT_INTRO_LK_2:
if (Creature* lichking = me->GetCreature(*me, lichkingGUID))
lichking->AI()->Talk(SAY_LK_INTRO_1);
events.ScheduleEvent(EVENT_INTRO_LK_3, 2000);
break;
case EVENT_INTRO_LK_3:
// The Lich King banishes Uther to the abyss.
if (Creature* uther = me->GetCreature(*me, utherGUID))
{
uther->DisappearAndDie();
utherGUID = 0;
}
// He steps forward and removes the runeblade from the heap of skulls.
events.ScheduleEvent(EVENT_INTRO_LK_4, 4000);
break;
case EVENT_INTRO_LK_4:
if (Creature* lichking = me->GetCreature(*me, lichkingGUID))
lichking->AI()->Talk(SAY_LK_INTRO_2);
events.ScheduleEvent(EVENT_INTRO_LK_5, 10000);
break;
case EVENT_INTRO_LK_5:
// summon Falric and Marwyn. then go back to the door
if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
pFalric->SetVisible(true);
if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
pMarwyn->SetVisible(true);
if (Creature* lichking = me->GetCreature(*me, lichkingGUID))
{
lichking->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
lichking->AI()->Talk(SAY_LK_INTRO_3);
}
events.ScheduleEvent(EVENT_INTRO_LK_6, 8000);
break;
case EVENT_INTRO_LK_6:
if (Creature* falric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
falric->AI()->Talk(SAY_FALRIC_INTRO_1);
events.ScheduleEvent(EVENT_INTRO_LK_7, 2000);
break;
case EVENT_INTRO_LK_7:
if (Creature* marwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
marwyn->AI()->Talk(SAY_MARWYN_INTRO_1);
events.ScheduleEvent(EVENT_INTRO_LK_8, 2000);
break;
case EVENT_INTRO_LK_8:
if (Creature* falric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
falric->AI()->Talk(SAY_FALRIC_INTRO_2);
events.ScheduleEvent(EVENT_INTRO_LK_9, 5000);
break;
case EVENT_INTRO_LK_9:
if (instance->GetData(<API key>) == ALLIANCE)
Talk(SAY_JAINA_INTRO_END);
else
Talk(<API key>);
me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
// TODO: Loralen/Koreln shall run also
events.ScheduleEvent(EVENT_INTRO_END, 10000);
break;
case EVENT_INTRO_END:
if (instance)
instance->SetData(DATA_WAVE_COUNT, SPECIAL); // start first wave
// Loralen or Koreln disappearAndDie()
me->DisappearAndDie();
break;
case EVENT_SKIP_INTRO:
// TODO: implement
if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
pFalric->SetVisible(true);
if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
pMarwyn->SetVisible(true);
me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
// TODO: Loralen/Koreln shall run also
events.ScheduleEvent(EVENT_INTRO_END, 15000);
break;
}
}
};
};
enum TrashSpells
{
// Ghostly Priest
<API key> = 72318,
<API key> = 72320,
SPELL_COWER_IN_FEAR = 72321,
SPELL_DARK_MENDING = 72322,
// Phantom Mage
SPELL_FIREBALL = 72163,
SPELL_FLAMESTRIKE = 72169,
SPELL_FROSTBOLT = 72166,
SPELL_CHAINS_OF_ICE = 72121,
SPELL_HALLUCINATION = 72342,
// Phantom Hallucination (same as phantom mage + HALLUCINATION_2 when dies)
<API key> = 72344,
// Shadowy Mercenary
SPELL_SHADOW_STEP = 72326,
SPELL_DEADLY_POISON = 72329,
<API key> = 72333,
SPELL_KIDNEY_SHOT = 72335,
// Spectral Footman
<API key> = 72198,
SPELL_SHIELD_BASH = 72194,
<API key> = 72203,
// Tortured Rifleman
SPELL_SHOOT = 72208,
SPELL_CURSED_ARROW = 72222,
SPELL_FROST_TRAP = 72215,
SPELL_ICE_SHOT = 72268,
};
enum TrashEvents
{
EVENT_TRASH_NONE,
// Ghostly Priest
<API key>,
<API key>,
EVENT_COWER_IN_FEAR,
EVENT_DARK_MENDING,
// Phantom Mage
EVENT_FIREBALL,
EVENT_FLAMESTRIKE,
EVENT_FROSTBOLT,
EVENT_CHAINS_OF_ICE,
EVENT_HALLUCINATION,
// Shadowy Mercenary
EVENT_SHADOW_STEP,
EVENT_DEADLY_POISON,
<API key>,
EVENT_KIDNEY_SHOT,
// Spectral Footman
<API key>,
EVENT_SHIELD_BASH,
<API key>,
// Tortured Rifleman
EVENT_SHOOT,
EVENT_CURSED_ARROW,
EVENT_FROST_TRAP,
EVENT_ICE_SHOT,
};
class npc_ghostly_priest : public CreatureScript
{
public:
npc_ghostly_priest() : CreatureScript("npc_ghostly_priest") { }
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
struct <API key>: public ScriptedAI
{
<API key>(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void EnterCombat(Unit* /*who*/)
{
events.ScheduleEvent(<API key>, 8000); // TODO: adjust timers
events.ScheduleEvent(<API key>, 12000);
events.ScheduleEvent(EVENT_COWER_IN_FEAR, 10000);
events.ScheduleEvent(EVENT_DARK_MENDING, 20000);
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case <API key>:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, <API key>);
events.ScheduleEvent(<API key>, 8000);
return;
case <API key>:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, <API key>);
events.ScheduleEvent(<API key>, 12000);
return;
case EVENT_COWER_IN_FEAR:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_COWER_IN_FEAR);
events.ScheduleEvent(EVENT_COWER_IN_FEAR, 10000);
return;
case EVENT_DARK_MENDING:
// find an ally with missing HP
if (Unit* target = <API key>(40, DUNGEON_MODE(30000, 50000)))
{
DoCast(target, SPELL_DARK_MENDING);
events.ScheduleEvent(EVENT_DARK_MENDING, 20000);
}
else
{
// no friendly unit with missing hp. re-check in just 5 sec.
events.ScheduleEvent(EVENT_DARK_MENDING, 5000);
}
return;
}
}
<API key>();
}
};
};
class npc_phantom_mage : public CreatureScript
{
public:
npc_phantom_mage() : CreatureScript("npc_phantom_mage") { }
CreatureAI* GetAI(Creature* creature) const
{
return new npc_phantom_mageAI(creature);
}
struct npc_phantom_mageAI: public ScriptedAI
{
npc_phantom_mageAI(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void EnterCombat(Unit* /*who*/)
{
events.ScheduleEvent(EVENT_FIREBALL, 3000); // TODO: adjust timers
events.ScheduleEvent(EVENT_FLAMESTRIKE, 6000);
events.ScheduleEvent(EVENT_FROSTBOLT, 9000);
events.ScheduleEvent(EVENT_CHAINS_OF_ICE, 12000);
events.ScheduleEvent(EVENT_HALLUCINATION, 40000);
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FIREBALL:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_FIREBALL);
events.ScheduleEvent(EVENT_FIREBALL, 15000);
return;
case EVENT_FLAMESTRIKE:
DoCast(SPELL_FLAMESTRIKE);
events.ScheduleEvent(EVENT_FLAMESTRIKE, 15000);
return;
case EVENT_FROSTBOLT:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_FROSTBOLT);
events.ScheduleEvent(EVENT_FROSTBOLT, 15000);
return;
case EVENT_CHAINS_OF_ICE:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_CHAINS_OF_ICE);
events.ScheduleEvent(EVENT_CHAINS_OF_ICE, 15000);
return;
case EVENT_HALLUCINATION:
DoCast(SPELL_HALLUCINATION);
return;
}
}
<API key>();
}
};
};
class <API key> : public CreatureScript
{
public:
<API key>() : CreatureScript("<API key>") { }
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
struct <API key> : public npc_phantom_mage::npc_phantom_mageAI
{
<API key>(Creature* creature) : npc_phantom_mage::npc_phantom_mageAI(creature)
{
}
void JustDied(Unit* /*killer*/)
{
DoCast(<API key>);
}
};
};
class <API key> : public CreatureScript
{
public:
<API key>() : CreatureScript("<API key>") { }
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
struct <API key>: public ScriptedAI
{
<API key>(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void EnterCombat(Unit* /*who*/)
{
events.ScheduleEvent(EVENT_SHADOW_STEP, 8000); // TODO: adjust timers
events.ScheduleEvent(EVENT_DEADLY_POISON, 5000);
events.ScheduleEvent(<API key>, 10000);
events.ScheduleEvent(EVENT_KIDNEY_SHOT, 12000);
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SHADOW_STEP:
DoCast(SPELL_SHADOW_STEP);
events.ScheduleEvent(EVENT_SHADOW_STEP, 8000);
return;
case EVENT_DEADLY_POISON:
DoCast(me->getVictim(), SPELL_DEADLY_POISON);
events.ScheduleEvent(EVENT_DEADLY_POISON, 10000);
return;
case <API key>:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, <API key>);
events.ScheduleEvent(<API key>, 10000);
return;
case EVENT_KIDNEY_SHOT:
DoCast(me->getVictim(), SPELL_KIDNEY_SHOT);
events.ScheduleEvent(EVENT_KIDNEY_SHOT, 10000);
return;
}
}
<API key>();
}
};
};
class <API key> : public CreatureScript
{
public:
<API key>() : CreatureScript("<API key>") { }
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
struct <API key>: public ScriptedAI
{
<API key>(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void EnterCombat(Unit* /*who*/)
{
events.ScheduleEvent(<API key>, 5000); // TODO: adjust timers
events.ScheduleEvent(EVENT_SHIELD_BASH, 10000);
events.ScheduleEvent(<API key>, 15000);
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case <API key>:
DoCast(me->getVictim(), <API key>);
events.ScheduleEvent(<API key>, 5000);
return;
case EVENT_SHIELD_BASH:
DoCast(me->getVictim(), SPELL_SHIELD_BASH);
events.ScheduleEvent(EVENT_SHIELD_BASH, 5000);
return;
case <API key>:
DoCast(<API key>);
events.ScheduleEvent(<API key>, 15000);
return;
}
}
<API key>();
}
};
};
class <API key> : public CreatureScript
{
public:
<API key>() : CreatureScript("<API key>") { }
CreatureAI* GetAI(Creature* creature) const
{
return new <API key>(creature);
}
struct <API key> : public ScriptedAI
{
<API key>(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void EnterCombat(Unit* /*who*/)
{
events.ScheduleEvent(EVENT_SHOOT, 2000); // TODO: adjust timers
events.ScheduleEvent(EVENT_CURSED_ARROW, 10000);
events.ScheduleEvent(EVENT_FROST_TRAP, 1000);
events.ScheduleEvent(EVENT_ICE_SHOT, 15000);
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SHOOT:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_SHOOT);
events.ScheduleEvent(EVENT_SHOOT, 2000);
return;
case EVENT_CURSED_ARROW:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_CURSED_ARROW);
events.ScheduleEvent(EVENT_CURSED_ARROW, 10000);
return;
case EVENT_FROST_TRAP:
DoCast(SPELL_FROST_TRAP);
events.ScheduleEvent(EVENT_FROST_TRAP, 30000);
return;
case EVENT_ICE_SHOT:
if (Unit* target = SelectTarget(<API key>))
DoCast(target, SPELL_ICE_SHOT);
events.ScheduleEvent(EVENT_ICE_SHOT, 15000);
return;
}
}
<API key>();
}
};
};
void <API key>()
{
new <API key>(true, "<API key>");
new <API key>(false, "npc_jaina_hor_part1");
new npc_ghostly_priest();
new npc_phantom_mage();
new <API key>();
new <API key>();
new <API key>();
new <API key>();
}
|
"""
Test cases adapted from the test_bsddb.py module in Python's
regression test suite.
"""
import sys, os, string
import unittest
import tempfile
from test_all import verbose
try:
# For Python 2.3
from bsddb import db, hashopen, btopen, rnopen
except ImportError:
# For earlier Pythons w/distutils pybsddb
from bsddb3 import db, hashopen, btopen, rnopen
class <API key>(unittest.TestCase):
def setUp(self):
self.filename = tempfile.mktemp()
def tearDown(self):
try:
os.remove(self.filename)
except os.error:
pass
def test01_btopen(self):
self.do_bthash_test(btopen, 'btopen')
def test02_hashopen(self):
self.do_bthash_test(hashopen, 'hashopen')
def test03_rnopen(self):
data = string.split("The quick brown fox jumped over the lazy dog.")
if verbose:
print "\nTesting: rnopen"
f = rnopen(self.filename, 'c')
for x in range(len(data)):
f[x+1] = data[x]
getTest = (f[1], f[2], f[3])
if verbose:
print '%s %s %s' % getTest
assert getTest[1] == 'quick', 'data mismatch!'
f[25] = 'twenty-five'
f.close()
del f
f = rnopen(self.filename, 'w')
f[20] = 'twenty'
def noRec(f):
rec = f[15]
self.assertRaises(KeyError, noRec, f)
def badKey(f):
rec = f['a string']
self.assertRaises(TypeError, badKey, f)
del f[3]
rec = f.first()
while rec:
if verbose:
print rec
try:
rec = f.next()
except KeyError:
break
f.close()
def test04_n_flag(self):
f = hashopen(self.filename, 'n')
f.close()
def do_bthash_test(self, factory, what):
if verbose:
print '\nTesting: ', what
f = factory(self.filename, 'c')
if verbose:
print 'creation...'
# truth test
if f:
if verbose: print "truth test: true"
else:
if verbose: print "truth test: false"
f['0'] = ''
f['a'] = 'Guido'
f['b'] = 'van'
f['c'] = 'Rossum'
f['d'] = 'invented'
f['f'] = 'Python'
if verbose:
print '%s %s %s' % (f['a'], f['b'], f['c'])
if verbose:
print 'key ordering...'
f.set_location(f.first()[0])
while 1:
try:
rec = f.next()
except KeyError:
assert rec == f.last(), 'Error, last <> last!'
f.previous()
break
if verbose:
print rec
assert f.has_key('f'), 'Error, missing key!'
f.sync()
f.close()
# truth test
try:
if f:
if verbose: print "truth test: true"
else:
if verbose: print "truth test: false"
except db.DBError:
pass
else:
self.fail("Exception expected")
del f
if verbose:
print 'modification...'
f = factory(self.filename, 'w')
f['d'] = 'discovered'
if verbose:
print 'access...'
for key in f.keys():
word = f[key]
if verbose:
print word
def noRec(f):
rec = f['no such key']
self.assertRaises(KeyError, noRec, f)
def badKey(f):
rec = f[15]
self.assertRaises(TypeError, badKey, f)
f.close()
def test_suite():
return unittest.makeSuite(<API key>)
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
|
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
jimport('joomla.application.component.view');
/**
* Description of <API key>
*
* @author stuart
*/
class <API key> extends JView {
function display($tpl = null) {
if(!$this->get(ucfirst($this->network) . 'Cache')){
$adminmodel = &$this->getModel();
}
$this->assignRef('cache', $cache);
parent::display($tpl);
}
}
?>
|
/* Delay between tap_code register and unregister to fix flaky media keys. */
#undef TAP_CODE_DELAY
#define TAP_CODE_DELAY 10
/* Turn off RGB lighting when the host goes to sleep. */
#define RGBLIGHT_SLEEP
/* Keep backlight and RGB level increments consistent across keyboards. */
#undef BACKLIGHT_LEVELS
#undef RGBLIGHT_HUE_STEP
#undef RGBLIGHT_SAT_STEP
#undef RGBLIGHT_VAL_STEP
#define BACKLIGHT_LEVELS 7
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 17
#define RGBLIGHT_VAL_STEP 17
/* Make mouse operation smoother. */
#undef MOUSEKEY_DELAY
#undef MOUSEKEY_INTERVAL
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_INTERVAL 16
/* Lower mouse speed to adjust for reduced MOUSEKEY_INTERVAL. */
#undef MOUSEKEY_MAX_SPEED
#undef <API key>
#undef <API key>
#undef <API key>
#define MOUSEKEY_MAX_SPEED 7
#define <API key> 150
#define <API key> 3
#define <API key> 150
|
#ifndef _CAPI2_CC_DS_H_
#define _CAPI2_CC_DS_H_
/**
* @addtogroup CAPI2_CCAPIGroup
* @{
*/
// Data Definitions used by CAPI2 only
#define PHONE_NUMBER_LEN 82
/**
Phone number dial string
**/
typedef struct
{
char phone_number[PHONE_NUMBER_LEN]; ///< NULL terminated dial string
} PHONE_NUMBER_STR_t;
/**
States for all non-idle calls
**/
typedef struct
{
CCallStateList_t stateList; ///< Call state array
UInt8 listSz; ///< Number of call states
} ALL_CALL_STATE_t;
/**
Indices for all non-idle calls
**/
typedef struct
{
CCallIndexList_t indexList; ///< Call index array
UInt8 listSz; ///< Number of call indices
} ALL_CALL_INDEX_t;
#endif
|
#include "qemu/osdep.h"
#include <linux/vhost.h>
#include <linux/vfio.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-backend.h"
#include "hw/virtio/virtio-net.h"
#include "hw/virtio/vhost-vdpa.h"
#include "qemu/main-loop.h"
#include "cpu.h"
static bool <API key>(MemoryRegionSection *section)
{
return (!<API key>(section->mr) &&
!<API key>(section->mr)) ||
/*
* Sizing an enabled 64-bit BAR can cause spurious mappings to
* addresses in the upper part of the 64-bit address space. These
* are never accessed by the CPU and beyond the address width of
* some IOMMU hardware. TODO: VDPA should tell us the IOMMU width.
*/
section-><API key> & (1ULL << 63);
}
static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
void *vaddr, bool readonly)
{
struct vhost_msg_v2 msg = {};
int fd = v->device_fd;
int ret = 0;
msg.type = v->msg_type;
msg.iotlb.iova = iova;
msg.iotlb.size = size;
msg.iotlb.uaddr = (uint64_t)(uintptr_t)vaddr;
msg.iotlb.perm = readonly ? VHOST_ACCESS_RO : VHOST_ACCESS_RW;
msg.iotlb.type = VHOST_IOTLB_UPDATE;
if (write(fd, &msg, sizeof(msg)) != sizeof(msg)) {
error_report("failed to write, fd=%d, errno=%d (%s)",
fd, errno, strerror(errno));
return -EIO ;
}
return ret;
}
static int <API key>(struct vhost_vdpa *v, hwaddr iova,
hwaddr size)
{
struct vhost_msg_v2 msg = {};
int fd = v->device_fd;
int ret = 0;
msg.type = v->msg_type;
msg.iotlb.iova = iova;
msg.iotlb.size = size;
msg.iotlb.type = <API key>;
if (write(fd, &msg, sizeof(msg)) != sizeof(msg)) {
error_report("failed to write, fd=%d, errno=%d (%s)",
fd, errno, strerror(errno));
return -EIO ;
}
return ret;
}
static void <API key>(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener);
hwaddr iova;
Int128 llend, llsize;
void *vaddr;
int ret;
if (<API key>(section)) {
return;
}
if (unlikely((section-><API key> & ~TARGET_PAGE_MASK) !=
(section-><API key> & ~TARGET_PAGE_MASK))) {
error_report("%s received unaligned region", __func__);
return;
}
iova = TARGET_PAGE_ALIGN(section-><API key>);
llend = int128_make64(section-><API key>);
llend = int128_add(llend, section->size);
llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
if (int128_ge(int128_make64(iova), llend)) {
return;
}
memory_region_ref(section->mr);
/* Here we assume that <API key>(section->mr)==true */
vaddr = <API key>(section->mr) +
section-><API key> +
(iova - section-><API key>);
llsize = int128_sub(llend, int128_make64(iova));
ret = vhost_vdpa_dma_map(v, iova, int128_get64(llsize),
vaddr, section->readonly);
if (ret) {
error_report("vhost vdpa map fail!");
if (<API key>(section->mr)) {
/* Allow unexpected mappings not to be fatal for RAM devices */
error_report("map ram fail!");
return ;
}
goto fail;
}
return;
fail:
if (<API key>(section->mr)) {
error_report("failed to vdpa_dma_map. pci p2p may not work");
return;
}
/*
* On the initfn path, store the first error in the container so we
* can gracefully fail. Runtime, there's not much we can do other
* than throw a hardware error.
*/
error_report("vhost-vdpa: DMA mapping failed, unable to continue");
return;
}
static void <API key>(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener);
hwaddr iova;
Int128 llend, llsize;
int ret;
bool try_unmap = true;
if (<API key>(section)) {
return;
}
if (unlikely((section-><API key> & ~TARGET_PAGE_MASK) !=
(section-><API key> & ~TARGET_PAGE_MASK))) {
error_report("%s received unaligned region", __func__);
return;
}
iova = TARGET_PAGE_ALIGN(section-><API key>);
llend = int128_make64(section-><API key>);
llend = int128_add(llend, section->size);
llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
if (int128_ge(int128_make64(iova), llend)) {
return;
}
llsize = int128_sub(llend, int128_make64(iova));
if (try_unmap) {
ret = <API key>(v, iova, int128_get64(llsize));
if (ret) {
error_report("vhost_vdpa dma unmap error!");
}
}
memory_region_unref(section->mr);
}
/*
* IOTLB API is used by vhost-vpda which requires incremental updating
* of the mapping. So we can not use generic vhost memory listener which
* depends on the addnop().
*/
static const MemoryListener <API key> = {
.region_add = <API key>,
.region_del = <API key>,
};
static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int request,
void *arg)
{
struct vhost_vdpa *v = dev->opaque;
int fd = v->device_fd;
assert(dev->vhost_ops->backend_type == <API key>);
return ioctl(fd, request, arg);
}
static void <API key>(struct vhost_dev *dev, uint8_t status)
{
uint8_t s;
if (vhost_vdpa_call(dev, <API key>, &s)) {
return;
}
s |= status;
vhost_vdpa_call(dev, <API key>, &s);
}
static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque)
{
struct vhost_vdpa *v;
uint64_t features;
assert(dev->vhost_ops->backend_type == <API key>);
v = opaque;
dev->opaque = opaque ;
vhost_vdpa_call(dev, VHOST_GET_FEATURES, &features);
dev->backend_features = features;
v->listener = <API key>;
v->msg_type = VHOST_IOTLB_MSG_V2;
<API key>(dev, <API key> |
<API key>);
return 0;
}
static int vhost_vdpa_cleanup(struct vhost_dev *dev)
{
struct vhost_vdpa *v;
assert(dev->vhost_ops->backend_type == <API key>);
v = dev->opaque;
<API key>(&v->listener);
dev->opaque = NULL;
return 0;
}
static int <API key>(struct vhost_dev *dev)
{
return INT_MAX;
}
static int <API key>(struct vhost_dev *dev,
struct vhost_memory *mem)
{
if (mem->padding) {
return -1;
}
return 0;
}
static int <API key>(struct vhost_dev *dev,
uint64_t features)
{
int ret;
ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features);
uint8_t status = 0;
if (ret) {
return ret;
}
<API key>(dev, <API key>);
vhost_vdpa_call(dev, <API key>, &status);
return !(status & <API key>);
}
int <API key>(struct vhost_dev *dev,
uint32_t *device_id)
{
return vhost_vdpa_call(dev, <API key>, device_id);
}
static int <API key>(struct vhost_dev *dev)
{
uint8_t status = 0;
return vhost_vdpa_call(dev, <API key>, &status);
}
static int <API key>(struct vhost_dev *dev, int idx)
{
assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
return idx - dev->vq_index;
}
static int <API key>(struct vhost_dev *dev)
{
int i;
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_vring_state state = {
.index = dev->vq_index + i,
.num = 1,
};
vhost_vdpa_call(dev, <API key>, &state);
}
return 0;
}
static int <API key>(struct vhost_dev *dev, const uint8_t *data,
uint32_t offset, uint32_t size,
uint32_t flags)
{
struct vhost_vdpa_config *config;
int ret;
unsigned long config_size = offsetof(struct vhost_vdpa_config, buf);
config = g_malloc(size + config_size);
if (config == NULL) {
return -1;
}
config->off = offset;
config->len = size;
memcpy(config->buf, data, size);
ret = vhost_vdpa_call(dev, <API key>, config);
g_free(config);
return ret;
}
static int <API key>(struct vhost_dev *dev, uint8_t *config,
uint32_t config_len)
{
struct vhost_vdpa_config *v_config;
unsigned long config_size = offsetof(struct vhost_vdpa_config, buf);
int ret;
v_config = g_malloc(config_len + config_size);
if (v_config == NULL) {
return -1;
}
v_config->len = config_len;
v_config->off = 0;
ret = vhost_vdpa_call(dev, <API key>, v_config);
memcpy(config, v_config->buf, config_len);
g_free(v_config);
return ret;
}
static int <API key>(struct vhost_dev *dev, bool started)
{
struct vhost_vdpa *v = dev->opaque;
if (started) {
uint8_t status = 0;
<API key>(&v->listener, &<API key>);
<API key>(dev);
<API key>(dev, <API key>);
vhost_vdpa_call(dev, <API key>, &status);
return !(status & <API key>);
} else {
<API key>(dev);
<API key>(dev, <API key> |
<API key>);
<API key>(&v->listener);
return 0;
}
}
static int <API key>(struct vhost_dev *dev, uint64_t base,
struct vhost_log *log)
{
return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_addr *addr)
{
return vhost_vdpa_call(dev, <API key>, addr);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_state *ring)
{
return vhost_vdpa_call(dev, VHOST_SET_VRING_NUM, ring);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_state *ring)
{
return vhost_vdpa_call(dev, <API key>, ring);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_state *ring)
{
return vhost_vdpa_call(dev, <API key>, ring);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_file *file)
{
return vhost_vdpa_call(dev, <API key>, file);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_file *file)
{
return vhost_vdpa_call(dev, <API key>, file);
}
static int <API key>(struct vhost_dev *dev,
uint64_t *features)
{
return vhost_vdpa_call(dev, VHOST_GET_FEATURES, features);
}
static int <API key>(struct vhost_dev *dev)
{
return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL);
}
static int <API key>(struct vhost_dev *dev,
struct vhost_vring_addr *addr, struct vhost_virtqueue *vq)
{
assert(dev->vhost_ops->backend_type == <API key>);
addr->desc_user_addr = (uint64_t)(unsigned long)vq->desc_phys;
addr->avail_user_addr = (uint64_t)(unsigned long)vq->avail_phys;
addr->used_user_addr = (uint64_t)(unsigned long)vq->used_phys;
return 0;
}
static bool <API key>(struct vhost_dev *dev)
{
return true;
}
const VhostOps vdpa_ops = {
.backend_type = <API key>,
.vhost_backend_init = vhost_vdpa_init,
.<API key> = vhost_vdpa_cleanup,
.vhost_set_log_base = <API key>,
.<API key> = <API key>,
.vhost_set_vring_num = <API key>,
.<API key> = <API key>,
.<API key> = <API key>,
.<API key> = <API key>,
.<API key> = <API key>,
.vhost_get_features = <API key>,
.vhost_set_owner = <API key>,
.<API key> = NULL,
.<API key> = <API key>,
.vhost_set_mem_table = <API key>,
.vhost_set_features = <API key>,
.vhost_reset_device = <API key>,
.vhost_get_vq_index = <API key>,
.vhost_get_config = <API key>,
.vhost_set_config = <API key>,
.<API key> = NULL,
.<API key> = NULL,
.<API key> = NULL,
.vhost_net_set_mtu = NULL,
.<API key> = NULL,
.<API key> = NULL,
.vhost_dev_start = <API key>,
.vhost_get_device_id = <API key>,
.vhost_vq_get_addr = <API key>,
.vhost_force_iommu = <API key>,
};
|
#include "<API key>.h"
#include "kis_debug.h"
#include <KoIcon.h>
#include <KoColor.h>
#include <KoColorSpace.h>
#include <<API key>.h>
#include "kis_paint_device.h"
#include "kis_painter.h"
#include "kis_node_visitor.h"
#include "<API key>.h"
KisTransparencyMask::KisTransparencyMask()
: KisEffectMask()
{
}
KisTransparencyMask::KisTransparencyMask(const KisTransparencyMask& rhs)
: KisEffectMask(rhs)
{
}
KisTransparencyMask::~KisTransparencyMask()
{
}
bool KisTransparencyMask::allowAsChild(KisNodeSP node) const
{
Q_UNUSED(node);
return false;
}
QRect KisTransparencyMask::decorateRect(KisPaintDeviceSP &src,
KisPaintDeviceSP &dst,
const QRect & rc) const
{
if (src != dst) {
KisPainter gc(dst);
gc.setCompositeOp(src->colorSpace()->compositeOp(COMPOSITE_COPY));
gc.bitBlt(rc.topLeft(), src, rc);
src->fill(rc, KoColor(Qt::transparent, src->colorSpace()));
}
return rc;
}
QRect KisTransparencyMask::extent() const
{
return parent() ? parent()->extent() : QRect();
}
QRect KisTransparencyMask::exactBounds() const
{
return parent() ? parent()->exactBounds() : QRect();
}
QRect KisTransparencyMask::changeRect(const QRect &rect, PositionToFilthy pos) const
{
/**
* Selection on transparency masks have no special meaning:
* They do crop both: change and need area
*/
return KisMask::changeRect(rect, pos);
}
QRect KisTransparencyMask::needRect(const QRect &rect, PositionToFilthy pos) const
{
/**
* Selection on transparency masks have no special meaning:
* They do crop both: change and need area
*/
return KisMask::needRect(rect, pos);
}
QIcon KisTransparencyMask::icon() const
{
return koIcon("view-filter");
}
bool KisTransparencyMask::accept(KisNodeVisitor &v)
{
return v.visit(this);
}
void KisTransparencyMask::accept(<API key> &visitor, KisUndoAdapter *undoAdapter)
{
return visitor.visit(this, undoAdapter);
}
#include "<API key>.moc"
|
<?php
namespace eZ\Publish\Core\Limitation\Tests;
use eZ\Publish\API\Repository\Values\ValueObject;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Values\Content\<API key>;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
use eZ\Publish\API\Repository\Values\User\Limitation;
use eZ\Publish\API\Repository\Values\User\Limitation\<API key>;
use eZ\Publish\API\Repository\Values\User\Limitation\<API key>;
use eZ\Publish\Core\Base\Exceptions\NotFoundException;
use eZ\Publish\Core\Limitation\<API key>;
use eZ\Publish\Core\Repository\Values\Content\Location;
use eZ\Publish\Core\Repository\Values\Content\ContentCreateStruct;
use eZ\Publish\SPI\Persistence\Content\ContentInfo as SPIContentInfo;
use eZ\Publish\SPI\Persistence\Content\Location as SPILocation;
use eZ\Publish\SPI\Persistence\Content\Type as SPIContentType;
/**
* Test Case for LimitationType
*/
class <API key> extends Base
{
/**
* @var \eZ\Publish\SPI\Persistence\Content\Location\Handler|\<API key>
*/
private $locationHandlerMock;
/**
* @var \eZ\Publish\SPI\Persistence\Content\Type\Handler|\<API key>
*/
private $<API key>;
/**
* @var \eZ\Publish\SPI\Persistence\Content\Handler|\<API key>
*/
private $contentHandlerMock;
/**
* Setup Location Handler mock
*/
public function setUp()
{
parent::setUp();
$this->locationHandlerMock = $this->getMock(
"eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler",
array(),
array(),
'',
false
);
$this-><API key> = $this->getMock(
"eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler",
array(),
array(),
'',
false
);
$this->contentHandlerMock = $this->getMock(
"eZ\\Publish\\SPI\\Persistence\\Content\\Handler",
array(),
array(),
'',
false
);
}
/**
* Tear down Location Handler mock
*/
public function tearDown()
{
unset( $this->locationHandlerMock );
unset( $this-><API key> );
unset( $this->contentHandlerMock );
parent::tearDown();
}
/**
*
* @return \eZ\Publish\Core\Limitation\<API key>
*/
public function testConstruct()
{
return new <API key>( $this->getPersistenceMock() );
}
/**
* @return array
*/
public function <API key>()
{
return array(
array( new <API key>() ),
array( new <API key>( array() ) ),
array( new <API key>( array( 'limitationValues' => array( '', 'true', '2', 's3fd4af32r' ) ) ) ),
);
}
/**
* @dataProvider <API key>
* @depends testConstruct
*
* @param \eZ\Publish\API\Repository\Values\User\Limitation\<API key> $limitation
* @param \eZ\Publish\Core\Limitation\<API key> $limitationType
*/
public function testAcceptValue( <API key> $limitation, <API key> $limitationType )
{
$limitationType->acceptValue( $limitation );
}
/**
* @return array
*/
public function <API key>()
{
return array(
array( new <API key>() ),
array( new <API key>( array( 'limitationValues' => array( true ) ) ) ),
array( new <API key>( array( 'limitationValues' => array( new \DateTime ) ) ) ),
);
}
/**
* @dataProvider <API key>
* @depends testConstruct
* @expectedException \eZ\Publish\API\Repository\Exceptions\<API key>
*
* @param \eZ\Publish\API\Repository\Values\User\Limitation $limitation
* @param \eZ\Publish\Core\Limitation\<API key> $limitationType
*/
public function <API key>( Limitation $limitation, <API key> $limitationType )
{
$limitationType->acceptValue( $limitation );
}
/**
* @return array
*/
public function <API key>()
{
return array(
array( new <API key>() ),
array( new <API key>( array() ) ),
array( new <API key>( array( 'limitationValues' => array( '1' ) ) ) ),
);
}
/**
* @dataProvider <API key>
*
* @param \eZ\Publish\API\Repository\Values\User\Limitation\<API key> $limitation
*/
public function testValidatePass( <API key> $limitation )
{
if ( !empty( $limitation->limitationValues ) )
{
$this->getPersistenceMock()
->expects( $this->any() )
->method( "contentTypeHandler" )
->will( $this->returnValue( $this-><API key> ) );
foreach ( $limitation->limitationValues as $key => $value )
{
$this-><API key>
->expects( $this->at( $key ) )
->method( "load" )
->with( $value )
->will( $this->returnValue( 42 ) );
}
}
// Need to create inline instead of depending on testConstruct() to get correct mock instance
$limitationType = $this->testConstruct();
$validationErrors = $limitationType->validate( $limitation );
self::assertEmpty( $validationErrors );
}
/**
* @return array
*/
public function <API key>()
{
return array(
array( new <API key>(), 0 ),
array( new <API key>( array( 'limitationValues' => array( '/1/777/' ) ) ), 1 ),
array( new <API key>( array( 'limitationValues' => array( '/1/888/', '/1/999/' ) ) ), 2 ),
);
}
/**
* @dataProvider <API key>
*
* @param \eZ\Publish\API\Repository\Values\User\Limitation\<API key> $limitation
* @param int $errorCount
*/
public function testValidateError( <API key> $limitation, $errorCount )
{
if ( !empty( $limitation->limitationValues ) )
{
$this->getPersistenceMock()
->expects( $this->any() )
->method( "contentTypeHandler" )
->will( $this->returnValue( $this-><API key> ) );
foreach ( $limitation->limitationValues as $key => $value )
{
$this-><API key>
->expects( $this->at( $key ) )
->method( "load" )
->with( $value )
->will( $this->throwException( new NotFoundException( 'location', $value ) ) );
}
}
else
{
$this->getPersistenceMock()
->expects( $this->never() )
->method( $this->anything() );
}
// Need to create inline instead of depending on testConstruct() to get correct mock instance
$limitationType = $this->testConstruct();
$validationErrors = $limitationType->validate( $limitation );
self::assertCount( $errorCount, $validationErrors );
}
/**
* @depends testConstruct
*
* @param \eZ\Publish\Core\Limitation\<API key> $limitationType
*/
public function testBuildValue( <API key> $limitationType )
{
$expected = array( 'test', 'test' => '1' );
$value = $limitationType->buildValue( $expected );
self::assertInstanceOf( '\eZ\Publish\API\Repository\Values\User\Limitation\<API key>', $value );
self::assertInternalType( 'array', $value->limitationValues );
self::assertEquals( $expected, $value->limitationValues );
}
protected function <API key>()
{
$contentMock = $this->getMock(
"eZ\\Publish\\API\\Repository\\Values\\Content\\Content",
array(),
array(),
'',
false
);
$contentMock
->expects( $this->once() )
->method( 'getVersionInfo' )
->will( $this->returnValue( $this-><API key>() ) );
return $contentMock;
}
protected function <API key>()
{
$versionInfoMock = $this->getMock(
"eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo",
array(),
array(),
'',
false
);
$versionInfoMock
->expects( $this->once() )
->method( 'getContentInfo' )
->will( $this->returnValue( new ContentInfo( array( 'published' => true ) ) ) );
return $versionInfoMock;
}
/**
* @return array
*/
public function <API key>()
{
return array(
// ContentInfo, with API targets, no access
array(
'limitation' => new <API key>(),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new Location( array( "contentInfo" => new ContentInfo( array( "contentTypeId" => 24 ) ) ) ) ),
'persistence' => array(),
'expected' => false
),
// ContentInfo, with SPI targets, no access
array(
'limitation' => new <API key>(),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new SPILocation( array( "contentId" => 42 ) ) ),
'persistence' => array(
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "24" ) ) )
),
'expected' => false
),
// ContentInfo, with API targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new Location( array( "contentInfo" => new ContentInfo( array( "contentTypeId" => 24 ) ) ) ) ),
'persistence' => array(),
'expected' => false
),
// ContentInfo, with SPI targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new SPILocation( array( "contentId" => 42 ) ) ),
'persistence' => array(
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "24" ) ) )
),
'expected' => false
),
// ContentInfo, with API targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new Location( array( "contentInfo" => new ContentInfo( array( "contentTypeId" => 42 ) ) ) ) ),
'persistence' => array(),
'expected' => true
),
// ContentInfo, with SPI targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array( new SPILocation( array( "contentId" => 24 ) ) ),
'persistence' => array(
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// ContentInfo, no targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array(),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => '24' ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// ContentInfo, no targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => true ) ),
'targets' => array(),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => '24' ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "4200" ) ) )
),
'expected' => false
),
// ContentInfo, no targets, un-published, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => false ) ),
'targets' => array(),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => '24' ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// ContentInfo, no targets, un-published, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentInfo( array( 'published' => false ) ),
'targets' => array(),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => '24' ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "4200" ) ) )
),
'expected' => false
),
// Content, with API targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new Location( array( "contentInfo" => new ContentInfo( array( "contentTypeId" => 42 ) ) ) ) ),
'persistence' => array(),
'expected' => true
),
// Content, with SPI targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new SPILocation( array( 'contentId' => '24' ) ) ),
'persistence' => array(
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// VersionInfo, with API targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new Location( array( "contentInfo" => new ContentInfo( array( "contentTypeId" => 42 ) ) ) ) ),
'persistence' => array(),
'expected' => true
),
// VersionInfo, with SPI targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new SPILocation( array( 'contentId' => '24' ) ) ),
'persistence' => array(
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// VersionInfo, with <API key> targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new <API key>( array( 'parentLocationId' => 24 ) ) ),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => 100 ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "42" ) ) )
),
'expected' => true
),
// Content, with <API key> targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => $this-><API key>(),
'targets' => array( new <API key>( array( 'parentLocationId' => 24 ) ) ),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => 100 ) ) ),
"contentInfos" => array( new SPIContentInfo( array( "contentTypeId" => "24" ) ) )
),
'expected' => false
),
// ContentCreateStruct, no targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 42 ) ) ),
'object' => new ContentCreateStruct(),
'targets' => array(),
'persistence' => array(),
'expected' => false
),
// ContentCreateStruct, with <API key> targets, no access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 12, 23 ) ) ),
'object' => new ContentCreateStruct(),
'targets' => array( new <API key>( array( 'parentLocationId' => 24 ) ) ),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => 100 ) ) ),
"contentInfos" => array( new SPIContentInfo( array( 'contentTypeId' => 34 ) ) )
),
'expected' => false
),
// ContentCreateStruct, with <API key> targets, with access
array(
'limitation' => new <API key>( array( 'limitationValues' => array( 12, 23 ) ) ),
'object' => new ContentCreateStruct(),
'targets' => array( new <API key>( array( 'parentLocationId' => 43 ) ) ),
'persistence' => array(
"locations" => array( new SPILocation( array( 'contentId' => 100 ) ) ),
"contentInfos" => array( new SPIContentInfo( array( 'contentTypeId' => 12 ) ) )
),
'expected' => true
),
);
}
protected function <API key>( $callNo, $persistenceCalled, $contentId, $contentInfo )
{
$this->getPersistenceMock()
->expects( $this->at( $callNo + ( $persistenceCalled ? 1 : 0 ) ) )
->method( "contentHandler" )
->will( $this->returnValue( $this->contentHandlerMock ) );
$this->contentHandlerMock
->expects( $this->at( $callNo ) )
->method( "loadContentInfo" )
->with( $contentId )
->will( $this->returnValue( $contentInfo ) );
}
/**
* @dataProvider <API key>
*/
public function testEvaluate(
<API key> $limitation,
ValueObject $object,
$targets,
array $persistence,
$expected
)
{
// Need to create inline instead of depending on testConstruct() to get correct mock instance
$limitationType = $this->testConstruct();
$userMock = $this->getUserMock();
$userMock
->expects( $this->never() )
->method( $this->anything() );
$persistenceMock = $this->getPersistenceMock();
// ContentTypeHandler is never used in evaluate()
$persistenceMock
->expects( $this->never() )
->method( "contentTypeHandler" );
if ( empty( $persistence ) )
{
// Covers API targets, where no additional loading is required
$persistenceMock
->expects( $this->never() )
->method( $this->anything() );
}
else if ( !empty( $targets ) )
{
foreach ( $targets as $index => $target )
{
if ( $target instanceof <API key> )
{
$this->getPersistenceMock()
->expects( $this->once( $index ) )
->method( "locationHandler" )
->will( $this->returnValue( $this->locationHandlerMock ) );
$this->locationHandlerMock
->expects( $this->at( $index ) )
->method( "load" )
->with( $target->parentLocationId )
->will( $this->returnValue( $location = $persistence["locations"][$index] ) );
$contentId = $location->contentId;
}
else
{
$contentId = $target->contentId;
}
$this-><API key>(
$index,
$target instanceof <API key>,
$contentId,
$persistence["contentInfos"][$index]
);
}
}
else
{
$this->getPersistenceMock()
->expects( $this->at( 0 ) )
->method( "locationHandler" )
->will( $this->returnValue( $this->locationHandlerMock ) );
$this->locationHandlerMock
->expects( $this->once() )
->method(
$object instanceof ContentInfo && $object->published ?
"<API key>" :
"<API key>"
)
->with( $object->id )
->will( $this->returnValue( $persistence["locations"] ) );
foreach ( $persistence["locations"] as $index => $location )
{
$this-><API key>(
$index,
true,
$location->contentId,
$persistence["contentInfos"][$index]
);
}
}
$value = $limitationType->evaluate(
$limitation,
$userMock,
$object,
$targets
);
self::assertInternalType( 'boolean', $value );
self::assertEquals( $expected, $value );
}
/**
* @return array
*/
public function <API key>()
{
return array(
// invalid limitation
array(
'limitation' => new <API key>(),
'object' => new ContentInfo(),
'targets' => array( new Location() ),
'persistence' => array(),
),
// invalid object
array(
'limitation' => new <API key>(),
'object' => new <API key>(),
'targets' => array(),
'persistence' => array(),
),
// invalid target when using ContentCreateStruct
array(
'limitation' => new <API key>(),
'object' => new ContentCreateStruct(),
'targets' => array( new Location() ),
'persistence' => array(),
),
// invalid target when not using ContentCreateStruct
array(
'limitation' => new <API key>(),
'object' => new ContentInfo(),
'targets' => array( new <API key>() ),
'persistence' => array(),
),
);
}
/**
* @dataProvider <API key>
* @expectedException \eZ\Publish\API\Repository\Exceptions\<API key>
*/
public function <API key>( Limitation $limitation, ValueObject $object, $targets )
{
// Need to create inline instead of depending on testConstruct() to get correct mock instance
$limitationType = $this->testConstruct();
$userMock = $this->getUserMock();
$userMock
->expects( $this->never() )
->method( $this->anything() );
$persistenceMock = $this->getPersistenceMock();
$persistenceMock
->expects( $this->never() )
->method( $this->anything() );
$limitationType->evaluate(
$limitation,
$userMock,
$object,
$targets
);
}
/**
* @depends testConstruct
* @expectedException \eZ\Publish\API\Repository\Exceptions\<API key>
*
* @param \eZ\Publish\Core\Limitation\<API key> $limitationType
*/
public function <API key>( <API key> $limitationType )
{
$limitationType->getCriterion(
new <API key>( array() ),
$this->getUserMock()
);
}
/**
* @depends testConstruct
*
* @param \eZ\Publish\Core\Limitation\<API key> $limitationType
*/
public function testValueSchema( <API key> $limitationType )
{
$this->markTestIncomplete( "Method is not implemented yet: " . __METHOD__ );
}
}
|
package Lacuna::DB::Result::Building::SSLa;
use Moose;
use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building';
use Lacuna::Constants qw(ORE_TYPES INFLATION);
around 'build_tags' => sub {
my ($orig, $class) = @_;
return ($orig->($class), qw(Construction Ships));
};
use constant university_prereq => 20;
use constant <API key> => 1;
use constant controller_class => 'Lacuna::RPC::Building::SSLa';
use constant image => 'ssla';
use constant name => 'Space Station Lab (A)';
use constant food_to_build => 230;
use constant energy_to_build => 350;
use constant ore_to_build => 370;
use constant water_to_build => 260;
use constant waste_to_build => 100;
use constant time_to_build => 60 * 2;
use constant food_consumption => 5;
use constant energy_consumption => 20;
use constant ore_consumption => 15;
use constant water_consumption => 6;
use constant waste_production => 20;
before 'can_demolish' => sub {
my $self = shift;
my $sslb = $self->body-><API key>('Lacuna::DB::Result::Building::SSLb');
if (defined $sslb) {
confess [1013, 'You have to demolish your Space Station Lab (B) before you can demolish your Space Station Lab (A).'];
}
};
before can_build => sub {
my $self = shift;
if ($self->x == 5 || $self->y == -5 || (($self->y == 1 || $self->y == 0) && ($self->x == -1 || $self->x == 0))) {
confess [1009, 'Space Station Lab cannot be placed in that location.'];
}
};
sub makeable_plans {
return {
command => 'Lacuna::DB::Result::Building::Module::StationCommand',
ibs => 'Lacuna::DB::Result::Building::Module::IBS',
art => 'Lacuna::DB::Result::Building::Module::ArtMuseum',
opera => 'Lacuna::DB::Result::Building::Module::OperaHouse',
food => 'Lacuna::DB::Result::Building::Module::CulinaryInstitute',
parliament => 'Lacuna::DB::Result::Building::Module::Parliament',
warehouse => 'Lacuna::DB::Result::Building::Module::Warehouse',
policestation => 'Lacuna::DB::Result::Building::Module::PoliceStation',
};
}
sub <API key> {
my $self = shift;
my @out;
my $makeable_plans = $self->makeable_plans;
while (my ($type, $class) = each %{$makeable_plans}) {
push @out, {
image => $class->image,
name => $class->name,
url => $class->controller_class->app_url,
type => $type,
};
}
@out = sort { $a->{name} cmp $b->{name} } @out;
return \@out;
}
sub <API key> {
my $self = shift;
my $max = $self->max_level;
return [] if $max == 0;
my @costs;
my $resource_cost = $self->plan_resource_cost;
my $time_cost = $self->plan_time_cost;
foreach my $level (1..$max) {
my $resource = $self->plan_cost_at_level($level, $resource_cost);
push @costs, {
level => $level,
ore => $resource,
water => $resource,
energy => $resource,
food => $resource,
waste => sprintf('%.0f', $resource/2),
time => $self->plan_time_at_level($level, $time_cost),
};
}
return \@costs;
}
has plan_resource_cost => (
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
return 850_000;
}
);
has plan_time_cost => (
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
return 150;
}
);
sub plan_time_at_level {
my ($self, $level, $base) = @_;
my $inflate = INFLATION - (($self->max_level + $self->body->empire-><API key> * 5)/200);
my $time_cost = int($base * ($inflate ** $level));
$time_cost = 15 if ($time_cost < 15);
$time_cost = 5184000 if ($time_cost > 5184000);
return $time_cost;
}
sub plan_cost_at_level {
my ($self, $level, $base) = @_;
my $inflate = INFLATION - (($self->max_level + $self->body->empire-><API key> * 5)/200);
my $cost = int($base * ($inflate ** $level));
return $cost;
}
has max_level => (
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
my $level = $self->effective_level;
my $body = $self->body;
foreach my $part (qw(b c d)) {
my $building = $body-><API key>('Lacuna::DB::Result::Building::SSL'.$part);
if (defined $building) {
$level = ($level > $building->effective_level) ? $building->effective_level : $level;
}
else {
$level = 0;
last;
}
}
return $level;
},
);
sub can_make_plan {
my ($self, $type, $level) = @_;
if ($self->is_working) {
confess [1010, 'The Space Station Lab is already making a plan.'];
}
$level ||= 1;
if ($level > $self->max_level) {
confess [1013, 'This Space Station Lab is not a high enough level to make that plan.'];
}
my $makeable = $self->makeable_plans;
unless ($type ~~ [keys %{$makeable}]) {
confess [1009, 'Cannot make that type of plan.'];
}
my $resource_cost = $self->plan_cost_at_level($level, $self->plan_resource_cost);
my $fraction = sprintf('%.0f',$resource_cost * 0.01);
my $body = $self->body;
foreach my $ore (ORE_TYPES) {
if ($body->type_stored($ore) < $fraction) {
confess [1011, 'Not enough '.$ore.' in storage. You need at least '.$fraction.'.'];
}
}
foreach my $resource (qw(ore water food energy)) {
if ($body->type_stored($resource) < $resource_cost) {
confess [1011, 'Not enough '.$resource.' in storage. You need at least '.$resource_cost.'.'];
}
}
return 1;
}
sub make_plan {
my ($self, $type, $level) = @_;
$level ||= 1;
my $makeable = $self->makeable_plans;
my $resource_cost = $self->plan_cost_at_level($level, $self->plan_resource_cost);
my $time_cost = $self->plan_time_at_level($level, $self->plan_time_cost);
my $body = $self->body;
$body->spend_ore($resource_cost);
$body->spend_water($resource_cost);
$body->spend_food($resource_cost, 0);
$body->spend_energy($resource_cost);
$body->add_waste($resource_cost/4);
$body->update;
$self->start_work({
class => $makeable->{$type},
level => $level,
}, $time_cost)->update;
}
before finish_work => sub {
my $self = shift;
my $planet = $self->body;
$planet->add_plan($self->work->{class}, $self->work->{level});
};
no Moose;
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
|
<?php
defined('_JEXEC') or die('Restricted access');
require_once(JCE_LIBRARIES .DS. 'classes' .DS. 'manager.php');
class ImageManager extends Manager
{
var $_ext = 'image=jpg,jpeg,gif,png';
/**
* @access protected
*/
function __construct()
{
parent::__construct();
// Set the file type map from parameters
$this->setFileTypes($this->getPluginParam('<API key>', $this->_ext));
// Init plugin
$this->init();
}
/**
* Returns a reference to a editor object
*
* This method must be invoked as:
* <pre> $browser = &JCE::getInstance();</pre>
*
* @access public
* @return JCE The editor object.
* @since 1.5
*/
function &getInstance()
{
static $instance;
if (!is_object($instance)) {
$instance = new ImageManager();
}
return $instance;
}
/**
* Initialise the plugin
*/
function init()
{
$this->checkPlugin() or die(JError::raiseError(403, JText::_('Access Forbidden')));
parent::init();
// Setup plugin XHR callback functions
$this->setXHR(array($this, 'getDimensions'));
// Set javascript file array
$this->script(array('imgmanager'), 'plugins');
// Set css file array
$this->css(array('imgmanager'), 'plugins');
// Load extensions if any
$this->loadExtensions();
}
/**
* Get the dimensions of an image
* @return array Dimensions as array
* @param object $file Relative path to image
*/
function getDimensions($file)
{
$path = Utils::makePath($this->getBaseDir(), rawurldecode($file));
$h = array(
'width' => '',
'height' => ''
);
if (file_exists($path)) {
$dim = @getimagesize($path);
$h = array(
'width' => $dim[0],
'height' => $dim[1]
);
}
return $h;
}
/**
* Get list of uploadable extensions
* @return Mapped extension list (list mapped to type object eg: 'images', 'jpeg,jpg,gif,png')
*/
function getUploadFileTypes()
{
$list = $this->getPluginParam('<API key>', 'image=jpg,jpeg,gif,png');
return $this->mapUploadFileTypes($list);
}
}
?>
|
/* $Id: fileaio.h $ */
/** @file
* IPRT - Internal RTFileAio header.
*/
#ifndef <API key>
#define <API key>
#include <iprt/file.h>
#include "internal/magics.h"
/**
* Defined request states.
*/
typedef enum RTFILEAIOREQSTATE
{
/** Prepared. */
<API key> = 0,
/** Submitted. */
<API key>,
/** Completed. */
<API key>,
/** Omni present 32bit hack. */
<API key> = 0x7fffffff
} RTFILEAIOREQSTATE;
/** Return true if the specified request is not valid, false otherwise. */
#define <API key>(pReq) \
(RT_UNLIKELY(!VALID_PTR(pReq) || (pReq->u32Magic != RTFILEAIOREQ_MAGIC)))
/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
#define <API key>(pReq, rc) \
do { \
AssertPtrReturn((pReq), (rc)); \
AssertReturn((pReq)->u32Magic == RTFILEAIOREQ_MAGIC, (rc)); \
} while (0)
/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
#define <API key>(pReq) <API key>((pReq), VERR_INVALID_HANDLE)
/** Validates a context handle and returns (void) if not valid. */
#define <API key>(pReq) \
do { \
AssertPtrReturnVoid(pReq); \
AssertReturnVoid((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
} while (0)
/** Validates a context handle and returns the specified rc if not valid. */
#define <API key>(pCtx, rc) \
do { \
AssertPtrReturn((pCtx), (rc)); \
AssertReturn((pCtx)->u32Magic == RTFILEAIOCTX_MAGIC, (rc)); \
} while (0)
/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
#define <API key>(pCtx) <API key>((pCtx), VERR_INVALID_HANDLE)
/** Checks if a request is in the specified state and returns the specified rc if not. */
#define <API key>(pReq, State, rc) \
do { \
if (RT_UNLIKELY(pReq->enmState != RTFILEAIOREQSTATE_##State)) \
return rc; \
} while (0)
/** Checks if a request is not in the specified state and returns the specified rc if it is. */
#define <API key>(pReq, State, rc) \
do { \
if (RT_UNLIKELY(pReq->enmState == RTFILEAIOREQSTATE_##State)) \
return rc; \
} while (0)
/** Checks if a request in the given states and sserts if not. */
#define <API key>(pReq, State) \
do { \
AssertPtr((pReq)); \
Assert((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
Assert((pReq)->enmState == RTFILEAIOREQSTATE_##State); \
} while (0)
/** Sets the request into a specific state. */
#define <API key>(pReq, State) \
do { \
pReq->enmState = RTFILEAIOREQSTATE_##State; \
} while (0)
RT_C_DECLS_BEGIN
RT_C_DECLS_END
#endif
|
/*
EventON Generate Google maps function
*/
(function($){
$.fn.evoGenmaps = function(opt){
var defaults = {
delay: 0,
fnt: 1,
cal: '',
mapSpotId: '',
_action:''
};
var options = $.extend({}, defaults, opt);
var geocoder;
// popup lightbox generation
if(options._action=='lightbox'){
var cur_window_top = parseInt($(window).scrollTop()) + 50;
$('.evo_popin').css({'margin-top':cur_window_top});
$('.evo_pop_body').html('');
var event_list = this.closest('.eventon_events_list');
var content = this.siblings('.event_description').html();
var content_front = this.html();
var _content = $(content).not('.evcal_close');
// RTL
if(event_list.hasClass('evortl')){
$('.evo_popin').addClass('evortl');
}
$('.evo_pop_body').append('<div class="evopop_top">'+content_front+'</div>').append(_content);
var this_map = $('.evo_pop_body').find('.evcal_gmaps');
var idd = this_map.attr('id');
this_map.attr({'id':idd+'_evop'});
$('.evo_popup').fadeIn(300);
$('.evo_popbg').fadeIn(300);
// check if gmaps should run
if( this.attr('data-gmtrig')=='1' && this.attr('data-gmap_status')!='null'){
var cal = this.closest('div.ajde_evcal_calendar ');
loadl_gmaps_in(this, cal, idd+'_evop');
}
}
// functions
if(options.fnt==1){
this.each(function(){
var eventcard = $(this).attr('eventcard');
if(eventcard=='1'){
$(this).find('a.desc_trig').each(function(elm){
//$(this).siblings('.event_description').slideDown();
var obj = $(this);
if(options.delay==0){
<API key>(obj);
}else{
setTimeout(<API key>, options.delay, obj);
}
});
}
});
}
if(options.fnt==2){
if(options.delay==0){
<API key>(this);
}else{
setTimeout(<API key>, options.delay, this);
}
}
if(options.fnt==3){
loadl_gmaps_in(this, options.cal, '');
}
// gmaps on popup
if(options.fnt==4){
// check if gmaps should run
if( this.attr('data-gmtrig')=='1' && this.attr('data-gmap_status')!='null'){
var cal = this.closest('div.ajde_evcal_calendar ');
loadl_gmaps_in(this, cal, options.mapSpotId);
}
}
// function to load google maps for eventcard
function <API key>(obj){
if( obj.data('gmstat')!= '1'){
obj.attr({'data-gmstat':'1'});
}
var cal = obj.closest('div.ajde_evcal_calendar ');
if( obj.attr('data-gmtrig')=='1' && obj.attr('data-gmap_status')!='null'){
loadl_gmaps_in(obj, cal, '');
}
}
// Load the google map on the object
function loadl_gmaps_in(obj, cal, mapId){
var evodata = cal.find('.evo-data');
var mapformat = evodata.data('mapformat');
var ev_location = obj.find('.evcal_desc');
var location_type = ev_location.attr('data-location_type');
if(location_type=='address'){
var address = ev_location.attr('<API key>');
var location_type = 'add';
}else{
var address = ev_location.attr('data-latlng');
var location_type = 'latlng';
}
var map_canvas_id= (mapId!=='')?
mapId:
obj.siblings('.event_description').find('.evcal_gmaps').attr('id');
// google maps styles
// @since 2.2.22
var styles = '';
if(gmapstyles != 'default'){
styles = $.parseJSON(gmapstyles);
}
var zoom = evodata.data('mapzoom');
var zoomlevel = (typeof zoom !== 'undefined' && zoom !== false)? parseInt(zoom):12;
var scroll = evodata.data('mapscroll');
//console.log(map_canvas_id+' '+mapformat+' '+ location_type +' '+scroll +' '+ address);
//obj.siblings('.event_description').find('.evcal_gmaps').html(address);
initialize(map_canvas_id, address, mapformat, zoomlevel, location_type, scroll, styles);
}
//console.log(options);
};
}(jQuery));
|
<?php
require_once dirname(__FILE__) . '/../../prepend.inc.php';
require_once 'PEAR.php';
require_once 'sys/authn/<API key>.php';
class <API key> extends <API key>
{
/**
* Standard setup method.
*
* @return void
* @access public
*/
public function setUp()
{
$this-><API key> = dirname(__FILE__) . '/../../conf';
}
/**
* Verify that missing host causes failure.
*
* @return void
* @access public
*/
public function testWithMissingHost()
{
try {
$<API key> = new <API key>(
$this-><API key> .
"/authn/ldap/<API key>.ini"
);
$parameters = $<API key>->getParameter();
} catch (<API key> $expected) {
return;
}
$this->fail('An expected <API key> has not been raised');
}
/**
* Verify that missing port causes failure.
*
* @return void
* @access public
*/
public function testWithMissingPort()
{
try {
$<API key> = new <API key>(
$this-><API key> .
"/authn/ldap/<API key>.ini"
);
$parameters = $<API key>->getParameter();
} catch (<API key> $expected) {
return;
}
$this->fail('An expected <API key> has not been raised');
}
/**
* Verify that missing baseDN causes failure.
*
* @return void
* @access public
*/
public function <API key>()
{
try {
$<API key> = new <API key>(
$this-><API key> .
"/authn/ldap/<API key>.ini"
);
$parameters = $<API key>->getParameter();
} catch (<API key> $expected) {
return;
}
$this->fail('An expected <API key> has not been raised');
}
/**
* Verify that missing UID causes failure.
*
* @return void
* @access public
*/
public function testWithMissingUid()
{
try {
$<API key> = new <API key>(
$this-><API key> .
"/authn/ldap/<API key>.ini"
);
$parameters = $<API key>->getParameter();
} catch (<API key> $expected) {
return;
}
$this->fail('An expected <API key> has not been raised');
}
/**
* Verify that good parameters parse correctly.
*
* @return void
* @access public
*/
public function <API key>()
{
try {
$<API key> = new <API key>();
$parameters = $<API key>->getParameter();
$this->assertTrue(is_array($parameters));
} catch (<API key> $unexpected) {
$this->fail(
"An unexpected <API key> has been raised: " .
$unexpected
);
}
}
/**
* Verify lowercasing of parameter values.
*
* @return void
* @access public
*/
public function <API key>()
{
try {
$<API key> = new <API key>(
$this-><API key> .
"/authn/ldap/<API key>.ini"
);
$parameters = $<API key>->getParameter();
foreach ($parameters as $index => $value) {
if ($index == "username") {
$this->assertTrue($value == "uid");
}
if ($index == "college") {
$this->assertTrue($value == "employeetype");
}
}
} catch (<API key> $unexpected) {
$this->fail(
"An unexpected <API key> has been raised: " .
$unexpected
);
}
}
}
?>
|
#include "StdAfx.h"
#include "StringUtil.h"
namespace {
// Is the character a end of sentence punctuation character?
// English only?
bool IsEOSPunct(wchar_t ch)
{
return ch == '?' || ch == '!' || ch == '.';
}
}
namespace StringUtil {
std::string Narrow(const WCHAR* str, int strLen, int cp)
{
std::string narrowStr;
if (str && *str)
{
if (strLen == -1)
{
strLen = (int)wcslen(str);
}
int bufLen = WideCharToMultiByte(cp, 0, str, strLen, nullptr, 0, nullptr, nullptr);
if (bufLen > 0)
{
narrowStr.resize(bufLen);
WideCharToMultiByte(cp, 0, str, strLen, &narrowStr[0], bufLen, nullptr, nullptr);
}
}
return narrowStr;
}
std::wstring Widen(const char* str, int strLen, int cp)
{
std::wstring wideStr;
if (str && *str)
{
if (strLen == -1)
{
strLen = (int)strlen(str);
}
int bufLen = MultiByteToWideChar(cp, 0, str, strLen, nullptr, 0);
if (bufLen > 0)
{
wideStr.resize(bufLen);
MultiByteToWideChar(cp, 0, str, strLen, &wideStr[0], bufLen);
}
}
return wideStr;
}
void ToLowerCase(std::wstring& str)
{
WCHAR* srcAndDest = &str[0];
int strAndDestLen = (int)str.length();
LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, srcAndDest, strAndDestLen, srcAndDest, strAndDestLen);
}
void ToUpperCase(std::wstring& str)
{
WCHAR* srcAndDest = &str[0];
int strAndDestLen = (int)str.length();
LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, srcAndDest, strAndDestLen, srcAndDest, strAndDestLen);
}
void ToProperCase(std::wstring& str)
{
WCHAR* srcAndDest = &str[0];
int strAndDestLen = (int)str.length();
LCMapString(LOCALE_USER_DEFAULT, LCMAP_TITLECASE, srcAndDest, strAndDestLen, srcAndDest, strAndDestLen);
}
void ToSentenceCase(std::wstring& str)
{
if (!str.empty())
{
ToLowerCase(str);
bool isCapped = false;
for (size_t i = 0; i < str.length(); ++i)
{
if (IsEOSPunct(str[i])) isCapped = false;
if (!isCapped && iswalpha(str[i]) != 0)
{
WCHAR* srcAndDest = &str[i];
LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, srcAndDest, 1, srcAndDest, 1);
isCapped = true;
}
}
}
}
/*
** Escapes reserved PCRE regex metacharacters.
*/
void EscapeRegExp(std::wstring& str)
{
size_t start = 0;
while ((start = str.find_first_of(L"\\^$|()[{.+*?", start)) != std::wstring::npos)
{
str.insert(start, L"\\");
start += 2;
}
}
/*
** Escapes reserved URL characters.
*/
void EncodeUrl(std::wstring& str)
{
size_t pos = 0;
while ((pos = str.find_first_of(L" !*'();:@&=+$,/?#[]", pos)) != std::wstring::npos)
{
WCHAR buffer[3];
_snwprintf_s(buffer, _countof(buffer), L"%.2X", str[pos]);
str[pos] = L'%';
str.insert(pos + 1, buffer);
pos += 3;
}
}
/*
** Case insensitive comparison of strings. If equal, strip str2 from str1 and any leading whitespace.
*/
bool <API key>(std::wstring& str1, const std::wstring& str2)
{
size_t pos = str2.length();
if (_wcsnicmp(str1.c_str(), str2.c_str(), pos) == 0)
{
str1 = str1.substr(pos); // remove str2 from str1
str1.erase(0, str1.find_first_not_of(L" \t\r\n")); // remove any leading whitespace
return true;
}
return false;
}
} // namespace StringUtil
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.