repo_name
stringlengths
4
116
path
stringlengths
3
942
size
stringlengths
1
7
content
stringlengths
3
1.05M
license
stringclasses
15 values
Mertiozys/thelia.github.io
api/2.0.0-beta2/Thelia/Controller/Admin/ProductController.html
25615
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="robots" content="index, follow, all" /> <title>Thelia\Controller\Admin\ProductController | </title> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css"> </head> <body id="class"> <div class="header"> <ul> <li><a href="../../../classes.html">Classes</a></li> <li><a href="../../../namespaces.html">Namespaces</a></li> <li><a href="../../../interfaces.html">Interfaces</a></li> <li><a href="../../../traits.html">Traits</a></li> <li><a href="../../../doc-index.html">Index</a></li> </ul> <div id="title"></div> <div class="type">Class</div> <h1><a href="../../../Thelia/Controller/Admin.html">Thelia\Controller\Admin</a>\ProductController</h1> </div> <div class="content"> <p> class <strong>ProductController</strong> extends <a href="../../../Thelia/Controller/Admin/AbstractSeoCrudController.html"><abbr title="Thelia\Controller\Admin\AbstractSeoCrudController">AbstractSeoCrudController</abbr></a></p> <div class="description"> <p>Manages products</p> <p> </p> </div> <h2>Constants</h2> <table> <tr> <td>TEMPLATE_404</td> <td class="last"> <p><em> </em></p> <p> </p> </td> </tr> </table> <h2>Methods</h2> <table> <tr> <td class="type"> </td> <td class="last"> <a href="#method___construct">__construct</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> <abbr title="Thelia\Controller\Admin\Thelia\Core\HttpFoundation\Response">Response</abbr> </td> <td class="last"> <a href="#method_processUpdateSeoAction">processUpdateSeoAction</a>() <p>Update SEO modification, and either go back to the object list, or stay on the edition page.</p> </td> <td><small>from&nbsp;<a href="../../../Thelia/Controller/Admin/AbstractSeoCrudController.html#method_processUpdateSeoAction"><abbr title="Thelia\Controller\Admin\AbstractSeoCrudController">AbstractSeoCrudController</abbr></a></small></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_loadAttributesAjaxTabAction">loadAttributesAjaxTabAction</a>() <p>Attributes ajax tab loading</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_loadRelatedAjaxTabAction">loadRelatedAjaxTabAction</a>() <p>Related information ajax tab loading</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_setToggleVisibilityAction">setToggleVisibilityAction</a>() <p>Online status toggle product</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_getAvailableRelatedContentAction">getAvailableRelatedContentAction</a>($productId, $folderId) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_addRelatedContentAction">addRelatedContentAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_deleteRelatedContentAction">deleteRelatedContentAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_getAvailableAccessoriesAction">getAvailableAccessoriesAction</a>($productId, $categoryId) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_addAccessoryAction">addAccessoryAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_deleteAccessoryAction">deleteAccessoryAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_updateAccessoryPositionAction">updateAccessoryPositionAction</a>() <p>Update accessory position</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_updateContentPositionAction">updateContentPositionAction</a>() <p>Update related content position</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_setProductTemplateAction">setProductTemplateAction</a>(<abbr title="Thelia\Controller\Admin\unknown">unknown</abbr> $productId) <p>Change product template for a given product.</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_updateAttributesAndFeaturesAction">updateAttributesAndFeaturesAction</a>($productId) <p>Update product attributes and features</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_addAdditionalCategoryAction">addAdditionalCategoryAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_deleteAdditionalCategoryAction">deleteAdditionalCategoryAction</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_getAttributeValuesAction">getAttributeValuesAction</a>($productId, $attributeId) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_addAttributeValueToCombinationAction">addAttributeValueToCombinationAction</a>($productId, $attributeAvId, $combination) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_addProductSaleElementAction">addProductSaleElementAction</a>() <p>A a new combination to a product</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_deleteProductSaleElementAction">deleteProductSaleElementAction</a>() <p>A a new combination to a product</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_updateProductSaleElementsAction">updateProductSaleElementsAction</a>() <p>Process the change of product's PSE list.</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_updateProductDefaultSaleElementAction">updateProductDefaultSaleElementAction</a>() <p>Update default product sale element (not attached to any combination)</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_buildCombinationsAction">buildCombinationsAction</a>() <p>Build combinations from the combination output builder</p> </td> <td></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_priceCaclulator">priceCaclulator</a>() <p>Invoked through Ajax; this method calculates the taxed price from the unaxed price, and vice versa.</p> </td> <td></td> </tr> <tr> <td class="type"> <abbr title="Symfony\Component\HttpFoundation\JsonResponse">JsonResponse</abbr> </td> <td class="last"> <a href="#method_loadConvertedPrices">loadConvertedPrices</a>() <p>Calculate all prices</p> </td> <td></td> </tr> </table> <h2>Details</h2> <h3 id="method___construct"> <div class="location">at line 83</div> <code> public <strong>__construct</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_processUpdateSeoAction"> <div class="location">in <a href="../../../Thelia/Controller/Admin/AbstractSeoCrudController.html#method_processUpdateSeoAction"><abbr title="Thelia\Controller\Admin\AbstractSeoCrudController">AbstractSeoCrudController</abbr></a> at line 161</div> <code> public <abbr title="Thelia\Controller\Admin\Thelia\Core\HttpFoundation\Response">Response</abbr> <strong>processUpdateSeoAction</strong>()</code> </h3> <div class="details"> <p>Update SEO modification, and either go back to the object list, or stay on the edition page.</p> <p> </p> <div class="tags"> <h4>Return Value</h4> <table> <tr> <td><abbr title="Thelia\Controller\Admin\Thelia\Core\HttpFoundation\Response">Response</abbr></td> <td>the response</td> </tr> </table> </div> </div> <h3 id="method_loadAttributesAjaxTabAction"> <div class="location">at line 105</div> <code> public <strong>loadAttributesAjaxTabAction</strong>()</code> </h3> <div class="details"> <p>Attributes ajax tab loading</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_loadRelatedAjaxTabAction"> <div class="location">at line 118</div> <code> public <strong>loadRelatedAjaxTabAction</strong>()</code> </h3> <div class="details"> <p>Related information ajax tab loading</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_setToggleVisibilityAction"> <div class="location">at line 415</div> <code> public <strong>setToggleVisibilityAction</strong>()</code> </h3> <div class="details"> <p>Online status toggle product</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_getAvailableRelatedContentAction"> <div class="location">at line 465</div> <code> public <strong>getAvailableRelatedContentAction</strong>($productId, $folderId)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$productId</td> <td> </td> </tr> <tr> <td></td> <td>$folderId</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_addRelatedContentAction"> <div class="location">at line 490</div> <code> public <strong>addRelatedContentAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_deleteRelatedContentAction"> <div class="location">at line 516</div> <code> public <strong>deleteRelatedContentAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_getAvailableAccessoriesAction"> <div class="location">at line 544</div> <code> public <strong>getAvailableAccessoriesAction</strong>($productId, $categoryId)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$productId</td> <td> </td> </tr> <tr> <td></td> <td>$categoryId</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_addAccessoryAction"> <div class="location">at line 569</div> <code> public <strong>addAccessoryAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_deleteAccessoryAction"> <div class="location">at line 594</div> <code> public <strong>deleteAccessoryAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_updateAccessoryPositionAction"> <div class="location">at line 622</div> <code> public <strong>updateAccessoryPositionAction</strong>()</code> </h3> <div class="details"> <p>Update accessory position</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_updateContentPositionAction"> <div class="location">at line 635</div> <code> public <strong>updateContentPositionAction</strong>()</code> </h3> <div class="details"> <p>Update related content position</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_setProductTemplateAction"> <div class="location">at line 650</div> <code> public <strong>setProductTemplateAction</strong>(<abbr title="Thelia\Controller\Admin\unknown">unknown</abbr> $productId)</code> </h3> <div class="details"> <p>Change product template for a given product.</p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td><abbr title="Thelia\Controller\Admin\unknown">unknown</abbr></td> <td>$productId</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_updateAttributesAndFeaturesAction"> <div class="location">at line 673</div> <code> public <strong>updateAttributesAndFeaturesAction</strong>($productId)</code> </h3> <div class="details"> <p>Update product attributes and features</p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$productId</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_addAdditionalCategoryAction"> <div class="location">at line 747</div> <code> public <strong>addAdditionalCategoryAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_deleteAdditionalCategoryAction"> <div class="location">at line 772</div> <code> public <strong>deleteAdditionalCategoryAction</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_getAttributeValuesAction"> <div class="location">at line 799</div> <code> public <strong>getAttributeValuesAction</strong>($productId, $attributeId)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$productId</td> <td> </td> </tr> <tr> <td></td> <td>$attributeId</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_addAttributeValueToCombinationAction"> <div class="location">at line 824</div> <code> public <strong>addAttributeValueToCombinationAction</strong>($productId, $attributeAvId, $combination)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$productId</td> <td> </td> </tr> <tr> <td></td> <td>$attributeAvId</td> <td> </td> </tr> <tr> <td></td> <td>$combination</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_addProductSaleElementAction"> <div class="location">at line 869</div> <code> public <strong>addProductSaleElementAction</strong>()</code> </h3> <div class="details"> <p>A a new combination to a product</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_deleteProductSaleElementAction"> <div class="location">at line 893</div> <code> public <strong>deleteProductSaleElementAction</strong>()</code> </h3> <div class="details"> <p>A a new combination to a product</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_updateProductSaleElementsAction"> <div class="location">at line 1022</div> <code> public <strong>updateProductSaleElementsAction</strong>()</code> </h3> <div class="details"> <p>Process the change of product's PSE list.</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_updateProductDefaultSaleElementAction"> <div class="location">at line 1032</div> <code> public <strong>updateProductDefaultSaleElementAction</strong>()</code> </h3> <div class="details"> <p>Update default product sale element (not attached to any combination)</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_buildCombinationsAction"> <div class="location">at line 1061</div> <code> public <strong>buildCombinationsAction</strong>()</code> </h3> <div class="details"> <p>Build combinations from the combination output builder</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_priceCaclulator"> <div class="location">at line 1145</div> <code> public <strong>priceCaclulator</strong>()</code> </h3> <div class="details"> <p>Invoked through Ajax; this method calculates the taxed price from the unaxed price, and vice versa.</p> <p> </p> <div class="tags"> </div> </div> <h3 id="method_loadConvertedPrices"> <div class="location">at line 1177</div> <code> public <abbr title="Symfony\Component\HttpFoundation\JsonResponse">JsonResponse</abbr> <strong>loadConvertedPrices</strong>()</code> </h3> <div class="details"> <p>Calculate all prices</p> <p> </p> <div class="tags"> <h4>Return Value</h4> <table> <tr> <td><abbr title="Symfony\Component\HttpFoundation\JsonResponse">JsonResponse</abbr></td> <td> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated by <a href="http://sami.sensiolabs.org/" target="_top">Sami, the API Documentation Generator</a>. </div> </body> </html>
mit
blesh/jsbin
public/css/upgrade.css
17961
body { font-family: 'helvetica neue', sans-serif; /*font-weight:200!important;*/ } h1, h2 { text-align:center; } h1 { font-weight:300; } h2 { font-weight:400; } table { border: 1; width: 100%; border-collapse: collapse; } tbody tr { border-top: 1px solid rgb(240, 240, 240); } tr.headings th { vertical-align: bottom; padding-bottom: 20px; } td { text-align:center; line-height:30px; font-size:16px; font-weight:300; width:160px; } td.feature { text-align:left; width: auto; min-width:280px; } .coupon-btn { font-size:14px; } #coupon_code { font-size:14px; } .backers { width:720px; margin:0 auto; } .backers a { } #body .backers .backer-img { width:200px; margin:20px auto; border:none; } /* button.stripe-button-el { font-size: 1.4em; font-weight: 200; background: #f0f0f0; background: linear-gradient(0deg, #f0f0f0, #fefefe); box-shadow: 0px 1px 1px #eee; border: 1px solid #aaa; border-radius: 2px; padding: 10px 12px; cursor: pointer; display: inline; -moz-box-sizing: border-box; box-sizing: border-box; text-align: center; text-decoration: none; border-bottom: 2px solid #aaa; } button.stripe-button-el:hover { background: linear-gradient(0deg, #e8e8e8, #f8f8f8); } */ th small { color: rgb(165, 164, 164); font-weight: normal; } /*tr.anon td.anon:after, tr.anon td.free:after, tr.anon td.pro:after { content: "\2713"; } tr.free td.free:after, tr.free td.pro:after { content: "\2713"; } tr.pro td.pro:after { content: "\2713"; }*/ #pay { display: block; height: auto; margin: 30px 0; width: 100%; font-size: 1.1em; line-height: 2.5em; } .btn-github { width: 100%; max-width: 280px; } .btn-login { color: #949494; } .btn-login:hover { color: #111; } .login-group { font-size: 14px; } .upgrade-wrapper { font-size: 0; } .upgrade-feature-wrapper, .upgrade-form-wrapper { /*display: inline-block;*/ display: table-cell; vertical-align: top; font-size: 16px; } .upgrade-feature-wrapper { /*width: 56%;*/ } .upgrade-info-wrapper { font-size: 16px; clear: both; } .upgrade-form-wrapper { float: right; margin: 0; width: 44%; width: 360px; } .upgrade-feature-wrapper tfoot.upgrade, .upgrade-feature-wrapper .upgrade-cost { display: none; } .upgrade-form-wrapper form { border: 0 none; } .upgrade-fieldset { padding: 20px 30px; border: 1px solid #DDD; border-top: none; background-color: #fff; margin: 0; } .login .upgrade-fieldset.register, .register .upgrade-fieldset.login { display: none; } .form-container .tab, .form-container.login .tab.login, .form-container.register .tab.register { border-color: #DDD; } .form-container.login, .form-container.register .tab.register { box-shadow: none; } .form-container { max-width: 100%; } #form-login { display: none; margin-top: 0; } .form-container .tab.active { opacity: 1; background-color: #fff; border: 1px solid rgba(0,0,0,0.5); position: relative; z-index: 100; border-bottom: none; } div.submit { display: none; } .upgrade-signin-wrapper { text-align: center; padding: 20px 0; } .upgrade-signin-wrapper .btn-github { margin-top: 0; margin-bottom: 16px; } .upgrade-payment-wrapper { border: 1px solid #DDD; padding: 0 30px; /*margin-top: 20px;*/ } .upgrade-payment-wrapper section { margin: 20px 0; } .upgrade-payment-wrapper .buyer-type label { display: inline; } .upgrade-payment-wrapper input[type=radio] { margin: 0 10px 0 0; width: auto; } .upgrade-payment-wrapper input[type=checkbox] { margin: 0 5px 0 0; width: auto; } .footnotes p { margin: 8px 0; line-height: 20px; } .ccy-note { color: rgb(180, 0, 72); } form label[for], form .label { color: #666; font-weight: 500; font-size: 16px; } form .options label { font-weight: normal; padding: 0; } form .ccy label { display: inline; margin-right: 10px; font-size: 13px; } form .ccy input[type=radio] { font-size: 16px; margin-right: 5px; } .ccy-legend { display: block; } /* payment form */ @font-face { font-family: 'icomoon'; src:url('../font/account.eot?-p4vtht'); src:url('../font/account.eot?#iefix-p4vtht') format('embedded-opentype'), url('../font/account.woff?-p4vtht') format('woff'), url('../font/account.ttf?-p4vtht') format('truetype'), url('../font/account.svg?-p4vtht#icomoon') format('svg'); font-weight: normal; font-style: normal; } [class^="icon-"], [class*=" icon-"] { font-family: 'icomoon'; speak: none; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; /* Better Font Rendering =========== */ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .icon-mail:before { content: "\e002"; } .icon-lock:before { content: "\e007"; } .icon-info-circle:before { content: "\f05a"; } .icon-calendar-o:before { content: "\f133"; } .icon-credit:before { content: "\e600"; } .icon-happy:before { content: "\e601"; } .icon-smiley:before { content: "\e602"; } .icon-calendar:before { content: "\e603"; } section.business { -webkit-transition: opacity 50ms ease-out; -moz-transition: opacity 50ms ease-out; -o-transition: opacity 50ms ease-out; transition: opacity 50ms ease-out; } section.business.disabled { display: none; } .disabled { opacity: 0.5; } #vatiso { position: absolute; background: rgb(255, 255, 255); color: black; z-index: 1; font-family: sans-serif; font-size: 14px; margin: 3px 1px 4px 1px; line-height: 16px; background: rgba(216, 216, 216, 0.5); padding: 3px; border-right: 1px solid rgba(216, 216, 216, 0.5); } .disabled #vatiso { display: none; } #vat { padding-left: 30px; width: 135px; font-size: 16px; line-height: 16px; } #vat.validating { background: url(/images/loader.svg) no-repeat right; } button { font-size: 13px; } select#country { width: 165px; font-size: 16px; /* margin-left: 80px; */ /* float: right; */ } .payment-errors:empty { padding: 0; border: 0; } .payment-errors { padding: 5px 10px; color: #fff; background: #2ECC40; line-height: 24px; border: 1px solid rgb(25, 175, 42); border-radius: 3px; } .payment-errors b { font-size: 16px; line-height: 29px; display: inline-block; /* vertical-align: initial; */ } input.invalid { border: 2px solid red; } .validation.failed:after { color: red; content: 'Validation failed'; } .validation.passed:after { color: green; content: 'Validation passed'; } .inputWithImage { position: relative; display: inline-block; } .inputWithImage b { position: absolute; z-index: 1; display: block; margin-left: 5px; font-size: 14px; line-height: 28px; color: rgb(147, 147, 147); left: 0; } .inputWithImage.valid b { color: rgb(0, 128, 0); } .inputWithImage.invalid b { color: red; } .inputWithImage input { padding-left: 24px; width: 200px; } #email { /*width: 200px;*/ } #expiry { width: 100%; } #cvc { width: 100%; } .upgrade-payment-wrapper .business label { display: inline; margin-right: 5px; } .upgrade-payment-wrapper .business input { margin: 2px 0; } div.vat { /* margin-top: 30px; */ } div.vat small { width: 500px; display: block; margin-left: 90px; margin-top: 10px; } .carddetails { font-size: 0; } .carddetails span { font-size: 16px; } .payment-details span input { font-size: 16px; margin: 2px 0; } .payment-details-email { width: 100%; } .payment-details-card-number { width: 100%; } .payment-details-card-date { width: 55%; } .payment-details-card-cvc { width: 43%; margin-left: 2%; } .highlight { color: rgb(0, 180, 0); font-weight: 500; font-size: 12px; } /* action button */ /* line 24, ../scss/partials/_buttons.scss */ .actionButton { -webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.5), 0px 1px 2px rgba(0, 0, 0, 0.15); -moz-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.5), 0px 1px 2px rgba(0, 0, 0, 0.15); box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.5), 0px 1px 2px rgba(0, 0, 0, 0.15); background-color: #eeeeee; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fbfbfb), color-stop(100%, #e1e1e1)); background: -webkit-linear-gradient(top, #fbfbfb, #e1e1e1); background: -moz-linear-gradient(top, #fbfbfb, #e1e1e1); background: -o-linear-gradient(top, #fbfbfb, #e1e1e1); background: linear-gradient(top, #fbfbfb, #e1e1e1); display: -moz-inline-stack; display: inline-block; vertical-align: middle; *vertical-align: auto; zoom: 1; *display: inline; border: 1px solid #d4d4d4; height: 32px; line-height: 32px; padding: 0px 25.6px; font-weight: 300; font-size: 14px; font-family: "Helvetica Neue Light", "Helvetica Neue", "Helvetica", "Arial", "Lucida Grande", sans-serif; color: #666666; text-shadow: 0 1px 1px white; margin: 0; text-decoration: none; text-align: center; } /* line 42, ../scss/partials/_buttons.scss */ .actionButton:hover { background-color: #eeeeee; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #dcdcdc)); background: -webkit-linear-gradient(top, #ffffff, #dcdcdc); background: -moz-linear-gradient(top, #ffffff, #dcdcdc); background: -o-linear-gradient(top, #ffffff, #dcdcdc); background: linear-gradient(top, #ffffff, #dcdcdc); } /* line 46, ../scss/partials/_buttons.scss */ .actionButton:active { -webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 1px 0px white; -moz-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 1px 0px white; box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 1px 0px white; text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.4); background: #eeeeee; color: #bbbbbb; } /* line 52, ../scss/partials/_buttons.scss */ .actionButton:focus { outline: none; } /* line 58, ../scss/partials/_buttons.scss */ input.actionButton, button.actionButton { height: 34px; cursor: pointer; -webkit-appearance: none; } /* line 65, ../scss/partials/_buttons.scss */ .actionButton-block { display: block; } /* line 74, ../scss/partials/_buttons.scss */ .actionButton.disabled, .actionButton.disabled:hover, .actionButton.disabled:active, input.actionButton:disabled, button.actionButton:disabled { -webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1); -moz-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1); box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1); filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); opacity: 0.8; background: #EEE; border: 1px solid #DDD; text-shadow: 0 1px 1px white; color: #CCC; cursor: default; -webkit-appearance: none; } /* line 86, ../scss/partials/_buttons.scss */ .actionButton-wrap { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #e3e3e3), color-stop(100%, #f2f2f2)); background: -webkit-linear-gradient(top, #e3e3e3, #f2f2f2); background: -moz-linear-gradient(top, #e3e3e3, #f2f2f2); background: -o-linear-gradient(top, #e3e3e3, #f2f2f2); background: linear-gradient(top, #e3e3e3, #f2f2f2); -webkit-border-radius: 200px; -moz-border-radius: 200px; -ms-border-radius: 200px; -o-border-radius: 200px; border-radius: 200px; -webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.04); -moz-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.04); box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.04); padding: 10px; display: inline-block; } /* line 192, ../scss/partials/_buttons.scss */ .actionButton-rounded { -webkit-border-radius: 3px; -moz-border-radius: 3px; -ms-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; } /* line 226, ../scss/partials/_buttons.scss */ .actionButton-primary { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #76a1d9), color-stop(100%, #4e85cd)); background: -webkit-linear-gradient(top, #76a1d9, #4e85cd); background: -moz-linear-gradient(top, #76a1d9, #4e85cd); background: -o-linear-gradient(top, #76a1d9, #4e85cd); background: linear-gradient(top, #76a1d9, #4e85cd); background-color: #6293d3; border-color: #3a78c8; color: white; text-shadow: 0 -1px 1px rgba(34, 72, 122, 0.35); } /* line 233, ../scss/partials/_buttons.scss */ .actionButton-primary:hover { color: white; background-color: #6293d3; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #8aaede), color-stop(100%, #4e85cd)); background: -webkit-linear-gradient(top, #8aaede, #4e85cd); background: -moz-linear-gradient(top, #8aaede, #4e85cd); background: -o-linear-gradient(top, #8aaede, #4e85cd); background: linear-gradient(top, #8aaede, #4e85cd); } /* line 238, ../scss/partials/_buttons.scss */ .actionButton-primary:active { background: #7696bf; color: #2d60a2; } /* line 226, ../scss/partials/_buttons.scss */ .actionButton-action { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #8fcf00), color-stop(100%, #6b9c00)); background: -webkit-linear-gradient(top, #8fcf00, #6b9c00); background: -moz-linear-gradient(top, #8fcf00, #6b9c00); background: -o-linear-gradient(top, #8fcf00, #6b9c00); background: linear-gradient(top, #8fcf00, #6b9c00); background-color: #7db500; border-color: #5a8200; color: white; text-shadow: 0 -1px 1px rgba(19, 28, 0, 0.35); } /* line 233, ../scss/partials/_buttons.scss */ .actionButton-action:hover { color: white; background-color: #7db500; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #a0e800), color-stop(100%, #6b9c00)); background: -webkit-linear-gradient(top, #a0e800, #6b9c00); background: -moz-linear-gradient(top, #a0e800, #6b9c00); background: -o-linear-gradient(top, #a0e800, #6b9c00); background: linear-gradient(top, #a0e800, #6b9c00); } /* line 238, ../scss/partials/_buttons.scss */ .actionButton-action:active { background: #76a312; color: #374f00; } /* line 359, ../scss/partials/_buttons.scss */ .actionButton-jumbo { font-size: 24px; height: 51.2px; line-height: 51.2px; padding: 0px 40.96px; } /* line 359, ../scss/partials/_buttons.scss */ .actionButton-large { font-size: 19px; height: 38.4px; line-height: 38.4px; padding: 0px 30.72px; } /* line 390, ../scss/partials/_buttons.scss */ input.actionButton-large, button.actionButton-large { height: 40.4px; } /* line 359, ../scss/partials/_buttons.scss */ .actionButton-small { font-size: 15px; height: 25.6px; line-height: 25.6px; padding: 0px 20.48px; } /* line 390, ../scss/partials/_buttons.scss */ input.actionButton-small, button.actionButton-small { height: 27.6px; } .upgrade-wrapper .payment-type .label { display: none; } /* accordion */ .upgrade-summary { cursor: pointer; text-align: left; } .upgrade-summary:before { content: '\25b8'; padding-right: 5px; } .open .upgrade-summary:before { content: '\25be'; } .upgrade-details-content { display: none; } .open .upgrade-details-content { display: block; } .upgrade-details .upgrade-details-button { font-size: 0.75em; background: #f0f0f0; background: linear-gradient(0deg, #f0f0f0, #fefefe); /*box-shadow: 0 3px 2px 0px #eee;*/ border: 1px solid rgba(0,0,0,0.5); border-radius: 2px; padding: 5px 10px; cursor: pointer; font-weight: 600; width: auto; margin: 10px 0 0; } .upgrade-next { text-align: right; } .upgrade-center { text-align: center; } .upgrade-tweet { display: inline-block; margin: 0 5px; vertical-align: top; width: 300px; } @media (max-width: 850px) { .upgrade-tweets-wrapper { /* clear: both; */ } h3.tweets { font-size: 20px; } } @media (max-width: 767px) { #featureGrid { margin-left: 0; } .upgrade-form-wrapper { float: none; width: 100%; display: block; } .upgrade-feature-wrapper { width: 100%; display: block; } .upgrade-feature-wrapper table { margin: 0 auto; width: 100%; } .upgrade-feature-wrapper table td:nth-child(1), .upgrade-feature-wrapper table th:nth-child(1) { min-width: 150px; font-size: 0.9rem; line-height: 1.3rem; } .upgrade-feature-wrapper table td:nth-child(2), .upgrade-feature-wrapper table th:nth-child(2) /* .upgrade-feature-wrapper table td:nth-child(2), */ /* .upgrade-feature-wrapper table th:nth-child(2) */{ display: none; } .upgrade-payment-wrapper { padding: 0 10px; } .form-container form { padding: 10px 5px 10px; } } input.valid { background: #2ECC40; } input.invalid { background: #FF4136; } .tip { font-family: Times; display: inline-block; background: rgb(245, 241, 241); border-radius: 10px; width: 16px; height: 16px; font-size: 11px; text-align: center; line-height: 17px; vertical-align: sub; color: #000; cursor: help; vertical-align: baseline; opacity: 1; margin-right: 7px; outline: none; position: relative; font-weight: bold; } .tip:hover, .tip:focus { background: rgb(159, 153, 153); color: rgb(255, 255, 255); } .tip:focus:after, .tip:hover:after { visibility: hidden; content: attr(data-tip); position: absolute; font-family: 'helvetica neue', sans-serif; background: inherit; width: 190px; font-size: 14px; padding: 7px 10px; /* bottom: 0; */ /* display: block; */ left: -14px; border-radius: 3px; /* margin-top: -77px; */ /* height: 50px; */ text-align: left; /* top: -60px; */ font-weight: normal; bottom: 26px; } .tip:focus:after, .tip:hover:after { visibility: visible; -webkit-transition: visibility 0s linear 3s; transition: visibility 0s linear 3s; } .tip:focus:before, .tip:hover:before { position: absolute; /* top: 45px; */ /* 42px */ left: 3px; /* border-left: solid 1px #ccc; */ /* border-top: solid 1px #ccc; */ width: 1.1em; height: 1.1em; -webkit-transform: rotate(45deg); transform: rotate(45deg); background: inherit; content: ''; margin-top: -16px; }
mit
sk89q/CommandHelper
src/main/java/com/laytonsmith/abstraction/entities/MCEvokerFangs.java
262
package com.laytonsmith.abstraction.entities; import com.laytonsmith.abstraction.MCEntity; import com.laytonsmith.abstraction.MCLivingEntity; public interface MCEvokerFangs extends MCEntity { MCLivingEntity getOwner(); void setOwner(MCLivingEntity owner); }
mit
tasselchof/Codeception
docs/01-Introduction.md
6039
# Introduction The idea behind testing is not new. You can't sleep well if you are not confident that your last commit didn't take down the whole application. Having your application covered with tests gives you more trust in the stability of your application. That's all. In most cases tests don't guarantee that the application works 100% as it is supposed to. You can't predict all possible scenarios and exceptional situations for complex apps, but with tests you can cover the most important parts of your app and at least be sure they work as predicted. There are plenty of ways to test your application. The most popular paradigm is [Unit Testing](http://en.wikipedia.org/wiki/Unit_testing). For web applications, testing just the controller and/or the model doesn't prove that your application is working. To test the behavior of your application as a whole, you should write functional or acceptance tests. Codeception supports all three testing types. Out of the box you have tools for writing unit, functional, and acceptance tests in a unified framework. | | Codeception Unit Tests | Codeception Functional Tests | Codeception Acceptance Tests | --- | --- | --- | --- | | Scope of the test | Single PHP class | PHP Framework (Routing, Controllers, etc.) | Page in browser (Chrome, Firefox, or PhpBrowser) | | Testing computer needs access to project's PHP files | Yes | Yes | No | | Webserver required | No | No | Yes | | JavaScript | No | No | Yes | | Additional software required | None | None | <ul><li>For WebDriver: Selenium Server or PhantomJS (deprecated)</li><li>For PhpBrowser: None</li></ul> | | Test execution speed | High | High | Low | | Configuration file | `unit.suite.yml` | `functional.suite.yml` | `acceptance.suite.yml` | One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You can have all three! And chances are, that you will (sooner or later) need all three. That's why Codeception consists of three so-called "suites": A "unit suite" for all unit tests, a "functional suite" for all functional tests, and an "acceptance suite" for all acceptance tests. Let's review those three testing types in reverse order. ### Acceptance Tests How does your client, manager, tester, or any other non-technical person know your website is working? By opening the browser, accessing the site, clicking on links, filling in the forms, and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server, or why the application did (or did not) behave as expected. This is what acceptance tests are doing. They cover scenarios from a user's perspective. With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors. **Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework. #### Sample acceptance test ```php <?php $I->amOnPage('/'); $I->click('Sign Up'); $I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => '[email protected]']); $I->see('Thank you for Signing Up!'); ``` ### Functional Tests What if we could check our application without running it on a server? That way we could see detailed exceptions on errors, have our tests run faster, and check the database against predictable and expected results. That's what functional tests are for. For functional tests, you emulate a web request (`$_GET` and `$_POST` variables) which returns the HTML response. Inside a test, you can make assertions about the response, and you can check if the data was successfully stored in the database. For functional tests, your application needs to be structured in order to run in a test environment. Codeception provides connectors to several popular PHP frameworks. You can also write your own. #### Sample functional test ```php <?php $I->amOnPage('/'); $I->click('Sign Up'); $I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => '[email protected]']); $I->see('Thank you for Signing Up!'); $I->seeEmailSent('[email protected]', 'Thank you for registration'); $I->seeInDatabase('users', ['email' => '[email protected]']); ``` ### Unit Tests Testing pieces of code before coupling them together is highly important as well. This way, you can be sure that some deeply hidden feature still works, even if it was not covered by functional or acceptance tests. This also shows care in producing stable and testable code. Codeception is created on top of [PHPUnit](http://www.phpunit.de/). If you have experience writing unit tests with PHPUnit you can continue doing so. Codeception has no problem executing standard PHPUnit tests, but, additionally, Codeception provides some well-built tools to make your unit tests simpler and cleaner. Requirements and code can change rapidly, and unit tests should be updated every time to fit the requirements. The better you understand the testing scenario, the faster you can update it for new behavior. #### Sample integration test ```php <?php function testSavingUser() { $user = new User(); $user->setName('Miles'); $user->setSurname('Davis'); $user->save(); $this->assertEquals('Miles Davis', $user->getFullName()); $this->tester->seeInDatabase('users', ['name' => 'Miles', 'surname' => 'Davis']); } ``` ## Conclusion Despite the wide popularity of *TDD* (Test Driven Development), some PHP developers never write automated tests for their applications mostly because they think it's hard, slow or boring. The Codeception framework was developed to actually make testing fun. It allows writing unit, functional, integration, and acceptance tests in a single, coherent style. It can be called a *BDD* (Behavior Driven Development) framework. All Codeception tests are written in a descriptive manner. Just by looking at the test body, you can clearly understand what is being tested and how it is performed. Even complex tests with many assertions are written in a simple PHP Domain-Specific Language (*DSL*).
mit
mxrrow/zaicoin
src/deps/boost/doc/html/boost/proto/functional/prior.html
12638
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Struct prior</title> <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> <link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="../../../proto/reference.html#header.boost.proto.functional.std.iterator_hpp" title="Header &lt;boost/proto/functional/std/iterator.hpp&gt;"> <link rel="prev" href="next/result_This_Fo_idp89274544.html" title="Struct template result&lt;This(ForwardIterator, Distance)&gt;"> <link rel="next" href="prior/result_This_Bi_idp89285504.html" title="Struct template result&lt;This(BidirectionalIterator)&gt;"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> <td align="center"><a href="../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="next/result_This_Fo_idp89274544.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../proto/reference.html#header.boost.proto.functional.std.iterator_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="prior/result_This_Bi_idp89285504.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="refentry"> <a name="boost.proto.functional.prior"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Struct prior</span></h2> <p>boost::proto::functional::prior &#8212; A <a class="link" href="../../../PolymorphicFunctionObject.html" title="Concept PolymorphicFunctionObject">PolymorphicFunctionObject</a> type that invokes the <code class="computeroutput">std::prior()</code> function on its arguments.</p> </div> <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../proto/reference.html#header.boost.proto.functional.std.iterator_hpp" title="Header &lt;boost/proto/functional/std/iterator.hpp&gt;">boost/proto/functional/std/iterator.hpp</a>&gt; </span> <span class="keyword">struct</span> <a class="link" href="prior.html" title="Struct prior">prior</a> <span class="special">:</span> <span class="keyword"></span> <a class="link" href="../callable.html" title="Struct callable">proto::callable</a> <span class="special">{</span> <span class="comment">// member classes/structs/unions</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> This<span class="special">,</span> <span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">&gt;</span> <span class="keyword">struct</span> <a class="link" href="prior/result_This_Bi_idp89285504.html" title="Struct template result&lt;This(BidirectionalIterator)&gt;">result</a><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">BidirectionalIterator</span><span class="special">)</span><span class="special">&gt;</span> <span class="special">{</span> <span class="comment">// types</span> <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_const</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <a class="link" href="prior/result_This_Bi_idp89285504.html#boost.proto.functional.prior.result_This(Bi_idp89285504.type"><span class="identifier">type</span></a><span class="special">;</span> <span class="special">}</span><span class="special">;</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> This<span class="special">,</span> <span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">,</span> <span class="keyword">typename</span> Distance<span class="special">&gt;</span> <span class="keyword">struct</span> <a class="link" href="prior/result_This_Bi_idp89287776.html" title="Struct template result&lt;This(BidirectionalIterator, Distance)&gt;">result</a><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">BidirectionalIterator</span><span class="special">,</span> <span class="identifier">Distance</span><span class="special">)</span><span class="special">&gt;</span> <span class="special">{</span> <span class="comment">// types</span> <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_const</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <a class="link" href="prior/result_This_Bi_idp89287776.html#boost.proto.functional.prior.result_This(Bi_idp89287776.type"><span class="identifier">type</span></a><span class="special">;</span> <span class="special">}</span><span class="special">;</span> <span class="comment">// <a class="link" href="prior.html#idp89290336-bb">public member functions</a></span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="prior.html#idp89290624-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">BidirectionalIterator</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="prior.html#idp89292992-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">BidirectionalIterator</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special">&lt;</span><span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">difference_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="special">}</span><span class="special">;</span></pre></div> <div class="refsect1"> <a name="idp135089536"></a><h2>Description</h2> <p> A <a class="link" href="../../../PolymorphicFunctionObject.html" title="Concept PolymorphicFunctionObject">PolymorphicFunctionObject</a> type that invokes the <code class="computeroutput">std::prior()</code> function on its arguments.</p> <div class="refsect2"> <a name="idp135090896"></a><h3> <a name="idp89290336-bb"></a><code class="computeroutput">prior</code> public member functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"> <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">&gt;</span> <span class="keyword">void</span> <a name="idp89290624-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">BidirectionalIterator</span> x<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><p><span class="term">Returns:</span></p></td> <td><p><code class="computeroutput">std::prior(x)</code></p></td> </tr></tbody> </table></div> </li> <li class="listitem"> <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <a class="link" href="../../../BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a><span class="special">&gt;</span> <span class="keyword">void</span> <a name="idp89292992-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">BidirectionalIterator</span> x<span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special">&lt;</span><span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">difference_type</span> n<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><p><span class="term">Returns:</span></p></td> <td><p><code class="computeroutput">std::prior(x, n)</code></p></td> </tr></tbody> </table></div> </li> </ol></div> </div> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2008 Eric Niebler<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="next/result_This_Fo_idp89274544.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../proto/reference.html#header.boost.proto.functional.std.iterator_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="prior/result_This_Bi_idp89285504.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
mit
curry684/symfony
src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
17092
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\Catalogue\MergeOperation; use Symfony\Component\Translation\DataCollectorTranslator; use Symfony\Component\Translation\Extractor\ExtractorInterface; use Symfony\Component\Translation\LoggingTranslator; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Reader\TranslationReaderInterface; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** * Helps finding unused or missing translation messages in a given locale * and comparing them with the fallback ones. * * @author Florian Voutzinos <[email protected]> * * @final */ class TranslationDebugCommand extends Command { const MESSAGE_MISSING = 0; const MESSAGE_UNUSED = 1; const MESSAGE_EQUALS_FALLBACK = 2; protected static $defaultName = 'debug:translation'; private $translator; private $reader; private $extractor; private $defaultTransPath; private $defaultViewsPath; private $transPaths; private $viewsPaths; /** * @param TranslatorInterface $translator */ public function __construct($translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $viewsPaths = []) { if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) { throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); } parent::__construct(); $this->translator = $translator; $this->reader = $reader; $this->extractor = $extractor; $this->defaultTransPath = $defaultTransPath; $this->defaultViewsPath = $defaultViewsPath; $this->transPaths = $transPaths; $this->viewsPaths = $viewsPaths; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition([ new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'), new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Displays only missing messages'), new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Displays only unused messages'), new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'), ]) ->setDescription('Displays translation messages information') ->setHelp(<<<'EOF' The <info>%command.name%</info> command helps finding unused or missing translation messages and comparing them with the fallback ones by inspecting the templates and translation files of a given bundle or the default translations directory. You can display information about bundle translations in a specific locale: <info>php %command.full_name% en AcmeDemoBundle</info> You can also specify a translation domain for the search: <info>php %command.full_name% --domain=messages en AcmeDemoBundle</info> You can only display missing messages: <info>php %command.full_name% --only-missing en AcmeDemoBundle</info> You can only display unused messages: <info>php %command.full_name% --only-unused en AcmeDemoBundle</info> You can display information about application translations in a specific locale: <info>php %command.full_name% en</info> You can display information about translations in all registered bundles in a specific locale: <info>php %command.full_name% --all en</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $locale = $input->getArgument('locale'); $domain = $input->getOption('domain'); /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); $rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); // Define Root Paths $transPaths = $this->transPaths; if (is_dir($dir = $rootDir.'/Resources/translations')) { if ($dir !== $this->defaultTransPath) { $notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); } $transPaths[] = $dir; } if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = $this->viewsPaths; if (is_dir($dir = $rootDir.'/Resources/views')) { if ($dir !== $this->defaultViewsPath) { $notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir); @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); } $viewsPaths[] = $dir; } if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } // Override with provided Bundle info if (null !== $input->getArgument('bundle')) { try { $bundle = $kernel->getBundle($input->getArgument('bundle')); $transPaths = [$bundle->getPath().'/Resources/translations']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { $transPaths[] = $dir; $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName()); @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); } $viewsPaths = [$bundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { $viewsPaths[] = $dir; $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir); @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); } } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; if (is_dir($dir = $path.'/Resources/translations')) { if ($dir !== $this->defaultTransPath) { @trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED); } $transPaths[] = $dir; } $viewsPaths = [$path.'/templates']; if (is_dir($dir = $path.'/Resources/views')) { if ($dir !== $this->defaultViewsPath) { @trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED); } $viewsPaths[] = $dir; } if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); } } } elseif ($input->getOption('all')) { foreach ($kernel->getBundles() as $bundle) { $transPaths[] = $bundle->getPath().'/Resources/translations'; if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { $transPaths[] = $deprecatedPath; $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); } $viewsPaths[] = $bundle->getPath().'/Resources/views'; if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { $viewsPaths[] = $deprecatedPath; $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); } } } // Extract used messages $extractedCatalogue = $this->extractMessages($locale, $viewsPaths); // Load defined messages $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths); // Merge defined and extracted messages to get all message ids $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue); $allMessages = $mergeOperation->getResult()->all($domain); if (null !== $domain) { $allMessages = [$domain => $allMessages]; } // No defined or extracted messages if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) { $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale); if (null !== $domain) { $outputMessage .= sprintf(' and domain "%s"', $domain); } $io->getErrorStyle()->warning($outputMessage); return; } // Load the fallback catalogues $fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths); // Display header line $headers = ['State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)]; foreach ($fallbackCatalogues as $fallbackCatalogue) { $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale()); } $rows = []; // Iterate all message ids and determine their state foreach ($allMessages as $domain => $messages) { foreach (array_keys($messages) as $messageId) { $value = $currentCatalogue->get($messageId, $domain); $states = []; if ($extractedCatalogue->defines($messageId, $domain)) { if (!$currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_MISSING; } } elseif ($currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_UNUSED; } if (!\in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused') || !\in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) { continue; } foreach ($fallbackCatalogues as $fallbackCatalogue) { if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) { $states[] = self::MESSAGE_EQUALS_FALLBACK; break; } } $row = [$this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)]; foreach ($fallbackCatalogues as $fallbackCatalogue) { $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain)); } $rows[] = $row; } } $io->table($headers, $rows); } private function formatState($state): string { if (self::MESSAGE_MISSING === $state) { return '<error> missing </error>'; } if (self::MESSAGE_UNUSED === $state) { return '<comment> unused </comment>'; } if (self::MESSAGE_EQUALS_FALLBACK === $state) { return '<info> fallback </info>'; } return $state; } private function formatStates(array $states): string { $result = []; foreach ($states as $state) { $result[] = $this->formatState($state); } return implode(' ', $result); } private function formatId(string $id): string { return sprintf('<fg=cyan;options=bold>%s</>', $id); } private function sanitizeString(string $string, int $length = 40): string { $string = trim(preg_replace('/\s+/', ' ', $string)); if (false !== $encoding = mb_detect_encoding($string, null, true)) { if (mb_strlen($string, $encoding) > $length) { return mb_substr($string, 0, $length - 3, $encoding).'...'; } } elseif (\strlen($string) > $length) { return substr($string, 0, $length - 3).'...'; } return $string; } private function extractMessages(string $locale, array $transPaths): MessageCatalogue { $extractedCatalogue = new MessageCatalogue($locale); foreach ($transPaths as $path) { if (is_dir($path) || is_file($path)) { $this->extractor->extract($path, $extractedCatalogue); } } return $extractedCatalogue; } private function loadCurrentMessages(string $locale, array $transPaths): MessageCatalogue { $currentCatalogue = new MessageCatalogue($locale); foreach ($transPaths as $path) { if (is_dir($path)) { $this->reader->read($path, $currentCatalogue); } } return $currentCatalogue; } /** * @return MessageCatalogue[] */ private function loadFallbackCatalogues(string $locale, array $transPaths): array { $fallbackCatalogues = []; if ($this->translator instanceof Translator || $this->translator instanceof DataCollectorTranslator || $this->translator instanceof LoggingTranslator) { foreach ($this->translator->getFallbackLocales() as $fallbackLocale) { if ($fallbackLocale === $locale) { continue; } $fallbackCatalogue = new MessageCatalogue($fallbackLocale); foreach ($transPaths as $path) { if (is_dir($path)) { $this->reader->read($path, $fallbackCatalogue); } } $fallbackCatalogues[] = $fallbackCatalogue; } } return $fallbackCatalogues; } }
mit
himanshu0503/admiral
.eslintrc.js
1174
module.exports = { "env": { "browser": true }, "plugins": [ "callback-function" ], "globals": { "_": true, "$": true, "ActErr": true, "async": true, "config": true, "logger": true, "moment": true, "respondWithError": true, "sendJSONResponse": true, "util": true, "admiral": true }, "extends": "airbnb-base/legacy", "rules": { // rules to override from airbnb/legacy "object-curly-spacing": ["error", "never"], "curly": ["error", "multi", "consistent"], "no-param-reassign": ["error", { "props": false }], "no-underscore-dangle": ["error", { "allow": ["_r", "_p"] }], "quote-props": ["error", "consistent-as-needed"], // rules from airbnb that we won't be using "consistent-return": 0, "default-case": 0, "func-names": 0, "no-plusplus": 0, "no-use-before-define": 0, "vars-on-top": 0, "no-loop-func": 0, "no-underscore-dangle": 0, "no-param-reassign": 0, "one-var-declaration-per-line": 0, "one-var": 0, "no-multi-assign": 0, "global-require": 0, // extra rules not present in airbnb "max-len": ["error", 80], } };
mit
breezechen/DiscUtils
src/Vmdk/HostedSparseExtentStream.cs
10139
// // Copyright (c) 2008-2011, Kenneth Bell // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // namespace DiscUtils.Vmdk { using System; using System.IO; using System.IO.Compression; /// <summary> /// Represents and extent from a sparse disk from 'hosted' software (VMware Workstation, etc). /// </summary> /// <remarks>Hosted disks and server disks (ESX, etc) are subtly different formats.</remarks> internal sealed class HostedSparseExtentStream : CommonSparseExtentStream { private HostedSparseExtentHeader _hostedHeader; public HostedSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream) { _fileStream = file; _ownsFileStream = ownsFile; _diskOffset = diskOffset; _parentDiskStream = parentDiskStream; _ownsParentDiskStream = ownsParentDiskStream; file.Position = 0; byte[] headerSector = Utilities.ReadFully(file, Sizes.Sector); _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0); if (_hostedHeader.GdOffset == -1) { // Fall back to secondary copy that (should) be at the end of the stream, just before the end-of-stream sector marker file.Position = file.Length - Sizes.OneKiB; headerSector = Utilities.ReadFully(file, Sizes.Sector); _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0); if (_hostedHeader.MagicNumber != HostedSparseExtentHeader.VmdkMagicNumber) { throw new IOException("Unable to locate valid VMDK header or footer"); } } _header = _hostedHeader; if (_hostedHeader.CompressAlgorithm != 0 && _hostedHeader.CompressAlgorithm != 1) { throw new NotSupportedException("Only uncompressed and DEFLATE compressed disks supported"); } _gtCoverage = _header.NumGTEsPerGT * _header.GrainSize * Sizes.Sector; LoadGlobalDirectory(); } public override bool CanWrite { get { // No write support for streamOptimized disks return _fileStream.CanWrite && (_hostedHeader.Flags & (HostedSparseExtentFlags.CompressedGrains | HostedSparseExtentFlags.MarkersInUse)) == 0; } } public override void Write(byte[] buffer, int offset, int count) { CheckDisposed(); if (!CanWrite) { throw new InvalidOperationException("Cannot write to this stream"); } if (_position + count > Length) { throw new IOException("Attempt to write beyond end of stream"); } int totalWritten = 0; while (totalWritten < count) { int grainTable = (int)(_position / _gtCoverage); int grainTableOffset = (int)(_position - (grainTable * _gtCoverage)); LoadGrainTable(grainTable); int grainSize = (int)(_header.GrainSize * Sizes.Sector); int grain = grainTableOffset / grainSize; int grainOffset = grainTableOffset - (grain * grainSize); if (GetGrainTableEntry(grain) == 0) { AllocateGrain(grainTable, grain); } int numToWrite = Math.Min(count - totalWritten, grainSize - grainOffset); _fileStream.Position = (((long)GetGrainTableEntry(grain)) * Sizes.Sector) + grainOffset; _fileStream.Write(buffer, offset + totalWritten, numToWrite); _position += numToWrite; totalWritten += numToWrite; } _atEof = _position == Length; } protected override int ReadGrain(byte[] buffer, int bufferOffset, long grainStart, int grainOffset, int numToRead) { if ((_hostedHeader.Flags & HostedSparseExtentFlags.CompressedGrains) != 0) { _fileStream.Position = grainStart; byte[] readBuffer = Utilities.ReadFully(_fileStream, CompressedGrainHeader.Size); CompressedGrainHeader hdr = new CompressedGrainHeader(); hdr.Read(readBuffer, 0); readBuffer = Utilities.ReadFully(_fileStream, hdr.DataSize); // This is really a zlib stream, so has header and footer. We ignore this right now, but we sanity // check against expected header values... ushort header = Utilities.ToUInt16BigEndian(readBuffer, 0); if ((header % 31) != 0) { throw new IOException("Invalid ZLib header found"); } if ((header & 0x0F00) != (8 << 8)) { throw new NotSupportedException("ZLib compression not using DEFLATE algorithm"); } if ((header & 0x0020) != 0) { throw new NotSupportedException("ZLib compression using preset dictionary"); } Stream readStream = new MemoryStream(readBuffer, 2, hdr.DataSize - 2, false); DeflateStream deflateStream = new DeflateStream(readStream, CompressionMode.Decompress); // Need to skip some bytes, but DefaultStream doesn't support seeking... Utilities.ReadFully(deflateStream, grainOffset); return deflateStream.Read(buffer, bufferOffset, numToRead); } else { return base.ReadGrain(buffer, bufferOffset, grainStart, grainOffset, numToRead); } } protected override StreamExtent MapGrain(long grainStart, int grainOffset, int numToRead) { if ((_hostedHeader.Flags & HostedSparseExtentFlags.CompressedGrains) != 0) { _fileStream.Position = grainStart; byte[] readBuffer = Utilities.ReadFully(_fileStream, CompressedGrainHeader.Size); CompressedGrainHeader hdr = new CompressedGrainHeader(); hdr.Read(readBuffer, 0); return new StreamExtent(grainStart + grainOffset, CompressedGrainHeader.Size + hdr.DataSize); } else { return base.MapGrain(grainStart, grainOffset, numToRead); } } protected override void LoadGlobalDirectory() { base.LoadGlobalDirectory(); if ((_hostedHeader.Flags & HostedSparseExtentFlags.RedundantGrainTable) != 0) { int numGTs = (int)Utilities.Ceil(_header.Capacity * Sizes.Sector, _gtCoverage); _redundantGlobalDirectory = new uint[numGTs]; _fileStream.Position = _hostedHeader.RgdOffset * Sizes.Sector; byte[] gdAsBytes = Utilities.ReadFully(_fileStream, numGTs * 4); for (int i = 0; i < _globalDirectory.Length; ++i) { _redundantGlobalDirectory[i] = Utilities.ToUInt32LittleEndian(gdAsBytes, i * 4); } } } private void AllocateGrain(int grainTable, int grain) { // Calculate start pos for new grain long grainStartPos = Utilities.RoundUp(_fileStream.Length, _header.GrainSize * Sizes.Sector); // Copy-on-write semantics, read the bytes from parent and write them out to this extent. _parentDiskStream.Position = _diskOffset + ((grain + (_header.NumGTEsPerGT * (long)grainTable)) * _header.GrainSize * Sizes.Sector); byte[] content = Utilities.ReadFully(_parentDiskStream, (int)_header.GrainSize * Sizes.Sector); _fileStream.Position = grainStartPos; _fileStream.Write(content, 0, content.Length); LoadGrainTable(grainTable); SetGrainTableEntry(grain, (uint)(grainStartPos / Sizes.Sector)); WriteGrainTable(); } private void WriteGrainTable() { if (_grainTable == null) { throw new InvalidOperationException("No grain table loaded"); } _fileStream.Position = _globalDirectory[_currentGrainTable] * (long)Sizes.Sector; _fileStream.Write(_grainTable, 0, _grainTable.Length); if (_redundantGlobalDirectory != null) { _fileStream.Position = _redundantGlobalDirectory[_currentGrainTable] * (long)Sizes.Sector; _fileStream.Write(_grainTable, 0, _grainTable.Length); } } } }
mit
Slamdunk/symfony
src/Symfony/Component/Intl/Resources/data/timezones/su.php
13893
<?php return [ 'Names' => [ 'Africa/Abidjan' => 'Waktu Greenwich (Abidjan)', 'Africa/Accra' => 'Waktu Greenwich (Accra)', 'Africa/Algiers' => 'Waktu Éropa Tengah (Algiers)', 'Africa/Bamako' => 'Waktu Greenwich (Bamako)', 'Africa/Banjul' => 'Waktu Greenwich (Banjul)', 'Africa/Bissau' => 'Waktu Greenwich (Bissau)', 'Africa/Cairo' => 'Waktu Éropa Timur (Cairo)', 'Africa/Casablanca' => 'Waktu Éropa Barat (Casablanca)', 'Africa/Ceuta' => 'Waktu Éropa Tengah (Ceuta)', 'Africa/Conakry' => 'Waktu Greenwich (Conakry)', 'Africa/Dakar' => 'Waktu Greenwich (Dakar)', 'Africa/El_Aaiun' => 'Waktu Éropa Barat (El Aaiun)', 'Africa/Freetown' => 'Waktu Greenwich (Freetown)', 'Africa/Lome' => 'Waktu Greenwich (Lome)', 'Africa/Monrovia' => 'Waktu Greenwich (Monrovia)', 'Africa/Nouakchott' => 'Waktu Greenwich (Nouakchott)', 'Africa/Ouagadougou' => 'Waktu Greenwich (Ouagadougou)', 'Africa/Sao_Tome' => 'Waktu Greenwich (Sao Tome)', 'Africa/Tripoli' => 'Waktu Éropa Timur (Tripoli)', 'Africa/Tunis' => 'Waktu Éropa Tengah (Tunis)', 'America/Adak' => 'Amérika Sarikat (Adak)', 'America/Anchorage' => 'Amérika Sarikat (Anchorage)', 'America/Anguilla' => 'Waktu Atlantik (Anguilla)', 'America/Antigua' => 'Waktu Atlantik (Antigua)', 'America/Araguaina' => 'Brasil (Araguaina)', 'America/Aruba' => 'Waktu Atlantik (Aruba)', 'America/Bahia' => 'Brasil (Bahia)', 'America/Bahia_Banderas' => 'Waktu Tengah (Bahia Banderas)', 'America/Barbados' => 'Waktu Atlantik (Barbados)', 'America/Belem' => 'Brasil (Belem)', 'America/Belize' => 'Waktu Tengah (Belize)', 'America/Blanc-Sablon' => 'Waktu Atlantik (Blanc-Sablon)', 'America/Boa_Vista' => 'Brasil (Boa Vista)', 'America/Bogota' => 'Waktu Kolombia (Bogota)', 'America/Boise' => 'Waktu Pagunungan (Boise)', 'America/Cambridge_Bay' => 'Waktu Pagunungan (Cambridge Bay)', 'America/Campo_Grande' => 'Brasil (Campo Grande)', 'America/Cancun' => 'Waktu Wétan (Cancun)', 'America/Cayman' => 'Waktu Wétan (Cayman)', 'America/Chicago' => 'Waktu Tengah (Chicago)', 'America/Coral_Harbour' => 'Waktu Wétan (Atikokan)', 'America/Costa_Rica' => 'Waktu Tengah (Costa Rica)', 'America/Creston' => 'Waktu Pagunungan (Creston)', 'America/Cuiaba' => 'Brasil (Cuiaba)', 'America/Curacao' => 'Waktu Atlantik (Curacao)', 'America/Danmarkshavn' => 'Waktu Greenwich (Danmarkshavn)', 'America/Dawson' => 'Waktu Pagunungan (Dawson)', 'America/Dawson_Creek' => 'Waktu Pagunungan (Dawson Creek)', 'America/Denver' => 'Waktu Pagunungan (Denver)', 'America/Detroit' => 'Waktu Wétan (Detroit)', 'America/Dominica' => 'Waktu Atlantik (Dominica)', 'America/Edmonton' => 'Waktu Pagunungan (Edmonton)', 'America/Eirunepe' => 'Brasil (Eirunepe)', 'America/El_Salvador' => 'Waktu Tengah (El Salvador)', 'America/Fort_Nelson' => 'Waktu Pagunungan (Fort Nelson)', 'America/Fortaleza' => 'Brasil (Fortaleza)', 'America/Glace_Bay' => 'Waktu Atlantik (Glace Bay)', 'America/Goose_Bay' => 'Waktu Atlantik (Goose Bay)', 'America/Grand_Turk' => 'Waktu Wétan (Grand Turk)', 'America/Grenada' => 'Waktu Atlantik (Grenada)', 'America/Guadeloupe' => 'Waktu Atlantik (Guadeloupe)', 'America/Guatemala' => 'Waktu Tengah (Guatemala)', 'America/Halifax' => 'Waktu Atlantik (Halifax)', 'America/Indiana/Knox' => 'Waktu Tengah (Knox, Indiana)', 'America/Indiana/Marengo' => 'Waktu Wétan (Marengo, Indiana)', 'America/Indiana/Petersburg' => 'Waktu Wétan (Petersburg, Indiana)', 'America/Indiana/Tell_City' => 'Waktu Tengah (Tell City, Indiana)', 'America/Indiana/Vevay' => 'Waktu Wétan (Vevay, Indiana)', 'America/Indiana/Vincennes' => 'Waktu Wétan (Vincennes, Indiana)', 'America/Indiana/Winamac' => 'Waktu Wétan (Winamac, Indiana)', 'America/Indianapolis' => 'Waktu Wétan (Indianapolis)', 'America/Inuvik' => 'Waktu Pagunungan (Inuvik)', 'America/Iqaluit' => 'Waktu Wétan (Iqaluit)', 'America/Jamaica' => 'Waktu Wétan (Jamaica)', 'America/Juneau' => 'Amérika Sarikat (Juneau)', 'America/Kentucky/Monticello' => 'Waktu Wétan (Monticello, Kentucky)', 'America/Kralendijk' => 'Waktu Atlantik (Kralendijk)', 'America/Los_Angeles' => 'Waktu Pasifik (Los Angeles)', 'America/Louisville' => 'Waktu Wétan (Louisville)', 'America/Lower_Princes' => 'Waktu Atlantik (Lower Prince’s Quarter)', 'America/Maceio' => 'Brasil (Maceio)', 'America/Managua' => 'Waktu Tengah (Managua)', 'America/Manaus' => 'Brasil (Manaus)', 'America/Marigot' => 'Waktu Atlantik (Marigot)', 'America/Martinique' => 'Waktu Atlantik (Martinique)', 'America/Matamoros' => 'Waktu Tengah (Matamoros)', 'America/Menominee' => 'Waktu Tengah (Menominee)', 'America/Merida' => 'Waktu Tengah (Merida)', 'America/Metlakatla' => 'Amérika Sarikat (Metlakatla)', 'America/Mexico_City' => 'Waktu Tengah (Mexico City)', 'America/Moncton' => 'Waktu Atlantik (Moncton)', 'America/Monterrey' => 'Waktu Tengah (Monterrey)', 'America/Montserrat' => 'Waktu Atlantik (Montserrat)', 'America/Nassau' => 'Waktu Wétan (Nassau)', 'America/New_York' => 'Waktu Wétan (New York)', 'America/Nipigon' => 'Waktu Wétan (Nipigon)', 'America/Nome' => 'Amérika Sarikat (Nome)', 'America/Noronha' => 'Brasil (Noronha)', 'America/North_Dakota/Beulah' => 'Waktu Tengah (Beulah, North Dakota)', 'America/North_Dakota/Center' => 'Waktu Tengah (Center, North Dakota)', 'America/North_Dakota/New_Salem' => 'Waktu Tengah (New Salem, North Dakota)', 'America/Ojinaga' => 'Waktu Pagunungan (Ojinaga)', 'America/Panama' => 'Waktu Wétan (Panama)', 'America/Pangnirtung' => 'Waktu Wétan (Pangnirtung)', 'America/Phoenix' => 'Waktu Pagunungan (Phoenix)', 'America/Port-au-Prince' => 'Waktu Wétan (Port-au-Prince)', 'America/Port_of_Spain' => 'Waktu Atlantik (Port of Spain)', 'America/Porto_Velho' => 'Brasil (Porto Velho)', 'America/Puerto_Rico' => 'Waktu Atlantik (Puerto Rico)', 'America/Rainy_River' => 'Waktu Tengah (Rainy River)', 'America/Rankin_Inlet' => 'Waktu Tengah (Rankin Inlet)', 'America/Recife' => 'Brasil (Recife)', 'America/Regina' => 'Waktu Tengah (Regina)', 'America/Resolute' => 'Waktu Tengah (Resolute)', 'America/Rio_Branco' => 'Brasil (Rio Branco)', 'America/Santarem' => 'Brasil (Santarem)', 'America/Santo_Domingo' => 'Waktu Atlantik (Santo Domingo)', 'America/Sao_Paulo' => 'Brasil (Sao Paulo)', 'America/Sitka' => 'Amérika Sarikat (Sitka)', 'America/St_Barthelemy' => 'Waktu Atlantik (St. Barthelemy)', 'America/St_Kitts' => 'Waktu Atlantik (St. Kitts)', 'America/St_Lucia' => 'Waktu Atlantik (St. Lucia)', 'America/St_Thomas' => 'Waktu Atlantik (St. Thomas)', 'America/St_Vincent' => 'Waktu Atlantik (St. Vincent)', 'America/Swift_Current' => 'Waktu Tengah (Swift Current)', 'America/Tegucigalpa' => 'Waktu Tengah (Tegucigalpa)', 'America/Thule' => 'Waktu Atlantik (Thule)', 'America/Thunder_Bay' => 'Waktu Wétan (Thunder Bay)', 'America/Tijuana' => 'Waktu Pasifik (Tijuana)', 'America/Toronto' => 'Waktu Wétan (Toronto)', 'America/Tortola' => 'Waktu Atlantik (Tortola)', 'America/Vancouver' => 'Waktu Pasifik (Vancouver)', 'America/Whitehorse' => 'Waktu Pagunungan (Whitehorse)', 'America/Winnipeg' => 'Waktu Tengah (Winnipeg)', 'America/Yakutat' => 'Amérika Sarikat (Yakutat)', 'America/Yellowknife' => 'Waktu Pagunungan (Yellowknife)', 'Antarctica/Troll' => 'Waktu Greenwich (Troll)', 'Arctic/Longyearbyen' => 'Waktu Éropa Tengah (Longyearbyen)', 'Asia/Amman' => 'Waktu Éropa Timur (Amman)', 'Asia/Anadyr' => 'Rusia (Anadyr)', 'Asia/Barnaul' => 'Rusia (Barnaul)', 'Asia/Beirut' => 'Waktu Éropa Timur (Beirut)', 'Asia/Calcutta' => 'India (Kolkata)', 'Asia/Chita' => 'Rusia (Chita)', 'Asia/Damascus' => 'Waktu Éropa Timur (Damascus)', 'Asia/Famagusta' => 'Waktu Éropa Timur (Famagusta)', 'Asia/Gaza' => 'Waktu Éropa Timur (Gaza)', 'Asia/Hebron' => 'Waktu Éropa Timur (Hebron)', 'Asia/Irkutsk' => 'Rusia (Irkutsk)', 'Asia/Kamchatka' => 'Rusia (Kamchatka)', 'Asia/Khandyga' => 'Rusia (Khandyga)', 'Asia/Krasnoyarsk' => 'Rusia (Krasnoyarsk)', 'Asia/Magadan' => 'Rusia (Magadan)', 'Asia/Nicosia' => 'Waktu Éropa Timur (Nicosia)', 'Asia/Novokuznetsk' => 'Rusia (Novokuznetsk)', 'Asia/Novosibirsk' => 'Rusia (Novosibirsk)', 'Asia/Omsk' => 'Rusia (Omsk)', 'Asia/Sakhalin' => 'Rusia (Sakhalin)', 'Asia/Shanghai' => 'Tiongkok (Shanghai)', 'Asia/Srednekolymsk' => 'Rusia (Srednekolymsk)', 'Asia/Tokyo' => 'Jepang (Tokyo)', 'Asia/Tomsk' => 'Rusia (Tomsk)', 'Asia/Urumqi' => 'Tiongkok (Urumqi)', 'Asia/Ust-Nera' => 'Rusia (Ust-Nera)', 'Asia/Vladivostok' => 'Rusia (Vladivostok)', 'Asia/Yakutsk' => 'Rusia (Yakutsk)', 'Asia/Yekaterinburg' => 'Rusia (Yekaterinburg)', 'Atlantic/Bermuda' => 'Waktu Atlantik (Bermuda)', 'Atlantic/Canary' => 'Waktu Éropa Barat (Canary)', 'Atlantic/Faeroe' => 'Waktu Éropa Barat (Faroe)', 'Atlantic/Madeira' => 'Waktu Éropa Barat (Madeira)', 'Atlantic/Reykjavik' => 'Waktu Greenwich (Reykjavik)', 'Atlantic/St_Helena' => 'Waktu Greenwich (St. Helena)', 'CST6CDT' => 'Waktu Tengah', 'EST5EDT' => 'Waktu Wétan', 'Etc/GMT' => 'Waktu Greenwich', 'Etc/UTC' => 'Waktu Universal Terkoordinasi', 'Europe/Amsterdam' => 'Waktu Éropa Tengah (Amsterdam)', 'Europe/Andorra' => 'Waktu Éropa Tengah (Andorra)', 'Europe/Astrakhan' => 'Rusia (Astrakhan)', 'Europe/Athens' => 'Waktu Éropa Timur (Athens)', 'Europe/Belgrade' => 'Waktu Éropa Tengah (Belgrade)', 'Europe/Berlin' => 'Waktu Éropa Tengah (Berlin)', 'Europe/Bratislava' => 'Waktu Éropa Tengah (Bratislava)', 'Europe/Brussels' => 'Waktu Éropa Tengah (Brussels)', 'Europe/Bucharest' => 'Waktu Éropa Timur (Bucharest)', 'Europe/Budapest' => 'Waktu Éropa Tengah (Budapest)', 'Europe/Busingen' => 'Waktu Éropa Tengah (Busingen)', 'Europe/Chisinau' => 'Waktu Éropa Timur (Chisinau)', 'Europe/Copenhagen' => 'Waktu Éropa Tengah (Copenhagen)', 'Europe/Dublin' => 'Waktu Greenwich (Dublin)', 'Europe/Gibraltar' => 'Waktu Éropa Tengah (Gibraltar)', 'Europe/Guernsey' => 'Waktu Greenwich (Guernsey)', 'Europe/Helsinki' => 'Waktu Éropa Timur (Helsinki)', 'Europe/Isle_of_Man' => 'Waktu Greenwich (Isle of Man)', 'Europe/Jersey' => 'Waktu Greenwich (Jersey)', 'Europe/Kaliningrad' => 'Waktu Éropa Timur (Kaliningrad)', 'Europe/Kiev' => 'Waktu Éropa Timur (Kiev)', 'Europe/Kirov' => 'Rusia (Kirov)', 'Europe/Lisbon' => 'Waktu Éropa Barat (Lisbon)', 'Europe/Ljubljana' => 'Waktu Éropa Tengah (Ljubljana)', 'Europe/London' => 'Waktu Greenwich (London)', 'Europe/Luxembourg' => 'Waktu Éropa Tengah (Luxembourg)', 'Europe/Madrid' => 'Waktu Éropa Tengah (Madrid)', 'Europe/Malta' => 'Waktu Éropa Tengah (Malta)', 'Europe/Mariehamn' => 'Waktu Éropa Timur (Mariehamn)', 'Europe/Monaco' => 'Waktu Éropa Tengah (Monaco)', 'Europe/Moscow' => 'Rusia (Moscow)', 'Europe/Oslo' => 'Waktu Éropa Tengah (Oslo)', 'Europe/Paris' => 'Waktu Éropa Tengah (Paris)', 'Europe/Podgorica' => 'Waktu Éropa Tengah (Podgorica)', 'Europe/Prague' => 'Waktu Éropa Tengah (Prague)', 'Europe/Riga' => 'Waktu Éropa Timur (Riga)', 'Europe/Rome' => 'Waktu Éropa Tengah (Rome)', 'Europe/Samara' => 'Rusia (Samara)', 'Europe/San_Marino' => 'Waktu Éropa Tengah (San Marino)', 'Europe/Sarajevo' => 'Waktu Éropa Tengah (Sarajevo)', 'Europe/Saratov' => 'Rusia (Saratov)', 'Europe/Skopje' => 'Waktu Éropa Tengah (Skopje)', 'Europe/Sofia' => 'Waktu Éropa Timur (Sofia)', 'Europe/Stockholm' => 'Waktu Éropa Tengah (Stockholm)', 'Europe/Tallinn' => 'Waktu Éropa Timur (Tallinn)', 'Europe/Tirane' => 'Waktu Éropa Tengah (Tirane)', 'Europe/Ulyanovsk' => 'Rusia (Ulyanovsk)', 'Europe/Uzhgorod' => 'Waktu Éropa Timur (Uzhgorod)', 'Europe/Vaduz' => 'Waktu Éropa Tengah (Vaduz)', 'Europe/Vatican' => 'Waktu Éropa Tengah (Vatican)', 'Europe/Vienna' => 'Waktu Éropa Tengah (Vienna)', 'Europe/Vilnius' => 'Waktu Éropa Timur (Vilnius)', 'Europe/Volgograd' => 'Rusia (Volgograd)', 'Europe/Warsaw' => 'Waktu Éropa Tengah (Warsaw)', 'Europe/Zagreb' => 'Waktu Éropa Tengah (Zagreb)', 'Europe/Zaporozhye' => 'Waktu Éropa Timur (Zaporozhye)', 'Europe/Zurich' => 'Waktu Éropa Tengah (Zurich)', 'MST7MDT' => 'Waktu Pagunungan', 'PST8PDT' => 'Waktu Pasifik', 'Pacific/Galapagos' => 'Waktu Galapagos', 'Pacific/Honolulu' => 'Amérika Sarikat (Honolulu)', ], 'Meta' => [ ], ];
mit
okyada/p2-php
rep2/js/post_form.js
4984
// textarea‚̍‚‚³‚ðƒ‰ƒCƒu’²ß‚·‚é function adjustTextareaRows(obj, org, plus) { var brlen = null; if (obj.wrap) { if (obj.wrap == 'virtual' || obj.wrap == 'soft') { brlen = obj.cols; } } var aLen = countLines(obj.value, brlen); var aRows = aLen + plus; var move = 0; var scroll = 14; if (org) { if (Math.max(aRows, obj.rows) > org) { move = Math.abs((aRows - obj.rows) * scroll); if (move) { obj.rows = Math.max(org, aRows); window.scrollBy(0, move); } } /* if (aRows > org + plus) { if (obj.rows < aRows) { move = (aRows - obj.rows) * scroll; } else if (obj.rows > aRows) { move = (aRows - obj.rows) * -scroll; } if (move != 0) { if (move < 0) { window.scrollBy(0, move); } obj.rows = aRows; if (move > 0) { window.scrollBy(0, move); } } } */ } else if (obj.rows < aRows) { move = (aRows - obj.rows) * scroll; obj.rows = aRows; window.scrollBy(0, move); } } /** * \n ‚ð‰üs‚Æ‚µ‚čs”‚𐔂¦‚é * * @param integer brlen ‰üs‚·‚é•¶Žš”B–³Žw’è‚È‚ç•¶Žš”‚ʼnüs‚µ‚È‚¢ */ function countLines(str, brlen) { var lines = str.split("\n"); var count = lines.length; var aLen = 0; for (var i = 0; i < lines.length; i++) { aLen = jstrlen(lines[i]); if (brlen) { var adjust = 1.15; // ’PŒê’PˆÊ‚̐܂è•Ô‚µ‚ɑΉž‚µ‚Ä‚¢‚È‚¢‚̂ŃAƒoƒEƒg’²® if ((aLen * adjust) > brlen) { count = count + Math.floor((aLen * adjust) / brlen); } } } return count; } // •¶Žš—ñ‚ðƒoƒCƒg”‚Ő”‚¦‚é function jstrlen(str) { var len = 0; str = escape(str); for (var i = 0; i < str.length; i++, len++) { if (str.charAt(i) == "%") { if (str.charAt(++i) == "u") { i += 3; len++; } i++; } } return len; } // (‘Ώۂªdisable‚łȂ¯‚ê‚Î) ƒtƒH[ƒJƒX‚ð‡‚í‚¹‚é function setFocus(ID){ var obj; if (obj = document.getElementById(ID)) { if (obj.disabled != true) { obj.focus(); } } } // sageƒ`ƒFƒbƒN‚ɍ‡‚킹‚āAƒ[ƒ‹—“‚Ì“à—e‚ð‘‚«Š·‚¦‚é function mailSage(){ var mailran, cbsage; if (cbsage = document.getElementById('sage')) { if (mailran = document.getElementById('mail')) { if (cbsage.checked == true) { mailran.value = "sage"; } else { if (mailran.value == "sage") { mailran.value = ""; } } } } } // ƒ[ƒ‹—“‚Ì“à—e‚ɉž‚¶‚āAsageƒ`ƒFƒbƒN‚ðON OFF‚·‚é function checkSage(){ var mailran, cbsage; if (mailran = document.getElementById('mail')) { if (cbsage = document.getElementById('sage')) { if (mailran.value == "sage") { cbsage.checked = true; } else { cbsage.checked = false; } } } } /* // Ž©“®‚œǂݍž‚Þ‚±‚Ƃɂµ‚½‚̂ŁAŽg‚í‚È‚¢ // ‘O‰ñ‚̏‘‚«ž‚Ý“à—e‚𕜋A‚·‚é function loadLastPosted(from, mail, message){ if (fromran = document.getElementById('FROM')) { fromran.value = from; } if (mailran = document.getElementById('mail')) { mailran.value = mail; } if (messageran = document.getElementById('MESSAGE')) { messageran.value = message; } checkSage(); } */ // ‘‚«ž‚݃{ƒ^ƒ“‚Ì—LŒøE–³Œø‚ðØ‚è‘Ö‚¦‚é function switchBlockSubmit(onoff) { var kakiko_submit = document.getElementById('kakiko_submit'); if (kakiko_submit) { kakiko_submit.disabled = onoff; } var submit_beres = document.getElementById('submit_beres'); if (submit_beres) { submit_beres.disabled = onoff; } } // ’èŒ^•¶‚ð‘}“ü‚·‚é function inputConstant(obj) { var msg = document.getElementById('MESSAGE'); msg.value = msg.value + obj.options[obj.selectedIndex].value; msg.focus(); obj.options[0].selected = true; } // ‘‚«ž‚Ý“à—e‚ðŒŸØ‚·‚é function validateAll(doValidateMsg, doValidateSage) { var block_submit = document.getElementById('block_submit'); if (block_submit && block_submit.checked) { alert('‘‚«ž‚݃uƒƒbƒN’†'); return false; } if (doValidateMsg && !validateMsg()) { return false; } if (doValidateSage && !validateSage()) { return false; } return true; } // –{•¶‚ª‹ó‚łȂ¢‚©ŒŸØ‚·‚é function validateMsg() { if (document.getElementById('MESSAGE').value.length == 0) { alert('–{•¶‚ª‚ ‚è‚Ü‚¹‚ñB'); return false; } return true; } // sage‚Ä‚¢‚é‚©ŒŸØ‚·‚é function validateSage() { if (document.getElementById('mail').value.indexOf('sage') == -1) { if (window.confirm('sage‚Ă܂¹‚ñ‚æH')) { return true; } else { return false; } } return true; } // ˆø”‚Étrue‚ðŽw’肵‚½‚ç–¼–³‚µ‚ŏ‘ž‚·‚é‚©‚Ç‚¤‚©Šm”F‚·‚é function confirmNanashi(doconfirmNanashi) { // ˆø”‚ªtrue‚Å–¼‘O—“‚ª0•¶Žš(–¼–³‚µ)‚È‚ç‚Î if (doconfirmNanashi && document.getElementById('FROM').value.length == 0) { if(window.confirm('‚±‚̔‚͖¼–³‚µ‚É fusianasan ‚ªŠÜ‚Ü‚ê‚Ä‚¢‚Ü‚·B\n–¼–³‚µ‚ŏ‘‚«ž‚݂܂·‚©H')) { return true; } else { return false; } } return true; } //ˆø”‚Étrue‚ðŽw’肵‚½‚ç–¼–³‚µ‚ŏ‘žo—ˆ‚È‚¢ function blockNanashi(blockNanashi) { // ˆø”‚ªtrue‚Å–¼‘O—“‚ª0•¶Žš(–¼–³‚µ)‚È‚ç‚Î if (blockNanashi && document.getElementById('FROM').value.length == 0) { alert('‚±‚̔‚͖¼–³‚µ‚̏‘‚«ž‚Ý‚ª§ŒÀ‚³‚ê‚Ä‚¢‚é‚̂Ŗ¼–³‚µ‚ŏ‘‚«ž‚Þ‚±‚Æ‚ªo—ˆ‚Ü‚¹‚ñB'); return false; } return true; }
mit
eriawan/octokit.net
Octokit/Models/Request/IssueCommentRequest.cs
1391
using System; using System.Diagnostics; using System.Globalization; namespace Octokit { /// <summary> /// Used to filter issue comments. /// </summary> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class IssueCommentRequest : RequestParameters { /// <summary> /// Initializes a new instance of the <see cref="IssueCommentRequest"/> class. /// </summary> public IssueCommentRequest() { // Default arguments Sort = PullRequestReviewCommentSort.Created; Direction = SortDirection.Ascending; Since = null; } /// <summary> /// Can be either created or updated. Default: created. /// </summary> public PullRequestReviewCommentSort Sort { get; set; } /// <summary> /// Can be either asc or desc. Default: asc. /// </summary> public SortDirection Direction { get; set; } /// <summary> /// Only comments updated at or after this time are returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. /// </summary> public DateTimeOffset? Since { get; set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Sort: {0}, Direction: {1}, Since: {2}", Sort, Direction, Since); } } } }
mit
cdnjs/cdnjs
ajax/libs/primeng/10.0.3/esm2015/utils/public_api.js
585
export * from './filterutils'; export * from './objectutils'; export * from './uniquecomponentid'; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvY29tcG9uZW50cy91dGlscy9wdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMscUJBQXFCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2ZpbHRlcnV0aWxzJztcbmV4cG9ydCAqIGZyb20gJy4vb2JqZWN0dXRpbHMnO1xuZXhwb3J0ICogZnJvbSAnLi91bmlxdWVjb21wb25lbnRpZCc7ICJdfQ==
mit
dipakmankumbare/idecore
com.salesforce.ide.ui.test/src/com/salesforce/ide/ui/views/log/LogViewTest_unit.java
1175
/******************************************************************************* * Copyright (c) 2014 Salesforce.com, inc.. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Salesforce.com, inc. - initial API and implementation ******************************************************************************/ package com.salesforce.ide.ui.views.log; import static org.mockito.Mockito.mock; import java.io.File; import junit.framework.TestCase; /** * Class to unit test Logview * @author bvenkatesan * */ public class LogViewTest_unit extends TestCase { public void testCheckSpaceInLogEntryBeforeParentheses() throws Exception { String mockMessage = "Unable to get component for id"; File mockFile = mock(File.class); LogEntry mockEntry = mock(LogEntry.class); String TestMessage = new LogView(mockFile).new LogViewLabelProvider().getExceptionMessage(mockMessage, mockEntry); assertTrue(TestMessage.contains(" (Open")); } }
epl-1.0
johannrichard/openhab2-addons
addons/binding/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/command/ControlCommand.java
2159
/** * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ package org.openhab.binding.satel.internal.command; import org.apache.commons.lang.StringUtils; import org.openhab.binding.satel.internal.protocol.SatelMessage; /** * Base class for all commands that return result code in the response. * * @author Krzysztof Goworek - Initial contribution * @since 1.9.0 */ public abstract class ControlCommand extends SatelCommandBase { /** * Creates new command class instance. * * @param commandCode * command code * @param payload */ public ControlCommand(byte commandCode, byte[] payload) { super(commandCode, payload); } @Override protected boolean isResponseValid(SatelMessage response) { return true; } protected static byte[] userCodeToBytes(String userCode) { if (StringUtils.isEmpty(userCode)) { throw new IllegalArgumentException("User code is empty"); } if (userCode.length() > 8) { throw new IllegalArgumentException("User code too long"); } byte[] bytes = new byte[8]; int digitsNbr = 2 * bytes.length; for (int i = 0; i < digitsNbr; ++i) { if (i < userCode.length()) { char digit = userCode.charAt(i); if (!Character.isDigit(digit)) { throw new IllegalArgumentException("User code must contain digits only"); } if (i % 2 == 0) { bytes[i / 2] = (byte) ((digit - '0') << 4); } else { bytes[i / 2] |= (byte) (digit - '0'); } } else if (i % 2 == 0) { bytes[i / 2] = (byte) 0xff; } else if (i == userCode.length()) { bytes[i / 2] |= 0x0f; } } return bytes; } }
epl-1.0
davidfestal/che
selenium/che-selenium-test/src/test/resources/projects/console-cpp-simple/iseven.h
407
/** * Copyright (c) 2012-2018 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Red Hat, Inc. - initial API and implementation */ #ifndef VARIABLE #define VARIABLE int isEven(int arg); #endif
epl-1.0
gorindn/ice
src/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRAssembly.java
6609
/******************************************************************************* * Copyright (c) 2013, 2014 UT-Battelle, LLC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Initial API and implementation and/or initial documentation - Jay Jay Billings, * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ package org.eclipse.ice.reactor.sfr.core.assembly; import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; import org.eclipse.ice.reactor.sfr.base.SFRComposite; import org.eclipse.ice.reactor.sfr.core.AssemblyType; /** * <p> * Class representing the assembly structure of a SFR. The SFR assembly is * housed in a hexagonal structure called the wrapper tube (or duct), and * contains a lattice of either pins or rods. * </p> * * @author Anna Wojtowicz */ public class SFRAssembly extends SFRComposite { /** * <p> * Size of a SFRAssembly. Size represents number of pins in a fuel or * control assembly, and rods in a reflector assembly. * </p> * */ private int size; /** * <p> * The type of SFR assembly represented, either fuel, control or reflector. * </p> * */ protected AssemblyType assemblyType; /** * <p> * Thickness of the assembly duct wall. * </p> * */ private double ductThickness; /** * <p> * Parameterized constructor with assemble size specified. Size represents * number of pins in a fuel or control assembly, and rods in a reflector * assembly. * </p> * * @param size * Size of the assembly. */ public SFRAssembly(int size) { // Set the size if positive, otherwise default to 1. this.size = (size > 0 ? size : 1); // Set the default name, description, and ID. setName("SFR Assembly 1"); setDescription("SFR Assembly 1's Description"); setId(1); // Default the assembly type to Fuel. assemblyType = AssemblyType.Fuel; // Initialize ductThickness. ductThickness = 0.0; return; } /** * <p> * Parameterized constructor with assembly name, type and size specified. * Size represents number of pins in a fuel or control assembly, and rods in * a reflector assembly. * </p> * * @param name * The name of the assembly. * @param type * The assembly type (fuel, control or reflector). * @param size * The size of the assembly. */ public SFRAssembly(String name, AssemblyType type, int size) { // Call the basic constructor first. this(size); // Set the name. setName(name); // Set the assembly type if possible. If null, the other constructor has // already set the type to the default (Fuel). if (type != null) { assemblyType = type; } return; } /** * <p> * Returns the assembly size. Size represents number of pins in a fuel or * control assembly, and rods in a reflector assembly. * </p> * * @return The size of the assembly. */ public int getSize() { return size; } /** * <p> * Returns the assembly type (fuel, control or reflector). * </p> * * @return The assembly type. */ public AssemblyType getAssemblyType() { return assemblyType; } /** * <p> * Sets the thickness of the assembly duct wall. * </p> * * @param thickness * The duct thickness. Must be non-negative. */ public void setDuctThickness(double thickness) { // Only set the duct thickness if it is 0 or larger. if (thickness >= 0.0) { ductThickness = thickness; } return; } /** * <p> * Returns the duct wall thickness of an assembly as a double. * </p> * * @return The duct thickness. */ public double getDuctThickness() { return ductThickness; } /** * <p> * Overrides the equals operation to check the attributes on this object * with another object of the same type. Returns true if the objects are * equal. False otherwise. * </p> * * @param otherObject * The object to be compared. * @return True if otherObject is equal. False otherwise. */ @Override public boolean equals(Object otherObject) { // By default, the objects are not equivalent. boolean equals = false; // Check the reference. if (this == otherObject) { equals = true; } // Check the information stored in the other object. else if (otherObject != null && otherObject instanceof SFRAssembly) { // We can now cast the other object. SFRAssembly assembly = (SFRAssembly) otherObject; // Compare the values between the two objects. equals = (super.equals(otherObject) && size == assembly.size && assemblyType == assembly.assemblyType && ductThickness == assembly.ductThickness); } return equals; } /** * <p> * Returns the hashCode of the object. * </p> * * @return <p> * The hash of the object. * </p> */ @Override public int hashCode() { // Hash based on super's hashCode. int hash = super.hashCode(); // Add local hashes. hash += 31 * size; hash += 31 * assemblyType.hashCode(); hash += 31 * ductThickness; return hash; } /** * <p> * Deep copies the contents of the object from another object. * </p> * * @param otherObject * <p> * The object to be copied from. * </p> */ public void copy(SFRAssembly otherObject) { // Check the parameters. if (otherObject == null) { return; } // Copy the super's values. super.copy(otherObject); // Copy the local values. size = otherObject.size; assemblyType = otherObject.assemblyType; ductThickness = otherObject.ductThickness; return; } /** * <p> * Deep copies and returns a newly instantiated object. * </p> * * @return <p> * The newly instantiated copied object. * </p> */ @Override public Object clone() { // Initialize a new object. SFRAssembly object = new SFRAssembly(size); // Copy the contents from this one. object.copy(this); // Return the newly instantiated object. return object; } /** * Overrides the default behavior (ignore) from SFRComponent and implements * the accept operation for this SFRComponent's type. */ @Override public void accept(ISFRComponentVisitor visitor) { if (visitor != null) { visitor.visit(this); } return; } }
epl-1.0
kreynen/civicrm-starterkit-drops-7
profiles/civicrm_starterkit/modules/civicrm/api/v3/examples/GroupNesting/Delete.ex.php
1670
<?php /** * Test Generated example demonstrating the GroupNesting.delete API. * * @return array * API result array */ function group_nesting_delete_example() { $params = [ 'id' => 1, ]; try{ $result = civicrm_api3('GroupNesting', 'delete', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. $errorMessage = $e->getMessage(); $errorCode = $e->getErrorCode(); $errorData = $e->getExtraParams(); return [ 'is_error' => 1, 'error_message' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData, ]; } return $result; } /** * Function returns array of result expected from previous function. * * @return array * API result array */ function group_nesting_delete_expectedresult() { $expectedResult = [ 'is_error' => 0, 'version' => 3, 'count' => 1, 'values' => 1, ]; return $expectedResult; } /* * This example has been generated from the API test suite. * The test that created it is called "testDelete" * and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupNestingTest.php * * You can see the outcome of the API tests at * https://test.civicrm.org/job/CiviCRM-Core-Matrix/ * * To Learn about the API read * https://docs.civicrm.org/dev/en/latest/api/ * * Browse the API on your own site with the API Explorer. It is in the main * CiviCRM menu, under: Support > Development > API Explorer. * * Read more about testing here * https://docs.civicrm.org/dev/en/latest/testing/ * * API Standards documentation: * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/ */
gpl-2.0
vliaskov/gst-plugins-bad
ext/kate/gstkatespu.c
27514
/* GStreamer * Copyright (C) 2009 Vincent Penquerc'h <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <string.h> #include <kate/kate.h> #include <gst/gst.h> #include <gst/gstpad.h> #include "gstkatespu.h" #define MAX_SPU_SIZE 53220 GST_DEBUG_CATEGORY_EXTERN (gst_kateenc_debug); GST_DEBUG_CATEGORY_EXTERN (gst_katedec_debug); /* taken off the dvdsubdec element */ const guint32 gst_kate_spu_default_clut[16] = { 0xb48080, 0x248080, 0x628080, 0xd78080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080, 0x808080 }; #define GST_CAT_DEFAULT gst_kateenc_debug static void gst_kate_spu_decode_colormap (GstKateEnc * ke, const guint8 * ptr) { ke->spu_colormap[3] = ptr[0] >> 4; ke->spu_colormap[2] = ptr[0] & 0x0f; ke->spu_colormap[1] = ptr[1] >> 4; ke->spu_colormap[0] = ptr[1] & 0x0f; } static void gst_kate_spu_decode_alpha (GstKateEnc * ke, const guint8 * ptr) { ke->spu_alpha[3] = ptr[0] >> 4; ke->spu_alpha[2] = ptr[0] & 0x0f; ke->spu_alpha[1] = ptr[1] >> 4; ke->spu_alpha[0] = ptr[1] & 0x0f; } static void gst_kate_spu_decode_area (GstKateEnc * ke, const guint8 * ptr) { ke->spu_left = ((((guint16) ptr[0]) & 0xff) << 4) | (ptr[1] >> 4); ke->spu_top = ((((guint16) ptr[3]) & 0xff) << 4) | (ptr[4] >> 4); ke->spu_right = ((((guint16) ptr[1]) & 0x0f) << 8) | ptr[2]; ke->spu_bottom = ((((guint16) ptr[4]) & 0x0f) << 8) | ptr[5]; GST_DEBUG_OBJECT (ke, "SPU area %u %u -> %u %d", ke->spu_left, ke->spu_top, ke->spu_right, ke->spu_bottom); } static void gst_kate_spu_decode_pixaddr (GstKateEnc * ke, const guint8 * ptr) { ke->spu_pix_data[0] = GST_KATE_UINT16_BE (ptr + 0); ke->spu_pix_data[1] = GST_KATE_UINT16_BE (ptr + 2); } /* heavily inspired from dvdspudec */ static guint16 gst_kate_spu_decode_colcon (GstKateEnc * ke, const guint8 * ptr, guint16 sz) { guint16 nbytes = GST_KATE_UINT16_BE (ptr + 0); guint16 nbytes_left = nbytes; GST_LOG_OBJECT (ke, "Number of bytes in color/contrast change command is %u", nbytes); if (G_UNLIKELY (nbytes < 2)) { GST_WARNING_OBJECT (ke, "Number of bytes in color/contrast change command is %u, should be at least 2", nbytes); return 0; } if (G_UNLIKELY (nbytes > sz)) { GST_WARNING_OBJECT (ke, "Number of bytes in color/contrast change command is %u, but the buffer " "only contains %u byte(s)", nbytes, sz); return 0; } ptr += 2; nbytes_left -= 2; /* we will just skip that data for now */ while (nbytes_left > 0) { guint32 entry, nchanges, sz; GST_LOG_OBJECT (ke, "Reading a color/contrast change entry, %u bytes left", nbytes_left); if (G_UNLIKELY (nbytes_left < 4)) { GST_WARNING_OBJECT (ke, "Not enough bytes to read a full color/contrast entry header"); break; } entry = GST_READ_UINT32_BE (ptr); GST_LOG_OBJECT (ke, "Color/contrast change entry header is %08x", entry); nchanges = CLAMP ((ptr[2] >> 4), 1, 8); ptr += 4; nbytes_left -= 4; if (entry == 0x0fffffff) { GST_LOG_OBJECT (ke, "Encountered color/contrast change termination code, breaking, %u bytes left", nbytes_left); break; } GST_LOG_OBJECT (ke, "Color/contrast change entry has %u changes", nchanges); sz = 6 * nchanges; if (G_UNLIKELY (sz > nbytes_left)) { GST_WARNING_OBJECT (ke, "Not enough bytes to read a full color/contrast entry"); break; } ptr += sz; nbytes_left -= sz; } return nbytes - nbytes_left; } static inline guint8 gst_kate_spu_get_nybble (const guint8 * nybbles, size_t * nybble_offset) { guint8 ret; ret = nybbles[(*nybble_offset) / 2]; /* If the offset is even, we shift the answer down 4 bits, otherwise not */ if ((*nybble_offset) & 0x01) ret &= 0x0f; else ret = ret >> 4; (*nybble_offset)++; return ret; } static guint16 gst_kate_spu_get_rle_code (const guint8 * nybbles, size_t * nybble_offset) { guint16 code; code = gst_kate_spu_get_nybble (nybbles, nybble_offset); if (code < 0x4) { /* 4 .. f */ code = (code << 4) | gst_kate_spu_get_nybble (nybbles, nybble_offset); if (code < 0x10) { /* 1x .. 3x */ code = (code << 4) | gst_kate_spu_get_nybble (nybbles, nybble_offset); if (code < 0x40) { /* 04x .. 0fx */ code = (code << 4) | gst_kate_spu_get_nybble (nybbles, nybble_offset); } } } return code; } static void gst_kate_spu_crop_bitmap (GstKateEnc * ke, kate_bitmap * kb, guint16 * dx, guint16 * dy) { int top, bottom, left, right; guint8 zero = 0; size_t n, x, y, w, h; #if 0 /* find the zero */ zero = kb->pixels[0]; for (x = 0; x < kb->width; ++x) { if (kb->pixels[x] != zero) { GST_LOG_OBJECT (ke, "top line at %u is not zero: %u", x, kb->pixels[x]); return; } } #endif /* top */ for (top = 0; top < kb->height; ++top) { int empty = 1; for (x = 0; x < kb->width; ++x) { if (G_UNLIKELY (kb->pixels[x + top * kb->width] != zero)) { empty = 0; break; } } if (!empty) break; } /* bottom */ for (bottom = kb->height - 1; bottom >= top; --bottom) { int empty = 1; for (x = 0; x < kb->width; ++x) { if (G_UNLIKELY (kb->pixels[x + bottom * kb->width] != zero)) { empty = 0; break; } } if (!empty) break; } /* left */ for (left = 0; left < kb->width; ++left) { int empty = 1; for (y = top; y <= bottom; ++y) { if (G_UNLIKELY (kb->pixels[left + y * kb->width] != zero)) { empty = 0; break; } } if (!empty) break; } /* right */ for (right = kb->width - 1; right >= left; --right) { int empty = 1; for (y = top; y <= bottom; ++y) { if (G_UNLIKELY (kb->pixels[right + y * kb->width] != zero)) { empty = 0; break; } } if (!empty) break; } w = right - left + 1; h = bottom - top + 1; GST_LOG_OBJECT (ke, "cropped from %" G_GSIZE_FORMAT " %" G_GSIZE_FORMAT " to %" G_GSIZE_FORMAT " %" G_GSIZE_FORMAT, kb->width, kb->height, w, h); *dx += left; *dy += top; n = 0; for (y = 0; y < h; ++y) { memmove (kb->pixels + n, kb->pixels + kb->width * (y + top) + left, w); n += w; } kb->width = w; kb->height = h; } #define CHECK(x) G_STMT_START { \ guint16 _ = (x); \ if (G_UNLIKELY((_) > sz)) { \ GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Read outside buffer")); \ return GST_FLOW_ERROR; \ } \ } G_STMT_END #define ADVANCE(x) G_STMT_START { \ guint16 _ = (x); ptr += (_); sz -= (_); \ } G_STMT_END #define IGNORE(x) G_STMT_START { \ guint16 __ = (x); \ CHECK (__); \ ADVANCE (__); \ } G_STMT_END static GstFlowReturn gst_kate_spu_decode_command_sequence (GstKateEnc * ke, GstBuffer * buf, guint16 command_sequence_offset) { guint16 date; guint16 next_command_sequence; const guint8 *ptr; GstMapInfo info; guint16 sz; if (!gst_buffer_map (buf, &info, GST_MAP_READ)) { GST_ERROR_OBJECT (ke, "Failed to map buffer"); return GST_FLOW_ERROR; } if (command_sequence_offset >= info.size) goto out_of_range; ptr = info.data + command_sequence_offset; sz = info.size - command_sequence_offset; GST_DEBUG_OBJECT (ke, "Decoding command sequence at %u (%u bytes)", command_sequence_offset, sz); CHECK (2); date = GST_KATE_UINT16_BE (ptr); ADVANCE (2); GST_DEBUG_OBJECT (ke, "date %u", date); CHECK (2); next_command_sequence = GST_KATE_UINT16_BE (ptr); ADVANCE (2); GST_DEBUG_OBJECT (ke, "next command sequence at %u", next_command_sequence); while (sz) { guint8 cmd = *ptr++; switch (cmd) { case SPU_CMD_FSTA_DSP: /* 0x00 */ GST_DEBUG_OBJECT (ke, "[0] DISPLAY"); break; case SPU_CMD_DSP: /* 0x01 */ GST_DEBUG_OBJECT (ke, "[1] SHOW"); ke->show_time = date; break; case SPU_CMD_STP_DSP: /* 0x02 */ GST_DEBUG_OBJECT (ke, "[2] HIDE"); ke->hide_time = date; break; case SPU_CMD_SET_COLOR: /* 0x03 */ GST_DEBUG_OBJECT (ke, "[3] SET COLOR"); CHECK (2); gst_kate_spu_decode_colormap (ke, ptr); ADVANCE (2); break; case SPU_CMD_SET_ALPHA: /* 0x04 */ GST_DEBUG_OBJECT (ke, "[4] SET ALPHA"); CHECK (2); gst_kate_spu_decode_alpha (ke, ptr); ADVANCE (2); break; case SPU_CMD_SET_DAREA: /* 0x05 */ GST_DEBUG_OBJECT (ke, "[5] SET DISPLAY AREA"); CHECK (6); gst_kate_spu_decode_area (ke, ptr); ADVANCE (6); break; case SPU_CMD_DSPXA: /* 0x06 */ GST_DEBUG_OBJECT (ke, "[6] SET PIXEL ADDRESSES"); CHECK (4); gst_kate_spu_decode_pixaddr (ke, ptr); GST_DEBUG_OBJECT (ke, " -> first pixel address %u", ke->spu_pix_data[0]); GST_DEBUG_OBJECT (ke, " -> second pixel address %u", ke->spu_pix_data[1]); ADVANCE (4); break; case SPU_CMD_CHG_COLCON: /* 0x07 */ GST_DEBUG_OBJECT (ke, "[7] CHANGE COLOR/CONTRAST"); CHECK (2); ADVANCE (gst_kate_spu_decode_colcon (ke, ptr, sz)); break; case SPU_CMD_END: /* 0xff */ GST_DEBUG_OBJECT (ke, "[0xff] END"); if (next_command_sequence != command_sequence_offset) { GST_DEBUG_OBJECT (ke, "Jumping to next sequence at offset %u", next_command_sequence); gst_buffer_unmap (buf, &info); return gst_kate_spu_decode_command_sequence (ke, buf, next_command_sequence); } else { gst_buffer_unmap (buf, &info); GST_DEBUG_OBJECT (ke, "No more sequences to decode"); return GST_FLOW_OK; } break; default: gst_buffer_unmap (buf, &info); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Invalid SPU command: %u", cmd)); return GST_FLOW_ERROR; } } gst_buffer_unmap (buf, &info); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Error parsing SPU")); return GST_FLOW_ERROR; /* ERRORS */ out_of_range: { gst_buffer_unmap (buf, &info); GST_ELEMENT_ERROR (ke, STREAM, DECODE, (NULL), ("Command sequence offset %u is out of range %zu", command_sequence_offset, info.size)); return GST_FLOW_ERROR; } } static inline int gst_kate_spu_clamp (int value) { if (value < 0) return 0; if (value > 255) return 255; return value; } static void gst_kate_spu_yuv2rgb (int y, int u, int v, int *r, int *g, int *b) { #if 0 *r = gst_kate_spu_clamp (y + 1.371 * v); *g = gst_kate_spu_clamp (y - 0.698 * v - 0.336 * u); *b = gst_kate_spu_clamp (y + 1.732 * u); #elif 0 *r = gst_kate_spu_clamp (y + u); *g = gst_kate_spu_clamp (y - (76 * u - 26 * v) / 256); *b = gst_kate_spu_clamp (y + v); #else y = (y - 16) * 255 / 219; u = (u - 128) * 255 / 224; v = (v - 128) * 255 / 224; *r = gst_kate_spu_clamp (y + 1.402 * v); *g = gst_kate_spu_clamp (y - 0.34414 * u - 0.71414 * v); *b = gst_kate_spu_clamp (y + 1.772 * u); #endif } static GstFlowReturn gst_kate_spu_create_spu_palette (GstKateEnc * ke, kate_palette * kp) { size_t n; kate_palette_init (kp); kp->ncolors = 4; kp->colors = (kate_color *) g_malloc (kp->ncolors * sizeof (kate_color)); if (G_UNLIKELY (!kp->colors)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Out of memory")); return GST_FLOW_ERROR; } #if 1 for (n = 0; n < kp->ncolors; ++n) { int idx = ke->spu_colormap[n]; guint32 color = ke->spu_clut[idx]; int y = (color >> 16) & 0xff; int v = (color >> 8) & 0xff; int u = color & 0xff; int r, g, b; gst_kate_spu_yuv2rgb (y, u, v, &r, &g, &b); kp->colors[n].r = r; kp->colors[n].g = g; kp->colors[n].b = b; kp->colors[n].a = ke->spu_alpha[n] * 17; } #else /* just make a ramp from 0 to 255 for those non transparent colors */ for (n = 0; n < kp->ncolors; ++n) if (ke->spu_alpha[n] == 0) ++ntrans; for (n = 0; n < kp->ncolors; ++n) { kp->colors[n].r = luma; kp->colors[n].g = luma; kp->colors[n].b = luma; kp->colors[n].a = ke->spu_alpha[n] * 17; if (ke->spu_alpha[n]) luma /= 2; } #endif return GST_FLOW_OK; } GstFlowReturn gst_kate_spu_decode_spu (GstKateEnc * ke, GstBuffer * buf, kate_region * kr, kate_bitmap * kb, kate_palette * kp) { GstMapInfo info; const guint8 *ptr; size_t sz; guint16 packet_size; guint16 x, y; size_t n; guint8 *pixptr[2]; size_t nybble_offset[2]; size_t max_nybbles[2]; GstFlowReturn rflow; guint16 next_command_sequence; guint16 code; if (!gst_buffer_map (buf, &info, GST_MAP_READ)) { GST_ERROR_OBJECT (ke, "Failed to map buffer"); } ptr = info.data; sz = info.size; /* before decoding anything, initialize to sensible defaults */ memset (ke->spu_colormap, 0, sizeof (ke->spu_colormap)); memset (ke->spu_alpha, 0, sizeof (ke->spu_alpha)); ke->spu_top = ke->spu_left = 1; ke->spu_bottom = ke->spu_right = 0; ke->spu_pix_data[0] = ke->spu_pix_data[1] = 0; ke->show_time = ke->hide_time = 0; /* read sizes and get to the start of the data */ CHECK (2); packet_size = GST_KATE_UINT16_BE (ptr); ADVANCE (2); GST_DEBUG_OBJECT (ke, "packet size %d (GstBuffer size %zu)", packet_size, info.size); CHECK (2); next_command_sequence = GST_KATE_UINT16_BE (ptr); ADVANCE (2); ptr = info.data + next_command_sequence; sz = info.size - next_command_sequence; GST_DEBUG_OBJECT (ke, "next command sequence at %u for %u", next_command_sequence, (guint) sz); rflow = gst_kate_spu_decode_command_sequence (ke, buf, next_command_sequence); if (G_UNLIKELY (rflow != GST_FLOW_OK)) { gst_buffer_unmap (buf, &info); return rflow; } /* if no addresses or sizes were given, or if they define an empty SPU, nothing more to do */ if (G_UNLIKELY (ke->spu_right - ke->spu_left < 0 || ke->spu_bottom - ke->spu_top < 0 || ke->spu_pix_data[0] == 0 || ke->spu_pix_data[1] == 0)) { GST_DEBUG_OBJECT (ke, "left %d, right %d, top %d, bottom %d, pix data %d %d", ke->spu_left, ke->spu_right, ke->spu_top, ke->spu_bottom, ke->spu_pix_data[0], ke->spu_pix_data[1]); GST_WARNING_OBJECT (ke, "SPU area is empty, nothing to encode"); kate_bitmap_init (kb); kb->width = kb->height = 0; gst_buffer_unmap (buf, &info); return GST_FLOW_OK; } /* create the palette */ rflow = gst_kate_spu_create_spu_palette (ke, kp); if (G_UNLIKELY (rflow != GST_FLOW_OK)) { gst_buffer_unmap (buf, &info); return rflow; } /* create the bitmap */ kate_bitmap_init (kb); kb->width = ke->spu_right - ke->spu_left + 1; kb->height = ke->spu_bottom - ke->spu_top + 1; kb->bpp = 2; kb->type = kate_bitmap_type_paletted; kb->pixels = (unsigned char *) g_malloc (kb->width * kb->height); if (G_UNLIKELY (!kb->pixels)) { gst_buffer_unmap (buf, &info); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Failed to allocate memory for pixel data")); return GST_FLOW_ERROR; } n = 0; pixptr[0] = info.data + ke->spu_pix_data[0]; pixptr[1] = info.data + ke->spu_pix_data[1]; nybble_offset[0] = 0; nybble_offset[1] = 0; max_nybbles[0] = 2 * (packet_size - ke->spu_pix_data[0]); max_nybbles[1] = 2 * (packet_size - ke->spu_pix_data[1]); for (y = 0; y < kb->height; ++y) { nybble_offset[y & 1] = GST_ROUND_UP_2 (nybble_offset[y & 1]); for (x = 0; x < kb->width;) { if (G_UNLIKELY (nybble_offset[y & 1] >= max_nybbles[y & 1])) { GST_DEBUG_OBJECT (ke, "RLE overflow, clearing the remainder"); memset (kb->pixels + n, 0, kb->width - x); n += kb->width - x; break; } code = gst_kate_spu_get_rle_code (pixptr[y & 1], &nybble_offset[y & 1]); if (code == 0) { memset (kb->pixels + n, 0, kb->width - x); n += kb->width - x; break; } else { guint16 npixels = code >> 2; guint16 pixel = code & 3; if (npixels > kb->width - x) { npixels = kb->width - x; } memset (kb->pixels + n, pixel, npixels); n += npixels; x += npixels; } } } GST_LOG_OBJECT (ke, "%u/%u bytes left in the data packet", (guint) (max_nybbles[0] - nybble_offset[0]), (guint) (max_nybbles[1] - nybble_offset[1])); /* some streams seem to have huge uncropped SPUs, fix those up */ x = ke->spu_left; y = ke->spu_top; gst_kate_spu_crop_bitmap (ke, kb, &x, &y); /* create the region */ kate_region_init (kr); if (ke->original_canvas_width > 0 && ke->original_canvas_height > 0) { /* prefer relative sizes in case we're encoding for a different resolution that what the SPU was created for */ kr->metric = kate_millionths; kr->x = 1000000 * (size_t) x / ke->original_canvas_width; kr->y = 1000000 * (size_t) y / ke->original_canvas_height; kr->w = 1000000 * kb->width / ke->original_canvas_width; kr->h = 1000000 * kb->height / ke->original_canvas_height; } else { kr->metric = kate_pixel; kr->x = x; kr->y = y; kr->w = kb->width; kr->h = kb->height; } /* some SPUs have no hide time */ if (ke->hide_time == 0) { GST_INFO_OBJECT (ke, "SPU has no hide time"); /* now, we don't know when the next SPU is scheduled to go, since we probably haven't received it yet, so we'll just make it a 1 second delay, which is probably going to end before the next one while being readable */ //ke->hide_time = ke->show_time + (1000 * 90 / 1024); } gst_buffer_unmap (buf, &info); return GST_FLOW_OK; } #undef IGNORE #undef ADVANCE #undef CHECK #undef GST_CAT_DEFAULT #define GST_CAT_DEFAULT gst_katedec_debug static void gst_kate_spu_add_nybble (unsigned char *bytes, size_t nbytes, int nybble_offset, unsigned char nybble) { unsigned char *ptr = bytes + nbytes + nybble_offset / 2; if (!(nybble_offset & 1)) { *ptr = nybble << 4; } else { *ptr |= nybble; } } static void gst_kate_spu_rgb2yuv (int r, int g, int b, int *y, int *u, int *v) { *y = gst_kate_spu_clamp (r * 0.299 * 219 / 255 + g * 0.587 * 219 / 255 + b * 0.114 * 219 / 255 + 16); *u = gst_kate_spu_clamp (-r * 0.16874 * 224 / 255 - g * 0.33126 * 224 / 255 + b * 0.5 * 224 / 255 + 128); *v = gst_kate_spu_clamp (r * 0.5 * 224 / 255 - g * 0.41869 * 224 / 255 - b * 0.08131 * 224 / 255 + 128); } static void gst_kate_spu_make_palette (GstKateDec * kd, int palette[4], const kate_palette * kp) { int n; GstStructure *structure; GstEvent *event; char name[16]; int y, u, v; palette[0] = 0; palette[1] = 1; palette[2] = 2; palette[3] = 3; structure = gst_structure_new ("application/x-gst-dvd", "event", G_TYPE_STRING, "dvd-spu-clut-change", NULL); /* Create a separate field for each value in the table. */ for (n = 0; n < 16; n++) { guint32 color = 0; if (n < 4) { gst_kate_spu_rgb2yuv (kp->colors[n].r, kp->colors[n].g, kp->colors[n].b, &y, &u, &v); color = (y << 16) | (v << 8) | u; } g_snprintf (name, sizeof (name), "clut%02d", n); gst_structure_set (structure, name, G_TYPE_INT, (int) color, NULL); } /* Create the DVD event and put the structure into it. */ event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, structure); GST_LOG_OBJECT (kd, "preparing clut change event %" GST_PTR_FORMAT, event); gst_pad_push_event (kd->srcpad, event); } GstBuffer * gst_kate_spu_encode_spu (GstKateDec * kd, const kate_event * ev) { kate_tracker kin; unsigned char *bytes = NULL; size_t nbytes = 0; GstBuffer *buffer = NULL; int ret; int ocw, och; int top, left, right, bottom; int pass, line, row; int lines_offset[2]; int first_commands_offset, second_commands_offset; int nybble_count; const kate_bitmap *kb; const kate_palette *kp; int palette[4]; int delay; /* we need a region, a bitmap, and a palette */ if (!ev || !ev->region || !ev->bitmap || !ev->palette) return NULL; kb = ev->bitmap; kp = ev->palette; /* these need particular properties */ if (kb->type != kate_bitmap_type_paletted || kb->bpp != 2) return NULL; if (kp->ncolors != 4) return NULL; ret = kate_tracker_init (&kin, ev->ki, ev); if (ret < 0) { GST_WARNING_OBJECT (kd, "Failed to initialize kate tracker"); return NULL; } ocw = ev->ki->original_canvas_width; och = ev->ki->original_canvas_height; ret = kate_tracker_update (&kin, (kate_float) 0, ocw, och, 0, 0, ocw, och); if (ret < 0) goto error; if (kin.has.region) { top = (int) (kin.region_y + (kate_float) 0.5); left = (int) (kin.region_x + (kate_float) 0.5); } else { GST_WARNING_OBJECT (kd, "No region information to place SPU, placing at 0 0"); top = left = 0; } right = left + kb->width - 1; bottom = top + kb->height - 1; /* Allocate space to build the SPU */ bytes = g_malloc (MAX_SPU_SIZE); if (G_UNLIKELY (!bytes)) { GST_WARNING_OBJECT (kd, "Failed to allocate %" G_GSIZE_FORMAT " byte buffer", nbytes); goto error; } nbytes = 4; nybble_count = 0; #define CHKBUFSPC(nybbles) \ do { \ if ((nbytes + (nybbles + nybble_count + 1) / 2) > MAX_SPU_SIZE) { \ GST_WARNING_OBJECT (kd, "Not enough space in SPU buffer"); \ goto error; \ } \ } while(0) /* encode lines */ for (pass = 0; pass <= 1; ++pass) { lines_offset[pass] = nbytes; for (line = pass; line < bottom - top + 1; line += 2) { const unsigned char *ptr = kb->pixels + line * kb->width; for (row = 0; row < kb->width;) { int run = 1; while (row + run < kb->width && run < 255 && ptr[row + run] == ptr[row]) ++run; if (run >= 63 && row + run == kb->width) { /* special end of line marker */ CHKBUFSPC (4); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, ptr[row]); } else if (run >= 1 && run <= 3) { CHKBUFSPC (1); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, (run << 2) | ptr[row]); } else if (run <= 15) { CHKBUFSPC (2); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, run >> 2); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, ((run & 3) << 2) | ptr[row]); } else if (run <= 63) { CHKBUFSPC (3); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, run >> 2); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, ((run & 3) << 2) | ptr[row]); } else { CHKBUFSPC (4); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, (run >> 6)); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, (run >> 2) & 0xf); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, ((run & 3) << 2) | ptr[row]); } row += run; } if (nybble_count & 1) { CHKBUFSPC (1); gst_kate_spu_add_nybble (bytes, nbytes, nybble_count++, 0); } nbytes += nybble_count / 2; nybble_count = 0; } } first_commands_offset = nbytes; gst_kate_spu_make_palette (kd, palette, kp); /* Commands header */ CHKBUFSPC (4 * 2); bytes[nbytes++] = 0; bytes[nbytes++] = 0; /* link to next command chunk will be filled later, when we know where it is */ bytes[nbytes++] = 0; bytes[nbytes++] = 0; CHKBUFSPC (3 * 2); bytes[nbytes++] = SPU_CMD_SET_COLOR; bytes[nbytes++] = (palette[3] << 4) | palette[2]; bytes[nbytes++] = (palette[1] << 4) | palette[0]; CHKBUFSPC (3 * 2); bytes[nbytes++] = SPU_CMD_SET_ALPHA; bytes[nbytes++] = ((kp->colors[palette[3]].a / 17) << 4) | (kp->colors[palette[2]].a / 17); bytes[nbytes++] = ((kp->colors[palette[1]].a / 17) << 4) | (kp->colors[palette[0]].a / 17); CHKBUFSPC (7 * 2); bytes[nbytes++] = SPU_CMD_SET_DAREA; bytes[nbytes++] = left >> 4; bytes[nbytes++] = ((left & 0xf) << 4) | (right >> 8); bytes[nbytes++] = right & 0xff; bytes[nbytes++] = top >> 4; bytes[nbytes++] = ((top & 0xf) << 4) | (bottom >> 8); bytes[nbytes++] = bottom & 0xff; CHKBUFSPC (5 * 2); bytes[nbytes++] = SPU_CMD_DSPXA; bytes[nbytes++] = (lines_offset[0] >> 8) & 0xff; bytes[nbytes++] = lines_offset[0] & 0xff; bytes[nbytes++] = (lines_offset[1] >> 8) & 0xff; bytes[nbytes++] = lines_offset[1] & 0xff; CHKBUFSPC (1 * 2); bytes[nbytes++] = SPU_CMD_DSP; CHKBUFSPC (1 * 2); bytes[nbytes++] = SPU_CMD_END; /* stop display chunk */ CHKBUFSPC (4 * 2); second_commands_offset = nbytes; bytes[first_commands_offset + 2] = (second_commands_offset >> 8) & 0xff; bytes[first_commands_offset + 3] = second_commands_offset & 0xff; delay = GST_KATE_GST_TO_STM (ev->end_time - ev->start_time); bytes[nbytes++] = (delay >> 8) & 0xff; bytes[nbytes++] = delay & 0xff; /* close the loop by linking back to self */ bytes[nbytes++] = (second_commands_offset >> 8) & 0xff; bytes[nbytes++] = second_commands_offset & 0xff; CHKBUFSPC (1 * 2); bytes[nbytes++] = SPU_CMD_STP_DSP; CHKBUFSPC (1 * 2); bytes[nbytes++] = SPU_CMD_END; /* Now that we know the size of the SPU, update the size and pointers */ bytes[0] = (nbytes >> 8) & 0xff; bytes[1] = nbytes & 0xff; bytes[2] = (first_commands_offset >> 8) & 0xff; bytes[3] = first_commands_offset & 0xff; /* Create a buffer with those values */ buffer = gst_buffer_new_wrapped (bytes, nbytes); if (G_UNLIKELY (!buffer)) { GST_WARNING_OBJECT (kd, "Failed to allocate %" G_GSIZE_FORMAT " byte buffer", nbytes); goto error; } GST_BUFFER_OFFSET_END (buffer) = GST_SECOND * (ev->end_time); GST_BUFFER_OFFSET (buffer) = GST_SECOND * (ev->start_time); GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND * (ev->start_time); GST_BUFFER_DURATION (buffer) = GST_SECOND * (ev->end_time - ev->start_time); GST_DEBUG_OBJECT (kd, "SPU uses %" G_GSIZE_FORMAT " bytes", nbytes); kate_tracker_clear (&kin); return buffer; error: kate_tracker_clear (&kin); if (bytes) g_free (bytes); return NULL; }
gpl-2.0
mambax7/XoopsCore25
htdocs/class/xoopseditor/tinymce/tinymce/jscripts/tiny_mce/plugins/xoopsimagemanager/js/xoopsimagemanager.js
16092
/** * @author Moxiecode * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. * * @author ralf57 * @author luciorota ([email protected]) * @author dugris ([email protected]) */ tinyMCEPopup.requireLangPack(); var XoopsimagemanagerDialog = { preInit : function() { var url; if (url = tinyMCEPopup.getParam("external_image_list_url")) document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>'); }, init : function(ed) { var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(); tinyMCEPopup.resizeToInnerSize(); this.fillClassList('class_list'); this.fillFileList('src_list', 'tinyMCEImageList'); this.fillFileList('over_list', 'tinyMCEImageList'); this.fillFileList('out_list', 'tinyMCEImageList'); if (n.nodeName == 'IMG') { nl.src.value = dom.getAttrib(n, 'src'); nl.width.value = dom.getAttrib(n, 'width'); nl.height.value = dom.getAttrib(n, 'height'); nl.alt.value = dom.getAttrib(n, 'alt'); nl.title.value = dom.getAttrib(n, 'title'); nl.vspace.value = this.getAttrib(n, 'vspace'); nl.hspace.value = this.getAttrib(n, 'hspace'); nl.border.value = this.getAttrib(n, 'border'); selectByValue(f, 'align', this.getAttrib(n, 'align')); selectByValue(f, 'class_list', dom.getAttrib(n, 'class')); nl.style.value = dom.getAttrib(n, 'style'); nl.id.value = dom.getAttrib(n, 'id'); nl.dir.value = dom.getAttrib(n, 'dir'); nl.lang.value = dom.getAttrib(n, 'lang'); nl.usemap.value = dom.getAttrib(n, 'usemap'); nl.longdesc.value = dom.getAttrib(n, 'longdesc'); nl.insert.value = ed.getLang('update'); if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover'))) nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout'))) nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); if (ed.settings.inline_styles) { // Move attribs to styles if (dom.getAttrib(n, 'align')) this.updateStyle('align'); if (dom.getAttrib(n, 'hspace')) this.updateStyle('hspace'); if (dom.getAttrib(n, 'border')) this.updateStyle('border'); if (dom.getAttrib(n, 'vspace')) this.updateStyle('vspace'); } } // Setup browse button document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); if (isVisible('srcbrowser')) document.getElementById('src').style.width = '260px'; // Setup browse button document.getElementById('onmouseoversrccontainer').innerHTML = getBrowserHTML('overbrowser','onmouseoversrc','image','theme_advanced_image'); if (isVisible('overbrowser')) document.getElementById('onmouseoversrc').style.width = '260px'; // Setup browse button document.getElementById('onmouseoutsrccontainer').innerHTML = getBrowserHTML('outbrowser','onmouseoutsrc','image','theme_advanced_image'); if (isVisible('outbrowser')) document.getElementById('onmouseoutsrc').style.width = '260px'; // If option enabled default contrain proportions to checked if (ed.getParam("xoopsimagemanager_constrain_proportions", true)) f.constrain.checked = true; // Check swap image if valid data if (nl.onmouseoversrc.value || nl.onmouseoutsrc.value) this.setSwapImage(true); else this.setSwapImage(false); this.changeAppearance(); this.showPreviewImage(nl.src.value, 1); }, insert : function(file, title) { var ed = tinyMCEPopup.editor, t = this, f = document.forms[0]; if (f.src.value === '') { if (ed.selection.getNode().nodeName == 'IMG') { ed.dom.remove(ed.selection.getNode()); ed.execCommand('mceRepaint'); } tinyMCEPopup.close(); return; } if (tinyMCEPopup.getParam("accessibility_warnings", 1)) { if (!f.alt.value) { tinyMCEPopup.editor.windowManager.confirm(tinyMCEPopup.getLang('xoopsimagemanager_dlg.missing_alt'), function(s) { if (s) t.insertAndClose(); }); return; } } t.insertAndClose(); }, insertAndClose : function() { var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el; tinyMCEPopup.restoreSelection(); // Fixes crash in Safari if (tinymce.isWebKit) ed.getWin().focus(); if (!ed.settings.inline_styles) { args = { vspace : nl.vspace.value, hspace : nl.hspace.value, border : nl.border.value, align : getSelectValue(f, 'align') }; } else { // Remove deprecated values args = { vspace : '', hspace : '', border : '', align : '' }; } tinymce.extend(args, { src : nl.src.value, width : nl.width.value, height : nl.height.value, alt : nl.alt.value, title : nl.title.value, 'class' : getSelectValue(f, 'class_list'), style : nl.style.value, id : nl.id.value, dir : nl.dir.value, lang : nl.lang.value, usemap : nl.usemap.value, longdesc : nl.longdesc.value }); args.onmouseover = args.onmouseout = ''; if (f.onmousemovecheck.checked) { if (nl.onmouseoversrc.value) args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';"; if (nl.onmouseoutsrc.value) args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';"; } el = ed.selection.getNode(); if (el && el.nodeName == 'IMG') { ed.dom.setAttribs(el, args); } else { ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" src="javascript:;" />', {skip_undo : 1}); ed.dom.setAttribs('__mce_tmp', args); ed.dom.setAttrib('__mce_tmp', 'id', ''); ed.undoManager.add(); } tinyMCEPopup.close(); }, getAttrib : function(e, at) { var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2; if (ed.settings.inline_styles) { switch (at) { case 'align': if (v = dom.getStyle(e, 'float')) return v; if (v = dom.getStyle(e, 'vertical-align')) return v; break; case 'hspace': v = dom.getStyle(e, 'margin-left') v2 = dom.getStyle(e, 'margin-right'); if (v && v == v2) return parseInt(v.replace(/[^0-9]/g, '')); break; case 'vspace': v = dom.getStyle(e, 'margin-top') v2 = dom.getStyle(e, 'margin-bottom'); if (v && v == v2) return parseInt(v.replace(/[^0-9]/g, '')); break; case 'border': v = 0; tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) { sv = dom.getStyle(e, 'border-' + sv + '-width'); // False or not the same as prev if (!sv || (sv != v && v !== 0)) { v = 0; return false; } if (sv) v = sv; }); if (v) return parseInt(v.replace(/[^0-9]/g, '')); break; } } if (v = dom.getAttrib(e, at)) return v; return ''; }, setSwapImage : function(st) { var f = document.forms[0]; f.onmousemovecheck.checked = st; setBrowserDisabled('overbrowser', !st); setBrowserDisabled('outbrowser', !st); if (f.over_list) f.over_list.disabled = !st; if (f.out_list) f.out_list.disabled = !st; f.onmouseoversrc.disabled = !st; f.onmouseoutsrc.disabled = !st; }, fillClassList : function(id) { var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; if (v = tinyMCEPopup.getParam('theme_advanced_styles')) { cl = []; tinymce.each(v.split(';'), function(v) { var p = v.split('='); cl.push({'title' : p[0], 'class' : p[1]}); }); } else cl = tinyMCEPopup.editor.dom.getClasses(); if (cl.length > 0) { lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); tinymce.each(cl, function(o) { lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); }); } else dom.remove(dom.getParent(id, 'tr')); }, fillFileList : function(id, l) { var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; l = window[l]; if (l && l.length > 0) { lst.options[lst.options.length] = new Option('', ''); tinymce.each(l, function(o) { lst.options[lst.options.length] = new Option(o[0], o[1]); }); } else dom.remove(dom.getParent(id, 'tr')); }, resetImageData : function() { var f = document.forms[0]; f.elements.width.value = f.elements.height.value = ''; }, updateImageData : function(img, st) { var f = document.forms[0]; if (!st) { f.elements.width.value = img.width; f.elements.height.value = img.height; } this.preloadImg = img; }, changeAppearance : function() { var ed = tinyMCEPopup.editor, f = document.forms[0], img = document.getElementById('alignSampleImg'); if (img) { if (ed.getParam('inline_styles')) { ed.dom.setAttrib(img, 'style', f.style.value); } else { img.align = f.align.value; img.border = f.border.value; img.hspace = f.hspace.value; img.vspace = f.vspace.value; } } }, changeHeight : function() { var f = document.forms[0], tp, t = this; if (!f.constrain.checked || !t.preloadImg) { return; } if (f.width.value == "" || f.height.value == "") return; tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height; f.height.value = tp.toFixed(0); }, changeWidth : function() { var f = document.forms[0], tp, t = this; if (!f.constrain.checked || !t.preloadImg) { return; } if (f.width.value == "" || f.height.value == "") return; tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width; f.width.value = tp.toFixed(0); }, updateStyle : function(ty) { var dom = tinyMCEPopup.dom, st, v, f = document.forms[0], img = dom.create('img', {style : dom.get('style').value}); if (tinyMCEPopup.editor.settings.inline_styles) { // Handle align if (ty == 'align') { dom.setStyle(img, 'float', ''); dom.setStyle(img, 'vertical-align', ''); v = getSelectValue(f, 'align'); if (v) { if (v == 'left' || v == 'right') dom.setStyle(img, 'float', v); else img.style.verticalAlign = v; } } // Handle border if (ty == 'border') { dom.setStyle(img, 'border', ''); v = f.border.value; if (v || v == '0') { if (v == '0') img.style.border = ''; else img.style.border = v + 'px solid black'; } } // Handle hspace if (ty == 'hspace') { dom.setStyle(img, 'marginLeft', ''); dom.setStyle(img, 'marginRight', ''); v = f.hspace.value; if (v) { img.style.marginLeft = v + 'px'; img.style.marginRight = v + 'px'; } } // Handle vspace if (ty == 'vspace') { dom.setStyle(img, 'marginTop', ''); dom.setStyle(img, 'marginBottom', ''); v = f.vspace.value; if (v) { img.style.marginTop = v + 'px'; img.style.marginBottom = v + 'px'; } } // Merge dom.get('style').value = dom.serializeStyle(dom.parseStyle(img.style.cssText)); } }, changeMouseMove : function() { }, showPreviewImage : function(u, st) { if (!u) { tinyMCEPopup.dom.setHTML('prev', ''); return; } if (!st && tinyMCEPopup.getParam("xoopsimagemanager_update_dimensions_onchange", true)) this.resetImageData(); u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u); if (!st) tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="XoopsimagemanagerDialog.updateImageData(this);" onerror="XoopsimagemanagerDialog.resetImageData();" />'); else tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="XoopsimagemanagerDialog.updateImageData(this, 1);" />'); } }; XoopsimagemanagerDialog.preInit(); tinyMCEPopup.onInit.add(XoopsimagemanagerDialog.init, XoopsimagemanagerDialog); function XoopsImageBrowser( input ) { var url = "xoopsimagebrowser.php?target=src"; var type = "image"; var win = window.self; var cmsURL = window.location.href; // script URL var cmsURL = cmsURL.substring( 0, cmsURL.lastIndexOf("/") + 1 ); var searchString = window.location.search; // possible parameters if (searchString.length < 1) { // add "?" to the URL to include parameters (in other words: create a search string because there wasn't one before) searchString = "?"; } tinyMCE.activeEditor.windowManager.open({ file : cmsURL + url + searchString + "&type=" + type, title : 'Xoops Image Manager', width : 650, height : 440, resizable : "yes", scrollbars : "yes", inline : "yes", // This parameter only has an effect if you use the inlinepopups plugin! close_previous : "no" }, { window : win, input_src : input, input_title : "title", input_alt : "alt", input_align : "align" }); return false; }
gpl-2.0
cpjobling/proman-d8
proman.swan.ac.uk/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
7426
<?php /** * @file * Contains \Drupal\Core\Utility\UnroutedUrlAssembler. */ namespace Drupal\Core\Utility; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\GeneratedUrl; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Symfony\Component\HttpFoundation\RequestStack; /** * Provides a way to build external or non Drupal local domain URLs. * * It takes into account configured safe HTTP protocols. */ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { /** * A request stack object. * * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $requestStack; /** * The outbound path processor. * * @var \Drupal\Core\PathProcessor\OutboundPathProcessorInterface */ protected $pathProcessor; /** * Constructs a new unroutedUrlAssembler object. * * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack object. * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config factory. * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor * The output path processor. */ public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, OutboundPathProcessorInterface $path_processor) { $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https']; UrlHelper::setAllowedProtocols($allowed_protocols); $this->requestStack = $request_stack; $this->pathProcessor = $path_processor; } /** * {@inheritdoc} * * This is a helper function that calls buildExternalUrl() or buildLocalUrl() * based on a check of whether the path is a valid external URL. */ public function assemble($uri, array $options = [], $collect_cacheability_metadata = FALSE) { // Note that UrlHelper::isExternal will return FALSE if the $uri has a // disallowed protocol. This is later made safe since we always add at // least a leading slash. if (parse_url($uri, PHP_URL_SCHEME) === 'base') { return $this->buildLocalUrl($uri, $options, $collect_cacheability_metadata); } elseif (UrlHelper::isExternal($uri)) { // UrlHelper::isExternal() only returns true for safe protocols. return $this->buildExternalUrl($uri, $options, $collect_cacheability_metadata); } throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal.', ['@uri' => $uri])); } /** * {@inheritdoc} */ protected function buildExternalUrl($uri, array $options = [], $collect_cacheability_metadata = FALSE) { $this->addOptionDefaults($options); // Split off the fragment. if (strpos($uri, '#') !== FALSE) { list($uri, $old_fragment) = explode('#', $uri, 2); // If $options contains no fragment, take it over from the path. if (isset($old_fragment) && !$options['fragment']) { $options['fragment'] = '#' . $old_fragment; } } if (isset($options['https'])) { if ($options['https'] === TRUE) { $uri = str_replace('http://', 'https://', $uri); } elseif ($options['https'] === FALSE) { $uri = str_replace('https://', 'http://', $uri); } } // Append the query. if ($options['query']) { $uri .= (strpos($uri, '?') !== FALSE ? '&' : '?') . UrlHelper::buildQuery($options['query']); } // Reassemble. $url = $uri . $options['fragment']; return $collect_cacheability_metadata ? (new GeneratedUrl())->setGeneratedUrl($url) : $url; } /** * {@inheritdoc} */ protected function buildLocalUrl($uri, array $options = [], $collect_cacheability_metadata = FALSE) { $generated_url = $collect_cacheability_metadata ? new GeneratedUrl() : NULL; $this->addOptionDefaults($options); $request = $this->requestStack->getCurrentRequest(); // Remove the base: scheme. // @todo Consider using a class constant for this in // https://www.drupal.org/node/2417459 $uri = substr($uri, 5); // Strip leading slashes from internal paths to prevent them becoming // external URLs without protocol. /example.com should not be turned into // //example.com. $uri = ltrim($uri, '/'); // Allow (outbound) path processing, if needed. A valid use case is the path // alias overview form: // @see \Drupal\path\Controller\PathController::adminOverview(). if (!empty($options['path_processing'])) { // Do not pass the request, since this is a special case and we do not // want to include e.g. the request language in the processing. $uri = $this->pathProcessor->processOutbound($uri, $options, NULL, $generated_url); } // Add any subdirectory where Drupal is installed. $current_base_path = $request->getBasePath() . '/'; if ($options['absolute']) { $current_base_url = $request->getSchemeAndHttpHost() . $current_base_path; if (isset($options['https'])) { if (!empty($options['https'])) { $base = str_replace('http://', 'https://', $current_base_url); $options['absolute'] = TRUE; } else { $base = str_replace('https://', 'http://', $current_base_url); $options['absolute'] = TRUE; } } else { $base = $current_base_url; } if ($collect_cacheability_metadata) { $generated_url->addCacheContexts(['url.site']); } } else { $base = $current_base_path; } $prefix = empty($uri) ? rtrim($options['prefix'], '/') : $options['prefix']; $uri = str_replace('%2F', '/', rawurlencode($prefix . $uri)); $query = $options['query'] ? ('?' . UrlHelper::buildQuery($options['query'])) : ''; $url = $base . $options['script'] . $uri . $query . $options['fragment']; return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url; } /** * Merges in default defaults * * @param array $options * The options to merge in the defaults. */ protected function addOptionDefaults(array &$options) { $request = $this->requestStack->getCurrentRequest(); $current_base_path = $request->getBasePath() . '/'; $current_script_path = ''; $base_path_with_script = $request->getBaseUrl(); // If the current request was made with the script name (eg, index.php) in // it, then extract it, making sure the leading / is gone, and a trailing / // is added, to allow simple string concatenation with other parts. This // mirrors code from UrlGenerator::generateFromPath(). if (!empty($base_path_with_script)) { $script_name = $request->getScriptName(); if (strpos($base_path_with_script, $script_name) !== FALSE) { $current_script_path = ltrim(substr($script_name, strlen($current_base_path)), '/') . '/'; } } // Merge in defaults. $options += [ 'fragment' => '', 'query' => [], 'absolute' => FALSE, 'prefix' => '', 'script' => $current_script_path, ]; if (isset($options['fragment']) && $options['fragment'] !== '') { $options['fragment'] = '#' . $options['fragment']; } } }
gpl-2.0
vyatta/vyatta-strongswan
scripts/oid2der.c
400
#include <stdio.h> #include <asn1/asn1.h> /** * convert string OID to DER encoding */ int main(int argc, char *argv[]) { int i, nr = 0; chunk_t oid; while (argc > ++nr) { oid = asn1_oid_from_string(argv[nr]); if (oid.len) { for (i = 0; i < oid.len; i++) { printf("0x%02x,", oid.ptr[i]); } printf("\n"); free(oid.ptr); } else { return 1; } } return 0; }
gpl-2.0
TabTwo/silc-client
lib/silcutil/silclog_i.h
1062
/* silclog_i.h Author: Pekka Riikonen <[email protected]> Copyright (C) 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #ifndef SILCLOG_I_H #define SILCLOG_I_H #ifndef SILCLOG_H #error "Do not include this header directly" #endif #if defined(SILC_WIN32) #ifndef __FUNCTION__ #define __FUNCTION__ __FILE__ #endif #endif void silc_log_output(SilcLogType type, char *string); void silc_log_output_debug(char *file, const char *function, int line, char *string); void silc_log_output_hexdump(char *file, const char *function, int line, void *data_in, SilcUInt32 len, char *string); #endif /* SILCLOG_I_H */
gpl-2.0
NickRuiz/wikitrans-pootle
templates/contact_form/contact_form_sent.html
244
{% extends "base.html" %} {% load i18n baseurl %} {% block title %}{{ block.super }}: {% trans "Message Sent" %}{% endblock %} {% block content %} <div class="general-message"> <h2>{% trans "Message Sent" %}</h2> </div> {% endblock %}
gpl-2.0
csitarichie/boost_msm_bare_metal
tools/compilers/arm/sourcery_2010_q1_none_eabi/share/doc/arm-arm-none-eabi/html/gdb/Altering.html
3468
<html lang="en"> <head> <title>Altering - Debugging with GDB</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Debugging with GDB"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="prev" href="Symbols.html#Symbols" title="Symbols"> <link rel="next" href="GDB-Files.html#GDB-Files" title="GDB Files"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Free Software'' and ``Free Software Needs Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom.''--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> <link rel="stylesheet" type="text/css" href="../cs.css"> </head> <body> <div class="node"> <a name="Altering"></a> <p> Next:&nbsp;<a rel="next" accesskey="n" href="GDB-Files.html#GDB-Files">GDB Files</a>, Previous:&nbsp;<a rel="previous" accesskey="p" href="Symbols.html#Symbols">Symbols</a>, Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <hr> </div> <h2 class="chapter">17 Altering Execution</h2> <p>Once you think you have found an error in your program, you might want to find out for certain whether correcting the apparent error would lead to correct results in the rest of the run. You can find the answer by experiment, using the <span class="sc">gdb</span> features for altering execution of the program. <p>For example, you can store new values into variables or memory locations, give your program a signal, restart it at a different address, or even return prematurely from a function. <ul class="menu"> <li><a accesskey="1" href="Assignment.html#Assignment">Assignment</a>: Assignment to variables <li><a accesskey="2" href="Jumping.html#Jumping">Jumping</a>: Continuing at a different address <li><a accesskey="3" href="Signaling.html#Signaling">Signaling</a>: Giving your program a signal <li><a accesskey="4" href="Returning.html#Returning">Returning</a>: Returning from a function <li><a accesskey="5" href="Calling.html#Calling">Calling</a>: Calling your program's functions <li><a accesskey="6" href="Patching.html#Patching">Patching</a>: Patching your program </ul> </body></html>
gpl-2.0
Teplitsa/bquest.ru
lib/vendor/diem/dmCorePlugin/test/project/lib/filter/doctrine/dmCorePlugin/base/BaseDmSettingFormFilter.class.php
2784
<?php /** * DmSetting filter form base class. * * @package retest * @subpackage filter * @author Your name here * @version SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $ */ abstract class BaseDmSettingFormFilter extends BaseFormFilterDoctrine { public function setup() { if($this->needsWidget('id')){ $this->setWidget('id', new sfWidgetFormDmFilterInput()); $this->setValidator('id', new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DmSetting', 'column' => 'id'))); } if($this->needsWidget('name')){ $this->setWidget('name', new sfWidgetFormDmFilterInput()); $this->setValidator('name', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false)))); } if($this->needsWidget('type')){ $this->setWidget('type', new sfWidgetFormChoice(array('multiple' => true, 'choices' => array('' => '', 'text' => 'text', 'boolean' => 'boolean', 'select' => 'select', 'textarea' => 'textarea', 'number' => 'number', 'datetime' => 'datetime')))); $this->setValidator('type', new sfValidatorChoice(array('required' => false, 'multiple' => true , 'choices' => array('text' => 'text', 'boolean' => 'boolean', 'select' => 'select', 'textarea' => 'textarea', 'number' => 'number', 'datetime' => 'datetime')))); } if($this->needsWidget('params')){ $this->setWidget('params', new sfWidgetFormDmFilterInput()); $this->setValidator('params', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false)))); } if($this->needsWidget('group_name')){ $this->setWidget('group_name', new sfWidgetFormDmFilterInput()); $this->setValidator('group_name', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false)))); } if($this->needsWidget('credentials')){ $this->setWidget('credentials', new sfWidgetFormDmFilterInput()); $this->setValidator('credentials', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false)))); } $this->mergeI18nForm(); $this->widgetSchema->setNameFormat('dm_setting_filters[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); $this->setupInheritance(); parent::setup(); } public function getModelName() { return 'DmSetting'; } public function getFields() { return array( 'id' => 'Number', 'name' => 'Text', 'type' => 'Enum', 'params' => 'Text', 'group_name' => 'Text', 'credentials' => 'Text', 'id' => 'Number', 'description' => 'Text', 'value' => 'Text', 'default_value' => 'Text', 'lang' => 'Text', ); } }
gpl-2.0
SalvationDevelopment/Salvation-Scripts-TCG
c33665663.lua
963
--炎舞-「開陽」 function c33665663.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetHintTiming(TIMING_DAMAGE_STEP) e1:SetOperation(c33665663.activate) c:RegisterEffect(e1) --atkup local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_SZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetTarget(c33665663.filter) e2:SetValue(300) c:RegisterEffect(e2) end function c33665663.filter(e,c) return c:IsRace(RACE_BEASTWARRIOR) end function c33665663.activate(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_PIERCE) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetTarget(c33665663.filter) e1:SetTargetRange(LOCATION_MZONE,0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end
gpl-2.0
itsimbal/gcc.cet
libgfortran/generated/reshape_i4.c
9606
/* Implementation of the RESHAPE intrinsic Copyright (C) 2002-2017 Free Software Foundation, Inc. Contributed by Paul Brook <[email protected]> This file is part of the GNU Fortran runtime library (libgfortran). Libgfortran is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Libgfortran is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #include "libgfortran.h" #if defined (HAVE_GFC_INTEGER_4) typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type; extern void reshape_4 (gfc_array_i4 * const restrict, gfc_array_i4 * const restrict, shape_type * const restrict, gfc_array_i4 * const restrict, shape_type * const restrict); export_proto(reshape_4); void reshape_4 (gfc_array_i4 * const restrict ret, gfc_array_i4 * const restrict source, shape_type * const restrict shape, gfc_array_i4 * const restrict pad, shape_type * const restrict order) { /* r.* indicates the return array. */ index_type rcount[GFC_MAX_DIMENSIONS]; index_type rextent[GFC_MAX_DIMENSIONS]; index_type rstride[GFC_MAX_DIMENSIONS]; index_type rstride0; index_type rdim; index_type rsize; index_type rs; index_type rex; GFC_INTEGER_4 *rptr; /* s.* indicates the source array. */ index_type scount[GFC_MAX_DIMENSIONS]; index_type sextent[GFC_MAX_DIMENSIONS]; index_type sstride[GFC_MAX_DIMENSIONS]; index_type sstride0; index_type sdim; index_type ssize; const GFC_INTEGER_4 *sptr; /* p.* indicates the pad array. */ index_type pcount[GFC_MAX_DIMENSIONS]; index_type pextent[GFC_MAX_DIMENSIONS]; index_type pstride[GFC_MAX_DIMENSIONS]; index_type pdim; index_type psize; const GFC_INTEGER_4 *pptr; const GFC_INTEGER_4 *src; int n; int dim; int sempty, pempty, shape_empty; index_type shape_data[GFC_MAX_DIMENSIONS]; rdim = GFC_DESCRIPTOR_EXTENT(shape,0); /* rdim is always > 0; this lets the compiler optimize more and avoids a potential warning. */ GFC_ASSERT(rdim>0); if (rdim != GFC_DESCRIPTOR_RANK(ret)) runtime_error("rank of return array incorrect in RESHAPE intrinsic"); shape_empty = 0; for (n = 0; n < rdim; n++) { shape_data[n] = shape->base_addr[n * GFC_DESCRIPTOR_STRIDE(shape,0)]; if (shape_data[n] <= 0) { shape_data[n] = 0; shape_empty = 1; } } if (ret->base_addr == NULL) { index_type alloc_size; rs = 1; for (n = 0; n < rdim; n++) { rex = shape_data[n]; GFC_DIMENSION_SET(ret->dim[n], 0, rex - 1, rs); rs *= rex; } ret->offset = 0; if (unlikely (rs < 1)) alloc_size = 0; else alloc_size = rs; ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; } if (shape_empty) return; if (pad) { pdim = GFC_DESCRIPTOR_RANK (pad); psize = 1; pempty = 0; for (n = 0; n < pdim; n++) { pcount[n] = 0; pstride[n] = GFC_DESCRIPTOR_STRIDE(pad,n); pextent[n] = GFC_DESCRIPTOR_EXTENT(pad,n); if (pextent[n] <= 0) { pempty = 1; pextent[n] = 0; } if (psize == pstride[n]) psize *= pextent[n]; else psize = 0; } pptr = pad->base_addr; } else { pdim = 0; psize = 1; pempty = 1; pptr = NULL; } if (unlikely (compile_options.bounds_check)) { index_type ret_extent, source_extent; rs = 1; for (n = 0; n < rdim; n++) { rs *= shape_data[n]; ret_extent = GFC_DESCRIPTOR_EXTENT(ret,n); if (ret_extent != shape_data[n]) runtime_error("Incorrect extent in return value of RESHAPE" " intrinsic in dimension %ld: is %ld," " should be %ld", (long int) n+1, (long int) ret_extent, (long int) shape_data[n]); } source_extent = 1; sdim = GFC_DESCRIPTOR_RANK (source); for (n = 0; n < sdim; n++) { index_type se; se = GFC_DESCRIPTOR_EXTENT(source,n); source_extent *= se > 0 ? se : 0; } if (rs > source_extent && (!pad || pempty)) runtime_error("Incorrect size in SOURCE argument to RESHAPE" " intrinsic: is %ld, should be %ld", (long int) source_extent, (long int) rs); if (order) { int seen[GFC_MAX_DIMENSIONS]; index_type v; for (n = 0; n < rdim; n++) seen[n] = 0; for (n = 0; n < rdim; n++) { v = order->base_addr[n * GFC_DESCRIPTOR_STRIDE(order,0)] - 1; if (v < 0 || v >= rdim) runtime_error("Value %ld out of range in ORDER argument" " to RESHAPE intrinsic", (long int) v + 1); if (seen[v] != 0) runtime_error("Duplicate value %ld in ORDER argument to" " RESHAPE intrinsic", (long int) v + 1); seen[v] = 1; } } } rsize = 1; for (n = 0; n < rdim; n++) { if (order) dim = order->base_addr[n * GFC_DESCRIPTOR_STRIDE(order,0)] - 1; else dim = n; rcount[n] = 0; rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim); rextent[n] = GFC_DESCRIPTOR_EXTENT(ret,dim); if (rextent[n] < 0) rextent[n] = 0; if (rextent[n] != shape_data[dim]) runtime_error ("shape and target do not conform"); if (rsize == rstride[n]) rsize *= rextent[n]; else rsize = 0; if (rextent[n] <= 0) return; } sdim = GFC_DESCRIPTOR_RANK (source); /* sdim is always > 0; this lets the compiler optimize more and avoids a warning. */ GFC_ASSERT(sdim>0); ssize = 1; sempty = 0; for (n = 0; n < sdim; n++) { scount[n] = 0; sstride[n] = GFC_DESCRIPTOR_STRIDE(source,n); sextent[n] = GFC_DESCRIPTOR_EXTENT(source,n); if (sextent[n] <= 0) { sempty = 1; sextent[n] = 0; } if (ssize == sstride[n]) ssize *= sextent[n]; else ssize = 0; } if (rsize != 0 && ssize != 0 && psize != 0) { rsize *= sizeof (GFC_INTEGER_4); ssize *= sizeof (GFC_INTEGER_4); psize *= sizeof (GFC_INTEGER_4); reshape_packed ((char *)ret->base_addr, rsize, (char *)source->base_addr, ssize, pad ? (char *)pad->base_addr : NULL, psize); return; } rptr = ret->base_addr; src = sptr = source->base_addr; rstride0 = rstride[0]; sstride0 = sstride[0]; if (sempty && pempty) abort (); if (sempty) { /* Pretend we are using the pad array the first time around, too. */ src = pptr; sptr = pptr; sdim = pdim; for (dim = 0; dim < pdim; dim++) { scount[dim] = pcount[dim]; sextent[dim] = pextent[dim]; sstride[dim] = pstride[dim]; sstride0 = pstride[0]; } } while (rptr) { /* Select between the source and pad arrays. */ *rptr = *src; /* Advance to the next element. */ rptr += rstride0; src += sstride0; rcount[0]++; scount[0]++; /* Advance to the next destination element. */ n = 0; while (rcount[n] == rextent[n]) { /* When we get to the end of a dimension, reset it and increment the next dimension. */ rcount[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ rptr -= rstride[n] * rextent[n]; n++; if (n == rdim) { /* Break out of the loop. */ rptr = NULL; break; } else { rcount[n]++; rptr += rstride[n]; } } /* Advance to the next source element. */ n = 0; while (scount[n] == sextent[n]) { /* When we get to the end of a dimension, reset it and increment the next dimension. */ scount[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ src -= sstride[n] * sextent[n]; n++; if (n == sdim) { if (sptr && pad) { /* Switch to the pad array. */ sptr = NULL; sdim = pdim; for (dim = 0; dim < pdim; dim++) { scount[dim] = pcount[dim]; sextent[dim] = pextent[dim]; sstride[dim] = pstride[dim]; sstride0 = sstride[0]; } } /* We now start again from the beginning of the pad array. */ src = pptr; break; } else { scount[n]++; src += sstride[n]; } } } } #endif
gpl-2.0
ironhead123/DeathCore_3.3.5
src/server/shared/Database/Field.cpp
1759
/* * Copyright (C) 2013-2015 DeathCore <http://www.noffearrdeathproject.net/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "Field.h" Field::Field() { data.value = NULL; data.type = MYSQL_TYPE_NULL; data.length = 0; data.raw = false; } Field::~Field() { CleanUp(); } void Field::SetByteValue(const void* newValue, const size_t newSize, enum_field_types newType, uint32 length) { if (data.value) CleanUp(); // This value stores raw bytes that have to be explicitly cast later if (newValue) { data.value = new char[newSize]; memcpy(data.value, newValue, newSize); data.length = length; } data.type = newType; data.raw = true; } void Field::SetStructuredValue(char* newValue, enum_field_types newType) { if (data.value) CleanUp(); // This value stores somewhat structured data that needs function style casting if (newValue) { size_t size = strlen(newValue); data.value = new char [size+1]; strcpy((char*)data.value, newValue); data.length = size; } data.type = newType; data.raw = false; }
gpl-2.0
khuongdang/dongtrungtruongsinh
plugins/installer/jce/jce.php
1570
<?php /** * @package JCE * @copyright Copyright (c)2016 Ryan Demmer * @license GNU General Public License version 2, or later */ defined('_JEXEC') or die; /** * Handle commercial extension update authorization * * @package Joomla.Plugin * @subpackage Installer.Jce * @since 2.6 */ class plgInstallerJce extends JPlugin { /** * Handle adding credentials to package download request * * @param string $url url from which package is going to be downloaded * @param array $headers headers to be sent along the download request (key => value format) * * @return boolean true if credentials have been added to request or not our business, false otherwise (credentials not set by user) * * @since 3.0 */ public function onInstallerBeforePackageDownload(&$url, &$headers) { $app = JFactory::getApplication(); $uri = JUri::getInstance($url); $host = $uri->getHost(); if ($host !== 'www.joomlacontenteditor.net') { return true; } // Get the subscription key JLoader::import('joomla.application.component.helper'); $component = JComponentHelper::getComponent('com_jce'); $key = $component->params->get('updates_key', ''); if (empty($key)) { $language = JFactory::getLanguage(); $language->load('plg_installer_jce', JPATH_ADMINISTRATOR); $app->enqueueMessage(JText::_('PLG_INSTALLER_JCE_KEY_WARNING'), 'notice'); } // Append the subscription key to the download URL $uri->setVar('key', $key); $url = $uri->toString(); return true; } }
gpl-2.0
mikedanylov/full-stack-dev
NodeJS/week3/rest-server/routes/leaderRouter.js
1220
var express = require('express'); var leaderRouter = express.Router(); leaderRouter.route('/') .all(function(req, res, next) { res.writeHead(200, { 'Content-Type': 'text/plain' }); next(); }) .get(function(req, res, next){ res.end('Will send all the leaders to you!'); }) .post(function(req, res, next){ res.end('Will add the leader: ' + req.body.name + ' with details: ' + req.body.description); }) .delete(function(req, res, next){ res.end('Deleting all leaders'); }); leaderRouter.route('/:leaderId') .all(function(req, res, next) { res.writeHead(200, { 'Content-Type': 'text/plain' }); next(); }) .get(function(req, res, next){ res.end('Will send details of the leader: ' + req.params.leaderId +' to you!'); }) .put(function(req, res, next){ res.write('Updating the leader: ' + req.params.leaderId + '\n'); res.end('Will update the leader: ' + req.body.name + ' with details: ' + req.body.description); }) .delete(function(req, res, next){ res.end('Deleting the leader: ' + req.params.leaderId); }); module.exports = leaderRouter;
gpl-2.0
gltn/stdm
stdm/third_party/sqlalchemy/dialects/postgresql/pypostgresql.py
2915
# postgresql/pypostgresql.py # Copyright (C) 2005-2020 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """ .. dialect:: postgresql+pypostgresql :name: py-postgresql :dbapi: pypostgresql :connectstring: postgresql+pypostgresql://user:password@host:port/dbname[?key=value&key=value...] :url: http://python.projects.pgfoundry.org/ .. note:: The pypostgresql dialect is **not tested as part of SQLAlchemy's continuous integration** and may have unresolved issues. The recommended PostgreSQL driver is psycopg2. """ # noqa from .base import PGDialect from .base import PGExecutionContext from ... import processors from ... import types as sqltypes from ... import util class PGNumeric(sqltypes.Numeric): def bind_processor(self, dialect): return processors.to_str def result_processor(self, dialect, coltype): if self.asdecimal: return None else: return processors.to_float class PGExecutionContext_pypostgresql(PGExecutionContext): pass class PGDialect_pypostgresql(PGDialect): driver = "pypostgresql" supports_unicode_statements = True supports_unicode_binds = True description_encoding = None default_paramstyle = "pyformat" # requires trunk version to support sane rowcounts # TODO: use dbapi version information to set this flag appropriately supports_sane_rowcount = True supports_sane_multi_rowcount = False execution_ctx_cls = PGExecutionContext_pypostgresql colspecs = util.update_copy( PGDialect.colspecs, { sqltypes.Numeric: PGNumeric, # prevents PGNumeric from being used sqltypes.Float: sqltypes.Float, }, ) @classmethod def dbapi(cls): from postgresql.driver import dbapi20 return dbapi20 _DBAPI_ERROR_NAMES = [ "Error", "InterfaceError", "DatabaseError", "DataError", "OperationalError", "IntegrityError", "InternalError", "ProgrammingError", "NotSupportedError", ] @util.memoized_property def dbapi_exception_translation_map(self): if self.dbapi is None: return {} return dict( (getattr(self.dbapi, name).__name__, name) for name in self._DBAPI_ERROR_NAMES ) def create_connect_args(self, url): opts = url.translate_connect_args(username="user") if "port" in opts: opts["port"] = int(opts["port"]) else: opts["port"] = 5432 opts.update(url.query) return ([], opts) def is_disconnect(self, e, connection, cursor): return "connection is closed" in str(e) dialect = PGDialect_pypostgresql
gpl-2.0
songxiafeng/joomla-platform
tests/suites/unit/joomla/language/JLanguageTest.php
26706
<?php /** * @package Joomla.UnitTest * * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ jimport('joomla.filesystem.folder'); require_once __DIR__ . '/JLanguageInspector.php'; require_once __DIR__ . '/data/language/en-GB/en-GB.localise.php'; /** * Test class for JLanguage. * Generated by PHPUnit on 2012-03-21 at 21:29:28. * * @package Joomla.UnitTest * @subpackage Language * @since 11.1 */ class JLanguageTest extends PHPUnit_Framework_TestCase { /** * @var JLanguage */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $path = JPATH_BASE . '/language'; if (is_dir($path)) { JFolder::delete($path); } JFolder::copy(__DIR__ . '/data/language', $path); $this->object = new JLanguage; $this->inspector = new JLanguageInspector('', true); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @return void */ protected function tearDown() { JFolder::delete(JPATH_BASE . '/language'); } /** * Test... * * @covers JLanguage::getInstance * * @return void */ public function testGetInstance() { $instance = JLanguage::getInstance(null); $this->assertInstanceOf('JLanguage', $instance); } /** * Test... * * @covers JLanguage::__construct * * @return void */ public function testConstruct() { // @codingStandardsIgnoreStart // @todo check the instanciating new classes without brackets sniff $instance = new JLanguage(null, true); // @codingStandardsIgnoreEnd $this->assertInstanceOf('JLanguage', $instance); $this->assertTrue($instance->getDebug()); // @codingStandardsIgnoreStart // @todo check the instanciating new classes without brackets sniff $instance = new JLanguage(null, false); // @codingStandardsIgnoreEnd $this->assertInstanceOf('JLanguage', $instance); $this->assertFalse($instance->getDebug()); } /** * Test... * * @covers JLanguage::_ * * @return void */ public function test_() { $string1 = 'delete'; $string2 = "delete's"; $this->assertEquals( 'delete', $this->object->_($string1, false), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is false ' ); $this->assertNotEquals( 'Delete', $this->object->_($string1, false), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is false' ); $this->assertEquals( 'delete', $this->object->_($string1, true), 'Line: ' . __LINE__ . ' Exact case match should work when javascript safe is true' ); $this->assertNotEquals( 'Delete', $this->object->_($string1, true), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is true' ); $this->assertEquals( 'delete\'s', $this->object->_($string2, false), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is false ' ); $this->assertNotEquals( 'Delete\'s', $this->object->_($string2, false), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is false' ); $this->assertEquals( "delete\'s", $this->object->_($string2, true), 'Line: ' . __LINE__ . ' Exact case should match when javascript safe is true, also it calls addslashes (\' => \\\') ' ); $this->assertNotEquals( "Delete\'s", $this->object->_($string2, true), 'Line: ' . __LINE__ . ' Should be case sensitive when javascript safe is true,, also it calls addslashes (\' => \\\') ' ); } /** * Test... * * @covers JLanguage::transliterate * * @return void */ public function testTransliterate() { $string1 = 'Así'; $string2 = 'EÑE'; $this->assertEquals( 'asi', $this->object->transliterate($string1), 'Line: ' . __LINE__ ); $this->assertNotEquals( 'Asi', $this->object->transliterate($string1), 'Line: ' . __LINE__ ); $this->assertNotEquals( 'Así', $this->object->transliterate($string1), 'Line: ' . __LINE__ ); $this->assertEquals( 'ene', $this->object->transliterate($string2), 'Line: ' . __LINE__ ); $this->assertNotEquals( 'ENE', $this->object->transliterate($string2), 'Line: ' . __LINE__ ); $this->assertNotEquals( 'EÑE', $this->object->transliterate($string2), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getTransliterator * * @return void */ public function testGetTransliterator() { $lang = new JLanguage(''); // The first time you run the method returns NULL // Only if there is an setTransliterator, this test is wrong $this->assertNull( $lang->getTransliterator() ); } /** * Test... * * @covers JLanguage::setTransliterator * @todo Implement testSetTransliterator(). * * @return void */ public function testSetTransliterator() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); // Note: set -> $funtion1: set returns NULL and get returns $function1 $this->assertNull( $lang->setTransliterator($function1) ); $get = $lang->getTransliterator(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setTransliterator($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getTransliterator(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getTransliterator(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getPluralSuffixes * * @return void */ public function testGetPluralSuffixes() { $this->assertEquals( array('0'), $this->object->getPluralSuffixes(0), 'Line: ' . __LINE__ ); $this->assertEquals( array('1'), $this->object->getPluralSuffixes(1), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getPluralSuffixesCallback * * @return void */ public function testGetPluralSuffixesCallback() { $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getPluralSuffixesCallback()) ); } /** * Test... * * @covers JLanguage::setPluralSuffixesCallback * @covers JLanguage::getPluralSuffixesCallback * * @return void */ public function testSetPluralSuffixesCallback() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getPluralSuffixesCallback()) ); $this->assertTrue( is_callable($lang->setPluralSuffixesCallback($function1)) ); $get = $lang->getPluralSuffixesCallback(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setPluralSuffixesCallback($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getPluralSuffixesCallback(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getPluralSuffixesCallback(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getIgnoredSearchWords * * @return void */ public function testGetIgnoredSearchWords() { $lang = new JLanguage(''); $this->assertEquals( array('and', 'in', 'on'), $lang->getIgnoredSearchWords(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getIgnoredSearchWordsCallback * * @return void */ public function testGetIgnoredSearchWordsCallback() { $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getIgnoredSearchWordsCallback()) ); } /** * Test... * * @covers JLanguage::setIgnoredSearchWordsCallback * @covers JLanguage::getIgnoredSearchWordsCallback * * @return void */ public function testSetIgnoredSearchWordsCallback() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getIgnoredSearchWordsCallback()) ); // Note: set -> $funtion1: set returns NULL and get returns $function1 $this->assertTrue( is_callable($lang->setIgnoredSearchWordsCallback($function1)) ); $get = $lang->getIgnoredSearchWordsCallback(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setIgnoredSearchWordsCallback($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getIgnoredSearchWordsCallback(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getIgnoredSearchWordsCallback(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getLowerLimitSearchWord * * @return void */ public function testGetLowerLimitSearchWord() { $lang = new JLanguage(''); $this->assertEquals( 3, $lang->getLowerLimitSearchWord(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getLowerLimitSearchWordCallback * * @return void */ public function testGetLowerLimitSearchWordCallback() { $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getLowerLimitSearchWordCallback()) ); } /** * Test... * * @covers JLanguage::setLowerLimitSearchWordCallback * @covers JLanguage::getLowerLimitSearchWordCallback * * @return void */ public function testSetLowerLimitSearchWordCallback() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getLowerLimitSearchWordCallback()) ); // Note: set -> $funtion1: set returns NULL and get returns $function1 $this->assertTrue( is_callable($lang->setLowerLimitSearchWordCallback($function1)) ); $get = $lang->getLowerLimitSearchWordCallback(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setLowerLimitSearchWordCallback($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getLowerLimitSearchWordCallback(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getLowerLimitSearchWordCallback(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getUpperLimitSearchWord * * @return void */ public function testGetUpperLimitSearchWord() { $lang = new JLanguage(''); $this->assertEquals( 20, $lang->getUpperLimitSearchWord(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getUpperLimitSearchWordCallback * * @return void */ public function testGetUpperLimitSearchWordCallback() { $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getUpperLimitSearchWordCallback()) ); } /** * Test... * * @covers JLanguage::setUpperLimitSearchWordCallback * @covers JLanguage::getUpperLimitSearchWordCallback * * @return void */ public function testSetUpperLimitSearchWordCallback() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getUpperLimitSearchWordCallback()) ); // Note: set -> $funtion1: set returns NULL and get returns $function1 $this->assertTrue( is_callable($lang->setUpperLimitSearchWordCallback($function1)) ); $get = $lang->getUpperLimitSearchWordCallback(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setUpperLimitSearchWordCallback($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getUpperLimitSearchWordCallback(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getUpperLimitSearchWordCallback(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getSearchDisplayedCharactersNumber * * @return void */ public function testGetSearchDisplayedCharactersNumber() { $lang = new JLanguage(''); $this->assertEquals( 200, $lang->getSearchDisplayedCharactersNumber(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getSearchDisplayedCharactersNumberCallback * * @return void */ public function testGetSearchDisplayedCharactersNumberCallback() { $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getSearchDisplayedCharactersNumberCallback()) ); } /** * Test... * * @covers JLanguage::setSearchDisplayedCharactersNumberCallback * @covers JLanguage::getSearchDisplayedCharactersNumberCallback * * @return void */ public function testSetSearchDisplayedCharactersNumberCallback() { $function1 = 'phpinfo'; $function2 = 'print'; $lang = new JLanguage(''); $this->assertTrue( is_callable($lang->getSearchDisplayedCharactersNumberCallback()) ); // Note: set -> $funtion1: set returns NULL and get returns $function1 $this->assertTrue( is_callable($lang->setSearchDisplayedCharactersNumberCallback($function1)) ); $get = $lang->getSearchDisplayedCharactersNumberCallback(); $this->assertEquals( $function1, $get, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $get, 'Line: ' . __LINE__ ); // Note: set -> $function2: set returns $function1 and get retuns $function2 $set = $lang->setSearchDisplayedCharactersNumberCallback($function2); $this->assertEquals( $function1, $set, 'Line: ' . __LINE__ ); $this->assertNotEquals( $function2, $set, 'Line: ' . __LINE__ ); $this->assertEquals( $function2, $lang->getSearchDisplayedCharactersNumberCallback(), 'Line: ' . __LINE__ ); $this->assertNotEquals( $function1, $lang->getSearchDisplayedCharactersNumberCallback(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::exists * @todo Implement testExists(). * * @return void */ public function testExists() { $this->assertFalse( $this->object->exists(null) ); $basePath = __DIR__ . '/data'; $this->assertTrue( $this->object->exists('en-GB', $basePath) ); $this->assertFalse( $this->object->exists('es-ES', $basePath) ); } /** * Test... * * @covers JLanguage::load * @todo Implement testLoad(). * * @return void */ public function testLoad() { // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::parse * * @return void */ public function testParse() { $strings = $this->inspector->parse(__DIR__ . '/data/good.ini'); $this->assertThat( $strings, $this->logicalNot($this->equalTo(array())), 'Line: ' . __LINE__ . ' good ini file should load properly.' ); $this->assertEquals( $strings, array('FOO' => 'Bar'), 'Line: ' . __LINE__ . ' test that the strings were parsed correctly.' ); $strings = $this->inspector->parse(__DIR__ . '/data/bad.ini'); $this->assertEquals( $strings, array(), 'Line: ' . __LINE__ . ' bad ini file should not load properly.' ); } /** * Test... * * @covers JLanguage::get * @todo Implement testGet(). * * @return void */ public function testGet() { $this->assertNull( $this->object->get('noExist') ); $this->assertEquals( 'abc', $this->object->get('noExist', 'abc') ); // Note: property = tag, returns en-GB (default language) $this->assertEquals( 'en-GB', $this->object->get('tag') ); // Note: property = name, returns English (United Kingdom) (default language) $this->assertEquals( 'English (United Kingdom)', $this->object->get('name') ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getName * @todo Implement testGetName(). * * @return void */ public function testGetName() { $this->assertEquals( 'English (United Kingdom)', $this->object->getName() ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getPaths * @todo Implement testGetPaths(). * * @return void */ public function testGetPaths() { // Without extension, retuns NULL $this->assertNull( $this->object->getPaths('') ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getErrorFiles * @todo Implement testGetErrorFiles(). * * @return void */ public function testGetErrorFiles() { // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getTag * @todo Implement testGetTag(). * * @return void */ public function testGetTag() { $this->assertEquals( 'en-GB', $this->object->getTag() ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::isRTL * @todo Implement testIsRTL(). * * @return void */ public function testIsRTL() { $this->assertFalse( $this->object->isRTL() ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::setDebug * @covers JLanguage::getDebug * * @return void */ public function testGetSetDebug() { $current = $this->object->getDebug(); $this->assertEquals( $current, $this->object->setDebug(true), 'Line: ' . __LINE__ ); $this->object->setDebug(false); $this->assertFalse( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug(true); $this->assertTrue( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug(0); $this->assertFalse( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug(1); $this->assertTrue( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug(''); $this->assertFalse( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug('test'); $this->assertTrue( $this->object->getDebug(), 'Line: ' . __LINE__ ); $this->object->setDebug('0'); $this->assertFalse( $this->object->getDebug(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getDefault * * @return void */ public function testGetDefault() { $this->assertEquals( 'en-GB', $this->object->getDefault(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::setDefault * * @return void */ public function testSetDefault() { $this->object->setDefault('de-DE'); $this->assertEquals( 'de-DE', $this->object->getDefault(), 'Line: ' . __LINE__ ); $this->object->setDefault('en-GB'); } /** * Test... * * @covers JLanguage::getOrphans * @todo Implement testGetOrphans(). * * @return void */ public function testGetOrphans() { $this->assertEquals( array(), $this->object->getOrphans(), 'Line: ' . __LINE__ ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getUsed * @todo Implement testGetUsed(). * * @return void */ public function testGetUsed() { $this->assertEquals( array(), $this->object->getUsed(), 'Line: ' . __LINE__ ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::hasKey * @todo Implement testHasKey(). * * @return void */ public function testHasKey() { // Key doesn't exist, returns false $this->assertFalse( $this->object->hasKey('com_admin.key') ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getMetadata * @todo Implement testGetMetadata(). * * @return void */ public function testGetMetadata() { // Language doesn't exist, retun NULL $this->assertNull( $this->inspector->getMetadata('es-ES') ); $localeString = 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, ' . 'uk, united kingdom, united-kingdom'; // In this case, returns array with default language // - same operation of get method with metadata property $options = array( 'name' => 'English (United Kingdom)', 'tag' => 'en-GB', 'rtl' => '0', 'locale' => $localeString, 'firstDay' => '0' ); // Language exists, returns array with values $this->assertEquals( $options, $this->inspector->getMetadata('en-GB') ); } /** * Test... * * @covers JLanguage::getKnownLanguages * * @return void */ public function testGetKnownLanguages() { // This method returns a list of known languages $basePath = __DIR__ . '/data'; $localeString = 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain,' . ' uk, united kingdom, united-kingdom'; $option1 = array( 'name' => 'English (United Kingdom)', 'tag' => 'en-GB', 'rtl' => '0', 'locale' => $localeString, 'firstDay' => '0' ); $listCompareEqual1 = array( 'en-GB' => $option1, ); $list = JLanguage::getKnownLanguages($basePath); $this->assertEquals( $listCompareEqual1, $list, 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getLanguagePath * * @return void */ public function testGetLanguagePath() { $basePath = 'test'; // $language = null, returns language directory $this->assertEquals( 'test/language', JLanguage::getLanguagePath($basePath, null), 'Line: ' . __LINE__ ); // $language = value (en-GB, for example), returns en-GB language directory $this->assertEquals( 'test/language/en-GB', JLanguage::getLanguagePath($basePath, 'en-GB'), 'Line: ' . __LINE__ ); // With no argument JPATH_BASE should be returned $this->assertEquals( JPATH_BASE . '/language', JLanguage::getLanguagePath(), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::setLanguage * * @return void */ public function testSetLanguage() { $this->assertEquals( 'en-GB', $this->object->setLanguage('es-ES'), 'Line: ' . __LINE__ ); $this->assertEquals( 'es-ES', $this->object->setLanguage('en-GB'), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::getLocale * @todo Implement testGetLocale(). * * @return void */ public function testGetLocale() { // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::getFirstDay * @todo Implement testGetFirstDay(). * * @return void */ public function testGetFirstDay() { // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); } /** * Test... * * @covers JLanguage::parseLanguageFiles * * @return void */ public function testParseLanguageFiles() { $dir = __DIR__ . '/data/language'; $option = array( 'name' => 'English (United Kingdom)', 'tag' => 'en-GB', 'rtl' => '0', 'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england,' . ' great britain, uk, united kingdom, united-kingdom', 'firstDay' => '0' ); $expected = array( 'en-GB' => $option ); $result = JLanguage::parseLanguageFiles($dir); $this->assertEquals( $expected, $result, 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::parseXMLLanguageFile * * @return void */ public function testParseXMLLanguageFile() { $option = array( 'name' => 'English (United Kingdom)', 'tag' => 'en-GB', 'rtl' => '0', 'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain,' . ' uk, united kingdom, united-kingdom', 'firstDay' => '0' ); $path = __DIR__ . '/data/language/en-GB/en-GB.xml'; $this->assertEquals( $option, JLanguage::parseXMLLanguageFile($path), 'Line: ' . __LINE__ ); $path2 = __DIR__ . '/data/language/es-ES/es-ES.xml'; $this->assertEquals( $option, JLanguage::parseXMLLanguageFile($path), 'Line: ' . __LINE__ ); } /** * Test... * * @covers JLanguage::parseXMLLanguageFile * @expectedException RuntimeException * * @return void */ public function testParseXMLLanguageFileException() { $path = __DIR__ . '/data/language/es-ES/es-ES.xml'; JLanguage::parseXMLLanguageFile($path); } }
gpl-2.0
chensuchun/pbuilder
test_testlib.sh
632
#!/bin/bash # testsuite for testlib if [ -n "$PBUILDER_CHECKOUT" ]; then . "$PBUILDER_CHECKOUT/testlib.sh" else # these currently don't need to be exported PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}" PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}" . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh" fi test_success() { exit 0 } test_fail() { exit 1 } test_options() { echo "$@" exit 1 } test_output() { echo "$@" } expect_success test_success expect_fail test_fail expect_fail test_options "hello world" expect_output "foo bar" test_output "foo" "bar" testlib_summary
gpl-2.0
rbartolomeirb/joomlaatirb
tools/com_irbtools/build/administrator/components/com_irbtools/views/default/view.html.php
663
<?php /** * Joomla! 1.5 component irbtools * * @version $Id: view.html.php 2010-10-13 07:12:40 svn $ * @author IRB Barcelona * @package Joomla * @subpackage irbtools * @license GNU/GPL * * IRB Barcelona Tools * * This component file was created using the Joomla Component Creator by Not Web Design * http://www.notwebdesign.com/joomla_component_creator/ * */ // no direct access defined('_JEXEC') or die('Restricted access'); // Import Joomla! libraries jimport( 'joomla.application.component.view'); class IrbtoolsViewDefault extends JView { function display($tpl = null) { parent::display($tpl); } } ?>
gpl-2.0
Orphis/ppsspp
Core/SaveState.h
3168
// Copyright (c) 2012- PPSSPP Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 2.0 or later versions. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License 2.0 for more details. // A copy of the GPL 2.0 should have been included with the program. // If not, see http://www.gnu.org/licenses/ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include <functional> #include <string> #include <vector> #include "Common/ChunkFile.h" namespace SaveState { typedef std::function<void(bool status, const std::string &message, void *cbUserData)> Callback; static const int NUM_SLOTS = 5; static const char *STATE_EXTENSION = "ppst"; static const char *SCREENSHOT_EXTENSION = "jpg"; void Init(); void Shutdown(); // Cycle through the 5 savestate slots void NextSlot(); void SaveSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0); void LoadSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0); // Checks whether there's an existing save in the specified slot. bool HasSaveInSlot(const std::string &gameFilename, int slot); bool HasScreenshotInSlot(const std::string &gameFilename, int slot); int GetCurrentSlot(); // Returns -1 if there's no newest slot. int GetNewestSlot(const std::string &gameFilename); std::string GetSlotDateAsString(const std::string &gameFilename, int slot); std::string GenerateSaveSlotFilename(const std::string &gameFilename, int slot, const char *extension); std::string GetTitle(const std::string &filename); // Load the specified file into the current state (async.) // Warning: callback will be called on a different thread. void Load(const std::string &filename, Callback callback = Callback(), void *cbUserData = 0); // Save the current state to the specified file (async.) // Warning: callback will be called on a different thread. void Save(const std::string &filename, Callback callback = Callback(), void *cbUserData = 0); CChunkFileReader::Error SaveToRam(std::vector<u8> &state); CChunkFileReader::Error LoadFromRam(std::vector<u8> &state); // For testing / automated tests. Runs a save state verification pass (async.) // Warning: callback will be called on a different thread. void Verify(Callback callback = Callback(), void *cbUserData = 0); // To go back to a previous snapshot (only if enabled.) // Warning: callback will be called on a different thread. void Rewind(Callback callback = Callback(), void *cbUserData = 0); // Returns true if there are rewind snapshots available. bool CanRewind(); // Returns true if a savestate has been used during this session. bool HasLoadedState(); // Check if there's any save stating needing to be done. Normally called once per frame. void Process(); };
gpl-2.0
FFMG/myoddweb.piger
myodd/boost/libs/geometry/doc/doxy/doxygen_output/html_by_doxygen/structboost_1_1geometry_1_1nyi_1_1tag__to__term_3_01polygon__tag_01_4-members.html
3580
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Boost.Geometry (aka GGL, Generic Geometry Library)</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head> <table cellpadding="2" width="100%"> <tbody> <tr> <td valign="top"> <img alt="Boost.Geometry" src="images/ggl-logo-big.png" height="80" width="200"> &nbsp;&nbsp; </td> <td valign="top" align="right"> <a href="http://www.boost.org"> <img alt="Boost C++ Libraries" src="images/accepted_by_boost.png" height="80" width="230" border="0"> </a> </td> </tr> </tbody> </table> <!-- Generated by Doxygen 1.8.6 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class&#160;List</span></a></li> <li><a href="classes.html"><span>Class&#160;Index</span></a></li> <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li> <li><a href="functions.html"><span>Class&#160;Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceboost.html">boost</a></li><li class="navelem"><a class="el" href="namespaceboost_1_1geometry.html">geometry</a></li><li class="navelem"><a class="el" href="namespaceboost_1_1geometry_1_1nyi.html">nyi</a></li><li class="navelem"><a class="el" href="structboost_1_1geometry_1_1nyi_1_1tag__to__term_3_01polygon__tag_01_4.html">tag_to_term< polygon_tag ></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">boost::geometry::nyi::tag_to_term&lt; polygon_tag &gt; Member List</div> </div> </div><!--header--> <div class="contents"> <p>This is the complete list of members for <a class="el" href="structboost_1_1geometry_1_1nyi_1_1tag__to__term_3_01polygon__tag_01_4.html">boost::geometry::nyi::tag_to_term&lt; polygon_tag &gt;</a>, including all inherited members.</p> <table class="directory"> <tr class="even"><td class="entry"><a class="el" href="structboost_1_1geometry_1_1nyi_1_1tag__to__term_3_01polygon__tag_01_4.html#ac7797a759be7128aa788accdf8ced491">type</a> typedef</td><td class="entry"><a class="el" href="structboost_1_1geometry_1_1nyi_1_1tag__to__term_3_01polygon__tag_01_4.html">boost::geometry::nyi::tag_to_term&lt; polygon_tag &gt;</a></td><td class="entry"></td></tr> </table></div><!-- contents --> <hr size="1"> <table width="100%"> <tbody> <tr> <td align="left"><small> <p>April 2, 2011</p> </small></td> <td align="right"> <small> Copyright &copy; 2007-2011 Barend Gehrels, Amsterdam, the Netherlands<br> Copyright &copy; 2008-2011 Bruno Lalande, Paris, France<br> Copyright &copy; 2009-2010 Mateusz Loskot, London, UK<br> </small> </td> </tr> </tbody> </table> <address style="text-align: right;"><small> Documentation is generated by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a> </small></address> </body> </html>
gpl-2.0
xIchigox/ArkCORE-NG
dep/acelite/ace/Dynamic_Service_Dependency.cpp
1326
// $Id: Dynamic_Service_Dependency.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "ace/ACE.h" #include "ace/DLL_Manager.h" #include "ace/Dynamic_Service_Dependency.h" #include "ace/Service_Config.h" #include "ace/Log_Category.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal) { this->init (ACE_Service_Config::current (), principal); } ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal) { this->init (cfg, principal); } ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency (void) { if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"), this)); } void ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal) { const ACE_Service_Type* st = ACE_Dynamic_Service_Base::find_i (cfg, principal,false); if (ACE::debug ()) { ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) DSD, this=%@ - creating dependency on "), this)); st->dump (); } this->tracker_ = st->dll (); } ACE_END_VERSIONED_NAMESPACE_DECL
gpl-2.0
nhatnhatnet/nukecms
modules/news/language/block.global.block_news_cat_fr.php
1084
<?php /** * @Project NUKEVIET 4.x * @Author VINADES.,JSC ([email protected]) * @Copyright (C) 2016 VINADES.,JSC. All rights reserved * @Language Français * @License CC BY-SA (http://creativecommons.org/licenses/by-sa/4.0/) * @Createdate Jul 31, 2015, 09:30:00 AM */ if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE')) { die( 'Stop!!!' ); } $lang_translator['author'] = 'Nguyễn Phú Thành'; $lang_translator['createdate'] = '31/07/2015, 16:30'; $lang_translator['copyright'] = '[email protected]'; $lang_translator['info'] = ''; $lang_translator['langtype'] = 'lang_block'; $lang_block['catid'] = 'Sujet'; $lang_block['numrow'] = 'Nombre d\'articles affichés'; $lang_block['type'] = 'Méthode d\'affichage'; $lang_block['showtooltip'] = 'Affichage de tooltip'; $lang_block['tooltip_position'] = 'Position'; $lang_block['tooltip_position_top'] = 'Au dessus'; $lang_block['tooltip_position_bottom'] = 'Au dessous'; $lang_block['tooltip_position_left'] = 'A gauche'; $lang_block['tooltip_position_right'] = 'A droite'; $lang_block['tooltip_length'] = 'Numero';
gpl-2.0
jhbsz/LC4
package/atheros_ssdk/src/board/db12x/ethernet/athrs_mac.c
64735
/* * Copyright (c) 2008, Atheros Communications Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/stddef.h> #include <linux/module.h> #include <linux/types.h> #include <asm/byteorder.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/delay.h> #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> #include <linux/bitops.h> #include <linux/igmp.h> #include <asm/irq.h> #include <asm/io.h> #include <net/sch_generic.h> #include <linux/if_pppox.h> #include <linux/ip.h> #include <net/checksum.h> #include "osdep.h" #include "athrs_trc.h" #include "athrs_mac_def.h" #define MODULE_NAME "ATHR_GMAC" MODULE_LICENSE("Dual BSD/GPL"); module_param(tx_len_per_ds, int, 0); MODULE_PARM_DESC(tx_len_per_ds, "Size of DMA chunk"); int fifo_3 = 0x1f00140; module_param(fifo_3, int, 0); MODULE_PARM_DESC(fifo_3, "fifo cfg 3 settings"); int mii0_if = ATHR_GMAC_MII0_INTERFACE; module_param(mii0_if, int, 0); MODULE_PARM_DESC(mii0_if, "mii0 connect"); int mii1_if = ATHR_GMAC_MII1_INTERFACE; module_param(mii1_if, int, 0); MODULE_PARM_DESC(mii1_if, "mii1 connect"); int gige_pll = 0x1a000000; module_param(gige_pll, int, 0); MODULE_PARM_DESC(gige_pll, "Pll for (R)GMII if"); int fifo_5 = 0xbefff; module_param(fifo_5, int, 0); MODULE_PARM_DESC(fifo_5, "fifo cfg 5 settings"); static char *mii_str[2][4] = { {"GMii", "Mii", "RGMii", "RMii"}, {"GMii","Mii","RGMii", "RMii"} }; int ignore_packet_inspection = 0; #ifdef CONFIG_ATHRS17_HNAT void aos_header_arp_in (struct sk_buff *skb); #endif void set_packet_inspection_flag(int flag) { if(flag==0) ignore_packet_inspection = 0; else ignore_packet_inspection = 1; } void hdr_dump(char *str,int unit,struct ethhdr *ehdr,int qos,int ac) { printk("\n[%s:%x][%x:%x][MAC1:%x,%x,%x,%x,%x,%x" "MAC2: %x,%x,%x,%x,%x,%x Prot:%x]\n",str,unit,qos,ac, ehdr->h_dest[0],ehdr->h_dest[1],ehdr->h_dest[2],ehdr->h_dest[3], ehdr->h_dest[4],ehdr->h_dest[5],ehdr->h_source[0],ehdr->h_source[1], ehdr->h_source[2],ehdr->h_source[3],ehdr->h_source[4], ehdr->h_source[5],ehdr->h_proto); } void pkt_dump(uint8_t *data,int len,const char *dir,int unit) { int i; for (i=0;i<=len;i++) { if (i == 0) printk("%s mac:%d: len:%d ->\n",dir,unit,len); printk("%2X:",data[i]); if (!(i%20)) printk("\n"); } } static int athr_gmac_open(struct net_device *dev) { unsigned int w1 = 0, w2 = 0; athr_gmac_t *mac = (athr_gmac_t *)ATHR_MAC_PRIV(dev); athr_phy_ops_t *phy = mac->phy; int st; unsigned long flags; uint32_t mask; assert(mac); if(!phy) { printk("ERROR: MAC:%d PHY not found !!!\n",mac->mac_unit); return -1; } if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) mac->mac_noacs = 4; else mac->mac_noacs = 1; mac->tx_ac_bt = 0; mac->tx_ac_drops = 0; st = request_irq(mac->mac_irq, athr_gmac_intr, ATHR_MAC_IRQF_DISABLED, dev->name, dev); if (st < 0) { printk(MODULE_NAME ": request irq %d failed %d\n", mac->mac_irq, st); return 1; } if (athr_gmac_tx_alloc(mac)) goto tx_failed; if (athr_gmac_rx_alloc(mac)) goto rx_failed; udelay(20); mask = athr_gmac_reset_mask(mac->mac_unit); /* * put into reset, hold, pull out. */ spin_lock_irqsave(&mac->mac_lock, flags); athr_reg_rmw_set(ATHR_RESET, mask); udelay(10); athr_reg_rmw_clear(ATHR_RESET, mask); udelay(10); spin_unlock_irqrestore(&mac->mac_lock, flags); if (mac->mac_unit == 0) { athr_nat_init(); athr_hw_acl_init(); } athr_gmac_hw_setup(mac); mac->mac_speed = ATHR_PHY_SPEED_UNKNOWN; phy->init(mac); printk("Setting PHY...\n"); if (mac_has_flag(mac,ETH_SOFT_LED)) { /* Resetting PHY will disable MDIO access needed by soft LED task. * Hence, Do not reset PHY until Soft LED task get completed. */ while(atomic_read(&Ledstatus) == 1); } phy_in_reset = 1; phy->setup(mac); phy_in_reset = 0; /* * set the mac addr */ addr_to_words(dev->dev_addr, w1, w2); athr_gmac_reg_wr(mac, ATHR_GMAC_GE_MAC_ADDR1, w1); athr_gmac_reg_wr(mac, ATHR_GMAC_GE_MAC_ADDR2, w2); dev->trans_start = jiffies; /* * XXX FIX ME: Enable intterupt only after link is asserted * check if interrupts are enabled by default. */ athr_gmac_int_disable(mac); /* * Keep carrier off while initialization and switch it once the link is up. */ netif_carrier_off(dev); netif_stop_queue(dev); athr_napi_enable(mac); mac->mac_ifup = 1; athr_gmac_int_enable(mac); if (is_ar7240()) athr_gmac_intr_enable_rxovf(mac); /* * Enable Link poll, Soft led, dma_check timers */ athr_gmac_timer_init(mac); if (mac_has_flag(mac,ETH_LINK_INTERRUPT)) mac->phy->en_link_intrs(mac); athr_gmac_rx_start(mac); if (is_8021()) athr_gmac_check_link(mac, 0); return 0; rx_failed: athr_gmac_tx_free(mac); tx_failed: free_irq(mac->mac_irq, dev); return 1; } static int athr_gmac_stop(struct net_device *dev) { athr_gmac_t *mac = (athr_gmac_t *)ATHR_MAC_PRIV(dev); unsigned long flags; netif_stop_queue(dev); netif_carrier_off(dev); athr_napi_disable(mac); spin_lock_irqsave(&mac->mac_lock, flags); mac->mac_ifup = 0; mac->link_up = 0; athr_gmac_timer_del(mac); athr_gmac_hw_stop(mac); athr_gmac_tx_free(mac); athr_gmac_rx_free(mac); spin_unlock_irqrestore(&mac->mac_lock, flags); athr_napi_disable(mac); free_irq(mac->mac_irq, dev); return 0; } static int mdc_check(athr_gmac_t *mac) { int i; for (i=0; i<4000; i++) { if(mac->phy->read_mac_reg(0x10c) != 0x18007fff) return -1; } return 0; } static void athr_gmac_mii_setup(athr_gmac_t *mac) { uint8_t mgmt_cfg_val = 0, check_cnt = 0; /* * set the mii if type - NB reg not in the gigE space */ if (is_ar934x() && (is_f1e() || is_vir_phy())) { if (is_vir_phy()) printk("WASP ----> VIR PHY\n"); else printk("WASP ----> F1e PHY\n"); mgmt_cfg_val = 6; if(mac->mac_unit == 0) athr_reg_wr(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_RGMII_GE0); // External RGMII Mode on GE0 athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); return; } if (is_ar934x() && is_s16()) { if (is_s17()) printk("WASP ----> S17 PHY *\n"); else printk("WASP ----> S16 PHY *\n"); mgmt_cfg_val = 4; if(mac->mac_unit == 0) athr_reg_wr(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_RGMII_GE0); athr_reg_rmw_clear(ATHR_SWITCH_CLK_SPARE, (1 << 6)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); return; } if (is_ar934x() && is_s27()) { if (!is_emu()) { printk("WASP ----> S27 PHY MDIO\n"); mgmt_cfg_val = 2; athr_swap_phy(); athr_reg_wr(ATHR_SWITCH_CLK_SPARE,(athr_reg_rd(ATHR_SWITCH_CLK_SPARE)|0x40)); athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); if (mac_has_flag(mac,ETH_SWONLY_MODE)) { athr_reg_rmw_set(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_SW_ONLY_MODE); athr_gmac_reg_rmw_set(athr_gmacs[0], ATHR_GMAC_CFG1, ATHR_GMAC_CFG1_SOFT_RST);; } //athr_reg_rmw_set(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_SW_APB_ACCESS); } else { printk("WASP EMULATION ----> S27 PHY\n"); mgmt_cfg_val = 7; athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); } return; } if (is_ar7240()) { mgmt_cfg_val = 0x2; if (mac->mac_unit == 0) { athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); } } else { switch (athrs_ahb_freq/1000000) { case 150: mgmt_cfg_val = 0x7; break; case 175: mgmt_cfg_val = 0x5; break; case 200: mgmt_cfg_val = 0x4; break; case 210: mgmt_cfg_val = 0x9; break; case 220: mgmt_cfg_val = 0x9; break; case 40: case 24: /* hornet emulation...ahb is either 24 or 40Mhz */ mgmt_cfg_val = 0x6; break; default: mgmt_cfg_val = 0x7; } if ((is_ar7241() || is_ar7242())) { if (is_8021()) { athr_gmac_reg_rmw_set(mac, ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_RGMII_GE0); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); return ; } /* External MII mode */ if (mac->mac_unit == 0 && is_ar7242()) { mgmt_cfg_val = 0x6; athr_reg_rmw_set(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_RGMII_GE0); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); } /* Virian */ mgmt_cfg_val = 0x4; if (mac_has_flag(mac,ETH_SWONLY_MODE)) { athr_reg_rmw_set(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_SW_ONLY_MODE); athr_gmac_reg_rmw_set(athr_gmacs[0], ATHR_GMAC_CFG1, ATHR_GMAC_CFG1_SOFT_RST);; } athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(athr_gmacs[1], ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); printk("Virian MDC CFG Value ==> %x\n",mgmt_cfg_val); } else if(is_ar9330()){ athr_reg_wr(ATHR_GMAC_ETH_CFG, ATHR_GMAC_ETH_CFG_MII_GE0_SLAVE); mgmt_cfg_val = 0xF; if (mac->mac_unit == 1) { while (check_cnt++ < 10) { athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); if(mdc_check(mac) == 0) break; } if(check_cnt == 11) printk("%s: MDC check failed\n", __func__); } } else { /* Python 1.0 & 1.1 */ if (mac->mac_unit == 0) { while (check_cnt++ < 10) { athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val | (1 << 31)); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CFG, mgmt_cfg_val); if(mdc_check(mac) == 0) break; } if(check_cnt == 11) printk("%s: MDC check failed\n", __func__); } } } } static void athr_gmac_hw_setup(athr_gmac_t *mac) { athr_gmac_ring_t *tx, *rx = &mac->mac_rxring; athr_gmac_desc_t *r0, *t0; uint8_t ac; /* clear the rx fifo state if any */ athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_RX_STATUS, athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_RX_STATUS)); athr_gmac_reg_wr(mac, ATHR_GMAC_CFG1, (ATHR_GMAC_CFG1_RX_EN | ATHR_GMAC_CFG1_TX_EN)); if ((mac->mac_unit == 1)) athr_gmac_reg_rmw_set(mac, ATHR_GMAC_CFG2, (ATHR_GMAC_CFG2_PAD_CRC_EN | ATHR_GMAC_CFG2_LEN_CHECK | ATHR_GMAC_CFG2_IF_1000)); if (mac->mac_unit == 0) athr_gmac_reg_rmw_set(mac, ATHR_GMAC_CFG2, (ATHR_GMAC_CFG2_PAD_CRC_EN | ATHR_GMAC_CFG2_LEN_CHECK | ATHR_GMAC_CFG2_IF_10_100)); athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_0, 0x1f00); if (mac_has_flag(mac,ATHR_RX_FLCTL)) athr_gmac_reg_rmw_set(mac,ATHR_GMAC_CFG1,ATHR_GMAC_CFG1_RX_FCTL); if (mac_has_flag(mac,ATHR_TX_FLCTL)) athr_gmac_reg_rmw_set(mac,ATHR_GMAC_CFG1,ATHR_GMAC_CFG1_TX_FCTL); /* Disable ATHR_GMAC_CFG2_LEN_CHECK to fix the bug that * the mac address is mistaken as length when enabling Atheros header */ if (mac_has_flag(mac,ATHR_HEADER_ENABLED)) athr_gmac_reg_rmw_clear(mac, ATHR_GMAC_CFG2, ATHR_GMAC_CFG2_LEN_CHECK) if(!is_ar7100()) athr_gmac_mii_setup(mac); athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_1, 0x10ffff); athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_2, 0x015500aa); /* * Weed out junk frames (CRC errored, short collision'ed frames etc.) */ athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_4, 0x3ffff); /* * Drop CRC Errors, Pause Frames ,Length Error frames, Truncated Frames * dribble nibble and rxdv error frames. */ printk("Setting Drop CRC Errors, Pause Frames and Length Error frames \n"); if (is_8021()) { athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_5, 0xbefff); } else if (mac_has_flag(mac,ATHR_HEADER_ENABLED)) { athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_5, 0xe6be2); } else if (mac->mac_unit == 0 && (is_ar7242() || is_s16())) { athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_5, 0xe6be2); } else { athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_5, 0x66b82); } if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) { athr_gmac_reg_wr(mac,ATHR_GMAC_DMA_TX_ARB_CFG,ATHR_GMAC_TX_QOS_MODE_WEIGHTED | ATHR_GMAC_TX_QOS_WGT_0(0x7) | ATHR_GMAC_TX_QOS_WGT_1(0x5) | ATHR_GMAC_TX_QOS_WGT_2(0x3) | ATHR_GMAC_TX_QOS_WGT_3(0x1)); for(ac = 0;ac < mac->mac_noacs; ac++) { tx = &mac->mac_txring[ac]; t0 = &tx->ring_desc[0]; switch(ac) { case ENET_AC_VO: athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_TX_DESC_Q0, athr_gmac_desc_dma_addr(tx, t0)); break; case ENET_AC_VI: athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_TX_DESC_Q1, athr_gmac_desc_dma_addr(tx, t0)); break; case ENET_AC_BK: athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_TX_DESC_Q2, athr_gmac_desc_dma_addr(tx, t0)); break; case ENET_AC_BE: athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_TX_DESC_Q3, athr_gmac_desc_dma_addr(tx, t0)); break; } } } else { tx = &mac->mac_txring[0]; t0 = &tx->ring_desc[0]; athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_TX_DESC_Q0, athr_gmac_desc_dma_addr(tx, t0)); } r0 = &rx->ring_desc[0]; athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_RX_DESC, athr_gmac_desc_dma_addr(rx, r0)); DPRINTF(MODULE_NAME ": cfg1 %#x cfg2 %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_CFG1), athr_gmac_reg_rd(mac, ATHR_GMAC_CFG2)); } static void athr_gmac_hw_stop(athr_gmac_t *mac) { athr_phy_ops_t *phy = mac->phy; int i; athr_gmac_rx_stop(mac); athr_gmac_tx_stop(mac); athr_gmac_int_disable(mac); if (mac_has_flag(mac,ETH_LINK_INTERRUPT)) phy->dis_link_intrs(mac); /* During interface up on PHY reset the link status will be updated. * Clearing the software link status while bringing the interface down * will avoid the race condition during PHY RESET. */ if (mac_has_flag(mac,ETH_SOFT_LED)) { if (mac->mac_unit == ENET_UNIT_LAN) { for(i = 0;i < 4; i++) mac->ledctrl.link[i] = 0; } else { mac->ledctrl.link[4] = 0; } } /* * put everything into reset. * Dont Reset WAN MAC as we are using eth0 MDIO to access S26 Registers. */ if(!is_ar9330_emu() && (mac->mac_unit == 1 || is_ar7241() || is_ar7242() || is_emu() || is_ar934x()) ) { athr_gmac_reg_rmw_set(mac, ATHR_GMAC_CFG1, ATHR_GMAC_CFG1_SOFT_RST); } } /* * Several fields need to be programmed based on what the PHY negotiated * Ideally we should quiesce everything before touching the pll, but: * 1. If its a linkup/linkdown, we dont care about quiescing the traffic. * 2. If its a single gigE PHY, this can only happen on lup/ldown. * 3. If its a 100Mpbs switch, the link will always remain at 100 (or nothing) * 4. If its a gigE switch then the speed should always be set at 1000Mpbs, * and the switch should provide buffering for slower devices. * * XXX Only gigE PLL can be changed as a parameter for now. 100/10 is hardcoded. * XXX Need defines for them - * XXX FIFO settings based on the mode */ void athr_gmac_set_mac_from_link(athr_gmac_t *mac, athr_phy_speed_t speed, int fdx) { athr_gmac_ops_t *ops = mac->ops; if (mac_has_flag(mac,ETH_FORCE_SPEED)) { speed = mac->forced_speed; fdx = 1; } mac->mac_speed = speed; mac->mac_fdx = fdx; athr_gmac_set_mac_duplex(mac, fdx); athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_3, fifo_3); athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_FIFO_THRESH ,0x01d80160); switch (speed) { case ATHR_PHY_SPEED_1000T: athr_gmac_set_mac_if(mac, 1); athr_gmac_reg_rmw_set(mac, ATHR_GMAC_FIFO_CFG_5, (1 << 19)); if (ops->set_pll) ops->set_pll(mac,mac->mac_speed); if (is_ar7242() && mac->mac_unit == 0) athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x16000000); if (is_ar934x() && mac->mac_unit == 0 && is_s16()) athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x06000000); if (is_ar934x() && mac->mac_unit == 0 && is_f1e() ) athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x0e000000); if (is_ar934x() && mac->mac_unit == 0 && is_vir_phy() ){ athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x82000000); athr_reg_wr(ATHR_GMAC_ETH_CFG,0x000c0001); } if (is_ar934x() && mac->mac_unit == 0 && is_f1e() ) { athr_reg_rmw_set(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RXD_DELAY); athr_reg_rmw_set(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RDV_DELAY); } break; case ATHR_PHY_SPEED_100T: athr_gmac_set_mac_if(mac, 0); athr_gmac_set_mac_speed(mac, 1); athr_gmac_reg_rmw_clear(mac, ATHR_GMAC_FIFO_CFG_5, (1 << 19)); if (is_emu() && is_f1e()) { athr_reg_wr(0xb804006c,0x2); athr_reg_rmw_clear(ATHR_GPIO_OUT_FUNCTION1, (0xff << 16)); athr_reg_rmw_set(ATHR_GPIO_OE, 0x4); athr_reg_rmw_set(ATHR_GPIO_OUT, 0x4); udelay(10); athr_reg_rmw_clear(ATHR_GPIO_OUT, 0x4); } if (ops->set_pll) ops->set_pll(mac,mac->mac_speed); if ((is_ar7242() || is_ar934x()) && mac->mac_unit == 0 && (is_s16() || is_f1e())) athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x0101); if (is_ar934x() && mac->mac_unit == 0 && is_f1e()) { athr_reg_rmw_clear(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RXD_DELAY); athr_reg_rmw_clear(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RDV_DELAY); } break; case ATHR_PHY_SPEED_10T: athr_gmac_set_mac_if(mac, 0); athr_gmac_set_mac_speed(mac, 0); athr_gmac_reg_rmw_clear(mac, ATHR_GMAC_FIFO_CFG_5, (1 << 19)); if (mac->mac_unit == 0 && !mac->mac_fdx) { athr_gmac_reg_wr(mac, ATHR_GMAC_DMA_FIFO_THRESH ,0x00880060); athr_gmac_reg_wr(mac, ATHR_GMAC_FIFO_CFG_3, 0x00f00040); } if (ops->set_pll) ops->set_pll(mac,mac->mac_speed); if ((is_ar7242() || is_ar934x()) && mac->mac_unit == 0 && is_s16()) athr_reg_wr(ATHR_GMAC_XMII_CONFIG,0x1616); if (is_ar934x() && mac->mac_unit == 0 && is_f1e()) { athr_reg_rmw_clear(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RXD_DELAY); athr_reg_rmw_clear(ATHR_GMAC_ETH_CFG,ATHR_GMAC_ETH_CFG_RDV_DELAY); } break; default: assert(0); } DPRINTF(MODULE_NAME ": cfg_1: %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_FIFO_CFG_1)); DPRINTF(MODULE_NAME ": cfg_2: %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_FIFO_CFG_2)); DPRINTF(MODULE_NAME ": cfg_3: %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_FIFO_CFG_3)); DPRINTF(MODULE_NAME ": cfg_4: %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_FIFO_CFG_4)); DPRINTF(MODULE_NAME ": cfg_5: %#x\n", athr_gmac_reg_rd(mac, ATHR_GMAC_FIFO_CFG_5)); } void athr_gmac_fast_reset(athr_gmac_t *mac,athr_gmac_desc_t *ds,int ac) { athr_gmac_ring_t *r = &mac->mac_txring[0]; uint32_t rx_ds,tx_ds; unsigned long flags,mask,int_mask; unsigned int w1 = 0, w2 = 0; spin_lock_irqsave(&mac->mac_lock, flags); int_mask = athr_gmac_reg_rd(mac,ATHR_GMAC_DMA_INTR_MASK); athr_gmac_tx_stop(mac); athr_gmac_rx_stop(mac); rx_ds = athr_gmac_reg_rd(mac,ATHR_GMAC_DMA_RX_DESC); tx_ds = athr_gmac_reg_rd(mac,ATHR_GMAC_DMA_TX_DESC); mask = athr_gmac_reset_mask(mac->mac_unit); /* * put into reset, hold, pull out. */ athr_reg_rmw_set(ATHR_RESET, mask); udelay(10); athr_reg_rmw_clear(ATHR_RESET, mask); udelay(10); if (mac->mac_unit == 0) { athr_nat_init(); athr_hw_acl_init(); } athr_gmac_hw_setup(mac); if (ds){ athr_gmac_reg_wr(mac,ATHR_GMAC_DMA_TX_DESC, (athr_gmac_desc_dma_addr(r,ds))); } else { athr_gmac_reg_wr(mac,ATHR_GMAC_DMA_TX_DESC,tx_ds); } athr_gmac_reg_wr(mac,ATHR_GMAC_DMA_RX_DESC,rx_ds); /* * set the mac addr */ addr_to_words(mac->mac_dev->dev_addr, w1, w2); athr_gmac_reg_wr(mac, ATHR_GMAC_GE_MAC_ADDR1, w1); athr_gmac_reg_wr(mac, ATHR_GMAC_GE_MAC_ADDR2, w2); athr_gmac_set_mac_from_link(mac, mac->mac_speed, mac->mac_fdx); mac->dma_check = 1; mac->tx_ac_bt = 0; mac->tx_ac_drops = 0; if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) { athr_gmac_tx_start_qos(mac,ac); } else { athr_gmac_tx_start(mac); } athr_gmac_rx_start(mac); /* * Restore interrupts */ athr_gmac_reg_wr(mac,ATHR_GMAC_DMA_INTR_MASK,int_mask); spin_unlock_irqrestore(&mac->mac_lock,flags); } unsigned int athr_gmac_get_link_st(athr_gmac_t *mac, int *link, int *fdx, athr_phy_speed_t *speed,int phyUnit) { athr_phy_ops_t *phy = mac->phy; if(phy) { *link = phy->is_up(mac->mac_unit); *fdx = phy->is_fdx(mac->mac_unit, phyUnit); *speed = phy->speed(mac->mac_unit, phyUnit); } else { printk("MAC:%d Warning: Phy not found!!!\n",mac->mac_unit); } return 0; } /* * phy link state management */ int athr_gmac_check_link(void *arg,int phyUnit) { athr_phy_speed_t speed; athr_gmac_t *mac = (athr_gmac_t *) arg; struct net_device *dev = mac->mac_dev; athr_phy_ops_t *phy = mac->phy; int carrier = netif_carrier_ok(dev); int fdx, phy_up; int rc; assert(mac); assert(phy); rc = athr_gmac_get_link_st(mac, &phy_up, &fdx, &speed, phyUnit); if(phy->stab_wr) phy->stab_wr(phyUnit,phy_up,speed); if (rc < 0) goto done; if (!phy_up) { if (carrier) { printk(MODULE_NAME ":unit %d: phy %0d not up carrier %d\n", mac->mac_unit, phyUnit, carrier); /* A race condition is hit when the queue is switched on while tx interrupts are enabled. * To avoid that disable tx interrupts when phy is down. */ mac->link_up = 0; athr_gmac_intr_disable_tx(mac); netif_carrier_off(dev); netif_stop_queue(dev); if (mac_has_flag(mac,ETH_SOFT_LED)) { mac->ledctrl.link[phyUnit] = 0; phy->write_phy_reg(mac->mac_unit,phyUnit,0x19,0x0); /* * Turn off LED */ if (is_ar9330()) { athr_reg_wr(ATHR_GPIO_FUNCTIONS, (athr_reg_rd(ATHR_GPIO_FUNCTIONS)& (~(1 << (phyUnit + 3))))); } } } goto done; } if(!mac->mac_ifup) goto done; /* * phy is up. Either nothing changed or phy setttings changed while we * were sleeping. */ if ((fdx < 0) || (speed < 0)) { printk(MODULE_NAME ": phy not connected?\n"); return 0; } if (carrier && (speed == mac->mac_speed) && (fdx == mac->mac_fdx)) goto done; if (phy->is_alive(phyUnit) || is_ar9330_emu()) { printk(MODULE_NAME ": Enet Unit:%d PHY:%d is UP ", mac->mac_unit,phyUnit); printk("%s %s %s\n", mii_str[mac->mac_unit][mii_if(mac)], spd_str[speed], dup_str[fdx]); athr_gmac_set_mac_from_link(mac, speed, fdx); printk(MODULE_NAME ": done cfg2 %#x ifctl %#x miictrl \n", athr_gmac_reg_rd(mac, ATHR_GMAC_CFG2), athr_gmac_reg_rd(mac, ATHR_GMAC_IFCTL)); if (!mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) athr_gmac_fast_reset(mac,NULL,0); /* * in business */ netif_carrier_on(dev); netif_start_queue(dev); mac->link_up = 1; /* * WAR: Enable link LED to glow if speed is negotiated as 10 Mbps */ if (mac_has_flag(mac,ETH_SOFT_LED)) { mac->ledctrl.link[phyUnit] = 1; mac->ledctrl.speed[phyUnit] = speed; if (is_ar9330()) { /* * Turn on LED */ athr_reg_wr(ATHR_GPIO_FUNCTIONS, (athr_reg_rd(ATHR_GPIO_FUNCTIONS) | (1 << (phyUnit + 3)))); } phy->write_phy_reg(mac->mac_unit,phyUnit,0x19,0x3c0); } } else { if (mac_has_flag(mac,ETH_SOFT_LED)) { mac->ledctrl.link[phyUnit] = 0; phy->write_phy_reg(mac->mac_unit,phyUnit,0x19,0x0); if (is_ar9330()) { phy->write_phy_reg(mac->mac_unit,phyUnit,0x18,0x0); /* * Turn off LED */ athr_reg_wr(ATHR_GPIO_FUNCTIONS, athr_reg_rd(ATHR_GPIO_FUNCTIONS) & (~(1 << (phyUnit + 3)))); } } printk(MODULE_NAME ": Enet Unit:%d PHY:%d is Down.\n", mac->mac_unit,phyUnit); } done: return 0; } uint16_t athr_gmac_mii_read(int unit, uint32_t phy_addr, uint8_t reg) { athr_gmac_t *mac = athr_gmac_unit2mac(unit); uint16_t addr = (phy_addr << ATHR_GMAC_ADDR_SHIFT) | reg, val = 0; volatile int rddata; uint16_t ii = 0x1000; if(is_ar9330_emu()) mac = athr_gmac_unit2mac(0); /* * Check for previous transactions are complete. Added to avoid * race condition while running at higher frequencies. */ do { udelay(5); rddata = athr_gmac_reg_rd(mac, ATHR_GMAC_MII_MGMT_IND) & 0x1; }while(rddata && --ii); if (ii == 0) printk("ERROR:%s:%d transaction failed\n",__func__,__LINE__); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CMD, 0x0); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_ADDRESS, addr); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CMD, ATHR_GMAC_MGMT_CMD_READ); do { udelay(5); rddata = athr_gmac_reg_rd(mac, ATHR_GMAC_MII_MGMT_IND) & 0x1; }while(rddata && --ii); if (ii == 0) printk("ERROR:%s:%d transaction failed\n",__func__,__LINE__); val = athr_gmac_reg_rd(mac, ATHR_GMAC_MII_MGMT_STATUS); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CMD, 0x0); return val; } void athr_gmac_mii_write(int unit, uint32_t phy_addr, uint8_t reg, uint16_t data) { athr_gmac_t *mac = athr_gmac_unit2mac(unit); uint16_t addr = (phy_addr << ATHR_GMAC_ADDR_SHIFT) | reg; volatile int rddata; uint16_t ii = 0x1000; if(is_ar9330_emu()) mac = athr_gmac_unit2mac(0); /* * Check for previous transactions are complete. Added to avoid * race condition while running at higher frequencies. */ do { udelay(5); rddata = athr_gmac_reg_rd(mac, ATHR_GMAC_MII_MGMT_IND) & 0x1; }while(rddata && --ii); if (ii == 0) printk("ERROR:%s:%d transaction failed\n",__func__,__LINE__); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CMD, 0x0); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_ADDRESS, addr); athr_gmac_reg_wr(mac, ATHR_GMAC_MII_MGMT_CTRL, data); do { rddata = athr_gmac_reg_rd(mac, ATHR_GMAC_MII_MGMT_IND) & 0x1; }while(rddata && --ii); if (ii == 0) printk("ERROR:%s:%d transaction failed\n",__func__,__LINE__); } /* * Tx operation: * We do lazy reaping - only when the ring is "thresh" full. If the ring is * full and the hardware is not even done with the first pkt we q'd, we turn * on the tx interrupt, stop all q's and wait for h/w to * tell us when its done with a "few" pkts, and then turn the Qs on again. * * Locking: * The interrupt only touches the ring when Q's stopped => Tx is lockless, * except when handling ring full. * * Desc Flushing: Flushing needs to be handled at various levels, broadly: * - The DDr FIFOs for desc reads. * - WB's for desc writes. */ static void athr_gmac_handle_tx_full(athr_gmac_t *mac,int ac) { unsigned long flags; /* * Do nothing if the link went down while we are here. */ if (netif_queue_stopped(mac->mac_dev) && !mac->link_up) return; if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) { mac->tx_ac_bt |= (1 << ac); if (!((mac->tx_ac_bt & 0xf) == 0xf)) return; } assert(!netif_queue_stopped(mac->mac_dev)); mac->mac_net_stats.tx_fifo_errors ++; netif_stop_queue(mac->mac_dev); spin_lock_irqsave(&mac->mac_lock, flags); athr_gmac_intr_enable_tx(mac); spin_unlock_irqrestore(&mac->mac_lock, flags); } static void athr_gmac_add_hdr(athr_gmac_t *mac,struct sk_buff *skb) { int ac = skb->priority; if (mac_has_flag(mac,ATHR_S26_HEADER)) { skb_push(skb, ATHR_HEADER_LEN); skb->data[0] = 0x30; /* broadcast = 0; from_cpu = 0; reserved = 1; port_num = 0 */ skb->data[1] = (0x40 | (ac << HDR_PRIORITY_SHIFT)); /* reserved = 0b10; priority = 0; type = 0 (normal) */ skb->priority = ENET_AC_BE; } else if (mac_has_flag(mac,ATHR_S16_HEADER)) { skb_push(skb, ATHR_HEADER_LEN); memcpy(skb->data,skb->data + ATHR_HEADER_LEN, 12); skb->data[12] = 0x30; /* broadcast = 0; from_cpu = 0; reserved = 1; port_num = 0 */ skb->data[13] = 0x40 | ((ac << HDR_PRIORITY_SHIFT)); /* reserved = 0b10; priority = 0; type = 0 (normal) */ skb->priority = ENET_AC_BE; } else if (mac_has_flag(mac,ATHR_S27_HEADER)) { skb_push(skb, ATHR_HEADER_LEN); memcpy(skb->data,skb->data + ATHR_HEADER_LEN, 12); skb->data[13] = 0x1e; /* Lower order bits (0 - 7) */ skb->data[12] = 0x80 | ((ac << HDR_PRIORITY_SHIFT)); /* Higer order bits (8 - 15)*/ skb->priority = ENET_AC_BE; } } int athr_gmac_hard_start(struct sk_buff *skb, struct net_device *dev) { athr_gmac_t *mac = (athr_gmac_t *)ATHR_MAC_PRIV(dev); athr_gmac_ring_t *r; athr_gmac_buffer_t *bp; athr_gmac_desc_t *ds, *fds; unsigned char *start; int len; int nds_this_pkt; int ac = 0; assert(mac->mac_ifup); IF_ATHR_SKB_LEN_CHECK() { printk(MODULE_NAME ": bad skb, len %d\n", skb->len); goto dropit; } if (athr_gmac_plc_filter(skb, mac)) goto dropit; for (ac = 0;ac < mac->mac_noacs; ac++) { if (athr_gmac_tx_reap_thresh(mac,ac)) athr_gmac_tx_reap(mac,ac); } skb->priority = ENET_AC_BE; athr_gmac_tx_qos(mac,skb); if (athr_gmac_check_qos_bt(mac,skb)) goto dropit; if (mac_has_flag(mac,ATHR_HEADER_ENABLED)) athr_gmac_add_hdr(mac,skb); r = &mac->mac_txring[skb->priority]; assert(r); athr_gmac_trc_new(r->ring_head,"hard-stop hd"); athr_gmac_trc_new(r->ring_tail,"hard-stop tl"); athr_gmac_trc_new(skb->len, "len this pkt"); athr_gmac_trc_new(skb->data, "ptr 2 pkt"); athr_mac_dma_cache_sync(skb->data, skb->len); bp = &r->ring_buffer[r->ring_head]; assert(bp); bp->buf_pkt = skb; len = skb->len; start = skb->data; assert(len > 4); nds_this_pkt = 1; fds = ds = athr_gmac_get_tx_ds(mac, &len, &start, skb->priority); ds->res1 = 0; athr_nat_process_egress_pkts(mac->mac_unit, skb, ds); while ( len > 0) { ds = athr_gmac_get_tx_ds(mac, &len, &start, skb->priority); nds_this_pkt++; athr_gmac_tx_give_to_dma(ds); } athr_acl_enable_tx(mac,ds); ds->res2 = 0; ds->ftpp_override = 0; ds->res3 = 0; ds->more = 0; athr_gmac_tx_give_to_dma(fds); bp->buf_lastds = ds; bp->buf_nds = nds_this_pkt; athr_gmac_trc_new(ds,"last ds"); athr_gmac_trc_new(nds_this_pkt,"nmbr ds for this pkt"); wmb(); mac->net_tx_packets ++; mac->net_tx_bytes += skb->len; athr_gmac_trc(athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_TX_CTRL),"dma idle"); if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) { athr_gmac_tx_start_qos(mac,skb->priority); } else { athr_gmac_tx_start(mac); } for ( ac = 0;ac < mac->mac_noacs; ac++) { if (unlikely(athr_gmac_tx_ring_full(mac,ac))) athr_gmac_handle_tx_full(mac,ac); } dev->trans_start = jiffies; return NETDEV_TX_OK; dropit: if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) mac->tx_ac_drops++; else printk(MODULE_NAME ": dropping skb %08x\n", (unsigned int)skb); kfree_skb(skb); return NETDEV_TX_OK; } /* * Interrupt handling: * - Recv NAPI style (refer to Documentation/networking/NAPI) * * 2 Rx interrupts: RX and Overflow (OVF). * - If we get RX and/or OVF, schedule a poll. Turn off _both_ interurpts. * * - When our poll's called, we * a) Have one or more packets to process and replenish * b) The hardware may have stopped because of an OVF. * * - We process and replenish as much as we can. For every rcvd pkt * indicated up the stack, the head moves. For every such slot that we * replenish with an skb, the tail moves. If head catches up with the tail * we're OOM. When all's done, we consider where we're at: * * if no OOM: * - if we're out of quota, let the ints be disabled and poll scheduled. * - If we've processed everything, enable ints and cancel poll. * * If OOM: * - Start a timer. Cancel poll. Ints still disabled. * If the hardware's stopped, no point in restarting yet. * * Note that in general, whether we're OOM or not, we still try to * indicate everything recvd, up. * * Locking: * The interrupt doesnt touch the ring => Rx is lockless * */ static irqreturn_t athr_gmac_intr(ATHR_MAC_ISR_ARGS) { struct net_device *dev = (struct net_device *)dev_id; athr_gmac_t *mac = (athr_gmac_t *)ATHR_MAC_PRIV(dev); int isr, imr, handled = 0; isr = athr_gmac_get_isr(mac); imr = athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_INTR_MASK); athr_gmac_trc(isr,"isr"); athr_gmac_trc(imr,"imr"); assert(mac->mac_ifup); assert(isr == (isr & imr)); if (isr & (ATHR_GMAC_INTR_RX_OVF)) { handled = 1; if (is_ar7240() || is_ar9330()) athr_gmac_reg_wr(mac,ATHR_GMAC_CFG1,(athr_gmac_reg_rd(mac,ATHR_GMAC_CFG1)&0xfffffff3)); athr_gmac_intr_ack_rxovf(mac); } if (likely(isr & ATHR_GMAC_INTR_RX)) { handled = 1; if (mac_has_flag(mac,ATHR_RX_POLL)) { if (likely(athr_mac_rx_sched_prep(mac,dev))) { int status = athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_RX_STATUS); athr_gmac_intr_disable_recv(mac); assert((status & ATHR_GMAC_RX_STATUS_PKT_RCVD)); assert((status >> 16)); __athr_mac_rx_sched(mac,dev); } else { //printk(MODULE_NAME ": driver bug! interrupt while in poll\n"); //assert(0); athr_gmac_intr_disable_recv(mac); } } else { athr_gmac_intr_disable_recv(mac); ATH_SCHEDULE_TQUEUE(&mac->rxtq,mac); } } if (likely(isr & ATHR_GMAC_INTR_TX)) { handled = 1; athr_gmac_intr_ack_tx(mac); athr_gmac_intr_disable_tx(mac); ATH_SCHEDULE_TQUEUE(&mac->txreaptq,mac); } if (unlikely(isr & ATHR_GMAC_INTR_RX_BUS_ERROR)) { assert(0); handled = 1; athr_gmac_intr_ack_rxbe(mac); } if (unlikely(isr & ATHR_GMAC_INTR_TX_BUS_ERROR)) { assert(0); handled = 1; athr_gmac_intr_ack_txbe(mac); } if (!handled) { assert(0); printk(MODULE_NAME ": unhandled intr isr %#x\n", isr); } return IRQ_HANDLED; } static irqreturn_t athr_gmac_link_intr(ATHR_MAC_ISR_ARGS) { struct net_device *dev = (struct net_device *)dev_id; athr_gmac_t *mac = ATHR_MAC_PRIV(dev); mac->phy->link_isr(0); return IRQ_HANDLED; } static int ATHR_MAC_POLL() { ATHR_MAC_NAPI_MAC(); int work_done = 0, status = 0; int max_work = ATHR_MAC_GET_MAX_WORK(budget, dev); athr_gmac_rx_status_t ret; unsigned long flags; ATHR_GET_DEV(); assert(mac->mac_ifup); assert(mac_has_flag(mac,ATHR_RX_POLL)); ret = athr_gmac_rx_pkt(); ATHR_MAC_UPDATE_QUOTA_BUDGET(dev->quota, budget, work_done); /* * Fix ME: 2.6.31 kernel hits a corner case when budget == work done * It tries to queue another request assuming that more packets are ready * to be processed and if napi_complete is called by the driver it * results in panic. Might not work for 2.6.15 */ IF_RX_STATUS_DONE(ret,ATHR_GMAC_RX_STATUS_DONE,work_done,budget) { ATHR_NAPI_HANDLE_RX_DONE(); } else if (likely(ret == ATHR_GMAC_RX_STATUS_NOT_DONE)) { /* * We have work left */ status = 1; ATHR_NAPI_HANDLE_RX_NOT_DONE(); } else if (ret == ATHR_GMAC_RX_STATUS_OOM) { printk(MODULE_NAME ": oom..?\n"); /* * Start timer, stop polling, but do not enable rx interrupts. */ mod_timer(&mac->mac_oom_timer, jiffies+1); ATHR_MAC_RX_COMPLETE(mac); } return status; } void athr_remove_hdr(athr_gmac_t *mac, struct sk_buff *skb) { if (mac_has_flag(mac,ATHR_S26_HEADER)) { skb_pull(skb, 2); /* remove attansic header */ } else if (mac_has_flag(mac,ATHR_S16_HEADER) || mac_has_flag(mac,ATHR_S27_HEADER)) { int i; for (i = 13 ; i > 1; i --) { skb->data[i] = skb->data[i - ATHR_HEADER_LEN]; } skb_pull(skb,2); } } athr_receive_pkt() { ATHR_TASK_DEFS() athr_gmac_ring_t *r = &mac->mac_rxring; \ athr_gmac_desc_t *ds; athr_gmac_buffer_t *bp; struct sk_buff *skb; athr_gmac_rx_status_t ret = ATHR_GMAC_RX_STATUS_DONE; int head = r->ring_head, len, status, iquota = quota, more_pkts, rep; athr_gmac_trc(iquota,"iquota"); status = athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_RX_STATUS); process_pkts: athr_gmac_trc(status,"status"); assert(mac->mac_ifup); /* * Flush the DDR FIFOs for our gmac */ athrs_flush_ge(mac->mac_unit); assert(quota > 0); /* WCL */ if (mac->dma_check) { mac->dma_check = 0; } else { ATHR_NAPI_CHECK_STATUS(); } while(quota) { ds = &r->ring_desc[head]; athr_gmac_trc(head,"hd"); athr_gmac_trc(ds, "ds"); if (athr_gmac_rx_owned_by_dma(ds)) { assert(quota != iquota); /* WCL */ break; } athr_gmac_intr_ack_rx(mac); bp = &r->ring_buffer[head]; len = ds->pkt_size; skb = bp->buf_pkt; assert(skb); skb_put(skb, len - ETHERNET_FCS_SIZE); #ifdef CONFIG_ATHRS17_HNAT if(mac->mac_unit == 0) { aos_header_arp_in(skb); } #endif athr_gmac_rx_qos(mac,skb); athr_gmac_vlan_igmp(mac,skb); mac->net_rx_packets ++; mac->net_rx_bytes += skb->len; /* * also pulls the ether header */ skb->protocol = eth_type_trans(skb, dev); skb->dev = dev; bp->buf_pkt = NULL; dev->last_rx = jiffies; quota--; athr_nat_process_ingress_pkts(mac->mac_unit, skb, ds); netif_receive_skb(skb); athr_gmac_ring_incr(head); } assert(iquota != quota); r->ring_head = head; rep = athr_gmac_rx_replenish(mac); /* * let's see what changed while we were slogging. * ack Rx in the loop above is no flush version. It will get flushed now. */ status = athr_gmac_reg_rd(mac, ATHR_GMAC_DMA_RX_STATUS); more_pkts = (status & ATHR_GMAC_RX_STATUS_PKT_RCVD); athr_gmac_trc(more_pkts,"more_pkts"); if (!more_pkts) goto done; /* * more pkts arrived; if we have quota left, get rolling again */ if (quota) goto process_pkts; /* * out of quota */ ret = ATHR_GMAC_RX_STATUS_NOT_DONE; done: if (mac_has_flag(mac,ATHR_RX_POLL)) *work_done = (iquota - quota); if (mac_has_flag(mac,ATHR_RX_POLL) && unlikely(athr_gmac_rx_ring_full(mac))) return GMAC_RX_STATUS_OOM; /* * !oom; if stopped, restart h/w */ if (unlikely(status & ATHR_GMAC_RX_STATUS_OVF)) { mac->net_rx_over_errors ++; athr_gmac_intr_ack_rxovf(mac); athr_gmac_rx_start(mac); } if (mac_has_flag(mac,ATHR_RX_TASK)) athr_gmac_intr_enable_recv(mac); RX_RETURN(); } static struct sk_buff * athr_gmac_buffer_alloc(void) { struct sk_buff *skb; u_int32_t off; skb = dev_alloc_skb((ATHR_GMAC_RX_BUF_SIZE + 2) + L1_CACHE_BYTES - 1); if (unlikely(!skb)) return NULL; off = ((unsigned long) skb->data) % L1_CACHE_BYTES; if (off != 0) skb_reserve(skb, L1_CACHE_BYTES - off); skb_reserve(skb, (ATHR_GMAC_RX_RESERVE + 2)); /* * Return unaligned address for skb data * so that header processing will be aligned */ return skb; } static void athr_gmac_buffer_free(struct sk_buff *skb) { if (in_irq()) dev_kfree_skb_irq(skb); else dev_kfree_skb(skb); } /* * Head is the first slot with a valid buffer. Tail is the last slot * replenished. Tries to refill buffers from tail to head. */ static int athr_gmac_rx_replenish(athr_gmac_t *mac) { athr_gmac_ring_t *r = &mac->mac_rxring; int head = r->ring_head, tail = r->ring_tail, refilled = 0; athr_gmac_desc_t *ds; athr_gmac_buffer_t *bf; athr_gmac_trc(head,"hd"); athr_gmac_trc(tail,"tl"); while ( tail != head ) { bf = &r->ring_buffer[tail]; ds = &r->ring_desc[tail]; athr_gmac_trc(ds,"ds"); assert(!athr_gmac_rx_owned_by_dma(ds)); assert(!bf->buf_pkt); bf->buf_pkt = athr_gmac_buffer_alloc(); if (!bf->buf_pkt) { printk(MODULE_NAME ": outta skbs!\n"); break; } /* Invalidate chache should be chache aligned */ athr_mac_cache_inv((unsigned long)(bf->buf_pkt->data - 2), ATHR_GMAC_RX_BUF_SIZE); ds->pkt_start_addr = virt_to_phys(bf->buf_pkt->data); athr_gmac_rx_give_to_dma(ds); refilled ++; athr_gmac_ring_incr(tail); } /* * Flush descriptors */ wmb(); if (is_ar7240()||is_ar9330()) { athr_gmac_reg_wr(mac,ATHR_GMAC_CFG1,(athr_gmac_reg_rd(mac,ATHR_GMAC_CFG1)|0xc)); athr_gmac_rx_start(mac); } r->ring_tail = tail; athr_gmac_trc(refilled,"refilled"); return refilled; } /* * Reap from tail till the head or whenever we encounter an unxmited packet. */ static int athr_gmac_tx_reap(athr_gmac_t *mac,int ac) { athr_gmac_ring_t *r; athr_gmac_desc_t *ds; athr_gmac_buffer_t *bf; int head, tail, reaped = 0, i; r = &mac->mac_txring[ac]; head = r->ring_head; tail = r->ring_tail; athr_gmac_trc_new(head,"hd"); athr_gmac_trc_new(tail,"tl"); athrs_flush_ge(mac->mac_unit); while(tail != head) { ds = &r->ring_desc[tail]; athr_gmac_trc_new(ds,"ds"); if(athr_gmac_tx_owned_by_dma(ds)) break; bf = &r->ring_buffer[tail]; assert(bf->buf_pkt); athr_gmac_trc_new(bf->buf_lastds,"lastds"); if(athr_gmac_tx_owned_by_dma(bf->buf_lastds)) break; for(i = 0; i < bf->buf_nds; i++) { athr_gmac_intr_ack_tx(mac); athr_gmac_ring_incr(tail); } athr_gmac_buffer_free(bf->buf_pkt); bf->buf_pkt = NULL; reaped ++; } r->ring_tail = tail; if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS) && (athr_gmac_ndesc_unused(mac, r) >= mac->qstart_thresh) && netif_carrier_ok(mac->mac_dev)) { mac->tx_ac_bt &= ~(1 << ac); } if (netif_queue_stopped(mac->mac_dev) && netif_carrier_ok(mac->mac_dev)) { if ((athr_gmac_ndesc_unused(mac, r) >= mac->qstart_thresh)) { /* * Keep reaping till all the queues have enough descriptors. */ if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS) && (mac->tx_ac_bt != 0)) { athr_gmac_intr_enable_tx(mac); goto done; } netif_wake_queue(mac->mac_dev); } else { athr_gmac_intr_enable_tx(mac); } } done: return reaped; } static void athr_gmac_txreap_task(TQUEUE_ARG data) { int ac; athr_gmac_t *mac = (athr_gmac_t *)data; for(ac = 0; ac < mac->mac_noacs; ac++) athr_gmac_tx_reap(mac,ac); } /* * allocate and init rings, descriptors etc. */ static int athr_gmac_tx_alloc(athr_gmac_t *mac) { athr_gmac_ring_t *r ; athr_gmac_desc_t *ds; int ac, i, next; for(ac = 0;ac < mac->mac_noacs; ac++) { r = &mac->mac_txring[ac]; if (athr_gmac_ring_alloc(r, mac->num_tx_desc)) return 1; athr_gmac_trc(r->ring_desc,"ring_desc"); ds = r->ring_desc; for(i = 0; i < r->ring_nelem; i++ ) { athr_gmac_trc_new(ds,"tx alloc ds"); next = (i == (r->ring_nelem - 1)) ? 0 : (i + 1); ds[i].next_desc = athr_gmac_desc_dma_addr(r, &ds[next]); athr_gmac_tx_own(&ds[i]); } } return 0; } static int athr_gmac_rx_alloc(athr_gmac_t *mac) { athr_gmac_ring_t *r = &mac->mac_rxring; athr_gmac_desc_t *ds; int i, next, tail = r->ring_tail; athr_gmac_buffer_t *bf; if (athr_gmac_ring_alloc(r, mac->num_rx_desc)) return 1; athr_gmac_trc(r->ring_desc,"ring_desc"); ds = r->ring_desc; for(i = 0; i < r->ring_nelem; i++ ) { next = (i == (r->ring_nelem - 1)) ? 0 : (i + 1); ds[i].next_desc = athr_gmac_desc_dma_addr(r, &ds[next]); } for (i = 0; i < mac->num_rx_desc; i++) { bf = &r->ring_buffer[tail]; ds = &r->ring_desc[tail]; bf->buf_pkt = athr_gmac_buffer_alloc(); if (!bf->buf_pkt) goto error; athr_mac_cache_inv((unsigned long)(bf->buf_pkt->data - 2), ATHR_GMAC_RX_BUF_SIZE); ds->pkt_start_addr = virt_to_phys(bf->buf_pkt->data); ds->res1 = 0; ds->res2 = 0; ds->ftpp_override = 0; ds->res3 = 0; ds->more = 0; athr_gmac_rx_give_to_dma(ds); athr_gmac_ring_incr(tail); } return 0; error: printk(MODULE_NAME ": unable to allocate rx\n"); athr_gmac_rx_free(mac); return 1; } static void athr_gmac_tx_free(athr_gmac_t *mac) { int ac; for(ac = 0;ac < mac->mac_noacs; ac++) { athr_gmac_ring_release(mac, &mac->mac_txring[ac]); athr_gmac_ring_free(&mac->mac_txring[ac]); } } static void athr_gmac_rx_free(athr_gmac_t *mac) { athr_gmac_ring_release(mac, &mac->mac_rxring); athr_gmac_ring_free(&mac->mac_rxring); } static int athr_gmac_ring_alloc(athr_gmac_ring_t *r, int count) { int desc_alloc_size, buf_alloc_size; desc_alloc_size = sizeof(athr_gmac_desc_t) * count; buf_alloc_size = sizeof(athr_gmac_buffer_t) * count; memset(r, 0, sizeof(athr_gmac_ring_t)); r->ring_buffer = (athr_gmac_buffer_t *)kmalloc(buf_alloc_size, GFP_KERNEL); printk("%s Allocated %d at 0x%lx\n",__func__,buf_alloc_size,(unsigned long) r->ring_buffer); if (!r->ring_buffer) { printk(MODULE_NAME ": unable to allocate buffers\n"); return 1; } r->ring_desc = (athr_gmac_desc_t *)dma_alloc_coherent(NULL, desc_alloc_size, &r->ring_desc_dma, GFP_DMA); if (! r->ring_desc) { printk(MODULE_NAME ": unable to allocate coherent descs\n"); kfree(r->ring_buffer); printk("%s Freeing at 0x%lx\n",__func__,(unsigned long) r->ring_buffer); return 1; } memset(r->ring_buffer, 0, buf_alloc_size); memset(r->ring_desc, 0, desc_alloc_size); r->ring_nelem = count; return 0; } static void athr_gmac_ring_release(athr_gmac_t *mac, athr_gmac_ring_t *r) { int i; for(i = 0; i < r->ring_nelem; i++) if (r->ring_buffer[i].buf_pkt) athr_gmac_buffer_free(r->ring_buffer[i].buf_pkt); } static void athr_gmac_ring_free(athr_gmac_ring_t *r) { dma_free_coherent(NULL, sizeof(athr_gmac_desc_t)*r->ring_nelem, r->ring_desc, r->ring_desc_dma); kfree(r->ring_buffer); printk("%s Freeing at 0x%lx\n",__func__,(unsigned long) r->ring_buffer); } /* * Error timers */ static void athr_gmac_oom_timer(unsigned long data) { athr_gmac_t *mac = (athr_gmac_t *)data; int val; athr_gmac_trc(data,"data"); athr_gmac_rx_replenish(mac); if (athr_gmac_rx_ring_full(mac)) { val = mod_timer(&mac->mac_oom_timer, jiffies+1); assert(!val); } else athr_mac_rx_sched(mac); } static void athr_gmac_tx_timeout(struct net_device *dev) { athr_gmac_t *mac = (athr_gmac_t *)ATHR_MAC_PRIV(dev); athr_gmac_trc(dev,"dev"); printk("%s\n",__func__); /* * Do the reset outside of interrupt context */ schedule_work(&mac->mac_tx_timeout); } static void athr_gmac_tx_timeout_task(ATHR_MAC_TASK_ARG) { ATHR_MAC_TASK_MAC(); athr_gmac_trc(mac,"mac"); if (mac->ops->check_dma_st) mac->ops->check_dma_st(mac,0); } static void athr_gmac_get_default_macaddr(athr_gmac_t *mac, u8 *mac_addr) { u8 *eep_mac_addr = NULL; /* Use MAC address stored in Flash */ if (!is_emu() && !is_ar9330_emu()) { athr_get_gmac_addr(mac,&eep_mac_addr); printk(MODULE_NAME ": Mac address for unit %d:%p\n",mac->mac_unit,eep_mac_addr); printk(MODULE_NAME ": %02x:%02x:%02x:%02x:%02x:%02x \n", eep_mac_addr[0],eep_mac_addr[1],eep_mac_addr[2], eep_mac_addr[3],eep_mac_addr[4],eep_mac_addr[5]); /* ** Check for a valid manufacturer prefix. If not, then use the defaults */ if(eep_mac_addr[0] == 0x00 && eep_mac_addr[1] == 0x03 && eep_mac_addr[2] == 0x7f) { memcpy(mac_addr, eep_mac_addr, 6); return ; } } /* Use Default address at top of range */ mac_addr[0] = 0x00; mac_addr[1] = 0x03; mac_addr[2] = 0x7F; mac_addr[3] = 0xFF; mac_addr[4] = 0xFF; mac_addr[5] = 0xFF - mac->mac_unit; } static int athr_gmac_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { return (athrs_do_ioctl(dev,ifr,cmd)); } static struct net_device_stats *athr_gmac_get_stats(struct net_device *dev) { athr_gmac_t *mac = ATHR_MAC_PRIV(dev); int carrier = netif_carrier_ok(dev); if (mac->mac_speed == ATHR_PHY_SPEED_UNKNOWN) { return &mac->mac_net_stats; } /* * MIB registers reads will fail if link is lost while resetting PHY. */ if (carrier && !phy_in_reset) { mac->mac_net_stats.rx_packets = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_PKT_CNTR); mac->mac_net_stats.tx_packets = athr_gmac_reg_rd(mac,ATHR_GMAC_TX_PKT_CNTR); mac->mac_net_stats.rx_bytes = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_BYTES_CNTR); mac->mac_net_stats.tx_bytes = athr_gmac_reg_rd(mac,ATHR_GMAC_TX_BYTES_CNTR); mac->mac_net_stats.tx_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_TX_CRC_ERR_CNTR); mac->mac_net_stats.rx_dropped = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_DROP_CNTR); mac->mac_net_stats.tx_dropped = athr_gmac_reg_rd(mac,ATHR_GMAC_TX_DROP_CNTR); mac->mac_net_stats.collisions = athr_gmac_reg_rd(mac,ATHR_GMAC_TOTAL_COL_CNTR); /* detailed rx_errors: */ mac->mac_net_stats.rx_length_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_LEN_ERR_CNTR); mac->mac_net_stats.rx_over_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_OVL_ERR_CNTR); mac->mac_net_stats.rx_crc_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_CRC_ERR_CNTR); mac->mac_net_stats.rx_frame_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_FRM_ERR_CNTR); mac->mac_net_stats.rx_errors = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_CODE_ERR_CNTR) + athr_gmac_reg_rd(mac,ATHR_GMAC_RX_CRS_ERR_CNTR) + mac->mac_net_stats.rx_length_errors + mac->mac_net_stats.rx_over_errors + mac->mac_net_stats.rx_crc_errors + mac->mac_net_stats.rx_frame_errors; mac->mac_net_stats.multicast = athr_gmac_reg_rd(mac,ATHR_GMAC_RX_MULT_CNTR) + athr_gmac_reg_rd(mac,ATHR_GMAC_TX_MULT_CNTR); if (mac_has_flag(mac,WAN_QOS_SOFT_CLASS)) mac->mac_net_stats.tx_dropped += mac->tx_ac_drops; } return &mac->mac_net_stats; } static void athr_gmac_vet_tx_len_per_pkt(unsigned int *len) { unsigned int l; /* make it into words */ l = *len & ~3; /* * Not too small */ if (l < ATHR_GMAC_TX_MIN_DS_LEN) { l = ATHR_GMAC_TX_MIN_DS_LEN; } else { /* Avoid len where we know we will deadlock, that * is the range between fif_len/2 and the MTU size */ if (l > ATHR_GMAC_TX_FIFO_LEN/2) { if (l < ATHR_GMAC_TX_MTU_LEN) l = ATHR_GMAC_TX_MTU_LEN; else if (l > ATHR_GMAC_TX_MAX_DS_LEN) l = ATHR_GMAC_TX_MAX_DS_LEN; *len = l; } } } /* * All allocations (except irq and rings). */ static int __init athr_gmac_init(void) { int i,st; struct net_device *dev; athr_gmac_t *mac; uint32_t mask; /* * tx_len_per_ds is the number of bytes per data transfer in word increments. * * If the value is 0 than we default the value to a known good value based * on benchmarks. Otherwise we use the value specified - within some * cosntraints of course. * * Tested working values are 256, 512, 768, 1024 & 1536. * * A value of 256 worked best in all benchmarks. That is the default. * */ /* Tested 256, 512, 768, 1024, 1536 OK, 1152 and 1280 failed*/ if (0 == tx_len_per_ds) tx_len_per_ds = CONFIG_ATHR_GMAC_LEN_PER_TX_DS; athr_gmac_vet_tx_len_per_pkt( &tx_len_per_ds); printk(MODULE_NAME ": Length per segment %d\n", tx_len_per_ds); /* * Compute the number of descriptors for an MTU */ tx_max_desc_per_ds_pkt =1; /* * Let hydra know how much to put into the fifo in words (for tx) */ if (0 == fifo_3) fifo_3 = 0x000001ff | ((ATHR_GMAC_TX_FIFO_LEN-tx_len_per_ds)/4)<<16; printk(MODULE_NAME ": fifo cfg 3 %08x\n", fifo_3); /* ** Do the rest of the initializations */ for(i = 0; i < ATHR_GMAC_NMACS; i++) { dev = alloc_etherdev(ATHR_MAC_ETHERDEV_SZ); if (!dev) { printk(MODULE_NAME ": unable to allocate mac\n"); return 1; } ATHR_MAC_NETPRIV(mac,dev); memset(mac, 0, sizeof(athr_gmac_t)); mac->mac_dev = dev; mac->mac_unit = i; mac->mac_base = athr_gmac_base(i); mac->mac_irq = athr_gmac_irq(i); mac->mac_noacs = 1; mac->num_tx_desc = athr_tx_desc_num[i]; mac->num_rx_desc = athr_rx_desc_num[i]; mac->reap_thresh = athr_tx_desc_num[i] / 2; mac->qstart_thresh = 4 * tx_max_desc_per_ds_pkt; mac->mac_speed = ATHR_PHY_SPEED_UNKNOWN; athr_gmacs[i] = mac; athr_gmac_attach(mac); if(!mac->ops) { printk(MODULE_NAME "ERROR: No MAC found !!!\n"); assert(0); return 1; } mac->ops->check_link = athr_gmac_check_link; mac->ops->set_caps(mac); if (mac_has_flag(mac,ETH_SWONLY_MODE)) { if (mac->mac_unit == 0) continue; } spin_lock_init(&mac->mac_lock); /* * out of memory timer */ init_timer(&mac->mac_oom_timer); mac->mac_oom_timer.data = (unsigned long)mac; mac->mac_oom_timer.function = (void *)athr_gmac_oom_timer; ATHR_MAC_INIT_WORK(mac, athr_gmac_tx_timeout_task); /* * watchdog task */ ATHR_MAC_SET_DEV_NET_OPS(dev, mac, athr_gmac_get_stats, athr_gmac_open, athr_gmac_stop, athr_gmac_hard_start, athr_gmac_do_ioctl, athr_gmac_poll, athr_gmac_tx_timeout, ATHR_GMAC_NAPI_WEIGHT); ATH_INIT_RX_TASK(); ATH_INIT_TX_TASK(); if (mac_has_flag(mac,ATHR_RX_TASK)) printk(MODULE_NAME ": RX TASKLET - Pkts per Intr:%d\n",CONFIG_ATHR_RX_PKTS_CNT); athr_gmac_get_default_macaddr(mac, dev->dev_addr); if (mac->mac_unit == 0) { athr_set_nat_wan_mac(dev->dev_addr); } if (register_netdev(dev)) { printk(MODULE_NAME ": register netdev failed\n"); goto failed; } netif_carrier_off(dev); athr_gmac_reg_rmw_set(mac, ATHR_GMAC_CFG1, ATHR_GMAC_CFG1_SOFT_RST | ATHR_GMAC_CFG1_RX_RST | ATHR_GMAC_CFG1_TX_RST); udelay(20); mask = athr_gmac_reset_mask(mac->mac_unit); mask |= (ATHR_RESET_GE0_PHY | ATHR_RESET_GE1_PHY); if (is_ar7241() || is_ar7242() || is_ar934x()) mask |= ATHR_RESET_GE0_MDIO | ATHR_RESET_GE1_MDIO; /* * put into reset, hold, pull out. */ athr_reg_rmw_set(ATHR_RESET, mask); mdelay(100); athr_reg_rmw_clear(ATHR_RESET, mask); mdelay(100); athr_gmac_phy_attach(mac,mac->mac_unit); athr_register_qos(mac); athr_register_vlan_igmp(mac); if(!mac->phy) printk("MAC:%d Warning: Phy not found!!!\n",mac->mac_unit); athr_gmac_trc_init(); /* * Initialize timers. */ if (mac_has_flag(mac,CHECK_DMA_STATUS)) { mac->dma_chk_ts = jiffies; } if (mac_has_flag(mac,ETH_SOFT_LED)) { mac->led_blink_ts = jiffies; } if (mac_has_flag(mac,ETH_LINK_POLL)) { mac->link_ts = jiffies; } printk(MODULE_NAME ": Max segments per packet : %d\n", tx_max_desc_per_ds_pkt); printk(MODULE_NAME ": Max tx descriptor count : %d\n", mac->num_tx_desc); printk(MODULE_NAME ": Max rx descriptor count : %d\n", mac->num_rx_desc); printk(MODULE_NAME ": Mac capability flags : %X\n", mac->mac_flags); } /* * Enable link interrupts for PHYs */ if (mac_has_flag(mac,ETH_LINK_INTERRUPT)) { dev = mac->mac_dev; if (is_ar934x() && is_s16()) { st = request_irq(ATHR_GPIO_IRQn(4), athr_gmac_link_intr, ATHR_MAC_IRQF_DISABLED, "gmac s16 link intr", dev); } else { st = request_irq(ATHR_IRQ_ENET_LINK, athr_gmac_link_intr, ATHR_MAC_IRQF_DISABLED, "gmac link intr", dev); } if (st < 0) { printk(MODULE_NAME ": request irq %d failed %d\n" , ATHR_IRQ_ENET_LINK, st); goto failed; } } athr_reg_net_notifcations(); // Register Push button notification handler if (is_push_button() && athr_gmacs[0]) { mac = athr_gmacs[0]; dev = mac->mac_dev; register_simple_config_callback (dev->name, (void *) pushbutton_intr, (void *) dev, (void *)&mac->push_dur); } return 0; failed: for(i = 0; i < ATHR_GMAC_NMACS; i++) { if (!athr_gmacs[i]) continue; if (athr_gmacs[i]->mac_dev) { if (mac_has_flag(athr_gmacs[i],ETH_LINK_INTERRUPT) && (i == ATHR_GMAC_NMACS)) free_irq(ATHR_IRQ_ENET_LINK, athr_gmacs[i]->mac_dev); printk("%s Freeing at 0x%lx\n",__func__,(unsigned long) athr_gmacs[i]); free_netdev(athr_gmacs[i]->mac_dev); } } return 1; } static void __exit athr_gmac_cleanup(void) { int i; for(i = 0; i < ATHR_GMAC_NMACS; i++) { if (is_push_button() && (i == 0)) { unregister_simple_config_callback(athr_gmacs[0]->mac_dev->name); } if (mac_has_flag(athr_gmacs[1],ETH_SWONLY_MODE) && i == 0) { continue; } kfree(athr_gmacs[i]); if (mac_has_flag(athr_gmacs[i],ETH_LINK_INTERRUPT) && ((i+1) == ATHR_GMAC_NMACS)) free_irq(ATHR_IRQ_ENET_LINK, athr_gmacs[i]->mac_dev); athr_gmac_timer_del(athr_gmacs[i]); unregister_netdev(athr_gmacs[i]->mac_dev); printk("%s Freeing at 0x%lx\n",__func__,(unsigned long) athr_gmacs[i]); free_netdev(athr_gmacs[i]->mac_dev); athr_gmacs[i] = NULL; } athr_unreg_net_notifcations(); athr_nat_proc_remove(); printk(MODULE_NAME ": cleanup done\n"); } module_init(athr_gmac_init); module_exit(athr_gmac_cleanup);
gpl-2.0
fyu1/test
drivers/scsi/scsi_debug.c
160139
/* * vvvvvvvvvvvvvvvvvvvvvvv Original vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv * Copyright (C) 1992 Eric Youngdale * Simulate a host adapter with 2 disks attached. Do a lot of checking * to make sure that we are not getting blocks mixed up, and PANIC if * anything out of the ordinary is seen. * ^^^^^^^^^^^^^^^^^^^^^^^ Original ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * * This version is more generic, simulating a variable number of disk * (or disk like devices) sharing a common amount of RAM. To be more * realistic, the simulated devices have the transport attributes of * SAS disks. * * * For documentation see http://sg.danny.cz/sg/sdebug26.html * * D. Gilbert (dpg) work for Magneto-Optical device test [20010421] * dpg: work for devfs large number of disks [20010809] * forked for lk 2.5 series [20011216, 20020101] * use vmalloc() more inquiry+mode_sense [20020302] * add timers for delayed responses [20020721] * Patrick Mansfield <[email protected]> max_luns+scsi_level [20021031] * Mike Anderson <[email protected]> sysfs work [20021118] * dpg: change style of boot options to "scsi_debug.num_tgts=2" and * module options to "modprobe scsi_debug num_tgts=2" [20021221] */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/timer.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/string.h> #include <linux/genhd.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/proc_fs.h> #include <linux/vmalloc.h> #include <linux/moduleparam.h> #include <linux/scatterlist.h> #include <linux/blkdev.h> #include <linux/crc-t10dif.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/atomic.h> #include <linux/hrtimer.h> #include <net/checksum.h> #include <asm/unaligned.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h> #include <scsi/scsi_host.h> #include <scsi/scsicam.h> #include <scsi/scsi_eh.h> #include <scsi/scsi_tcq.h> #include <scsi/scsi_dbg.h> #include "sd.h" #include "scsi_logging.h" #define SCSI_DEBUG_VERSION "1.85" static const char *scsi_debug_version_date = "20141022"; #define MY_NAME "scsi_debug" /* Additional Sense Code (ASC) */ #define NO_ADDITIONAL_SENSE 0x0 #define LOGICAL_UNIT_NOT_READY 0x4 #define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 #define UNRECOVERED_READ_ERR 0x11 #define PARAMETER_LIST_LENGTH_ERR 0x1a #define INVALID_OPCODE 0x20 #define LBA_OUT_OF_RANGE 0x21 #define INVALID_FIELD_IN_CDB 0x24 #define INVALID_FIELD_IN_PARAM_LIST 0x26 #define UA_RESET_ASC 0x29 #define UA_CHANGED_ASC 0x2a #define INSUFF_RES_ASC 0x55 #define INSUFF_RES_ASCQ 0x3 #define POWER_ON_RESET_ASCQ 0x0 #define BUS_RESET_ASCQ 0x2 /* scsi bus reset occurred */ #define MODE_CHANGED_ASCQ 0x1 /* mode parameters changed */ #define CAPACITY_CHANGED_ASCQ 0x9 #define SAVING_PARAMS_UNSUP 0x39 #define TRANSPORT_PROBLEM 0x4b #define THRESHOLD_EXCEEDED 0x5d #define LOW_POWER_COND_ON 0x5e #define MISCOMPARE_VERIFY_ASC 0x1d /* Additional Sense Code Qualifier (ASCQ) */ #define ACK_NAK_TO 0x3 /* Default values for driver parameters */ #define DEF_NUM_HOST 1 #define DEF_NUM_TGTS 1 #define DEF_MAX_LUNS 1 /* With these defaults, this driver will make 1 host with 1 target * (id 0) containing 1 logical unit (lun 0). That is 1 device. */ #define DEF_ATO 1 #define DEF_DELAY 1 /* if > 0 unit is a jiffy */ #define DEF_DEV_SIZE_MB 8 #define DEF_DIF 0 #define DEF_DIX 0 #define DEF_D_SENSE 0 #define DEF_EVERY_NTH 0 #define DEF_FAKE_RW 0 #define DEF_GUARD 0 #define DEF_HOST_LOCK 0 #define DEF_LBPU 0 #define DEF_LBPWS 0 #define DEF_LBPWS10 0 #define DEF_LBPRZ 1 #define DEF_LOWEST_ALIGNED 0 #define DEF_NDELAY 0 /* if > 0 unit is a nanosecond */ #define DEF_NO_LUN_0 0 #define DEF_NUM_PARTS 0 #define DEF_OPTS 0 #define DEF_OPT_BLKS 64 #define DEF_PHYSBLK_EXP 0 #define DEF_PTYPE 0 #define DEF_REMOVABLE false #define DEF_SCSI_LEVEL 6 /* INQUIRY, byte2 [6->SPC-4] */ #define DEF_SECTOR_SIZE 512 #define DEF_TAGGED_QUEUING 0 /* 0 | MSG_SIMPLE_TAG | MSG_ORDERED_TAG */ #define DEF_UNMAP_ALIGNMENT 0 #define DEF_UNMAP_GRANULARITY 1 #define DEF_UNMAP_MAX_BLOCKS 0xFFFFFFFF #define DEF_UNMAP_MAX_DESC 256 #define DEF_VIRTUAL_GB 0 #define DEF_VPD_USE_HOSTNO 1 #define DEF_WRITESAME_LENGTH 0xFFFF #define DEF_STRICT 0 #define DELAY_OVERRIDDEN -9999 /* bit mask values for scsi_debug_opts */ #define SCSI_DEBUG_OPT_NOISE 1 #define SCSI_DEBUG_OPT_MEDIUM_ERR 2 #define SCSI_DEBUG_OPT_TIMEOUT 4 #define SCSI_DEBUG_OPT_RECOVERED_ERR 8 #define SCSI_DEBUG_OPT_TRANSPORT_ERR 16 #define SCSI_DEBUG_OPT_DIF_ERR 32 #define SCSI_DEBUG_OPT_DIX_ERR 64 #define SCSI_DEBUG_OPT_MAC_TIMEOUT 128 #define SCSI_DEBUG_OPT_SHORT_TRANSFER 0x100 #define SCSI_DEBUG_OPT_Q_NOISE 0x200 #define SCSI_DEBUG_OPT_ALL_TSF 0x400 #define SCSI_DEBUG_OPT_RARE_TSF 0x800 #define SCSI_DEBUG_OPT_N_WCE 0x1000 #define SCSI_DEBUG_OPT_RESET_NOISE 0x2000 #define SCSI_DEBUG_OPT_NO_CDB_NOISE 0x4000 #define SCSI_DEBUG_OPT_ALL_NOISE (0x1 | 0x200 | 0x2000) /* When "every_nth" > 0 then modulo "every_nth" commands: * - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set * - a RECOVERED_ERROR is simulated on successful read and write * commands if SCSI_DEBUG_OPT_RECOVERED_ERR is set. * - a TRANSPORT_ERROR is simulated on successful read and write * commands if SCSI_DEBUG_OPT_TRANSPORT_ERR is set. * * When "every_nth" < 0 then after "- every_nth" commands: * - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set * - a RECOVERED_ERROR is simulated on successful read and write * commands if SCSI_DEBUG_OPT_RECOVERED_ERR is set. * - a TRANSPORT_ERROR is simulated on successful read and write * commands if SCSI_DEBUG_OPT_TRANSPORT_ERR is set. * This will continue until some other action occurs (e.g. the user * writing a new value (other than -1 or 1) to every_nth via sysfs). */ /* As indicated in SAM-5 and SPC-4 Unit Attentions (UAs)are returned in * priority order. In the subset implemented here lower numbers have higher * priority. The UA numbers should be a sequence starting from 0 with * SDEBUG_NUM_UAS being 1 higher than the highest numbered UA. */ #define SDEBUG_UA_POR 0 /* Power on, reset, or bus device reset */ #define SDEBUG_UA_BUS_RESET 1 #define SDEBUG_UA_MODE_CHANGED 2 #define SDEBUG_UA_CAPACITY_CHANGED 3 #define SDEBUG_NUM_UAS 4 /* for check_readiness() */ #define UAS_ONLY 1 /* check for UAs only */ #define UAS_TUR 0 /* if no UAs then check if media access possible */ /* when 1==SCSI_DEBUG_OPT_MEDIUM_ERR, a medium error is simulated at this * sector on read commands: */ #define OPT_MEDIUM_ERR_ADDR 0x1234 /* that's sector 4660 in decimal */ #define OPT_MEDIUM_ERR_NUM 10 /* number of consecutive medium errs */ /* If REPORT LUNS has luns >= 256 it can choose "flat space" (value 1) * or "peripheral device" addressing (value 0) */ #define SAM2_LUN_ADDRESS_METHOD 0 #define SAM2_WLUN_REPORT_LUNS 0xc101 /* SCSI_DEBUG_CANQUEUE is the maximum number of commands that can be queued * (for response) at one time. Can be reduced by max_queue option. Command * responses are not queued when delay=0 and ndelay=0. The per-device * DEF_CMD_PER_LUN can be changed via sysfs: * /sys/class/scsi_device/<h:c:t:l>/device/queue_depth but cannot exceed * SCSI_DEBUG_CANQUEUE. */ #define SCSI_DEBUG_CANQUEUE_WORDS 9 /* a WORD is bits in a long */ #define SCSI_DEBUG_CANQUEUE (SCSI_DEBUG_CANQUEUE_WORDS * BITS_PER_LONG) #define DEF_CMD_PER_LUN 255 #if DEF_CMD_PER_LUN > SCSI_DEBUG_CANQUEUE #warning "Expect DEF_CMD_PER_LUN <= SCSI_DEBUG_CANQUEUE" #endif /* SCSI opcodes (first byte of cdb) mapped onto these indexes */ enum sdeb_opcode_index { SDEB_I_INVALID_OPCODE = 0, SDEB_I_INQUIRY = 1, SDEB_I_REPORT_LUNS = 2, SDEB_I_REQUEST_SENSE = 3, SDEB_I_TEST_UNIT_READY = 4, SDEB_I_MODE_SENSE = 5, /* 6, 10 */ SDEB_I_MODE_SELECT = 6, /* 6, 10 */ SDEB_I_LOG_SENSE = 7, SDEB_I_READ_CAPACITY = 8, /* 10; 16 is in SA_IN(16) */ SDEB_I_READ = 9, /* 6, 10, 12, 16 */ SDEB_I_WRITE = 10, /* 6, 10, 12, 16 */ SDEB_I_START_STOP = 11, SDEB_I_SERV_ACT_IN = 12, /* 12, 16 */ SDEB_I_SERV_ACT_OUT = 13, /* 12, 16 */ SDEB_I_MAINT_IN = 14, SDEB_I_MAINT_OUT = 15, SDEB_I_VERIFY = 16, /* 10 only */ SDEB_I_VARIABLE_LEN = 17, SDEB_I_RESERVE = 18, /* 6, 10 */ SDEB_I_RELEASE = 19, /* 6, 10 */ SDEB_I_ALLOW_REMOVAL = 20, /* PREVENT ALLOW MEDIUM REMOVAL */ SDEB_I_REZERO_UNIT = 21, /* REWIND in SSC */ SDEB_I_ATA_PT = 22, /* 12, 16 */ SDEB_I_SEND_DIAG = 23, SDEB_I_UNMAP = 24, SDEB_I_XDWRITEREAD = 25, /* 10 only */ SDEB_I_WRITE_BUFFER = 26, SDEB_I_WRITE_SAME = 27, /* 10, 16 */ SDEB_I_SYNC_CACHE = 28, /* 10 only */ SDEB_I_COMP_WRITE = 29, SDEB_I_LAST_ELEMENT = 30, /* keep this last */ }; static const unsigned char opcode_ind_arr[256] = { /* 0x0; 0x0->0x1f: 6 byte cdbs */ SDEB_I_TEST_UNIT_READY, SDEB_I_REZERO_UNIT, 0, SDEB_I_REQUEST_SENSE, 0, 0, 0, 0, SDEB_I_READ, 0, SDEB_I_WRITE, 0, 0, 0, 0, 0, 0, 0, SDEB_I_INQUIRY, 0, 0, SDEB_I_MODE_SELECT, SDEB_I_RESERVE, SDEB_I_RELEASE, 0, 0, SDEB_I_MODE_SENSE, SDEB_I_START_STOP, 0, SDEB_I_SEND_DIAG, SDEB_I_ALLOW_REMOVAL, 0, /* 0x20; 0x20->0x3f: 10 byte cdbs */ 0, 0, 0, 0, 0, SDEB_I_READ_CAPACITY, 0, 0, SDEB_I_READ, 0, SDEB_I_WRITE, 0, 0, 0, 0, SDEB_I_VERIFY, 0, 0, 0, 0, 0, SDEB_I_SYNC_CACHE, 0, 0, 0, 0, 0, SDEB_I_WRITE_BUFFER, 0, 0, 0, 0, /* 0x40; 0x40->0x5f: 10 byte cdbs */ 0, SDEB_I_WRITE_SAME, SDEB_I_UNMAP, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDEB_I_LOG_SENSE, 0, 0, 0, 0, 0, SDEB_I_XDWRITEREAD, 0, SDEB_I_MODE_SELECT, SDEB_I_RESERVE, SDEB_I_RELEASE, 0, 0, SDEB_I_MODE_SENSE, 0, 0, 0, 0, 0, /* 0x60; 0x60->0x7d are reserved */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDEB_I_VARIABLE_LEN, /* 0x80; 0x80->0x9f: 16 byte cdbs */ 0, 0, 0, 0, 0, SDEB_I_ATA_PT, 0, 0, SDEB_I_READ, SDEB_I_COMP_WRITE, SDEB_I_WRITE, 0, 0, 0, 0, 0, 0, 0, 0, SDEB_I_WRITE_SAME, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDEB_I_SERV_ACT_IN, SDEB_I_SERV_ACT_OUT, /* 0xa0; 0xa0->0xbf: 12 byte cdbs */ SDEB_I_REPORT_LUNS, SDEB_I_ATA_PT, 0, SDEB_I_MAINT_IN, SDEB_I_MAINT_OUT, 0, 0, 0, SDEB_I_READ, SDEB_I_SERV_ACT_OUT, SDEB_I_WRITE, SDEB_I_SERV_ACT_IN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0; 0xc0->0xff: vendor specific */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #define F_D_IN 1 #define F_D_OUT 2 #define F_D_OUT_MAYBE 4 /* WRITE SAME, NDOB bit */ #define F_D_UNKN 8 #define F_RL_WLUN_OK 0x10 #define F_SKIP_UA 0x20 #define F_DELAY_OVERR 0x40 #define F_SA_LOW 0x80 /* cdb byte 1, bits 4 to 0 */ #define F_SA_HIGH 0x100 /* as used by variable length cdbs */ #define F_INV_OP 0x200 #define F_FAKE_RW 0x400 #define F_M_ACCESS 0x800 /* media access */ #define FF_RESPOND (F_RL_WLUN_OK | F_SKIP_UA | F_DELAY_OVERR) #define FF_DIRECT_IO (F_M_ACCESS | F_FAKE_RW) #define FF_SA (F_SA_HIGH | F_SA_LOW) struct sdebug_dev_info; static int resp_inquiry(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_report_luns(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_requests(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_mode_sense(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_mode_select(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_log_sense(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_readcap(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_read_dt0(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_write_dt0(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_start_stop(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_readcap16(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_get_lba_status(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_report_tgtpgs(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_unmap(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_rsup_opcodes(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_rsup_tmfs(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_write_same_10(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_write_same_16(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_xdwriteread_10(struct scsi_cmnd *, struct sdebug_dev_info *); static int resp_comp_write(struct scsi_cmnd *, struct sdebug_dev_info *); struct opcode_info_t { u8 num_attached; /* 0 if this is it (i.e. a leaf); use 0xff * for terminating element */ u8 opcode; /* if num_attached > 0, preferred */ u16 sa; /* service action */ u32 flags; /* OR-ed set of SDEB_F_* */ int (*pfp)(struct scsi_cmnd *, struct sdebug_dev_info *); const struct opcode_info_t *arrp; /* num_attached elements or NULL */ u8 len_mask[16]; /* len=len_mask[0], then mask for cdb[1]... */ /* ignore cdb bytes after position 15 */ }; static const struct opcode_info_t msense_iarr[1] = { {0, 0x1a, 0, F_D_IN, NULL, NULL, {6, 0xe8, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; static const struct opcode_info_t mselect_iarr[1] = { {0, 0x15, 0, F_D_OUT, NULL, NULL, {6, 0xf1, 0, 0, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; static const struct opcode_info_t read_iarr[3] = { {0, 0x28, 0, F_D_IN | FF_DIRECT_IO, resp_read_dt0, NULL,/* READ(10) */ {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x8, 0, F_D_IN | FF_DIRECT_IO, resp_read_dt0, NULL, /* READ(6) */ {6, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0xa8, 0, F_D_IN | FF_DIRECT_IO, resp_read_dt0, NULL,/* READ(12) */ {12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xc7, 0, 0, 0, 0} }, }; static const struct opcode_info_t write_iarr[3] = { {0, 0x2a, 0, F_D_OUT | FF_DIRECT_IO, resp_write_dt0, NULL, /* 10 */ {10, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0xa, 0, F_D_OUT | FF_DIRECT_IO, resp_write_dt0, NULL, /* 6 */ {6, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0xaa, 0, F_D_OUT | FF_DIRECT_IO, resp_write_dt0, NULL, /* 12 */ {12, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xc7, 0, 0, 0, 0} }, }; static const struct opcode_info_t sa_in_iarr[1] = { {0, 0x9e, 0x12, F_SA_LOW | F_D_IN, resp_get_lba_status, NULL, {16, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0xc7} }, }; static const struct opcode_info_t vl_iarr[1] = { /* VARIABLE LENGTH */ {0, 0x7f, 0xb, F_SA_HIGH | F_D_OUT | FF_DIRECT_IO, resp_write_dt0, NULL, {32, 0xc7, 0, 0, 0, 0, 0x1f, 0x18, 0x0, 0xb, 0xfa, 0, 0xff, 0xff, 0xff, 0xff} }, /* WRITE(32) */ }; static const struct opcode_info_t maint_in_iarr[2] = { {0, 0xa3, 0xc, F_SA_LOW | F_D_IN, resp_rsup_opcodes, NULL, {12, 0xc, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0xc7, 0, 0, 0, 0} }, {0, 0xa3, 0xd, F_SA_LOW | F_D_IN, resp_rsup_tmfs, NULL, {12, 0xd, 0x80, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0xc7, 0, 0, 0, 0} }, }; static const struct opcode_info_t write_same_iarr[1] = { {0, 0x93, 0, F_D_OUT_MAYBE | FF_DIRECT_IO, resp_write_same_16, NULL, {16, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xc7} }, }; static const struct opcode_info_t reserve_iarr[1] = { {0, 0x16, 0, F_D_OUT, NULL, NULL, /* RESERVE(6) */ {6, 0x1f, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; static const struct opcode_info_t release_iarr[1] = { {0, 0x17, 0, F_D_OUT, NULL, NULL, /* RELEASE(6) */ {6, 0x1f, 0xff, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; /* This array is accessed via SDEB_I_* values. Make sure all are mapped, * plus the terminating elements for logic that scans this table such as * REPORT SUPPORTED OPERATION CODES. */ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEMENT + 1] = { /* 0 */ {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0x12, 0, FF_RESPOND | F_D_IN, resp_inquiry, NULL, {6, 0xe3, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0xa0, 0, FF_RESPOND | F_D_IN, resp_report_luns, NULL, {12, 0xe3, 0xff, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0xc7, 0, 0, 0, 0} }, {0, 0x3, 0, FF_RESPOND | F_D_IN, resp_requests, NULL, {6, 0xe1, 0, 0, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0x0, 0, F_M_ACCESS | F_RL_WLUN_OK, NULL, NULL,/* TEST UNIT READY */ {6, 0, 0, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {1, 0x5a, 0, F_D_IN, resp_mode_sense, msense_iarr, {10, 0xf8, 0xff, 0xff, 0, 0, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {1, 0x55, 0, F_D_OUT, resp_mode_select, mselect_iarr, {10, 0xf1, 0, 0, 0, 0, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x4d, 0, F_D_IN, resp_log_sense, NULL, {10, 0xe3, 0xff, 0xff, 0, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x25, 0, F_D_IN, resp_readcap, NULL, {10, 0xe1, 0xff, 0xff, 0xff, 0xff, 0, 0, 0x1, 0xc7, 0, 0, 0, 0, 0, 0} }, {3, 0x88, 0, F_D_IN | FF_DIRECT_IO, resp_read_dt0, read_iarr, {16, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xc7} }, /* READ(16) */ /* 10 */ {3, 0x8a, 0, F_D_OUT | FF_DIRECT_IO, resp_write_dt0, write_iarr, {16, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xc7} }, /* WRITE(16) */ {0, 0x1b, 0, 0, resp_start_stop, NULL, /* START STOP UNIT */ {6, 0x1, 0, 0xf, 0xf7, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {1, 0x9e, 0x10, F_SA_LOW | F_D_IN, resp_readcap16, sa_in_iarr, {16, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1, 0xc7} }, /* READ CAPACITY(16) */ {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* SA OUT */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {2, 0xa3, 0xa, F_SA_LOW | F_D_IN, resp_report_tgtpgs, maint_in_iarr, {12, 0xea, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0xc7, 0, 0, 0, 0} }, {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* MAINT OUT */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* VERIFY */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {1, 0x7f, 0x9, F_SA_HIGH | F_D_IN | FF_DIRECT_IO, resp_read_dt0, vl_iarr, {32, 0xc7, 0, 0, 0, 0, 0x1f, 0x18, 0x0, 0x9, 0xfe, 0, 0xff, 0xff, 0xff, 0xff} },/* VARIABLE LENGTH, READ(32) */ {1, 0x56, 0, F_D_OUT, NULL, reserve_iarr, /* RESERVE(10) */ {10, 0xff, 0xff, 0xff, 0, 0, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {1, 0x57, 0, F_D_OUT, NULL, release_iarr, /* RELEASE(10) */ {10, 0x13, 0xff, 0xff, 0, 0, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, /* 20 */ {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* ALLOW REMOVAL */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0x1, 0, 0, resp_start_stop, NULL, /* REWIND ?? */ {6, 0x1, 0, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* ATA_PT */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0x1d, F_D_OUT, 0, NULL, NULL, /* SEND DIAGNOSTIC */ {6, 0xf7, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0x42, 0, F_D_OUT | FF_DIRECT_IO, resp_unmap, NULL, /* UNMAP */ {10, 0x1, 0, 0, 0, 0, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x53, 0, F_D_IN | F_D_OUT | FF_DIRECT_IO, resp_xdwriteread_10, NULL, {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* WRITE_BUFFER */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {1, 0x41, 0, F_D_OUT_MAYBE | FF_DIRECT_IO, resp_write_same_10, write_same_iarr, {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x35, 0, F_DELAY_OVERR | FF_DIRECT_IO, NULL, NULL, /* SYNC_CACHE */ {10, 0x7, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, {0, 0x89, 0, F_D_OUT | FF_DIRECT_IO, resp_comp_write, NULL, {16, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0xff, 0x1f, 0xc7} }, /* COMPARE AND WRITE */ /* 30 */ {0xff, 0, 0, 0, NULL, NULL, /* terminating element */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; struct sdebug_scmd_extra_t { bool inj_recovered; bool inj_transport; bool inj_dif; bool inj_dix; bool inj_short; }; static int scsi_debug_add_host = DEF_NUM_HOST; static int scsi_debug_ato = DEF_ATO; static int scsi_debug_delay = DEF_DELAY; static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; static int scsi_debug_dif = DEF_DIF; static int scsi_debug_dix = DEF_DIX; static int scsi_debug_dsense = DEF_D_SENSE; static int scsi_debug_every_nth = DEF_EVERY_NTH; static int scsi_debug_fake_rw = DEF_FAKE_RW; static unsigned int scsi_debug_guard = DEF_GUARD; static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; static int scsi_debug_max_luns = DEF_MAX_LUNS; static int scsi_debug_max_queue = SCSI_DEBUG_CANQUEUE; static atomic_t retired_max_queue; /* if > 0 then was prior max_queue */ static int scsi_debug_ndelay = DEF_NDELAY; static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; static int scsi_debug_no_uld = 0; static int scsi_debug_num_parts = DEF_NUM_PARTS; static int scsi_debug_num_tgts = DEF_NUM_TGTS; /* targets per host */ static int scsi_debug_opt_blks = DEF_OPT_BLKS; static int scsi_debug_opts = DEF_OPTS; static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; static int scsi_debug_sector_size = DEF_SECTOR_SIZE; static int scsi_debug_virtual_gb = DEF_VIRTUAL_GB; static int scsi_debug_vpd_use_hostno = DEF_VPD_USE_HOSTNO; static unsigned int scsi_debug_lbpu = DEF_LBPU; static unsigned int scsi_debug_lbpws = DEF_LBPWS; static unsigned int scsi_debug_lbpws10 = DEF_LBPWS10; static unsigned int scsi_debug_lbprz = DEF_LBPRZ; static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; static unsigned int scsi_debug_unmap_max_desc = DEF_UNMAP_MAX_DESC; static unsigned int scsi_debug_write_same_length = DEF_WRITESAME_LENGTH; static bool scsi_debug_removable = DEF_REMOVABLE; static bool scsi_debug_clustering; static bool scsi_debug_host_lock = DEF_HOST_LOCK; static bool scsi_debug_strict = DEF_STRICT; static bool sdebug_any_injecting_opt; static atomic_t sdebug_cmnd_count; static atomic_t sdebug_completions; static atomic_t sdebug_a_tsf; /* counter of 'almost' TSFs */ #define DEV_READONLY(TGT) (0) static unsigned int sdebug_store_sectors; static sector_t sdebug_capacity; /* in sectors */ /* old BIOS stuff, kernel may get rid of them but some mode sense pages may still need them */ static int sdebug_heads; /* heads per disk */ static int sdebug_cylinders_per; /* cylinders per surface */ static int sdebug_sectors_per; /* sectors per cylinder */ #define SDEBUG_MAX_PARTS 4 #define SCSI_DEBUG_MAX_CMD_LEN 32 static unsigned int scsi_debug_lbp(void) { return ((0 == scsi_debug_fake_rw) && (scsi_debug_lbpu | scsi_debug_lbpws | scsi_debug_lbpws10)); } struct sdebug_dev_info { struct list_head dev_list; unsigned int channel; unsigned int target; u64 lun; struct sdebug_host_info *sdbg_host; unsigned long uas_bm[1]; atomic_t num_in_q; char stopped; /* TODO: should be atomic */ bool used; }; struct sdebug_host_info { struct list_head host_list; struct Scsi_Host *shost; struct device dev; struct list_head dev_info_list; }; #define to_sdebug_host(d) \ container_of(d, struct sdebug_host_info, dev) static LIST_HEAD(sdebug_host_list); static DEFINE_SPINLOCK(sdebug_host_list_lock); struct sdebug_hrtimer { /* ... is derived from hrtimer */ struct hrtimer hrt; /* must be first element */ int qa_indx; }; struct sdebug_queued_cmd { /* in_use flagged by a bit in queued_in_use_bm[] */ struct timer_list *cmnd_timerp; struct tasklet_struct *tletp; struct sdebug_hrtimer *sd_hrtp; struct scsi_cmnd * a_cmnd; }; static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; static unsigned long queued_in_use_bm[SCSI_DEBUG_CANQUEUE_WORDS]; static unsigned char * fake_storep; /* ramdisk storage */ static struct sd_dif_tuple *dif_storep; /* protection info */ static void *map_storep; /* provisioning map */ static unsigned long map_size; static int num_aborts; static int num_dev_resets; static int num_target_resets; static int num_bus_resets; static int num_host_resets; static int dix_writes; static int dix_reads; static int dif_errors; static DEFINE_SPINLOCK(queued_arr_lock); static DEFINE_RWLOCK(atomic_rw); static char sdebug_proc_name[] = MY_NAME; static const char *my_name = MY_NAME; static struct bus_type pseudo_lld_bus; static struct device_driver sdebug_driverfs_driver = { .name = sdebug_proc_name, .bus = &pseudo_lld_bus, }; static const int check_condition_result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; static const int illegal_condition_result = (DRIVER_SENSE << 24) | (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; static const int device_qfull_result = (DID_OK << 16) | (COMMAND_COMPLETE << 8) | SAM_STAT_TASK_SET_FULL; static unsigned char caching_pg[] = {0x8, 18, 0x14, 0, 0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x80, 0x14, 0, 0, 0, 0, 0, 0}; static unsigned char ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0x2, 0x4b}; static unsigned char iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x0}; static void *fake_store(unsigned long long lba) { lba = do_div(lba, sdebug_store_sectors); return fake_storep + lba * scsi_debug_sector_size; } static struct sd_dif_tuple *dif_store(sector_t sector) { sector = do_div(sector, sdebug_store_sectors); return dif_storep + sector; } static int sdebug_add_adapter(void); static void sdebug_remove_adapter(void); static void sdebug_max_tgts_luns(void) { struct sdebug_host_info *sdbg_host; struct Scsi_Host *hpnt; spin_lock(&sdebug_host_list_lock); list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) { hpnt = sdbg_host->shost; if ((hpnt->this_id >= 0) && (scsi_debug_num_tgts > hpnt->this_id)) hpnt->max_id = scsi_debug_num_tgts + 1; else hpnt->max_id = scsi_debug_num_tgts; /* scsi_debug_max_luns; */ hpnt->max_lun = SAM2_WLUN_REPORT_LUNS; } spin_unlock(&sdebug_host_list_lock); } enum sdeb_cmd_data {SDEB_IN_DATA = 0, SDEB_IN_CDB = 1}; /* Set in_bit to -1 to indicate no bit position of invalid field */ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, enum sdeb_cmd_data c_d, int in_byte, int in_bit) { unsigned char *sbuff; u8 sks[4]; int sl, asc; sbuff = scp->sense_buffer; if (!sbuff) { sdev_printk(KERN_ERR, scp->device, "%s: sense_buffer is NULL\n", __func__); return; } asc = c_d ? INVALID_FIELD_IN_CDB : INVALID_FIELD_IN_PARAM_LIST; memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); scsi_build_sense_buffer(scsi_debug_dsense, sbuff, ILLEGAL_REQUEST, asc, 0); memset(sks, 0, sizeof(sks)); sks[0] = 0x80; if (c_d) sks[0] |= 0x40; if (in_bit >= 0) { sks[0] |= 0x8; sks[0] |= 0x7 & in_bit; } put_unaligned_be16(in_byte, sks + 1); if (scsi_debug_dsense) { sl = sbuff[7] + 8; sbuff[7] = sl; sbuff[sl] = 0x2; sbuff[sl + 1] = 0x6; memcpy(sbuff + sl + 4, sks, 3); } else memcpy(sbuff + 15, sks, 3); if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" "]: [0x5,0x%x,0x0] %c byte=%d, bit=%d\n", my_name, asc, c_d ? 'C' : 'D', in_byte, in_bit); } static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) { unsigned char *sbuff; sbuff = scp->sense_buffer; if (!sbuff) { sdev_printk(KERN_ERR, scp->device, "%s: sense_buffer is NULL\n", __func__); return; } memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); scsi_build_sense_buffer(scsi_debug_dsense, sbuff, key, asc, asq); if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n", my_name, key, asc, asq); } static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); } static int scsi_debug_ioctl(struct scsi_device *dev, int cmd, void __user *arg) { if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) { if (0x1261 == cmd) sdev_printk(KERN_INFO, dev, "%s: BLKFLSBUF [0x1261]\n", __func__); else if (0x5331 == cmd) sdev_printk(KERN_INFO, dev, "%s: CDROM_GET_CAPABILITY [0x5331]\n", __func__); else sdev_printk(KERN_INFO, dev, "%s: cmd=0x%x\n", __func__, cmd); } return -EINVAL; /* return -ENOTTY; // correct return but upsets fdisk */ } static int check_readiness(struct scsi_cmnd *SCpnt, int uas_only, struct sdebug_dev_info * devip) { int k; bool debug = !!(SCSI_DEBUG_OPT_NOISE & scsi_debug_opts); k = find_first_bit(devip->uas_bm, SDEBUG_NUM_UAS); if (k != SDEBUG_NUM_UAS) { const char *cp = NULL; switch (k) { case SDEBUG_UA_POR: mk_sense_buffer(SCpnt, UNIT_ATTENTION, UA_RESET_ASC, POWER_ON_RESET_ASCQ); if (debug) cp = "power on reset"; break; case SDEBUG_UA_BUS_RESET: mk_sense_buffer(SCpnt, UNIT_ATTENTION, UA_RESET_ASC, BUS_RESET_ASCQ); if (debug) cp = "bus reset"; break; case SDEBUG_UA_MODE_CHANGED: mk_sense_buffer(SCpnt, UNIT_ATTENTION, UA_CHANGED_ASC, MODE_CHANGED_ASCQ); if (debug) cp = "mode parameters changed"; break; case SDEBUG_UA_CAPACITY_CHANGED: mk_sense_buffer(SCpnt, UNIT_ATTENTION, UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ); if (debug) cp = "capacity data changed"; default: pr_warn("%s: unexpected unit attention code=%d\n", __func__, k); if (debug) cp = "unknown"; break; } clear_bit(k, devip->uas_bm); if (debug) sdev_printk(KERN_INFO, SCpnt->device, "%s reports: Unit attention: %s\n", my_name, cp); return check_condition_result; } if ((UAS_TUR == uas_only) && devip->stopped) { mk_sense_buffer(SCpnt, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); if (debug) sdev_printk(KERN_INFO, SCpnt->device, "%s reports: Not ready: %s\n", my_name, "initializing command required"); return check_condition_result; } return 0; } /* Returns 0 if ok else (DID_ERROR << 16). Sets scp->resid . */ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, int arr_len) { int act_len; struct scsi_data_buffer *sdb = scsi_in(scp); if (!sdb->length) return 0; if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) return (DID_ERROR << 16); act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents, arr, arr_len); sdb->resid = scsi_bufflen(scp) - act_len; return 0; } /* Returns number of bytes fetched into 'arr' or -1 if error. */ static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, int arr_len) { if (!scsi_bufflen(scp)) return 0; if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE)) return -1; return scsi_sg_copy_to_buffer(scp, arr, arr_len); } static const char * inq_vendor_id = "Linux "; static const char * inq_product_id = "scsi_debug "; static const char *inq_product_rev = "0184"; /* version less '.' */ /* Device identification VPD page. Returns number of bytes placed in arr */ static int inquiry_evpd_83(unsigned char * arr, int port_group_id, int target_dev_id, int dev_id_num, const char * dev_id_str, int dev_id_str_len) { int num, port_a; char b[32]; port_a = target_dev_id + 1; /* T10 vendor identifier field format (faked) */ arr[0] = 0x2; /* ASCII */ arr[1] = 0x1; arr[2] = 0x0; memcpy(&arr[4], inq_vendor_id, 8); memcpy(&arr[12], inq_product_id, 16); memcpy(&arr[28], dev_id_str, dev_id_str_len); num = 8 + 16 + dev_id_str_len; arr[3] = num; num += 4; if (dev_id_num >= 0) { /* NAA-5, Logical unit identifier (binary) */ arr[num++] = 0x1; /* binary (not necessarily sas) */ arr[num++] = 0x3; /* PIV=0, lu, naa */ arr[num++] = 0x0; arr[num++] = 0x8; arr[num++] = 0x53; /* naa-5 ieee company id=0x333333 (fake) */ arr[num++] = 0x33; arr[num++] = 0x33; arr[num++] = 0x30; arr[num++] = (dev_id_num >> 24); arr[num++] = (dev_id_num >> 16) & 0xff; arr[num++] = (dev_id_num >> 8) & 0xff; arr[num++] = dev_id_num & 0xff; /* Target relative port number */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0x94; /* PIV=1, target port, rel port */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x4; /* length */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; arr[num++] = 0x1; /* relative port A */ } /* NAA-5, Target port identifier */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0x93; /* piv=1, target port, naa */ arr[num++] = 0x0; arr[num++] = 0x8; arr[num++] = 0x52; /* naa-5, company id=0x222222 (fake) */ arr[num++] = 0x22; arr[num++] = 0x22; arr[num++] = 0x20; arr[num++] = (port_a >> 24); arr[num++] = (port_a >> 16) & 0xff; arr[num++] = (port_a >> 8) & 0xff; arr[num++] = port_a & 0xff; /* NAA-5, Target port group identifier */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0x95; /* piv=1, target port group id */ arr[num++] = 0x0; arr[num++] = 0x4; arr[num++] = 0; arr[num++] = 0; arr[num++] = (port_group_id >> 8) & 0xff; arr[num++] = port_group_id & 0xff; /* NAA-5, Target device identifier */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0xa3; /* piv=1, target device, naa */ arr[num++] = 0x0; arr[num++] = 0x8; arr[num++] = 0x52; /* naa-5, company id=0x222222 (fake) */ arr[num++] = 0x22; arr[num++] = 0x22; arr[num++] = 0x20; arr[num++] = (target_dev_id >> 24); arr[num++] = (target_dev_id >> 16) & 0xff; arr[num++] = (target_dev_id >> 8) & 0xff; arr[num++] = target_dev_id & 0xff; /* SCSI name string: Target device identifier */ arr[num++] = 0x63; /* proto=sas, UTF-8 */ arr[num++] = 0xa8; /* piv=1, target device, SCSI name string */ arr[num++] = 0x0; arr[num++] = 24; memcpy(arr + num, "naa.52222220", 12); num += 12; snprintf(b, sizeof(b), "%08X", target_dev_id); memcpy(arr + num, b, 8); num += 8; memset(arr + num, 0, 4); num += 4; return num; } static unsigned char vpd84_data[] = { /* from 4th byte */ 0x22,0x22,0x22,0x0,0xbb,0x0, 0x22,0x22,0x22,0x0,0xbb,0x1, 0x22,0x22,0x22,0x0,0xbb,0x2, }; /* Software interface identification VPD page */ static int inquiry_evpd_84(unsigned char * arr) { memcpy(arr, vpd84_data, sizeof(vpd84_data)); return sizeof(vpd84_data); } /* Management network addresses VPD page */ static int inquiry_evpd_85(unsigned char * arr) { int num = 0; const char * na1 = "https://www.kernel.org/config"; const char * na2 = "http://www.kernel.org/log"; int plen, olen; arr[num++] = 0x1; /* lu, storage config */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; olen = strlen(na1); plen = olen + 1; if (plen % 4) plen = ((plen / 4) + 1) * 4; arr[num++] = plen; /* length, null termianted, padded */ memcpy(arr + num, na1, olen); memset(arr + num + olen, 0, plen - olen); num += plen; arr[num++] = 0x4; /* lu, logging */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; olen = strlen(na2); plen = olen + 1; if (plen % 4) plen = ((plen / 4) + 1) * 4; arr[num++] = plen; /* length, null terminated, padded */ memcpy(arr + num, na2, olen); memset(arr + num + olen, 0, plen - olen); num += plen; return num; } /* SCSI ports VPD page */ static int inquiry_evpd_88(unsigned char * arr, int target_dev_id) { int num = 0; int port_a, port_b; port_a = target_dev_id + 1; port_b = port_a + 1; arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; arr[num++] = 0x1; /* relative port 1 (primary) */ memset(arr + num, 0, 6); num += 6; arr[num++] = 0x0; arr[num++] = 12; /* length tp descriptor */ /* naa-5 target port identifier (A) */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0x93; /* PIV=1, target port, NAA */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x8; /* length */ arr[num++] = 0x52; /* NAA-5, company_id=0x222222 (fake) */ arr[num++] = 0x22; arr[num++] = 0x22; arr[num++] = 0x20; arr[num++] = (port_a >> 24); arr[num++] = (port_a >> 16) & 0xff; arr[num++] = (port_a >> 8) & 0xff; arr[num++] = port_a & 0xff; arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x0; arr[num++] = 0x2; /* relative port 2 (secondary) */ memset(arr + num, 0, 6); num += 6; arr[num++] = 0x0; arr[num++] = 12; /* length tp descriptor */ /* naa-5 target port identifier (B) */ arr[num++] = 0x61; /* proto=sas, binary */ arr[num++] = 0x93; /* PIV=1, target port, NAA */ arr[num++] = 0x0; /* reserved */ arr[num++] = 0x8; /* length */ arr[num++] = 0x52; /* NAA-5, company_id=0x222222 (fake) */ arr[num++] = 0x22; arr[num++] = 0x22; arr[num++] = 0x20; arr[num++] = (port_b >> 24); arr[num++] = (port_b >> 16) & 0xff; arr[num++] = (port_b >> 8) & 0xff; arr[num++] = port_b & 0xff; return num; } static unsigned char vpd89_data[] = { /* from 4th byte */ 0,0,0,0, 'l','i','n','u','x',' ',' ',' ', 'S','A','T',' ','s','c','s','i','_','d','e','b','u','g',' ',' ', '1','2','3','4', 0x34,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, 0xec,0,0,0, 0x5a,0xc,0xff,0x3f,0x37,0xc8,0x10,0,0,0,0,0,0x3f,0,0,0, 0,0,0,0,0x58,0x58,0x58,0x58,0x58,0x58,0x58,0x58,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0,0,0,0x40,0x4,0,0x2e,0x33, 0x38,0x31,0x20,0x20,0x20,0x20,0x54,0x53,0x38,0x33,0x30,0x30,0x33,0x31, 0x53,0x41, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x10,0x80, 0,0,0,0x2f,0,0,0,0x2,0,0x2,0x7,0,0xff,0xff,0x1,0, 0x3f,0,0xc1,0xff,0x3e,0,0x10,0x1,0xb0,0xf8,0x50,0x9,0,0,0x7,0, 0x3,0,0x78,0,0x78,0,0xf0,0,0x78,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0x2,0,0,0,0,0,0,0, 0x7e,0,0x1b,0,0x6b,0x34,0x1,0x7d,0x3,0x40,0x69,0x34,0x1,0x3c,0x3,0x40, 0x7f,0x40,0,0,0,0,0xfe,0xfe,0,0,0,0,0,0xfe,0,0, 0,0,0,0,0,0,0,0,0xb0,0xf8,0x50,0x9,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0x1,0,0xb0,0xf8,0x50,0x9,0xb0,0xf8,0x50,0x9,0x20,0x20,0x2,0,0xb6,0x42, 0,0x80,0x8a,0,0x6,0x3c,0xa,0x3c,0xff,0xff,0xc6,0x7,0,0x1,0,0x8, 0xf0,0xf,0,0x10,0x2,0,0x30,0,0,0,0,0,0,0,0x6,0xfe, 0,0,0x2,0,0x50,0,0x8a,0,0x4f,0x95,0,0,0x21,0,0xb,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xa5,0x51, }; /* ATA Information VPD page */ static int inquiry_evpd_89(unsigned char * arr) { memcpy(arr, vpd89_data, sizeof(vpd89_data)); return sizeof(vpd89_data); } static unsigned char vpdb0_data[] = { /* from 4th byte */ 0,0,0,4, 0,0,0x4,0, 0,0,0,64, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; /* Block limits VPD page (SBC-3) */ static int inquiry_evpd_b0(unsigned char * arr) { unsigned int gran; memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); /* Optimal transfer length granularity */ gran = 1 << scsi_debug_physblk_exp; arr[2] = (gran >> 8) & 0xff; arr[3] = gran & 0xff; /* Maximum Transfer Length */ if (sdebug_store_sectors > 0x400) { arr[4] = (sdebug_store_sectors >> 24) & 0xff; arr[5] = (sdebug_store_sectors >> 16) & 0xff; arr[6] = (sdebug_store_sectors >> 8) & 0xff; arr[7] = sdebug_store_sectors & 0xff; } /* Optimal Transfer Length */ put_unaligned_be32(scsi_debug_opt_blks, &arr[8]); if (scsi_debug_lbpu) { /* Maximum Unmap LBA Count */ put_unaligned_be32(scsi_debug_unmap_max_blocks, &arr[16]); /* Maximum Unmap Block Descriptor Count */ put_unaligned_be32(scsi_debug_unmap_max_desc, &arr[20]); } /* Unmap Granularity Alignment */ if (scsi_debug_unmap_alignment) { put_unaligned_be32(scsi_debug_unmap_alignment, &arr[28]); arr[28] |= 0x80; /* UGAVALID */ } /* Optimal Unmap Granularity */ put_unaligned_be32(scsi_debug_unmap_granularity, &arr[24]); /* Maximum WRITE SAME Length */ put_unaligned_be64(scsi_debug_write_same_length, &arr[32]); return 0x3c; /* Mandatory page length for Logical Block Provisioning */ return sizeof(vpdb0_data); } /* Block device characteristics VPD page (SBC-3) */ static int inquiry_evpd_b1(unsigned char *arr) { memset(arr, 0, 0x3c); arr[0] = 0; arr[1] = 1; /* non rotating medium (e.g. solid state) */ arr[2] = 0; arr[3] = 5; /* less than 1.8" */ return 0x3c; } /* Logical block provisioning VPD page (SBC-3) */ static int inquiry_evpd_b2(unsigned char *arr) { memset(arr, 0, 0x4); arr[0] = 0; /* threshold exponent */ if (scsi_debug_lbpu) arr[1] = 1 << 7; if (scsi_debug_lbpws) arr[1] |= 1 << 6; if (scsi_debug_lbpws10) arr[1] |= 1 << 5; if (scsi_debug_lbprz) arr[1] |= 1 << 2; return 0x4; } #define SDEBUG_LONG_INQ_SZ 96 #define SDEBUG_MAX_INQ_ARR_SZ 584 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { unsigned char pq_pdt; unsigned char * arr; unsigned char *cmd = scp->cmnd; int alloc_len, n, ret; bool have_wlun; alloc_len = (cmd[3] << 8) + cmd[4]; arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_ATOMIC); if (! arr) return DID_REQUEUE << 16; have_wlun = (scp->device->lun == SAM2_WLUN_REPORT_LUNS); if (have_wlun) pq_pdt = 0x1e; /* present, wlun */ else if (scsi_debug_no_lun_0 && (0 == devip->lun)) pq_pdt = 0x7f; /* not present, no device type */ else pq_pdt = (scsi_debug_ptype & 0x1f); arr[0] = pq_pdt; if (0x2 & cmd[1]) { /* CMDDT bit set */ mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); kfree(arr); return check_condition_result; } else if (0x1 & cmd[1]) { /* EVPD bit set */ int lu_id_num, port_group_id, target_dev_id, len; char lu_id_str[6]; int host_no = devip->sdbg_host->shost->host_no; port_group_id = (((host_no + 1) & 0x7f) << 8) + (devip->channel & 0x7f); if (0 == scsi_debug_vpd_use_hostno) host_no = 0; lu_id_num = have_wlun ? -1 : (((host_no + 1) * 2000) + (devip->target * 1000) + devip->lun); target_dev_id = ((host_no + 1) * 2000) + (devip->target * 1000) - 3; len = scnprintf(lu_id_str, 6, "%d", lu_id_num); if (0 == cmd[2]) { /* supported vital product data pages */ arr[1] = cmd[2]; /*sanity */ n = 4; arr[n++] = 0x0; /* this page */ arr[n++] = 0x80; /* unit serial number */ arr[n++] = 0x83; /* device identification */ arr[n++] = 0x84; /* software interface ident. */ arr[n++] = 0x85; /* management network addresses */ arr[n++] = 0x86; /* extended inquiry */ arr[n++] = 0x87; /* mode page policy */ arr[n++] = 0x88; /* SCSI ports */ arr[n++] = 0x89; /* ATA information */ arr[n++] = 0xb0; /* Block limits (SBC) */ arr[n++] = 0xb1; /* Block characteristics (SBC) */ if (scsi_debug_lbp()) /* Logical Block Prov. (SBC) */ arr[n++] = 0xb2; arr[3] = n - 4; /* number of supported VPD pages */ } else if (0x80 == cmd[2]) { /* unit serial number */ arr[1] = cmd[2]; /*sanity */ arr[3] = len; memcpy(&arr[4], lu_id_str, len); } else if (0x83 == cmd[2]) { /* device identification */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_83(&arr[4], port_group_id, target_dev_id, lu_id_num, lu_id_str, len); } else if (0x84 == cmd[2]) { /* Software interface ident. */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_84(&arr[4]); } else if (0x85 == cmd[2]) { /* Management network addresses */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_85(&arr[4]); } else if (0x86 == cmd[2]) { /* extended inquiry */ arr[1] = cmd[2]; /*sanity */ arr[3] = 0x3c; /* number of following entries */ if (scsi_debug_dif == SD_DIF_TYPE3_PROTECTION) arr[4] = 0x4; /* SPT: GRD_CHK:1 */ else if (scsi_debug_dif) arr[4] = 0x5; /* SPT: GRD_CHK:1, REF_CHK:1 */ else arr[4] = 0x0; /* no protection stuff */ arr[5] = 0x7; /* head of q, ordered + simple q's */ } else if (0x87 == cmd[2]) { /* mode page policy */ arr[1] = cmd[2]; /*sanity */ arr[3] = 0x8; /* number of following entries */ arr[4] = 0x2; /* disconnect-reconnect mp */ arr[6] = 0x80; /* mlus, shared */ arr[8] = 0x18; /* protocol specific lu */ arr[10] = 0x82; /* mlus, per initiator port */ } else if (0x88 == cmd[2]) { /* SCSI Ports */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_88(&arr[4], target_dev_id); } else if (0x89 == cmd[2]) { /* ATA information */ arr[1] = cmd[2]; /*sanity */ n = inquiry_evpd_89(&arr[4]); arr[2] = (n >> 8); arr[3] = (n & 0xff); } else if (0xb0 == cmd[2]) { /* Block limits (SBC) */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_b0(&arr[4]); } else if (0xb1 == cmd[2]) { /* Block characteristics (SBC) */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_b1(&arr[4]); } else if (0xb2 == cmd[2]) { /* Logical Block Prov. (SBC) */ arr[1] = cmd[2]; /*sanity */ arr[3] = inquiry_evpd_b2(&arr[4]); } else { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); kfree(arr); return check_condition_result; } len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); ret = fill_from_dev_buffer(scp, arr, min(len, SDEBUG_MAX_INQ_ARR_SZ)); kfree(arr); return ret; } /* drops through here for a standard inquiry */ arr[1] = scsi_debug_removable ? 0x80 : 0; /* Removable disk */ arr[2] = scsi_debug_scsi_level; arr[3] = 2; /* response_data_format==2 */ arr[4] = SDEBUG_LONG_INQ_SZ - 5; arr[5] = scsi_debug_dif ? 1 : 0; /* PROTECT bit */ if (0 == scsi_debug_vpd_use_hostno) arr[5] = 0x10; /* claim: implicit TGPS */ arr[6] = 0x10; /* claim: MultiP */ /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */ arr[7] = 0xa; /* claim: LINKED + CMDQUE */ memcpy(&arr[8], inq_vendor_id, 8); memcpy(&arr[16], inq_product_id, 16); memcpy(&arr[32], inq_product_rev, 4); /* version descriptors (2 bytes each) follow */ arr[58] = 0x0; arr[59] = 0xa2; /* SAM-5 rev 4 */ arr[60] = 0x4; arr[61] = 0x68; /* SPC-4 rev 37 */ n = 62; if (scsi_debug_ptype == 0) { arr[n++] = 0x4; arr[n++] = 0xc5; /* SBC-4 rev 36 */ } else if (scsi_debug_ptype == 1) { arr[n++] = 0x5; arr[n++] = 0x25; /* SSC-4 rev 3 */ } arr[n++] = 0x20; arr[n++] = 0xe6; /* SPL-3 rev 7 */ ret = fill_from_dev_buffer(scp, arr, min(alloc_len, SDEBUG_LONG_INQ_SZ)); kfree(arr); return ret; } static int resp_requests(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned char * sbuff; unsigned char *cmd = scp->cmnd; unsigned char arr[SCSI_SENSE_BUFFERSIZE]; bool dsense, want_dsense; int len = 18; memset(arr, 0, sizeof(arr)); dsense = !!(cmd[1] & 1); want_dsense = dsense || scsi_debug_dsense; sbuff = scp->sense_buffer; if ((iec_m_pg[2] & 0x4) && (6 == (iec_m_pg[3] & 0xf))) { if (dsense) { arr[0] = 0x72; arr[1] = 0x0; /* NO_SENSE in sense_key */ arr[2] = THRESHOLD_EXCEEDED; arr[3] = 0xff; /* TEST set and MRIE==6 */ len = 8; } else { arr[0] = 0x70; arr[2] = 0x0; /* NO_SENSE in sense_key */ arr[7] = 0xa; /* 18 byte sense buffer */ arr[12] = THRESHOLD_EXCEEDED; arr[13] = 0xff; /* TEST set and MRIE==6 */ } } else { memcpy(arr, sbuff, SCSI_SENSE_BUFFERSIZE); if (arr[0] >= 0x70 && dsense == scsi_debug_dsense) ; /* have sense and formats match */ else if (arr[0] <= 0x70) { if (dsense) { memset(arr, 0, 8); arr[0] = 0x72; len = 8; } else { memset(arr, 0, 18); arr[0] = 0x70; arr[7] = 0xa; } } else if (dsense) { memset(arr, 0, 8); arr[0] = 0x72; arr[1] = sbuff[2]; /* sense key */ arr[2] = sbuff[12]; /* asc */ arr[3] = sbuff[13]; /* ascq */ len = 8; } else { memset(arr, 0, 18); arr[0] = 0x70; arr[2] = sbuff[1]; arr[7] = 0xa; arr[12] = sbuff[1]; arr[13] = sbuff[3]; } } mk_sense_buffer(scp, 0, NO_ADDITIONAL_SENSE, 0); return fill_from_dev_buffer(scp, arr, len); } static int resp_start_stop(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned char *cmd = scp->cmnd; int power_cond, start; power_cond = (cmd[4] & 0xf0) >> 4; if (power_cond) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); return check_condition_result; } start = cmd[4] & 1; if (start == devip->stopped) devip->stopped = !start; return 0; } static sector_t get_sdebug_capacity(void) { if (scsi_debug_virtual_gb > 0) return (sector_t)scsi_debug_virtual_gb * (1073741824 / scsi_debug_sector_size); else return sdebug_store_sectors; } #define SDEBUG_READCAP_ARR_SZ 8 static int resp_readcap(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned char arr[SDEBUG_READCAP_ARR_SZ]; unsigned int capac; /* following just in case virtual_gb changed */ sdebug_capacity = get_sdebug_capacity(); memset(arr, 0, SDEBUG_READCAP_ARR_SZ); if (sdebug_capacity < 0xffffffff) { capac = (unsigned int)sdebug_capacity - 1; arr[0] = (capac >> 24); arr[1] = (capac >> 16) & 0xff; arr[2] = (capac >> 8) & 0xff; arr[3] = capac & 0xff; } else { arr[0] = 0xff; arr[1] = 0xff; arr[2] = 0xff; arr[3] = 0xff; } arr[6] = (scsi_debug_sector_size >> 8) & 0xff; arr[7] = scsi_debug_sector_size & 0xff; return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); } #define SDEBUG_READCAP16_ARR_SZ 32 static int resp_readcap16(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned char *cmd = scp->cmnd; unsigned char arr[SDEBUG_READCAP16_ARR_SZ]; unsigned long long capac; int k, alloc_len; alloc_len = ((cmd[10] << 24) + (cmd[11] << 16) + (cmd[12] << 8) + cmd[13]); /* following just in case virtual_gb changed */ sdebug_capacity = get_sdebug_capacity(); memset(arr, 0, SDEBUG_READCAP16_ARR_SZ); capac = sdebug_capacity - 1; for (k = 0; k < 8; ++k, capac >>= 8) arr[7 - k] = capac & 0xff; arr[8] = (scsi_debug_sector_size >> 24) & 0xff; arr[9] = (scsi_debug_sector_size >> 16) & 0xff; arr[10] = (scsi_debug_sector_size >> 8) & 0xff; arr[11] = scsi_debug_sector_size & 0xff; arr[13] = scsi_debug_physblk_exp & 0xf; arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; if (scsi_debug_lbp()) { arr[14] |= 0x80; /* LBPME */ if (scsi_debug_lbprz) arr[14] |= 0x40; /* LBPRZ */ } arr[15] = scsi_debug_lowest_aligned & 0xff; if (scsi_debug_dif) { arr[12] = (scsi_debug_dif - 1) << 1; /* P_TYPE */ arr[12] |= 1; /* PROT_EN */ } return fill_from_dev_buffer(scp, arr, min(alloc_len, SDEBUG_READCAP16_ARR_SZ)); } #define SDEBUG_MAX_TGTPGS_ARR_SZ 1412 static int resp_report_tgtpgs(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned char *cmd = scp->cmnd; unsigned char * arr; int host_no = devip->sdbg_host->shost->host_no; int n, ret, alen, rlen; int port_group_a, port_group_b, port_a, port_b; alen = ((cmd[6] << 24) + (cmd[7] << 16) + (cmd[8] << 8) + cmd[9]); arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_ATOMIC); if (! arr) return DID_REQUEUE << 16; /* * EVPD page 0x88 states we have two ports, one * real and a fake port with no device connected. * So we create two port groups with one port each * and set the group with port B to unavailable. */ port_a = 0x1; /* relative port A */ port_b = 0x2; /* relative port B */ port_group_a = (((host_no + 1) & 0x7f) << 8) + (devip->channel & 0x7f); port_group_b = (((host_no + 1) & 0x7f) << 8) + (devip->channel & 0x7f) + 0x80; /* * The asymmetric access state is cycled according to the host_id. */ n = 4; if (0 == scsi_debug_vpd_use_hostno) { arr[n++] = host_no % 3; /* Asymm access state */ arr[n++] = 0x0F; /* claim: all states are supported */ } else { arr[n++] = 0x0; /* Active/Optimized path */ arr[n++] = 0x01; /* claim: only support active/optimized paths */ } arr[n++] = (port_group_a >> 8) & 0xff; arr[n++] = port_group_a & 0xff; arr[n++] = 0; /* Reserved */ arr[n++] = 0; /* Status code */ arr[n++] = 0; /* Vendor unique */ arr[n++] = 0x1; /* One port per group */ arr[n++] = 0; /* Reserved */ arr[n++] = 0; /* Reserved */ arr[n++] = (port_a >> 8) & 0xff; arr[n++] = port_a & 0xff; arr[n++] = 3; /* Port unavailable */ arr[n++] = 0x08; /* claim: only unavailalbe paths are supported */ arr[n++] = (port_group_b >> 8) & 0xff; arr[n++] = port_group_b & 0xff; arr[n++] = 0; /* Reserved */ arr[n++] = 0; /* Status code */ arr[n++] = 0; /* Vendor unique */ arr[n++] = 0x1; /* One port per group */ arr[n++] = 0; /* Reserved */ arr[n++] = 0; /* Reserved */ arr[n++] = (port_b >> 8) & 0xff; arr[n++] = port_b & 0xff; rlen = n - 4; arr[0] = (rlen >> 24) & 0xff; arr[1] = (rlen >> 16) & 0xff; arr[2] = (rlen >> 8) & 0xff; arr[3] = rlen & 0xff; /* * Return the smallest value of either * - The allocated length * - The constructed command length * - The maximum array size */ rlen = min(alen,n); ret = fill_from_dev_buffer(scp, arr, min(rlen, SDEBUG_MAX_TGTPGS_ARR_SZ)); kfree(arr); return ret; } static int resp_rsup_opcodes(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { bool rctd; u8 reporting_opts, req_opcode, sdeb_i, supp; u16 req_sa, u; u32 alloc_len, a_len; int k, offset, len, errsts, count, bump, na; const struct opcode_info_t *oip; const struct opcode_info_t *r_oip; u8 *arr; u8 *cmd = scp->cmnd; rctd = !!(cmd[2] & 0x80); reporting_opts = cmd[2] & 0x7; req_opcode = cmd[3]; req_sa = get_unaligned_be16(cmd + 4); alloc_len = get_unaligned_be32(cmd + 6); if (alloc_len < 4 && alloc_len > 0xffff) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); return check_condition_result; } if (alloc_len > 8192) a_len = 8192; else a_len = alloc_len; arr = kzalloc((a_len < 256) ? 320 : a_len + 64, GFP_KERNEL); if (NULL == arr) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ); return check_condition_result; } switch (reporting_opts) { case 0: /* all commands */ /* count number of commands */ for (count = 0, oip = opcode_info_arr; oip->num_attached != 0xff; ++oip) { if (F_INV_OP & oip->flags) continue; count += (oip->num_attached + 1); } bump = rctd ? 20 : 8; put_unaligned_be32(count * bump, arr); for (offset = 4, oip = opcode_info_arr; oip->num_attached != 0xff && offset < a_len; ++oip) { if (F_INV_OP & oip->flags) continue; na = oip->num_attached; arr[offset] = oip->opcode; put_unaligned_be16(oip->sa, arr + offset + 2); if (rctd) arr[offset + 5] |= 0x2; if (FF_SA & oip->flags) arr[offset + 5] |= 0x1; put_unaligned_be16(oip->len_mask[0], arr + offset + 6); if (rctd) put_unaligned_be16(0xa, arr + offset + 8); r_oip = oip; for (k = 0, oip = oip->arrp; k < na; ++k, ++oip) { if (F_INV_OP & oip->flags) continue; offset += bump; arr[offset] = oip->opcode; put_unaligned_be16(oip->sa, arr + offset + 2); if (rctd) arr[offset + 5] |= 0x2; if (FF_SA & oip->flags) arr[offset + 5] |= 0x1; put_unaligned_be16(oip->len_mask[0], arr + offset + 6); if (rctd) put_unaligned_be16(0xa, arr + offset + 8); } oip = r_oip; offset += bump; } break; case 1: /* one command: opcode only */ case 2: /* one command: opcode plus service action */ case 3: /* one command: if sa==0 then opcode only else opcode+sa */ sdeb_i = opcode_ind_arr[req_opcode]; oip = &opcode_info_arr[sdeb_i]; if (F_INV_OP & oip->flags) { supp = 1; offset = 4; } else { if (1 == reporting_opts) { if (FF_SA & oip->flags) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); kfree(arr); return check_condition_result; } req_sa = 0; } else if (2 == reporting_opts && 0 == (FF_SA & oip->flags)) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); kfree(arr); /* point at requested sa */ return check_condition_result; } if (0 == (FF_SA & oip->flags) && req_opcode == oip->opcode) supp = 3; else if (0 == (FF_SA & oip->flags)) { na = oip->num_attached; for (k = 0, oip = oip->arrp; k < na; ++k, ++oip) { if (req_opcode == oip->opcode) break; } supp = (k >= na) ? 1 : 3; } else if (req_sa != oip->sa) { na = oip->num_attached; for (k = 0, oip = oip->arrp; k < na; ++k, ++oip) { if (req_sa == oip->sa) break; } supp = (k >= na) ? 1 : 3; } else supp = 3; if (3 == supp) { u = oip->len_mask[0]; put_unaligned_be16(u, arr + 2); arr[4] = oip->opcode; for (k = 1; k < u; ++k) arr[4 + k] = (k < 16) ? oip->len_mask[k] : 0xff; offset = 4 + u; } else offset = 4; } arr[1] = (rctd ? 0x80 : 0) | supp; if (rctd) { put_unaligned_be16(0xa, arr + offset); offset += 12; } break; default: mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); kfree(arr); return check_condition_result; } offset = (offset < a_len) ? offset : a_len; len = (offset < alloc_len) ? offset : alloc_len; errsts = fill_from_dev_buffer(scp, arr, len); kfree(arr); return errsts; } static int resp_rsup_tmfs(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { bool repd; u32 alloc_len, len; u8 arr[16]; u8 *cmd = scp->cmnd; memset(arr, 0, sizeof(arr)); repd = !!(cmd[2] & 0x80); alloc_len = get_unaligned_be32(cmd + 6); if (alloc_len < 4) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); return check_condition_result; } arr[0] = 0xc8; /* ATS | ATSS | LURS */ arr[1] = 0x1; /* ITNRS */ if (repd) { arr[3] = 0xc; len = 16; } else len = 4; len = (len < alloc_len) ? len : alloc_len; return fill_from_dev_buffer(scp, arr, len); } /* <<Following mode page info copied from ST318451LW>> */ static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target) { /* Read-Write Error Recovery page for mode_sense */ unsigned char err_recov_pg[] = {0x1, 0xa, 0xc0, 11, 240, 0, 0, 0, 5, 0, 0xff, 0xff}; memcpy(p, err_recov_pg, sizeof(err_recov_pg)); if (1 == pcontrol) memset(p + 2, 0, sizeof(err_recov_pg) - 2); return sizeof(err_recov_pg); } static int resp_disconnect_pg(unsigned char * p, int pcontrol, int target) { /* Disconnect-Reconnect page for mode_sense */ unsigned char disconnect_pg[] = {0x2, 0xe, 128, 128, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; memcpy(p, disconnect_pg, sizeof(disconnect_pg)); if (1 == pcontrol) memset(p + 2, 0, sizeof(disconnect_pg) - 2); return sizeof(disconnect_pg); } static int resp_format_pg(unsigned char * p, int pcontrol, int target) { /* Format device page for mode_sense */ unsigned char format_pg[] = {0x3, 0x16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0}; memcpy(p, format_pg, sizeof(format_pg)); p[10] = (sdebug_sectors_per >> 8) & 0xff; p[11] = sdebug_sectors_per & 0xff; p[12] = (scsi_debug_sector_size >> 8) & 0xff; p[13] = scsi_debug_sector_size & 0xff; if (scsi_debug_removable) p[20] |= 0x20; /* should agree with INQUIRY */ if (1 == pcontrol) memset(p + 2, 0, sizeof(format_pg) - 2); return sizeof(format_pg); } static int resp_caching_pg(unsigned char * p, int pcontrol, int target) { /* Caching page for mode_sense */ unsigned char ch_caching_pg[] = {/* 0x8, 18, */ 0x4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char d_caching_pg[] = {0x8, 18, 0x14, 0, 0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x80, 0x14, 0, 0, 0, 0, 0, 0}; if (SCSI_DEBUG_OPT_N_WCE & scsi_debug_opts) caching_pg[2] &= ~0x4; /* set WCE=0 (default WCE=1) */ memcpy(p, caching_pg, sizeof(caching_pg)); if (1 == pcontrol) memcpy(p + 2, ch_caching_pg, sizeof(ch_caching_pg)); else if (2 == pcontrol) memcpy(p, d_caching_pg, sizeof(d_caching_pg)); return sizeof(caching_pg); } static int resp_ctrl_m_pg(unsigned char * p, int pcontrol, int target) { /* Control mode page for mode_sense */ unsigned char ch_ctrl_m_pg[] = {/* 0xa, 10, */ 0x6, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char d_ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0x2, 0x4b}; if (scsi_debug_dsense) ctrl_m_pg[2] |= 0x4; else ctrl_m_pg[2] &= ~0x4; if (scsi_debug_ato) ctrl_m_pg[5] |= 0x80; /* ATO=1 */ memcpy(p, ctrl_m_pg, sizeof(ctrl_m_pg)); if (1 == pcontrol) memcpy(p + 2, ch_ctrl_m_pg, sizeof(ch_ctrl_m_pg)); else if (2 == pcontrol) memcpy(p, d_ctrl_m_pg, sizeof(d_ctrl_m_pg)); return sizeof(ctrl_m_pg); } static int resp_iec_m_pg(unsigned char * p, int pcontrol, int target) { /* Informational Exceptions control mode page for mode_sense */ unsigned char ch_iec_m_pg[] = {/* 0x1c, 0xa, */ 0x4, 0xf, 0, 0, 0, 0, 0, 0, 0x0, 0x0}; unsigned char d_iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x0}; memcpy(p, iec_m_pg, sizeof(iec_m_pg)); if (1 == pcontrol) memcpy(p + 2, ch_iec_m_pg, sizeof(ch_iec_m_pg)); else if (2 == pcontrol) memcpy(p, d_iec_m_pg, sizeof(d_iec_m_pg)); return sizeof(iec_m_pg); } static int resp_sas_sf_m_pg(unsigned char * p, int pcontrol, int target) { /* SAS SSP mode page - short format for mode_sense */ unsigned char sas_sf_m_pg[] = {0x19, 0x6, 0x6, 0x0, 0x7, 0xd0, 0x0, 0x0}; memcpy(p, sas_sf_m_pg, sizeof(sas_sf_m_pg)); if (1 == pcontrol) memset(p + 2, 0, sizeof(sas_sf_m_pg) - 2); return sizeof(sas_sf_m_pg); } static int resp_sas_pcd_m_spg(unsigned char * p, int pcontrol, int target, int target_dev_id) { /* SAS phy control and discover mode page for mode_sense */ unsigned char sas_pcd_m_pg[] = {0x59, 0x1, 0, 0x64, 0, 0x6, 0, 2, 0, 0, 0, 0, 0x10, 0x9, 0x8, 0x0, 0x52, 0x22, 0x22, 0x20, 0x0, 0x0, 0x0, 0x0, 0x51, 0x11, 0x11, 0x10, 0x0, 0x0, 0x0, 0x1, 0x2, 0, 0, 0, 0, 0, 0, 0, 0x88, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0x10, 0x9, 0x8, 0x0, 0x52, 0x22, 0x22, 0x20, 0x0, 0x0, 0x0, 0x0, 0x51, 0x11, 0x11, 0x10, 0x0, 0x0, 0x0, 0x1, 0x3, 0, 0, 0, 0, 0, 0, 0, 0x88, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; int port_a, port_b; port_a = target_dev_id + 1; port_b = port_a + 1; memcpy(p, sas_pcd_m_pg, sizeof(sas_pcd_m_pg)); p[20] = (port_a >> 24); p[21] = (port_a >> 16) & 0xff; p[22] = (port_a >> 8) & 0xff; p[23] = port_a & 0xff; p[48 + 20] = (port_b >> 24); p[48 + 21] = (port_b >> 16) & 0xff; p[48 + 22] = (port_b >> 8) & 0xff; p[48 + 23] = port_b & 0xff; if (1 == pcontrol) memset(p + 4, 0, sizeof(sas_pcd_m_pg) - 4); return sizeof(sas_pcd_m_pg); } static int resp_sas_sha_m_spg(unsigned char * p, int pcontrol) { /* SAS SSP shared protocol specific port mode subpage */ unsigned char sas_sha_m_pg[] = {0x59, 0x2, 0, 0xc, 0, 0x6, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; memcpy(p, sas_sha_m_pg, sizeof(sas_sha_m_pg)); if (1 == pcontrol) memset(p + 4, 0, sizeof(sas_sha_m_pg) - 4); return sizeof(sas_sha_m_pg); } #define SDEBUG_MAX_MSENSE_SZ 256 static int resp_mode_sense(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { unsigned char dbd, llbaa; int pcontrol, pcode, subpcode, bd_len; unsigned char dev_spec; int k, alloc_len, msense_6, offset, len, target_dev_id; int target = scp->device->id; unsigned char * ap; unsigned char arr[SDEBUG_MAX_MSENSE_SZ]; unsigned char *cmd = scp->cmnd; dbd = !!(cmd[1] & 0x8); pcontrol = (cmd[2] & 0xc0) >> 6; pcode = cmd[2] & 0x3f; subpcode = cmd[3]; msense_6 = (MODE_SENSE == cmd[0]); llbaa = msense_6 ? 0 : !!(cmd[1] & 0x10); if ((0 == scsi_debug_ptype) && (0 == dbd)) bd_len = llbaa ? 16 : 8; else bd_len = 0; alloc_len = msense_6 ? cmd[4] : ((cmd[7] << 8) | cmd[8]); memset(arr, 0, SDEBUG_MAX_MSENSE_SZ); if (0x3 == pcontrol) { /* Saving values not supported */ mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); return check_condition_result; } target_dev_id = ((devip->sdbg_host->shost->host_no + 1) * 2000) + (devip->target * 1000) - 3; /* set DPOFUA bit for disks */ if (0 == scsi_debug_ptype) dev_spec = (DEV_READONLY(target) ? 0x80 : 0x0) | 0x10; else dev_spec = 0x0; if (msense_6) { arr[2] = dev_spec; arr[3] = bd_len; offset = 4; } else { arr[3] = dev_spec; if (16 == bd_len) arr[4] = 0x1; /* set LONGLBA bit */ arr[7] = bd_len; /* assume 255 or less */ offset = 8; } ap = arr + offset; if ((bd_len > 0) && (!sdebug_capacity)) sdebug_capacity = get_sdebug_capacity(); if (8 == bd_len) { if (sdebug_capacity > 0xfffffffe) { ap[0] = 0xff; ap[1] = 0xff; ap[2] = 0xff; ap[3] = 0xff; } else { ap[0] = (sdebug_capacity >> 24) & 0xff; ap[1] = (sdebug_capacity >> 16) & 0xff; ap[2] = (sdebug_capacity >> 8) & 0xff; ap[3] = sdebug_capacity & 0xff; } ap[6] = (scsi_debug_sector_size >> 8) & 0xff; ap[7] = scsi_debug_sector_size & 0xff; offset += bd_len; ap = arr + offset; } else if (16 == bd_len) { unsigned long long capac = sdebug_capacity; for (k = 0; k < 8; ++k, capac >>= 8) ap[7 - k] = capac & 0xff; ap[12] = (scsi_debug_sector_size >> 24) & 0xff; ap[13] = (scsi_debug_sector_size >> 16) & 0xff; ap[14] = (scsi_debug_sector_size >> 8) & 0xff; ap[15] = scsi_debug_sector_size & 0xff; offset += bd_len; ap = arr + offset; } if ((subpcode > 0x0) && (subpcode < 0xff) && (0x19 != pcode)) { /* TODO: Control Extension page */ mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); return check_condition_result; } switch (pcode) { case 0x1: /* Read-Write error recovery page, direct access */ len = resp_err_recov_pg(ap, pcontrol, target); offset += len; break; case 0x2: /* Disconnect-Reconnect page, all devices */ len = resp_disconnect_pg(ap, pcontrol, target); offset += len; break; case 0x3: /* Format device page, direct access */ len = resp_format_pg(ap, pcontrol, target); offset += len; break; case 0x8: /* Caching page, direct access */ len = resp_caching_pg(ap, pcontrol, target); offset += len; break; case 0xa: /* Control Mode page, all devices */ len = resp_ctrl_m_pg(ap, pcontrol, target); offset += len; break; case 0x19: /* if spc==1 then sas phy, control+discover */ if ((subpcode > 0x2) && (subpcode < 0xff)) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); return check_condition_result; } len = 0; if ((0x0 == subpcode) || (0xff == subpcode)) len += resp_sas_sf_m_pg(ap + len, pcontrol, target); if ((0x1 == subpcode) || (0xff == subpcode)) len += resp_sas_pcd_m_spg(ap + len, pcontrol, target, target_dev_id); if ((0x2 == subpcode) || (0xff == subpcode)) len += resp_sas_sha_m_spg(ap + len, pcontrol); offset += len; break; case 0x1c: /* Informational Exceptions Mode page, all devices */ len = resp_iec_m_pg(ap, pcontrol, target); offset += len; break; case 0x3f: /* Read all Mode pages */ if ((0 == subpcode) || (0xff == subpcode)) { len = resp_err_recov_pg(ap, pcontrol, target); len += resp_disconnect_pg(ap + len, pcontrol, target); len += resp_format_pg(ap + len, pcontrol, target); len += resp_caching_pg(ap + len, pcontrol, target); len += resp_ctrl_m_pg(ap + len, pcontrol, target); len += resp_sas_sf_m_pg(ap + len, pcontrol, target); if (0xff == subpcode) { len += resp_sas_pcd_m_spg(ap + len, pcontrol, target, target_dev_id); len += resp_sas_sha_m_spg(ap + len, pcontrol); } len += resp_iec_m_pg(ap + len, pcontrol, target); } else { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); return check_condition_result; } offset += len; break; default: mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); return check_condition_result; } if (msense_6) arr[0] = offset - 1; else { arr[0] = ((offset - 2) >> 8) & 0xff; arr[1] = (offset - 2) & 0xff; } return fill_from_dev_buffer(scp, arr, min(alloc_len, offset)); } #define SDEBUG_MAX_MSELECT_SZ 512 static int resp_mode_select(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { int pf, sp, ps, md_len, bd_len, off, spf, pg_len; int param_len, res, mpage; unsigned char arr[SDEBUG_MAX_MSELECT_SZ]; unsigned char *cmd = scp->cmnd; int mselect6 = (MODE_SELECT == cmd[0]); memset(arr, 0, sizeof(arr)); pf = cmd[1] & 0x10; sp = cmd[1] & 0x1; param_len = mselect6 ? cmd[4] : ((cmd[7] << 8) + cmd[8]); if ((0 == pf) || sp || (param_len > SDEBUG_MAX_MSELECT_SZ)) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); return check_condition_result; } res = fetch_to_dev_buffer(scp, arr, param_len); if (-1 == res) return (DID_ERROR << 16); else if ((res < param_len) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, scp->device, "%s: cdb indicated=%d, IO sent=%d bytes\n", __func__, param_len, res); md_len = mselect6 ? (arr[0] + 1) : ((arr[0] << 8) + arr[1] + 2); bd_len = mselect6 ? arr[3] : ((arr[6] << 8) + arr[7]); if (md_len > 2) { mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); return check_condition_result; } off = bd_len + (mselect6 ? 4 : 8); mpage = arr[off] & 0x3f; ps = !!(arr[off] & 0x80); if (ps) { mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); return check_condition_result; } spf = !!(arr[off] & 0x40); pg_len = spf ? ((arr[off + 2] << 8) + arr[off + 3] + 4) : (arr[off + 1] + 2); if ((pg_len + off) > param_len) { mk_sense_buffer(scp, ILLEGAL_REQUEST, PARAMETER_LIST_LENGTH_ERR, 0); return check_condition_result; } switch (mpage) { case 0x8: /* Caching Mode page */ if (caching_pg[1] == arr[off + 1]) { memcpy(caching_pg + 2, arr + off + 2, sizeof(caching_pg) - 2); goto set_mode_changed_ua; } break; case 0xa: /* Control Mode page */ if (ctrl_m_pg[1] == arr[off + 1]) { memcpy(ctrl_m_pg + 2, arr + off + 2, sizeof(ctrl_m_pg) - 2); scsi_debug_dsense = !!(ctrl_m_pg[2] & 0x4); goto set_mode_changed_ua; } break; case 0x1c: /* Informational Exceptions Mode page */ if (iec_m_pg[1] == arr[off + 1]) { memcpy(iec_m_pg + 2, arr + off + 2, sizeof(iec_m_pg) - 2); goto set_mode_changed_ua; } break; default: break; } mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); return check_condition_result; set_mode_changed_ua: set_bit(SDEBUG_UA_MODE_CHANGED, devip->uas_bm); return 0; } static int resp_temp_l_pg(unsigned char * arr) { unsigned char temp_l_pg[] = {0x0, 0x0, 0x3, 0x2, 0x0, 38, 0x0, 0x1, 0x3, 0x2, 0x0, 65, }; memcpy(arr, temp_l_pg, sizeof(temp_l_pg)); return sizeof(temp_l_pg); } static int resp_ie_l_pg(unsigned char * arr) { unsigned char ie_l_pg[] = {0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 38, }; memcpy(arr, ie_l_pg, sizeof(ie_l_pg)); if (iec_m_pg[2] & 0x4) { /* TEST bit set */ arr[4] = THRESHOLD_EXCEEDED; arr[5] = 0xff; } return sizeof(ie_l_pg); } #define SDEBUG_MAX_LSENSE_SZ 512 static int resp_log_sense(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { int ppc, sp, pcontrol, pcode, subpcode, alloc_len, len, n; unsigned char arr[SDEBUG_MAX_LSENSE_SZ]; unsigned char *cmd = scp->cmnd; memset(arr, 0, sizeof(arr)); ppc = cmd[1] & 0x2; sp = cmd[1] & 0x1; if (ppc || sp) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); return check_condition_result; } pcontrol = (cmd[2] & 0xc0) >> 6; pcode = cmd[2] & 0x3f; subpcode = cmd[3] & 0xff; alloc_len = (cmd[7] << 8) + cmd[8]; arr[0] = pcode; if (0 == subpcode) { switch (pcode) { case 0x0: /* Supported log pages log page */ n = 4; arr[n++] = 0x0; /* this page */ arr[n++] = 0xd; /* Temperature */ arr[n++] = 0x2f; /* Informational exceptions */ arr[3] = n - 4; break; case 0xd: /* Temperature log page */ arr[3] = resp_temp_l_pg(arr + 4); break; case 0x2f: /* Informational exceptions log page */ arr[3] = resp_ie_l_pg(arr + 4); break; default: mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); return check_condition_result; } } else if (0xff == subpcode) { arr[0] |= 0x40; arr[1] = subpcode; switch (pcode) { case 0x0: /* Supported log pages and subpages log page */ n = 4; arr[n++] = 0x0; arr[n++] = 0x0; /* 0,0 page */ arr[n++] = 0x0; arr[n++] = 0xff; /* this page */ arr[n++] = 0xd; arr[n++] = 0x0; /* Temperature */ arr[n++] = 0x2f; arr[n++] = 0x0; /* Informational exceptions */ arr[3] = n - 4; break; case 0xd: /* Temperature subpages */ n = 4; arr[n++] = 0xd; arr[n++] = 0x0; /* Temperature */ arr[3] = n - 4; break; case 0x2f: /* Informational exceptions subpages */ n = 4; arr[n++] = 0x2f; arr[n++] = 0x0; /* Informational exceptions */ arr[3] = n - 4; break; default: mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); return check_condition_result; } } else { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); return check_condition_result; } len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); return fill_from_dev_buffer(scp, arr, min(len, SDEBUG_MAX_INQ_ARR_SZ)); } static int check_device_access_params(struct scsi_cmnd *scp, unsigned long long lba, unsigned int num) { if (lba + num > sdebug_capacity) { mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); return check_condition_result; } /* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) { /* needs work to find which cdb byte 'num' comes from */ mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); return check_condition_result; } return 0; } /* Returns number of bytes copied or -1 if error. */ static int do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, bool do_write) { int ret; u64 block, rest = 0; struct scsi_data_buffer *sdb; enum dma_data_direction dir; size_t (*func)(struct scatterlist *, unsigned int, void *, size_t, off_t); if (do_write) { sdb = scsi_out(scmd); dir = DMA_TO_DEVICE; func = sg_pcopy_to_buffer; } else { sdb = scsi_in(scmd); dir = DMA_FROM_DEVICE; func = sg_pcopy_from_buffer; } if (!sdb->length) return 0; if (!(scsi_bidi_cmnd(scmd) || scmd->sc_data_direction == dir)) return -1; block = do_div(lba, sdebug_store_sectors); if (block + num > sdebug_store_sectors) rest = block + num - sdebug_store_sectors; ret = func(sdb->table.sgl, sdb->table.nents, fake_storep + (block * scsi_debug_sector_size), (num - rest) * scsi_debug_sector_size, 0); if (ret != (num - rest) * scsi_debug_sector_size) return ret; if (rest) { ret += func(sdb->table.sgl, sdb->table.nents, fake_storep, rest * scsi_debug_sector_size, (num - rest) * scsi_debug_sector_size); } return ret; } /* If fake_store(lba,num) compares equal to arr(num), then copy top half of * arr into fake_store(lba,num) and return true. If comparison fails then * return false. */ static bool comp_write_worker(u64 lba, u32 num, const u8 *arr) { bool res; u64 block, rest = 0; u32 store_blks = sdebug_store_sectors; u32 lb_size = scsi_debug_sector_size; block = do_div(lba, store_blks); if (block + num > store_blks) rest = block + num - store_blks; res = !memcmp(fake_storep + (block * lb_size), arr, (num - rest) * lb_size); if (!res) return res; if (rest) res = memcmp(fake_storep, arr + ((num - rest) * lb_size), rest * lb_size); if (!res) return res; arr += num * lb_size; memcpy(fake_storep + (block * lb_size), arr, (num - rest) * lb_size); if (rest) memcpy(fake_storep, arr + ((num - rest) * lb_size), rest * lb_size); return res; } static __be16 dif_compute_csum(const void *buf, int len) { __be16 csum; if (scsi_debug_guard) csum = (__force __be16)ip_compute_csum(buf, len); else csum = cpu_to_be16(crc_t10dif(buf, len)); return csum; } static int dif_verify(struct sd_dif_tuple *sdt, const void *data, sector_t sector, u32 ei_lba) { __be16 csum = dif_compute_csum(data, scsi_debug_sector_size); if (sdt->guard_tag != csum) { pr_err("%s: GUARD check failed on sector %lu rcvd 0x%04x, data 0x%04x\n", __func__, (unsigned long)sector, be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); return 0x01; } if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION && be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) { pr_err("%s: REF check failed on sector %lu\n", __func__, (unsigned long)sector); return 0x03; } if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && be32_to_cpu(sdt->ref_tag) != ei_lba) { pr_err("%s: REF check failed on sector %lu\n", __func__, (unsigned long)sector); return 0x03; } return 0; } static void dif_copy_prot(struct scsi_cmnd *SCpnt, sector_t sector, unsigned int sectors, bool read) { size_t resid; void *paddr; const void *dif_store_end = dif_storep + sdebug_store_sectors; struct sg_mapping_iter miter; /* Bytes of protection data to copy into sgl */ resid = sectors * sizeof(*dif_storep); sg_miter_start(&miter, scsi_prot_sglist(SCpnt), scsi_prot_sg_count(SCpnt), SG_MITER_ATOMIC | (read ? SG_MITER_TO_SG : SG_MITER_FROM_SG)); while (sg_miter_next(&miter) && resid > 0) { size_t len = min(miter.length, resid); void *start = dif_store(sector); size_t rest = 0; if (dif_store_end < start + len) rest = start + len - dif_store_end; paddr = miter.addr; if (read) memcpy(paddr, start, len - rest); else memcpy(start, paddr, len - rest); if (rest) { if (read) memcpy(paddr + len - rest, dif_storep, rest); else memcpy(dif_storep, paddr + len - rest, rest); } sector += len / sizeof(*dif_storep); resid -= len; } sg_miter_stop(&miter); } static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, unsigned int sectors, u32 ei_lba) { unsigned int i; struct sd_dif_tuple *sdt; sector_t sector; for (i = 0; i < sectors; i++, ei_lba++) { int ret; sector = start_sec + i; sdt = dif_store(sector); if (sdt->app_tag == cpu_to_be16(0xffff)) continue; ret = dif_verify(sdt, fake_store(sector), sector, ei_lba); if (ret) { dif_errors++; return ret; } } dif_copy_prot(SCpnt, start_sec, sectors, true); dix_reads++; return 0; } static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u64 lba; u32 num; u32 ei_lba; unsigned long iflags; int ret; bool check_prot; switch (cmd[0]) { case READ_16: ei_lba = 0; lba = get_unaligned_be64(cmd + 2); num = get_unaligned_be32(cmd + 10); check_prot = true; break; case READ_10: ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); check_prot = true; break; case READ_6: ei_lba = 0; lba = (u32)cmd[3] | (u32)cmd[2] << 8 | (u32)(cmd[1] & 0x1f) << 16; num = (0 == cmd[4]) ? 256 : cmd[4]; check_prot = true; break; case READ_12: ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be32(cmd + 6); check_prot = true; break; case XDWRITEREAD_10: ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); check_prot = false; break; default: /* assume READ(32) */ lba = get_unaligned_be64(cmd + 12); ei_lba = get_unaligned_be32(cmd + 20); num = get_unaligned_be32(cmd + 28); check_prot = false; break; } if (check_prot) { if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && (cmd[1] & 0xe0)) { mk_sense_invalid_opcode(scp); return check_condition_result; } if ((scsi_debug_dif == SD_DIF_TYPE1_PROTECTION || scsi_debug_dif == SD_DIF_TYPE3_PROTECTION) && (cmd[1] & 0xe0) == 0) sdev_printk(KERN_ERR, scp->device, "Unprotected RD " "to DIF device\n"); } if (sdebug_any_injecting_opt) { struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); if (ep->inj_short) num /= 2; } /* inline check_device_access_params() */ if (lba + num > sdebug_capacity) { mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); return check_condition_result; } /* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) { /* needs work to find which cdb byte 'num' comes from */ mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); return check_condition_result; } if ((SCSI_DEBUG_OPT_MEDIUM_ERR & scsi_debug_opts) && (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) && ((lba + num) > OPT_MEDIUM_ERR_ADDR)) { /* claim unrecoverable read error */ mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); /* set info field and valid bit for fixed descriptor */ if (0x70 == (scp->sense_buffer[0] & 0x7f)) { scp->sense_buffer[0] |= 0x80; /* Valid bit */ ret = (lba < OPT_MEDIUM_ERR_ADDR) ? OPT_MEDIUM_ERR_ADDR : (int)lba; put_unaligned_be32(ret, scp->sense_buffer + 3); } scsi_set_resid(scp, scsi_bufflen(scp)); return check_condition_result; } read_lock_irqsave(&atomic_rw, iflags); /* DIX + T10 DIF */ if (scsi_debug_dix && scsi_prot_sg_count(scp)) { int prot_ret = prot_verify_read(scp, lba, num, ei_lba); if (prot_ret) { read_unlock_irqrestore(&atomic_rw, iflags); mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, prot_ret); return illegal_condition_result; } } ret = do_device_access(scp, lba, num, false); read_unlock_irqrestore(&atomic_rw, iflags); if (ret == -1) return DID_ERROR << 16; scsi_in(scp)->resid = scsi_bufflen(scp) - ret; if (sdebug_any_injecting_opt) { struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); if (ep->inj_recovered) { mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); return check_condition_result; } else if (ep->inj_transport) { mk_sense_buffer(scp, ABORTED_COMMAND, TRANSPORT_PROBLEM, ACK_NAK_TO); return check_condition_result; } else if (ep->inj_dif) { /* Logical block guard check failed */ mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); return illegal_condition_result; } else if (ep->inj_dix) { mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); return illegal_condition_result; } } return 0; } void dump_sector(unsigned char *buf, int len) { int i, j, n; pr_err(">>> Sector Dump <<<\n"); for (i = 0 ; i < len ; i += 16) { char b[128]; for (j = 0, n = 0; j < 16; j++) { unsigned char c = buf[i+j]; if (c >= 0x20 && c < 0x7e) n += scnprintf(b + n, sizeof(b) - n, " %c ", buf[i+j]); else n += scnprintf(b + n, sizeof(b) - n, "%02x ", buf[i+j]); } pr_err("%04d: %s\n", i, b); } } static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, unsigned int sectors, u32 ei_lba) { int ret; struct sd_dif_tuple *sdt; void *daddr; sector_t sector = start_sec; int ppage_offset; int dpage_offset; struct sg_mapping_iter diter; struct sg_mapping_iter piter; BUG_ON(scsi_sg_count(SCpnt) == 0); BUG_ON(scsi_prot_sg_count(SCpnt) == 0); sg_miter_start(&piter, scsi_prot_sglist(SCpnt), scsi_prot_sg_count(SCpnt), SG_MITER_ATOMIC | SG_MITER_FROM_SG); sg_miter_start(&diter, scsi_sglist(SCpnt), scsi_sg_count(SCpnt), SG_MITER_ATOMIC | SG_MITER_FROM_SG); /* For each protection page */ while (sg_miter_next(&piter)) { dpage_offset = 0; if (WARN_ON(!sg_miter_next(&diter))) { ret = 0x01; goto out; } for (ppage_offset = 0; ppage_offset < piter.length; ppage_offset += sizeof(struct sd_dif_tuple)) { /* If we're at the end of the current * data page advance to the next one */ if (dpage_offset >= diter.length) { if (WARN_ON(!sg_miter_next(&diter))) { ret = 0x01; goto out; } dpage_offset = 0; } sdt = piter.addr + ppage_offset; daddr = diter.addr + dpage_offset; ret = dif_verify(sdt, daddr, sector, ei_lba); if (ret) { dump_sector(daddr, scsi_debug_sector_size); goto out; } sector++; ei_lba++; dpage_offset += scsi_debug_sector_size; } diter.consumed = dpage_offset; sg_miter_stop(&diter); } sg_miter_stop(&piter); dif_copy_prot(SCpnt, start_sec, sectors, false); dix_writes++; return 0; out: dif_errors++; sg_miter_stop(&diter); sg_miter_stop(&piter); return ret; } static unsigned long lba_to_map_index(sector_t lba) { if (scsi_debug_unmap_alignment) { lba += scsi_debug_unmap_granularity - scsi_debug_unmap_alignment; } do_div(lba, scsi_debug_unmap_granularity); return lba; } static sector_t map_index_to_lba(unsigned long index) { sector_t lba = index * scsi_debug_unmap_granularity; if (scsi_debug_unmap_alignment) { lba -= scsi_debug_unmap_granularity - scsi_debug_unmap_alignment; } return lba; } static unsigned int map_state(sector_t lba, unsigned int *num) { sector_t end; unsigned int mapped; unsigned long index; unsigned long next; index = lba_to_map_index(lba); mapped = test_bit(index, map_storep); if (mapped) next = find_next_zero_bit(map_storep, map_size, index); else next = find_next_bit(map_storep, map_size, index); end = min_t(sector_t, sdebug_store_sectors, map_index_to_lba(next)); *num = end - lba; return mapped; } static void map_region(sector_t lba, unsigned int len) { sector_t end = lba + len; while (lba < end) { unsigned long index = lba_to_map_index(lba); if (index < map_size) set_bit(index, map_storep); lba = map_index_to_lba(index + 1); } } static void unmap_region(sector_t lba, unsigned int len) { sector_t end = lba + len; while (lba < end) { unsigned long index = lba_to_map_index(lba); if (lba == map_index_to_lba(index) && lba + scsi_debug_unmap_granularity <= end && index < map_size) { clear_bit(index, map_storep); if (scsi_debug_lbprz) { memset(fake_storep + lba * scsi_debug_sector_size, 0, scsi_debug_sector_size * scsi_debug_unmap_granularity); } if (dif_storep) { memset(dif_storep + lba, 0xff, sizeof(*dif_storep) * scsi_debug_unmap_granularity); } } lba = map_index_to_lba(index + 1); } } static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u64 lba; u32 num; u32 ei_lba; unsigned long iflags; int ret; bool check_prot; switch (cmd[0]) { case WRITE_16: ei_lba = 0; lba = get_unaligned_be64(cmd + 2); num = get_unaligned_be32(cmd + 10); check_prot = true; break; case WRITE_10: ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); check_prot = true; break; case WRITE_6: ei_lba = 0; lba = (u32)cmd[3] | (u32)cmd[2] << 8 | (u32)(cmd[1] & 0x1f) << 16; num = (0 == cmd[4]) ? 256 : cmd[4]; check_prot = true; break; case WRITE_12: ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be32(cmd + 6); check_prot = true; break; case 0x53: /* XDWRITEREAD(10) */ ei_lba = 0; lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); check_prot = false; break; default: /* assume WRITE(32) */ lba = get_unaligned_be64(cmd + 12); ei_lba = get_unaligned_be32(cmd + 20); num = get_unaligned_be32(cmd + 28); check_prot = false; break; } if (check_prot) { if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && (cmd[1] & 0xe0)) { mk_sense_invalid_opcode(scp); return check_condition_result; } if ((scsi_debug_dif == SD_DIF_TYPE1_PROTECTION || scsi_debug_dif == SD_DIF_TYPE3_PROTECTION) && (cmd[1] & 0xe0) == 0) sdev_printk(KERN_ERR, scp->device, "Unprotected WR " "to DIF device\n"); } /* inline check_device_access_params() */ if (lba + num > sdebug_capacity) { mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); return check_condition_result; } /* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) { /* needs work to find which cdb byte 'num' comes from */ mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); return check_condition_result; } write_lock_irqsave(&atomic_rw, iflags); /* DIX + T10 DIF */ if (scsi_debug_dix && scsi_prot_sg_count(scp)) { int prot_ret = prot_verify_write(scp, lba, num, ei_lba); if (prot_ret) { write_unlock_irqrestore(&atomic_rw, iflags); mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, prot_ret); return illegal_condition_result; } } ret = do_device_access(scp, lba, num, true); if (scsi_debug_lbp()) map_region(lba, num); write_unlock_irqrestore(&atomic_rw, iflags); if (-1 == ret) return (DID_ERROR << 16); else if ((ret < (num * scsi_debug_sector_size)) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, scp->device, "%s: write: cdb indicated=%u, IO sent=%d bytes\n", my_name, num * scsi_debug_sector_size, ret); if (sdebug_any_injecting_opt) { struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); if (ep->inj_recovered) { mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); return check_condition_result; } else if (ep->inj_dif) { /* Logical block guard check failed */ mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); return illegal_condition_result; } else if (ep->inj_dix) { mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); return illegal_condition_result; } } return 0; } static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, u32 ei_lba, bool unmap, bool ndob) { unsigned long iflags; unsigned long long i; int ret; ret = check_device_access_params(scp, lba, num); if (ret) return ret; write_lock_irqsave(&atomic_rw, iflags); if (unmap && scsi_debug_lbp()) { unmap_region(lba, num); goto out; } /* if ndob then zero 1 logical block, else fetch 1 logical block */ if (ndob) { memset(fake_storep + (lba * scsi_debug_sector_size), 0, scsi_debug_sector_size); ret = 0; } else ret = fetch_to_dev_buffer(scp, fake_storep + (lba * scsi_debug_sector_size), scsi_debug_sector_size); if (-1 == ret) { write_unlock_irqrestore(&atomic_rw, iflags); return (DID_ERROR << 16); } else if ((ret < (num * scsi_debug_sector_size)) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, scp->device, "%s: %s: cdb indicated=%u, IO sent=%d bytes\n", my_name, "write same", num * scsi_debug_sector_size, ret); /* Copy first sector to remaining blocks */ for (i = 1 ; i < num ; i++) memcpy(fake_storep + ((lba + i) * scsi_debug_sector_size), fake_storep + (lba * scsi_debug_sector_size), scsi_debug_sector_size); if (scsi_debug_lbp()) map_region(lba, num); out: write_unlock_irqrestore(&atomic_rw, iflags); return 0; } static int resp_write_same_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u32 lba; u16 num; u32 ei_lba = 0; bool unmap = false; if (cmd[1] & 0x8) { if (scsi_debug_lbpws10 == 0) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); return check_condition_result; } else unmap = true; } lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); if (num > scsi_debug_write_same_length) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); return check_condition_result; } return resp_write_same(scp, lba, num, ei_lba, unmap, false); } static int resp_write_same_16(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u64 lba; u32 num; u32 ei_lba = 0; bool unmap = false; bool ndob = false; if (cmd[1] & 0x8) { /* UNMAP */ if (scsi_debug_lbpws == 0) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); return check_condition_result; } else unmap = true; } if (cmd[1] & 0x1) /* NDOB (no data-out buffer, assumes zeroes) */ ndob = true; lba = get_unaligned_be64(cmd + 2); num = get_unaligned_be32(cmd + 10); if (num > scsi_debug_write_same_length) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); return check_condition_result; } return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); } static int resp_comp_write(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u8 *arr; u8 *fake_storep_hold; u64 lba; u32 dnum; u32 lb_size = scsi_debug_sector_size; u8 num; unsigned long iflags; int ret; lba = get_unaligned_be32(cmd + 2); num = cmd[13]; /* 1 to a maximum of 255 logical blocks */ if (0 == num) return 0; /* degenerate case, not an error */ dnum = 2 * num; arr = kzalloc(dnum * lb_size, GFP_ATOMIC); if (NULL == arr) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ); return check_condition_result; } if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && (cmd[1] & 0xe0)) { mk_sense_invalid_opcode(scp); return check_condition_result; } if ((scsi_debug_dif == SD_DIF_TYPE1_PROTECTION || scsi_debug_dif == SD_DIF_TYPE3_PROTECTION) && (cmd[1] & 0xe0) == 0) sdev_printk(KERN_ERR, scp->device, "Unprotected WR " "to DIF device\n"); /* inline check_device_access_params() */ if (lba + num > sdebug_capacity) { mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); return check_condition_result; } /* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) { /* needs work to find which cdb byte 'num' comes from */ mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); return check_condition_result; } write_lock_irqsave(&atomic_rw, iflags); /* trick do_device_access() to fetch both compare and write buffers * from data-in into arr. Safe (atomic) since write_lock held. */ fake_storep_hold = fake_storep; fake_storep = arr; ret = do_device_access(scp, 0, dnum, true); fake_storep = fake_storep_hold; if (ret == -1) { write_unlock_irqrestore(&atomic_rw, iflags); kfree(arr); return DID_ERROR << 16; } else if ((ret < (dnum * lb_size)) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " "indicated=%u, IO sent=%d bytes\n", my_name, dnum * lb_size, ret); if (!comp_write_worker(lba, num, arr)) { write_unlock_irqrestore(&atomic_rw, iflags); kfree(arr); mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); return check_condition_result; } if (scsi_debug_lbp()) map_region(lba, num); write_unlock_irqrestore(&atomic_rw, iflags); return 0; } struct unmap_block_desc { __be64 lba; __be32 blocks; __be32 __reserved; }; static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { unsigned char *buf; struct unmap_block_desc *desc; unsigned int i, payload_len, descriptors; int ret; unsigned long iflags; if (!scsi_debug_lbp()) return 0; /* fib and say its done */ payload_len = get_unaligned_be16(scp->cmnd + 7); BUG_ON(scsi_bufflen(scp) != payload_len); descriptors = (payload_len - 8) / 16; if (descriptors > scsi_debug_unmap_max_desc) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); return check_condition_result; } buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); if (!buf) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ); return check_condition_result; } scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); BUG_ON(get_unaligned_be16(&buf[0]) != payload_len - 2); BUG_ON(get_unaligned_be16(&buf[2]) != descriptors * 16); desc = (void *)&buf[8]; write_lock_irqsave(&atomic_rw, iflags); for (i = 0 ; i < descriptors ; i++) { unsigned long long lba = get_unaligned_be64(&desc[i].lba); unsigned int num = get_unaligned_be32(&desc[i].blocks); ret = check_device_access_params(scp, lba, num); if (ret) goto out; unmap_region(lba, num); } ret = 0; out: write_unlock_irqrestore(&atomic_rw, iflags); kfree(buf); return ret; } #define SDEBUG_GET_LBA_STATUS_LEN 32 static int resp_get_lba_status(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u64 lba; u32 alloc_len, mapped, num; u8 arr[SDEBUG_GET_LBA_STATUS_LEN]; int ret; lba = get_unaligned_be64(cmd + 2); alloc_len = get_unaligned_be32(cmd + 10); if (alloc_len < 24) return 0; ret = check_device_access_params(scp, lba, 1); if (ret) return ret; if (scsi_debug_lbp()) mapped = map_state(lba, &num); else { mapped = 1; /* following just in case virtual_gb changed */ sdebug_capacity = get_sdebug_capacity(); if (sdebug_capacity - lba <= 0xffffffff) num = sdebug_capacity - lba; else num = 0xffffffff; } memset(arr, 0, SDEBUG_GET_LBA_STATUS_LEN); put_unaligned_be32(20, arr); /* Parameter Data Length */ put_unaligned_be64(lba, arr + 8); /* LBA */ put_unaligned_be32(num, arr + 16); /* Number of blocks */ arr[20] = !mapped; /* prov_stat=0: mapped; 1: dealloc */ return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); } #define SDEBUG_RLUN_ARR_SZ 256 static int resp_report_luns(struct scsi_cmnd * scp, struct sdebug_dev_info * devip) { unsigned int alloc_len; int lun_cnt, i, upper, num, n, want_wlun, shortish; u64 lun; unsigned char *cmd = scp->cmnd; int select_report = (int)cmd[2]; struct scsi_lun *one_lun; unsigned char arr[SDEBUG_RLUN_ARR_SZ]; unsigned char * max_addr; alloc_len = cmd[9] + (cmd[8] << 8) + (cmd[7] << 16) + (cmd[6] << 24); shortish = (alloc_len < 4); if (shortish || (select_report > 2)) { mk_sense_invalid_fld(scp, SDEB_IN_CDB, shortish ? 6 : 2, -1); return check_condition_result; } /* can produce response with up to 16k luns (lun 0 to lun 16383) */ memset(arr, 0, SDEBUG_RLUN_ARR_SZ); lun_cnt = scsi_debug_max_luns; if (1 == select_report) lun_cnt = 0; else if (scsi_debug_no_lun_0 && (lun_cnt > 0)) --lun_cnt; want_wlun = (select_report > 0) ? 1 : 0; num = lun_cnt + want_wlun; arr[2] = ((sizeof(struct scsi_lun) * num) >> 8) & 0xff; arr[3] = (sizeof(struct scsi_lun) * num) & 0xff; n = min((int)((SDEBUG_RLUN_ARR_SZ - 8) / sizeof(struct scsi_lun)), num); if (n < num) { want_wlun = 0; lun_cnt = n; } one_lun = (struct scsi_lun *) &arr[8]; max_addr = arr + SDEBUG_RLUN_ARR_SZ; for (i = 0, lun = (scsi_debug_no_lun_0 ? 1 : 0); ((i < lun_cnt) && ((unsigned char *)(one_lun + i) < max_addr)); i++, lun++) { upper = (lun >> 8) & 0x3f; if (upper) one_lun[i].scsi_lun[0] = (upper | (SAM2_LUN_ADDRESS_METHOD << 6)); one_lun[i].scsi_lun[1] = lun & 0xff; } if (want_wlun) { one_lun[i].scsi_lun[0] = (SAM2_WLUN_REPORT_LUNS >> 8) & 0xff; one_lun[i].scsi_lun[1] = SAM2_WLUN_REPORT_LUNS & 0xff; i++; } alloc_len = (unsigned char *)(one_lun + i) - arr; return fill_from_dev_buffer(scp, arr, min((int)alloc_len, SDEBUG_RLUN_ARR_SZ)); } static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba, unsigned int num, struct sdebug_dev_info *devip) { int j; unsigned char *kaddr, *buf; unsigned int offset; struct scsi_data_buffer *sdb = scsi_in(scp); struct sg_mapping_iter miter; /* better not to use temporary buffer. */ buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); if (!buf) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ); return check_condition_result; } scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); offset = 0; sg_miter_start(&miter, sdb->table.sgl, sdb->table.nents, SG_MITER_ATOMIC | SG_MITER_TO_SG); while (sg_miter_next(&miter)) { kaddr = miter.addr; for (j = 0; j < miter.length; j++) *(kaddr + j) ^= *(buf + offset + j); offset += miter.length; } sg_miter_stop(&miter); kfree(buf); return 0; } static int resp_xdwriteread_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { u8 *cmd = scp->cmnd; u64 lba; u32 num; int errsts; if (!scsi_bidi_cmnd(scp)) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ); return check_condition_result; } errsts = resp_read_dt0(scp, devip); if (errsts) return errsts; if (!(cmd[1] & 0x4)) { /* DISABLE_WRITE is not set */ errsts = resp_write_dt0(scp, devip); if (errsts) return errsts; } lba = get_unaligned_be32(cmd + 2); num = get_unaligned_be16(cmd + 7); return resp_xdwriteread(scp, lba, num, devip); } /* When timer or tasklet goes off this function is called. */ static void sdebug_q_cmd_complete(unsigned long indx) { int qa_indx; int retiring = 0; unsigned long iflags; struct sdebug_queued_cmd *sqcp; struct scsi_cmnd *scp; struct sdebug_dev_info *devip; atomic_inc(&sdebug_completions); qa_indx = indx; if ((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE)) { pr_err("%s: wild qa_indx=%d\n", __func__, qa_indx); return; } spin_lock_irqsave(&queued_arr_lock, iflags); sqcp = &queued_arr[qa_indx]; scp = sqcp->a_cmnd; if (NULL == scp) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: scp is NULL\n", __func__); return; } devip = (struct sdebug_dev_info *)scp->device->hostdata; if (devip) atomic_dec(&devip->num_in_q); else pr_err("%s: devip=NULL\n", __func__); if (atomic_read(&retired_max_queue) > 0) retiring = 1; sqcp->a_cmnd = NULL; if (!test_and_clear_bit(qa_indx, queued_in_use_bm)) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: Unexpected completion\n", __func__); return; } if (unlikely(retiring)) { /* user has reduced max_queue */ int k, retval; retval = atomic_read(&retired_max_queue); if (qa_indx >= retval) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: index %d too large\n", __func__, retval); return; } k = find_last_bit(queued_in_use_bm, retval); if ((k < scsi_debug_max_queue) || (k == retval)) atomic_set(&retired_max_queue, 0); else atomic_set(&retired_max_queue, k + 1); } spin_unlock_irqrestore(&queued_arr_lock, iflags); scp->scsi_done(scp); /* callback to mid level */ } /* When high resolution timer goes off this function is called. */ static enum hrtimer_restart sdebug_q_cmd_hrt_complete(struct hrtimer *timer) { int qa_indx; int retiring = 0; unsigned long iflags; struct sdebug_hrtimer *sd_hrtp = (struct sdebug_hrtimer *)timer; struct sdebug_queued_cmd *sqcp; struct scsi_cmnd *scp; struct sdebug_dev_info *devip; atomic_inc(&sdebug_completions); qa_indx = sd_hrtp->qa_indx; if ((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE)) { pr_err("%s: wild qa_indx=%d\n", __func__, qa_indx); goto the_end; } spin_lock_irqsave(&queued_arr_lock, iflags); sqcp = &queued_arr[qa_indx]; scp = sqcp->a_cmnd; if (NULL == scp) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: scp is NULL\n", __func__); goto the_end; } devip = (struct sdebug_dev_info *)scp->device->hostdata; if (devip) atomic_dec(&devip->num_in_q); else pr_err("%s: devip=NULL\n", __func__); if (atomic_read(&retired_max_queue) > 0) retiring = 1; sqcp->a_cmnd = NULL; if (!test_and_clear_bit(qa_indx, queued_in_use_bm)) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: Unexpected completion\n", __func__); goto the_end; } if (unlikely(retiring)) { /* user has reduced max_queue */ int k, retval; retval = atomic_read(&retired_max_queue); if (qa_indx >= retval) { spin_unlock_irqrestore(&queued_arr_lock, iflags); pr_err("%s: index %d too large\n", __func__, retval); goto the_end; } k = find_last_bit(queued_in_use_bm, retval); if ((k < scsi_debug_max_queue) || (k == retval)) atomic_set(&retired_max_queue, 0); else atomic_set(&retired_max_queue, k + 1); } spin_unlock_irqrestore(&queued_arr_lock, iflags); scp->scsi_done(scp); /* callback to mid level */ the_end: return HRTIMER_NORESTART; } static struct sdebug_dev_info * sdebug_device_create(struct sdebug_host_info *sdbg_host, gfp_t flags) { struct sdebug_dev_info *devip; devip = kzalloc(sizeof(*devip), flags); if (devip) { devip->sdbg_host = sdbg_host; list_add_tail(&devip->dev_list, &sdbg_host->dev_info_list); } return devip; } static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev) { struct sdebug_host_info * sdbg_host; struct sdebug_dev_info * open_devip = NULL; struct sdebug_dev_info * devip = (struct sdebug_dev_info *)sdev->hostdata; if (devip) return devip; sdbg_host = *(struct sdebug_host_info **)shost_priv(sdev->host); if (!sdbg_host) { pr_err("%s: Host info NULL\n", __func__); return NULL; } list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) { if ((devip->used) && (devip->channel == sdev->channel) && (devip->target == sdev->id) && (devip->lun == sdev->lun)) return devip; else { if ((!devip->used) && (!open_devip)) open_devip = devip; } } if (!open_devip) { /* try and make a new one */ open_devip = sdebug_device_create(sdbg_host, GFP_ATOMIC); if (!open_devip) { printk(KERN_ERR "%s: out of memory at line %d\n", __func__, __LINE__); return NULL; } } open_devip->channel = sdev->channel; open_devip->target = sdev->id; open_devip->lun = sdev->lun; open_devip->sdbg_host = sdbg_host; atomic_set(&open_devip->num_in_q, 0); set_bit(SDEBUG_UA_POR, open_devip->uas_bm); open_devip->used = true; return open_devip; } static int scsi_debug_slave_alloc(struct scsi_device *sdp) { if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) printk(KERN_INFO "scsi_debug: slave_alloc <%u %u %u %llu>\n", sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); queue_flag_set_unlocked(QUEUE_FLAG_BIDI, sdp->request_queue); return 0; } static int scsi_debug_slave_configure(struct scsi_device *sdp) { struct sdebug_dev_info *devip; if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) printk(KERN_INFO "scsi_debug: slave_configure <%u %u %u %llu>\n", sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); if (sdp->host->max_cmd_len != SCSI_DEBUG_MAX_CMD_LEN) sdp->host->max_cmd_len = SCSI_DEBUG_MAX_CMD_LEN; devip = devInfoReg(sdp); if (NULL == devip) return 1; /* no resources, will be marked offline */ sdp->hostdata = devip; blk_queue_max_segment_size(sdp->request_queue, -1U); if (scsi_debug_no_uld) sdp->no_uld_attach = 1; return 0; } static void scsi_debug_slave_destroy(struct scsi_device *sdp) { struct sdebug_dev_info *devip = (struct sdebug_dev_info *)sdp->hostdata; if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) printk(KERN_INFO "scsi_debug: slave_destroy <%u %u %u %llu>\n", sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); if (devip) { /* make this slot available for re-use */ devip->used = false; sdp->hostdata = NULL; } } /* Returns 1 if cmnd found (deletes its timer or tasklet), else returns 0 */ static int stop_queued_cmnd(struct scsi_cmnd *cmnd) { unsigned long iflags; int k, qmax, r_qmax; struct sdebug_queued_cmd *sqcp; struct sdebug_dev_info *devip; spin_lock_irqsave(&queued_arr_lock, iflags); qmax = scsi_debug_max_queue; r_qmax = atomic_read(&retired_max_queue); if (r_qmax > qmax) qmax = r_qmax; for (k = 0; k < qmax; ++k) { if (test_bit(k, queued_in_use_bm)) { sqcp = &queued_arr[k]; if (cmnd == sqcp->a_cmnd) { devip = (struct sdebug_dev_info *) cmnd->device->hostdata; if (devip) atomic_dec(&devip->num_in_q); sqcp->a_cmnd = NULL; spin_unlock_irqrestore(&queued_arr_lock, iflags); if (scsi_debug_ndelay > 0) { if (sqcp->sd_hrtp) hrtimer_cancel( &sqcp->sd_hrtp->hrt); } else if (scsi_debug_delay > 0) { if (sqcp->cmnd_timerp) del_timer_sync( sqcp->cmnd_timerp); } else if (scsi_debug_delay < 0) { if (sqcp->tletp) tasklet_kill(sqcp->tletp); } clear_bit(k, queued_in_use_bm); return 1; } } } spin_unlock_irqrestore(&queued_arr_lock, iflags); return 0; } /* Deletes (stops) timers or tasklets of all queued commands */ static void stop_all_queued(void) { unsigned long iflags; int k; struct sdebug_queued_cmd *sqcp; struct sdebug_dev_info *devip; spin_lock_irqsave(&queued_arr_lock, iflags); for (k = 0; k < SCSI_DEBUG_CANQUEUE; ++k) { if (test_bit(k, queued_in_use_bm)) { sqcp = &queued_arr[k]; if (sqcp->a_cmnd) { devip = (struct sdebug_dev_info *) sqcp->a_cmnd->device->hostdata; if (devip) atomic_dec(&devip->num_in_q); sqcp->a_cmnd = NULL; spin_unlock_irqrestore(&queued_arr_lock, iflags); if (scsi_debug_ndelay > 0) { if (sqcp->sd_hrtp) hrtimer_cancel( &sqcp->sd_hrtp->hrt); } else if (scsi_debug_delay > 0) { if (sqcp->cmnd_timerp) del_timer_sync( sqcp->cmnd_timerp); } else if (scsi_debug_delay < 0) { if (sqcp->tletp) tasklet_kill(sqcp->tletp); } clear_bit(k, queued_in_use_bm); spin_lock_irqsave(&queued_arr_lock, iflags); } } } spin_unlock_irqrestore(&queued_arr_lock, iflags); } /* Free queued command memory on heap */ static void free_all_queued(void) { unsigned long iflags; int k; struct sdebug_queued_cmd *sqcp; spin_lock_irqsave(&queued_arr_lock, iflags); for (k = 0; k < SCSI_DEBUG_CANQUEUE; ++k) { sqcp = &queued_arr[k]; kfree(sqcp->cmnd_timerp); sqcp->cmnd_timerp = NULL; kfree(sqcp->tletp); sqcp->tletp = NULL; kfree(sqcp->sd_hrtp); sqcp->sd_hrtp = NULL; } spin_unlock_irqrestore(&queued_arr_lock, iflags); } static int scsi_debug_abort(struct scsi_cmnd *SCpnt) { ++num_aborts; if (SCpnt) { if (SCpnt->device && (SCSI_DEBUG_OPT_ALL_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__); stop_queued_cmnd(SCpnt); } return SUCCESS; } static int scsi_debug_device_reset(struct scsi_cmnd * SCpnt) { struct sdebug_dev_info * devip; ++num_dev_resets; if (SCpnt && SCpnt->device) { struct scsi_device *sdp = SCpnt->device; if (SCSI_DEBUG_OPT_ALL_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s\n", __func__); devip = devInfoReg(sdp); if (devip) set_bit(SDEBUG_UA_POR, devip->uas_bm); } return SUCCESS; } static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt) { struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *devip; struct scsi_device *sdp; struct Scsi_Host *hp; int k = 0; ++num_target_resets; if (!SCpnt) goto lie; sdp = SCpnt->device; if (!sdp) goto lie; if (SCSI_DEBUG_OPT_ALL_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s\n", __func__); hp = sdp->host; if (!hp) goto lie; sdbg_host = *(struct sdebug_host_info **)shost_priv(hp); if (sdbg_host) { list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) if (devip->target == sdp->id) { set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); ++k; } } if (SCSI_DEBUG_OPT_RESET_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s: %d device(s) found in target\n", __func__, k); lie: return SUCCESS; } static int scsi_debug_bus_reset(struct scsi_cmnd * SCpnt) { struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *devip; struct scsi_device * sdp; struct Scsi_Host * hp; int k = 0; ++num_bus_resets; if (!(SCpnt && SCpnt->device)) goto lie; sdp = SCpnt->device; if (SCSI_DEBUG_OPT_ALL_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s\n", __func__); hp = sdp->host; if (hp) { sdbg_host = *(struct sdebug_host_info **)shost_priv(hp); if (sdbg_host) { list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) { set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); ++k; } } } if (SCSI_DEBUG_OPT_RESET_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s: %d device(s) found in host\n", __func__, k); lie: return SUCCESS; } static int scsi_debug_host_reset(struct scsi_cmnd * SCpnt) { struct sdebug_host_info * sdbg_host; struct sdebug_dev_info *devip; int k = 0; ++num_host_resets; if ((SCpnt->device) && (SCSI_DEBUG_OPT_ALL_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__); spin_lock(&sdebug_host_list_lock); list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) { list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) { set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); ++k; } } spin_unlock(&sdebug_host_list_lock); stop_all_queued(); if (SCSI_DEBUG_OPT_RESET_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, SCpnt->device, "%s: %d device(s) found\n", __func__, k); return SUCCESS; } static void __init sdebug_build_parts(unsigned char *ramp, unsigned long store_size) { struct partition * pp; int starts[SDEBUG_MAX_PARTS + 2]; int sectors_per_part, num_sectors, k; int heads_by_sects, start_sec, end_sec; /* assume partition table already zeroed */ if ((scsi_debug_num_parts < 1) || (store_size < 1048576)) return; if (scsi_debug_num_parts > SDEBUG_MAX_PARTS) { scsi_debug_num_parts = SDEBUG_MAX_PARTS; pr_warn("%s: reducing partitions to %d\n", __func__, SDEBUG_MAX_PARTS); } num_sectors = (int)sdebug_store_sectors; sectors_per_part = (num_sectors - sdebug_sectors_per) / scsi_debug_num_parts; heads_by_sects = sdebug_heads * sdebug_sectors_per; starts[0] = sdebug_sectors_per; for (k = 1; k < scsi_debug_num_parts; ++k) starts[k] = ((k * sectors_per_part) / heads_by_sects) * heads_by_sects; starts[scsi_debug_num_parts] = num_sectors; starts[scsi_debug_num_parts + 1] = 0; ramp[510] = 0x55; /* magic partition markings */ ramp[511] = 0xAA; pp = (struct partition *)(ramp + 0x1be); for (k = 0; starts[k + 1]; ++k, ++pp) { start_sec = starts[k]; end_sec = starts[k + 1] - 1; pp->boot_ind = 0; pp->cyl = start_sec / heads_by_sects; pp->head = (start_sec - (pp->cyl * heads_by_sects)) / sdebug_sectors_per; pp->sector = (start_sec % sdebug_sectors_per) + 1; pp->end_cyl = end_sec / heads_by_sects; pp->end_head = (end_sec - (pp->end_cyl * heads_by_sects)) / sdebug_sectors_per; pp->end_sector = (end_sec % sdebug_sectors_per) + 1; pp->start_sect = cpu_to_le32(start_sec); pp->nr_sects = cpu_to_le32(end_sec - start_sec + 1); pp->sys_ind = 0x83; /* plain Linux partition */ } } static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip, int scsi_result, int delta_jiff) { unsigned long iflags; int k, num_in_q, qdepth, inject; struct sdebug_queued_cmd *sqcp = NULL; struct scsi_device *sdp = cmnd->device; if (NULL == cmnd || NULL == devip) { pr_warn("%s: called with NULL cmnd or devip pointer\n", __func__); /* no particularly good error to report back */ return SCSI_MLQUEUE_HOST_BUSY; } if ((scsi_result) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, sdp, "%s: non-zero result=0x%x\n", __func__, scsi_result); if (delta_jiff == 0) goto respond_in_thread; /* schedule the response at a later time if resources permit */ spin_lock_irqsave(&queued_arr_lock, iflags); num_in_q = atomic_read(&devip->num_in_q); qdepth = cmnd->device->queue_depth; inject = 0; if ((qdepth > 0) && (num_in_q >= qdepth)) { if (scsi_result) { spin_unlock_irqrestore(&queued_arr_lock, iflags); goto respond_in_thread; } else scsi_result = device_qfull_result; } else if ((scsi_debug_every_nth != 0) && (SCSI_DEBUG_OPT_RARE_TSF & scsi_debug_opts) && (scsi_result == 0)) { if ((num_in_q == (qdepth - 1)) && (atomic_inc_return(&sdebug_a_tsf) >= abs(scsi_debug_every_nth))) { atomic_set(&sdebug_a_tsf, 0); inject = 1; scsi_result = device_qfull_result; } } k = find_first_zero_bit(queued_in_use_bm, scsi_debug_max_queue); if (k >= scsi_debug_max_queue) { spin_unlock_irqrestore(&queued_arr_lock, iflags); if (scsi_result) goto respond_in_thread; else if (SCSI_DEBUG_OPT_ALL_TSF & scsi_debug_opts) scsi_result = device_qfull_result; if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) sdev_printk(KERN_INFO, sdp, "%s: max_queue=%d exceeded, %s\n", __func__, scsi_debug_max_queue, (scsi_result ? "status: TASK SET FULL" : "report: host busy")); if (scsi_result) goto respond_in_thread; else return SCSI_MLQUEUE_HOST_BUSY; } __set_bit(k, queued_in_use_bm); atomic_inc(&devip->num_in_q); sqcp = &queued_arr[k]; sqcp->a_cmnd = cmnd; cmnd->result = scsi_result; spin_unlock_irqrestore(&queued_arr_lock, iflags); if (delta_jiff > 0) { if (NULL == sqcp->cmnd_timerp) { sqcp->cmnd_timerp = kmalloc(sizeof(struct timer_list), GFP_ATOMIC); if (NULL == sqcp->cmnd_timerp) return SCSI_MLQUEUE_HOST_BUSY; init_timer(sqcp->cmnd_timerp); } sqcp->cmnd_timerp->function = sdebug_q_cmd_complete; sqcp->cmnd_timerp->data = k; sqcp->cmnd_timerp->expires = get_jiffies_64() + delta_jiff; add_timer(sqcp->cmnd_timerp); } else if (scsi_debug_ndelay > 0) { ktime_t kt = ktime_set(0, scsi_debug_ndelay); struct sdebug_hrtimer *sd_hp = sqcp->sd_hrtp; if (NULL == sd_hp) { sd_hp = kmalloc(sizeof(*sd_hp), GFP_ATOMIC); if (NULL == sd_hp) return SCSI_MLQUEUE_HOST_BUSY; sqcp->sd_hrtp = sd_hp; hrtimer_init(&sd_hp->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); sd_hp->hrt.function = sdebug_q_cmd_hrt_complete; sd_hp->qa_indx = k; } hrtimer_start(&sd_hp->hrt, kt, HRTIMER_MODE_REL); } else { /* delay < 0 */ if (NULL == sqcp->tletp) { sqcp->tletp = kmalloc(sizeof(*sqcp->tletp), GFP_ATOMIC); if (NULL == sqcp->tletp) return SCSI_MLQUEUE_HOST_BUSY; tasklet_init(sqcp->tletp, sdebug_q_cmd_complete, k); } if (-1 == delta_jiff) tasklet_hi_schedule(sqcp->tletp); else tasklet_schedule(sqcp->tletp); } if ((SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) && (scsi_result == device_qfull_result)) sdev_printk(KERN_INFO, sdp, "%s: num_in_q=%d +1, %s%s\n", __func__, num_in_q, (inject ? "<inject> " : ""), "status: TASK SET FULL"); return 0; respond_in_thread: /* call back to mid-layer using invocation thread */ cmnd->result = scsi_result; cmnd->scsi_done(cmnd); return 0; } /* Note: The following macros create attribute files in the /sys/module/scsi_debug/parameters directory. Unfortunately this driver is unaware of a change and cannot trigger auxiliary actions as it can when the corresponding attribute in the /sys/bus/pseudo/drivers/scsi_debug directory is changed. */ module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); module_param_named(ato, scsi_debug_ato, int, S_IRUGO); module_param_named(clustering, scsi_debug_clustering, bool, S_IRUGO | S_IWUSR); module_param_named(delay, scsi_debug_delay, int, S_IRUGO | S_IWUSR); module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, S_IRUGO); module_param_named(dif, scsi_debug_dif, int, S_IRUGO); module_param_named(dix, scsi_debug_dix, int, S_IRUGO); module_param_named(dsense, scsi_debug_dsense, int, S_IRUGO | S_IWUSR); module_param_named(every_nth, scsi_debug_every_nth, int, S_IRUGO | S_IWUSR); module_param_named(fake_rw, scsi_debug_fake_rw, int, S_IRUGO | S_IWUSR); module_param_named(guard, scsi_debug_guard, uint, S_IRUGO); module_param_named(host_lock, scsi_debug_host_lock, bool, S_IRUGO | S_IWUSR); module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO); module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO); module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO); module_param_named(lbprz, scsi_debug_lbprz, int, S_IRUGO); module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR); module_param_named(ndelay, scsi_debug_ndelay, int, S_IRUGO | S_IWUSR); module_param_named(no_lun_0, scsi_debug_no_lun_0, int, S_IRUGO | S_IWUSR); module_param_named(no_uld, scsi_debug_no_uld, int, S_IRUGO); module_param_named(num_parts, scsi_debug_num_parts, int, S_IRUGO); module_param_named(num_tgts, scsi_debug_num_tgts, int, S_IRUGO | S_IWUSR); module_param_named(opt_blks, scsi_debug_opt_blks, int, S_IRUGO); module_param_named(opts, scsi_debug_opts, int, S_IRUGO | S_IWUSR); module_param_named(physblk_exp, scsi_debug_physblk_exp, int, S_IRUGO); module_param_named(ptype, scsi_debug_ptype, int, S_IRUGO | S_IWUSR); module_param_named(removable, scsi_debug_removable, bool, S_IRUGO | S_IWUSR); module_param_named(scsi_level, scsi_debug_scsi_level, int, S_IRUGO); module_param_named(sector_size, scsi_debug_sector_size, int, S_IRUGO); module_param_named(strict, scsi_debug_strict, bool, S_IRUGO | S_IWUSR); module_param_named(unmap_alignment, scsi_debug_unmap_alignment, int, S_IRUGO); module_param_named(unmap_granularity, scsi_debug_unmap_granularity, int, S_IRUGO); module_param_named(unmap_max_blocks, scsi_debug_unmap_max_blocks, int, S_IRUGO); module_param_named(unmap_max_desc, scsi_debug_unmap_max_desc, int, S_IRUGO); module_param_named(virtual_gb, scsi_debug_virtual_gb, int, S_IRUGO | S_IWUSR); module_param_named(vpd_use_hostno, scsi_debug_vpd_use_hostno, int, S_IRUGO | S_IWUSR); module_param_named(write_same_length, scsi_debug_write_same_length, int, S_IRUGO | S_IWUSR); MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); MODULE_DESCRIPTION("SCSI debug adapter driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(SCSI_DEBUG_VERSION); MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); MODULE_PARM_DESC(ato, "application tag ownership: 0=disk 1=host (def=1)"); MODULE_PARM_DESC(clustering, "when set enables larger transfers (def=0)"); MODULE_PARM_DESC(delay, "response delay (def=1 jiffy); 0:imm, -1,-2:tiny"); MODULE_PARM_DESC(dev_size_mb, "size in MiB of ram shared by devs(def=8)"); MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); MODULE_PARM_DESC(every_nth, "timeout every nth command(def=0)"); MODULE_PARM_DESC(fake_rw, "fake reads/writes instead of copying (def=0)"); MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); MODULE_PARM_DESC(host_lock, "use host_lock around all commands (def=0)"); MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)"); MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)"); MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)"); MODULE_PARM_DESC(lbprz, "unmapped blocks return 0 on read (def=1)"); MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to max(def))"); MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)"); MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)"); MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))"); MODULE_PARM_DESC(num_parts, "number of partitions(def=0)"); MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); MODULE_PARM_DESC(opt_blks, "optimal transfer length in block (def=64)"); MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)"); MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); MODULE_PARM_DESC(removable, "claim to have removable media (def=0)"); MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=6[SPC-4])"); MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); MODULE_PARM_DESC(strict, "stricter checks: reserved field in cdb (def=0)"); MODULE_PARM_DESC(unmap_alignment, "lowest aligned thin provisioning lba (def=0)"); MODULE_PARM_DESC(unmap_granularity, "thin provisioning granularity in blocks (def=1)"); MODULE_PARM_DESC(unmap_max_blocks, "max # of blocks can be unmapped in one cmd (def=0xffffffff)"); MODULE_PARM_DESC(unmap_max_desc, "max # of ranges that can be unmapped in one cmd (def=256)"); MODULE_PARM_DESC(virtual_gb, "virtual gigabyte (GiB) size (def=0 -> use dev_size_mb)"); MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)"); static char sdebug_info[256]; static const char * scsi_debug_info(struct Scsi_Host * shp) { sprintf(sdebug_info, "scsi_debug, version %s [%s], " "dev_size_mb=%d, opts=0x%x", SCSI_DEBUG_VERSION, scsi_debug_version_date, scsi_debug_dev_size_mb, scsi_debug_opts); return sdebug_info; } /* 'echo <val> > /proc/scsi/scsi_debug/<host_id>' writes to opts */ static int scsi_debug_write_info(struct Scsi_Host *host, char *buffer, int length) { char arr[16]; int opts; int minLen = length > 15 ? 15 : length; if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) return -EACCES; memcpy(arr, buffer, minLen); arr[minLen] = '\0'; if (1 != sscanf(arr, "%d", &opts)) return -EINVAL; scsi_debug_opts = opts; if (scsi_debug_every_nth != 0) atomic_set(&sdebug_cmnd_count, 0); return length; } /* Output seen with 'cat /proc/scsi/scsi_debug/<host_id>'. It will be the * same for each scsi_debug host (if more than one). Some of the counters * output are not atomics so might be inaccurate in a busy system. */ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host) { int f, l; char b[32]; if (scsi_debug_every_nth > 0) snprintf(b, sizeof(b), " (curr:%d)", ((SCSI_DEBUG_OPT_RARE_TSF & scsi_debug_opts) ? atomic_read(&sdebug_a_tsf) : atomic_read(&sdebug_cmnd_count))); else b[0] = '\0'; seq_printf(m, "scsi_debug adapter driver, version %s [%s]\n" "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, " "every_nth=%d%s\n" "delay=%d, ndelay=%d, max_luns=%d, q_completions=%d\n" "sector_size=%d bytes, cylinders=%d, heads=%d, sectors=%d\n" "command aborts=%d; RESETs: device=%d, target=%d, bus=%d, " "host=%d\ndix_reads=%d dix_writes=%d dif_errors=%d " "usec_in_jiffy=%lu\n", SCSI_DEBUG_VERSION, scsi_debug_version_date, scsi_debug_num_tgts, scsi_debug_dev_size_mb, scsi_debug_opts, scsi_debug_every_nth, b, scsi_debug_delay, scsi_debug_ndelay, scsi_debug_max_luns, atomic_read(&sdebug_completions), scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads, sdebug_sectors_per, num_aborts, num_dev_resets, num_target_resets, num_bus_resets, num_host_resets, dix_reads, dix_writes, dif_errors, TICK_NSEC / 1000); f = find_first_bit(queued_in_use_bm, scsi_debug_max_queue); if (f != scsi_debug_max_queue) { l = find_last_bit(queued_in_use_bm, scsi_debug_max_queue); seq_printf(m, " %s BUSY: first,last bits set: %d,%d\n", "queued_in_use_bm", f, l); } return 0; } static ssize_t delay_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay); } /* Returns -EBUSY if delay is being changed and commands are queued */ static ssize_t delay_store(struct device_driver *ddp, const char *buf, size_t count) { int delay, res; if ((count > 0) && (1 == sscanf(buf, "%d", &delay))) { res = count; if (scsi_debug_delay != delay) { unsigned long iflags; int k; spin_lock_irqsave(&queued_arr_lock, iflags); k = find_first_bit(queued_in_use_bm, scsi_debug_max_queue); if (k != scsi_debug_max_queue) res = -EBUSY; /* have queued commands */ else { scsi_debug_delay = delay; scsi_debug_ndelay = 0; } spin_unlock_irqrestore(&queued_arr_lock, iflags); } return res; } return -EINVAL; } static DRIVER_ATTR_RW(delay); static ssize_t ndelay_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ndelay); } /* Returns -EBUSY if ndelay is being changed and commands are queued */ /* If > 0 and accepted then scsi_debug_delay is set to DELAY_OVERRIDDEN */ static ssize_t ndelay_store(struct device_driver *ddp, const char *buf, size_t count) { unsigned long iflags; int ndelay, res, k; if ((count > 0) && (1 == sscanf(buf, "%d", &ndelay)) && (ndelay >= 0) && (ndelay < 1000000000)) { res = count; if (scsi_debug_ndelay != ndelay) { spin_lock_irqsave(&queued_arr_lock, iflags); k = find_first_bit(queued_in_use_bm, scsi_debug_max_queue); if (k != scsi_debug_max_queue) res = -EBUSY; /* have queued commands */ else { scsi_debug_ndelay = ndelay; scsi_debug_delay = ndelay ? DELAY_OVERRIDDEN : DEF_DELAY; } spin_unlock_irqrestore(&queued_arr_lock, iflags); } return res; } return -EINVAL; } static DRIVER_ATTR_RW(ndelay); static ssize_t opts_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "0x%x\n", scsi_debug_opts); } static ssize_t opts_store(struct device_driver *ddp, const char *buf, size_t count) { int opts; char work[20]; if (1 == sscanf(buf, "%10s", work)) { if (0 == strncasecmp(work,"0x", 2)) { if (1 == sscanf(&work[2], "%x", &opts)) goto opts_done; } else { if (1 == sscanf(work, "%d", &opts)) goto opts_done; } } return -EINVAL; opts_done: scsi_debug_opts = opts; if (SCSI_DEBUG_OPT_RECOVERED_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_DIF_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_DIX_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & opts) sdebug_any_injecting_opt = true; atomic_set(&sdebug_cmnd_count, 0); atomic_set(&sdebug_a_tsf, 0); return count; } static DRIVER_ATTR_RW(opts); static ssize_t ptype_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ptype); } static ssize_t ptype_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_ptype = n; return count; } return -EINVAL; } static DRIVER_ATTR_RW(ptype); static ssize_t dsense_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dsense); } static ssize_t dsense_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_dsense = n; return count; } return -EINVAL; } static DRIVER_ATTR_RW(dsense); static ssize_t fake_rw_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_fake_rw); } static ssize_t fake_rw_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { n = (n > 0); scsi_debug_fake_rw = (scsi_debug_fake_rw > 0); if (scsi_debug_fake_rw != n) { if ((0 == n) && (NULL == fake_storep)) { unsigned long sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; fake_storep = vmalloc(sz); if (NULL == fake_storep) { pr_err("%s: out of memory, 9\n", __func__); return -ENOMEM; } memset(fake_storep, 0, sz); } scsi_debug_fake_rw = n; } return count; } return -EINVAL; } static DRIVER_ATTR_RW(fake_rw); static ssize_t no_lun_0_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_lun_0); } static ssize_t no_lun_0_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_no_lun_0 = n; return count; } return -EINVAL; } static DRIVER_ATTR_RW(no_lun_0); static ssize_t num_tgts_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts); } static ssize_t num_tgts_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_num_tgts = n; sdebug_max_tgts_luns(); return count; } return -EINVAL; } static DRIVER_ATTR_RW(num_tgts); static ssize_t dev_size_mb_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb); } static DRIVER_ATTR_RO(dev_size_mb); static ssize_t num_parts_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_parts); } static DRIVER_ATTR_RO(num_parts); static ssize_t every_nth_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_every_nth); } static ssize_t every_nth_store(struct device_driver *ddp, const char *buf, size_t count) { int nth; if ((count > 0) && (1 == sscanf(buf, "%d", &nth))) { scsi_debug_every_nth = nth; atomic_set(&sdebug_cmnd_count, 0); return count; } return -EINVAL; } static DRIVER_ATTR_RW(every_nth); static ssize_t max_luns_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_luns); } static ssize_t max_luns_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_max_luns = n; sdebug_max_tgts_luns(); return count; } return -EINVAL; } static DRIVER_ATTR_RW(max_luns); static ssize_t max_queue_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_queue); } /* N.B. max_queue can be changed while there are queued commands. In flight * commands beyond the new max_queue will be completed. */ static ssize_t max_queue_store(struct device_driver *ddp, const char *buf, size_t count) { unsigned long iflags; int n, k; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n > 0) && (n <= SCSI_DEBUG_CANQUEUE)) { spin_lock_irqsave(&queued_arr_lock, iflags); k = find_last_bit(queued_in_use_bm, SCSI_DEBUG_CANQUEUE); scsi_debug_max_queue = n; if (SCSI_DEBUG_CANQUEUE == k) atomic_set(&retired_max_queue, 0); else if (k >= n) atomic_set(&retired_max_queue, k + 1); else atomic_set(&retired_max_queue, 0); spin_unlock_irqrestore(&queued_arr_lock, iflags); return count; } return -EINVAL; } static DRIVER_ATTR_RW(max_queue); static ssize_t no_uld_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_uld); } static DRIVER_ATTR_RO(no_uld); static ssize_t scsi_level_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level); } static DRIVER_ATTR_RO(scsi_level); static ssize_t virtual_gb_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb); } static ssize_t virtual_gb_store(struct device_driver *ddp, const char *buf, size_t count) { int n; bool changed; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { changed = (scsi_debug_virtual_gb != n); scsi_debug_virtual_gb = n; sdebug_capacity = get_sdebug_capacity(); if (changed) { struct sdebug_host_info *sdhp; struct sdebug_dev_info *dp; list_for_each_entry(sdhp, &sdebug_host_list, host_list) { list_for_each_entry(dp, &sdhp->dev_info_list, dev_list) { set_bit(SDEBUG_UA_CAPACITY_CHANGED, dp->uas_bm); } } } return count; } return -EINVAL; } static DRIVER_ATTR_RW(virtual_gb); static ssize_t add_host_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host); } static ssize_t add_host_store(struct device_driver *ddp, const char *buf, size_t count) { int delta_hosts; if (sscanf(buf, "%d", &delta_hosts) != 1) return -EINVAL; if (delta_hosts > 0) { do { sdebug_add_adapter(); } while (--delta_hosts); } else if (delta_hosts < 0) { do { sdebug_remove_adapter(); } while (++delta_hosts); } return count; } static DRIVER_ATTR_RW(add_host); static ssize_t vpd_use_hostno_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_vpd_use_hostno); } static ssize_t vpd_use_hostno_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_vpd_use_hostno = n; return count; } return -EINVAL; } static DRIVER_ATTR_RW(vpd_use_hostno); static ssize_t sector_size_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_sector_size); } static DRIVER_ATTR_RO(sector_size); static ssize_t dix_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dix); } static DRIVER_ATTR_RO(dix); static ssize_t dif_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dif); } static DRIVER_ATTR_RO(dif); static ssize_t guard_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_guard); } static DRIVER_ATTR_RO(guard); static ssize_t ato_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ato); } static DRIVER_ATTR_RO(ato); static ssize_t map_show(struct device_driver *ddp, char *buf) { ssize_t count; if (!scsi_debug_lbp()) return scnprintf(buf, PAGE_SIZE, "0-%u\n", sdebug_store_sectors); count = bitmap_scnlistprintf(buf, PAGE_SIZE, map_storep, map_size); buf[count++] = '\n'; buf[count++] = 0; return count; } static DRIVER_ATTR_RO(map); static ssize_t removable_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_removable ? 1 : 0); } static ssize_t removable_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_removable = (n > 0); return count; } return -EINVAL; } static DRIVER_ATTR_RW(removable); static ssize_t host_lock_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", !!scsi_debug_host_lock); } /* Returns -EBUSY if host_lock is being changed and commands are queued */ static ssize_t host_lock_store(struct device_driver *ddp, const char *buf, size_t count) { int n, res; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { bool new_host_lock = (n > 0); res = count; if (new_host_lock != scsi_debug_host_lock) { unsigned long iflags; int k; spin_lock_irqsave(&queued_arr_lock, iflags); k = find_first_bit(queued_in_use_bm, scsi_debug_max_queue); if (k != scsi_debug_max_queue) res = -EBUSY; /* have queued commands */ else scsi_debug_host_lock = new_host_lock; spin_unlock_irqrestore(&queued_arr_lock, iflags); } return res; } return -EINVAL; } static DRIVER_ATTR_RW(host_lock); static ssize_t strict_show(struct device_driver *ddp, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", !!scsi_debug_strict); } static ssize_t strict_store(struct device_driver *ddp, const char *buf, size_t count) { int n; if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_strict = (n > 0); return count; } return -EINVAL; } static DRIVER_ATTR_RW(strict); /* Note: The following array creates attribute files in the /sys/bus/pseudo/drivers/scsi_debug directory. The advantage of these files (over those found in the /sys/module/scsi_debug/parameters directory) is that auxiliary actions can be triggered when an attribute is changed. For example see: sdebug_add_host_store() above. */ static struct attribute *sdebug_drv_attrs[] = { &driver_attr_delay.attr, &driver_attr_opts.attr, &driver_attr_ptype.attr, &driver_attr_dsense.attr, &driver_attr_fake_rw.attr, &driver_attr_no_lun_0.attr, &driver_attr_num_tgts.attr, &driver_attr_dev_size_mb.attr, &driver_attr_num_parts.attr, &driver_attr_every_nth.attr, &driver_attr_max_luns.attr, &driver_attr_max_queue.attr, &driver_attr_no_uld.attr, &driver_attr_scsi_level.attr, &driver_attr_virtual_gb.attr, &driver_attr_add_host.attr, &driver_attr_vpd_use_hostno.attr, &driver_attr_sector_size.attr, &driver_attr_dix.attr, &driver_attr_dif.attr, &driver_attr_guard.attr, &driver_attr_ato.attr, &driver_attr_map.attr, &driver_attr_removable.attr, &driver_attr_host_lock.attr, &driver_attr_ndelay.attr, &driver_attr_strict.attr, NULL, }; ATTRIBUTE_GROUPS(sdebug_drv); static struct device *pseudo_primary; static int __init scsi_debug_init(void) { unsigned long sz; int host_to_add; int k; int ret; atomic_set(&sdebug_cmnd_count, 0); atomic_set(&sdebug_completions, 0); atomic_set(&retired_max_queue, 0); if (scsi_debug_ndelay >= 1000000000) { pr_warn("%s: ndelay must be less than 1 second, ignored\n", __func__); scsi_debug_ndelay = 0; } else if (scsi_debug_ndelay > 0) scsi_debug_delay = DELAY_OVERRIDDEN; switch (scsi_debug_sector_size) { case 512: case 1024: case 2048: case 4096: break; default: pr_err("%s: invalid sector_size %d\n", __func__, scsi_debug_sector_size); return -EINVAL; } switch (scsi_debug_dif) { case SD_DIF_TYPE0_PROTECTION: case SD_DIF_TYPE1_PROTECTION: case SD_DIF_TYPE2_PROTECTION: case SD_DIF_TYPE3_PROTECTION: break; default: pr_err("%s: dif must be 0, 1, 2 or 3\n", __func__); return -EINVAL; } if (scsi_debug_guard > 1) { pr_err("%s: guard must be 0 or 1\n", __func__); return -EINVAL; } if (scsi_debug_ato > 1) { pr_err("%s: ato must be 0 or 1\n", __func__); return -EINVAL; } if (scsi_debug_physblk_exp > 15) { pr_err("%s: invalid physblk_exp %u\n", __func__, scsi_debug_physblk_exp); return -EINVAL; } if (scsi_debug_lowest_aligned > 0x3fff) { pr_err("%s: lowest_aligned too big: %u\n", __func__, scsi_debug_lowest_aligned); return -EINVAL; } if (scsi_debug_dev_size_mb < 1) scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; sdebug_store_sectors = sz / scsi_debug_sector_size; sdebug_capacity = get_sdebug_capacity(); /* play around with geometry, don't waste too much on track 0 */ sdebug_heads = 8; sdebug_sectors_per = 32; if (scsi_debug_dev_size_mb >= 16) sdebug_heads = 32; else if (scsi_debug_dev_size_mb >= 256) sdebug_heads = 64; sdebug_cylinders_per = (unsigned long)sdebug_capacity / (sdebug_sectors_per * sdebug_heads); if (sdebug_cylinders_per >= 1024) { /* other LLDs do this; implies >= 1GB ram disk ... */ sdebug_heads = 255; sdebug_sectors_per = 63; sdebug_cylinders_per = (unsigned long)sdebug_capacity / (sdebug_sectors_per * sdebug_heads); } if (0 == scsi_debug_fake_rw) { fake_storep = vmalloc(sz); if (NULL == fake_storep) { pr_err("%s: out of memory, 1\n", __func__); return -ENOMEM; } memset(fake_storep, 0, sz); if (scsi_debug_num_parts > 0) sdebug_build_parts(fake_storep, sz); } if (scsi_debug_dix) { int dif_size; dif_size = sdebug_store_sectors * sizeof(struct sd_dif_tuple); dif_storep = vmalloc(dif_size); pr_err("%s: dif_storep %u bytes @ %p\n", __func__, dif_size, dif_storep); if (dif_storep == NULL) { pr_err("%s: out of mem. (DIX)\n", __func__); ret = -ENOMEM; goto free_vm; } memset(dif_storep, 0xff, dif_size); } /* Logical Block Provisioning */ if (scsi_debug_lbp()) { scsi_debug_unmap_max_blocks = clamp(scsi_debug_unmap_max_blocks, 0U, 0xffffffffU); scsi_debug_unmap_max_desc = clamp(scsi_debug_unmap_max_desc, 0U, 256U); scsi_debug_unmap_granularity = clamp(scsi_debug_unmap_granularity, 1U, 0xffffffffU); if (scsi_debug_unmap_alignment && scsi_debug_unmap_granularity <= scsi_debug_unmap_alignment) { pr_err("%s: ERR: unmap_granularity <= unmap_alignment\n", __func__); return -EINVAL; } map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; map_storep = vmalloc(BITS_TO_LONGS(map_size) * sizeof(long)); pr_info("%s: %lu provisioning blocks\n", __func__, map_size); if (map_storep == NULL) { pr_err("%s: out of mem. (MAP)\n", __func__); ret = -ENOMEM; goto free_vm; } bitmap_zero(map_storep, map_size); /* Map first 1KB for partition table */ if (scsi_debug_num_parts) map_region(0, 2); } pseudo_primary = root_device_register("pseudo_0"); if (IS_ERR(pseudo_primary)) { pr_warn("%s: root_device_register() error\n", __func__); ret = PTR_ERR(pseudo_primary); goto free_vm; } ret = bus_register(&pseudo_lld_bus); if (ret < 0) { pr_warn("%s: bus_register error: %d\n", __func__, ret); goto dev_unreg; } ret = driver_register(&sdebug_driverfs_driver); if (ret < 0) { pr_warn("%s: driver_register error: %d\n", __func__, ret); goto bus_unreg; } host_to_add = scsi_debug_add_host; scsi_debug_add_host = 0; for (k = 0; k < host_to_add; k++) { if (sdebug_add_adapter()) { pr_err("%s: sdebug_add_adapter failed k=%d\n", __func__, k); break; } } if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) { pr_info("%s: built %d host(s)\n", __func__, scsi_debug_add_host); } return 0; bus_unreg: bus_unregister(&pseudo_lld_bus); dev_unreg: root_device_unregister(pseudo_primary); free_vm: if (map_storep) vfree(map_storep); if (dif_storep) vfree(dif_storep); vfree(fake_storep); return ret; } static void __exit scsi_debug_exit(void) { int k = scsi_debug_add_host; stop_all_queued(); free_all_queued(); for (; k; k--) sdebug_remove_adapter(); driver_unregister(&sdebug_driverfs_driver); bus_unregister(&pseudo_lld_bus); root_device_unregister(pseudo_primary); if (dif_storep) vfree(dif_storep); vfree(fake_storep); } device_initcall(scsi_debug_init); module_exit(scsi_debug_exit); static void sdebug_release_adapter(struct device * dev) { struct sdebug_host_info *sdbg_host; sdbg_host = to_sdebug_host(dev); kfree(sdbg_host); } static int sdebug_add_adapter(void) { int k, devs_per_host; int error = 0; struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *sdbg_devinfo, *tmp; sdbg_host = kzalloc(sizeof(*sdbg_host),GFP_KERNEL); if (NULL == sdbg_host) { printk(KERN_ERR "%s: out of memory at line %d\n", __func__, __LINE__); return -ENOMEM; } INIT_LIST_HEAD(&sdbg_host->dev_info_list); devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns; for (k = 0; k < devs_per_host; k++) { sdbg_devinfo = sdebug_device_create(sdbg_host, GFP_KERNEL); if (!sdbg_devinfo) { printk(KERN_ERR "%s: out of memory at line %d\n", __func__, __LINE__); error = -ENOMEM; goto clean; } } spin_lock(&sdebug_host_list_lock); list_add_tail(&sdbg_host->host_list, &sdebug_host_list); spin_unlock(&sdebug_host_list_lock); sdbg_host->dev.bus = &pseudo_lld_bus; sdbg_host->dev.parent = pseudo_primary; sdbg_host->dev.release = &sdebug_release_adapter; dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host); error = device_register(&sdbg_host->dev); if (error) goto clean; ++scsi_debug_add_host; return error; clean: list_for_each_entry_safe(sdbg_devinfo, tmp, &sdbg_host->dev_info_list, dev_list) { list_del(&sdbg_devinfo->dev_list); kfree(sdbg_devinfo); } kfree(sdbg_host); return error; } static void sdebug_remove_adapter(void) { struct sdebug_host_info * sdbg_host = NULL; spin_lock(&sdebug_host_list_lock); if (!list_empty(&sdebug_host_list)) { sdbg_host = list_entry(sdebug_host_list.prev, struct sdebug_host_info, host_list); list_del(&sdbg_host->host_list); } spin_unlock(&sdebug_host_list_lock); if (!sdbg_host) return; device_unregister(&sdbg_host->dev); --scsi_debug_add_host; } static int sdebug_change_qdepth(struct scsi_device *sdev, int qdepth) { int num_in_q = 0; unsigned long iflags; struct sdebug_dev_info *devip; spin_lock_irqsave(&queued_arr_lock, iflags); devip = (struct sdebug_dev_info *)sdev->hostdata; if (NULL == devip) { spin_unlock_irqrestore(&queued_arr_lock, iflags); return -ENODEV; } num_in_q = atomic_read(&devip->num_in_q); spin_unlock_irqrestore(&queued_arr_lock, iflags); if (qdepth < 1) qdepth = 1; /* allow to exceed max host queued_arr elements for testing */ if (qdepth > SCSI_DEBUG_CANQUEUE + 10) qdepth = SCSI_DEBUG_CANQUEUE + 10; scsi_change_queue_depth(sdev, qdepth); if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) { sdev_printk(KERN_INFO, sdev, "%s: qdepth=%d, num_in_q=%d\n", __func__, qdepth, num_in_q); } return sdev->queue_depth; } static int sdebug_change_qtype(struct scsi_device *sdev, int qtype) { qtype = scsi_change_queue_type(sdev, qtype); if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) { const char *cp; switch (qtype) { case 0: cp = "untagged"; break; case MSG_SIMPLE_TAG: cp = "simple tags"; break; case MSG_ORDERED_TAG: cp = "ordered tags"; break; default: cp = "unknown"; break; } sdev_printk(KERN_INFO, sdev, "%s: to %s\n", __func__, cp); } return qtype; } static int check_inject(struct scsi_cmnd *scp) { struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); memset(ep, 0, sizeof(struct sdebug_scmd_extra_t)); if (atomic_inc_return(&sdebug_cmnd_count) >= abs(scsi_debug_every_nth)) { atomic_set(&sdebug_cmnd_count, 0); if (scsi_debug_every_nth < -1) scsi_debug_every_nth = -1; if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts) return 1; /* ignore command causing timeout */ else if (SCSI_DEBUG_OPT_MAC_TIMEOUT & scsi_debug_opts && scsi_medium_access_command(scp)) return 1; /* time out reads and writes */ if (sdebug_any_injecting_opt) { int opts = scsi_debug_opts; if (SCSI_DEBUG_OPT_RECOVERED_ERR & opts) ep->inj_recovered = true; else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & opts) ep->inj_transport = true; else if (SCSI_DEBUG_OPT_DIF_ERR & opts) ep->inj_dif = true; else if (SCSI_DEBUG_OPT_DIX_ERR & opts) ep->inj_dix = true; else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & opts) ep->inj_short = true; } } return 0; } static int scsi_debug_queuecommand(struct scsi_cmnd *scp) { u8 sdeb_i; struct scsi_device *sdp = scp->device; const struct opcode_info_t *oip; const struct opcode_info_t *r_oip; struct sdebug_dev_info *devip; u8 *cmd = scp->cmnd; int (*r_pfp)(struct scsi_cmnd *, struct sdebug_dev_info *); int k, na; int errsts = 0; int errsts_no_connect = DID_NO_CONNECT << 16; u32 flags; u16 sa; u8 opcode = cmd[0]; bool has_wlun_rl; bool debug = !!(SCSI_DEBUG_OPT_NOISE & scsi_debug_opts); scsi_set_resid(scp, 0); if (debug && !(SCSI_DEBUG_OPT_NO_CDB_NOISE & scsi_debug_opts)) { char b[120]; int n, len, sb; len = scp->cmd_len; sb = (int)sizeof(b); if (len > 32) strcpy(b, "too long, over 32 bytes"); else { for (k = 0, n = 0; k < len && n < sb; ++k) n += scnprintf(b + n, sb - n, "%02x ", (u32)cmd[k]); } sdev_printk(KERN_INFO, sdp, "%s: cmd %s\n", my_name, b); } has_wlun_rl = (sdp->lun == SAM2_WLUN_REPORT_LUNS); if ((sdp->lun >= scsi_debug_max_luns) && !has_wlun_rl) return schedule_resp(scp, NULL, errsts_no_connect, 0); sdeb_i = opcode_ind_arr[opcode]; /* fully mapped */ oip = &opcode_info_arr[sdeb_i]; /* safe if table consistent */ devip = (struct sdebug_dev_info *)sdp->hostdata; if (!devip) { devip = devInfoReg(sdp); if (NULL == devip) return schedule_resp(scp, NULL, errsts_no_connect, 0); } na = oip->num_attached; r_pfp = oip->pfp; if (na) { /* multiple commands with this opcode */ r_oip = oip; if (FF_SA & r_oip->flags) { if (F_SA_LOW & oip->flags) sa = 0x1f & cmd[1]; else sa = get_unaligned_be16(cmd + 8); for (k = 0; k <= na; oip = r_oip->arrp + k++) { if (opcode == oip->opcode && sa == oip->sa) break; } } else { /* since no service action only check opcode */ for (k = 0; k <= na; oip = r_oip->arrp + k++) { if (opcode == oip->opcode) break; } } if (k > na) { if (F_SA_LOW & r_oip->flags) mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); else if (F_SA_HIGH & r_oip->flags) mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); else mk_sense_invalid_opcode(scp); goto check_cond; } } /* else (when na==0) we assume the oip is a match */ flags = oip->flags; if (F_INV_OP & flags) { mk_sense_invalid_opcode(scp); goto check_cond; } if (has_wlun_rl && !(F_RL_WLUN_OK & flags)) { if (debug) sdev_printk(KERN_INFO, sdp, "scsi_debug: Opcode: " "0x%x not supported for wlun\n", opcode); mk_sense_invalid_opcode(scp); goto check_cond; } if (scsi_debug_strict) { /* check cdb against mask */ u8 rem; int j; for (k = 1; k < oip->len_mask[0] && k < 16; ++k) { rem = ~oip->len_mask[k] & cmd[k]; if (rem) { for (j = 7; j >= 0; --j, rem <<= 1) { if (0x80 & rem) break; } mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); goto check_cond; } } } if (!(F_SKIP_UA & flags) && SDEBUG_NUM_UAS != find_first_bit(devip->uas_bm, SDEBUG_NUM_UAS)) { errsts = check_readiness(scp, UAS_ONLY, devip); if (errsts) goto check_cond; } if ((F_M_ACCESS & flags) && devip->stopped) { mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); if (debug) sdev_printk(KERN_INFO, sdp, "%s reports: Not ready: " "%s\n", my_name, "initializing command " "required"); errsts = check_condition_result; goto fini; } if (scsi_debug_fake_rw && (F_FAKE_RW & flags)) goto fini; if (scsi_debug_every_nth) { if (check_inject(scp)) return 0; /* ignore command: make trouble */ } if (oip->pfp) /* if this command has a resp_* function, call it */ errsts = oip->pfp(scp, devip); else if (r_pfp) /* if leaf function ptr NULL, try the root's */ errsts = r_pfp(scp, devip); fini: return schedule_resp(scp, devip, errsts, ((F_DELAY_OVERR & flags) ? 0 : scsi_debug_delay)); check_cond: return schedule_resp(scp, devip, check_condition_result, 0); } static int sdebug_queuecommand_lock_or_not(struct Scsi_Host *shost, struct scsi_cmnd *cmd) { if (scsi_debug_host_lock) { unsigned long iflags; int rc; spin_lock_irqsave(shost->host_lock, iflags); rc = scsi_debug_queuecommand(cmd); spin_unlock_irqrestore(shost->host_lock, iflags); return rc; } else return scsi_debug_queuecommand(cmd); } static struct scsi_host_template sdebug_driver_template = { .show_info = scsi_debug_show_info, .write_info = scsi_debug_write_info, .proc_name = sdebug_proc_name, .name = "SCSI DEBUG", .info = scsi_debug_info, .slave_alloc = scsi_debug_slave_alloc, .slave_configure = scsi_debug_slave_configure, .slave_destroy = scsi_debug_slave_destroy, .ioctl = scsi_debug_ioctl, .queuecommand = sdebug_queuecommand_lock_or_not, .change_queue_depth = sdebug_change_qdepth, .change_queue_type = sdebug_change_qtype, .eh_abort_handler = scsi_debug_abort, .eh_device_reset_handler = scsi_debug_device_reset, .eh_target_reset_handler = scsi_debug_target_reset, .eh_bus_reset_handler = scsi_debug_bus_reset, .eh_host_reset_handler = scsi_debug_host_reset, .can_queue = SCSI_DEBUG_CANQUEUE, .this_id = 7, .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, .cmd_per_lun = DEF_CMD_PER_LUN, .max_sectors = -1U, .use_clustering = DISABLE_CLUSTERING, .module = THIS_MODULE, .track_queue_depth = 1, .cmd_size = sizeof(struct sdebug_scmd_extra_t), }; static int sdebug_driver_probe(struct device * dev) { int error = 0; int opts; struct sdebug_host_info *sdbg_host; struct Scsi_Host *hpnt; int host_prot; sdbg_host = to_sdebug_host(dev); sdebug_driver_template.can_queue = scsi_debug_max_queue; if (scsi_debug_clustering) sdebug_driver_template.use_clustering = ENABLE_CLUSTERING; hpnt = scsi_host_alloc(&sdebug_driver_template, sizeof(sdbg_host)); if (NULL == hpnt) { pr_err("%s: scsi_host_alloc failed\n", __func__); error = -ENODEV; return error; } sdbg_host->shost = hpnt; *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host; if ((hpnt->this_id >= 0) && (scsi_debug_num_tgts > hpnt->this_id)) hpnt->max_id = scsi_debug_num_tgts + 1; else hpnt->max_id = scsi_debug_num_tgts; hpnt->max_lun = SAM2_WLUN_REPORT_LUNS; /* = scsi_debug_max_luns; */ host_prot = 0; switch (scsi_debug_dif) { case SD_DIF_TYPE1_PROTECTION: host_prot = SHOST_DIF_TYPE1_PROTECTION; if (scsi_debug_dix) host_prot |= SHOST_DIX_TYPE1_PROTECTION; break; case SD_DIF_TYPE2_PROTECTION: host_prot = SHOST_DIF_TYPE2_PROTECTION; if (scsi_debug_dix) host_prot |= SHOST_DIX_TYPE2_PROTECTION; break; case SD_DIF_TYPE3_PROTECTION: host_prot = SHOST_DIF_TYPE3_PROTECTION; if (scsi_debug_dix) host_prot |= SHOST_DIX_TYPE3_PROTECTION; break; default: if (scsi_debug_dix) host_prot |= SHOST_DIX_TYPE0_PROTECTION; break; } scsi_host_set_prot(hpnt, host_prot); printk(KERN_INFO "scsi_debug: host protection%s%s%s%s%s%s%s\n", (host_prot & SHOST_DIF_TYPE1_PROTECTION) ? " DIF1" : "", (host_prot & SHOST_DIF_TYPE2_PROTECTION) ? " DIF2" : "", (host_prot & SHOST_DIF_TYPE3_PROTECTION) ? " DIF3" : "", (host_prot & SHOST_DIX_TYPE0_PROTECTION) ? " DIX0" : "", (host_prot & SHOST_DIX_TYPE1_PROTECTION) ? " DIX1" : "", (host_prot & SHOST_DIX_TYPE2_PROTECTION) ? " DIX2" : "", (host_prot & SHOST_DIX_TYPE3_PROTECTION) ? " DIX3" : ""); if (scsi_debug_guard == 1) scsi_host_set_guard(hpnt, SHOST_DIX_GUARD_IP); else scsi_host_set_guard(hpnt, SHOST_DIX_GUARD_CRC); opts = scsi_debug_opts; if (SCSI_DEBUG_OPT_RECOVERED_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_DIF_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_DIX_ERR & opts) sdebug_any_injecting_opt = true; else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & opts) sdebug_any_injecting_opt = true; error = scsi_add_host(hpnt, &sdbg_host->dev); if (error) { printk(KERN_ERR "%s: scsi_add_host failed\n", __func__); error = -ENODEV; scsi_host_put(hpnt); } else scsi_scan_host(hpnt); return error; } static int sdebug_driver_remove(struct device * dev) { struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *sdbg_devinfo, *tmp; sdbg_host = to_sdebug_host(dev); if (!sdbg_host) { printk(KERN_ERR "%s: Unable to locate host info\n", __func__); return -ENODEV; } scsi_remove_host(sdbg_host->shost); list_for_each_entry_safe(sdbg_devinfo, tmp, &sdbg_host->dev_info_list, dev_list) { list_del(&sdbg_devinfo->dev_list); kfree(sdbg_devinfo); } scsi_host_put(sdbg_host->shost); return 0; } static int pseudo_lld_bus_match(struct device *dev, struct device_driver *dev_driver) { return 1; } static struct bus_type pseudo_lld_bus = { .name = "pseudo", .match = pseudo_lld_bus_match, .probe = sdebug_driver_probe, .remove = sdebug_driver_remove, .drv_groups = sdebug_drv_groups, };
gpl-2.0
ziozzang/rhel6-kernel-src
drivers/video/offb.c
19780
/* * linux/drivers/video/offb.c -- Open Firmware based frame buffer device * * Copyright (C) 1997 Geert Uytterhoeven * * This driver is partly based on the PowerMac console driver: * * Copyright (C) 1996 Paul Mackerras * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/pci.h> #include <asm/io.h> #include <asm/prom.h> #ifdef CONFIG_PPC64 #include <asm/pci-bridge.h> #endif #ifdef CONFIG_PPC32 #include <asm/bootx.h> #endif #include "macmodes.h" /* Supported palette hacks */ enum { cmap_unknown, cmap_simple, /* ATI Mach64 */ cmap_r128, /* ATI Rage128 */ cmap_M3A, /* ATI Rage Mobility M3 Head A */ cmap_M3B, /* ATI Rage Mobility M3 Head B */ cmap_radeon, /* ATI Radeon */ cmap_gxt2000, /* IBM GXT2000 */ cmap_avivo, /* ATI R5xx */ cmap_qemu, /* qemu vga */ }; struct offb_par { volatile void __iomem *cmap_adr; volatile void __iomem *cmap_data; int cmap_type; int blanked; }; struct offb_par default_par; #ifdef CONFIG_PPC32 extern boot_infos_t *boot_infos; #endif /* Definitions used by the Avivo palette hack */ #define AVIVO_DC_LUT_RW_SELECT 0x6480 #define AVIVO_DC_LUT_RW_MODE 0x6484 #define AVIVO_DC_LUT_RW_INDEX 0x6488 #define AVIVO_DC_LUT_SEQ_COLOR 0x648c #define AVIVO_DC_LUT_PWL_DATA 0x6490 #define AVIVO_DC_LUT_30_COLOR 0x6494 #define AVIVO_DC_LUT_READ_PIPE_SELECT 0x6498 #define AVIVO_DC_LUT_WRITE_EN_MASK 0x649c #define AVIVO_DC_LUT_AUTOFILL 0x64a0 #define AVIVO_DC_LUTA_CONTROL 0x64c0 #define AVIVO_DC_LUTA_BLACK_OFFSET_BLUE 0x64c4 #define AVIVO_DC_LUTA_BLACK_OFFSET_GREEN 0x64c8 #define AVIVO_DC_LUTA_BLACK_OFFSET_RED 0x64cc #define AVIVO_DC_LUTA_WHITE_OFFSET_BLUE 0x64d0 #define AVIVO_DC_LUTA_WHITE_OFFSET_GREEN 0x64d4 #define AVIVO_DC_LUTA_WHITE_OFFSET_RED 0x64d8 #define AVIVO_DC_LUTB_CONTROL 0x6cc0 #define AVIVO_DC_LUTB_BLACK_OFFSET_BLUE 0x6cc4 #define AVIVO_DC_LUTB_BLACK_OFFSET_GREEN 0x6cc8 #define AVIVO_DC_LUTB_BLACK_OFFSET_RED 0x6ccc #define AVIVO_DC_LUTB_WHITE_OFFSET_BLUE 0x6cd0 #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN 0x6cd4 #define AVIVO_DC_LUTB_WHITE_OFFSET_RED 0x6cd8 /* * Set a single color register. The values supplied are already * rounded down to the hardware's capabilities (according to the * entries in the var structure). Return != 0 for invalid regno. */ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { struct offb_par *par = (struct offb_par *) info->par; if (info->fix.visual == FB_VISUAL_TRUECOLOR) { u32 *pal = info->pseudo_palette; u32 cr = red >> (16 - info->var.red.length); u32 cg = green >> (16 - info->var.green.length); u32 cb = blue >> (16 - info->var.blue.length); u32 value; if (regno >= 16) return -EINVAL; value = (cr << info->var.red.offset) | (cg << info->var.green.offset) | (cb << info->var.blue.offset); if (info->var.transp.length > 0) { u32 mask = (1 << info->var.transp.length) - 1; mask <<= info->var.transp.offset; value |= mask; } pal[regno] = value; return 0; } if (regno > 255) return -EINVAL; red >>= 8; green >>= 8; blue >>= 8; if (!par->cmap_adr) return 0; switch (par->cmap_type) { case cmap_simple: writeb(regno, par->cmap_adr); writeb(red, par->cmap_data); writeb(green, par->cmap_data); writeb(blue, par->cmap_data); break; case cmap_M3A: /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) & ~0x20); case cmap_r128: /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, regno); out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); break; case cmap_M3B: /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) | 0x20); /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, regno); out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); break; case cmap_radeon: /* Set palette index & data (could be smarter) */ out_8(par->cmap_adr + 0xb0, regno); out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); break; case cmap_gxt2000: out_le32(((unsigned __iomem *) par->cmap_adr) + regno, (red << 16 | green << 8 | blue)); break; case cmap_avivo: /* Write to both LUTs for now */ writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(regno, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(((red) << 22) | ((green) << 12) | ((blue) << 2), par->cmap_adr + AVIVO_DC_LUT_30_COLOR); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(regno, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(((red) << 22) | ((green) << 12) | ((blue) << 2), par->cmap_adr + AVIVO_DC_LUT_30_COLOR); break; } return 0; } /* * Blank the display. */ static int offb_blank(int blank, struct fb_info *info) { struct offb_par *par = (struct offb_par *) info->par; int i, j; if (!par->cmap_adr) return 0; if (!par->blanked) if (!blank) return 0; par->blanked = blank; if (blank) for (i = 0; i < 256; i++) { switch (par->cmap_type) { case cmap_simple: writeb(i, par->cmap_adr); for (j = 0; j < 3; j++) writeb(0, par->cmap_data); break; case cmap_M3A: /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) & ~0x20); case cmap_r128: /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_M3B: /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) | 0x20); /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_radeon: out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_gxt2000: out_le32(((unsigned __iomem *) par->cmap_adr) + i, 0); break; case cmap_avivo: writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR); break; } } else fb_set_cmap(&info->cmap, info); return 0; } static int offb_set_par(struct fb_info *info) { struct offb_par *par = (struct offb_par *) info->par; /* On avivo, initialize palette control */ if (par->cmap_type == cmap_avivo) { writel(0, par->cmap_adr + AVIVO_DC_LUTA_CONTROL); writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_BLUE); writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_GREEN); writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_RED); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_BLUE); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_GREEN); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_RED); writel(0, par->cmap_adr + AVIVO_DC_LUTB_CONTROL); writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_BLUE); writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_GREEN); writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_RED); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_BLUE); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_GREEN); writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_RED); writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_MODE); writel(0x0000003f, par->cmap_adr + AVIVO_DC_LUT_WRITE_EN_MASK); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_MODE); writel(0x0000003f, par->cmap_adr + AVIVO_DC_LUT_WRITE_EN_MASK); } return 0; } static void offb_destroy(struct fb_info *info) { if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->aperture_base, info->aperture_size); framebuffer_release(info); } static struct fb_ops offb_ops = { .owner = THIS_MODULE, .fb_destroy = offb_destroy, .fb_setcolreg = offb_setcolreg, .fb_set_par = offb_set_par, .fb_blank = offb_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, }; static void __iomem *offb_map_reg(struct device_node *np, int index, unsigned long offset, unsigned long size) { const u32 *addrp; u64 asize, taddr; unsigned int flags; addrp = of_get_pci_address(np, index, &asize, &flags); if (addrp == NULL) addrp = of_get_address(np, index, &asize, &flags); if (addrp == NULL) return NULL; if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) return NULL; if ((offset + size) > asize) return NULL; taddr = of_translate_address(np, addrp); if (taddr == OF_BAD_ADDR) return NULL; return ioremap(taddr + offset, size); } static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp, const char *name, unsigned long address) { struct offb_par *par = (struct offb_par *) info->par; if (dp && !strncmp(name, "ATY,Rage128", 11)) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_r128; } else if (dp && (!strncmp(name, "ATY,RageM3pA", 12) || !strncmp(name, "ATY,RageM3p12A", 14))) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_M3A; } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_M3B; } else if (dp && !strncmp(name, "ATY,Rage6", 9)) { par->cmap_adr = offb_map_reg(dp, 1, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_radeon; } else if (!strncmp(name, "ATY,", 4)) { unsigned long base = address & 0xff000000UL; par->cmap_adr = ioremap(base + 0x7ff000, 0x1000) + 0xcc0; par->cmap_data = par->cmap_adr + 1; par->cmap_type = cmap_simple; } else if (dp && (of_device_is_compatible(dp, "pci1014,b7") || of_device_is_compatible(dp, "pci1014,21c"))) { par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); if (par->cmap_adr) par->cmap_type = cmap_gxt2000; } else if (dp && !strncmp(name, "vga,Display-", 12)) { /* Look for AVIVO initialized by SLOF */ struct device_node *pciparent = of_get_parent(dp); const u32 *vid, *did; vid = of_get_property(pciparent, "vendor-id", NULL); did = of_get_property(pciparent, "device-id", NULL); /* This will match most R5xx */ if (vid && did && *vid == 0x1002 && ((*did >= 0x7100 && *did < 0x7800) || (*did >= 0x9400))) { par->cmap_adr = offb_map_reg(pciparent, 2, 0, 0x10000); if (par->cmap_adr) par->cmap_type = cmap_avivo; } of_node_put(pciparent); } else if (dp && of_device_is_compatible(dp, "qemu,std-vga")) { const u32 io_of_addr[3] = { 0x01000000, 0x0, 0x0 }; u64 io_addr = of_translate_address(dp, io_of_addr); if (io_addr != OF_BAD_ADDR) { par->cmap_adr = ioremap(io_addr + 0x3c8, 2); if (par->cmap_adr) { par->cmap_type = cmap_simple; par->cmap_data = par->cmap_adr + 1; } } } info->fix.visual = (par->cmap_type != cmap_unknown) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR; } static void __init offb_init_fb(const char *name, const char *full_name, int width, int height, int depth, int pitch, unsigned long address, int foreign_endian, struct device_node *dp) { unsigned long res_size = pitch * height; struct offb_par *par = &default_par; unsigned long res_start = address; struct fb_fix_screeninfo *fix; struct fb_var_screeninfo *var; struct fb_info *info; if (!request_mem_region(res_start, res_size, "offb")) return; printk(KERN_INFO "Using unsupported %dx%d %s at %lx, depth=%d, pitch=%d\n", width, height, name, address, depth, pitch); if (depth != 8 && depth != 15 && depth != 16 && depth != 32) { printk(KERN_ERR "%s: can't use depth = %d\n", full_name, depth); release_mem_region(res_start, res_size); return; } info = framebuffer_alloc(sizeof(u32) * 16, NULL); if (info == 0) { release_mem_region(res_start, res_size); return; } fix = &info->fix; var = &info->var; info->par = par; strcpy(fix->id, "OFfb "); strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb ")); fix->id[sizeof(fix->id) - 1] = '\0'; var->xres = var->xres_virtual = width; var->yres = var->yres_virtual = height; fix->line_length = pitch; fix->smem_start = address; fix->smem_len = pitch * height; fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; par->cmap_type = cmap_unknown; if (depth == 8) offb_init_palette_hacks(info, dp, name, address); else fix->visual = FB_VISUAL_TRUECOLOR; var->xoffset = var->yoffset = 0; switch (depth) { case 8: var->bits_per_pixel = 8; var->red.offset = 0; var->red.length = 8; var->green.offset = 0; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; var->transp.offset = 0; var->transp.length = 0; break; case 15: /* RGB 555 */ var->bits_per_pixel = 16; var->red.offset = 10; var->red.length = 5; var->green.offset = 5; var->green.length = 5; var->blue.offset = 0; var->blue.length = 5; var->transp.offset = 0; var->transp.length = 0; break; case 16: /* RGB 565 */ var->bits_per_pixel = 16; var->red.offset = 11; var->red.length = 5; var->green.offset = 5; var->green.length = 6; var->blue.offset = 0; var->blue.length = 5; var->transp.offset = 0; var->transp.length = 0; break; case 32: /* RGB 888 */ var->bits_per_pixel = 32; var->red.offset = 16; var->red.length = 8; var->green.offset = 8; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; var->transp.offset = 24; var->transp.length = 8; break; } var->red.msb_right = var->green.msb_right = var->blue.msb_right = var->transp.msb_right = 0; var->grayscale = 0; var->nonstd = 0; var->activate = 0; var->height = var->width = -1; var->pixclock = 10000; var->left_margin = var->right_margin = 16; var->upper_margin = var->lower_margin = 16; var->hsync_len = var->vsync_len = 8; var->sync = 0; var->vmode = FB_VMODE_NONINTERLACED; /* set offb aperture size for generic probing */ info->aperture_base = address; info->aperture_size = fix->smem_len; info->fbops = &offb_ops; info->screen_base = ioremap(address, fix->smem_len); info->pseudo_palette = (void *) (info + 1); info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | foreign_endian; fb_alloc_cmap(&info->cmap, 256, 0); if (register_framebuffer(info) < 0) goto out_err; printk(KERN_INFO "fb%d: Open Firmware frame buffer device on %s\n", info->node, full_name); return; out_err: iounmap(info->screen_base); out_aper: iounmap(par->cmap_adr); par->cmap_adr = NULL; framebuffer_release(info); release_mem_region(res_start, res_size); } static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) { unsigned int len; int i, width = 640, height = 480, depth = 8, pitch = 640; unsigned int flags, rsize, addr_prop = 0; unsigned long max_size = 0; u64 rstart, address = OF_BAD_ADDR; const u32 *pp, *addrp, *up; u64 asize; int foreign_endian = 0; #ifdef __BIG_ENDIAN if (of_get_property(dp, "little-endian", NULL)) foreign_endian = FBINFO_FOREIGN_ENDIAN; #else if (of_get_property(dp, "big-endian", NULL)) foreign_endian = FBINFO_FOREIGN_ENDIAN; #endif pp = of_get_property(dp, "linux,bootx-depth", &len); if (pp == NULL) pp = of_get_property(dp, "depth", &len); if (pp && len == sizeof(u32)) depth = *pp; pp = of_get_property(dp, "linux,bootx-width", &len); if (pp == NULL) pp = of_get_property(dp, "width", &len); if (pp && len == sizeof(u32)) width = *pp; pp = of_get_property(dp, "linux,bootx-height", &len); if (pp == NULL) pp = of_get_property(dp, "height", &len); if (pp && len == sizeof(u32)) height = *pp; pp = of_get_property(dp, "linux,bootx-linebytes", &len); if (pp == NULL) pp = of_get_property(dp, "linebytes", &len); if (pp && len == sizeof(u32) && (*pp != 0xffffffffu)) pitch = *pp; else pitch = width * ((depth + 7) / 8); rsize = (unsigned long)pitch * (unsigned long)height; /* Ok, now we try to figure out the address of the framebuffer. * * Unfortunately, Open Firmware doesn't provide a standard way to do * so. All we can do is a dodgy heuristic that happens to work in * practice. On most machines, the "address" property contains what * we need, though not on Matrox cards found in IBM machines. What I've * found that appears to give good results is to go through the PCI * ranges and pick one that is both big enough and if possible encloses * the "address" property. If none match, we pick the biggest */ up = of_get_property(dp, "linux,bootx-addr", &len); if (up == NULL) up = of_get_property(dp, "address", &len); if (up && len == sizeof(u32)) addr_prop = *up; /* Hack for when BootX is passing us */ if (no_real_node) goto skip_addr; for (i = 0; (addrp = of_get_address(dp, i, &asize, &flags)) != NULL; i++) { int match_addrp = 0; if (!(flags & IORESOURCE_MEM)) continue; if (asize < rsize) continue; rstart = of_translate_address(dp, addrp); if (rstart == OF_BAD_ADDR) continue; if (addr_prop && (rstart <= addr_prop) && ((rstart + asize) >= (addr_prop + rsize))) match_addrp = 1; if (match_addrp) { address = addr_prop; break; } if (rsize > max_size) { max_size = rsize; address = OF_BAD_ADDR; } if (address == OF_BAD_ADDR) address = rstart; } skip_addr: if (address == OF_BAD_ADDR && addr_prop) address = (u64)addr_prop; if (address != OF_BAD_ADDR) { /* kludge for valkyrie */ if (strcmp(dp->name, "valkyrie") == 0) address += 0x1000; offb_init_fb(no_real_node ? "bootx" : dp->name, no_real_node ? "display" : dp->full_name, width, height, depth, pitch, address, foreign_endian, no_real_node ? NULL : dp); } } static int __init offb_init(void) { struct device_node *dp = NULL, *boot_disp = NULL; if (fb_get_options("offb", NULL)) return -ENODEV; /* Check if we have a MacOS display without a node spec */ if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL) != NULL) { /* The old code tried to work out which node was the MacOS * display based on the address. I'm dropping that since the * lack of a node spec only happens with old BootX versions * (users can update) and with this code, they'll still get * a display (just not the palette hacks). */ offb_init_nodriver(of_chosen, 1); } for (dp = NULL; (dp = of_find_node_by_type(dp, "display"));) { if (of_get_property(dp, "linux,opened", NULL) && of_get_property(dp, "linux,boot-display", NULL)) { boot_disp = dp; offb_init_nodriver(dp, 0); } } for (dp = NULL; (dp = of_find_node_by_type(dp, "display"));) { if (of_get_property(dp, "linux,opened", NULL) && dp != boot_disp) offb_init_nodriver(dp, 0); } return 0; } module_init(offb_init); MODULE_LICENSE("GPL");
gpl-2.0
bmi-forum/bmi-pyre
StGermain/Base/Automation/tests/testComponentMetadata.0of1.sh
204
#!/bin/sh TEST_SCRIPT=./VMake/executableTester.sh until test -r ${TEST_SCRIPT} ; do TEST_SCRIPT=../${TEST_SCRIPT} done . ${TEST_SCRIPT} runAndHandleSystemTest "testComponentMetadata " "$0" "$@"
gpl-2.0
aosm/gcc3
libjava/java/lang/Number.java
3524
/* java.lang.Number Copyright (C) 1998, 2001 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package java.lang; import java.io.Serializable; /** ** Number is a generic superclass of all the numeric classes, namely ** <code>Byte</code>, <code>Short</code>, <code>Integer</code>, ** <code>Long</code>, <code>Float</code>, and <code>Double</code>. ** ** It provides ways to convert from any one value to any other. ** ** @author Paul Fisher ** @author John Keiser ** @author Warren Levy ** @since JDK1.0 **/ public abstract class Number implements Serializable { /** Return the value of this <code>Number</code> as a <code>byte</code>. ** @return the value of this <code>Number</code> as a <code>byte</code>. **/ public byte byteValue() { return (byte) intValue(); } /** Return the value of this <code>Number</code> as a <code>short</code>. ** @return the value of this <code>Number</code> as a <code>short</code>. **/ public short shortValue() { return (short) intValue(); } /** Return the value of this <code>Number</code> as an <code>int</code>. ** @return the value of this <code>Number</code> as an <code>int</code>. **/ public abstract int intValue(); /** Return the value of this <code>Number</code> as a <code>long</code>. ** @return the value of this <code>Number</code> as a <code>long</code>. **/ public abstract long longValue(); /** Return the value of this <code>Number</code> as a <code>float</code>. ** @return the value of this <code>Number</code> as a <code>float</code>. **/ public abstract float floatValue(); /** Return the value of this <code>Number</code> as a <code>float</code>. ** @return the value of this <code>Number</code> as a <code>float</code>. **/ public abstract double doubleValue(); private static final long serialVersionUID = -8742448824652078965L; }
gpl-2.0
nandra/omap_850_kernel
fs/file.c
6468
/* * linux/fs/file.c * * Copyright (C) 1998-1999, Stephen Tweedie and Bill Hawes * * Manage the dynamic fd arrays in the process files_struct. */ #include <linux/fs.h> #include <linux/mm.h> #include <linux/time.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/file.h> #include <linux/bitops.h> #include <linux/interrupt.h> #include <linux/spinlock.h> #include <linux/rcupdate.h> #include <linux/workqueue.h> struct fdtable_defer { spinlock_t lock; struct work_struct wq; struct fdtable *next; }; int sysctl_nr_open __read_mostly = 1024*1024; /* * We use this list to defer free fdtables that have vmalloced * sets/arrays. By keeping a per-cpu list, we avoid having to embed * the work_struct in fdtable itself which avoids a 64 byte (i386) increase in * this per-task structure. */ static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list); static inline void * alloc_fdmem(unsigned int size) { if (size <= PAGE_SIZE) return kmalloc(size, GFP_KERNEL); else return vmalloc(size); } static inline void free_fdarr(struct fdtable *fdt) { if (fdt->max_fds <= (PAGE_SIZE / sizeof(struct file *))) kfree(fdt->fd); else vfree(fdt->fd); } static inline void free_fdset(struct fdtable *fdt) { if (fdt->max_fds <= (PAGE_SIZE * BITS_PER_BYTE / 2)) kfree(fdt->open_fds); else vfree(fdt->open_fds); } static void free_fdtable_work(struct work_struct *work) { struct fdtable_defer *f = container_of(work, struct fdtable_defer, wq); struct fdtable *fdt; spin_lock_bh(&f->lock); fdt = f->next; f->next = NULL; spin_unlock_bh(&f->lock); while(fdt) { struct fdtable *next = fdt->next; vfree(fdt->fd); free_fdset(fdt); kfree(fdt); fdt = next; } } void free_fdtable_rcu(struct rcu_head *rcu) { struct fdtable *fdt = container_of(rcu, struct fdtable, rcu); struct fdtable_defer *fddef; BUG_ON(!fdt); if (fdt->max_fds <= NR_OPEN_DEFAULT) { /* * This fdtable is embedded in the files structure and that * structure itself is getting destroyed. */ kmem_cache_free(files_cachep, container_of(fdt, struct files_struct, fdtab)); return; } if (fdt->max_fds <= (PAGE_SIZE / sizeof(struct file *))) { kfree(fdt->fd); kfree(fdt->open_fds); kfree(fdt); } else { fddef = &get_cpu_var(fdtable_defer_list); spin_lock(&fddef->lock); fdt->next = fddef->next; fddef->next = fdt; /* vmallocs are handled from the workqueue context */ schedule_work(&fddef->wq); spin_unlock(&fddef->lock); put_cpu_var(fdtable_defer_list); } } /* * Expand the fdset in the files_struct. Called with the files spinlock * held for write. */ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt) { unsigned int cpy, set; BUG_ON(nfdt->max_fds < ofdt->max_fds); if (ofdt->max_fds == 0) return; cpy = ofdt->max_fds * sizeof(struct file *); set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *); memcpy(nfdt->fd, ofdt->fd, cpy); memset((char *)(nfdt->fd) + cpy, 0, set); cpy = ofdt->max_fds / BITS_PER_BYTE; set = (nfdt->max_fds - ofdt->max_fds) / BITS_PER_BYTE; memcpy(nfdt->open_fds, ofdt->open_fds, cpy); memset((char *)(nfdt->open_fds) + cpy, 0, set); memcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy); memset((char *)(nfdt->close_on_exec) + cpy, 0, set); } static struct fdtable * alloc_fdtable(unsigned int nr) { struct fdtable *fdt; char *data; /* * Figure out how many fds we actually want to support in this fdtable. * Allocation steps are keyed to the size of the fdarray, since it * grows far faster than any of the other dynamic data. We try to fit * the fdarray into comfortable page-tuned chunks: starting at 1024B * and growing in powers of two from there on. */ nr /= (1024 / sizeof(struct file *)); nr = roundup_pow_of_two(nr + 1); nr *= (1024 / sizeof(struct file *)); if (nr > sysctl_nr_open) nr = sysctl_nr_open; fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); if (!fdt) goto out; fdt->max_fds = nr; data = alloc_fdmem(nr * sizeof(struct file *)); if (!data) goto out_fdt; fdt->fd = (struct file **)data; data = alloc_fdmem(max_t(unsigned int, 2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES)); if (!data) goto out_arr; fdt->open_fds = (fd_set *)data; data += nr / BITS_PER_BYTE; fdt->close_on_exec = (fd_set *)data; INIT_RCU_HEAD(&fdt->rcu); fdt->next = NULL; return fdt; out_arr: free_fdarr(fdt); out_fdt: kfree(fdt); out: return NULL; } /* * Expand the file descriptor table. * This function will allocate a new fdtable and both fd array and fdset, of * the given size. * Return <0 error code on error; 1 on successful completion. * The files->file_lock should be held on entry, and will be held on exit. */ static int expand_fdtable(struct files_struct *files, int nr) __releases(files->file_lock) __acquires(files->file_lock) { struct fdtable *new_fdt, *cur_fdt; spin_unlock(&files->file_lock); new_fdt = alloc_fdtable(nr); spin_lock(&files->file_lock); if (!new_fdt) return -ENOMEM; /* * Check again since another task may have expanded the fd table while * we dropped the lock */ cur_fdt = files_fdtable(files); if (nr >= cur_fdt->max_fds) { /* Continue as planned */ copy_fdtable(new_fdt, cur_fdt); rcu_assign_pointer(files->fdt, new_fdt); if (cur_fdt->max_fds > NR_OPEN_DEFAULT) free_fdtable(cur_fdt); } else { /* Somebody else expanded, so undo our attempt */ free_fdarr(new_fdt); free_fdset(new_fdt); kfree(new_fdt); } return 1; } /* * Expand files. * This function will expand the file structures, if the requested size exceeds * the current capacity and there is room for expansion. * Return <0 error code on error; 0 when nothing done; 1 when files were * expanded and execution may have blocked. * The files->file_lock should be held on entry, and will be held on exit. */ int expand_files(struct files_struct *files, int nr) { struct fdtable *fdt; fdt = files_fdtable(files); /* Do we need to expand? */ if (nr < fdt->max_fds) return 0; /* Can we expand? */ if (nr >= sysctl_nr_open) return -EMFILE; /* All good, so we try */ return expand_fdtable(files, nr); } static void __devinit fdtable_defer_list_init(int cpu) { struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); spin_lock_init(&fddef->lock); INIT_WORK(&fddef->wq, free_fdtable_work); fddef->next = NULL; } void __init files_defer_init(void) { int i; for_each_possible_cpu(i) fdtable_defer_list_init(i); }
gpl-2.0
coolstar/coreboot
src/drivers/pc80/vga/vga_font_8x16.c
101417
/* * Copyright (C) 2007-2009 Luc Verhaegen <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. */ #include "vga.h" /**********************************************/ /* */ /* Font file generated by cpi2fnt */ /* */ /**********************************************/ const unsigned char vga_font_8x16[256][16] = { { /* 0 0x00 '^@' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 1 0x01 '^A' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x81, /* 10000001 */ 0xa5, /* 10100101 */ 0x81, /* 10000001 */ 0x81, /* 10000001 */ 0xbd, /* 10111101 */ 0x99, /* 10011001 */ 0x81, /* 10000001 */ 0x81, /* 10000001 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 2 0x02 '^B' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0xff, /* 11111111 */ 0xdb, /* 11011011 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xc3, /* 11000011 */ 0xe7, /* 11100111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 3 0x03 '^C' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x6c, /* 01101100 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0x7c, /* 01111100 */ 0x38, /* 00111000 */ 0x10, /* 00010000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 4 0x04 '^D' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x7c, /* 01111100 */ 0xfe, /* 11111110 */ 0x7c, /* 01111100 */ 0x38, /* 00111000 */ 0x10, /* 00010000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 5 0x05 '^E' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0xe7, /* 11100111 */ 0xe7, /* 11100111 */ 0xe7, /* 11100111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 6 0x06 '^F' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x7e, /* 01111110 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 7 0x07 '^G' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 8 0x08 '^H' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xe7, /* 11100111 */ 0xc3, /* 11000011 */ 0xc3, /* 11000011 */ 0xe7, /* 11100111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ }, { /* 9 0x09 '^I' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x42, /* 01000010 */ 0x42, /* 01000010 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 10 0x0a '^J' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xc3, /* 11000011 */ 0x99, /* 10011001 */ 0xbd, /* 10111101 */ 0xbd, /* 10111101 */ 0x99, /* 10011001 */ 0xc3, /* 11000011 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ }, { /* 11 0x0b '^K' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1e, /* 00011110 */ 0x0e, /* 00001110 */ 0x1a, /* 00011010 */ 0x32, /* 00110010 */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 12 0x0c '^L' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 13 0x0d '^M' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3f, /* 00111111 */ 0x33, /* 00110011 */ 0x3f, /* 00111111 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x70, /* 01110000 */ 0xf0, /* 11110000 */ 0xe0, /* 11100000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 14 0x0e '^N' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7f, /* 01111111 */ 0x63, /* 01100011 */ 0x7f, /* 01111111 */ 0x63, /* 01100011 */ 0x63, /* 01100011 */ 0x63, /* 01100011 */ 0x63, /* 01100011 */ 0x67, /* 01100111 */ 0xe7, /* 11100111 */ 0xe6, /* 11100110 */ 0xc0, /* 11000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 15 0x0f '^O' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xdb, /* 11011011 */ 0x3c, /* 00111100 */ 0xe7, /* 11100111 */ 0x3c, /* 00111100 */ 0xdb, /* 11011011 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 16 0x10 '^P' */ 0x00, /* 00000000 */ 0x80, /* 10000000 */ 0xc0, /* 11000000 */ 0xe0, /* 11100000 */ 0xf0, /* 11110000 */ 0xf8, /* 11111000 */ 0xfe, /* 11111110 */ 0xf8, /* 11111000 */ 0xf0, /* 11110000 */ 0xe0, /* 11100000 */ 0xc0, /* 11000000 */ 0x80, /* 10000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 17 0x11 '^Q' */ 0x00, /* 00000000 */ 0x02, /* 00000010 */ 0x06, /* 00000110 */ 0x0e, /* 00001110 */ 0x1e, /* 00011110 */ 0x3e, /* 00111110 */ 0xfe, /* 11111110 */ 0x3e, /* 00111110 */ 0x1e, /* 00011110 */ 0x0e, /* 00001110 */ 0x06, /* 00000110 */ 0x02, /* 00000010 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 18 0x12 '^R' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 19 0x13 '^S' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 20 0x14 '^T' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7f, /* 01111111 */ 0xdb, /* 11011011 */ 0xdb, /* 11011011 */ 0xdb, /* 11011011 */ 0x7b, /* 01111011 */ 0x1b, /* 00011011 */ 0x1b, /* 00011011 */ 0x1b, /* 00011011 */ 0x1b, /* 00011011 */ 0x1b, /* 00011011 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 21 0x15 '^U' */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0x60, /* 01100000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x0c, /* 00001100 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 22 0x16 '^V' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 23 0x17 '^W' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 24 0x18 '^X' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 25 0x19 '^Y' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 26 0x1a '^Z' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0xfe, /* 11111110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 27 0x1b '^[' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xfe, /* 11111110 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 28 0x1c '^\' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 29 0x1d '^]' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x28, /* 00101000 */ 0x6c, /* 01101100 */ 0xfe, /* 11111110 */ 0x6c, /* 01101100 */ 0x28, /* 00101000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 30 0x1e '^^' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x38, /* 00111000 */ 0x7c, /* 01111100 */ 0x7c, /* 01111100 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 31 0x1f '^_' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0x7c, /* 01111100 */ 0x7c, /* 01111100 */ 0x38, /* 00111000 */ 0x38, /* 00111000 */ 0x10, /* 00010000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 32 0x20 ' ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 33 0x21 '!' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 34 0x22 '"' */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x24, /* 00100100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 35 0x23 '#' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0xfe, /* 11111110 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0xfe, /* 11111110 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 36 0x24 '$' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc2, /* 11000010 */ 0xc0, /* 11000000 */ 0x7c, /* 01111100 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x86, /* 10000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 37 0x25 '%' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc2, /* 11000010 */ 0xc6, /* 11000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc6, /* 11000110 */ 0x86, /* 10000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 38 0x26 '&' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 39 0x27 ''' */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 40 0x28 '(' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 41 0x29 ')' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 42 0x2a '*' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0xff, /* 11111111 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 43 0x2b '+' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 44 0x2c ',' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 45 0x2d '-' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 46 0x2e '.' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 47 0x2f '/' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x02, /* 00000010 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0x80, /* 10000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 48 0x30 '0' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 49 0x31 '1' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x38, /* 00111000 */ 0x78, /* 01111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 50 0x32 '2' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 51 0x33 '3' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x3c, /* 00111100 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 52 0x34 '4' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0c, /* 00001100 */ 0x1c, /* 00011100 */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ 0xcc, /* 11001100 */ 0xfe, /* 11111110 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x1e, /* 00011110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 53 0x35 '5' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xfc, /* 11111100 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 54 0x36 '6' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xfc, /* 11111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 55 0x37 '7' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 56 0x38 '8' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 57 0x39 '9' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7e, /* 01111110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 58 0x3a ':' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 59 0x3b ';' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 60 0x3c '<' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x06, /* 00000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 61 0x3d '=' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 62 0x3e '>' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 63 0x3f '?' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 64 0x40 '@' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xde, /* 11011110 */ 0xde, /* 11011110 */ 0xde, /* 11011110 */ 0xdc, /* 11011100 */ 0xc0, /* 11000000 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 65 0x41 'A' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 66 0x42 'B' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfc, /* 11111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0xfc, /* 11111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 67 0x43 'C' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0xc2, /* 11000010 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc2, /* 11000010 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 68 0x44 'D' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xf8, /* 11111000 */ 0x6c, /* 01101100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x6c, /* 01101100 */ 0xf8, /* 11111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 69 0x45 'E' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x66, /* 01100110 */ 0x62, /* 01100010 */ 0x68, /* 01101000 */ 0x78, /* 01111000 */ 0x68, /* 01101000 */ 0x60, /* 01100000 */ 0x62, /* 01100010 */ 0x66, /* 01100110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 70 0x46 'F' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x66, /* 01100110 */ 0x62, /* 01100010 */ 0x68, /* 01101000 */ 0x78, /* 01111000 */ 0x68, /* 01101000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xf0, /* 11110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 71 0x47 'G' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0xc2, /* 11000010 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xde, /* 11011110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x66, /* 01100110 */ 0x3a, /* 00111010 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 72 0x48 'H' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 73 0x49 'I' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 74 0x4a 'J' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1e, /* 00011110 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 75 0x4b 'K' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xe6, /* 11100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x6c, /* 01101100 */ 0x78, /* 01111000 */ 0x78, /* 01111000 */ 0x6c, /* 01101100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0xe6, /* 11100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 76 0x4c 'L' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xf0, /* 11110000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x62, /* 01100010 */ 0x66, /* 01100110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 77 0x4d 'M' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xee, /* 11101110 */ 0xfe, /* 11111110 */ 0xfe, /* 11111110 */ 0xd6, /* 11010110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 78 0x4e 'N' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xe6, /* 11100110 */ 0xf6, /* 11110110 */ 0xfe, /* 11111110 */ 0xde, /* 11011110 */ 0xce, /* 11001110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 79 0x4f 'O' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 80 0x50 'P' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfc, /* 11111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xf0, /* 11110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 81 0x51 'Q' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xd6, /* 11010110 */ 0xde, /* 11011110 */ 0x7c, /* 01111100 */ 0x0c, /* 00001100 */ 0x0e, /* 00001110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 82 0x52 'R' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfc, /* 11111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x6c, /* 01101100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0xe6, /* 11100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 83 0x53 'S' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x60, /* 01100000 */ 0x38, /* 00111000 */ 0x0c, /* 00001100 */ 0x06, /* 00000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 84 0x54 'T' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x5a, /* 01011010 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 85 0x55 'U' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 86 0x56 'V' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x10, /* 00010000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 87 0x57 'W' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xfe, /* 11111110 */ 0xee, /* 11101110 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 88 0x58 'X' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x7c, /* 01111100 */ 0x38, /* 00111000 */ 0x38, /* 00111000 */ 0x7c, /* 01111100 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 89 0x59 'Y' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 90 0x5a 'Z' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0x86, /* 10000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc2, /* 11000010 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 91 0x5b '[' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 92 0x5c '\' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x80, /* 10000000 */ 0xc0, /* 11000000 */ 0xe0, /* 11100000 */ 0x70, /* 01110000 */ 0x38, /* 00111000 */ 0x1c, /* 00011100 */ 0x0e, /* 00001110 */ 0x06, /* 00000110 */ 0x02, /* 00000010 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 93 0x5d ']' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 94 0x5e '^' */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 95 0x5f '_' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 96 0x60 '`' */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 97 0x61 'a' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 98 0x62 'b' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xe0, /* 11100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x78, /* 01111000 */ 0x6c, /* 01101100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 99 0x63 'c' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 100 0x64 'd' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1c, /* 00011100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 101 0x65 'e' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 102 0x66 'f' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1c, /* 00011100 */ 0x36, /* 00110110 */ 0x32, /* 00110010 */ 0x30, /* 00110000 */ 0x78, /* 01111000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 103 0x67 'g' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x7c, /* 01111100 */ 0x0c, /* 00001100 */ 0xcc, /* 11001100 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ }, { /* 104 0x68 'h' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xe0, /* 11100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x6c, /* 01101100 */ 0x76, /* 01110110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0xe6, /* 11100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 105 0x69 'i' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 106 0x6a 'j' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x00, /* 00000000 */ 0x0e, /* 00001110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ }, { /* 107 0x6b 'k' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xe0, /* 11100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x66, /* 01100110 */ 0x6c, /* 01101100 */ 0x78, /* 01111000 */ 0x78, /* 01111000 */ 0x6c, /* 01101100 */ 0x66, /* 01100110 */ 0xe6, /* 11100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 108 0x6c 'l' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 109 0x6d 'm' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xec, /* 11101100 */ 0xfe, /* 11111110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 110 0x6e 'n' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xdc, /* 11011100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 111 0x6f 'o' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 112 0x70 'p' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xdc, /* 11011100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xf0, /* 11110000 */ 0x00, /* 00000000 */ }, { /* 113 0x71 'q' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x7c, /* 01111100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x1e, /* 00011110 */ 0x00, /* 00000000 */ }, { /* 114 0x72 'r' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xdc, /* 11011100 */ 0x76, /* 01110110 */ 0x66, /* 01100110 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xf0, /* 11110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 115 0x73 's' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0x60, /* 01100000 */ 0x38, /* 00111000 */ 0x0c, /* 00001100 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 116 0x74 't' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0xfc, /* 11111100 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x36, /* 00110110 */ 0x1c, /* 00011100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 117 0x75 'u' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 118 0x76 'v' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 119 0x77 'w' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xd6, /* 11010110 */ 0xfe, /* 11111110 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 120 0x78 'x' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x38, /* 00111000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 121 0x79 'y' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7e, /* 01111110 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0xf8, /* 11111000 */ 0x00, /* 00000000 */ }, { /* 122 0x7a 'z' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xcc, /* 11001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 123 0x7b '{' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0e, /* 00001110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x70, /* 01110000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x0e, /* 00001110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 124 0x7c '|' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 125 0x7d '}' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x70, /* 01110000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x0e, /* 00001110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 126 0x7e '~' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 127 0x7f '' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 128 0x80 '€' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0xc2, /* 11000010 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc2, /* 11000010 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 129 0x81 '' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 130 0x82 '‚' */ 0x00, /* 00000000 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 131 0x83 'ƒ' */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 132 0x84 '„' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 133 0x85 '…' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 134 0x86 '†' */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 135 0x87 '‡' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x18, /* 00011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 136 0x88 'ˆ' */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 137 0x89 '‰' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 138 0x8a 'Š' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 139 0x8b '‹' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 140 0x8c 'Œ' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 141 0x8d '' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 142 0x8e 'Ž' */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 143 0x8f '' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 144 0x90 '' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x66, /* 01100110 */ 0x62, /* 01100010 */ 0x68, /* 01101000 */ 0x78, /* 01111000 */ 0x68, /* 01101000 */ 0x62, /* 01100010 */ 0x66, /* 01100110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 145 0x91 '‘' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xec, /* 11101100 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x7e, /* 01111110 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0x6e, /* 01101110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 146 0x92 '’' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3e, /* 00111110 */ 0x6c, /* 01101100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xfe, /* 11111110 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xce, /* 11001110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 147 0x93 '“' */ 0x00, /* 00000000 */ 0x10, /* 00010000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 148 0x94 '”' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 149 0x95 '•' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 150 0x96 '–' */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 151 0x97 '—' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 152 0x98 '˜' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7e, /* 01111110 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x78, /* 01111000 */ 0x00, /* 00000000 */ }, { /* 153 0x99 '™' */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 154 0x9a 'š' */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 155 0x9b '›' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 156 0x9c 'œ' */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x64, /* 01100100 */ 0x60, /* 01100000 */ 0xf0, /* 11110000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xe6, /* 11100110 */ 0xfc, /* 11111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 157 0x9d '' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 158 0x9e 'ž' */ 0x00, /* 00000000 */ 0xf8, /* 11111000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xf8, /* 11111000 */ 0xc4, /* 11000100 */ 0xcc, /* 11001100 */ 0xde, /* 11011110 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 159 0x9f 'Ÿ' */ 0x00, /* 00000000 */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xd8, /* 11011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 160 0xa0 ' ' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ 0x7c, /* 01111100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 161 0xa1 '¡' */ 0x00, /* 00000000 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 162 0xa2 '¢' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 163 0xa3 '£' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 164 0xa4 '¤' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x00, /* 00000000 */ 0xdc, /* 11011100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 165 0xa5 '¥' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x00, /* 00000000 */ 0xc6, /* 11000110 */ 0xe6, /* 11100110 */ 0xf6, /* 11110110 */ 0xfe, /* 11111110 */ 0xde, /* 11011110 */ 0xce, /* 11001110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 166 0xa6 '¦' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x3e, /* 00111110 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 167 0xa7 '§' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 168 0xa8 '¨' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x7c, /* 01111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 169 0xa9 '©' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 170 0xaa 'ª' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 171 0xab '«' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0xe0, /* 11100000 */ 0x62, /* 01100010 */ 0x66, /* 01100110 */ 0x6c, /* 01101100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xdc, /* 11011100 */ 0x86, /* 10000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x3e, /* 00111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 172 0xac '¬' */ 0x00, /* 00000000 */ 0x60, /* 01100000 */ 0xe0, /* 11100000 */ 0x62, /* 01100010 */ 0x66, /* 01100110 */ 0x6c, /* 01101100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x66, /* 01100110 */ 0xce, /* 11001110 */ 0x9a, /* 10011010 */ 0x3f, /* 00111111 */ 0x06, /* 00000110 */ 0x06, /* 00000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 173 0xad '­' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 174 0xae '®' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x36, /* 00110110 */ 0x6c, /* 01101100 */ 0xd8, /* 11011000 */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 175 0xaf '¯' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xd8, /* 11011000 */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ 0x6c, /* 01101100 */ 0xd8, /* 11011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 176 0xb0 '°' */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ 0x11, /* 00010001 */ 0x44, /* 01000100 */ }, { /* 177 0xb1 '±' */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ }, { /* 178 0xb2 '²' */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ 0x77, /* 01110111 */ }, { /* 179 0xb3 '³' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 180 0xb4 '´' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 181 0xb5 'µ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 182 0xb6 '¶' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xf6, /* 11110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 183 0xb7 '·' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 184 0xb8 '¸' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 185 0xb9 '¹' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xf6, /* 11110110 */ 0x06, /* 00000110 */ 0xf6, /* 11110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 186 0xba 'º' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 187 0xbb '»' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x06, /* 00000110 */ 0xf6, /* 11110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 188 0xbc '¼' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xf6, /* 11110110 */ 0x06, /* 00000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 189 0xbd '½' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 190 0xbe '¾' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 191 0xbf '¿' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xf8, /* 11111000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 192 0xc0 'À' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 193 0xc1 'Á' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 194 0xc2 'Â' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 195 0xc3 'Ã' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 196 0xc4 'Ä' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 197 0xc5 'Å' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xff, /* 11111111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 198 0xc6 'Æ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 199 0xc7 'Ç' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x37, /* 00110111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 200 0xc8 'È' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x37, /* 00110111 */ 0x30, /* 00110000 */ 0x3f, /* 00111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 201 0xc9 'É' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3f, /* 00111111 */ 0x30, /* 00110000 */ 0x37, /* 00110111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 202 0xca 'Ê' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xf7, /* 11110111 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 203 0xcb 'Ë' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0xf7, /* 11110111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 204 0xcc 'Ì' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x37, /* 00110111 */ 0x30, /* 00110000 */ 0x37, /* 00110111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 205 0xcd 'Í' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 206 0xce 'Î' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xf7, /* 11110111 */ 0x00, /* 00000000 */ 0xf7, /* 11110111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 207 0xcf 'Ï' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 208 0xd0 'Ð' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 209 0xd1 'Ñ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 210 0xd2 'Ò' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 211 0xd3 'Ó' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x3f, /* 00111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 212 0xd4 'Ô' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 213 0xd5 'Õ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 214 0xd6 'Ö' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3f, /* 00111111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 215 0xd7 '×' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0xff, /* 11111111 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ }, { /* 216 0xd8 'Ø' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xff, /* 11111111 */ 0x18, /* 00011000 */ 0xff, /* 11111111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 217 0xd9 'Ù' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xf8, /* 11111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 218 0xda 'Ú' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1f, /* 00011111 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 219 0xdb 'Û' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ }, { /* 220 0xdc 'Ü' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ }, { /* 221 0xdd 'Ý' */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ }, { /* 222 0xde 'Þ' */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ }, { /* 223 0xdf 'ß' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 224 0xe0 'à' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xdc, /* 11011100 */ 0x76, /* 01110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 225 0xe1 'á' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xcc, /* 11001100 */ 0xd8, /* 11011000 */ 0xcc, /* 11001100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 226 0xe2 'â' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0xc0, /* 11000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 227 0xe3 'ã' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 228 0xe4 'ä' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 229 0xe5 'å' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 230 0xe6 'æ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x7c, /* 01111100 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0x00, /* 00000000 */ }, { /* 231 0xe7 'ç' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 232 0xe8 'è' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 233 0xe9 'é' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 234 0xea 'ê' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0xee, /* 11101110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 235 0xeb 'ë' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1e, /* 00011110 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x3e, /* 00111110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ 0x3c, /* 00111100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 236 0xec 'ì' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0xdb, /* 11011011 */ 0xdb, /* 11011011 */ 0xdb, /* 11011011 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 237 0xed 'í' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x03, /* 00000011 */ 0x06, /* 00000110 */ 0x7e, /* 01111110 */ 0xdb, /* 11011011 */ 0xdb, /* 11011011 */ 0xf3, /* 11110011 */ 0x7e, /* 01111110 */ 0x60, /* 01100000 */ 0xc0, /* 11000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 238 0xee 'î' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x1c, /* 00011100 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x7c, /* 01111100 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x1c, /* 00011100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 239 0xef 'ï' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 240 0xf0 'ð' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 241 0xf1 'ñ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 242 0xf2 'ò' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 243 0xf3 'ó' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ 0x0c, /* 00001100 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 244 0xf4 'ô' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ 0x1b, /* 00011011 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ }, { /* 245 0xf5 'õ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0xd8, /* 11011000 */ 0x70, /* 01110000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 246 0xf6 'ö' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 247 0xf7 '÷' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 248 0xf8 'ø' */ 0x00, /* 00000000 */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x38, /* 00111000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 249 0xf9 'ù' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 250 0xfa 'ú' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 251 0xfb 'û' */ 0x00, /* 00000000 */ 0x0f, /* 00001111 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0x0c, /* 00001100 */ 0xec, /* 11101100 */ 0x6c, /* 01101100 */ 0x6c, /* 01101100 */ 0x3c, /* 00111100 */ 0x1c, /* 00011100 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 252 0xfc 'ü' */ 0x00, /* 00000000 */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 253 0xfd 'ý' */ 0x00, /* 00000000 */ 0x3c, /* 00111100 */ 0x66, /* 01100110 */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ 0x32, /* 00110010 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 254 0xfe 'þ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x7e, /* 01111110 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, { /* 255 0xff 'ÿ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }, };
gpl-2.0
mmuir-ca/tracmor
includes/data_meta_controls/AssetModelCustomFieldHelperMetaControl.class.php
1030
<?php require(__DATAGEN_META_CONTROLS__ . '/AssetModelCustomFieldHelperMetaControlGen.class.php'); /** * This is a MetaControl customizable subclass, providing a QForm or QPanel access to event handlers * and QControls to perform the Create, Edit, and Delete functionality of the * AssetModelCustomFieldHelper class. This code-generated class extends from * the generated MetaControl class, which contains all the basic elements to help a QPanel or QForm * display an HTML form that can manipulate a single AssetModelCustomFieldHelper object. * * To take advantage of some (or all) of these control objects, you * must create a new QForm or QPanel which instantiates a AssetModelCustomFieldHelperMetaControl * class. * * This file is intended to be modified. Subsequent code regenerations will NOT modify * or overwrite this file. * * @package My Application * @subpackage MetaControls */ class AssetModelCustomFieldHelperMetaControl extends AssetModelCustomFieldHelperMetaControlGen { } ?>
gpl-2.0
meghraj143/WebsiteRaj
css/bootstrap.css
137232
html { font-family: sans-serif; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } body { margin: 0; overflow-y:auto; } ::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(255,255,255,1); border-radius: 5px; } ::-webkit-scrollbar-thumb { border-radius: 10px; -webkit-box-shadow: inset 0 0 6px rgba(255,255,255,1); } article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } audio, canvas, progress, video { display: inline-block; vertical-align: baseline; } audio:not([controls]) { display: none; height: 0; } [hidden], template { display: none; } a:active, a:hover { outline: 0; } abbr[title] { border-bottom: 1px dotted; } b, strong { font-weight: bold; } dfn { font-style: italic; } h1 { margin: .67em 0; font-size: 3em; } mark { color: #000; background: #ff0; } small { font-size: 80%; } sub, sup { position: relative; font-size: 75%; line-height: 0; vertical-align: baseline; } sup { top: -.5em; } sub { bottom: -.25em; } img { border: 0; } svg:not(:root) { overflow: hidden; } figure { margin: 1em 40px; } hr { height: 0; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; } pre { overflow: auto; } code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; } button, input, optgroup, select, textarea { margin: 0; font: inherit; color: inherit; } button { overflow: visible; } button, select { text-transform: none; } button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; } button[disabled], html input[disabled] { cursor: default; } button::-moz-focus-inner, input::-moz-focus-inner { padding: 0; border: 0; } input { line-height: normal; } input[type="checkbox"], input[type="radio"] { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0; } input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } input[type="search"] { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; -webkit-appearance: textfield; } input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } fieldset { padding: .35em .625em .75em; margin: 0 2px; border: 1px solid #c0c0c0; } legend { padding: 0; border: 0; } textarea { overflow: auto; } optgroup { font-weight: bold; } table { border-spacing: 0; border-collapse: collapse; } td, th { padding: 0; } /*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */ @media print { *, *:before, *:after { color: #000 !important; text-shadow: none !important; background: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; } a, a:visited { text-decoration: underline; } a[href]:after { content: " (" attr(href) ")"; } abbr[title]:after { content: " (" attr(title) ")"; } a[href^="#"]:after, a[href^="javascript:"]:after { content: ""; } pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } thead { display: table-header-group; } tr, img { page-break-inside: avoid; } img { max-width: 100% !important; } p, h2, h3 { orphans: 3; widows: 3; } h2, h3 { page-break-after: avoid; } select { background: #fff !important; } .navbar { display: none; } .btn > .caret, .dropup > .btn > .caret { border-top-color: #000 !important; } .label { border: 1px solid #000; } .table { border-collapse: collapse !important; } .table td, .table th { background-color: #fff !important; } .table-bordered th, .table-bordered td { border: 1px solid #ddd !important; } } @font-face { font-family: 'Glyphicons Halflings'; src: url('../fonts/glyphicons-halflings-regular.eot'); src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } .glyphicon { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .glyphicon-asterisk:before { content: "\2a"; } .glyphicon-plus:before { content: "\2b"; } .glyphicon-euro:before, .glyphicon-eur:before { content: "\20ac"; } .glyphicon-minus:before { content: "\2212"; } .glyphicon-cloud:before { content: "\2601"; } .glyphicon-envelope:before { content: "\2709"; } .glyphicon-pencil:before { content: "\270f"; } .glyphicon-glass:before { content: "\e001"; } .glyphicon-music:before { content: "\e002"; } .glyphicon-search:before { content: "\e003"; } .glyphicon-heart:before { content: "\e005"; } .glyphicon-star:before { content: "\e006"; } .glyphicon-star-empty:before { content: "\e007"; } .glyphicon-user:before { content: "\e008"; } .glyphicon-film:before { content: "\e009"; } .glyphicon-th-large:before { content: "\e010"; } .glyphicon-th:before { content: "\e011"; } .glyphicon-th-list:before { content: "\e012"; } .glyphicon-ok:before { content: "\e013"; } .glyphicon-remove:before { content: "\e014"; } .glyphicon-zoom-in:before { content: "\e015"; } .glyphicon-zoom-out:before { content: "\e016"; } .glyphicon-off:before { content: "\e017"; } .glyphicon-signal:before { content: "\e018"; } .glyphicon-cog:before { content: "\e019"; } .glyphicon-trash:before { content: "\e020"; } .glyphicon-home:before { content: "\e021"; } .glyphicon-file:before { content: "\e022"; } .glyphicon-time:before { content: "\e023"; } .glyphicon-road:before { content: "\e024"; } .glyphicon-download-alt:before { content: "\e025"; } .glyphicon-download:before { content: "\e026"; } .glyphicon-upload:before { content: "\e027"; } .glyphicon-inbox:before { content: "\e028"; } .glyphicon-play-circle:before { content: "\e029"; } .glyphicon-repeat:before { content: "\e030"; } .glyphicon-refresh:before { content: "\e031"; } .glyphicon-list-alt:before { content: "\e032"; } .glyphicon-lock:before { content: "\e033"; } .glyphicon-flag:before { content: "\e034"; } .glyphicon-headphones:before { content: "\e035"; } .glyphicon-volume-off:before { content: "\e036"; } .glyphicon-volume-down:before { content: "\e037"; } .glyphicon-volume-up:before { content: "\e038"; } .glyphicon-qrcode:before { content: "\e039"; } .glyphicon-barcode:before { content: "\e040"; } .glyphicon-tag:before { content: "\e041"; } .glyphicon-tags:before { content: "\e042"; } .glyphicon-book:before { content: "\e043"; } .glyphicon-bookmark:before { content: "\e044"; } .glyphicon-print:before { content: "\e045"; } .glyphicon-camera:before { content: "\e046"; } .glyphicon-font:before { content: "\e047"; } .glyphicon-bold:before { content: "\e048"; } .glyphicon-italic:before { content: "\e049"; } .glyphicon-text-height:before { content: "\e050"; } .glyphicon-text-width:before { content: "\e051"; } .glyphicon-align-left:before { content: "\e052"; } .glyphicon-align-center:before { content: "\e053"; } .glyphicon-align-right:before { content: "\e054"; } .glyphicon-align-justify:before { content: "\e055"; } .glyphicon-list:before { content: "\e056"; } .glyphicon-indent-left:before { content: "\e057"; } .glyphicon-indent-right:before { content: "\e058"; } .glyphicon-facetime-video:before { content: "\e059"; } .glyphicon-picture:before { content: "\e060"; } .glyphicon-map-marker:before { content: "\e062"; } .glyphicon-adjust:before { content: "\e063"; } .glyphicon-tint:before { content: "\e064"; } .glyphicon-edit:before { content: "\e065"; } .glyphicon-share:before { content: "\e066"; } .glyphicon-check:before { content: "\e067"; } .glyphicon-move:before { content: "\e068"; } .glyphicon-step-backward:before { content: "\e069"; } .glyphicon-fast-backward:before { content: "\e070"; } .glyphicon-backward:before { content: "\e071"; } .glyphicon-play:before { content: "\e072"; } .glyphicon-pause:before { content: "\e073"; } .glyphicon-stop:before { content: "\e074"; } .glyphicon-forward:before { content: "\e075"; } .glyphicon-fast-forward:before { content: "\e076"; } .glyphicon-step-forward:before { content: "\e077"; } .glyphicon-eject:before { content: "\e078"; } .glyphicon-chevron-left:before { content: "\e079"; } .glyphicon-chevron-right:before { content: "\e080"; } .glyphicon-plus-sign:before { content: "\e081"; } .glyphicon-minus-sign:before { content: "\e082"; } .glyphicon-remove-sign:before { content: "\e083"; } .glyphicon-ok-sign:before { content: "\e084"; } .glyphicon-question-sign:before { content: "\e085"; } .glyphicon-info-sign:before { content: "\e086"; } .glyphicon-screenshot:before { content: "\e087"; } .glyphicon-remove-circle:before { content: "\e088"; } .glyphicon-ok-circle:before { content: "\e089"; } .glyphicon-ban-circle:before { content: "\e090"; } .glyphicon-arrow-left:before { content: "\e091"; } .glyphicon-arrow-right:before { content: "\e092"; } .glyphicon-arrow-up:before { content: "\e093"; } .glyphicon-arrow-down:before { content: "\e094"; } .glyphicon-share-alt:before { content: "\e095"; } .glyphicon-resize-full:before { content: "\e096"; } .glyphicon-resize-small:before { content: "\e097"; } .glyphicon-exclamation-sign:before { content: "\e101"; } .glyphicon-gift:before { content: "\e102"; } .glyphicon-leaf:before { content: "\e103"; } .glyphicon-fire:before { content: "\e104"; } .glyphicon-eye-open:before { content: "\e105"; } .glyphicon-eye-close:before { content: "\e106"; } .glyphicon-warning-sign:before { content: "\e107"; } .glyphicon-plane:before { content: "\e108"; } .glyphicon-calendar:before { content: "\e109"; } .glyphicon-random:before { content: "\e110"; } .glyphicon-comment:before { content: "\e111"; } .glyphicon-magnet:before { content: "\e112"; } .glyphicon-chevron-up:before { content: "\e113"; } .glyphicon-chevron-down:before { content: "\e114"; } .glyphicon-retweet:before { content: "\e115"; } .glyphicon-shopping-cart:before { content: "\e116"; } .glyphicon-folder-close:before { content: "\e117"; } .glyphicon-folder-open:before { content: "\e118"; } .glyphicon-resize-vertical:before { content: "\e119"; } .glyphicon-resize-horizontal:before { content: "\e120"; } .glyphicon-hdd:before { content: "\e121"; } .glyphicon-bullhorn:before { content: "\e122"; } .glyphicon-bell:before { content: "\e123"; } .glyphicon-certificate:before { content: "\e124"; } .glyphicon-thumbs-up:before { content: "\e125"; } .glyphicon-thumbs-down:before { content: "\e126"; } .glyphicon-hand-right:before { content: "\e127"; } .glyphicon-hand-left:before { content: "\e128"; } .glyphicon-hand-up:before { content: "\e129"; } .glyphicon-hand-down:before { content: "\e130"; } .glyphicon-circle-arrow-right:before { content: "\e131"; } .glyphicon-circle-arrow-left:before { content: "\e132"; } .glyphicon-circle-arrow-up:before { content: "\e133"; } .glyphicon-circle-arrow-down:before { content: "\e134"; } .glyphicon-globe:before { content: "\e135"; } .glyphicon-wrench:before { content: "\e136"; } .glyphicon-tasks:before { content: "\e137"; } .glyphicon-filter:before { content: "\e138"; } .glyphicon-briefcase:before { content: "\e139"; } .glyphicon-fullscreen:before { content: "\e140"; } .glyphicon-dashboard:before { content: "\e141"; } .glyphicon-paperclip:before { content: "\e142"; } .glyphicon-heart-empty:before { content: "\e143"; } .glyphicon-link:before { content: "\e144"; } .glyphicon-phone:before { content: "\e145"; } .glyphicon-pushpin:before { content: "\e146"; } .glyphicon-usd:before { content: "\e148"; } .glyphicon-gbp:before { content: "\e149"; } .glyphicon-sort:before { content: "\e150"; } .glyphicon-sort-by-alphabet:before { content: "\e151"; } .glyphicon-sort-by-alphabet-alt:before { content: "\e152"; } .glyphicon-sort-by-order:before { content: "\e153"; } .glyphicon-sort-by-order-alt:before { content: "\e154"; } .glyphicon-sort-by-attributes:before { content: "\e155"; } .glyphicon-sort-by-attributes-alt:before { content: "\e156"; } .glyphicon-unchecked:before { content: "\e157"; } .glyphicon-expand:before { content: "\e158"; } .glyphicon-collapse-down:before { content: "\e159"; } .glyphicon-collapse-up:before { content: "\e160"; } .glyphicon-log-in:before { content: "\e161"; } .glyphicon-flash:before { content: "\e162"; } .glyphicon-log-out:before { content: "\e163"; } .glyphicon-new-window:before { content: "\e164"; } .glyphicon-record:before { content: "\e165"; } .glyphicon-save:before { content: "\e166"; } .glyphicon-open:before { content: "\e167"; } .glyphicon-saved:before { content: "\e168"; } .glyphicon-import:before { content: "\e169"; } .glyphicon-export:before { content: "\e170"; } .glyphicon-send:before { content: "\e171"; } .glyphicon-floppy-disk:before { content: "\e172"; } .glyphicon-floppy-saved:before { content: "\e173"; } .glyphicon-floppy-remove:before { content: "\e174"; } .glyphicon-floppy-save:before { content: "\e175"; } .glyphicon-floppy-open:before { content: "\e176"; } .glyphicon-credit-card:before { content: "\e177"; } .glyphicon-transfer:before { content: "\e178"; } .glyphicon-cutlery:before { content: "\e179"; } .glyphicon-header:before { content: "\e180"; } .glyphicon-compressed:before { content: "\e181"; } .glyphicon-earphone:before { content: "\e182"; } .glyphicon-phone-alt:before { content: "\e183"; } .glyphicon-tower:before { content: "\e184"; } .glyphicon-stats:before { content: "\e185"; } .glyphicon-sd-video:before { content: "\e186"; } .glyphicon-hd-video:before { content: "\e187"; } .glyphicon-subtitles:before { content: "\e188"; } .glyphicon-sound-stereo:before { content: "\e189"; } .glyphicon-sound-dolby:before { content: "\e190"; } .glyphicon-sound-5-1:before { content: "\e191"; } .glyphicon-sound-6-1:before { content: "\e192"; } .glyphicon-sound-7-1:before { content: "\e193"; } .glyphicon-copyright-mark:before { content: "\e194"; } .glyphicon-registration-mark:before { content: "\e195"; } .glyphicon-cloud-download:before { content: "\e197"; } .glyphicon-cloud-upload:before { content: "\e198"; } .glyphicon-tree-conifer:before { content: "\e199"; } .glyphicon-tree-deciduous:before { content: "\e200"; } * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } *:before, *:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } html { font-size: 10px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.42857143; color: #333; background-color: #fff; } input, button, select, textarea { font-family: inherit; font-size: inherit; line-height: inherit; } a { color: #337ab7; text-decoration: none; } a:hover, a:focus { color: #23527c; text-decoration: underline; } a:focus { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } figure { margin: 0; } img { vertical-align: middle; } .img-responsive, .thumbnail > img, .thumbnail a > img, .carousel-inner > .item > img, .carousel-inner > .item > a > img { display: block; max-width: 100%; height: auto; } .img-rounded { border-radius: 6px; } .img-thumbnail { display: inline-block; max-width: 100%; height: auto; padding: 4px; line-height: 1.42857143; background-color: #fff; border: 1px solid #ddd; border-radius: 4px; -webkit-transition: all .2s ease-in-out; -o-transition: all .2s ease-in-out; transition: all .2s ease-in-out; } .img-circle { border-radius: 50%; } hr { margin-top: 20px; margin-bottom: 20px; border: 0; border-top: 1px solid #eee; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; } .sr-only-focusable:active, .sr-only-focusable:focus { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; } h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; } h1 small, h2 small, h3 small, h4 small, h5 small, h6 small, .h1 small, .h2 small, .h3 small, .h4 small, .h5 small, .h6 small, h1 .small, h2 .small, h3 .small, h4 .small, h5 .small, h6 .small, .h1 .small, .h2 .small, .h3 .small, .h4 .small, .h5 .small, .h6 .small { font-weight: normal; line-height: 1; color: #777; } h1, .h1, h2, .h2, h3, .h3 { margin-top: 20px; margin-bottom: 10px; } h1 small, .h1 small, h2 small, .h2 small, h3 small, .h3 small, h1 .small, .h1 .small, h2 .small, .h2 .small, h3 .small, .h3 .small { font-size: 65%; } h4, .h4, h5, .h5, h6, .h6 { margin-top: 10px; margin-bottom: 10px; } h4 small, .h4 small, h5 small, .h5 small, h6 small, .h6 small, h4 .small, .h4 .small, h5 .small, .h5 .small, h6 .small, .h6 .small { font-size: 75%; } h1, .h1 { font-size: 36px; } h2, .h2 { font-size: 30px; } h3, .h3 { font-size: 24px; } h4, .h4 { font-size: 18px; } h5, .h5 { font-size: 14px; } h6, .h6 { font-size: 12px; } p { margin: 0 0 10px; } .lead { margin-bottom: 20px; font-size: 16px; font-weight: 300; line-height: 1.4; } @media (min-width: 768px) { .lead { font-size: 21px; } } small, .small { font-size: 85%; } mark, .mark { padding: .2em; background-color: #fcf8e3; } .text-left { text-align: left; } .text-right { text-align: right; } .text-center { text-align: center; } .text-justify { text-align: justify; } .text-nowrap { white-space: nowrap; } .text-lowercase { text-transform: lowercase; } .text-uppercase { text-transform: uppercase; } .text-capitalize { text-transform: capitalize; } .text-muted { color: #777; } .text-primary { color: #337ab7; } a.text-primary:hover { color: #286090; } .text-success { color: #3c763d; } a.text-success:hover { color: #2b542c; } .text-info { color: #31708f; } a.text-info:hover { color: #245269; } .text-warning { color: #8a6d3b; } a.text-warning:hover { color: #66512c; } .text-danger { color: #a94442; } a.text-danger:hover { color: #843534; } .bg-primary { color: #fff; background-color: #337ab7; } a.bg-primary:hover { background-color: #286090; } .bg-success { background-color: #dff0d8; } a.bg-success:hover { background-color: #c1e2b3; } .bg-info { background-color: #d9edf7; } a.bg-info:hover { background-color: #afd9ee; } .bg-warning { background-color: #fcf8e3; } a.bg-warning:hover { background-color: #f7ecb5; } .bg-danger { background-color: #f2dede; } a.bg-danger:hover { background-color: #e4b9b9; } .page-header { padding-bottom: 9px; margin: 40px 0 20px; border-bottom: 1px solid #eee; } ul, ol { margin-top: 0; margin-bottom: 10px; } ul ul, ol ul, ul ol, ol ol { margin-bottom: 0; } .list-unstyled { padding-left: 0; list-style: none; } .list-inline { padding-left: 0; margin-left: -5px; list-style: none; } .list-inline > li { display: inline-block; padding-right: 5px; padding-left: 5px; } dl { margin-top: 0; margin-bottom: 20px; } dt, dd { line-height: 1.42857143; } dt { font-weight: bold; } dd { margin-left: 0; } @media (min-width: 768px) { .dl-horizontal dt { float: left; width: 160px; overflow: hidden; clear: left; text-align: right; text-overflow: ellipsis; white-space: nowrap; } .dl-horizontal dd { margin-left: 180px; } } abbr[title], abbr[data-original-title] { cursor: help; border-bottom: 1px dotted #777; } .initialism { font-size: 90%; text-transform: uppercase; } blockquote { padding: 10px 20px; margin: 0 0 20px; font-size: 17.5px; border-left: 5px solid #eee; } blockquote p:last-child, blockquote ul:last-child, blockquote ol:last-child { margin-bottom: 0; } blockquote footer, blockquote small, blockquote .small { display: block; font-size: 80%; line-height: 1.42857143; color: #777; } blockquote footer:before, blockquote small:before, blockquote .small:before { content: '\2014 \00A0'; } .blockquote-reverse, blockquote.pull-right { padding-right: 15px; padding-left: 0; text-align: right; border-right: 5px solid #eee; border-left: 0; } .blockquote-reverse footer:before, blockquote.pull-right footer:before, .blockquote-reverse small:before, blockquote.pull-right small:before, .blockquote-reverse .small:before, blockquote.pull-right .small:before { content: ''; } .blockquote-reverse footer:after, blockquote.pull-right footer:after, .blockquote-reverse small:after, blockquote.pull-right small:after, .blockquote-reverse .small:after, blockquote.pull-right .small:after { content: '\00A0 \2014'; } address { margin-bottom: 20px; font-style: normal; line-height: 1.42857143; } code, kbd, pre, samp { font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; } kbd { padding: 2px 4px; font-size: 90%; color: #fff; background-color: #333; border-radius: 3px; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25); } kbd kbd { padding: 0; font-size: 100%; font-weight: bold; -webkit-box-shadow: none; box-shadow: none; } pre { display: block; padding: 9.5px; margin: 0 0 10px; font-size: 13px; line-height: 1.42857143; color: #333; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; } pre code { padding: 0; font-size: inherit; color: inherit; white-space: pre-wrap; background-color: transparent; border-radius: 0; } .pre-scrollable { max-height: 340px; overflow-y: scroll; } .container { padding-right: 15px; padding-left: 15px; margin-right: auto; margin-left: auto; } @media (min-width: 768px) { .container { width: 750px; } } @media (min-width: 992px) { .container { width: 970px; } } @media (min-width: 1200px) { .container { width: 1170px; } } .container-fluid { padding-right: 15px; padding-left: 15px; margin-right: auto; margin-left: auto; } .row { margin-right: -15px; margin-left: -15px; } .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { position: relative; min-height: 1px; padding-right: 15px; padding-left: 15px; } .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { float: left; } .col-xs-12 { width: 100%; } .col-xs-11 { width: 91.66666667%; } .col-xs-10 { width: 83.33333333%; } .col-xs-9 { width: 75%; } .col-xs-8 { width: 66.66666667%; } .col-xs-7 { width: 58.33333333%; } .col-xs-6 { width: 50%; } .col-xs-5 { width: 41.66666667%; } .col-xs-4 { width: 33.33333333%; } .col-xs-3 { width: 25%; } .col-xs-2 { width: 16.66666667%; } .col-xs-1 { width: 8.33333333%; } .col-xs-pull-12 { right: 100%; } .col-xs-pull-11 { right: 91.66666667%; } .col-xs-pull-10 { right: 83.33333333%; } .col-xs-pull-9 { right: 75%; } .col-xs-pull-8 { right: 66.66666667%; } .col-xs-pull-7 { right: 58.33333333%; } .col-xs-pull-6 { right: 50%; } .col-xs-pull-5 { right: 41.66666667%; } .col-xs-pull-4 { right: 33.33333333%; } .col-xs-pull-3 { right: 25%; } .col-xs-pull-2 { right: 16.66666667%; } .col-xs-pull-1 { right: 8.33333333%; } .col-xs-pull-0 { right: auto; } .col-xs-push-12 { left: 100%; } .col-xs-push-11 { left: 91.66666667%; } .col-xs-push-10 { left: 83.33333333%; } .col-xs-push-9 { left: 75%; } .col-xs-push-8 { left: 66.66666667%; } .col-xs-push-7 { left: 58.33333333%; } .col-xs-push-6 { left: 50%; } .col-xs-push-5 { left: 41.66666667%; } .col-xs-push-4 { left: 33.33333333%; } .col-xs-push-3 { left: 25%; } .col-xs-push-2 { left: 16.66666667%; } .col-xs-push-1 { left: 8.33333333%; } .col-xs-push-0 { left: auto; } .col-xs-offset-12 { margin-left: 100%; } .col-xs-offset-11 { margin-left: 91.66666667%; } .col-xs-offset-10 { margin-left: 83.33333333%; } .col-xs-offset-9 { margin-left: 75%; } .col-xs-offset-8 { margin-left: 66.66666667%; } .col-xs-offset-7 { margin-left: 58.33333333%; } .col-xs-offset-6 { margin-left: 50%; } .col-xs-offset-5 { margin-left: 41.66666667%; } .col-xs-offset-4 { margin-left: 33.33333333%; } .col-xs-offset-3 { margin-left: 25%; } .col-xs-offset-2 { margin-left: 16.66666667%; } .col-xs-offset-1 { margin-left: 8.33333333%; } .col-xs-offset-0 { margin-left: 0; } @media (min-width: 768px) { .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { float: left; } .col-sm-12 { width: 100%; } .col-sm-11 { width: 91.66666667%; } .col-sm-10 { width: 83.33333333%; } .col-sm-9 { width: 75%; } .col-sm-8 { width: 66.66666667%; } .col-sm-7 { width: 58.33333333%; } .col-sm-6 { width: 50%; } .col-sm-5 { width: 41.66666667%; } .col-sm-4 { width: 33.33333333%; } .col-sm-3 { width: 25%; } .col-sm-2 { width: 16.66666667%; } .col-sm-1 { width: 8.33333333%; } .col-sm-pull-12 { right: 100%; } .col-sm-pull-11 { right: 91.66666667%; } .col-sm-pull-10 { right: 83.33333333%; } .col-sm-pull-9 { right: 75%; } .col-sm-pull-8 { right: 66.66666667%; } .col-sm-pull-7 { right: 58.33333333%; } .col-sm-pull-6 { right: 50%; } .col-sm-pull-5 { right: 41.66666667%; } .col-sm-pull-4 { right: 33.33333333%; } .col-sm-pull-3 { right: 25%; } .col-sm-pull-2 { right: 16.66666667%; } .col-sm-pull-1 { right: 8.33333333%; } .col-sm-pull-0 { right: auto; } .col-sm-push-12 { left: 100%; } .col-sm-push-11 { left: 91.66666667%; } .col-sm-push-10 { left: 83.33333333%; } .col-sm-push-9 { left: 75%; } .col-sm-push-8 { left: 66.66666667%; } .col-sm-push-7 { left: 58.33333333%; } .col-sm-push-6 { left: 50%; } .col-sm-push-5 { left: 41.66666667%; } .col-sm-push-4 { left: 33.33333333%; } .col-sm-push-3 { left: 25%; } .col-sm-push-2 { left: 16.66666667%; } .col-sm-push-1 { left: 8.33333333%; } .col-sm-push-0 { left: auto; } .col-sm-offset-12 { margin-left: 100%; } .col-sm-offset-11 { margin-left: 91.66666667%; } .col-sm-offset-10 { margin-left: 83.33333333%; } .col-sm-offset-9 { margin-left: 75%; } .col-sm-offset-8 { margin-left: 66.66666667%; } .col-sm-offset-7 { margin-left: 58.33333333%; } .col-sm-offset-6 { margin-left: 50%; } .col-sm-offset-5 { margin-left: 41.66666667%; } .col-sm-offset-4 { margin-left: 33.33333333%; } .col-sm-offset-3 { margin-left: 25%; } .col-sm-offset-2 { margin-left: 16.66666667%; } .col-sm-offset-1 { margin-left: 8.33333333%; } .col-sm-offset-0 { margin-left: 0; } } @media (min-width: 992px) { .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { float: left; } .col-md-12 { width: 100%; } .col-md-11 { width: 91.66666667%; } .col-md-10 { width: 83.33333333%; } .col-md-9 { width: 75%; } .col-md-8 { width: 66.66666667%; } .col-md-7 { width: 58.33333333%; } .col-md-6 { width: 50%; } .col-md-5 { width: 41.66666667%; } .col-md-4 { width: 33.33333333%; } .col-md-3 { width: 25%; } .col-md-2 { width: 16.66666667%; } .col-md-1 { width: 8.33333333%; } .col-md-pull-12 { right: 100%; } .col-md-pull-11 { right: 91.66666667%; } .col-md-pull-10 { right: 83.33333333%; } .col-md-pull-9 { right: 75%; } .col-md-pull-8 { right: 66.66666667%; } .col-md-pull-7 { right: 58.33333333%; } .col-md-pull-6 { right: 50%; } .col-md-pull-5 { right: 41.66666667%; } .col-md-pull-4 { right: 33.33333333%; } .col-md-pull-3 { right: 25%; } .col-md-pull-2 { right: 16.66666667%; } .col-md-pull-1 { right: 8.33333333%; } .col-md-pull-0 { right: auto; } .col-md-push-12 { left: 100%; } .col-md-push-11 { left: 91.66666667%; } .col-md-push-10 { left: 83.33333333%; } .col-md-push-9 { left: 75%; } .col-md-push-8 { left: 66.66666667%; } .col-md-push-7 { left: 58.33333333%; } .col-md-push-6 { left: 50%; } .col-md-push-5 { left: 41.66666667%; } .col-md-push-4 { left: 33.33333333%; } .col-md-push-3 { left: 25%; } .col-md-push-2 { left: 16.66666667%; } .col-md-push-1 { left: 8.33333333%; } .col-md-push-0 { left: auto; } .col-md-offset-12 { margin-left: 100%; } .col-md-offset-11 { margin-left: 91.66666667%; } .col-md-offset-10 { margin-left: 83.33333333%; } .col-md-offset-9 { margin-left: 75%; } .col-md-offset-8 { margin-left: 66.66666667%; } .col-md-offset-7 { margin-left: 58.33333333%; } .col-md-offset-6 { margin-left: 50%; } .col-md-offset-5 { margin-left: 41.66666667%; } .col-md-offset-4 { margin-left: 33.33333333%; } .col-md-offset-3 { margin-left: 25%; } .col-md-offset-2 { margin-left: 16.66666667%; } .col-md-offset-1 { margin-left: 8.33333333%; } .col-md-offset-0 { margin-left: 0; } } @media (min-width: 1200px) { .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { float: left; } .col-lg-12 { width: 100%; } .col-lg-11 { width: 91.66666667%; } .col-lg-10 { width: 83.33333333%; } .col-lg-9 { width: 75%; } .col-lg-8 { width: 66.66666667%; } .col-lg-7 { width: 58.33333333%; } .col-lg-6 { width: 50%; } .col-lg-5 { width: 41.66666667%; } .col-lg-4 { width: 33.33333333%; } .col-lg-3 { width: 25%; } .col-lg-2 { width: 16.66666667%; } .col-lg-1 { width: 8.33333333%; } .col-lg-pull-12 { right: 100%; } .col-lg-pull-11 { right: 91.66666667%; } .col-lg-pull-10 { right: 83.33333333%; } .col-lg-pull-9 { right: 75%; } .col-lg-pull-8 { right: 66.66666667%; } .col-lg-pull-7 { right: 58.33333333%; } .col-lg-pull-6 { right: 50%; } .col-lg-pull-5 { right: 41.66666667%; } .col-lg-pull-4 { right: 33.33333333%; } .col-lg-pull-3 { right: 25%; } .col-lg-pull-2 { right: 16.66666667%; } .col-lg-pull-1 { right: 8.33333333%; } .col-lg-pull-0 { right: auto; } .col-lg-push-12 { left: 100%; } .col-lg-push-11 { left: 91.66666667%; } .col-lg-push-10 { left: 83.33333333%; } .col-lg-push-9 { left: 75%; } .col-lg-push-8 { left: 66.66666667%; } .col-lg-push-7 { left: 58.33333333%; } .col-lg-push-6 { left: 50%; } .col-lg-push-5 { left: 41.66666667%; } .col-lg-push-4 { left: 33.33333333%; } .col-lg-push-3 { left: 25%; } .col-lg-push-2 { left: 16.66666667%; } .col-lg-push-1 { left: 8.33333333%; } .col-lg-push-0 { left: auto; } .col-lg-offset-12 { margin-left: 100%; } .col-lg-offset-11 { margin-left: 91.66666667%; } .col-lg-offset-10 { margin-left: 83.33333333%; } .col-lg-offset-9 { margin-left: 75%; } .col-lg-offset-8 { margin-left: 66.66666667%; } .col-lg-offset-7 { margin-left: 58.33333333%; } .col-lg-offset-6 { margin-left: 50%; } .col-lg-offset-5 { margin-left: 41.66666667%; } .col-lg-offset-4 { margin-left: 33.33333333%; } .col-lg-offset-3 { margin-left: 25%; } .col-lg-offset-2 { margin-left: 16.66666667%; } .col-lg-offset-1 { margin-left: 8.33333333%; } .col-lg-offset-0 { margin-left: 0; } } table { background-color: transparent; } caption { padding-top: 8px; padding-bottom: 8px; color: #777; text-align: left; } th { text-align: left; } .table { width: 100%; max-width: 100%; margin-bottom: 20px; } .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td { padding: 8px; line-height: 1.42857143; vertical-align: top; border-top: 1px solid #ddd; } .table > thead > tr > th { vertical-align: bottom; border-bottom: 2px solid #ddd; } .table > caption + thead > tr:first-child > th, .table > colgroup + thead > tr:first-child > th, .table > thead:first-child > tr:first-child > th, .table > caption + thead > tr:first-child > td, .table > colgroup + thead > tr:first-child > td, .table > thead:first-child > tr:first-child > td { border-top: 0; } .table > tbody + tbody { border-top: 2px solid #ddd; } .table .table { background-color: #fff; } .table-condensed > thead > tr > th, .table-condensed > tbody > tr > th, .table-condensed > tfoot > tr > th, .table-condensed > thead > tr > td, .table-condensed > tbody > tr > td, .table-condensed > tfoot > tr > td { padding: 5px; } .table-bordered { border: 1px solid #ddd; } .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td { border: 1px solid #ddd; } .table-bordered > thead > tr > th, .table-bordered > thead > tr > td { border-bottom-width: 2px; } .table-striped > tbody > tr:nth-child(odd) { background-color: #f9f9f9; } .table-hover > tbody > tr:hover { background-color: #f5f5f5; } table col[class*="col-"] { position: static; display: table-column; float: none; } table td[class*="col-"], table th[class*="col-"] { position: static; display: table-cell; float: none; } .table > thead > tr > td.active, .table > tbody > tr > td.active, .table > tfoot > tr > td.active, .table > thead > tr > th.active, .table > tbody > tr > th.active, .table > tfoot > tr > th.active, .table > thead > tr.active > td, .table > tbody > tr.active > td, .table > tfoot > tr.active > td, .table > thead > tr.active > th, .table > tbody > tr.active > th, .table > tfoot > tr.active > th { background-color: #f5f5f5; } .table-hover > tbody > tr > td.active:hover, .table-hover > tbody > tr > th.active:hover, .table-hover > tbody > tr.active:hover > td, .table-hover > tbody > tr:hover > .active, .table-hover > tbody > tr.active:hover > th { background-color: #e8e8e8; } .table > thead > tr > td.success, .table > tbody > tr > td.success, .table > tfoot > tr > td.success, .table > thead > tr > th.success, .table > tbody > tr > th.success, .table > tfoot > tr > th.success, .table > thead > tr.success > td, .table > tbody > tr.success > td, .table > tfoot > tr.success > td, .table > thead > tr.success > th, .table > tbody > tr.success > th, .table > tfoot > tr.success > th { background-color: #dff0d8; } .table-hover > tbody > tr > td.success:hover, .table-hover > tbody > tr > th.success:hover, .table-hover > tbody > tr.success:hover > td, .table-hover > tbody > tr:hover > .success, .table-hover > tbody > tr.success:hover > th { background-color: #d0e9c6; } .table > thead > tr > td.info, .table > tbody > tr > td.info, .table > tfoot > tr > td.info, .table > thead > tr > th.info, .table > tbody > tr > th.info, .table > tfoot > tr > th.info, .table > thead > tr.info > td, .table > tbody > tr.info > td, .table > tfoot > tr.info > td, .table > thead > tr.info > th, .table > tbody > tr.info > th, .table > tfoot > tr.info > th { background-color: #d9edf7; } .table-hover > tbody > tr > td.info:hover, .table-hover > tbody > tr > th.info:hover, .table-hover > tbody > tr.info:hover > td, .table-hover > tbody > tr:hover > .info, .table-hover > tbody > tr.info:hover > th { background-color: #c4e3f3; } .table > thead > tr > td.warning, .table > tbody > tr > td.warning, .table > tfoot > tr > td.warning, .table > thead > tr > th.warning, .table > tbody > tr > th.warning, .table > tfoot > tr > th.warning, .table > thead > tr.warning > td, .table > tbody > tr.warning > td, .table > tfoot > tr.warning > td, .table > thead > tr.warning > th, .table > tbody > tr.warning > th, .table > tfoot > tr.warning > th { background-color: #fcf8e3; } .table-hover > tbody > tr > td.warning:hover, .table-hover > tbody > tr > th.warning:hover, .table-hover > tbody > tr.warning:hover > td, .table-hover > tbody > tr:hover > .warning, .table-hover > tbody > tr.warning:hover > th { background-color: #faf2cc; } .table > thead > tr > td.danger, .table > tbody > tr > td.danger, .table > tfoot > tr > td.danger, .table > thead > tr > th.danger, .table > tbody > tr > th.danger, .table > tfoot > tr > th.danger, .table > thead > tr.danger > td, .table > tbody > tr.danger > td, .table > tfoot > tr.danger > td, .table > thead > tr.danger > th, .table > tbody > tr.danger > th, .table > tfoot > tr.danger > th { background-color: #f2dede; } .table-hover > tbody > tr > td.danger:hover, .table-hover > tbody > tr > th.danger:hover, .table-hover > tbody > tr.danger:hover > td, .table-hover > tbody > tr:hover > .danger, .table-hover > tbody > tr.danger:hover > th { background-color: #ebcccc; } .table-responsive { min-height: .01%; overflow-x: auto; } @media screen and (max-width: 767px) { .table-responsive { width: 100%; margin-bottom: 15px; overflow-y: hidden; -ms-overflow-style: -ms-autohiding-scrollbar; border: 1px solid #ddd; } .table-responsive > .table { margin-bottom: 0; } .table-responsive > .table > thead > tr > th, .table-responsive > .table > tbody > tr > th, .table-responsive > .table > tfoot > tr > th, .table-responsive > .table > thead > tr > td, .table-responsive > .table > tbody > tr > td, .table-responsive > .table > tfoot > tr > td { white-space: nowrap; } .table-responsive > .table-bordered { border: 0; } .table-responsive > .table-bordered > thead > tr > th:first-child, .table-responsive > .table-bordered > tbody > tr > th:first-child, .table-responsive > .table-bordered > tfoot > tr > th:first-child, .table-responsive > .table-bordered > thead > tr > td:first-child, .table-responsive > .table-bordered > tbody > tr > td:first-child, .table-responsive > .table-bordered > tfoot > tr > td:first-child { border-left: 0; } .table-responsive > .table-bordered > thead > tr > th:last-child, .table-responsive > .table-bordered > tbody > tr > th:last-child, .table-responsive > .table-bordered > tfoot > tr > th:last-child, .table-responsive > .table-bordered > thead > tr > td:last-child, .table-responsive > .table-bordered > tbody > tr > td:last-child, .table-responsive > .table-bordered > tfoot > tr > td:last-child { border-right: 0; } .table-responsive > .table-bordered > tbody > tr:last-child > th, .table-responsive > .table-bordered > tfoot > tr:last-child > th, .table-responsive > .table-bordered > tbody > tr:last-child > td, .table-responsive > .table-bordered > tfoot > tr:last-child > td { border-bottom: 0; } } fieldset { min-width: 0; padding: 0; margin: 0; border: 0; } legend { display: block; width: 100%; padding: 0; margin-bottom: 20px; font-size: 21px; line-height: inherit; color: #333; border: 0; border-bottom: 1px solid #e5e5e5; } label { display: inline-block; max-width: 100%; margin-bottom: 5px; font-weight: bold; } input[type="search"] { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } input[type="radio"], input[type="checkbox"] { margin: 4px 0 0; margin-top: 1px \9; line-height: normal; } input[type="file"] { display: block; } input[type="range"] { display: block; width: 100%; } select[multiple], select[size] { height: auto; } input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } output { display: block; padding-top: 7px; font-size: 14px; line-height: 1.42857143; color: #555; } .form-control { display: block; width: 100%; height: 34px; padding: 6px 12px; font-size: 14px; line-height: 1.42857143; color: #555; background-color: #fff; background-image: none; border: 1px solid #ccc; border-radius: 4px; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; } .form-control:focus { border-color: #66afe9; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6); box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6); } .form-control::-moz-placeholder { color: #999; opacity: 1; } .form-control:-ms-input-placeholder { color: #999; } .form-control::-webkit-input-placeholder { color: #999; } .form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control { cursor: not-allowed; background-color: #eee; opacity: 1; } textarea.form-control { height: auto; } input[type="search"] { -webkit-appearance: none; } @media screen and (-webkit-min-device-pixel-ratio: 0) { input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { line-height: 34px; } input[type="date"].input-sm, input[type="time"].input-sm, input[type="datetime-local"].input-sm, input[type="month"].input-sm { line-height: 30px; } input[type="date"].input-lg, input[type="time"].input-lg, input[type="datetime-local"].input-lg, input[type="month"].input-lg { line-height: 46px; } } .form-group { margin-bottom: 15px; } .radio, .checkbox { position: relative; display: block; margin-top: 10px; margin-bottom: 10px; } .radio label, .checkbox label { min-height: 20px; padding-left: 20px; margin-bottom: 0; font-weight: normal; cursor: pointer; } .radio input[type="radio"], .radio-inline input[type="radio"], .checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"] { position: absolute; margin-top: 4px \9; margin-left: -20px; } .radio + .radio, .checkbox + .checkbox { margin-top: -5px; } .radio-inline, .checkbox-inline { display: inline-block; padding-left: 20px; margin-bottom: 0; font-weight: normal; vertical-align: middle; cursor: pointer; } .radio-inline + .radio-inline, .checkbox-inline + .checkbox-inline { margin-top: 0; margin-left: 10px; } input[type="radio"][disabled], input[type="checkbox"][disabled], input[type="radio"].disabled, input[type="checkbox"].disabled, fieldset[disabled] input[type="radio"], fieldset[disabled] input[type="checkbox"] { cursor: not-allowed; } .radio-inline.disabled, .checkbox-inline.disabled, fieldset[disabled] .radio-inline, fieldset[disabled] .checkbox-inline { cursor: not-allowed; } .radio.disabled label, .checkbox.disabled label, fieldset[disabled] .radio label, fieldset[disabled] .checkbox label { cursor: not-allowed; } .form-control-static { padding-top: 7px; padding-bottom: 7px; margin-bottom: 0; } .form-control-static.input-lg, .form-control-static.input-sm { padding-right: 0; padding-left: 0; } .input-sm, .form-group-sm .form-control { height: 30px; padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px; } select.input-sm, select.form-group-sm .form-control { height: 30px; line-height: 30px; } textarea.input-sm, textarea.form-group-sm .form-control, select[multiple].input-sm, select[multiple].form-group-sm .form-control { height: auto; } .input-lg, .form-group-lg .form-control { height: 46px; padding: 10px 16px; font-size: 18px; line-height: 1.33; border-radius: 6px; } select.input-lg, select.form-group-lg .form-control { height: 46px; line-height: 46px; } textarea.input-lg, textarea.form-group-lg .form-control, select[multiple].input-lg, select[multiple].form-group-lg .form-control { height: auto; } .has-feedback { position: relative; } .has-feedback .form-control { padding-right: 42.5px; } .form-control-feedback { position: absolute; top: 0; right: 0; z-index: 2; display: block; width: 34px; height: 34px; line-height: 34px; text-align: center; pointer-events: none; } .input-lg + .form-control-feedback { width: 46px; height: 46px; line-height: 46px; } .input-sm + .form-control-feedback { width: 30px; height: 30px; line-height: 30px; } .has-success .help-block, .has-success .control-label, .has-success .radio, .has-success .checkbox, .has-success .radio-inline, .has-success .checkbox-inline, .has-success.radio label, .has-success.checkbox label, .has-success.radio-inline label, .has-success.checkbox-inline label { color: #3c763d; } .has-success .form-control { border-color: #3c763d; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); } .has-success .form-control:focus { border-color: #2b542c; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168; } .has-success .input-group-addon { color: #3c763d; background-color: #dff0d8; border-color: #3c763d; } .has-success .form-control-feedback { color: #3c763d; } .has-warning .help-block, .has-warning .control-label, .has-warning .radio, .has-warning .checkbox, .has-warning .radio-inline, .has-warning .checkbox-inline, .has-warning.radio label, .has-warning.checkbox label, .has-warning.radio-inline label, .has-warning.checkbox-inline label { color: #8a6d3b; } .has-warning .form-control { border-color: #8a6d3b; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); } .has-warning .form-control:focus { border-color: #66512c; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b; } .has-warning .input-group-addon { color: #8a6d3b; background-color: #fcf8e3; border-color: #8a6d3b; } .has-warning .form-control-feedback { color: #8a6d3b; } .has-error .help-block, .has-error .control-label, .has-error .radio, .has-error .checkbox, .has-error .radio-inline, .has-error .checkbox-inline, .has-error.radio label, .has-error.checkbox label, .has-error.radio-inline label, .has-error.checkbox-inline label { color: #a94442; } .has-error .form-control { border-color: #a94442; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); } .has-error .form-control:focus { border-color: #843534; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483; } .has-error .input-group-addon { color: #a94442; background-color: #f2dede; border-color: #a94442; } .has-error .form-control-feedback { color: #a94442; } .has-feedback label ~ .form-control-feedback { top: 25px; } .has-feedback label.sr-only ~ .form-control-feedback { top: 0; } .help-block { display: block; margin-top: 5px; margin-bottom: 10px; color: #737373; } @media (min-width: 768px) { .form-inline .form-group { display: inline-block; margin-bottom: 0; vertical-align: middle; } .form-inline .form-control { display: inline-block; width: auto; vertical-align: middle; } .form-inline .form-control-static { display: inline-block; } .form-inline .input-group { display: inline-table; vertical-align: middle; } .form-inline .input-group .input-group-addon, .form-inline .input-group .input-group-btn, .form-inline .input-group .form-control { width: auto; } .form-inline .input-group > .form-control { width: 100%; } .form-inline .control-label { margin-bottom: 0; vertical-align: middle; } .form-inline .radio, .form-inline .checkbox { display: inline-block; margin-top: 0; margin-bottom: 0; vertical-align: middle; } .form-inline .radio label, .form-inline .checkbox label { padding-left: 0; } .form-inline .radio input[type="radio"], .form-inline .checkbox input[type="checkbox"] { position: relative; margin-left: 0; } .form-inline .has-feedback .form-control-feedback { top: 0; } } .form-horizontal .radio, .form-horizontal .checkbox, .form-horizontal .radio-inline, .form-horizontal .checkbox-inline { padding-top: 7px; margin-top: 0; margin-bottom: 0; } .form-horizontal .radio, .form-horizontal .checkbox { min-height: 27px; } .form-horizontal .form-group { margin-right: -15px; margin-left: -15px; } @media (min-width: 768px) { .form-horizontal .control-label { padding-top: 7px; margin-bottom: 0; text-align: right; } } .form-horizontal .has-feedback .form-control-feedback { right: 15px; } @media (min-width: 768px) { .form-horizontal .form-group-lg .control-label { padding-top: 14.3px; } } @media (min-width: 768px) { .form-horizontal .form-group-sm .control-label { padding-top: 6px; } } .btn { display: inline-block; padding: 6px 12px; margin-bottom: 0; font-size: 14px; font-weight: normal; line-height: 1.42857143; text-align: center; white-space: nowrap; vertical-align: middle; -ms-touch-action: manipulation; touch-action: manipulation; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-image: none; border: 1px solid transparent; border-radius: 4px; } .btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } .btn:hover, .btn:focus, .btn.focus { color: #333; text-decoration: none; } .btn:active, .btn.active { background-image: none; outline: 0; -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); } .btn.disabled, .btn[disabled], fieldset[disabled] .btn { pointer-events: none; cursor: not-allowed; filter: alpha(opacity=65); -webkit-box-shadow: none; box-shadow: none; opacity: .65; } .btn-default { color: #333; background-color: #fff; border-color: #ccc; } .btn-default:hover, .btn-default:focus, .btn-default.focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default { color: #333; background-color: #e6e6e6; border-color: #adadad; } .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default { background-image: none; } .btn-default.disabled, .btn-default[disabled], fieldset[disabled] .btn-default, .btn-default.disabled:hover, .btn-default[disabled]:hover, fieldset[disabled] .btn-default:hover, .btn-default.disabled:focus, .btn-default[disabled]:focus, fieldset[disabled] .btn-default:focus, .btn-default.disabled.focus, .btn-default[disabled].focus, fieldset[disabled] .btn-default.focus, .btn-default.disabled:active, .btn-default[disabled]:active, fieldset[disabled] .btn-default:active, .btn-default.disabled.active, .btn-default[disabled].active, fieldset[disabled] .btn-default.active { background-color: #fff; border-color: #ccc; } .btn-default .badge { color: #fff; background-color: #333; } .btn-primary { color: #fff; background-color: #337ab7; border-color: #2e6da4; } .btn-primary:hover, .btn-primary:focus, .btn-primary.focus, .btn-primary:active, .btn-primary.active, .open > .dropdown-toggle.btn-primary { color: #fff; background-color: #286090; border-color: #204d74; } .btn-primary:active, .btn-primary.active, .open > .dropdown-toggle.btn-primary { background-image: none; } .btn-primary.disabled, .btn-primary[disabled], fieldset[disabled] .btn-primary, .btn-primary.disabled:hover, .btn-primary[disabled]:hover, fieldset[disabled] .btn-primary:hover, .btn-primary.disabled:focus, .btn-primary[disabled]:focus, fieldset[disabled] .btn-primary:focus, .btn-primary.disabled.focus, .btn-primary[disabled].focus, fieldset[disabled] .btn-primary.focus, .btn-primary.disabled:active, .btn-primary[disabled]:active, fieldset[disabled] .btn-primary:active, .btn-primary.disabled.active, .btn-primary[disabled].active, fieldset[disabled] .btn-primary.active { background-color: #337ab7; border-color: #2e6da4; } .btn-primary .badge { color: #337ab7; background-color: #fff; } .btn-success { color: #fff; background-color: #5cb85c; border-color: #4cae4c; } .btn-success:hover, .btn-success:focus, .btn-success.focus, .btn-success:active, .btn-success.active, .open > .dropdown-toggle.btn-success { color: #fff; background-color: #449d44; border-color: #398439; } .btn-success:active, .btn-success.active, .open > .dropdown-toggle.btn-success { background-image: none; } .btn-success.disabled, .btn-success[disabled], fieldset[disabled] .btn-success, .btn-success.disabled:hover, .btn-success[disabled]:hover, fieldset[disabled] .btn-success:hover, .btn-success.disabled:focus, .btn-success[disabled]:focus, fieldset[disabled] .btn-success:focus, .btn-success.disabled.focus, .btn-success[disabled].focus, fieldset[disabled] .btn-success.focus, .btn-success.disabled:active, .btn-success[disabled]:active, fieldset[disabled] .btn-success:active, .btn-success.disabled.active, .btn-success[disabled].active, fieldset[disabled] .btn-success.active { background-color: #5cb85c; border-color: #4cae4c; } .btn-success .badge { color: #5cb85c; background-color: #fff; } .btn-info { color: #fff; background-color: #5bc0de; border-color: #46b8da; } .btn-info:hover, .btn-info:focus, .btn-info.focus, .btn-info:active, .btn-info.active, .open > .dropdown-toggle.btn-info { color: #fff; background-color: #31b0d5; border-color: #269abc; } .btn-info:active, .btn-info.active, .open > .dropdown-toggle.btn-info { background-image: none; } .btn-info.disabled, .btn-info[disabled], fieldset[disabled] .btn-info, .btn-info.disabled:hover, .btn-info[disabled]:hover, fieldset[disabled] .btn-info:hover, .btn-info.disabled:focus, .btn-info[disabled]:focus, fieldset[disabled] .btn-info:focus, .btn-info.disabled.focus, .btn-info[disabled].focus, fieldset[disabled] .btn-info.focus, .btn-info.disabled:active, .btn-info[disabled]:active, fieldset[disabled] .btn-info:active, .btn-info.disabled.active, .btn-info[disabled].active, fieldset[disabled] .btn-info.active { background-color: #5bc0de; border-color: #46b8da; } .btn-info .badge { color: #5bc0de; background-color: #fff; } .btn-warning { color: #fff; background-color: #f0ad4e; border-color: #eea236; } .btn-warning:hover, .btn-warning:focus, .btn-warning.focus, .btn-warning:active, .btn-warning.active, .open > .dropdown-toggle.btn-warning { color: #fff; background-color: #ec971f; border-color: #d58512; } .btn-warning:active, .btn-warning.active, .open > .dropdown-toggle.btn-warning { background-image: none; } .btn-warning.disabled, .btn-warning[disabled], fieldset[disabled] .btn-warning, .btn-warning.disabled:hover, .btn-warning[disabled]:hover, fieldset[disabled] .btn-warning:hover, .btn-warning.disabled:focus, .btn-warning[disabled]:focus, fieldset[disabled] .btn-warning:focus, .btn-warning.disabled.focus, .btn-warning[disabled].focus, fieldset[disabled] .btn-warning.focus, .btn-warning.disabled:active, .btn-warning[disabled]:active, fieldset[disabled] .btn-warning:active, .btn-warning.disabled.active, .btn-warning[disabled].active, fieldset[disabled] .btn-warning.active { background-color: #f0ad4e; border-color: #eea236; } .btn-warning .badge { color: #f0ad4e; background-color: #fff; } .btn-danger { color: #fff; background-color: #d9534f; border-color: #d43f3a; } .btn-danger:hover, .btn-danger:focus, .btn-danger.focus, .btn-danger:active, .btn-danger.active, .open > .dropdown-toggle.btn-danger { color: #fff; background-color: #c9302c; border-color: #ac2925; } .btn-danger:active, .btn-danger.active, .open > .dropdown-toggle.btn-danger { background-image: none; } .btn-danger.disabled, .btn-danger[disabled], fieldset[disabled] .btn-danger, .btn-danger.disabled:hover, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger:hover, .btn-danger.disabled:focus, .btn-danger[disabled]:focus, fieldset[disabled] .btn-danger:focus, .btn-danger.disabled.focus, .btn-danger[disabled].focus, fieldset[disabled] .btn-danger.focus, .btn-danger.disabled:active, .btn-danger[disabled]:active, fieldset[disabled] .btn-danger:active, .btn-danger.disabled.active, .btn-danger[disabled].active, fieldset[disabled] .btn-danger.active { background-color: #d9534f; border-color: #d43f3a; } .btn-danger .badge { color: #d9534f; background-color: #fff; } .btn-link { font-weight: normal; color: #337ab7; border-radius: 0; } .btn-link, .btn-link:active, .btn-link.active, .btn-link[disabled], fieldset[disabled] .btn-link { background-color: transparent; -webkit-box-shadow: none; box-shadow: none; } .btn-link, .btn-link:hover, .btn-link:focus, .btn-link:active { border-color: transparent; } .btn-link:hover, .btn-link:focus { color: #23527c; text-decoration: underline; background-color: transparent; } .btn-link[disabled]:hover, fieldset[disabled] .btn-link:hover, .btn-link[disabled]:focus, fieldset[disabled] .btn-link:focus { color: #777; text-decoration: none; } .btn-lg, .btn-group-lg > .btn { padding: 10px 16px; font-size: 18px; line-height: 1.33; border-radius: 6px; } .btn-sm, .btn-group-sm > .btn { padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px; } .btn-xs, .btn-group-xs > .btn { padding: 1px 5px; font-size: 12px; line-height: 1.5; border-radius: 3px; } .btn-block { display: block; width: 100%; } .btn-block + .btn-block { margin-top: 5px; } input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="button"].btn-block { width: 100%; } .fade { opacity: 0; -webkit-transition: opacity .15s linear; -o-transition: opacity .15s linear; transition: opacity .15s linear; } .fade.in { opacity: 1; } .collapse { display: none; visibility: hidden; } .collapse.in { display: block; visibility: visible; } tr.collapse.in { display: table-row; } tbody.collapse.in { display: table-row-group; } .collapsing { position: relative; height: 0; overflow: hidden; -webkit-transition-timing-function: ease; -o-transition-timing-function: ease; transition-timing-function: ease; -webkit-transition-duration: .35s; -o-transition-duration: .35s; transition-duration: .35s; -webkit-transition-property: height, visibility; -o-transition-property: height, visibility; transition-property: height, visibility; } .caret { display: inline-block; width: 0; height: 0; margin-left: 2px; vertical-align: middle; border-top: 4px solid; border-right: 4px solid transparent; border-left: 4px solid transparent; } .dropdown { position: relative; } .dropdown-toggle:focus { outline: 0; } .dropdown-menu { position: absolute; top: 100%; left: 0; z-index: 1000; display: none; float: left; min-width: 160px; padding: 5px 0; margin: 2px 0 0; font-size: 14px; text-align: left; list-style: none; background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, .15); border-radius: 4px; -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); box-shadow: 0 6px 12px rgba(0, 0, 0, .175); } .dropdown-menu.pull-right { right: 0; left: auto; } .dropdown-menu .divider { height: 1px; margin: 9px 0; overflow: hidden; background-color: #e5e5e5; } .dropdown-menu > li > a { display: block; padding: 3px 20px; clear: both; font-weight: normal; line-height: 1.42857143; color: #333; white-space: nowrap; } .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { color: #262626; text-decoration: none; background-color: #f5f5f5; } .dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus { color: #fff; text-decoration: none; background-color: #337ab7; outline: 0; } .dropdown-menu > .disabled > a, .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { color: #777; } .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { text-decoration: none; cursor: not-allowed; background-color: transparent; background-image: none; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .open > .dropdown-menu { display: block; } .open > a { outline: 0; } .dropdown-menu-right { right: 0; left: auto; } .dropdown-menu-left { right: auto; left: 0; } .dropdown-header { display: block; padding: 3px 20px; font-size: 12px; line-height: 1.42857143; color: #777; white-space: nowrap; } .dropdown-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 990; } .pull-right > .dropdown-menu { right: 0; left: auto; } .dropup .caret, .navbar-fixed-bottom .dropdown .caret { content: ""; border-top: 0; border-bottom: 4px solid; } .dropup .dropdown-menu, .navbar-fixed-bottom .dropdown .dropdown-menu { top: auto; bottom: 100%; margin-bottom: 1px; } @media (min-width: 768px) { .navbar-right .dropdown-menu { right: 0; left: auto; } .navbar-right .dropdown-menu-left { right: auto; left: 0; } } .btn-group, .btn-group-vertical { position: relative; display: inline-block; vertical-align: middle; } .btn-group > .btn, .btn-group-vertical > .btn { position: relative; float: left; } .btn-group > .btn:hover, .btn-group-vertical > .btn:hover, .btn-group > .btn:focus, .btn-group-vertical > .btn:focus, .btn-group > .btn:active, .btn-group-vertical > .btn:active, .btn-group > .btn.active, .btn-group-vertical > .btn.active { z-index: 2; } .btn-group .btn + .btn, .btn-group .btn + .btn-group, .btn-group .btn-group + .btn, .btn-group .btn-group + .btn-group { margin-left: -1px; } .btn-toolbar { margin-left: -5px; } .btn-toolbar .btn-group, .btn-toolbar .input-group { float: left; } .btn-toolbar > .btn, .btn-toolbar > .btn-group, .btn-toolbar > .input-group { margin-left: 5px; } .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { border-radius: 0; } .btn-group > .btn:first-child { margin-left: 0; } .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) { border-top-right-radius: 0; border-bottom-right-radius: 0; } .btn-group > .btn:last-child:not(:first-child), .btn-group > .dropdown-toggle:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; } .btn-group > .btn-group { float: left; } .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { border-radius: 0; } .btn-group > .btn-group:first-child > .btn:last-child, .btn-group > .btn-group:first-child > .dropdown-toggle { border-top-right-radius: 0; border-bottom-right-radius: 0; } .btn-group > .btn-group:last-child > .btn:first-child { border-top-left-radius: 0; border-bottom-left-radius: 0; } .btn-group .dropdown-toggle:active, .btn-group.open .dropdown-toggle { outline: 0; } .btn-group > .btn + .dropdown-toggle { padding-right: 8px; padding-left: 8px; } .btn-group > .btn-lg + .dropdown-toggle { padding-right: 12px; padding-left: 12px; } .btn-group.open .dropdown-toggle { -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); } .btn-group.open .dropdown-toggle.btn-link { -webkit-box-shadow: none; box-shadow: none; } .btn .caret { margin-left: 0; } .btn-lg .caret { border-width: 5px 5px 0; border-bottom-width: 0; } .dropup .btn-lg .caret { border-width: 0 5px 5px; } .btn-group-vertical > .btn, .btn-group-vertical > .btn-group, .btn-group-vertical > .btn-group > .btn { display: block; float: none; width: 100%; max-width: 100%; } .btn-group-vertical > .btn-group > .btn { float: none; } .btn-group-vertical > .btn + .btn, .btn-group-vertical > .btn + .btn-group, .btn-group-vertical > .btn-group + .btn, .btn-group-vertical > .btn-group + .btn-group { margin-top: -1px; margin-left: 0; } .btn-group-vertical > .btn:not(:first-child):not(:last-child) { border-radius: 0; } .btn-group-vertical > .btn:first-child:not(:last-child) { border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; } .btn-group-vertical > .btn:last-child:not(:first-child) { border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-left-radius: 4px; } .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { border-radius: 0; } .btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, .btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle { border-bottom-right-radius: 0; border-bottom-left-radius: 0; } .btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child { border-top-left-radius: 0; border-top-right-radius: 0; } .btn-group-justified { display: table; width: 100%; table-layout: fixed; border-collapse: separate; } .btn-group-justified > .btn, .btn-group-justified > .btn-group { display: table-cell; float: none; width: 1%; } .btn-group-justified > .btn-group .btn { width: 100%; } .btn-group-justified > .btn-group .dropdown-menu { left: auto; } [data-toggle="buttons"] > .btn input[type="radio"], [data-toggle="buttons"] > .btn-group > .btn input[type="radio"], [data-toggle="buttons"] > .btn input[type="checkbox"], [data-toggle="buttons"] > .btn-group > .btn input[type="checkbox"] { position: absolute; clip: rect(0, 0, 0, 0); pointer-events: none; } .input-group { position: relative; display: table; border-collapse: separate; } .input-group[class*="col-"] { float: none; padding-right: 0; padding-left: 0; } .input-group .form-control { position: relative; z-index: 2; float: left; width: 100%; margin-bottom: 0; } .input-group-lg > .form-control, .input-group-lg > .input-group-addon, .input-group-lg > .input-group-btn > .btn { height: 46px; padding: 10px 16px; font-size: 18px; line-height: 1.33; border-radius: 6px; } select.input-group-lg > .form-control, select.input-group-lg > .input-group-addon, select.input-group-lg > .input-group-btn > .btn { height: 46px; line-height: 46px; } textarea.input-group-lg > .form-control, textarea.input-group-lg > .input-group-addon, textarea.input-group-lg > .input-group-btn > .btn, select[multiple].input-group-lg > .form-control, select[multiple].input-group-lg > .input-group-addon, select[multiple].input-group-lg > .input-group-btn > .btn { height: auto; } .input-group-sm > .form-control, .input-group-sm > .input-group-addon, .input-group-sm > .input-group-btn > .btn { height: 30px; padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px; } select.input-group-sm > .form-control, select.input-group-sm > .input-group-addon, select.input-group-sm > .input-group-btn > .btn { height: 30px; line-height: 30px; } textarea.input-group-sm > .form-control, textarea.input-group-sm > .input-group-addon, textarea.input-group-sm > .input-group-btn > .btn, select[multiple].input-group-sm > .form-control, select[multiple].input-group-sm > .input-group-addon, select[multiple].input-group-sm > .input-group-btn > .btn { height: auto; } .input-group-addon, .input-group-btn, .input-group .form-control { display: table-cell; } .input-group-addon:not(:first-child):not(:last-child), .input-group-btn:not(:first-child):not(:last-child), .input-group .form-control:not(:first-child):not(:last-child) { border-radius: 0; } .input-group-addon, .input-group-btn { width: 1%; white-space: nowrap; vertical-align: middle; } .input-group-addon { padding: 6px 12px; font-size: 14px; font-weight: normal; line-height: 1; color: #555; text-align: center; background-color: #eee; border: 1px solid #ccc; border-radius: 4px; } .input-group-addon.input-sm { padding: 5px 10px; font-size: 12px; border-radius: 3px; } .input-group-addon.input-lg { padding: 10px 16px; font-size: 18px; border-radius: 6px; } .input-group-addon input[type="radio"], .input-group-addon input[type="checkbox"] { margin-top: 0; } .input-group .form-control:first-child, .input-group-addon:first-child, .input-group-btn:first-child > .btn, .input-group-btn:first-child > .btn-group > .btn, .input-group-btn:first-child > .dropdown-toggle, .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), .input-group-btn:last-child > .btn-group:not(:last-child) > .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; } .input-group-addon:first-child { border-right: 0; } .input-group .form-control:last-child, .input-group-addon:last-child, .input-group-btn:last-child > .btn, .input-group-btn:last-child > .btn-group > .btn, .input-group-btn:last-child > .dropdown-toggle, .input-group-btn:first-child > .btn:not(:first-child), .input-group-btn:first-child > .btn-group:not(:first-child) > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; } .input-group-addon:last-child { border-left: 0; } .input-group-btn { position: relative; font-size: 0; white-space: nowrap; } .input-group-btn > .btn { position: relative; } .input-group-btn > .btn + .btn { margin-left: -1px; } .input-group-btn > .btn:hover, .input-group-btn > .btn:focus, .input-group-btn > .btn:active { z-index: 2; } .input-group-btn:first-child > .btn, .input-group-btn:first-child > .btn-group { margin-right: -1px; } .input-group-btn:last-child > .btn, .input-group-btn:last-child > .btn-group { margin-left: -1px; } .nav { padding-left: 0; margin-bottom: 0; list-style: none; } .nav > li { position: relative; display: block; } .nav > li > a { position: relative; display: block; padding: 10px 15px; } .nav > li > a:hover, .nav > li > a:focus { text-decoration: none; background-color: #eee; } .nav > li.disabled > a { color: #777; } .nav > li.disabled > a:hover, .nav > li.disabled > a:focus { color: #777; text-decoration: none; cursor: not-allowed; background-color: transparent; } .nav .open > a, .nav .open > a:hover, .nav .open > a:focus { background-color: #eee; border-color: #337ab7; } .nav .nav-divider { height: 1px; margin: 9px 0; overflow: hidden; background-color: #e5e5e5; } .nav > li > a > img { max-width: none; } .nav-tabs { border-bottom: 1px solid #ddd; } .nav-tabs > li { float: left; margin-bottom: -1px; } .nav-tabs > li > a { margin-right: 2px; line-height: 1.42857143; border: 1px solid transparent; border-radius: 4px 4px 0 0; } .nav-tabs > li > a:hover { border-color: #eee #eee #ddd; } .nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus { color: #555; cursor: default; background-color: #fff; border: 1px solid #ddd; border-bottom-color: transparent; } .nav-tabs.nav-justified { width: 100%; border-bottom: 0; } .nav-tabs.nav-justified > li { float: none; } .nav-tabs.nav-justified > li > a { margin-bottom: 5px; text-align: center; } .nav-tabs.nav-justified > .dropdown .dropdown-menu { top: auto; left: auto; } @media (min-width: 768px) { .nav-tabs.nav-justified > li { display: table-cell; width: 1%; } .nav-tabs.nav-justified > li > a { margin-bottom: 0; } } .nav-tabs.nav-justified > li > a { margin-right: 0; border-radius: 4px; } .nav-tabs.nav-justified > .active > a, .nav-tabs.nav-justified > .active > a:hover, .nav-tabs.nav-justified > .active > a:focus { border: 1px solid #ddd; } @media (min-width: 768px) { .nav-tabs.nav-justified > li > a { border-bottom: 1px solid #ddd; border-radius: 4px 4px 0 0; } .nav-tabs.nav-justified > .active > a, .nav-tabs.nav-justified > .active > a:hover, .nav-tabs.nav-justified > .active > a:focus { border-bottom-color: #fff; } } .nav-pills > li { float: left; } .nav-pills > li > a { border-radius: 4px; } .nav-pills > li + li { margin-left: 2px; } .nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus { color: #fff; background-color: #337ab7; } .nav-stacked > li { float: none; } .nav-stacked > li + li { margin-top: 2px; margin-left: 0; } .nav-justified { width: 100%; } .nav-justified > li { float: none; } .nav-justified > li > a { margin-bottom: 5px; text-align: center; } .nav-justified > .dropdown .dropdown-menu { top: auto; left: auto; } @media (min-width: 768px) { .nav-justified > li { display: table-cell; width: 1%; } .nav-justified > li > a { margin-bottom: 0; } } .nav-tabs-justified { border-bottom: 0; } .nav-tabs-justified > li > a { margin-right: 0; border-radius: 4px; } .nav-tabs-justified > .active > a, .nav-tabs-justified > .active > a:hover, .nav-tabs-justified > .active > a:focus { border: 1px solid #ddd; } @media (min-width: 768px) { .nav-tabs-justified > li > a { border-bottom: 1px solid #ddd; border-radius: 4px 4px 0 0; } .nav-tabs-justified > .active > a, .nav-tabs-justified > .active > a:hover, .nav-tabs-justified > .active > a:focus { border-bottom-color: #fff; } } .tab-content > .tab-pane { display: none; visibility: hidden; } .tab-content > .active { display: block; visibility: visible; } .nav-tabs .dropdown-menu { margin-top: -1px; border-top-left-radius: 0; border-top-right-radius: 0; } .navbar { position: relative; min-height: 50px; margin-bottom: 20px; border: 1px solid transparent; } @media (min-width: 768px) { .navbar { border-radius: 4px; } } @media (min-width: 768px) { .navbar-header { float: left; } } .navbar-collapse { padding-right: 15px; padding-left: 15px; overflow-x: visible; -webkit-overflow-scrolling: touch; border-top: 1px solid transparent; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1); } .navbar-collapse.in { overflow-y: auto; } @media (min-width: 768px) { .navbar-collapse { width: auto; border-top: 0; -webkit-box-shadow: none; box-shadow: none; } .navbar-collapse.collapse { display: block !important; height: auto !important; padding-bottom: 0; overflow: visible !important; visibility: visible !important; } .navbar-collapse.in { overflow-y: visible; } .navbar-fixed-top .navbar-collapse, .navbar-static-top .navbar-collapse, .navbar-fixed-bottom .navbar-collapse { padding-right: 0; padding-left: 0; } } .navbar-fixed-top .navbar-collapse, .navbar-fixed-bottom .navbar-collapse { max-height: 340px; } @media (max-device-width: 480px) and (orientation: landscape) { .navbar-fixed-top .navbar-collapse, .navbar-fixed-bottom .navbar-collapse { max-height: 200px; } } .container > .navbar-header, .container-fluid > .navbar-header, .container > .navbar-collapse, .container-fluid > .navbar-collapse { margin-right: -15px; margin-left: -15px; } @media (min-width: 768px) { .container > .navbar-header, .container-fluid > .navbar-header, .container > .navbar-collapse, .container-fluid > .navbar-collapse { margin-right: 0; margin-left: 0; } } .navbar-static-top { z-index: 1000; border-width: 0 0 1px; } @media (min-width: 768px) { .navbar-static-top { border-radius: 0; } } .navbar-fixed-top, .navbar-fixed-bottom { position: fixed; right: 0; left: 0; z-index: 1030; } @media (min-width: 768px) { .navbar-fixed-top, .navbar-fixed-bottom { border-radius: 0; } } .navbar-fixed-top { top: 0; border-width: 0 0 1px; } .navbar-fixed-bottom { bottom: 0; margin-bottom: 0; border-width: 1px 0 0; } .navbar-brand { float: left; height: 50px; padding: 15px 15px; font-size: 18px; line-height: 20px; } .navbar-brand:hover, .navbar-brand:focus { text-decoration: none; } .navbar-brand > img { display: block; } @media (min-width: 768px) { .navbar > .container .navbar-brand, .navbar > .container-fluid .navbar-brand { margin-left: -15px; } } .navbar-toggle { position: relative; float: right; padding: 9px 10px; margin-top: 8px; margin-right: 15px; margin-bottom: 8px; background-color: transparent; background-image: none; border: 1px solid transparent; border-radius: 4px; } .navbar-toggle:focus { outline: 0; } .navbar-toggle .icon-bar { display: block; width: 22px; height: 2px; border-radius: 1px; } .navbar-toggle .icon-bar + .icon-bar { margin-top: 4px; } @media (min-width: 768px) { .navbar-toggle { display: none; } } .navbar-nav { margin: 7.5px -15px; } .navbar-nav > li > a { padding-top: 10px; padding-bottom: 10px; line-height: 20px; } @media (max-width: 767px) { .navbar-nav .open .dropdown-menu { position: static; float: none; width: auto; margin-top: 0; background-color: transparent; border: 0; -webkit-box-shadow: none; box-shadow: none; } .navbar-nav .open .dropdown-menu > li > a, .navbar-nav .open .dropdown-menu .dropdown-header { padding: 5px 15px 5px 25px; } .navbar-nav .open .dropdown-menu > li > a { line-height: 20px; } .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-nav .open .dropdown-menu > li > a:focus { background-image: none; } } @media (min-width: 768px) { .navbar-nav { float: left; margin: 0; } .navbar-nav > li { float: left; } .navbar-nav > li > a { padding-top: 15px; padding-bottom: 15px; } } .navbar-form { padding: 10px 15px; margin-top: 8px; margin-right: -15px; margin-bottom: 8px; margin-left: -15px; border-top: 1px solid transparent; border-bottom: 1px solid transparent; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1); } @media (min-width: 768px) { .navbar-form .form-group { display: inline-block; margin-bottom: 0; vertical-align: middle; } .navbar-form .form-control { display: inline-block; width: auto; vertical-align: middle; } .navbar-form .form-control-static { display: inline-block; } .navbar-form .input-group { display: inline-table; vertical-align: middle; } .navbar-form .input-group .input-group-addon, .navbar-form .input-group .input-group-btn, .navbar-form .input-group .form-control { width: auto; } .navbar-form .input-group > .form-control { width: 100%; } .navbar-form .control-label { margin-bottom: 0; vertical-align: middle; } .navbar-form .radio, .navbar-form .checkbox { display: inline-block; margin-top: 0; margin-bottom: 0; vertical-align: middle; } .navbar-form .radio label, .navbar-form .checkbox label { padding-left: 0; } .navbar-form .radio input[type="radio"], .navbar-form .checkbox input[type="checkbox"] { position: relative; margin-left: 0; } .navbar-form .has-feedback .form-control-feedback { top: 0; } } @media (max-width: 767px) { .navbar-form .form-group { margin-bottom: 5px; } .navbar-form .form-group:last-child { margin-bottom: 0; } } @media (min-width: 768px) { .navbar-form { width: auto; padding-top: 0; padding-bottom: 0; margin-right: 0; margin-left: 0; border: 0; -webkit-box-shadow: none; box-shadow: none; } } .navbar-nav > li > .dropdown-menu { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; } .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; } .navbar-btn { margin-top: 8px; margin-bottom: 8px; } .navbar-btn.btn-sm { margin-top: 10px; margin-bottom: 10px; } .navbar-btn.btn-xs { margin-top: 14px; margin-bottom: 14px; } .navbar-text { margin-top: 15px; margin-bottom: 15px; } @media (min-width: 768px) { .navbar-text { float: left; margin-right: 15px; margin-left: 15px; } } @media (min-width: 768px) { .navbar-left { float: left !important; } .navbar-right { float: right !important; margin-right: -15px; } .navbar-right ~ .navbar-right { margin-right: 0; } } .navbar-default { background-color: #f8f8f8; border-color: #e7e7e7; } .navbar-default .navbar-brand { color: #777; } .navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus { color: #5e5e5e; background-color: transparent; } .navbar-default .navbar-text { color: #777; } .navbar-default .navbar-nav > li > a { color: #777; } .navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus { color: #333; background-color: transparent; } .navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus { color: #555; background-color: #e7e7e7; } .navbar-default .navbar-nav > .disabled > a, .navbar-default .navbar-nav > .disabled > a:hover, .navbar-default .navbar-nav > .disabled > a:focus { color: #ccc; background-color: transparent; } .navbar-default .navbar-toggle { border-color: #ddd; } .navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus { background-color: #ddd; } .navbar-default .navbar-toggle .icon-bar { background-color: #888; } .navbar-default .navbar-collapse, .navbar-default .navbar-form { border-color: #e7e7e7; } .navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus { color: #555; background-color: #e7e7e7; } @media (max-width: 767px) { .navbar-default .navbar-nav .open .dropdown-menu > li > a { color: #777; } .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { color: #333; background-color: transparent; } .navbar-default .navbar-nav .open .dropdown-menu > .active > a, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { color: #555; background-color: #e7e7e7; } .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { color: #ccc; background-color: transparent; } } .navbar-default .navbar-link { color: #777; } .navbar-default .navbar-link:hover { color: #333; } .navbar-default .btn-link { color: #777; } .navbar-default .btn-link:hover, .navbar-default .btn-link:focus { color: #333; } .navbar-default .btn-link[disabled]:hover, fieldset[disabled] .navbar-default .btn-link:hover, .navbar-default .btn-link[disabled]:focus, fieldset[disabled] .navbar-default .btn-link:focus { color: #ccc; } .navbar-inverse { background-color: #222; border-color: #080808; } .navbar-inverse .navbar-brand { color: #9d9d9d; } .navbar-inverse .navbar-brand:hover, .navbar-inverse .navbar-brand:focus { color: #fff; background-color: transparent; } .navbar-inverse .navbar-text { color: #9d9d9d; } .navbar-inverse .navbar-nav > li > a { color: #9d9d9d; } .navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus { color: #fff; background-color: transparent; } .navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus { color: #fff; background-color: #080808; } .navbar-inverse .navbar-nav > .disabled > a, .navbar-inverse .navbar-nav > .disabled > a:hover, .navbar-inverse .navbar-nav > .disabled > a:focus { color: #444; background-color: transparent; } .navbar-inverse .navbar-toggle { border-color: #333; } .navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus { background-color: #333; } .navbar-inverse .navbar-toggle .icon-bar { background-color: #fff; } .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form { border-color: #101010; } .navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus { color: #fff; background-color: #080808; } @media (max-width: 767px) { .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header { border-color: #080808; } .navbar-inverse .navbar-nav .open .dropdown-menu .divider { background-color: #080808; } .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { color: #9d9d9d; } .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { color: #fff; background-color: transparent; } .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { color: #fff; background-color: #080808; } .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a, .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover, .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus { color: #444; background-color: transparent; } } .navbar-inverse .navbar-link { color: #9d9d9d; } .navbar-inverse .navbar-link:hover { color: #fff; } .navbar-inverse .btn-link { color: #9d9d9d; } .navbar-inverse .btn-link:hover, .navbar-inverse .btn-link:focus { color: #fff; } .navbar-inverse .btn-link[disabled]:hover, fieldset[disabled] .navbar-inverse .btn-link:hover, .navbar-inverse .btn-link[disabled]:focus, fieldset[disabled] .navbar-inverse .btn-link:focus { color: #444; } .breadcrumb { padding: 8px 15px; margin-bottom: 20px; list-style: none; background-color: #f5f5f5; border-radius: 4px; } .breadcrumb > li { display: inline-block; } .breadcrumb > li + li:before { padding: 0 5px; color: #ccc; content: "/\00a0"; } .breadcrumb > .active { color: #777; } .pagination { display: inline-block; padding-left: 0; margin: 20px 0; border-radius: 4px; } .pagination > li { display: inline; } .pagination > li > a, .pagination > li > span { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.42857143; color: #337ab7; text-decoration: none; background-color: #fff; border: 1px solid #ddd; } .pagination > li:first-child > a, .pagination > li:first-child > span { margin-left: 0; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .pagination > li:last-child > a, .pagination > li:last-child > span { border-top-right-radius: 4px; border-bottom-right-radius: 4px; } .pagination > li > a:hover, .pagination > li > span:hover, .pagination > li > a:focus, .pagination > li > span:focus { color: #23527c; background-color: #eee; border-color: #ddd; } .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus { z-index: 2; color: #fff; cursor: default; background-color: #337ab7; border-color: #337ab7; } .pagination > .disabled > span, .pagination > .disabled > span:hover, .pagination > .disabled > span:focus, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus { color: #777; cursor: not-allowed; background-color: #fff; border-color: #ddd; } .pagination-lg > li > a, .pagination-lg > li > span { padding: 10px 16px; font-size: 18px; } .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span { border-top-left-radius: 6px; border-bottom-left-radius: 6px; } .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span { border-top-right-radius: 6px; border-bottom-right-radius: 6px; } .pagination-sm > li > a, .pagination-sm > li > span { padding: 5px 10px; font-size: 12px; } .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } .pager { padding-left: 0; margin: 20px 0; text-align: center; list-style: none; } .pager li { display: inline; } .pager li > a, .pager li > span { display: inline-block; padding: 5px 14px; background-color: #fff; border: 1px solid #ddd; border-radius: 15px; } .pager li > a:hover, .pager li > a:focus { text-decoration: none; background-color: #eee; } .pager .next > a, .pager .next > span { float: right; } .pager .previous > a, .pager .previous > span { float: left; } .pager .disabled > a, .pager .disabled > a:hover, .pager .disabled > a:focus, .pager .disabled > span { color: #777; cursor: not-allowed; background-color: #fff; } .label { display: inline; padding: .2em .6em .3em; font-size: 75%; font-weight: bold; line-height: 1; color: #fff; text-align: center; white-space: nowrap; vertical-align: baseline; border-radius: .25em; } a.label:hover, a.label:focus { color: #fff; text-decoration: none; cursor: pointer; } .label:empty { display: none; } .btn .label { position: relative; top: -1px; } .label-default { background-color: #777; } .label-default[href]:hover, .label-default[href]:focus { background-color: #5e5e5e; } .label-primary { background-color: #337ab7; } .label-primary[href]:hover, .label-primary[href]:focus { background-color: #286090; } .label-success { background-color: #5cb85c; } .label-success[href]:hover, .label-success[href]:focus { background-color: #449d44; } .label-info { background-color: #5bc0de; } .label-info[href]:hover, .label-info[href]:focus { background-color: #31b0d5; } .label-warning { background-color: #f0ad4e; } .label-warning[href]:hover, .label-warning[href]:focus { background-color: #ec971f; } .label-danger { background-color: #d9534f; } .label-danger[href]:hover, .label-danger[href]:focus { background-color: #c9302c; } .badge { display: inline-block; min-width: 10px; padding: 3px 7px; font-size: 12px; font-weight: bold; line-height: 1; color: #fff; text-align: center; white-space: nowrap; vertical-align: baseline; background-color: #777; border-radius: 10px; } .badge:empty { display: none; } .btn .badge { position: relative; top: -1px; } .btn-xs .badge { top: 0; padding: 1px 5px; } a.badge:hover, a.badge:focus { color: #fff; text-decoration: none; cursor: pointer; } .list-group-item.active > .badge, .nav-pills > .active > a > .badge { color: #337ab7; background-color: #fff; } .list-group-item > .badge { float: right; } .list-group-item > .badge + .badge { margin-right: 5px; } .nav-pills > li > a > .badge { margin-left: 3px; } .jumbotron { padding: 30px 15px; background-size:cover; min-height:100%; min-height:100vh; align-items:center; background:transparent !important; display:flex; text-align:center; -moz-background-size:cover; } .jumbotron h1, .jumbotron .h1 { color: inherit; font-weight:bold; font-size:46px } .jumbotron p { margin-bottom: 15px; font-weight: 200; } .jumbotron > hr { border-top-color: #d5d5d5; } .container .jumbotron, .container-fluid .jumbotron { border-radius: 6px; } .jumbotron .container { max-width: 100%; } @media screen and (min-width: 768px) { .jumbotron { padding: 48px 0; } .container .jumbotron, .container-fluid .jumbotron { padding-right: 60px; padding-left: 60px; } .jumbotron h1, .jumbotron .h1 { font-size: 63px; } } .thumbnail { display: block; padding: 4px; margin-bottom: 20px; line-height: 1.42857143; background-color: #fff; border: 1px solid #ddd; border-radius: 4px; -webkit-transition: border .2s ease-in-out; -o-transition: border .2s ease-in-out; transition: border .2s ease-in-out; } .thumbnail > img, .thumbnail a > img { margin-right: auto; margin-left: auto; } a.thumbnail:hover, a.thumbnail:focus, a.thumbnail.active { border-color: #337ab7; } .thumbnail .caption { padding: 9px; color: #333; } .alert { padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px; } .alert h4 { margin-top: 0; color: inherit; } .alert .alert-link { font-weight: bold; } .alert > p, .alert > ul { margin-bottom: 0; } .alert > p + p { margin-top: 5px; } .alert-dismissable, .alert-dismissible { padding-right: 35px; } .alert-dismissable .close, .alert-dismissible .close { position: relative; top: -2px; right: -21px; color: inherit; } .alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; } .alert-success hr { border-top-color: #c9e2b3; } .alert-success .alert-link { color: #2b542c; } .alert-info { color: #31708f; background-color: #d9edf7; border-color: #bce8f1; } .alert-info hr { border-top-color: #a6e1ec; } .alert-info .alert-link { color: #245269; } .alert-warning { color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; } .alert-warning hr { border-top-color: #f7e1b5; } .alert-warning .alert-link { color: #66512c; } .alert-danger { color: #a94442; background-color: #f2dede; border-color: #ebccd1; } .alert-danger hr { border-top-color: #e4b9c0; } .alert-danger .alert-link { color: #843534; } @-webkit-keyframes progress-bar-stripes { from { background-position: 40px 0; } to { background-position: 0 0; } } @-o-keyframes progress-bar-stripes { from { background-position: 40px 0; } to { background-position: 0 0; } } @keyframes progress-bar-stripes { from { background-position: 40px 0; } to { background-position: 0 0; } } .progress { height: 20px; margin-bottom: 20px; overflow: hidden; background-color: #f5f5f5; border-radius: 4px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); } .progress-bar { float: left; width: 0; height: 100%; font-size: 12px; line-height: 20px; color: #fff; text-align: center; background-color: #337ab7; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); -webkit-transition: width .6s ease; -o-transition: width .6s ease; transition: width .6s ease; } .progress-striped .progress-bar, .progress-bar-striped { background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); -webkit-background-size: 40px 40px; background-size: 40px 40px; } .progress.active .progress-bar, .progress-bar.active { -webkit-animation: progress-bar-stripes 2s linear infinite; -o-animation: progress-bar-stripes 2s linear infinite; animation: progress-bar-stripes 2s linear infinite; } .progress-bar-success { background-color: #5cb85c; } .progress-striped .progress-bar-success { background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-bar-info { background-color: #5bc0de; } .progress-striped .progress-bar-info { background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-bar-warning { background-color: #f0ad4e; } .progress-striped .progress-bar-warning { background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-bar-danger { background-color: #d9534f; } .progress-striped .progress-bar-danger { background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .media { margin-top: 15px; } .media:first-child { margin-top: 0; } .media-right, .media > .pull-right { padding-left: 10px; } .media-left, .media > .pull-left { padding-right: 10px; } .media-left, .media-right, .media-body { display: table-cell; vertical-align: top; } .media-middle { vertical-align: middle; } .media-bottom { vertical-align: bottom; } .media-heading { margin-top: 0; margin-bottom: 5px; } .media-list { padding-left: 0; list-style: none; } .list-group { padding-left: 0; margin-bottom: 20px; } .list-group-item { position: relative; display: block; padding: 10px 15px; margin-bottom: -1px; background-color: #fff; border: 1px solid #ddd; } .list-group-item:first-child { border-top-left-radius: 4px; border-top-right-radius: 4px; } .list-group-item:last-child { margin-bottom: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; } a.list-group-item { color: #555; } a.list-group-item .list-group-item-heading { color: #333; } a.list-group-item:hover, a.list-group-item:focus { color: #555; text-decoration: none; background-color: #f5f5f5; } .list-group-item.disabled, .list-group-item.disabled:hover, .list-group-item.disabled:focus { color: #777; cursor: not-allowed; background-color: #eee; } .list-group-item.disabled .list-group-item-heading, .list-group-item.disabled:hover .list-group-item-heading, .list-group-item.disabled:focus .list-group-item-heading { color: inherit; } .list-group-item.disabled .list-group-item-text, .list-group-item.disabled:hover .list-group-item-text, .list-group-item.disabled:focus .list-group-item-text { color: #777; } .list-group-item.active, .list-group-item.active:hover, .list-group-item.active:focus { z-index: 2; color: #fff; background-color: #337ab7; border-color: #337ab7; } .list-group-item.active .list-group-item-heading, .list-group-item.active:hover .list-group-item-heading, .list-group-item.active:focus .list-group-item-heading, .list-group-item.active .list-group-item-heading > small, .list-group-item.active:hover .list-group-item-heading > small, .list-group-item.active:focus .list-group-item-heading > small, .list-group-item.active .list-group-item-heading > .small, .list-group-item.active:hover .list-group-item-heading > .small, .list-group-item.active:focus .list-group-item-heading > .small { color: inherit; } .list-group-item.active .list-group-item-text, .list-group-item.active:hover .list-group-item-text, .list-group-item.active:focus .list-group-item-text { color: #c7ddef; } .list-group-item-success { color: #3c763d; background-color: #dff0d8; } a.list-group-item-success { color: #3c763d; } a.list-group-item-success .list-group-item-heading { color: inherit; } a.list-group-item-success:hover, a.list-group-item-success:focus { color: #3c763d; background-color: #d0e9c6; } a.list-group-item-success.active, a.list-group-item-success.active:hover, a.list-group-item-success.active:focus { color: #fff; background-color: #3c763d; border-color: #3c763d; } .list-group-item-info { color: #31708f; background-color: #d9edf7; } a.list-group-item-info { color: #31708f; } a.list-group-item-info .list-group-item-heading { color: inherit; } a.list-group-item-info:hover, a.list-group-item-info:focus { color: #31708f; background-color: #c4e3f3; } a.list-group-item-info.active, a.list-group-item-info.active:hover, a.list-group-item-info.active:focus { color: #fff; background-color: #31708f; border-color: #31708f; } .list-group-item-warning { color: #8a6d3b; background-color: #fcf8e3; } a.list-group-item-warning { color: #8a6d3b; } a.list-group-item-warning .list-group-item-heading { color: inherit; } a.list-group-item-warning:hover, a.list-group-item-warning:focus { color: #8a6d3b; background-color: #faf2cc; } a.list-group-item-warning.active, a.list-group-item-warning.active:hover, a.list-group-item-warning.active:focus { color: #fff; background-color: #8a6d3b; border-color: #8a6d3b; } .list-group-item-danger { color: #a94442; background-color: #f2dede; } a.list-group-item-danger { color: #a94442; } a.list-group-item-danger .list-group-item-heading { color: inherit; } a.list-group-item-danger:hover, a.list-group-item-danger:focus { color: #a94442; background-color: #ebcccc; } a.list-group-item-danger.active, a.list-group-item-danger.active:hover, a.list-group-item-danger.active:focus { color: #fff; background-color: #a94442; border-color: #a94442; } .list-group-item-heading { margin-top: 0; margin-bottom: 5px; } .list-group-item-text { margin-bottom: 0; line-height: 1.3; } .panel { margin-bottom: 20px; background-color: #fff; border: 1px solid transparent; border-radius: 4px; -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05); box-shadow: 0 1px 1px rgba(0, 0, 0, .05); } .panel-body { padding: 15px; } .panel-heading { padding: 10px 15px; border-bottom: 1px solid transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; } .panel-heading > .dropdown .dropdown-toggle { color: inherit; } .panel-title { margin-top: 0; margin-bottom: 0; font-size: 16px; color: inherit; } .panel-title > a { color: inherit; } .panel-footer { padding: 10px 15px; background-color: #f5f5f5; border-top: 1px solid #ddd; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; } .panel > .list-group, .panel > .panel-collapse > .list-group { margin-bottom: 0; } .panel > .list-group .list-group-item, .panel > .panel-collapse > .list-group .list-group-item { border-width: 1px 0; border-radius: 0; } .panel > .list-group:first-child .list-group-item:first-child, .panel > .panel-collapse > .list-group:first-child .list-group-item:first-child { border-top: 0; border-top-left-radius: 3px; border-top-right-radius: 3px; } .panel > .list-group:last-child .list-group-item:last-child, .panel > .panel-collapse > .list-group:last-child .list-group-item:last-child { border-bottom: 0; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; } .panel-heading + .list-group .list-group-item:first-child { border-top-width: 0; } .list-group + .panel-footer { border-top-width: 0; } .panel > .table, .panel > .table-responsive > .table, .panel > .panel-collapse > .table { margin-bottom: 0; } .panel > .table caption, .panel > .table-responsive > .table caption, .panel > .panel-collapse > .table caption { padding-right: 15px; padding-left: 15px; } .panel > .table:first-child, .panel > .table-responsive:first-child > .table:first-child { border-top-left-radius: 3px; border-top-right-radius: 3px; } .panel > .table:first-child > thead:first-child > tr:first-child, .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child, .panel > .table:first-child > tbody:first-child > tr:first-child, .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child { border-top-left-radius: 3px; border-top-right-radius: 3px; } .panel > .table:first-child > thead:first-child > tr:first-child td:first-child, .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child, .panel > .table:first-child > tbody:first-child > tr:first-child td:first-child, .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child, .panel > .table:first-child > thead:first-child > tr:first-child th:first-child, .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child, .panel > .table:first-child > tbody:first-child > tr:first-child th:first-child, .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child { border-top-left-radius: 3px; } .panel > .table:first-child > thead:first-child > tr:first-child td:last-child, .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child, .panel > .table:first-child > tbody:first-child > tr:first-child td:last-child, .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child, .panel > .table:first-child > thead:first-child > tr:first-child th:last-child, .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child, .panel > .table:first-child > tbody:first-child > tr:first-child th:last-child, .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child { border-top-right-radius: 3px; } .panel > .table:last-child, .panel > .table-responsive:last-child > .table:last-child { border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; } .panel > .table:last-child > tbody:last-child > tr:last-child, .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child, .panel > .table:last-child > tfoot:last-child > tr:last-child, .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child { border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; } .panel > .table:last-child > tbody:last-child > tr:last-child td:first-child, .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child, .panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child, .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child, .panel > .table:last-child > tbody:last-child > tr:last-child th:first-child, .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child, .panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child, .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child { border-bottom-left-radius: 3px; } .panel > .table:last-child > tbody:last-child > tr:last-child td:last-child, .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child, .panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child, .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child, .panel > .table:last-child > tbody:last-child > tr:last-child th:last-child, .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child, .panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child, .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child { border-bottom-right-radius: 3px; } .panel > .panel-body + .table, .panel > .panel-body + .table-responsive, .panel > .table + .panel-body, .panel > .table-responsive + .panel-body { border-top: 1px solid #ddd; } .panel > .table > tbody:first-child > tr:first-child th, .panel > .table > tbody:first-child > tr:first-child td { border-top: 0; } .panel > .table-bordered, .panel > .table-responsive > .table-bordered { border: 0; } .panel > .table-bordered > thead > tr > th:first-child, .panel > .table-responsive > .table-bordered > thead > tr > th:first-child, .panel > .table-bordered > tbody > tr > th:first-child, .panel > .table-responsive > .table-bordered > tbody > tr > th:first-child, .panel > .table-bordered > tfoot > tr > th:first-child, .panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child, .panel > .table-bordered > thead > tr > td:first-child, .panel > .table-responsive > .table-bordered > thead > tr > td:first-child, .panel > .table-bordered > tbody > tr > td:first-child, .panel > .table-responsive > .table-bordered > tbody > tr > td:first-child, .panel > .table-bordered > tfoot > tr > td:first-child, .panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child { border-left: 0; } .panel > .table-bordered > thead > tr > th:last-child, .panel > .table-responsive > .table-bordered > thead > tr > th:last-child, .panel > .table-bordered > tbody > tr > th:last-child, .panel > .table-responsive > .table-bordered > tbody > tr > th:last-child, .panel > .table-bordered > tfoot > tr > th:last-child, .panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child, .panel > .table-bordered > thead > tr > td:last-child, .panel > .table-responsive > .table-bordered > thead > tr > td:last-child, .panel > .table-bordered > tbody > tr > td:last-child, .panel > .table-responsive > .table-bordered > tbody > tr > td:last-child, .panel > .table-bordered > tfoot > tr > td:last-child, .panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child { border-right: 0; } .panel > .table-bordered > thead > tr:first-child > td, .panel > .table-responsive > .table-bordered > thead > tr:first-child > td, .panel > .table-bordered > tbody > tr:first-child > td, .panel > .table-responsive > .table-bordered > tbody > tr:first-child > td, .panel > .table-bordered > thead > tr:first-child > th, .panel > .table-responsive > .table-bordered > thead > tr:first-child > th, .panel > .table-bordered > tbody > tr:first-child > th, .panel > .table-responsive > .table-bordered > tbody > tr:first-child > th { border-bottom: 0; } .panel > .table-bordered > tbody > tr:last-child > td, .panel > .table-responsive > .table-bordered > tbody > tr:last-child > td, .panel > .table-bordered > tfoot > tr:last-child > td, .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td, .panel > .table-bordered > tbody > tr:last-child > th, .panel > .table-responsive > .table-bordered > tbody > tr:last-child > th, .panel > .table-bordered > tfoot > tr:last-child > th, .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th { border-bottom: 0; } .panel > .table-responsive { margin-bottom: 0; border: 0; } .panel-group { margin-bottom: 20px; } .panel-group .panel { margin-bottom: 0; border-radius: 4px; } .panel-group .panel + .panel { margin-top: 5px; } .panel-group .panel-heading { border-bottom: 0; } .panel-group .panel-heading + .panel-collapse > .panel-body, .panel-group .panel-heading + .panel-collapse > .list-group { border-top: 1px solid #ddd; } .panel-group .panel-footer { border-top: 0; } .panel-group .panel-footer + .panel-collapse .panel-body { border-bottom: 1px solid #ddd; } .panel-default { border-color: #ddd; } .panel-default > .panel-heading { color: #333; background-color: #f5f5f5; border-color: #ddd; } .panel-default > .panel-heading + .panel-collapse > .panel-body { border-top-color: #ddd; } .panel-default > .panel-heading .badge { color: #f5f5f5; background-color: #333; } .panel-default > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #ddd; } .panel-primary { border-color: #337ab7; } .panel-primary > .panel-heading { color: #fff; background-color: #337ab7; border-color: #337ab7; } .panel-primary > .panel-heading + .panel-collapse > .panel-body { border-top-color: #337ab7; } .panel-primary > .panel-heading .badge { color: #337ab7; background-color: #fff; } .panel-primary > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #337ab7; } .panel-success { border-color: #d6e9c6; } .panel-success > .panel-heading { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; } .panel-success > .panel-heading + .panel-collapse > .panel-body { border-top-color: #d6e9c6; } .panel-success > .panel-heading .badge { color: #dff0d8; background-color: #3c763d; } .panel-success > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #d6e9c6; } .panel-info { border-color: #bce8f1; } .panel-info > .panel-heading { color: #31708f; background-color: #d9edf7; border-color: #bce8f1; } .panel-info > .panel-heading + .panel-collapse > .panel-body { border-top-color: #bce8f1; } .panel-info > .panel-heading .badge { color: #d9edf7; background-color: #31708f; } .panel-info > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #bce8f1; } .panel-warning { border-color: #faebcc; } .panel-warning > .panel-heading { color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; } .panel-warning > .panel-heading + .panel-collapse > .panel-body { border-top-color: #faebcc; } .panel-warning > .panel-heading .badge { color: #fcf8e3; background-color: #8a6d3b; } .panel-warning > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #faebcc; } .panel-danger { border-color: #ebccd1; } .panel-danger > .panel-heading { color: #a94442; background-color: #f2dede; border-color: #ebccd1; } .panel-danger > .panel-heading + .panel-collapse > .panel-body { border-top-color: #ebccd1; } .panel-danger > .panel-heading .badge { color: #f2dede; background-color: #a94442; } .panel-danger > .panel-footer + .panel-collapse > .panel-body { border-bottom-color: #ebccd1; } .embed-responsive { position: relative; display: block; height: 0; padding: 0; overflow: hidden; } .embed-responsive .embed-responsive-item, .embed-responsive iframe, .embed-responsive embed, .embed-responsive object, .embed-responsive video { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; height: 100%; border: 0; } .embed-responsive.embed-responsive-16by9 { padding-bottom: 56.25%; } .embed-responsive.embed-responsive-4by3 { padding-bottom: 75%; } .well { min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: #f5f5f5; border: 1px solid #e3e3e3; border-radius: 4px; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05); } .well blockquote { border-color: #ddd; border-color: rgba(0, 0, 0, .15); } .well-lg { padding: 24px; border-radius: 6px; } .well-sm { padding: 9px; border-radius: 3px; } .close { float: right; font-size: 21px; font-weight: bold; line-height: 1; color: #000; text-shadow: 0 1px 0 #fff; filter: alpha(opacity=20); opacity: .2; } .close:hover, .close:focus { color: #000; text-decoration: none; cursor: pointer; filter: alpha(opacity=50); opacity: .5; } button.close { -webkit-appearance: none; padding: 0; cursor: pointer; background: transparent; border: 0; } .modal-open { overflow: hidden; } .modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1040; display: none; overflow: hidden; -webkit-overflow-scrolling: touch; outline: 0; } .modal.fade .modal-dialog { -webkit-transition: -webkit-transform .3s ease-out; -o-transition: -o-transform .3s ease-out; transition: transform .3s ease-out; -webkit-transform: translate(0, -25%); -ms-transform: translate(0, -25%); -o-transform: translate(0, -25%); transform: translate(0, -25%); } .modal.in .modal-dialog { -webkit-transform: translate(0, 0); -ms-transform: translate(0, 0); -o-transform: translate(0, 0); transform: translate(0, 0); } .modal-open .modal { overflow-x: hidden; overflow-y: auto; } .modal-dialog { position: relative; width: auto; margin: 10px; } .modal-content { position: relative; background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; border: 1px solid #999; border: 1px solid rgba(0, 0, 0, .2); border-radius: 6px; outline: 0; -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5); box-shadow: 0 3px 9px rgba(0, 0, 0, .5); } .modal-backdrop { position: absolute; top: 0; right: 0; left: 0; background-color: #000; } .modal-backdrop.fade { filter: alpha(opacity=0); opacity: 0; } .modal-backdrop.in { filter: alpha(opacity=50); opacity: .5; } .modal-header { min-height: 16.42857143px; padding: 15px; border-bottom: 1px solid #e5e5e5; } .modal-header .close { margin-top: -2px; } .modal-title { margin: 0; line-height: 1.42857143; } .modal-body { position: relative; padding: 15px; } .modal-footer { padding: 15px; text-align: right; border-top: 1px solid #e5e5e5; } .modal-footer .btn + .btn { margin-bottom: 0; margin-left: 5px; } .modal-footer .btn-group .btn + .btn { margin-left: -1px; } .modal-footer .btn-block + .btn-block { margin-left: 0; } .modal-scrollbar-measure { position: absolute; top: -9999px; width: 50px; height: 50px; overflow: scroll; } @media (min-width: 768px) { .modal-dialog { width: 600px; margin: 30px auto; } .modal-content { -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5); box-shadow: 0 5px 15px rgba(0, 0, 0, .5); } .modal-sm { width: 300px; } } @media (min-width: 992px) { .modal-lg { width: 900px; } } .tooltip { position: absolute; z-index: 1070; display: block; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; font-weight: normal; line-height: 1.4; visibility: visible; filter: alpha(opacity=0); opacity: 0; } .tooltip.in { filter: alpha(opacity=90); opacity: .9; } .tooltip.top { padding: 5px 0; margin-top: -3px; } .tooltip.right { padding: 0 5px; margin-left: 3px; } .tooltip.bottom { padding: 5px 0; margin-top: 3px; } .tooltip.left { padding: 0 5px; margin-left: -3px; } .tooltip-inner { max-width: 200px; padding: 3px 8px; color: #fff; text-align: center; text-decoration: none; background-color: #000; border-radius: 4px; } .tooltip-arrow { position: absolute; width: 0; height: 0; border-color: transparent; border-style: solid; } .tooltip.top .tooltip-arrow { bottom: 0; left: 50%; margin-left: -5px; border-width: 5px 5px 0; border-top-color: #000; } .tooltip.top-left .tooltip-arrow { right: 5px; bottom: 0; margin-bottom: -5px; border-width: 5px 5px 0; border-top-color: #000; } .tooltip.top-right .tooltip-arrow { bottom: 0; left: 5px; margin-bottom: -5px; border-width: 5px 5px 0; border-top-color: #000; } .tooltip.right .tooltip-arrow { top: 50%; left: 0; margin-top: -5px; border-width: 5px 5px 5px 0; border-right-color: #000; } .tooltip.left .tooltip-arrow { top: 50%; right: 0; margin-top: -5px; border-width: 5px 0 5px 5px; border-left-color: #000; } .tooltip.bottom .tooltip-arrow { top: 0; left: 50%; margin-left: -5px; border-width: 0 5px 5px; border-bottom-color: #000; } .tooltip.bottom-left .tooltip-arrow { top: 0; right: 5px; margin-top: -5px; border-width: 0 5px 5px; border-bottom-color: #000; } .tooltip.bottom-right .tooltip-arrow { top: 0; left: 5px; margin-top: -5px; border-width: 0 5px 5px; border-bottom-color: #000; } .popover { position: absolute; top: 0; left: 0; z-index: 1060; display: none; max-width: 276px; padding: 1px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 1.42857143; text-align: left; white-space: normal; background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, .2); border-radius: 6px; -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2); box-shadow: 0 5px 10px rgba(0, 0, 0, .2); } .popover.top { margin-top: -10px; } .popover.right { margin-left: 10px; } .popover.bottom { margin-top: 10px; } .popover.left { margin-left: -10px; } .popover-title { padding: 8px 14px; margin: 0; font-size: 14px; background-color: #f7f7f7; border-bottom: 1px solid #ebebeb; border-radius: 5px 5px 0 0; } .popover-content { padding: 9px 14px; } .popover > .arrow, .popover > .arrow:after { position: absolute; display: block; width: 0; height: 0; border-color: transparent; border-style: solid; } .popover > .arrow { border-width: 11px; } .popover > .arrow:after { content: ""; border-width: 10px; } .popover.top > .arrow { bottom: -11px; left: 50%; margin-left: -11px; border-top-color: #999; border-top-color: rgba(0, 0, 0, .25); border-bottom-width: 0; } .popover.top > .arrow:after { bottom: 1px; margin-left: -10px; content: " "; border-top-color: #fff; border-bottom-width: 0; } .popover.right > .arrow { top: 50%; left: -11px; margin-top: -11px; border-right-color: #999; border-right-color: rgba(0, 0, 0, .25); border-left-width: 0; } .popover.right > .arrow:after { bottom: -10px; left: 1px; content: " "; border-right-color: #fff; border-left-width: 0; } .popover.bottom > .arrow { top: -11px; left: 50%; margin-left: -11px; border-top-width: 0; border-bottom-color: #999; border-bottom-color: rgba(0, 0, 0, .25); } .popover.bottom > .arrow:after { top: 1px; margin-left: -10px; content: " "; border-top-width: 0; border-bottom-color: #fff; } .popover.left > .arrow { top: 50%; right: -11px; margin-top: -11px; border-right-width: 0; border-left-color: #999; border-left-color: rgba(0, 0, 0, .25); } .popover.left > .arrow:after { right: 1px; bottom: -10px; content: " "; border-right-width: 0; border-left-color: #fff; } .carousel { position: relative; } .carousel-inner { position: relative; width: 100%; overflow: hidden; } .carousel-inner > .item { position: relative; display: none; -webkit-transition: .6s ease-in-out left; -o-transition: .6s ease-in-out left; transition: .6s ease-in-out left; } .carousel-inner > .item > img, .carousel-inner > .item > a > img { line-height: 1; } @media all and (transform-3d), (-webkit-transform-3d) { .carousel-inner > .item { -webkit-transition: -webkit-transform .6s ease-in-out; -o-transition: -o-transform .6s ease-in-out; transition: transform .6s ease-in-out; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-perspective: 1000; perspective: 1000; } .carousel-inner > .item.next, .carousel-inner > .item.active.right { left: 0; -webkit-transform: translate3d(100%, 0, 0); transform: translate3d(100%, 0, 0); } .carousel-inner > .item.prev, .carousel-inner > .item.active.left { left: 0; -webkit-transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0); } .carousel-inner > .item.next.left, .carousel-inner > .item.prev.right, .carousel-inner > .item.active { left: 0; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } } .carousel-inner > .active, .carousel-inner > .next, .carousel-inner > .prev { display: block; } .carousel-inner > .active { left: 0; } .carousel-inner > .next, .carousel-inner > .prev { position: absolute; top: 0; width: 100%; } .carousel-inner > .next { left: 100%; } .carousel-inner > .prev { left: -100%; } .carousel-inner > .next.left, .carousel-inner > .prev.right { left: 0; } .carousel-inner > .active.left { left: -100%; } .carousel-inner > .active.right { left: 100%; } .carousel-control { position: absolute; top: 0; bottom: 0; left: 0; width: 15%; font-size: 20px; color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); filter: alpha(opacity=50); opacity: .5; } .carousel-control.left { background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%); background-image: -o-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%); background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .5)), to(rgba(0, 0, 0, .0001))); background-image: linear-gradient(to right, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1); background-repeat: repeat-x; } .carousel-control.right { right: 0; left: auto; background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%); background-image: -o-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%); background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .0001)), to(rgba(0, 0, 0, .5))); background-image: linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1); background-repeat: repeat-x; } .carousel-control:hover, .carousel-control:focus { color: #fff; text-decoration: none; filter: alpha(opacity=90); outline: 0; opacity: .9; } .carousel-control .icon-prev, .carousel-control .icon-next, .carousel-control .glyphicon-chevron-left, .carousel-control .glyphicon-chevron-right { position: absolute; top: 50%; z-index: 5; display: inline-block; } .carousel-control .icon-prev, .carousel-control .glyphicon-chevron-left { left: 50%; margin-left: -10px; } .carousel-control .icon-next, .carousel-control .glyphicon-chevron-right { right: 50%; margin-right: -10px; } .carousel-control .icon-prev, .carousel-control .icon-next { width: 20px; height: 20px; margin-top: -10px; font-family: serif; } .carousel-control .icon-prev:before { content: '\2039'; } .carousel-control .icon-next:before { content: '\203a'; } .carousel-indicators { position: absolute; bottom: 10px; left: 50%; z-index: 15; width: 60%; padding-left: 0; margin-left: -30%; text-align: center; list-style: none; } .carousel-indicators li { display: inline-block; width: 10px; height: 10px; margin: 1px; text-indent: -999px; cursor: pointer; background-color: #000 \9; background-color: rgba(0, 0, 0, 0); border: 1px solid #fff; border-radius: 10px; } .carousel-indicators .active { width: 12px; height: 12px; margin: 0; background-color: #fff; } .carousel-caption { position: absolute; right: 15%; bottom: 20px; left: 15%; z-index: 10; padding-top: 20px; padding-bottom: 20px; color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); } .carousel-caption .btn { text-shadow: none; } @media screen and (min-width: 768px) { .carousel-control .glyphicon-chevron-left, .carousel-control .glyphicon-chevron-right, .carousel-control .icon-prev, .carousel-control .icon-next { width: 30px; height: 30px; margin-top: -15px; font-size: 30px; } .carousel-control .glyphicon-chevron-left, .carousel-control .icon-prev { margin-left: -15px; } .carousel-control .glyphicon-chevron-right, .carousel-control .icon-next { margin-right: -15px; } .carousel-caption { right: 20%; left: 20%; padding-bottom: 30px; } .carousel-indicators { bottom: 20px; } } .clearfix:before, .clearfix:after, .dl-horizontal dd:before, .dl-horizontal dd:after, .container:before, .container:after, .container-fluid:before, .container-fluid:after, .row:before, .row:after, .form-horizontal .form-group:before, .form-horizontal .form-group:after, .btn-toolbar:before, .btn-toolbar:after, .btn-group-vertical > .btn-group:before, .btn-group-vertical > .btn-group:after, .nav:before, .nav:after, .navbar:before, .navbar:after, .navbar-header:before, .navbar-header:after, .navbar-collapse:before, .navbar-collapse:after, .pager:before, .pager:after, .panel-body:before, .panel-body:after, .modal-footer:before, .modal-footer:after { display: table; content: " "; } .clearfix:after, .dl-horizontal dd:after, .container:after, .container-fluid:after, .row:after, .form-horizontal .form-group:after, .btn-toolbar:after, .btn-group-vertical > .btn-group:after, .nav:after, .navbar:after, .navbar-header:after, .navbar-collapse:after, .pager:after, .panel-body:after, .modal-footer:after { clear: both; } .center-block { display: block; margin-right: auto; margin-left: auto; } .pull-right { float: right !important; } .pull-left { float: left !important; } .hide { display: none !important; } .show { display: block !important; } .invisible { visibility: hidden; } .text-hide { font: 0/0 a; color: transparent; text-shadow: none; background-color: transparent; border: 0; } .hidden { display: none !important; visibility: hidden !important; } .affix { position: fixed; } @-ms-viewport { width: device-width; } .visible-xs, .visible-sm, .visible-md, .visible-lg { display: none !important; } .visible-xs-block, .visible-xs-inline, .visible-xs-inline-block, .visible-sm-block, .visible-sm-inline, .visible-sm-inline-block, .visible-md-block, .visible-md-inline, .visible-md-inline-block, .visible-lg-block, .visible-lg-inline, .visible-lg-inline-block { display: none !important; } @media (max-width: 767px) { .visible-xs { display: block !important; } table.visible-xs { display: table; } tr.visible-xs { display: table-row !important; } th.visible-xs, td.visible-xs { display: table-cell !important; } } @media (max-width: 767px) { .visible-xs-block { display: block !important; } } @media (max-width: 767px) { .visible-xs-inline { display: inline !important; } } @media (max-width: 767px) { .visible-xs-inline-block { display: inline-block !important; } } @media (min-width: 768px) and (max-width: 991px) { .visible-sm { display: block !important; } table.visible-sm { display: table; } tr.visible-sm { display: table-row !important; } th.visible-sm, td.visible-sm { display: table-cell !important; } } @media (min-width: 768px) and (max-width: 991px) { .visible-sm-block { display: block !important; } } @media (min-width: 768px) and (max-width: 991px) { .visible-sm-inline { display: inline !important; } } @media (min-width: 768px) and (max-width: 991px) { .visible-sm-inline-block { display: inline-block !important; } } @media (min-width: 992px) and (max-width: 1199px) { .visible-md { display: block !important; } table.visible-md { display: table; } tr.visible-md { display: table-row !important; } th.visible-md, td.visible-md { display: table-cell !important; } } @media (min-width: 992px) and (max-width: 1199px) { .visible-md-block { display: block !important; } } @media (min-width: 992px) and (max-width: 1199px) { .visible-md-inline { display: inline !important; } } @media (min-width: 992px) and (max-width: 1199px) { .visible-md-inline-block { display: inline-block !important; } } @media (min-width: 1200px) { .visible-lg { display: block !important; } table.visible-lg { display: table; } tr.visible-lg { display: table-row !important; } th.visible-lg, td.visible-lg { display: table-cell !important; } } @media (min-width: 1200px) { .visible-lg-block { display: block !important; } } @media (min-width: 1200px) { .visible-lg-inline { display: inline !important; } } @media (min-width: 1200px) { .visible-lg-inline-block { display: inline-block !important; } } @media (max-width: 767px) { .hidden-xs { display: none !important; } } @media (min-width: 768px) and (max-width: 991px) { .hidden-sm { display: none !important; } } @media (min-width: 992px) and (max-width: 1199px) { .hidden-md { display: none !important; } } @media (min-width: 1200px) { .hidden-lg { display: none !important; } } .visible-print { display: none !important; } @media print { .visible-print { display: block !important; } table.visible-print { display: table; } tr.visible-print { display: table-row !important; } th.visible-print, td.visible-print { display: table-cell !important; } } .visible-print-block { display: none !important; } @media print { .visible-print-block { display: block !important; } } .visible-print-inline { display: none !important; } @media print { .visible-print-inline { display: inline !important; } } .visible-print-inline-block { display: none !important; } @media print { .visible-print-inline-block { display: inline-block !important; } } @media print { .hidden-print { display: none !important; } } /*# sourceMappingURL=bootstrap.css.map */
gpl-2.0
ragnerok/phpmyadmin
tbl_operations.php
15012
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Various table operations * * @package PhpMyAdmin */ use PMA\libraries\Partition; use PMA\libraries\Table; use PMA\libraries\Response; /** * */ require_once 'libraries/common.inc.php'; /** * functions implementation for this script */ require_once 'libraries/check_user_privileges.lib.php'; require_once 'libraries/operations.lib.php'; $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']); /** * Load JavaScript files */ $response = Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('tbl_operations.js'); /** * Runs common work */ require 'libraries/tbl_common.inc.php'; $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php'; $url_params['goto'] = $url_params['back'] = 'tbl_operations.php'; /** * Gets relation settings */ $cfgRelation = PMA_getRelationsParam(); // reselect current db (needed in some cases probably due to // the calling of relation.lib.php) $GLOBALS['dbi']->selectDb($GLOBALS['db']); /** * Gets tables information */ $pma_table = $GLOBALS['dbi']->getTable( $GLOBALS['db'], $GLOBALS['table'] ); $reread_info = $pma_table->getStatusInfo(null, false); $GLOBALS['showtable'] = $pma_table->getStatusInfo(null, (isset($reread_info) && $reread_info ? true : false)); if ($pma_table->isView()) { $tbl_is_view = true; $tbl_storage_engine = __('View'); $show_comment = null; } else { $tbl_is_view = false; $tbl_storage_engine = $pma_table->getStorageEngine(); $show_comment = $pma_table->getComment(); } $tbl_collation = $pma_table->getCollation(); $table_info_num_rows = $pma_table->getNumRows(); $row_format = $pma_table->getRowFormat(); $auto_increment = $pma_table->getAutoIncrement(); $create_options = $pma_table->getCreateOptions(); // set initial value of these variables, based on the current table engine if ($pma_table->isEngine('ARIA')) { // the value for transactional can be implicit // (no create option found, in this case it means 1) // or explicit (option found with a value of 0 or 1) // ($create_options['transactional'] may have been set by Table class, // from the $create_options) $create_options['transactional'] = (isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'; $create_options['page_checksum'] = (isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''; } $pma_table = $GLOBALS['dbi']->getTable( $GLOBALS['db'], $GLOBALS['table'] ); $reread_info = false; $table_alters = array(); /** * If the table has to be moved to some other database */ if (isset($_REQUEST['submit_move']) || isset($_REQUEST['submit_copy'])) { //$_message = ''; PMA_moveOrCopyTable($db, $table); // This was ended in an Ajax call exit; } /** * If the table has to be maintained */ if (isset($_REQUEST['table_maintenance'])) { include_once 'sql.php'; unset($result); } /** * Updates table comment, type and options if required */ if (isset($_REQUEST['submitoptions'])) { $_message = ''; $warning_messages = array(); if (isset($_REQUEST['new_name'])) { // Get original names before rename operation $oldTable = $pma_table->getName(); $oldDb = $pma_table->getDbName(); if ($pma_table->rename($_REQUEST['new_name'])) { if (isset($_REQUEST['adjust_privileges']) && ! empty($_REQUEST['adjust_privileges']) ) { PMA_AdjustPrivileges_renameOrMoveTable( $oldDb, $oldTable, $_REQUEST['db'], $_REQUEST['new_name'] ); } // Reselect the original DB $GLOBALS['db'] = $oldDb; $GLOBALS['dbi']->selectDb($oldDb); $_message .= $pma_table->getLastMessage(); $result = true; $GLOBALS['table'] = $pma_table->getName(); $reread_info = true; $reload = true; } else { $_message .= $pma_table->getLastError(); $result = false; } } if (! empty($_REQUEST['new_tbl_storage_engine']) && mb_strtoupper($_REQUEST['new_tbl_storage_engine']) !== $tbl_storage_engine ) { $new_tbl_storage_engine = mb_strtoupper($_REQUEST['new_tbl_storage_engine']); if ($pma_table->isEngine('ARIA')) { $create_options['transactional'] = (isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'; $create_options['page_checksum'] = (isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''; } } else { $new_tbl_storage_engine = ''; } $row_format = (isset($create_options['row_format'])) ? $create_options['row_format'] : $pma_table->getRowFormat(); $table_alters = PMA_getTableAltersArray( $pma_table, $create_options['pack_keys'], (empty($create_options['checksum']) ? '0' : '1'), ((isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''), (empty($create_options['delay_key_write']) ? '0' : '1'), $row_format, $new_tbl_storage_engine, ((isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'), $tbl_collation ); if (count($table_alters) > 0) { $sql_query = 'ALTER TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']); $sql_query .= "\r\n" . implode("\r\n", $table_alters); $sql_query .= ';'; $result .= $GLOBALS['dbi']->query($sql_query) ? true : false; $reread_info = true; unset($table_alters); $warning_messages = PMA_getWarningMessagesArray(); } if (isset($_REQUEST['tbl_collation']) && ! empty($_REQUEST['tbl_collation']) && isset($_REQUEST['change_all_collations']) && ! empty($_REQUEST['change_all_collations']) ) { PMA_changeAllColumnsCollation( $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['tbl_collation'] ); } } /** * Reordering the table has been requested by the user */ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) { list($sql_query, $result) = PMA_getQueryAndResultForReorderingTable(); } // end if /** * A partition operation has been requested by the user */ if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation']) ) { list($sql_query, $result) = PMA_getQueryAndResultForPartition(); } // end if if ($reread_info) { // to avoid showing the old value (for example the AUTO_INCREMENT) after // a change, clear the cache $GLOBALS['dbi']->clearTableCache(); $GLOBALS['dbi']->selectDb($GLOBALS['db']); $GLOBALS['showtable'] = $pma_table->getStatusInfo(null, true); if ($pma_table->isView()) { $tbl_is_view = true; $tbl_storage_engine = __('View'); $show_comment = null; } else { $tbl_is_view = false; $tbl_storage_engine = $pma_table->getStorageEngine(); $show_comment = $pma_table->getComment(); } $tbl_collation = $pma_table->getCollation(); $table_info_num_rows = $pma_table->getNumRows(); $row_format = $pma_table->getRowFormat(); $auto_increment = $pma_table->getAutoIncrement(); $create_options = $pma_table->getCreateOptions(); } unset($reread_info); if (isset($result) && empty($message_to_show)) { if (empty($_message)) { if (empty($sql_query)) { $_message = PMA\libraries\Message::success(__('No change')); } else { $_message = $result ? PMA\libraries\Message::success() : PMA\libraries\Message::error(); } if ($response->isAjax()) { $response->setRequestStatus($_message->isSuccess()); $response->addJSON('message', $_message); if (!empty($sql_query)) { $response->addJSON( 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) ); } exit; } } else { $_message = $result ? PMA\libraries\Message::success($_message) : PMA\libraries\Message::error($_message); } if (! empty($warning_messages)) { $_message = new PMA\libraries\Message; $_message->addMessagesString($warning_messages); $_message->isError(true); if ($response->isAjax()) { $response->setRequestStatus(false); $response->addJSON('message', $_message); if (!empty($sql_query)) { $response->addJSON( 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) ); } exit; } unset($warning_messages); } if (empty($sql_query)) { $response->addHTML( $_message->getDisplay() ); } else { $response->addHTML( PMA\libraries\Util::getMessage($_message, $sql_query) ); } unset($_message); } $url_params['goto'] = $url_params['back'] = 'tbl_operations.php'; /** * Get columns names */ $columns = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $GLOBALS['table']); /** * Displays the page */ $response->addHTML('<div id="boxContainer" data-box-width="300">'); /** * Order the table */ $hideOrderTable = false; // `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain // a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index). // InnoDB always orders table rows according to such an index if one is present. if ($tbl_storage_engine == 'INNODB') { $indexes = PMA\libraries\Index::getFromTable($GLOBALS['table'], $GLOBALS['db']); foreach ($indexes as $name => $idx) { if ($name == 'PRIMARY') { $hideOrderTable = true; break; } elseif (! $idx->getNonUnique()) { $notNull = true; foreach ($idx->getColumns() as $column) { if ($column->getNull()) { $notNull = false; break; } } if ($notNull) { $hideOrderTable = true; break; } } } } if (! $hideOrderTable) { $response->addHTML(PMA_getHtmlForOrderTheTable($columns)); } /** * Move table */ $response->addHTML(PMA_getHtmlForMoveTable()); if (mb_strstr($show_comment, '; InnoDB free') === false) { if (mb_strstr($show_comment, 'InnoDB free') === false) { // only user entered comment $comment = $show_comment; } else { // here we have just InnoDB generated part $comment = ''; } } else { // remove InnoDB comment from end, just the minimal part (*? is non greedy) $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); } // PACK_KEYS: MyISAM or ISAM // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT // Here should be version check for InnoDB, however it is supported // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to // check for version $response->addHTML( PMA_getTableOptionDiv( $pma_table, $comment, $tbl_collation, $tbl_storage_engine, $create_options['pack_keys'], $auto_increment, (empty($create_options['delay_key_write']) ? '0' : '1'), ((isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'), ((isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''), (empty($create_options['checksum']) ? '0' : '1') ) ); /** * Copy table */ $response->addHTML(PMA_getHtmlForCopytable()); /** * Table maintenance */ $response->addHTML( PMA_getHtmlForTableMaintenance($pma_table, $url_params) ); if (! (isset($db_is_system_schema) && $db_is_system_schema)) { $truncate_table_url_params = array(); $drop_table_url_params = array(); if (! $tbl_is_view && ! (isset($db_is_system_schema) && $db_is_system_schema) ) { $this_sql_query = 'TRUNCATE TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']); $truncate_table_url_params = array_merge( $url_params, array( 'sql_query' => $this_sql_query, 'goto' => 'tbl_structure.php', 'reload' => '1', 'message_to_show' => sprintf( __('Table %s has been emptied.'), htmlspecialchars($table) ), ) ); } if (! (isset($db_is_system_schema) && $db_is_system_schema)) { $this_sql_query = 'DROP TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']); $drop_table_url_params = array_merge( $url_params, array( 'sql_query' => $this_sql_query, 'goto' => 'db_operations.php', 'reload' => '1', 'purge' => '1', 'message_to_show' => sprintf( ($tbl_is_view ? __('View %s has been dropped.') : __('Table %s has been dropped.') ), htmlspecialchars($table) ), // table name is needed to avoid running // PMA_relationsCleanupDatabase() on the whole db later 'table' => $GLOBALS['table'], ) ); } $response->addHTML( PMA_getHtmlForDeleteDataOrTable( $truncate_table_url_params, $drop_table_url_params ) ); } if (Partition::havePartitioning()) { $partition_names = Partition::getPartitionNames($db, $table); // show the Partition maintenance section only if we detect a partition if (! is_null($partition_names[0])) { $response->addHTML( PMA_getHtmlForPartitionMaintenance($partition_names, $url_params) ); } // end if } // end if unset($partition_names); // Referential integrity check // The Referential integrity check was intended for the non-InnoDB // tables for which the relations are defined in pmadb // so I assume that if the current table is InnoDB, I don't display // this choice (InnoDB maintains integrity by itself) if ($cfgRelation['relwork'] && ! $pma_table->isEngine("INNODB")) { $GLOBALS['dbi']->selectDb($GLOBALS['db']); $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'internal'); if (! empty($foreign)) { $response->addHTML( PMA_getHtmlForReferentialIntegrityCheck($foreign, $url_params) ); } // end if ($foreign) } // end if (!empty($cfg['Server']['relation'])) $response->addHTML('</div>');
gpl-2.0
tectronics/force-distribution-analysis.gromacs-4-5-3
src/gmxlib/nonbonded/nb_kernel_f77_single/nb_kernel212_f77_single.h
4694
/* * This source code is part of * * G R O M A C S * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2009, The GROMACS Development Team * * Gromacs is a library for molecular simulation and trajectory analysis, * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for * a full list of developers and information, check out http://www.gromacs.org * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * As a special exception, you may use this file as part of a free software * library without restriction. Specifically, if other files instantiate * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by * the GNU Lesser General Public License. * * In plain-speak: do not worry about classes/macros/templates either - only * changes to the library have to be LGPL, not an application linking with it. * * To help fund GROMACS development, we humbly ask that you cite * the papers people have written on it - you can find them on the website! */ #ifndef _NBKERNEL212_F77S_H_ #define _NBKERNEL212_F77S_H_ /*! \file nb_kernel212_f77_single.h * \brief Nonbonded kernel 212 (RF Coul + LJ, SPC-SPC) * * \internal */ #include "types/simple.h" #ifdef __cplusplus extern "C" { #endif #if 0 } #endif /*! \brief Nonbonded kernel 212 with forces. * * <b>Coulomb interaction:</b> Reaction-Field <br> * <b>VdW interaction:</b> Lennard-Jones <br> * <b>Water optimization:</b> SPC - SPC <br> * <b>Forces calculated:</b> Yes <br> * * \note All level1 and level2 nonbonded kernels use the same * call sequence. Parameters are documented in nb_kernel_f77_single.h */ void nb_kernel212_f77_single (int * nri, int iinr[], int jindex[], int jjnr[], int shift[], real shiftvec[], real fshift[], int gid[], real pos[], real faction[], real charge[], real * facel, real * krf, real * crf, real Vc[], int type[], int * ntype, real vdwparam[], real Vvdw[], real * tabscale, real VFtab[], real invsqrta[], real dvda[], real * gbtabscale, real GBtab[], int * nthreads, int * count, void * mtx, int * outeriter, int * inneriter, real work[]); /*! \brief Nonbonded kernel 212 without forces. * * <b>Coulomb interaction:</b> Reaction-Field <br> * <b>VdW interaction:</b> Lennard-Jones <br> * <b>Water optimization:</b> SPC - SPC <br> * <b>Forces calculated:</b> No <br> * * \note All level1 and level2 nonbonded kernels use the same * call sequence. Parameters are documented in nb_kernel_f77_single.h */ void nb_kernel212nf_f77_single (int * nri, int iinr[], int jindex[], int jjnr[], int shift[], real shiftvec[], real fshift[], int gid[], real pos[], real faction[], real charge[], real * facel, real * krf, real * crf, real Vc[], int type[], int * ntype, real vdwparam[], real Vvdw[], real * tabscale, real VFtab[], real invsqrta[], real dvda[], real * gbtabscale, real GBtab[], int * nthreads, int * count, void * mtx, int * outeriter, int * inneriter, real work[]); #ifdef __cplusplus } #endif #endif /* _NBKERNEL212_F77S_H_ */
gpl-2.0
csitarichie/boost_msm_bare_metal
tools/compilers/arm/sourcery_2010_q1_none_eabi/share/doc/arm-arm-none-eabi/html/gcc/Structure_002dPacking-Pragmas.html
4563
<html lang="en"> <head> <title>Structure-Packing Pragmas - Using the GNU Compiler Collection (GCC)</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using the GNU Compiler Collection (GCC)"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Pragmas.html#Pragmas" title="Pragmas"> <link rel="prev" href="Symbol_002dRenaming-Pragmas.html#Symbol_002dRenaming-Pragmas" title="Symbol-Renaming Pragmas"> <link rel="next" href="Weak-Pragmas.html#Weak-Pragmas" title="Weak Pragmas"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Funding Free Software'', the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> <link rel="stylesheet" type="text/css" href="../cs.css"> </head> <body> <div class="node"> <a name="Structure-Packing-Pragmas"></a> <a name="Structure_002dPacking-Pragmas"></a> <p> Next:&nbsp;<a rel="next" accesskey="n" href="Weak-Pragmas.html#Weak-Pragmas">Weak Pragmas</a>, Previous:&nbsp;<a rel="previous" accesskey="p" href="Symbol_002dRenaming-Pragmas.html#Symbol_002dRenaming-Pragmas">Symbol-Renaming Pragmas</a>, Up:&nbsp;<a rel="up" accesskey="u" href="Pragmas.html#Pragmas">Pragmas</a> <hr> </div> <h4 class="subsection">5.53.7 Structure-Packing Pragmas</h4> <p>For compatibility with Microsoft Windows compilers, GCC supports a set of <code>#pragma</code> directives which change the maximum alignment of members of structures (other than zero-width bitfields), unions, and classes subsequently defined. The <var>n</var> value below always is required to be a small power of two and specifies the new alignment in bytes. <ol type=1 start=1> <li><code>#pragma pack(</code><var>n</var><code>)</code> simply sets the new alignment. <li><code>#pragma pack()</code> sets the alignment to the one that was in effect when compilation started (see also command line option <samp><span class="option">-fpack-struct[=&lt;n&gt;]</span></samp> see <a href="Code-Gen-Options.html#Code-Gen-Options">Code Gen Options</a>). <li><code>#pragma pack(push[,</code><var>n</var><code>])</code> pushes the current alignment setting on an internal stack and then optionally sets the new alignment. <li><code>#pragma pack(pop)</code> restores the alignment setting to the one saved at the top of the internal stack (and removes that stack entry). Note that <code>#pragma pack([</code><var>n</var><code>])</code> does not influence this internal stack; thus it is possible to have <code>#pragma pack(push)</code> followed by multiple <code>#pragma pack(</code><var>n</var><code>)</code> instances and finalized by a single <code>#pragma pack(pop)</code>. </ol> <p>Some targets, e.g. i386 and powerpc, support the <code>ms_struct</code> <code>#pragma</code> which lays out a structure as the documented <code>__attribute__ ((ms_struct))</code>. <ol type=1 start=1> <li><code>#pragma ms_struct on</code> turns on the layout for structures declared. <li><code>#pragma ms_struct off</code> turns off the layout for structures declared. <li><code>#pragma ms_struct reset</code> goes back to the default layout. </ol> </body></html>
gpl-2.0
fleeboy/tatt2tatt
core/modules/config_translation/tests/src/ConfigMapperManagerTest.php
6236
<?php /** * @file * Contains \Drupal\config_translation\Tests\ConfigMapperManagerTest. */ namespace Drupal\config_translation\Tests; use Drupal\config_translation\ConfigMapperManager; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Tests\UnitTestCase; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinitionInterface; /** * Tests the functionality provided by configuration translation mapper manager. * * @group config_translation */ class ConfigMapperManagerTest extends UnitTestCase { /** * The configuration mapper manager to test. * * @var \Drupal\config_translation\ConfigMapperManager */ protected $configMapperManager; /** * The typed configuration manager used for testing. * * @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $typedConfigManager; public function setUp() { $language = new Language(array('id' => 'en')); $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') ->with(LanguageInterface::TYPE_INTERFACE) ->will($this->returnValue($language)); $this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface') ->getMock(); $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); $module_handler->expects($this->once()) ->method('getModuleList') ->with() ->will($this->returnValue(array())); $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler->expects($this->any()) ->method('listInfo') ->will($this->returnValue(array())); $this->configMapperManager = new ConfigMapperManager( $this->getMock('Drupal\Core\Cache\CacheBackendInterface'), $language_manager, $module_handler, $this->typedConfigManager, $theme_handler ); } /** * Tests ConfigMapperManager::hasTranslatable(). * * @param \Drupal\Core\TypedData\TypedDataInterface $element * The schema element to test. * @param bool $expected * The expected return value of ConfigMapperManager::hasTranslatable(). * * @dataProvider providerTestHasTranslatable */ public function testHasTranslatable(TypedDataInterface $element, $expected) { $this->typedConfigManager ->expects($this->once()) ->method('get') ->with('test') ->will($this->returnValue($element)); $result = $this->configMapperManager->hasTranslatable('test'); $this->assertSame($expected, $result); } /** * Provides data for ConfigMapperManager::testHasTranslatable() * * @return array * An array of arrays, where each inner array contains the schema element * to test as the first key and the expected result of * ConfigMapperManager::hasTranslatable() as the second key. */ public function providerTestHasTranslatable() { return array( array($this->getElement(array()), FALSE), array($this->getElement(array('aaa' => 'bbb')), FALSE), array($this->getElement(array('translatable' => FALSE)), FALSE), array($this->getElement(array('translatable' => TRUE)), TRUE), array($this->getNestedElement(array( $this->getElement(array()), )), FALSE), array($this->getNestedElement(array( $this->getElement(array('translatable' => TRUE)), )), TRUE), array($this->getNestedElement(array( $this->getElement(array('aaa' => 'bbb')), $this->getElement(array('ccc' => 'ddd')), $this->getElement(array('eee' => 'fff')), )), FALSE), array($this->getNestedElement(array( $this->getElement(array('aaa' => 'bbb')), $this->getElement(array('ccc' => 'ddd')), $this->getElement(array('translatable' => TRUE)), )), TRUE), array($this->getNestedElement(array( $this->getElement(array('aaa' => 'bbb')), $this->getNestedElement(array( $this->getElement(array('ccc' => 'ddd')), $this->getElement(array('eee' => 'fff')), )), $this->getNestedElement(array( $this->getElement(array('ggg' => 'hhh')), $this->getElement(array('iii' => 'jjj')), )), )), FALSE), array($this->getNestedElement(array( $this->getElement(array('aaa' => 'bbb')), $this->getNestedElement(array( $this->getElement(array('ccc' => 'ddd')), $this->getElement(array('eee' => 'fff')), )), $this->getNestedElement(array( $this->getElement(array('ggg' => 'hhh')), $this->getElement(array('translatable' => TRUE)), )), )), TRUE), ); } /** * Returns a mocked schema element. * * @param array $definition * The definition of the schema element. * * @return \Drupal\Core\Config\Schema\Element * The mocked schema element. */ protected function getElement(array $definition) { $data_definition = new DataDefinition($definition); $element = $this->getMock('Drupal\Core\TypedData\TypedDataInterface'); $element->expects($this->any()) ->method('getDataDefinition') ->will($this->returnValue($data_definition)); return $element; } /** * Returns a mocked nested schema element. * * @param array $elements * An array of simple schema elements. * * @return \Drupal\Core\Config\Schema\Mapping * A nested schema element, containing the passed-in elements. */ protected function getNestedElement(array $elements) { // ConfigMapperManager::findTranslatable() checks for the abstract class // \Drupal\Core\Config\Schema\ArrayElement, but mocking that directly does // not work. $nested_element = $this->getMockBuilder('Drupal\Core\Config\Schema\Mapping') ->disableOriginalConstructor() ->getMock(); $nested_element->expects($this->once()) ->method('getIterator') ->will($this->returnValue(new \ArrayIterator($elements))); return $nested_element; } }
gpl-2.0
mcmenaminadrian/Linux-devel
drivers/net/ethernet/neterion/s2io.c
246436
/************************************************************************ * s2io.c: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC * Copyright(c) 2002-2010 Exar Corp. * * This software may be used and distributed according to the terms of * the GNU General Public License (GPL), incorporated herein by reference. * Drivers based on or derived from this code fall under the GPL and must * retain the authorship, copyright and license notice. This file is not * a complete program and may only be used when the entire operating * system is licensed under the GPL. * See the file COPYING in this distribution for more information. * * Credits: * Jeff Garzik : For pointing out the improper error condition * check in the s2io_xmit routine and also some * issues in the Tx watch dog function. Also for * patiently answering all those innumerable * questions regaring the 2.6 porting issues. * Stephen Hemminger : Providing proper 2.6 porting mechanism for some * macros available only in 2.6 Kernel. * Francois Romieu : For pointing out all code part that were * deprecated and also styling related comments. * Grant Grundler : For helping me get rid of some Architecture * dependent code. * Christopher Hellwig : Some more 2.6 specific issues in the driver. * * The module loadable parameters that are supported by the driver and a brief * explanation of all the variables. * * rx_ring_num : This can be used to program the number of receive rings used * in the driver. * rx_ring_sz: This defines the number of receive blocks each ring can have. * This is also an array of size 8. * rx_ring_mode: This defines the operation mode of all 8 rings. The valid * values are 1, 2. * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. * tx_fifo_len: This too is an array of 8. Each element defines the number of * Tx descriptors that can be associated with each corresponding FIFO. * intr_type: This defines the type of interrupt. The values can be 0(INTA), * 2(MSI_X). Default value is '2(MSI_X)' * lro_max_pkts: This parameter defines maximum number of packets can be * aggregated as a single large packet * napi: This parameter used to enable/disable NAPI (polling Rx) * Possible values '1' for enable and '0' for disable. Default is '1' * ufo: This parameter used to enable/disable UDP Fragmentation Offload(UFO) * Possible values '1' for enable and '0' for disable. Default is '0' * vlan_tag_strip: This can be used to enable or disable vlan stripping. * Possible values '1' for enable , '0' for disable. * Default is '2' - which means disable in promisc mode * and enable in non-promiscuous mode. * multiq: This parameter used to enable/disable MULTIQUEUE support. * Possible values '1' for enable and '0' for disable. Default is '0' ************************************************************************/ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/ioport.h> #include <linux/pci.h> #include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/mdio.h> #include <linux/skbuff.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/stddef.h> #include <linux/ioctl.h> #include <linux/timex.h> #include <linux/ethtool.h> #include <linux/workqueue.h> #include <linux/if_vlan.h> #include <linux/ip.h> #include <linux/tcp.h> #include <linux/uaccess.h> #include <linux/io.h> #include <linux/slab.h> #include <linux/prefetch.h> #include <net/tcp.h> #include <asm/system.h> #include <asm/div64.h> #include <asm/irq.h> /* local include */ #include "s2io.h" #include "s2io-regs.h" #define DRV_VERSION "2.0.26.28" /* S2io Driver name & version. */ static const char s2io_driver_name[] = "Neterion"; static const char s2io_driver_version[] = DRV_VERSION; static const int rxd_size[2] = {32, 48}; static const int rxd_count[2] = {127, 85}; static inline int RXD_IS_UP2DT(struct RxD_t *rxdp) { int ret; ret = ((!(rxdp->Control_1 & RXD_OWN_XENA)) && (GET_RXD_MARKER(rxdp->Control_2) != THE_RXD_MARK)); return ret; } /* * Cards with following subsystem_id have a link state indication * problem, 600B, 600C, 600D, 640B, 640C and 640D. * macro below identifies these cards given the subsystem_id. */ #define CARDS_WITH_FAULTY_LINK_INDICATORS(dev_type, subid) \ (dev_type == XFRAME_I_DEVICE) ? \ ((((subid >= 0x600B) && (subid <= 0x600D)) || \ ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0) : 0 #define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \ ADAPTER_STATUS_RMAC_LOCAL_FAULT))) static inline int is_s2io_card_up(const struct s2io_nic *sp) { return test_bit(__S2IO_STATE_CARD_UP, &sp->state); } /* Ethtool related variables and Macros. */ static const char s2io_gstrings[][ETH_GSTRING_LEN] = { "Register test\t(offline)", "Eeprom test\t(offline)", "Link test\t(online)", "RLDRAM test\t(offline)", "BIST Test\t(offline)" }; static const char ethtool_xena_stats_keys[][ETH_GSTRING_LEN] = { {"tmac_frms"}, {"tmac_data_octets"}, {"tmac_drop_frms"}, {"tmac_mcst_frms"}, {"tmac_bcst_frms"}, {"tmac_pause_ctrl_frms"}, {"tmac_ttl_octets"}, {"tmac_ucst_frms"}, {"tmac_nucst_frms"}, {"tmac_any_err_frms"}, {"tmac_ttl_less_fb_octets"}, {"tmac_vld_ip_octets"}, {"tmac_vld_ip"}, {"tmac_drop_ip"}, {"tmac_icmp"}, {"tmac_rst_tcp"}, {"tmac_tcp"}, {"tmac_udp"}, {"rmac_vld_frms"}, {"rmac_data_octets"}, {"rmac_fcs_err_frms"}, {"rmac_drop_frms"}, {"rmac_vld_mcst_frms"}, {"rmac_vld_bcst_frms"}, {"rmac_in_rng_len_err_frms"}, {"rmac_out_rng_len_err_frms"}, {"rmac_long_frms"}, {"rmac_pause_ctrl_frms"}, {"rmac_unsup_ctrl_frms"}, {"rmac_ttl_octets"}, {"rmac_accepted_ucst_frms"}, {"rmac_accepted_nucst_frms"}, {"rmac_discarded_frms"}, {"rmac_drop_events"}, {"rmac_ttl_less_fb_octets"}, {"rmac_ttl_frms"}, {"rmac_usized_frms"}, {"rmac_osized_frms"}, {"rmac_frag_frms"}, {"rmac_jabber_frms"}, {"rmac_ttl_64_frms"}, {"rmac_ttl_65_127_frms"}, {"rmac_ttl_128_255_frms"}, {"rmac_ttl_256_511_frms"}, {"rmac_ttl_512_1023_frms"}, {"rmac_ttl_1024_1518_frms"}, {"rmac_ip"}, {"rmac_ip_octets"}, {"rmac_hdr_err_ip"}, {"rmac_drop_ip"}, {"rmac_icmp"}, {"rmac_tcp"}, {"rmac_udp"}, {"rmac_err_drp_udp"}, {"rmac_xgmii_err_sym"}, {"rmac_frms_q0"}, {"rmac_frms_q1"}, {"rmac_frms_q2"}, {"rmac_frms_q3"}, {"rmac_frms_q4"}, {"rmac_frms_q5"}, {"rmac_frms_q6"}, {"rmac_frms_q7"}, {"rmac_full_q0"}, {"rmac_full_q1"}, {"rmac_full_q2"}, {"rmac_full_q3"}, {"rmac_full_q4"}, {"rmac_full_q5"}, {"rmac_full_q6"}, {"rmac_full_q7"}, {"rmac_pause_cnt"}, {"rmac_xgmii_data_err_cnt"}, {"rmac_xgmii_ctrl_err_cnt"}, {"rmac_accepted_ip"}, {"rmac_err_tcp"}, {"rd_req_cnt"}, {"new_rd_req_cnt"}, {"new_rd_req_rtry_cnt"}, {"rd_rtry_cnt"}, {"wr_rtry_rd_ack_cnt"}, {"wr_req_cnt"}, {"new_wr_req_cnt"}, {"new_wr_req_rtry_cnt"}, {"wr_rtry_cnt"}, {"wr_disc_cnt"}, {"rd_rtry_wr_ack_cnt"}, {"txp_wr_cnt"}, {"txd_rd_cnt"}, {"txd_wr_cnt"}, {"rxd_rd_cnt"}, {"rxd_wr_cnt"}, {"txf_rd_cnt"}, {"rxf_wr_cnt"} }; static const char ethtool_enhanced_stats_keys[][ETH_GSTRING_LEN] = { {"rmac_ttl_1519_4095_frms"}, {"rmac_ttl_4096_8191_frms"}, {"rmac_ttl_8192_max_frms"}, {"rmac_ttl_gt_max_frms"}, {"rmac_osized_alt_frms"}, {"rmac_jabber_alt_frms"}, {"rmac_gt_max_alt_frms"}, {"rmac_vlan_frms"}, {"rmac_len_discard"}, {"rmac_fcs_discard"}, {"rmac_pf_discard"}, {"rmac_da_discard"}, {"rmac_red_discard"}, {"rmac_rts_discard"}, {"rmac_ingm_full_discard"}, {"link_fault_cnt"} }; static const char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { {"\n DRIVER STATISTICS"}, {"single_bit_ecc_errs"}, {"double_bit_ecc_errs"}, {"parity_err_cnt"}, {"serious_err_cnt"}, {"soft_reset_cnt"}, {"fifo_full_cnt"}, {"ring_0_full_cnt"}, {"ring_1_full_cnt"}, {"ring_2_full_cnt"}, {"ring_3_full_cnt"}, {"ring_4_full_cnt"}, {"ring_5_full_cnt"}, {"ring_6_full_cnt"}, {"ring_7_full_cnt"}, {"alarm_transceiver_temp_high"}, {"alarm_transceiver_temp_low"}, {"alarm_laser_bias_current_high"}, {"alarm_laser_bias_current_low"}, {"alarm_laser_output_power_high"}, {"alarm_laser_output_power_low"}, {"warn_transceiver_temp_high"}, {"warn_transceiver_temp_low"}, {"warn_laser_bias_current_high"}, {"warn_laser_bias_current_low"}, {"warn_laser_output_power_high"}, {"warn_laser_output_power_low"}, {"lro_aggregated_pkts"}, {"lro_flush_both_count"}, {"lro_out_of_sequence_pkts"}, {"lro_flush_due_to_max_pkts"}, {"lro_avg_aggr_pkts"}, {"mem_alloc_fail_cnt"}, {"pci_map_fail_cnt"}, {"watchdog_timer_cnt"}, {"mem_allocated"}, {"mem_freed"}, {"link_up_cnt"}, {"link_down_cnt"}, {"link_up_time"}, {"link_down_time"}, {"tx_tcode_buf_abort_cnt"}, {"tx_tcode_desc_abort_cnt"}, {"tx_tcode_parity_err_cnt"}, {"tx_tcode_link_loss_cnt"}, {"tx_tcode_list_proc_err_cnt"}, {"rx_tcode_parity_err_cnt"}, {"rx_tcode_abort_cnt"}, {"rx_tcode_parity_abort_cnt"}, {"rx_tcode_rda_fail_cnt"}, {"rx_tcode_unkn_prot_cnt"}, {"rx_tcode_fcs_err_cnt"}, {"rx_tcode_buf_size_err_cnt"}, {"rx_tcode_rxd_corrupt_cnt"}, {"rx_tcode_unkn_err_cnt"}, {"tda_err_cnt"}, {"pfc_err_cnt"}, {"pcc_err_cnt"}, {"tti_err_cnt"}, {"tpa_err_cnt"}, {"sm_err_cnt"}, {"lso_err_cnt"}, {"mac_tmac_err_cnt"}, {"mac_rmac_err_cnt"}, {"xgxs_txgxs_err_cnt"}, {"xgxs_rxgxs_err_cnt"}, {"rc_err_cnt"}, {"prc_pcix_err_cnt"}, {"rpa_err_cnt"}, {"rda_err_cnt"}, {"rti_err_cnt"}, {"mc_err_cnt"} }; #define S2IO_XENA_STAT_LEN ARRAY_SIZE(ethtool_xena_stats_keys) #define S2IO_ENHANCED_STAT_LEN ARRAY_SIZE(ethtool_enhanced_stats_keys) #define S2IO_DRIVER_STAT_LEN ARRAY_SIZE(ethtool_driver_stats_keys) #define XFRAME_I_STAT_LEN (S2IO_XENA_STAT_LEN + S2IO_DRIVER_STAT_LEN) #define XFRAME_II_STAT_LEN (XFRAME_I_STAT_LEN + S2IO_ENHANCED_STAT_LEN) #define XFRAME_I_STAT_STRINGS_LEN (XFRAME_I_STAT_LEN * ETH_GSTRING_LEN) #define XFRAME_II_STAT_STRINGS_LEN (XFRAME_II_STAT_LEN * ETH_GSTRING_LEN) #define S2IO_TEST_LEN ARRAY_SIZE(s2io_gstrings) #define S2IO_STRINGS_LEN (S2IO_TEST_LEN * ETH_GSTRING_LEN) #define S2IO_TIMER_CONF(timer, handle, arg, exp) \ init_timer(&timer); \ timer.function = handle; \ timer.data = (unsigned long)arg; \ mod_timer(&timer, (jiffies + exp)) \ /* copy mac addr to def_mac_addr array */ static void do_s2io_copy_mac_addr(struct s2io_nic *sp, int offset, u64 mac_addr) { sp->def_mac_addr[offset].mac_addr[5] = (u8) (mac_addr); sp->def_mac_addr[offset].mac_addr[4] = (u8) (mac_addr >> 8); sp->def_mac_addr[offset].mac_addr[3] = (u8) (mac_addr >> 16); sp->def_mac_addr[offset].mac_addr[2] = (u8) (mac_addr >> 24); sp->def_mac_addr[offset].mac_addr[1] = (u8) (mac_addr >> 32); sp->def_mac_addr[offset].mac_addr[0] = (u8) (mac_addr >> 40); } /* * Constants to be programmed into the Xena's registers, to configure * the XAUI. */ #define END_SIGN 0x0 static const u64 herc_act_dtx_cfg[] = { /* Set address */ 0x8000051536750000ULL, 0x80000515367500E0ULL, /* Write data */ 0x8000051536750004ULL, 0x80000515367500E4ULL, /* Set address */ 0x80010515003F0000ULL, 0x80010515003F00E0ULL, /* Write data */ 0x80010515003F0004ULL, 0x80010515003F00E4ULL, /* Set address */ 0x801205150D440000ULL, 0x801205150D4400E0ULL, /* Write data */ 0x801205150D440004ULL, 0x801205150D4400E4ULL, /* Set address */ 0x80020515F2100000ULL, 0x80020515F21000E0ULL, /* Write data */ 0x80020515F2100004ULL, 0x80020515F21000E4ULL, /* Done */ END_SIGN }; static const u64 xena_dtx_cfg[] = { /* Set address */ 0x8000051500000000ULL, 0x80000515000000E0ULL, /* Write data */ 0x80000515D9350004ULL, 0x80000515D93500E4ULL, /* Set address */ 0x8001051500000000ULL, 0x80010515000000E0ULL, /* Write data */ 0x80010515001E0004ULL, 0x80010515001E00E4ULL, /* Set address */ 0x8002051500000000ULL, 0x80020515000000E0ULL, /* Write data */ 0x80020515F2100004ULL, 0x80020515F21000E4ULL, END_SIGN }; /* * Constants for Fixing the MacAddress problem seen mostly on * Alpha machines. */ static const u64 fix_mac[] = { 0x0060000000000000ULL, 0x0060600000000000ULL, 0x0040600000000000ULL, 0x0000600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0060600000000000ULL, 0x0020600000000000ULL, 0x0000600000000000ULL, 0x0040600000000000ULL, 0x0060600000000000ULL, END_SIGN }; MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_VERSION); /* Module Loadable parameters. */ S2IO_PARM_INT(tx_fifo_num, FIFO_DEFAULT_NUM); S2IO_PARM_INT(rx_ring_num, 1); S2IO_PARM_INT(multiq, 0); S2IO_PARM_INT(rx_ring_mode, 1); S2IO_PARM_INT(use_continuous_tx_intrs, 1); S2IO_PARM_INT(rmac_pause_time, 0x100); S2IO_PARM_INT(mc_pause_threshold_q0q3, 187); S2IO_PARM_INT(mc_pause_threshold_q4q7, 187); S2IO_PARM_INT(shared_splits, 0); S2IO_PARM_INT(tmac_util_period, 5); S2IO_PARM_INT(rmac_util_period, 5); S2IO_PARM_INT(l3l4hdr_size, 128); /* 0 is no steering, 1 is Priority steering, 2 is Default steering */ S2IO_PARM_INT(tx_steering_type, TX_DEFAULT_STEERING); /* Frequency of Rx desc syncs expressed as power of 2 */ S2IO_PARM_INT(rxsync_frequency, 3); /* Interrupt type. Values can be 0(INTA), 2(MSI_X) */ S2IO_PARM_INT(intr_type, 2); /* Large receive offload feature */ /* Max pkts to be aggregated by LRO at one time. If not specified, * aggregation happens until we hit max IP pkt size(64K) */ S2IO_PARM_INT(lro_max_pkts, 0xFFFF); S2IO_PARM_INT(indicate_max_pkts, 0); S2IO_PARM_INT(napi, 1); S2IO_PARM_INT(ufo, 0); S2IO_PARM_INT(vlan_tag_strip, NO_STRIP_IN_PROMISC); static unsigned int tx_fifo_len[MAX_TX_FIFOS] = {DEFAULT_FIFO_0_LEN, [1 ...(MAX_TX_FIFOS - 1)] = DEFAULT_FIFO_1_7_LEN}; static unsigned int rx_ring_sz[MAX_RX_RINGS] = {[0 ...(MAX_RX_RINGS - 1)] = SMALL_BLK_CNT}; static unsigned int rts_frm_len[MAX_RX_RINGS] = {[0 ...(MAX_RX_RINGS - 1)] = 0 }; module_param_array(tx_fifo_len, uint, NULL, 0); module_param_array(rx_ring_sz, uint, NULL, 0); module_param_array(rts_frm_len, uint, NULL, 0); /* * S2IO device table. * This table lists all the devices that this driver supports. */ static DEFINE_PCI_DEVICE_TABLE(s2io_tbl) = { {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN, PCI_ANY_ID, PCI_ANY_ID}, {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI, PCI_ANY_ID, PCI_ANY_ID}, {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_WIN, PCI_ANY_ID, PCI_ANY_ID}, {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_UNI, PCI_ANY_ID, PCI_ANY_ID}, {0,} }; MODULE_DEVICE_TABLE(pci, s2io_tbl); static struct pci_error_handlers s2io_err_handler = { .error_detected = s2io_io_error_detected, .slot_reset = s2io_io_slot_reset, .resume = s2io_io_resume, }; static struct pci_driver s2io_driver = { .name = "S2IO", .id_table = s2io_tbl, .probe = s2io_init_nic, .remove = __devexit_p(s2io_rem_nic), .err_handler = &s2io_err_handler, }; /* A simplifier macro used both by init and free shared_mem Fns(). */ #define TXD_MEM_PAGE_CNT(len, per_each) ((len+per_each - 1) / per_each) /* netqueue manipulation helper functions */ static inline void s2io_stop_all_tx_queue(struct s2io_nic *sp) { if (!sp->config.multiq) { int i; for (i = 0; i < sp->config.tx_fifo_num; i++) sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_STOP; } netif_tx_stop_all_queues(sp->dev); } static inline void s2io_stop_tx_queue(struct s2io_nic *sp, int fifo_no) { if (!sp->config.multiq) sp->mac_control.fifos[fifo_no].queue_state = FIFO_QUEUE_STOP; netif_tx_stop_all_queues(sp->dev); } static inline void s2io_start_all_tx_queue(struct s2io_nic *sp) { if (!sp->config.multiq) { int i; for (i = 0; i < sp->config.tx_fifo_num; i++) sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_START; } netif_tx_start_all_queues(sp->dev); } static inline void s2io_start_tx_queue(struct s2io_nic *sp, int fifo_no) { if (!sp->config.multiq) sp->mac_control.fifos[fifo_no].queue_state = FIFO_QUEUE_START; netif_tx_start_all_queues(sp->dev); } static inline void s2io_wake_all_tx_queue(struct s2io_nic *sp) { if (!sp->config.multiq) { int i; for (i = 0; i < sp->config.tx_fifo_num; i++) sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_START; } netif_tx_wake_all_queues(sp->dev); } static inline void s2io_wake_tx_queue( struct fifo_info *fifo, int cnt, u8 multiq) { if (multiq) { if (cnt && __netif_subqueue_stopped(fifo->dev, fifo->fifo_no)) netif_wake_subqueue(fifo->dev, fifo->fifo_no); } else if (cnt && (fifo->queue_state == FIFO_QUEUE_STOP)) { if (netif_queue_stopped(fifo->dev)) { fifo->queue_state = FIFO_QUEUE_START; netif_wake_queue(fifo->dev); } } } /** * init_shared_mem - Allocation and Initialization of Memory * @nic: Device private variable. * Description: The function allocates all the memory areas shared * between the NIC and the driver. This includes Tx descriptors, * Rx descriptors and the statistics block. */ static int init_shared_mem(struct s2io_nic *nic) { u32 size; void *tmp_v_addr, *tmp_v_addr_next; dma_addr_t tmp_p_addr, tmp_p_addr_next; struct RxD_block *pre_rxd_blk = NULL; int i, j, blk_cnt; int lst_size, lst_per_page; struct net_device *dev = nic->dev; unsigned long tmp; struct buffAdd *ba; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; unsigned long long mem_allocated = 0; /* Allocation and initialization of TXDLs in FIFOs */ size = 0; for (i = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; size += tx_cfg->fifo_len; } if (size > MAX_AVAILABLE_TXDS) { DBG_PRINT(ERR_DBG, "Too many TxDs requested: %d, max supported: %d\n", size, MAX_AVAILABLE_TXDS); return -EINVAL; } size = 0; for (i = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; size = tx_cfg->fifo_len; /* * Legal values are from 2 to 8192 */ if (size < 2) { DBG_PRINT(ERR_DBG, "Fifo %d: Invalid length (%d) - " "Valid lengths are 2 through 8192\n", i, size); return -EINVAL; } } lst_size = (sizeof(struct TxD) * config->max_txds); lst_per_page = PAGE_SIZE / lst_size; for (i = 0; i < config->tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; int fifo_len = tx_cfg->fifo_len; int list_holder_size = fifo_len * sizeof(struct list_info_hold); fifo->list_info = kzalloc(list_holder_size, GFP_KERNEL); if (!fifo->list_info) { DBG_PRINT(INFO_DBG, "Malloc failed for list_info\n"); return -ENOMEM; } mem_allocated += list_holder_size; } for (i = 0; i < config->tx_fifo_num; i++) { int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, lst_per_page); struct fifo_info *fifo = &mac_control->fifos[i]; struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; fifo->tx_curr_put_info.offset = 0; fifo->tx_curr_put_info.fifo_len = tx_cfg->fifo_len - 1; fifo->tx_curr_get_info.offset = 0; fifo->tx_curr_get_info.fifo_len = tx_cfg->fifo_len - 1; fifo->fifo_no = i; fifo->nic = nic; fifo->max_txds = MAX_SKB_FRAGS + 2; fifo->dev = dev; for (j = 0; j < page_num; j++) { int k = 0; dma_addr_t tmp_p; void *tmp_v; tmp_v = pci_alloc_consistent(nic->pdev, PAGE_SIZE, &tmp_p); if (!tmp_v) { DBG_PRINT(INFO_DBG, "pci_alloc_consistent failed for TxDL\n"); return -ENOMEM; } /* If we got a zero DMA address(can happen on * certain platforms like PPC), reallocate. * Store virtual address of page we don't want, * to be freed later. */ if (!tmp_p) { mac_control->zerodma_virt_addr = tmp_v; DBG_PRINT(INIT_DBG, "%s: Zero DMA address for TxDL. " "Virtual address %p\n", dev->name, tmp_v); tmp_v = pci_alloc_consistent(nic->pdev, PAGE_SIZE, &tmp_p); if (!tmp_v) { DBG_PRINT(INFO_DBG, "pci_alloc_consistent failed for TxDL\n"); return -ENOMEM; } mem_allocated += PAGE_SIZE; } while (k < lst_per_page) { int l = (j * lst_per_page) + k; if (l == tx_cfg->fifo_len) break; fifo->list_info[l].list_virt_addr = tmp_v + (k * lst_size); fifo->list_info[l].list_phy_addr = tmp_p + (k * lst_size); k++; } } } for (i = 0; i < config->tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; size = tx_cfg->fifo_len; fifo->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); if (!fifo->ufo_in_band_v) return -ENOMEM; mem_allocated += (size * sizeof(u64)); } /* Allocation and initialization of RXDs in Rings */ size = 0; for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; if (rx_cfg->num_rxd % (rxd_count[nic->rxd_mode] + 1)) { DBG_PRINT(ERR_DBG, "%s: Ring%d RxD count is not a " "multiple of RxDs per Block\n", dev->name, i); return FAILURE; } size += rx_cfg->num_rxd; ring->block_count = rx_cfg->num_rxd / (rxd_count[nic->rxd_mode] + 1); ring->pkt_cnt = rx_cfg->num_rxd - ring->block_count; } if (nic->rxd_mode == RXD_MODE_1) size = (size * (sizeof(struct RxD1))); else size = (size * (sizeof(struct RxD3))); for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; ring->rx_curr_get_info.block_index = 0; ring->rx_curr_get_info.offset = 0; ring->rx_curr_get_info.ring_len = rx_cfg->num_rxd - 1; ring->rx_curr_put_info.block_index = 0; ring->rx_curr_put_info.offset = 0; ring->rx_curr_put_info.ring_len = rx_cfg->num_rxd - 1; ring->nic = nic; ring->ring_no = i; blk_cnt = rx_cfg->num_rxd / (rxd_count[nic->rxd_mode] + 1); /* Allocating all the Rx blocks */ for (j = 0; j < blk_cnt; j++) { struct rx_block_info *rx_blocks; int l; rx_blocks = &ring->rx_blocks[j]; size = SIZE_OF_BLOCK; /* size is always page size */ tmp_v_addr = pci_alloc_consistent(nic->pdev, size, &tmp_p_addr); if (tmp_v_addr == NULL) { /* * In case of failure, free_shared_mem() * is called, which should free any * memory that was alloced till the * failure happened. */ rx_blocks->block_virt_addr = tmp_v_addr; return -ENOMEM; } mem_allocated += size; memset(tmp_v_addr, 0, size); size = sizeof(struct rxd_info) * rxd_count[nic->rxd_mode]; rx_blocks->block_virt_addr = tmp_v_addr; rx_blocks->block_dma_addr = tmp_p_addr; rx_blocks->rxds = kmalloc(size, GFP_KERNEL); if (!rx_blocks->rxds) return -ENOMEM; mem_allocated += size; for (l = 0; l < rxd_count[nic->rxd_mode]; l++) { rx_blocks->rxds[l].virt_addr = rx_blocks->block_virt_addr + (rxd_size[nic->rxd_mode] * l); rx_blocks->rxds[l].dma_addr = rx_blocks->block_dma_addr + (rxd_size[nic->rxd_mode] * l); } } /* Interlinking all Rx Blocks */ for (j = 0; j < blk_cnt; j++) { int next = (j + 1) % blk_cnt; tmp_v_addr = ring->rx_blocks[j].block_virt_addr; tmp_v_addr_next = ring->rx_blocks[next].block_virt_addr; tmp_p_addr = ring->rx_blocks[j].block_dma_addr; tmp_p_addr_next = ring->rx_blocks[next].block_dma_addr; pre_rxd_blk = tmp_v_addr; pre_rxd_blk->reserved_2_pNext_RxD_block = (unsigned long)tmp_v_addr_next; pre_rxd_blk->pNext_RxD_Blk_physical = (u64)tmp_p_addr_next; } } if (nic->rxd_mode == RXD_MODE_3B) { /* * Allocation of Storages for buffer addresses in 2BUFF mode * and the buffers as well. */ for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; blk_cnt = rx_cfg->num_rxd / (rxd_count[nic->rxd_mode] + 1); size = sizeof(struct buffAdd *) * blk_cnt; ring->ba = kmalloc(size, GFP_KERNEL); if (!ring->ba) return -ENOMEM; mem_allocated += size; for (j = 0; j < blk_cnt; j++) { int k = 0; size = sizeof(struct buffAdd) * (rxd_count[nic->rxd_mode] + 1); ring->ba[j] = kmalloc(size, GFP_KERNEL); if (!ring->ba[j]) return -ENOMEM; mem_allocated += size; while (k != rxd_count[nic->rxd_mode]) { ba = &ring->ba[j][k]; size = BUF0_LEN + ALIGN_SIZE; ba->ba_0_org = kmalloc(size, GFP_KERNEL); if (!ba->ba_0_org) return -ENOMEM; mem_allocated += size; tmp = (unsigned long)ba->ba_0_org; tmp += ALIGN_SIZE; tmp &= ~((unsigned long)ALIGN_SIZE); ba->ba_0 = (void *)tmp; size = BUF1_LEN + ALIGN_SIZE; ba->ba_1_org = kmalloc(size, GFP_KERNEL); if (!ba->ba_1_org) return -ENOMEM; mem_allocated += size; tmp = (unsigned long)ba->ba_1_org; tmp += ALIGN_SIZE; tmp &= ~((unsigned long)ALIGN_SIZE); ba->ba_1 = (void *)tmp; k++; } } } } /* Allocation and initialization of Statistics block */ size = sizeof(struct stat_block); mac_control->stats_mem = pci_alloc_consistent(nic->pdev, size, &mac_control->stats_mem_phy); if (!mac_control->stats_mem) { /* * In case of failure, free_shared_mem() is called, which * should free any memory that was alloced till the * failure happened. */ return -ENOMEM; } mem_allocated += size; mac_control->stats_mem_sz = size; tmp_v_addr = mac_control->stats_mem; mac_control->stats_info = tmp_v_addr; memset(tmp_v_addr, 0, size); DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n", dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr); mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; return SUCCESS; } /** * free_shared_mem - Free the allocated Memory * @nic: Device private variable. * Description: This function is to free all memory locations allocated by * the init_shared_mem() function and return it to the kernel. */ static void free_shared_mem(struct s2io_nic *nic) { int i, j, blk_cnt, size; void *tmp_v_addr; dma_addr_t tmp_p_addr; int lst_size, lst_per_page; struct net_device *dev; int page_num = 0; struct config_param *config; struct mac_info *mac_control; struct stat_block *stats; struct swStat *swstats; if (!nic) return; dev = nic->dev; config = &nic->config; mac_control = &nic->mac_control; stats = mac_control->stats_info; swstats = &stats->sw_stat; lst_size = sizeof(struct TxD) * config->max_txds; lst_per_page = PAGE_SIZE / lst_size; for (i = 0; i < config->tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; page_num = TXD_MEM_PAGE_CNT(tx_cfg->fifo_len, lst_per_page); for (j = 0; j < page_num; j++) { int mem_blks = (j * lst_per_page); struct list_info_hold *fli; if (!fifo->list_info) return; fli = &fifo->list_info[mem_blks]; if (!fli->list_virt_addr) break; pci_free_consistent(nic->pdev, PAGE_SIZE, fli->list_virt_addr, fli->list_phy_addr); swstats->mem_freed += PAGE_SIZE; } /* If we got a zero DMA address during allocation, * free the page now */ if (mac_control->zerodma_virt_addr) { pci_free_consistent(nic->pdev, PAGE_SIZE, mac_control->zerodma_virt_addr, (dma_addr_t)0); DBG_PRINT(INIT_DBG, "%s: Freeing TxDL with zero DMA address. " "Virtual address %p\n", dev->name, mac_control->zerodma_virt_addr); swstats->mem_freed += PAGE_SIZE; } kfree(fifo->list_info); swstats->mem_freed += tx_cfg->fifo_len * sizeof(struct list_info_hold); } size = SIZE_OF_BLOCK; for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; blk_cnt = ring->block_count; for (j = 0; j < blk_cnt; j++) { tmp_v_addr = ring->rx_blocks[j].block_virt_addr; tmp_p_addr = ring->rx_blocks[j].block_dma_addr; if (tmp_v_addr == NULL) break; pci_free_consistent(nic->pdev, size, tmp_v_addr, tmp_p_addr); swstats->mem_freed += size; kfree(ring->rx_blocks[j].rxds); swstats->mem_freed += sizeof(struct rxd_info) * rxd_count[nic->rxd_mode]; } } if (nic->rxd_mode == RXD_MODE_3B) { /* Freeing buffer storage addresses in 2BUFF mode. */ for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; blk_cnt = rx_cfg->num_rxd / (rxd_count[nic->rxd_mode] + 1); for (j = 0; j < blk_cnt; j++) { int k = 0; if (!ring->ba[j]) continue; while (k != rxd_count[nic->rxd_mode]) { struct buffAdd *ba = &ring->ba[j][k]; kfree(ba->ba_0_org); swstats->mem_freed += BUF0_LEN + ALIGN_SIZE; kfree(ba->ba_1_org); swstats->mem_freed += BUF1_LEN + ALIGN_SIZE; k++; } kfree(ring->ba[j]); swstats->mem_freed += sizeof(struct buffAdd) * (rxd_count[nic->rxd_mode] + 1); } kfree(ring->ba); swstats->mem_freed += sizeof(struct buffAdd *) * blk_cnt; } } for (i = 0; i < nic->config.tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; if (fifo->ufo_in_band_v) { swstats->mem_freed += tx_cfg->fifo_len * sizeof(u64); kfree(fifo->ufo_in_band_v); } } if (mac_control->stats_mem) { swstats->mem_freed += mac_control->stats_mem_sz; pci_free_consistent(nic->pdev, mac_control->stats_mem_sz, mac_control->stats_mem, mac_control->stats_mem_phy); } } /** * s2io_verify_pci_mode - */ static int s2io_verify_pci_mode(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; int mode; val64 = readq(&bar0->pci_mode); mode = (u8)GET_PCI_MODE(val64); if (val64 & PCI_MODE_UNKNOWN_MODE) return -1; /* Unknown PCI mode */ return mode; } #define NEC_VENID 0x1033 #define NEC_DEVID 0x0125 static int s2io_on_nec_bridge(struct pci_dev *s2io_pdev) { struct pci_dev *tdev = NULL; while ((tdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, tdev)) != NULL) { if (tdev->vendor == NEC_VENID && tdev->device == NEC_DEVID) { if (tdev->bus == s2io_pdev->bus->parent) { pci_dev_put(tdev); return 1; } } } return 0; } static int bus_speed[8] = {33, 133, 133, 200, 266, 133, 200, 266}; /** * s2io_print_pci_mode - */ static int s2io_print_pci_mode(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; int mode; struct config_param *config = &nic->config; const char *pcimode; val64 = readq(&bar0->pci_mode); mode = (u8)GET_PCI_MODE(val64); if (val64 & PCI_MODE_UNKNOWN_MODE) return -1; /* Unknown PCI mode */ config->bus_speed = bus_speed[mode]; if (s2io_on_nec_bridge(nic->pdev)) { DBG_PRINT(ERR_DBG, "%s: Device is on PCI-E bus\n", nic->dev->name); return mode; } switch (mode) { case PCI_MODE_PCI_33: pcimode = "33MHz PCI bus"; break; case PCI_MODE_PCI_66: pcimode = "66MHz PCI bus"; break; case PCI_MODE_PCIX_M1_66: pcimode = "66MHz PCIX(M1) bus"; break; case PCI_MODE_PCIX_M1_100: pcimode = "100MHz PCIX(M1) bus"; break; case PCI_MODE_PCIX_M1_133: pcimode = "133MHz PCIX(M1) bus"; break; case PCI_MODE_PCIX_M2_66: pcimode = "133MHz PCIX(M2) bus"; break; case PCI_MODE_PCIX_M2_100: pcimode = "200MHz PCIX(M2) bus"; break; case PCI_MODE_PCIX_M2_133: pcimode = "266MHz PCIX(M2) bus"; break; default: pcimode = "unsupported bus!"; mode = -1; } DBG_PRINT(ERR_DBG, "%s: Device is on %d bit %s\n", nic->dev->name, val64 & PCI_MODE_32_BITS ? 32 : 64, pcimode); return mode; } /** * init_tti - Initialization transmit traffic interrupt scheme * @nic: device private variable * @link: link status (UP/DOWN) used to enable/disable continuous * transmit interrupts * Description: The function configures transmit traffic interrupts * Return Value: SUCCESS on success and * '-1' on failure */ static int init_tti(struct s2io_nic *nic, int link) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; int i; struct config_param *config = &nic->config; for (i = 0; i < config->tx_fifo_num; i++) { /* * TTI Initialization. Default Tx timer gets us about * 250 interrupts per sec. Continuous interrupts are enabled * by default. */ if (nic->device_type == XFRAME_II_DEVICE) { int count = (nic->config.bus_speed * 125)/2; val64 = TTI_DATA1_MEM_TX_TIMER_VAL(count); } else val64 = TTI_DATA1_MEM_TX_TIMER_VAL(0x2078); val64 |= TTI_DATA1_MEM_TX_URNG_A(0xA) | TTI_DATA1_MEM_TX_URNG_B(0x10) | TTI_DATA1_MEM_TX_URNG_C(0x30) | TTI_DATA1_MEM_TX_TIMER_AC_EN; if (i == 0) if (use_continuous_tx_intrs && (link == LINK_UP)) val64 |= TTI_DATA1_MEM_TX_TIMER_CI_EN; writeq(val64, &bar0->tti_data1_mem); if (nic->config.intr_type == MSI_X) { val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) | TTI_DATA2_MEM_TX_UFC_B(0x100) | TTI_DATA2_MEM_TX_UFC_C(0x200) | TTI_DATA2_MEM_TX_UFC_D(0x300); } else { if ((nic->config.tx_steering_type == TX_DEFAULT_STEERING) && (config->tx_fifo_num > 1) && (i >= nic->udp_fifo_idx) && (i < (nic->udp_fifo_idx + nic->total_udp_fifos))) val64 = TTI_DATA2_MEM_TX_UFC_A(0x50) | TTI_DATA2_MEM_TX_UFC_B(0x80) | TTI_DATA2_MEM_TX_UFC_C(0x100) | TTI_DATA2_MEM_TX_UFC_D(0x120); else val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) | TTI_DATA2_MEM_TX_UFC_B(0x20) | TTI_DATA2_MEM_TX_UFC_C(0x40) | TTI_DATA2_MEM_TX_UFC_D(0x80); } writeq(val64, &bar0->tti_data2_mem); val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD | TTI_CMD_MEM_OFFSET(i); writeq(val64, &bar0->tti_command_mem); if (wait_for_cmd_complete(&bar0->tti_command_mem, TTI_CMD_MEM_STROBE_NEW_CMD, S2IO_BIT_RESET) != SUCCESS) return FAILURE; } return SUCCESS; } /** * init_nic - Initialization of hardware * @nic: device private variable * Description: The function sequentially configures every block * of the H/W from their reset values. * Return Value: SUCCESS on success and * '-1' on failure (endian settings incorrect). */ static int init_nic(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; struct net_device *dev = nic->dev; register u64 val64 = 0; void __iomem *add; u32 time; int i, j; int dtx_cnt = 0; unsigned long long mem_share; int mem_size; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; /* to set the swapper controle on the card */ if (s2io_set_swapper(nic)) { DBG_PRINT(ERR_DBG, "ERROR: Setting Swapper failed\n"); return -EIO; } /* * Herc requires EOI to be removed from reset before XGXS, so.. */ if (nic->device_type & XFRAME_II_DEVICE) { val64 = 0xA500000000ULL; writeq(val64, &bar0->sw_reset); msleep(500); val64 = readq(&bar0->sw_reset); } /* Remove XGXS from reset state */ val64 = 0; writeq(val64, &bar0->sw_reset); msleep(500); val64 = readq(&bar0->sw_reset); /* Ensure that it's safe to access registers by checking * RIC_RUNNING bit is reset. Check is valid only for XframeII. */ if (nic->device_type == XFRAME_II_DEVICE) { for (i = 0; i < 50; i++) { val64 = readq(&bar0->adapter_status); if (!(val64 & ADAPTER_STATUS_RIC_RUNNING)) break; msleep(10); } if (i == 50) return -ENODEV; } /* Enable Receiving broadcasts */ add = &bar0->mac_cfg; val64 = readq(&bar0->mac_cfg); val64 |= MAC_RMAC_BCAST_ENABLE; writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32)val64, add); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64 >> 32), (add + 4)); /* Read registers in all blocks */ val64 = readq(&bar0->mac_int_mask); val64 = readq(&bar0->mc_int_mask); val64 = readq(&bar0->xgxs_int_mask); /* Set MTU */ val64 = dev->mtu; writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len); if (nic->device_type & XFRAME_II_DEVICE) { while (herc_act_dtx_cfg[dtx_cnt] != END_SIGN) { SPECIAL_REG_WRITE(herc_act_dtx_cfg[dtx_cnt], &bar0->dtx_control, UF); if (dtx_cnt & 0x1) msleep(1); /* Necessary!! */ dtx_cnt++; } } else { while (xena_dtx_cfg[dtx_cnt] != END_SIGN) { SPECIAL_REG_WRITE(xena_dtx_cfg[dtx_cnt], &bar0->dtx_control, UF); val64 = readq(&bar0->dtx_control); dtx_cnt++; } } /* Tx DMA Initialization */ val64 = 0; writeq(val64, &bar0->tx_fifo_partition_0); writeq(val64, &bar0->tx_fifo_partition_1); writeq(val64, &bar0->tx_fifo_partition_2); writeq(val64, &bar0->tx_fifo_partition_3); for (i = 0, j = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; val64 |= vBIT(tx_cfg->fifo_len - 1, ((j * 32) + 19), 13) | vBIT(tx_cfg->fifo_priority, ((j * 32) + 5), 3); if (i == (config->tx_fifo_num - 1)) { if (i % 2 == 0) i++; } switch (i) { case 1: writeq(val64, &bar0->tx_fifo_partition_0); val64 = 0; j = 0; break; case 3: writeq(val64, &bar0->tx_fifo_partition_1); val64 = 0; j = 0; break; case 5: writeq(val64, &bar0->tx_fifo_partition_2); val64 = 0; j = 0; break; case 7: writeq(val64, &bar0->tx_fifo_partition_3); val64 = 0; j = 0; break; default: j++; break; } } /* * Disable 4 PCCs for Xena1, 2 and 3 as per H/W bug * SXE-008 TRANSMIT DMA ARBITRATION ISSUE. */ if ((nic->device_type == XFRAME_I_DEVICE) && (nic->pdev->revision < 4)) writeq(PCC_ENABLE_FOUR, &bar0->pcc_enable); val64 = readq(&bar0->tx_fifo_partition_0); DBG_PRINT(INIT_DBG, "Fifo partition at: 0x%p is: 0x%llx\n", &bar0->tx_fifo_partition_0, (unsigned long long)val64); /* * Initialization of Tx_PA_CONFIG register to ignore packet * integrity checking. */ val64 = readq(&bar0->tx_pa_cfg); val64 |= TX_PA_CFG_IGNORE_FRM_ERR | TX_PA_CFG_IGNORE_SNAP_OUI | TX_PA_CFG_IGNORE_LLC_CTRL | TX_PA_CFG_IGNORE_L2_ERR; writeq(val64, &bar0->tx_pa_cfg); /* Rx DMA intialization. */ val64 = 0; for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; val64 |= vBIT(rx_cfg->ring_priority, (5 + (i * 8)), 3); } writeq(val64, &bar0->rx_queue_priority); /* * Allocating equal share of memory to all the * configured Rings. */ val64 = 0; if (nic->device_type & XFRAME_II_DEVICE) mem_size = 32; else mem_size = 64; for (i = 0; i < config->rx_ring_num; i++) { switch (i) { case 0: mem_share = (mem_size / config->rx_ring_num + mem_size % config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q0_SZ(mem_share); continue; case 1: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q1_SZ(mem_share); continue; case 2: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q2_SZ(mem_share); continue; case 3: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q3_SZ(mem_share); continue; case 4: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q4_SZ(mem_share); continue; case 5: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q5_SZ(mem_share); continue; case 6: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q6_SZ(mem_share); continue; case 7: mem_share = (mem_size / config->rx_ring_num); val64 |= RX_QUEUE_CFG_Q7_SZ(mem_share); continue; } } writeq(val64, &bar0->rx_queue_cfg); /* * Filling Tx round robin registers * as per the number of FIFOs for equal scheduling priority */ switch (config->tx_fifo_num) { case 1: val64 = 0x0; writeq(val64, &bar0->tx_w_round_robin_0); writeq(val64, &bar0->tx_w_round_robin_1); writeq(val64, &bar0->tx_w_round_robin_2); writeq(val64, &bar0->tx_w_round_robin_3); writeq(val64, &bar0->tx_w_round_robin_4); break; case 2: val64 = 0x0001000100010001ULL; writeq(val64, &bar0->tx_w_round_robin_0); writeq(val64, &bar0->tx_w_round_robin_1); writeq(val64, &bar0->tx_w_round_robin_2); writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0001000100000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 3: val64 = 0x0001020001020001ULL; writeq(val64, &bar0->tx_w_round_robin_0); val64 = 0x0200010200010200ULL; writeq(val64, &bar0->tx_w_round_robin_1); val64 = 0x0102000102000102ULL; writeq(val64, &bar0->tx_w_round_robin_2); val64 = 0x0001020001020001ULL; writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0200010200000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 4: val64 = 0x0001020300010203ULL; writeq(val64, &bar0->tx_w_round_robin_0); writeq(val64, &bar0->tx_w_round_robin_1); writeq(val64, &bar0->tx_w_round_robin_2); writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0001020300000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 5: val64 = 0x0001020304000102ULL; writeq(val64, &bar0->tx_w_round_robin_0); val64 = 0x0304000102030400ULL; writeq(val64, &bar0->tx_w_round_robin_1); val64 = 0x0102030400010203ULL; writeq(val64, &bar0->tx_w_round_robin_2); val64 = 0x0400010203040001ULL; writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0203040000000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 6: val64 = 0x0001020304050001ULL; writeq(val64, &bar0->tx_w_round_robin_0); val64 = 0x0203040500010203ULL; writeq(val64, &bar0->tx_w_round_robin_1); val64 = 0x0405000102030405ULL; writeq(val64, &bar0->tx_w_round_robin_2); val64 = 0x0001020304050001ULL; writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0203040500000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 7: val64 = 0x0001020304050600ULL; writeq(val64, &bar0->tx_w_round_robin_0); val64 = 0x0102030405060001ULL; writeq(val64, &bar0->tx_w_round_robin_1); val64 = 0x0203040506000102ULL; writeq(val64, &bar0->tx_w_round_robin_2); val64 = 0x0304050600010203ULL; writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0405060000000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; case 8: val64 = 0x0001020304050607ULL; writeq(val64, &bar0->tx_w_round_robin_0); writeq(val64, &bar0->tx_w_round_robin_1); writeq(val64, &bar0->tx_w_round_robin_2); writeq(val64, &bar0->tx_w_round_robin_3); val64 = 0x0001020300000000ULL; writeq(val64, &bar0->tx_w_round_robin_4); break; } /* Enable all configured Tx FIFO partitions */ val64 = readq(&bar0->tx_fifo_partition_0); val64 |= (TX_FIFO_PARTITION_EN); writeq(val64, &bar0->tx_fifo_partition_0); /* Filling the Rx round robin registers as per the * number of Rings and steering based on QoS with * equal priority. */ switch (config->rx_ring_num) { case 1: val64 = 0x0; writeq(val64, &bar0->rx_w_round_robin_0); writeq(val64, &bar0->rx_w_round_robin_1); writeq(val64, &bar0->rx_w_round_robin_2); writeq(val64, &bar0->rx_w_round_robin_3); writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080808080808080ULL; writeq(val64, &bar0->rts_qos_steering); break; case 2: val64 = 0x0001000100010001ULL; writeq(val64, &bar0->rx_w_round_robin_0); writeq(val64, &bar0->rx_w_round_robin_1); writeq(val64, &bar0->rx_w_round_robin_2); writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0001000100000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080808040404040ULL; writeq(val64, &bar0->rts_qos_steering); break; case 3: val64 = 0x0001020001020001ULL; writeq(val64, &bar0->rx_w_round_robin_0); val64 = 0x0200010200010200ULL; writeq(val64, &bar0->rx_w_round_robin_1); val64 = 0x0102000102000102ULL; writeq(val64, &bar0->rx_w_round_robin_2); val64 = 0x0001020001020001ULL; writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0200010200000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080804040402020ULL; writeq(val64, &bar0->rts_qos_steering); break; case 4: val64 = 0x0001020300010203ULL; writeq(val64, &bar0->rx_w_round_robin_0); writeq(val64, &bar0->rx_w_round_robin_1); writeq(val64, &bar0->rx_w_round_robin_2); writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0001020300000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080404020201010ULL; writeq(val64, &bar0->rts_qos_steering); break; case 5: val64 = 0x0001020304000102ULL; writeq(val64, &bar0->rx_w_round_robin_0); val64 = 0x0304000102030400ULL; writeq(val64, &bar0->rx_w_round_robin_1); val64 = 0x0102030400010203ULL; writeq(val64, &bar0->rx_w_round_robin_2); val64 = 0x0400010203040001ULL; writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0203040000000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080404020201008ULL; writeq(val64, &bar0->rts_qos_steering); break; case 6: val64 = 0x0001020304050001ULL; writeq(val64, &bar0->rx_w_round_robin_0); val64 = 0x0203040500010203ULL; writeq(val64, &bar0->rx_w_round_robin_1); val64 = 0x0405000102030405ULL; writeq(val64, &bar0->rx_w_round_robin_2); val64 = 0x0001020304050001ULL; writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0203040500000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080404020100804ULL; writeq(val64, &bar0->rts_qos_steering); break; case 7: val64 = 0x0001020304050600ULL; writeq(val64, &bar0->rx_w_round_robin_0); val64 = 0x0102030405060001ULL; writeq(val64, &bar0->rx_w_round_robin_1); val64 = 0x0203040506000102ULL; writeq(val64, &bar0->rx_w_round_robin_2); val64 = 0x0304050600010203ULL; writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0405060000000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8080402010080402ULL; writeq(val64, &bar0->rts_qos_steering); break; case 8: val64 = 0x0001020304050607ULL; writeq(val64, &bar0->rx_w_round_robin_0); writeq(val64, &bar0->rx_w_round_robin_1); writeq(val64, &bar0->rx_w_round_robin_2); writeq(val64, &bar0->rx_w_round_robin_3); val64 = 0x0001020300000000ULL; writeq(val64, &bar0->rx_w_round_robin_4); val64 = 0x8040201008040201ULL; writeq(val64, &bar0->rts_qos_steering); break; } /* UDP Fix */ val64 = 0; for (i = 0; i < 8; i++) writeq(val64, &bar0->rts_frm_len_n[i]); /* Set the default rts frame length for the rings configured */ val64 = MAC_RTS_FRM_LEN_SET(dev->mtu+22); for (i = 0 ; i < config->rx_ring_num ; i++) writeq(val64, &bar0->rts_frm_len_n[i]); /* Set the frame length for the configured rings * desired by the user */ for (i = 0; i < config->rx_ring_num; i++) { /* If rts_frm_len[i] == 0 then it is assumed that user not * specified frame length steering. * If the user provides the frame length then program * the rts_frm_len register for those values or else * leave it as it is. */ if (rts_frm_len[i] != 0) { writeq(MAC_RTS_FRM_LEN_SET(rts_frm_len[i]), &bar0->rts_frm_len_n[i]); } } /* Disable differentiated services steering logic */ for (i = 0; i < 64; i++) { if (rts_ds_steer(nic, i, 0) == FAILURE) { DBG_PRINT(ERR_DBG, "%s: rts_ds_steer failed on codepoint %d\n", dev->name, i); return -ENODEV; } } /* Program statistics memory */ writeq(mac_control->stats_mem_phy, &bar0->stat_addr); if (nic->device_type == XFRAME_II_DEVICE) { val64 = STAT_BC(0x320); writeq(val64, &bar0->stat_byte_cnt); } /* * Initializing the sampling rate for the device to calculate the * bandwidth utilization. */ val64 = MAC_TX_LINK_UTIL_VAL(tmac_util_period) | MAC_RX_LINK_UTIL_VAL(rmac_util_period); writeq(val64, &bar0->mac_link_util); /* * Initializing the Transmit and Receive Traffic Interrupt * Scheme. */ /* Initialize TTI */ if (SUCCESS != init_tti(nic, nic->last_link_state)) return -ENODEV; /* RTI Initialization */ if (nic->device_type == XFRAME_II_DEVICE) { /* * Programmed to generate Apprx 500 Intrs per * second */ int count = (nic->config.bus_speed * 125)/4; val64 = RTI_DATA1_MEM_RX_TIMER_VAL(count); } else val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF); val64 |= RTI_DATA1_MEM_RX_URNG_A(0xA) | RTI_DATA1_MEM_RX_URNG_B(0x10) | RTI_DATA1_MEM_RX_URNG_C(0x30) | RTI_DATA1_MEM_RX_TIMER_AC_EN; writeq(val64, &bar0->rti_data1_mem); val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) | RTI_DATA2_MEM_RX_UFC_B(0x2) ; if (nic->config.intr_type == MSI_X) val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | RTI_DATA2_MEM_RX_UFC_D(0x40)); else val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80)); writeq(val64, &bar0->rti_data2_mem); for (i = 0; i < config->rx_ring_num; i++) { val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD | RTI_CMD_MEM_OFFSET(i); writeq(val64, &bar0->rti_command_mem); /* * Once the operation completes, the Strobe bit of the * command register will be reset. We poll for this * particular condition. We wait for a maximum of 500ms * for the operation to complete, if it's not complete * by then we return error. */ time = 0; while (true) { val64 = readq(&bar0->rti_command_mem); if (!(val64 & RTI_CMD_MEM_STROBE_NEW_CMD)) break; if (time > 10) { DBG_PRINT(ERR_DBG, "%s: RTI init failed\n", dev->name); return -ENODEV; } time++; msleep(50); } } /* * Initializing proper values as Pause threshold into all * the 8 Queues on Rx side. */ writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q0q3); writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q4q7); /* Disable RMAC PAD STRIPPING */ add = &bar0->mac_cfg; val64 = readq(&bar0->mac_cfg); val64 &= ~(MAC_CFG_RMAC_STRIP_PAD); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64), add); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64 >> 32), (add + 4)); val64 = readq(&bar0->mac_cfg); /* Enable FCS stripping by adapter */ add = &bar0->mac_cfg; val64 = readq(&bar0->mac_cfg); val64 |= MAC_CFG_RMAC_STRIP_FCS; if (nic->device_type == XFRAME_II_DEVICE) writeq(val64, &bar0->mac_cfg); else { writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64), add); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64 >> 32), (add + 4)); } /* * Set the time value to be inserted in the pause frame * generated by xena. */ val64 = readq(&bar0->rmac_pause_cfg); val64 &= ~(RMAC_PAUSE_HG_PTIME(0xffff)); val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time); writeq(val64, &bar0->rmac_pause_cfg); /* * Set the Threshold Limit for Generating the pause frame * If the amount of data in any Queue exceeds ratio of * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256 * pause frame is generated */ val64 = 0; for (i = 0; i < 4; i++) { val64 |= (((u64)0xFF00 | nic->mac_control.mc_pause_threshold_q0q3) << (i * 2 * 8)); } writeq(val64, &bar0->mc_pause_thresh_q0q3); val64 = 0; for (i = 0; i < 4; i++) { val64 |= (((u64)0xFF00 | nic->mac_control.mc_pause_threshold_q4q7) << (i * 2 * 8)); } writeq(val64, &bar0->mc_pause_thresh_q4q7); /* * TxDMA will stop Read request if the number of read split has * exceeded the limit pointed by shared_splits */ val64 = readq(&bar0->pic_control); val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits); writeq(val64, &bar0->pic_control); if (nic->config.bus_speed == 266) { writeq(TXREQTO_VAL(0x7f) | TXREQTO_EN, &bar0->txreqtimeout); writeq(0x0, &bar0->read_retry_delay); writeq(0x0, &bar0->write_retry_delay); } /* * Programming the Herc to split every write transaction * that does not start on an ADB to reduce disconnects. */ if (nic->device_type == XFRAME_II_DEVICE) { val64 = FAULT_BEHAVIOUR | EXT_REQ_EN | MISC_LINK_STABILITY_PRD(3); writeq(val64, &bar0->misc_control); val64 = readq(&bar0->pic_control2); val64 &= ~(s2BIT(13)|s2BIT(14)|s2BIT(15)); writeq(val64, &bar0->pic_control2); } if (strstr(nic->product_name, "CX4")) { val64 = TMAC_AVG_IPG(0x17); writeq(val64, &bar0->tmac_avg_ipg); } return SUCCESS; } #define LINK_UP_DOWN_INTERRUPT 1 #define MAC_RMAC_ERR_TIMER 2 static int s2io_link_fault_indication(struct s2io_nic *nic) { if (nic->device_type == XFRAME_II_DEVICE) return LINK_UP_DOWN_INTERRUPT; else return MAC_RMAC_ERR_TIMER; } /** * do_s2io_write_bits - update alarm bits in alarm register * @value: alarm bits * @flag: interrupt status * @addr: address value * Description: update alarm bits in alarm register * Return Value: * NONE. */ static void do_s2io_write_bits(u64 value, int flag, void __iomem *addr) { u64 temp64; temp64 = readq(addr); if (flag == ENABLE_INTRS) temp64 &= ~((u64)value); else temp64 |= ((u64)value); writeq(temp64, addr); } static void en_dis_err_alarms(struct s2io_nic *nic, u16 mask, int flag) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 gen_int_mask = 0; u64 interruptible; writeq(DISABLE_ALL_INTRS, &bar0->general_int_mask); if (mask & TX_DMA_INTR) { gen_int_mask |= TXDMA_INT_M; do_s2io_write_bits(TXDMA_TDA_INT | TXDMA_PFC_INT | TXDMA_PCC_INT | TXDMA_TTI_INT | TXDMA_LSO_INT | TXDMA_TPA_INT | TXDMA_SM_INT, flag, &bar0->txdma_int_mask); do_s2io_write_bits(PFC_ECC_DB_ERR | PFC_SM_ERR_ALARM | PFC_MISC_0_ERR | PFC_MISC_1_ERR | PFC_PCIX_ERR | PFC_ECC_SG_ERR, flag, &bar0->pfc_err_mask); do_s2io_write_bits(TDA_Fn_ECC_DB_ERR | TDA_SM0_ERR_ALARM | TDA_SM1_ERR_ALARM | TDA_Fn_ECC_SG_ERR | TDA_PCIX_ERR, flag, &bar0->tda_err_mask); do_s2io_write_bits(PCC_FB_ECC_DB_ERR | PCC_TXB_ECC_DB_ERR | PCC_SM_ERR_ALARM | PCC_WR_ERR_ALARM | PCC_N_SERR | PCC_6_COF_OV_ERR | PCC_7_COF_OV_ERR | PCC_6_LSO_OV_ERR | PCC_7_LSO_OV_ERR | PCC_FB_ECC_SG_ERR | PCC_TXB_ECC_SG_ERR, flag, &bar0->pcc_err_mask); do_s2io_write_bits(TTI_SM_ERR_ALARM | TTI_ECC_SG_ERR | TTI_ECC_DB_ERR, flag, &bar0->tti_err_mask); do_s2io_write_bits(LSO6_ABORT | LSO7_ABORT | LSO6_SM_ERR_ALARM | LSO7_SM_ERR_ALARM | LSO6_SEND_OFLOW | LSO7_SEND_OFLOW, flag, &bar0->lso_err_mask); do_s2io_write_bits(TPA_SM_ERR_ALARM | TPA_TX_FRM_DROP, flag, &bar0->tpa_err_mask); do_s2io_write_bits(SM_SM_ERR_ALARM, flag, &bar0->sm_err_mask); } if (mask & TX_MAC_INTR) { gen_int_mask |= TXMAC_INT_M; do_s2io_write_bits(MAC_INT_STATUS_TMAC_INT, flag, &bar0->mac_int_mask); do_s2io_write_bits(TMAC_TX_BUF_OVRN | TMAC_TX_SM_ERR | TMAC_ECC_SG_ERR | TMAC_ECC_DB_ERR | TMAC_DESC_ECC_SG_ERR | TMAC_DESC_ECC_DB_ERR, flag, &bar0->mac_tmac_err_mask); } if (mask & TX_XGXS_INTR) { gen_int_mask |= TXXGXS_INT_M; do_s2io_write_bits(XGXS_INT_STATUS_TXGXS, flag, &bar0->xgxs_int_mask); do_s2io_write_bits(TXGXS_ESTORE_UFLOW | TXGXS_TX_SM_ERR | TXGXS_ECC_SG_ERR | TXGXS_ECC_DB_ERR, flag, &bar0->xgxs_txgxs_err_mask); } if (mask & RX_DMA_INTR) { gen_int_mask |= RXDMA_INT_M; do_s2io_write_bits(RXDMA_INT_RC_INT_M | RXDMA_INT_RPA_INT_M | RXDMA_INT_RDA_INT_M | RXDMA_INT_RTI_INT_M, flag, &bar0->rxdma_int_mask); do_s2io_write_bits(RC_PRCn_ECC_DB_ERR | RC_FTC_ECC_DB_ERR | RC_PRCn_SM_ERR_ALARM | RC_FTC_SM_ERR_ALARM | RC_PRCn_ECC_SG_ERR | RC_FTC_ECC_SG_ERR | RC_RDA_FAIL_WR_Rn, flag, &bar0->rc_err_mask); do_s2io_write_bits(PRC_PCI_AB_RD_Rn | PRC_PCI_AB_WR_Rn | PRC_PCI_AB_F_WR_Rn | PRC_PCI_DP_RD_Rn | PRC_PCI_DP_WR_Rn | PRC_PCI_DP_F_WR_Rn, flag, &bar0->prc_pcix_err_mask); do_s2io_write_bits(RPA_SM_ERR_ALARM | RPA_CREDIT_ERR | RPA_ECC_SG_ERR | RPA_ECC_DB_ERR, flag, &bar0->rpa_err_mask); do_s2io_write_bits(RDA_RXDn_ECC_DB_ERR | RDA_FRM_ECC_DB_N_AERR | RDA_SM1_ERR_ALARM | RDA_SM0_ERR_ALARM | RDA_RXD_ECC_DB_SERR | RDA_RXDn_ECC_SG_ERR | RDA_FRM_ECC_SG_ERR | RDA_MISC_ERR|RDA_PCIX_ERR, flag, &bar0->rda_err_mask); do_s2io_write_bits(RTI_SM_ERR_ALARM | RTI_ECC_SG_ERR | RTI_ECC_DB_ERR, flag, &bar0->rti_err_mask); } if (mask & RX_MAC_INTR) { gen_int_mask |= RXMAC_INT_M; do_s2io_write_bits(MAC_INT_STATUS_RMAC_INT, flag, &bar0->mac_int_mask); interruptible = (RMAC_RX_BUFF_OVRN | RMAC_RX_SM_ERR | RMAC_UNUSED_INT | RMAC_SINGLE_ECC_ERR | RMAC_DOUBLE_ECC_ERR); if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) interruptible |= RMAC_LINK_STATE_CHANGE_INT; do_s2io_write_bits(interruptible, flag, &bar0->mac_rmac_err_mask); } if (mask & RX_XGXS_INTR) { gen_int_mask |= RXXGXS_INT_M; do_s2io_write_bits(XGXS_INT_STATUS_RXGXS, flag, &bar0->xgxs_int_mask); do_s2io_write_bits(RXGXS_ESTORE_OFLOW | RXGXS_RX_SM_ERR, flag, &bar0->xgxs_rxgxs_err_mask); } if (mask & MC_INTR) { gen_int_mask |= MC_INT_M; do_s2io_write_bits(MC_INT_MASK_MC_INT, flag, &bar0->mc_int_mask); do_s2io_write_bits(MC_ERR_REG_SM_ERR | MC_ERR_REG_ECC_ALL_SNG | MC_ERR_REG_ECC_ALL_DBL | PLL_LOCK_N, flag, &bar0->mc_err_mask); } nic->general_int_mask = gen_int_mask; /* Remove this line when alarm interrupts are enabled */ nic->general_int_mask = 0; } /** * en_dis_able_nic_intrs - Enable or Disable the interrupts * @nic: device private variable, * @mask: A mask indicating which Intr block must be modified and, * @flag: A flag indicating whether to enable or disable the Intrs. * Description: This function will either disable or enable the interrupts * depending on the flag argument. The mask argument can be used to * enable/disable any Intr block. * Return Value: NONE. */ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 temp64 = 0, intr_mask = 0; intr_mask = nic->general_int_mask; /* Top level interrupt classification */ /* PIC Interrupts */ if (mask & TX_PIC_INTR) { /* Enable PIC Intrs in the general intr mask register */ intr_mask |= TXPIC_INT_M; if (flag == ENABLE_INTRS) { /* * If Hercules adapter enable GPIO otherwise * disable all PCIX, Flash, MDIO, IIC and GPIO * interrupts for now. * TODO */ if (s2io_link_fault_indication(nic) == LINK_UP_DOWN_INTERRUPT) { do_s2io_write_bits(PIC_INT_GPIO, flag, &bar0->pic_int_mask); do_s2io_write_bits(GPIO_INT_MASK_LINK_UP, flag, &bar0->gpio_int_mask); } else writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask); } else if (flag == DISABLE_INTRS) { /* * Disable PIC Intrs in the general * intr mask register */ writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask); } } /* Tx traffic interrupts */ if (mask & TX_TRAFFIC_INTR) { intr_mask |= TXTRAFFIC_INT_M; if (flag == ENABLE_INTRS) { /* * Enable all the Tx side interrupts * writing 0 Enables all 64 TX interrupt levels */ writeq(0x0, &bar0->tx_traffic_mask); } else if (flag == DISABLE_INTRS) { /* * Disable Tx Traffic Intrs in the general intr mask * register. */ writeq(DISABLE_ALL_INTRS, &bar0->tx_traffic_mask); } } /* Rx traffic interrupts */ if (mask & RX_TRAFFIC_INTR) { intr_mask |= RXTRAFFIC_INT_M; if (flag == ENABLE_INTRS) { /* writing 0 Enables all 8 RX interrupt levels */ writeq(0x0, &bar0->rx_traffic_mask); } else if (flag == DISABLE_INTRS) { /* * Disable Rx Traffic Intrs in the general intr mask * register. */ writeq(DISABLE_ALL_INTRS, &bar0->rx_traffic_mask); } } temp64 = readq(&bar0->general_int_mask); if (flag == ENABLE_INTRS) temp64 &= ~((u64)intr_mask); else temp64 = DISABLE_ALL_INTRS; writeq(temp64, &bar0->general_int_mask); nic->general_int_mask = readq(&bar0->general_int_mask); } /** * verify_pcc_quiescent- Checks for PCC quiescent state * Return: 1 If PCC is quiescence * 0 If PCC is not quiescence */ static int verify_pcc_quiescent(struct s2io_nic *sp, int flag) { int ret = 0, herc; struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64 = readq(&bar0->adapter_status); herc = (sp->device_type == XFRAME_II_DEVICE); if (flag == false) { if ((!herc && (sp->pdev->revision >= 4)) || herc) { if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE)) ret = 1; } else { if (!(val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE)) ret = 1; } } else { if ((!herc && (sp->pdev->revision >= 4)) || herc) { if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) == ADAPTER_STATUS_RMAC_PCC_IDLE)) ret = 1; } else { if (((val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) == ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE)) ret = 1; } } return ret; } /** * verify_xena_quiescence - Checks whether the H/W is ready * Description: Returns whether the H/W is ready to go or not. Depending * on whether adapter enable bit was written or not the comparison * differs and the calling function passes the input argument flag to * indicate this. * Return: 1 If xena is quiescence * 0 If Xena is not quiescence */ static int verify_xena_quiescence(struct s2io_nic *sp) { int mode; struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64 = readq(&bar0->adapter_status); mode = s2io_verify_pci_mode(sp); if (!(val64 & ADAPTER_STATUS_TDMA_READY)) { DBG_PRINT(ERR_DBG, "TDMA is not ready!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_RDMA_READY)) { DBG_PRINT(ERR_DBG, "RDMA is not ready!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_PFC_READY)) { DBG_PRINT(ERR_DBG, "PFC is not ready!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_TMAC_BUF_EMPTY)) { DBG_PRINT(ERR_DBG, "TMAC BUF is not empty!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_PIC_QUIESCENT)) { DBG_PRINT(ERR_DBG, "PIC is not QUIESCENT!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_MC_DRAM_READY)) { DBG_PRINT(ERR_DBG, "MC_DRAM is not ready!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_MC_QUEUES_READY)) { DBG_PRINT(ERR_DBG, "MC_QUEUES is not ready!\n"); return 0; } if (!(val64 & ADAPTER_STATUS_M_PLL_LOCK)) { DBG_PRINT(ERR_DBG, "M_PLL is not locked!\n"); return 0; } /* * In PCI 33 mode, the P_PLL is not used, and therefore, * the the P_PLL_LOCK bit in the adapter_status register will * not be asserted. */ if (!(val64 & ADAPTER_STATUS_P_PLL_LOCK) && sp->device_type == XFRAME_II_DEVICE && mode != PCI_MODE_PCI_33) { DBG_PRINT(ERR_DBG, "P_PLL is not locked!\n"); return 0; } if (!((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) == ADAPTER_STATUS_RC_PRC_QUIESCENT)) { DBG_PRINT(ERR_DBG, "RC_PRC is not QUIESCENT!\n"); return 0; } return 1; } /** * fix_mac_address - Fix for Mac addr problem on Alpha platforms * @sp: Pointer to device specifc structure * Description : * New procedure to clear mac address reading problems on Alpha platforms * */ static void fix_mac_address(struct s2io_nic *sp) { struct XENA_dev_config __iomem *bar0 = sp->bar0; int i = 0; while (fix_mac[i] != END_SIGN) { writeq(fix_mac[i++], &bar0->gpio_control); udelay(10); (void) readq(&bar0->gpio_control); } } /** * start_nic - Turns the device on * @nic : device private variable. * Description: * This function actually turns the device on. Before this function is * called,all Registers are configured from their reset states * and shared memory is allocated but the NIC is still quiescent. On * calling this function, the device interrupts are cleared and the NIC is * literally switched on by writing into the adapter control register. * Return Value: * SUCCESS on success and -1 on failure. */ static int start_nic(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; struct net_device *dev = nic->dev; register u64 val64 = 0; u16 subid, i; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; /* PRC Initialization and configuration */ for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; writeq((u64)ring->rx_blocks[0].block_dma_addr, &bar0->prc_rxd0_n[i]); val64 = readq(&bar0->prc_ctrl_n[i]); if (nic->rxd_mode == RXD_MODE_1) val64 |= PRC_CTRL_RC_ENABLED; else val64 |= PRC_CTRL_RC_ENABLED | PRC_CTRL_RING_MODE_3; if (nic->device_type == XFRAME_II_DEVICE) val64 |= PRC_CTRL_GROUP_READS; val64 &= ~PRC_CTRL_RXD_BACKOFF_INTERVAL(0xFFFFFF); val64 |= PRC_CTRL_RXD_BACKOFF_INTERVAL(0x1000); writeq(val64, &bar0->prc_ctrl_n[i]); } if (nic->rxd_mode == RXD_MODE_3B) { /* Enabling 2 buffer mode by writing into Rx_pa_cfg reg. */ val64 = readq(&bar0->rx_pa_cfg); val64 |= RX_PA_CFG_IGNORE_L2_ERR; writeq(val64, &bar0->rx_pa_cfg); } if (vlan_tag_strip == 0) { val64 = readq(&bar0->rx_pa_cfg); val64 &= ~RX_PA_CFG_STRIP_VLAN_TAG; writeq(val64, &bar0->rx_pa_cfg); nic->vlan_strip_flag = 0; } /* * Enabling MC-RLDRAM. After enabling the device, we timeout * for around 100ms, which is approximately the time required * for the device to be ready for operation. */ val64 = readq(&bar0->mc_rldram_mrs); val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE | MC_RLDRAM_MRS_ENABLE; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF); val64 = readq(&bar0->mc_rldram_mrs); msleep(100); /* Delay by around 100 ms. */ /* Enabling ECC Protection. */ val64 = readq(&bar0->adapter_control); val64 &= ~ADAPTER_ECC_EN; writeq(val64, &bar0->adapter_control); /* * Verify if the device is ready to be enabled, if so enable * it. */ val64 = readq(&bar0->adapter_status); if (!verify_xena_quiescence(nic)) { DBG_PRINT(ERR_DBG, "%s: device is not ready, " "Adapter status reads: 0x%llx\n", dev->name, (unsigned long long)val64); return FAILURE; } /* * With some switches, link might be already up at this point. * Because of this weird behavior, when we enable laser, * we may not get link. We need to handle this. We cannot * figure out which switch is misbehaving. So we are forced to * make a global change. */ /* Enabling Laser. */ val64 = readq(&bar0->adapter_control); val64 |= ADAPTER_EOI_TX_ON; writeq(val64, &bar0->adapter_control); if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) { /* * Dont see link state interrupts initially on some switches, * so directly scheduling the link state task here. */ schedule_work(&nic->set_link_task); } /* SXE-002: Initialize link and activity LED */ subid = nic->pdev->subsystem_device; if (((subid & 0xFF) >= 0x07) && (nic->device_type == XFRAME_I_DEVICE)) { val64 = readq(&bar0->gpio_control); val64 |= 0x0000800000000000ULL; writeq(val64, &bar0->gpio_control); val64 = 0x0411040400000000ULL; writeq(val64, (void __iomem *)bar0 + 0x2700); } return SUCCESS; } /** * s2io_txdl_getskb - Get the skb from txdl, unmap and return skb */ static struct sk_buff *s2io_txdl_getskb(struct fifo_info *fifo_data, struct TxD *txdlp, int get_off) { struct s2io_nic *nic = fifo_data->nic; struct sk_buff *skb; struct TxD *txds; u16 j, frg_cnt; txds = txdlp; if (txds->Host_Control == (u64)(long)fifo_data->ufo_in_band_v) { pci_unmap_single(nic->pdev, (dma_addr_t)txds->Buffer_Pointer, sizeof(u64), PCI_DMA_TODEVICE); txds++; } skb = (struct sk_buff *)((unsigned long)txds->Host_Control); if (!skb) { memset(txdlp, 0, (sizeof(struct TxD) * fifo_data->max_txds)); return NULL; } pci_unmap_single(nic->pdev, (dma_addr_t)txds->Buffer_Pointer, skb_headlen(skb), PCI_DMA_TODEVICE); frg_cnt = skb_shinfo(skb)->nr_frags; if (frg_cnt) { txds++; for (j = 0; j < frg_cnt; j++, txds++) { const skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; if (!txds->Buffer_Pointer) break; pci_unmap_page(nic->pdev, (dma_addr_t)txds->Buffer_Pointer, skb_frag_size(frag), PCI_DMA_TODEVICE); } } memset(txdlp, 0, (sizeof(struct TxD) * fifo_data->max_txds)); return skb; } /** * free_tx_buffers - Free all queued Tx buffers * @nic : device private variable. * Description: * Free all queued Tx buffers. * Return Value: void */ static void free_tx_buffers(struct s2io_nic *nic) { struct net_device *dev = nic->dev; struct sk_buff *skb; struct TxD *txdp; int i, j; int cnt = 0; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; struct stat_block *stats = mac_control->stats_info; struct swStat *swstats = &stats->sw_stat; for (i = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; struct fifo_info *fifo = &mac_control->fifos[i]; unsigned long flags; spin_lock_irqsave(&fifo->tx_lock, flags); for (j = 0; j < tx_cfg->fifo_len; j++) { txdp = fifo->list_info[j].list_virt_addr; skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); if (skb) { swstats->mem_freed += skb->truesize; dev_kfree_skb(skb); cnt++; } } DBG_PRINT(INTR_DBG, "%s: forcibly freeing %d skbs on FIFO%d\n", dev->name, cnt, i); fifo->tx_curr_get_info.offset = 0; fifo->tx_curr_put_info.offset = 0; spin_unlock_irqrestore(&fifo->tx_lock, flags); } } /** * stop_nic - To stop the nic * @nic ; device private variable. * Description: * This function does exactly the opposite of what the start_nic() * function does. This function is called to stop the device. * Return Value: * void. */ static void stop_nic(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; u16 interruptible; /* Disable all interrupts */ en_dis_err_alarms(nic, ENA_ALL_INTRS, DISABLE_INTRS); interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR; interruptible |= TX_PIC_INTR; en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS); /* Clearing Adapter_En bit of ADAPTER_CONTROL Register */ val64 = readq(&bar0->adapter_control); val64 &= ~(ADAPTER_CNTL_EN); writeq(val64, &bar0->adapter_control); } /** * fill_rx_buffers - Allocates the Rx side skbs * @ring_info: per ring structure * @from_card_up: If this is true, we will map the buffer to get * the dma address for buf0 and buf1 to give it to the card. * Else we will sync the already mapped buffer to give it to the card. * Description: * The function allocates Rx side skbs and puts the physical * address of these buffers into the RxD buffer pointers, so that the NIC * can DMA the received frame into these locations. * The NIC supports 3 receive modes, viz * 1. single buffer, * 2. three buffer and * 3. Five buffer modes. * Each mode defines how many fragments the received frame will be split * up into by the NIC. The frame is split into L3 header, L4 Header, * L4 payload in three buffer mode and in 5 buffer mode, L4 payload itself * is split into 3 fragments. As of now only single buffer mode is * supported. * Return Value: * SUCCESS on success or an appropriate -ve value on failure. */ static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring, int from_card_up) { struct sk_buff *skb; struct RxD_t *rxdp; int off, size, block_no, block_no1; u32 alloc_tab = 0; u32 alloc_cnt; u64 tmp; struct buffAdd *ba; struct RxD_t *first_rxdp = NULL; u64 Buffer0_ptr = 0, Buffer1_ptr = 0; int rxd_index = 0; struct RxD1 *rxdp1; struct RxD3 *rxdp3; struct swStat *swstats = &ring->nic->mac_control.stats_info->sw_stat; alloc_cnt = ring->pkt_cnt - ring->rx_bufs_left; block_no1 = ring->rx_curr_get_info.block_index; while (alloc_tab < alloc_cnt) { block_no = ring->rx_curr_put_info.block_index; off = ring->rx_curr_put_info.offset; rxdp = ring->rx_blocks[block_no].rxds[off].virt_addr; rxd_index = off + 1; if (block_no) rxd_index += (block_no * ring->rxd_count); if ((block_no == block_no1) && (off == ring->rx_curr_get_info.offset) && (rxdp->Host_Control)) { DBG_PRINT(INTR_DBG, "%s: Get and Put info equated\n", ring->dev->name); goto end; } if (off && (off == ring->rxd_count)) { ring->rx_curr_put_info.block_index++; if (ring->rx_curr_put_info.block_index == ring->block_count) ring->rx_curr_put_info.block_index = 0; block_no = ring->rx_curr_put_info.block_index; off = 0; ring->rx_curr_put_info.offset = off; rxdp = ring->rx_blocks[block_no].block_virt_addr; DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n", ring->dev->name, rxdp); } if ((rxdp->Control_1 & RXD_OWN_XENA) && ((ring->rxd_mode == RXD_MODE_3B) && (rxdp->Control_2 & s2BIT(0)))) { ring->rx_curr_put_info.offset = off; goto end; } /* calculate size of skb based on ring mode */ size = ring->mtu + HEADER_ETHERNET_II_802_3_SIZE + HEADER_802_2_SIZE + HEADER_SNAP_SIZE; if (ring->rxd_mode == RXD_MODE_1) size += NET_IP_ALIGN; else size = ring->mtu + ALIGN_SIZE + BUF0_LEN + 4; /* allocate skb */ skb = netdev_alloc_skb(nic->dev, size); if (!skb) { DBG_PRINT(INFO_DBG, "%s: Could not allocate skb\n", ring->dev->name); if (first_rxdp) { wmb(); first_rxdp->Control_1 |= RXD_OWN_XENA; } swstats->mem_alloc_fail_cnt++; return -ENOMEM ; } swstats->mem_allocated += skb->truesize; if (ring->rxd_mode == RXD_MODE_1) { /* 1 buffer mode - normal operation mode */ rxdp1 = (struct RxD1 *)rxdp; memset(rxdp, 0, sizeof(struct RxD1)); skb_reserve(skb, NET_IP_ALIGN); rxdp1->Buffer0_ptr = pci_map_single(ring->pdev, skb->data, size - NET_IP_ALIGN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(nic->pdev, rxdp1->Buffer0_ptr)) goto pci_map_failed; rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); rxdp->Host_Control = (unsigned long)skb; } else if (ring->rxd_mode == RXD_MODE_3B) { /* * 2 buffer mode - * 2 buffer mode provides 128 * byte aligned receive buffers. */ rxdp3 = (struct RxD3 *)rxdp; /* save buffer pointers to avoid frequent dma mapping */ Buffer0_ptr = rxdp3->Buffer0_ptr; Buffer1_ptr = rxdp3->Buffer1_ptr; memset(rxdp, 0, sizeof(struct RxD3)); /* restore the buffer pointers for dma sync*/ rxdp3->Buffer0_ptr = Buffer0_ptr; rxdp3->Buffer1_ptr = Buffer1_ptr; ba = &ring->ba[block_no][off]; skb_reserve(skb, BUF0_LEN); tmp = (u64)(unsigned long)skb->data; tmp += ALIGN_SIZE; tmp &= ~ALIGN_SIZE; skb->data = (void *) (unsigned long)tmp; skb_reset_tail_pointer(skb); if (from_card_up) { rxdp3->Buffer0_ptr = pci_map_single(ring->pdev, ba->ba_0, BUF0_LEN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(nic->pdev, rxdp3->Buffer0_ptr)) goto pci_map_failed; } else pci_dma_sync_single_for_device(ring->pdev, (dma_addr_t)rxdp3->Buffer0_ptr, BUF0_LEN, PCI_DMA_FROMDEVICE); rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); if (ring->rxd_mode == RXD_MODE_3B) { /* Two buffer mode */ /* * Buffer2 will have L3/L4 header plus * L4 payload */ rxdp3->Buffer2_ptr = pci_map_single(ring->pdev, skb->data, ring->mtu + 4, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(nic->pdev, rxdp3->Buffer2_ptr)) goto pci_map_failed; if (from_card_up) { rxdp3->Buffer1_ptr = pci_map_single(ring->pdev, ba->ba_1, BUF1_LEN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(nic->pdev, rxdp3->Buffer1_ptr)) { pci_unmap_single(ring->pdev, (dma_addr_t)(unsigned long) skb->data, ring->mtu + 4, PCI_DMA_FROMDEVICE); goto pci_map_failed; } } rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); rxdp->Control_2 |= SET_BUFFER2_SIZE_3 (ring->mtu + 4); } rxdp->Control_2 |= s2BIT(0); rxdp->Host_Control = (unsigned long) (skb); } if (alloc_tab & ((1 << rxsync_frequency) - 1)) rxdp->Control_1 |= RXD_OWN_XENA; off++; if (off == (ring->rxd_count + 1)) off = 0; ring->rx_curr_put_info.offset = off; rxdp->Control_2 |= SET_RXD_MARKER; if (!(alloc_tab & ((1 << rxsync_frequency) - 1))) { if (first_rxdp) { wmb(); first_rxdp->Control_1 |= RXD_OWN_XENA; } first_rxdp = rxdp; } ring->rx_bufs_left += 1; alloc_tab++; } end: /* Transfer ownership of first descriptor to adapter just before * exiting. Before that, use memory barrier so that ownership * and other fields are seen by adapter correctly. */ if (first_rxdp) { wmb(); first_rxdp->Control_1 |= RXD_OWN_XENA; } return SUCCESS; pci_map_failed: swstats->pci_map_fail_cnt++; swstats->mem_freed += skb->truesize; dev_kfree_skb_irq(skb); return -ENOMEM; } static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk) { struct net_device *dev = sp->dev; int j; struct sk_buff *skb; struct RxD_t *rxdp; struct RxD1 *rxdp1; struct RxD3 *rxdp3; struct mac_info *mac_control = &sp->mac_control; struct stat_block *stats = mac_control->stats_info; struct swStat *swstats = &stats->sw_stat; for (j = 0 ; j < rxd_count[sp->rxd_mode]; j++) { rxdp = mac_control->rings[ring_no]. rx_blocks[blk].rxds[j].virt_addr; skb = (struct sk_buff *)((unsigned long)rxdp->Host_Control); if (!skb) continue; if (sp->rxd_mode == RXD_MODE_1) { rxdp1 = (struct RxD1 *)rxdp; pci_unmap_single(sp->pdev, (dma_addr_t)rxdp1->Buffer0_ptr, dev->mtu + HEADER_ETHERNET_II_802_3_SIZE + HEADER_802_2_SIZE + HEADER_SNAP_SIZE, PCI_DMA_FROMDEVICE); memset(rxdp, 0, sizeof(struct RxD1)); } else if (sp->rxd_mode == RXD_MODE_3B) { rxdp3 = (struct RxD3 *)rxdp; pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer0_ptr, BUF0_LEN, PCI_DMA_FROMDEVICE); pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer1_ptr, BUF1_LEN, PCI_DMA_FROMDEVICE); pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer2_ptr, dev->mtu + 4, PCI_DMA_FROMDEVICE); memset(rxdp, 0, sizeof(struct RxD3)); } swstats->mem_freed += skb->truesize; dev_kfree_skb(skb); mac_control->rings[ring_no].rx_bufs_left -= 1; } } /** * free_rx_buffers - Frees all Rx buffers * @sp: device private variable. * Description: * This function will free all Rx buffers allocated by host. * Return Value: * NONE. */ static void free_rx_buffers(struct s2io_nic *sp) { struct net_device *dev = sp->dev; int i, blk = 0, buf_cnt = 0; struct config_param *config = &sp->config; struct mac_info *mac_control = &sp->mac_control; for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; for (blk = 0; blk < rx_ring_sz[i]; blk++) free_rxd_blk(sp, i, blk); ring->rx_curr_put_info.block_index = 0; ring->rx_curr_get_info.block_index = 0; ring->rx_curr_put_info.offset = 0; ring->rx_curr_get_info.offset = 0; ring->rx_bufs_left = 0; DBG_PRINT(INIT_DBG, "%s: Freed 0x%x Rx Buffers on ring%d\n", dev->name, buf_cnt, i); } } static int s2io_chk_rx_buffers(struct s2io_nic *nic, struct ring_info *ring) { if (fill_rx_buffers(nic, ring, 0) == -ENOMEM) { DBG_PRINT(INFO_DBG, "%s: Out of memory in Rx Intr!!\n", ring->dev->name); } return 0; } /** * s2io_poll - Rx interrupt handler for NAPI support * @napi : pointer to the napi structure. * @budget : The number of packets that were budgeted to be processed * during one pass through the 'Poll" function. * Description: * Comes into picture only if NAPI support has been incorporated. It does * the same thing that rx_intr_handler does, but not in a interrupt context * also It will process only a given number of packets. * Return value: * 0 on success and 1 if there are No Rx packets to be processed. */ static int s2io_poll_msix(struct napi_struct *napi, int budget) { struct ring_info *ring = container_of(napi, struct ring_info, napi); struct net_device *dev = ring->dev; int pkts_processed = 0; u8 __iomem *addr = NULL; u8 val8 = 0; struct s2io_nic *nic = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = nic->bar0; int budget_org = budget; if (unlikely(!is_s2io_card_up(nic))) return 0; pkts_processed = rx_intr_handler(ring, budget); s2io_chk_rx_buffers(nic, ring); if (pkts_processed < budget_org) { napi_complete(napi); /*Re Enable MSI-Rx Vector*/ addr = (u8 __iomem *)&bar0->xmsi_mask_reg; addr += 7 - ring->ring_no; val8 = (ring->ring_no == 0) ? 0x3f : 0xbf; writeb(val8, addr); val8 = readb(addr); } return pkts_processed; } static int s2io_poll_inta(struct napi_struct *napi, int budget) { struct s2io_nic *nic = container_of(napi, struct s2io_nic, napi); int pkts_processed = 0; int ring_pkts_processed, i; struct XENA_dev_config __iomem *bar0 = nic->bar0; int budget_org = budget; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; if (unlikely(!is_s2io_card_up(nic))) return 0; for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; ring_pkts_processed = rx_intr_handler(ring, budget); s2io_chk_rx_buffers(nic, ring); pkts_processed += ring_pkts_processed; budget -= ring_pkts_processed; if (budget <= 0) break; } if (pkts_processed < budget_org) { napi_complete(napi); /* Re enable the Rx interrupts for the ring */ writeq(0, &bar0->rx_traffic_mask); readl(&bar0->rx_traffic_mask); } return pkts_processed; } #ifdef CONFIG_NET_POLL_CONTROLLER /** * s2io_netpoll - netpoll event handler entry point * @dev : pointer to the device structure. * Description: * This function will be called by upper layer to check for events on the * interface in situations where interrupts are disabled. It is used for * specific in-kernel networking tasks, such as remote consoles and kernel * debugging over the network (example netdump in RedHat). */ static void s2io_netpoll(struct net_device *dev) { struct s2io_nic *nic = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = nic->bar0; u64 val64 = 0xFFFFFFFFFFFFFFFFULL; int i; struct config_param *config = &nic->config; struct mac_info *mac_control = &nic->mac_control; if (pci_channel_offline(nic->pdev)) return; disable_irq(dev->irq); writeq(val64, &bar0->rx_traffic_int); writeq(val64, &bar0->tx_traffic_int); /* we need to free up the transmitted skbufs or else netpoll will * run out of skbs and will fail and eventually netpoll application such * as netdump will fail. */ for (i = 0; i < config->tx_fifo_num; i++) tx_intr_handler(&mac_control->fifos[i]); /* check for received packet and indicate up to network */ for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; rx_intr_handler(ring, 0); } for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; if (fill_rx_buffers(nic, ring, 0) == -ENOMEM) { DBG_PRINT(INFO_DBG, "%s: Out of memory in Rx Netpoll!!\n", dev->name); break; } } enable_irq(dev->irq); } #endif /** * rx_intr_handler - Rx interrupt handler * @ring_info: per ring structure. * @budget: budget for napi processing. * Description: * If the interrupt is because of a received frame or if the * receive ring contains fresh as yet un-processed frames,this function is * called. It picks out the RxD at which place the last Rx processing had * stopped and sends the skb to the OSM's Rx handler and then increments * the offset. * Return Value: * No. of napi packets processed. */ static int rx_intr_handler(struct ring_info *ring_data, int budget) { int get_block, put_block; struct rx_curr_get_info get_info, put_info; struct RxD_t *rxdp; struct sk_buff *skb; int pkt_cnt = 0, napi_pkts = 0; int i; struct RxD1 *rxdp1; struct RxD3 *rxdp3; get_info = ring_data->rx_curr_get_info; get_block = get_info.block_index; memcpy(&put_info, &ring_data->rx_curr_put_info, sizeof(put_info)); put_block = put_info.block_index; rxdp = ring_data->rx_blocks[get_block].rxds[get_info.offset].virt_addr; while (RXD_IS_UP2DT(rxdp)) { /* * If your are next to put index then it's * FIFO full condition */ if ((get_block == put_block) && (get_info.offset + 1) == put_info.offset) { DBG_PRINT(INTR_DBG, "%s: Ring Full\n", ring_data->dev->name); break; } skb = (struct sk_buff *)((unsigned long)rxdp->Host_Control); if (skb == NULL) { DBG_PRINT(ERR_DBG, "%s: NULL skb in Rx Intr\n", ring_data->dev->name); return 0; } if (ring_data->rxd_mode == RXD_MODE_1) { rxdp1 = (struct RxD1 *)rxdp; pci_unmap_single(ring_data->pdev, (dma_addr_t) rxdp1->Buffer0_ptr, ring_data->mtu + HEADER_ETHERNET_II_802_3_SIZE + HEADER_802_2_SIZE + HEADER_SNAP_SIZE, PCI_DMA_FROMDEVICE); } else if (ring_data->rxd_mode == RXD_MODE_3B) { rxdp3 = (struct RxD3 *)rxdp; pci_dma_sync_single_for_cpu(ring_data->pdev, (dma_addr_t)rxdp3->Buffer0_ptr, BUF0_LEN, PCI_DMA_FROMDEVICE); pci_unmap_single(ring_data->pdev, (dma_addr_t)rxdp3->Buffer2_ptr, ring_data->mtu + 4, PCI_DMA_FROMDEVICE); } prefetch(skb->data); rx_osm_handler(ring_data, rxdp); get_info.offset++; ring_data->rx_curr_get_info.offset = get_info.offset; rxdp = ring_data->rx_blocks[get_block]. rxds[get_info.offset].virt_addr; if (get_info.offset == rxd_count[ring_data->rxd_mode]) { get_info.offset = 0; ring_data->rx_curr_get_info.offset = get_info.offset; get_block++; if (get_block == ring_data->block_count) get_block = 0; ring_data->rx_curr_get_info.block_index = get_block; rxdp = ring_data->rx_blocks[get_block].block_virt_addr; } if (ring_data->nic->config.napi) { budget--; napi_pkts++; if (!budget) break; } pkt_cnt++; if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts)) break; } if (ring_data->lro) { /* Clear all LRO sessions before exiting */ for (i = 0; i < MAX_LRO_SESSIONS; i++) { struct lro *lro = &ring_data->lro0_n[i]; if (lro->in_use) { update_L3L4_header(ring_data->nic, lro); queue_rx_frame(lro->parent, lro->vlan_tag); clear_lro_session(lro); } } } return napi_pkts; } /** * tx_intr_handler - Transmit interrupt handler * @nic : device private variable * Description: * If an interrupt was raised to indicate DMA complete of the * Tx packet, this function is called. It identifies the last TxD * whose buffer was freed and frees all skbs whose data have already * DMA'ed into the NICs internal memory. * Return Value: * NONE */ static void tx_intr_handler(struct fifo_info *fifo_data) { struct s2io_nic *nic = fifo_data->nic; struct tx_curr_get_info get_info, put_info; struct sk_buff *skb = NULL; struct TxD *txdlp; int pkt_cnt = 0; unsigned long flags = 0; u8 err_mask; struct stat_block *stats = nic->mac_control.stats_info; struct swStat *swstats = &stats->sw_stat; if (!spin_trylock_irqsave(&fifo_data->tx_lock, flags)) return; get_info = fifo_data->tx_curr_get_info; memcpy(&put_info, &fifo_data->tx_curr_put_info, sizeof(put_info)); txdlp = fifo_data->list_info[get_info.offset].list_virt_addr; while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) && (get_info.offset != put_info.offset) && (txdlp->Host_Control)) { /* Check for TxD errors */ if (txdlp->Control_1 & TXD_T_CODE) { unsigned long long err; err = txdlp->Control_1 & TXD_T_CODE; if (err & 0x1) { swstats->parity_err_cnt++; } /* update t_code statistics */ err_mask = err >> 48; switch (err_mask) { case 2: swstats->tx_buf_abort_cnt++; break; case 3: swstats->tx_desc_abort_cnt++; break; case 7: swstats->tx_parity_err_cnt++; break; case 10: swstats->tx_link_loss_cnt++; break; case 15: swstats->tx_list_proc_err_cnt++; break; } } skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); if (skb == NULL) { spin_unlock_irqrestore(&fifo_data->tx_lock, flags); DBG_PRINT(ERR_DBG, "%s: NULL skb in Tx Free Intr\n", __func__); return; } pkt_cnt++; /* Updating the statistics block */ swstats->mem_freed += skb->truesize; dev_kfree_skb_irq(skb); get_info.offset++; if (get_info.offset == get_info.fifo_len + 1) get_info.offset = 0; txdlp = fifo_data->list_info[get_info.offset].list_virt_addr; fifo_data->tx_curr_get_info.offset = get_info.offset; } s2io_wake_tx_queue(fifo_data, pkt_cnt, nic->config.multiq); spin_unlock_irqrestore(&fifo_data->tx_lock, flags); } /** * s2io_mdio_write - Function to write in to MDIO registers * @mmd_type : MMD type value (PMA/PMD/WIS/PCS/PHYXS) * @addr : address value * @value : data value * @dev : pointer to net_device structure * Description: * This function is used to write values to the MDIO registers * NONE */ static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device *dev) { u64 val64; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; /* address transaction */ val64 = MDIO_MMD_INDX_ADDR(addr) | MDIO_MMD_DEV_ADDR(mmd_type) | MDIO_MMS_PRT_ADDR(0x0); writeq(val64, &bar0->mdio_control); val64 = val64 | MDIO_CTRL_START_TRANS(0xE); writeq(val64, &bar0->mdio_control); udelay(100); /* Data transaction */ val64 = MDIO_MMD_INDX_ADDR(addr) | MDIO_MMD_DEV_ADDR(mmd_type) | MDIO_MMS_PRT_ADDR(0x0) | MDIO_MDIO_DATA(value) | MDIO_OP(MDIO_OP_WRITE_TRANS); writeq(val64, &bar0->mdio_control); val64 = val64 | MDIO_CTRL_START_TRANS(0xE); writeq(val64, &bar0->mdio_control); udelay(100); val64 = MDIO_MMD_INDX_ADDR(addr) | MDIO_MMD_DEV_ADDR(mmd_type) | MDIO_MMS_PRT_ADDR(0x0) | MDIO_OP(MDIO_OP_READ_TRANS); writeq(val64, &bar0->mdio_control); val64 = val64 | MDIO_CTRL_START_TRANS(0xE); writeq(val64, &bar0->mdio_control); udelay(100); } /** * s2io_mdio_read - Function to write in to MDIO registers * @mmd_type : MMD type value (PMA/PMD/WIS/PCS/PHYXS) * @addr : address value * @dev : pointer to net_device structure * Description: * This function is used to read values to the MDIO registers * NONE */ static u64 s2io_mdio_read(u32 mmd_type, u64 addr, struct net_device *dev) { u64 val64 = 0x0; u64 rval64 = 0x0; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; /* address transaction */ val64 = val64 | (MDIO_MMD_INDX_ADDR(addr) | MDIO_MMD_DEV_ADDR(mmd_type) | MDIO_MMS_PRT_ADDR(0x0)); writeq(val64, &bar0->mdio_control); val64 = val64 | MDIO_CTRL_START_TRANS(0xE); writeq(val64, &bar0->mdio_control); udelay(100); /* Data transaction */ val64 = MDIO_MMD_INDX_ADDR(addr) | MDIO_MMD_DEV_ADDR(mmd_type) | MDIO_MMS_PRT_ADDR(0x0) | MDIO_OP(MDIO_OP_READ_TRANS); writeq(val64, &bar0->mdio_control); val64 = val64 | MDIO_CTRL_START_TRANS(0xE); writeq(val64, &bar0->mdio_control); udelay(100); /* Read the value from regs */ rval64 = readq(&bar0->mdio_control); rval64 = rval64 & 0xFFFF0000; rval64 = rval64 >> 16; return rval64; } /** * s2io_chk_xpak_counter - Function to check the status of the xpak counters * @counter : counter value to be updated * @flag : flag to indicate the status * @type : counter type * Description: * This function is to check the status of the xpak counters value * NONE */ static void s2io_chk_xpak_counter(u64 *counter, u64 * regs_stat, u32 index, u16 flag, u16 type) { u64 mask = 0x3; u64 val64; int i; for (i = 0; i < index; i++) mask = mask << 0x2; if (flag > 0) { *counter = *counter + 1; val64 = *regs_stat & mask; val64 = val64 >> (index * 0x2); val64 = val64 + 1; if (val64 == 3) { switch (type) { case 1: DBG_PRINT(ERR_DBG, "Take Xframe NIC out of service.\n"); DBG_PRINT(ERR_DBG, "Excessive temperatures may result in premature transceiver failure.\n"); break; case 2: DBG_PRINT(ERR_DBG, "Take Xframe NIC out of service.\n"); DBG_PRINT(ERR_DBG, "Excessive bias currents may indicate imminent laser diode failure.\n"); break; case 3: DBG_PRINT(ERR_DBG, "Take Xframe NIC out of service.\n"); DBG_PRINT(ERR_DBG, "Excessive laser output power may saturate far-end receiver.\n"); break; default: DBG_PRINT(ERR_DBG, "Incorrect XPAK Alarm type\n"); } val64 = 0x0; } val64 = val64 << (index * 0x2); *regs_stat = (*regs_stat & (~mask)) | (val64); } else { *regs_stat = *regs_stat & (~mask); } } /** * s2io_updt_xpak_counter - Function to update the xpak counters * @dev : pointer to net_device struct * Description: * This function is to upate the status of the xpak counters value * NONE */ static void s2io_updt_xpak_counter(struct net_device *dev) { u16 flag = 0x0; u16 type = 0x0; u16 val16 = 0x0; u64 val64 = 0x0; u64 addr = 0x0; struct s2io_nic *sp = netdev_priv(dev); struct stat_block *stats = sp->mac_control.stats_info; struct xpakStat *xstats = &stats->xpak_stat; /* Check the communication with the MDIO slave */ addr = MDIO_CTRL1; val64 = 0x0; val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev); if ((val64 == 0xFFFF) || (val64 == 0x0000)) { DBG_PRINT(ERR_DBG, "ERR: MDIO slave access failed - Returned %llx\n", (unsigned long long)val64); return; } /* Check for the expected value of control reg 1 */ if (val64 != MDIO_CTRL1_SPEED10G) { DBG_PRINT(ERR_DBG, "Incorrect value at PMA address 0x0000 - " "Returned: %llx- Expected: 0x%x\n", (unsigned long long)val64, MDIO_CTRL1_SPEED10G); return; } /* Loading the DOM register to MDIO register */ addr = 0xA100; s2io_mdio_write(MDIO_MMD_PMAPMD, addr, val16, dev); val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev); /* Reading the Alarm flags */ addr = 0xA070; val64 = 0x0; val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev); flag = CHECKBIT(val64, 0x7); type = 1; s2io_chk_xpak_counter(&xstats->alarm_transceiver_temp_high, &xstats->xpak_regs_stat, 0x0, flag, type); if (CHECKBIT(val64, 0x6)) xstats->alarm_transceiver_temp_low++; flag = CHECKBIT(val64, 0x3); type = 2; s2io_chk_xpak_counter(&xstats->alarm_laser_bias_current_high, &xstats->xpak_regs_stat, 0x2, flag, type); if (CHECKBIT(val64, 0x2)) xstats->alarm_laser_bias_current_low++; flag = CHECKBIT(val64, 0x1); type = 3; s2io_chk_xpak_counter(&xstats->alarm_laser_output_power_high, &xstats->xpak_regs_stat, 0x4, flag, type); if (CHECKBIT(val64, 0x0)) xstats->alarm_laser_output_power_low++; /* Reading the Warning flags */ addr = 0xA074; val64 = 0x0; val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev); if (CHECKBIT(val64, 0x7)) xstats->warn_transceiver_temp_high++; if (CHECKBIT(val64, 0x6)) xstats->warn_transceiver_temp_low++; if (CHECKBIT(val64, 0x3)) xstats->warn_laser_bias_current_high++; if (CHECKBIT(val64, 0x2)) xstats->warn_laser_bias_current_low++; if (CHECKBIT(val64, 0x1)) xstats->warn_laser_output_power_high++; if (CHECKBIT(val64, 0x0)) xstats->warn_laser_output_power_low++; } /** * wait_for_cmd_complete - waits for a command to complete. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * Description: Function that waits for a command to Write into RMAC * ADDR DATA registers to be completed and returns either success or * error depending on whether the command was complete or not. * Return value: * SUCCESS on success and FAILURE on failure. */ static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit, int bit_state) { int ret = FAILURE, cnt = 0, delay = 1; u64 val64; if ((bit_state != S2IO_BIT_RESET) && (bit_state != S2IO_BIT_SET)) return FAILURE; do { val64 = readq(addr); if (bit_state == S2IO_BIT_RESET) { if (!(val64 & busy_bit)) { ret = SUCCESS; break; } } else { if (val64 & busy_bit) { ret = SUCCESS; break; } } if (in_interrupt()) mdelay(delay); else msleep(delay); if (++cnt >= 10) delay = 50; } while (cnt < 20); return ret; } /* * check_pci_device_id - Checks if the device id is supported * @id : device id * Description: Function to check if the pci device id is supported by driver. * Return value: Actual device id if supported else PCI_ANY_ID */ static u16 check_pci_device_id(u16 id) { switch (id) { case PCI_DEVICE_ID_HERC_WIN: case PCI_DEVICE_ID_HERC_UNI: return XFRAME_II_DEVICE; case PCI_DEVICE_ID_S2IO_UNI: case PCI_DEVICE_ID_S2IO_WIN: return XFRAME_I_DEVICE; default: return PCI_ANY_ID; } } /** * s2io_reset - Resets the card. * @sp : private member of the device structure. * Description: Function to Reset the card. This function then also * restores the previously saved PCI configuration space registers as * the card reset also resets the configuration space. * Return value: * void. */ static void s2io_reset(struct s2io_nic *sp) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64; u16 subid, pci_cmd; int i; u16 val16; unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt; unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt; struct stat_block *stats; struct swStat *swstats; DBG_PRINT(INIT_DBG, "%s: Resetting XFrame card %s\n", __func__, pci_name(sp->pdev)); /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */ pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd)); val64 = SW_RESET_ALL; writeq(val64, &bar0->sw_reset); if (strstr(sp->product_name, "CX4")) msleep(750); msleep(250); for (i = 0; i < S2IO_MAX_PCI_CONFIG_SPACE_REINIT; i++) { /* Restore the PCI state saved during initialization. */ pci_restore_state(sp->pdev); pci_save_state(sp->pdev); pci_read_config_word(sp->pdev, 0x2, &val16); if (check_pci_device_id(val16) != (u16)PCI_ANY_ID) break; msleep(200); } if (check_pci_device_id(val16) == (u16)PCI_ANY_ID) DBG_PRINT(ERR_DBG, "%s SW_Reset failed!\n", __func__); pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, pci_cmd); s2io_init_pci(sp); /* Set swapper to enable I/O register access */ s2io_set_swapper(sp); /* restore mac_addr entries */ do_s2io_restore_unicast_mc(sp); /* Restore the MSIX table entries from local variables */ restore_xmsi_data(sp); /* Clear certain PCI/PCI-X fields after reset */ if (sp->device_type == XFRAME_II_DEVICE) { /* Clear "detected parity error" bit */ pci_write_config_word(sp->pdev, PCI_STATUS, 0x8000); /* Clearing PCIX Ecc status register */ pci_write_config_dword(sp->pdev, 0x68, 0x7C); /* Clearing PCI_STATUS error reflected here */ writeq(s2BIT(62), &bar0->txpic_int_reg); } /* Reset device statistics maintained by OS */ memset(&sp->stats, 0, sizeof(struct net_device_stats)); stats = sp->mac_control.stats_info; swstats = &stats->sw_stat; /* save link up/down time/cnt, reset/memory/watchdog cnt */ up_cnt = swstats->link_up_cnt; down_cnt = swstats->link_down_cnt; up_time = swstats->link_up_time; down_time = swstats->link_down_time; reset_cnt = swstats->soft_reset_cnt; mem_alloc_cnt = swstats->mem_allocated; mem_free_cnt = swstats->mem_freed; watchdog_cnt = swstats->watchdog_timer_cnt; memset(stats, 0, sizeof(struct stat_block)); /* restore link up/down time/cnt, reset/memory/watchdog cnt */ swstats->link_up_cnt = up_cnt; swstats->link_down_cnt = down_cnt; swstats->link_up_time = up_time; swstats->link_down_time = down_time; swstats->soft_reset_cnt = reset_cnt; swstats->mem_allocated = mem_alloc_cnt; swstats->mem_freed = mem_free_cnt; swstats->watchdog_timer_cnt = watchdog_cnt; /* SXE-002: Configure link and activity LED to turn it off */ subid = sp->pdev->subsystem_device; if (((subid & 0xFF) >= 0x07) && (sp->device_type == XFRAME_I_DEVICE)) { val64 = readq(&bar0->gpio_control); val64 |= 0x0000800000000000ULL; writeq(val64, &bar0->gpio_control); val64 = 0x0411040400000000ULL; writeq(val64, (void __iomem *)bar0 + 0x2700); } /* * Clear spurious ECC interrupts that would have occurred on * XFRAME II cards after reset. */ if (sp->device_type == XFRAME_II_DEVICE) { val64 = readq(&bar0->pcc_err_reg); writeq(val64, &bar0->pcc_err_reg); } sp->device_enabled_once = false; } /** * s2io_set_swapper - to set the swapper controle on the card * @sp : private member of the device structure, * pointer to the s2io_nic structure. * Description: Function to set the swapper control on the card * correctly depending on the 'endianness' of the system. * Return value: * SUCCESS on success and FAILURE on failure. */ static int s2io_set_swapper(struct s2io_nic *sp) { struct net_device *dev = sp->dev; struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64, valt, valr; /* * Set proper endian settings and verify the same by reading * the PIF Feed-back register. */ val64 = readq(&bar0->pif_rd_swapper_fb); if (val64 != 0x0123456789ABCDEFULL) { int i = 0; static const u64 value[] = { 0xC30000C3C30000C3ULL, /* FE=1, SE=1 */ 0x8100008181000081ULL, /* FE=1, SE=0 */ 0x4200004242000042ULL, /* FE=0, SE=1 */ 0 /* FE=0, SE=0 */ }; while (i < 4) { writeq(value[i], &bar0->swapper_ctrl); val64 = readq(&bar0->pif_rd_swapper_fb); if (val64 == 0x0123456789ABCDEFULL) break; i++; } if (i == 4) { DBG_PRINT(ERR_DBG, "%s: Endian settings are wrong, " "feedback read %llx\n", dev->name, (unsigned long long)val64); return FAILURE; } valr = value[i]; } else { valr = readq(&bar0->swapper_ctrl); } valt = 0x0123456789ABCDEFULL; writeq(valt, &bar0->xmsi_address); val64 = readq(&bar0->xmsi_address); if (val64 != valt) { int i = 0; static const u64 value[] = { 0x00C3C30000C3C300ULL, /* FE=1, SE=1 */ 0x0081810000818100ULL, /* FE=1, SE=0 */ 0x0042420000424200ULL, /* FE=0, SE=1 */ 0 /* FE=0, SE=0 */ }; while (i < 4) { writeq((value[i] | valr), &bar0->swapper_ctrl); writeq(valt, &bar0->xmsi_address); val64 = readq(&bar0->xmsi_address); if (val64 == valt) break; i++; } if (i == 4) { unsigned long long x = val64; DBG_PRINT(ERR_DBG, "Write failed, Xmsi_addr reads:0x%llx\n", x); return FAILURE; } } val64 = readq(&bar0->swapper_ctrl); val64 &= 0xFFFF000000000000ULL; #ifdef __BIG_ENDIAN /* * The device by default set to a big endian format, so a * big endian driver need not set anything. */ val64 |= (SWAPPER_CTRL_TXP_FE | SWAPPER_CTRL_TXP_SE | SWAPPER_CTRL_TXD_R_FE | SWAPPER_CTRL_TXD_W_FE | SWAPPER_CTRL_TXF_R_FE | SWAPPER_CTRL_RXD_R_FE | SWAPPER_CTRL_RXD_W_FE | SWAPPER_CTRL_RXF_W_FE | SWAPPER_CTRL_XMSI_FE | SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); if (sp->config.intr_type == INTA) val64 |= SWAPPER_CTRL_XMSI_SE; writeq(val64, &bar0->swapper_ctrl); #else /* * Initially we enable all bits to make it accessible by the * driver, then we selectively enable only those bits that * we want to set. */ val64 |= (SWAPPER_CTRL_TXP_FE | SWAPPER_CTRL_TXP_SE | SWAPPER_CTRL_TXD_R_FE | SWAPPER_CTRL_TXD_R_SE | SWAPPER_CTRL_TXD_W_FE | SWAPPER_CTRL_TXD_W_SE | SWAPPER_CTRL_TXF_R_FE | SWAPPER_CTRL_RXD_R_FE | SWAPPER_CTRL_RXD_R_SE | SWAPPER_CTRL_RXD_W_FE | SWAPPER_CTRL_RXD_W_SE | SWAPPER_CTRL_RXF_W_FE | SWAPPER_CTRL_XMSI_FE | SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); if (sp->config.intr_type == INTA) val64 |= SWAPPER_CTRL_XMSI_SE; writeq(val64, &bar0->swapper_ctrl); #endif val64 = readq(&bar0->swapper_ctrl); /* * Verifying if endian settings are accurate by reading a * feedback register. */ val64 = readq(&bar0->pif_rd_swapper_fb); if (val64 != 0x0123456789ABCDEFULL) { /* Endian settings are incorrect, calls for another dekko. */ DBG_PRINT(ERR_DBG, "%s: Endian settings are wrong, feedback read %llx\n", dev->name, (unsigned long long)val64); return FAILURE; } return SUCCESS; } static int wait_for_msix_trans(struct s2io_nic *nic, int i) { struct XENA_dev_config __iomem *bar0 = nic->bar0; u64 val64; int ret = 0, cnt = 0; do { val64 = readq(&bar0->xmsi_access); if (!(val64 & s2BIT(15))) break; mdelay(1); cnt++; } while (cnt < 5); if (cnt == 5) { DBG_PRINT(ERR_DBG, "XMSI # %d Access failed\n", i); ret = 1; } return ret; } static void restore_xmsi_data(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; u64 val64; int i, msix_index; if (nic->device_type == XFRAME_I_DEVICE) return; for (i = 0; i < MAX_REQUESTED_MSI_X; i++) { msix_index = (i) ? ((i-1) * 8 + 1) : 0; writeq(nic->msix_info[i].addr, &bar0->xmsi_address); writeq(nic->msix_info[i].data, &bar0->xmsi_data); val64 = (s2BIT(7) | s2BIT(15) | vBIT(msix_index, 26, 6)); writeq(val64, &bar0->xmsi_access); if (wait_for_msix_trans(nic, msix_index)) { DBG_PRINT(ERR_DBG, "%s: index: %d failed\n", __func__, msix_index); continue; } } } static void store_xmsi_data(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; u64 val64, addr, data; int i, msix_index; if (nic->device_type == XFRAME_I_DEVICE) return; /* Store and display */ for (i = 0; i < MAX_REQUESTED_MSI_X; i++) { msix_index = (i) ? ((i-1) * 8 + 1) : 0; val64 = (s2BIT(15) | vBIT(msix_index, 26, 6)); writeq(val64, &bar0->xmsi_access); if (wait_for_msix_trans(nic, msix_index)) { DBG_PRINT(ERR_DBG, "%s: index: %d failed\n", __func__, msix_index); continue; } addr = readq(&bar0->xmsi_address); data = readq(&bar0->xmsi_data); if (addr && data) { nic->msix_info[i].addr = addr; nic->msix_info[i].data = data; } } } static int s2io_enable_msi_x(struct s2io_nic *nic) { struct XENA_dev_config __iomem *bar0 = nic->bar0; u64 rx_mat; u16 msi_control; /* Temp variable */ int ret, i, j, msix_indx = 1; int size; struct stat_block *stats = nic->mac_control.stats_info; struct swStat *swstats = &stats->sw_stat; size = nic->num_entries * sizeof(struct msix_entry); nic->entries = kzalloc(size, GFP_KERNEL); if (!nic->entries) { DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __func__); swstats->mem_alloc_fail_cnt++; return -ENOMEM; } swstats->mem_allocated += size; size = nic->num_entries * sizeof(struct s2io_msix_entry); nic->s2io_entries = kzalloc(size, GFP_KERNEL); if (!nic->s2io_entries) { DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __func__); swstats->mem_alloc_fail_cnt++; kfree(nic->entries); swstats->mem_freed += (nic->num_entries * sizeof(struct msix_entry)); return -ENOMEM; } swstats->mem_allocated += size; nic->entries[0].entry = 0; nic->s2io_entries[0].entry = 0; nic->s2io_entries[0].in_use = MSIX_FLG; nic->s2io_entries[0].type = MSIX_ALARM_TYPE; nic->s2io_entries[0].arg = &nic->mac_control.fifos; for (i = 1; i < nic->num_entries; i++) { nic->entries[i].entry = ((i - 1) * 8) + 1; nic->s2io_entries[i].entry = ((i - 1) * 8) + 1; nic->s2io_entries[i].arg = NULL; nic->s2io_entries[i].in_use = 0; } rx_mat = readq(&bar0->rx_mat); for (j = 0; j < nic->config.rx_ring_num; j++) { rx_mat |= RX_MAT_SET(j, msix_indx); nic->s2io_entries[j+1].arg = &nic->mac_control.rings[j]; nic->s2io_entries[j+1].type = MSIX_RING_TYPE; nic->s2io_entries[j+1].in_use = MSIX_FLG; msix_indx += 8; } writeq(rx_mat, &bar0->rx_mat); readq(&bar0->rx_mat); ret = pci_enable_msix(nic->pdev, nic->entries, nic->num_entries); /* We fail init if error or we get less vectors than min required */ if (ret) { DBG_PRINT(ERR_DBG, "Enabling MSI-X failed\n"); kfree(nic->entries); swstats->mem_freed += nic->num_entries * sizeof(struct msix_entry); kfree(nic->s2io_entries); swstats->mem_freed += nic->num_entries * sizeof(struct s2io_msix_entry); nic->entries = NULL; nic->s2io_entries = NULL; return -ENOMEM; } /* * To enable MSI-X, MSI also needs to be enabled, due to a bug * in the herc NIC. (Temp change, needs to be removed later) */ pci_read_config_word(nic->pdev, 0x42, &msi_control); msi_control |= 0x1; /* Enable MSI */ pci_write_config_word(nic->pdev, 0x42, msi_control); return 0; } /* Handle software interrupt used during MSI(X) test */ static irqreturn_t s2io_test_intr(int irq, void *dev_id) { struct s2io_nic *sp = dev_id; sp->msi_detected = 1; wake_up(&sp->msi_wait); return IRQ_HANDLED; } /* Test interrupt path by forcing a a software IRQ */ static int s2io_test_msi(struct s2io_nic *sp) { struct pci_dev *pdev = sp->pdev; struct XENA_dev_config __iomem *bar0 = sp->bar0; int err; u64 val64, saved64; err = request_irq(sp->entries[1].vector, s2io_test_intr, 0, sp->name, sp); if (err) { DBG_PRINT(ERR_DBG, "%s: PCI %s: cannot assign irq %d\n", sp->dev->name, pci_name(pdev), pdev->irq); return err; } init_waitqueue_head(&sp->msi_wait); sp->msi_detected = 0; saved64 = val64 = readq(&bar0->scheduled_int_ctrl); val64 |= SCHED_INT_CTRL_ONE_SHOT; val64 |= SCHED_INT_CTRL_TIMER_EN; val64 |= SCHED_INT_CTRL_INT2MSI(1); writeq(val64, &bar0->scheduled_int_ctrl); wait_event_timeout(sp->msi_wait, sp->msi_detected, HZ/10); if (!sp->msi_detected) { /* MSI(X) test failed, go back to INTx mode */ DBG_PRINT(ERR_DBG, "%s: PCI %s: No interrupt was generated " "using MSI(X) during test\n", sp->dev->name, pci_name(pdev)); err = -EOPNOTSUPP; } free_irq(sp->entries[1].vector, sp); writeq(saved64, &bar0->scheduled_int_ctrl); return err; } static void remove_msix_isr(struct s2io_nic *sp) { int i; u16 msi_control; for (i = 0; i < sp->num_entries; i++) { if (sp->s2io_entries[i].in_use == MSIX_REGISTERED_SUCCESS) { int vector = sp->entries[i].vector; void *arg = sp->s2io_entries[i].arg; free_irq(vector, arg); } } kfree(sp->entries); kfree(sp->s2io_entries); sp->entries = NULL; sp->s2io_entries = NULL; pci_read_config_word(sp->pdev, 0x42, &msi_control); msi_control &= 0xFFFE; /* Disable MSI */ pci_write_config_word(sp->pdev, 0x42, msi_control); pci_disable_msix(sp->pdev); } static void remove_inta_isr(struct s2io_nic *sp) { struct net_device *dev = sp->dev; free_irq(sp->pdev->irq, dev); } /* ********************************************************* * * Functions defined below concern the OS part of the driver * * ********************************************************* */ /** * s2io_open - open entry point of the driver * @dev : pointer to the device structure. * Description: * This function is the open entry point of the driver. It mainly calls a * function to allocate Rx buffers and inserts them into the buffer * descriptors and then enables the Rx part of the NIC. * Return value: * 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ static int s2io_open(struct net_device *dev) { struct s2io_nic *sp = netdev_priv(dev); struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; int err = 0; /* * Make sure you have link off by default every time * Nic is initialized */ netif_carrier_off(dev); sp->last_link_state = 0; /* Initialize H/W and enable interrupts */ err = s2io_card_up(sp); if (err) { DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n", dev->name); goto hw_init_failed; } if (do_s2io_prog_unicast(dev, dev->dev_addr) == FAILURE) { DBG_PRINT(ERR_DBG, "Set Mac Address Failed\n"); s2io_card_down(sp); err = -ENODEV; goto hw_init_failed; } s2io_start_all_tx_queue(sp); return 0; hw_init_failed: if (sp->config.intr_type == MSI_X) { if (sp->entries) { kfree(sp->entries); swstats->mem_freed += sp->num_entries * sizeof(struct msix_entry); } if (sp->s2io_entries) { kfree(sp->s2io_entries); swstats->mem_freed += sp->num_entries * sizeof(struct s2io_msix_entry); } } return err; } /** * s2io_close -close entry point of the driver * @dev : device pointer. * Description: * This is the stop entry point of the driver. It needs to undo exactly * whatever was done by the open entry point,thus it's usually referred to * as the close function.Among other things this function mainly stops the * Rx side of the NIC and frees all the Rx buffers in the Rx rings. * Return value: * 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ static int s2io_close(struct net_device *dev) { struct s2io_nic *sp = netdev_priv(dev); struct config_param *config = &sp->config; u64 tmp64; int offset; /* Return if the device is already closed * * Can happen when s2io_card_up failed in change_mtu * */ if (!is_s2io_card_up(sp)) return 0; s2io_stop_all_tx_queue(sp); /* delete all populated mac entries */ for (offset = 1; offset < config->max_mc_addr; offset++) { tmp64 = do_s2io_read_unicast_mc(sp, offset); if (tmp64 != S2IO_DISABLE_MAC_ENTRY) do_s2io_delete_unicast_mc(sp, tmp64); } s2io_card_down(sp); return 0; } /** * s2io_xmit - Tx entry point of te driver * @skb : the socket buffer containing the Tx data. * @dev : device pointer. * Description : * This function is the Tx entry point of the driver. S2IO NIC supports * certain protocol assist features on Tx side, namely CSO, S/G, LSO. * NOTE: when device can't queue the pkt,just the trans_start variable will * not be upadted. * Return value: * 0 on success & 1 on failure. */ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev) { struct s2io_nic *sp = netdev_priv(dev); u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off; register u64 val64; struct TxD *txdp; struct TxFIFO_element __iomem *tx_fifo; unsigned long flags = 0; u16 vlan_tag = 0; struct fifo_info *fifo = NULL; int do_spin_lock = 1; int offload_type; int enable_per_list_interrupt = 0; struct config_param *config = &sp->config; struct mac_info *mac_control = &sp->mac_control; struct stat_block *stats = mac_control->stats_info; struct swStat *swstats = &stats->sw_stat; DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); if (unlikely(skb->len <= 0)) { DBG_PRINT(TX_DBG, "%s: Buffer has no data..\n", dev->name); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } if (!is_s2io_card_up(sp)) { DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", dev->name); dev_kfree_skb(skb); return NETDEV_TX_OK; } queue = 0; if (vlan_tx_tag_present(skb)) vlan_tag = vlan_tx_tag_get(skb); if (sp->config.tx_steering_type == TX_DEFAULT_STEERING) { if (skb->protocol == htons(ETH_P_IP)) { struct iphdr *ip; struct tcphdr *th; ip = ip_hdr(skb); if (!ip_is_fragment(ip)) { th = (struct tcphdr *)(((unsigned char *)ip) + ip->ihl*4); if (ip->protocol == IPPROTO_TCP) { queue_len = sp->total_tcp_fifos; queue = (ntohs(th->source) + ntohs(th->dest)) & sp->fifo_selector[queue_len - 1]; if (queue >= queue_len) queue = queue_len - 1; } else if (ip->protocol == IPPROTO_UDP) { queue_len = sp->total_udp_fifos; queue = (ntohs(th->source) + ntohs(th->dest)) & sp->fifo_selector[queue_len - 1]; if (queue >= queue_len) queue = queue_len - 1; queue += sp->udp_fifo_idx; if (skb->len > 1024) enable_per_list_interrupt = 1; do_spin_lock = 0; } } } } else if (sp->config.tx_steering_type == TX_PRIORITY_STEERING) /* get fifo number based on skb->priority value */ queue = config->fifo_mapping [skb->priority & (MAX_TX_FIFOS - 1)]; fifo = &mac_control->fifos[queue]; if (do_spin_lock) spin_lock_irqsave(&fifo->tx_lock, flags); else { if (unlikely(!spin_trylock_irqsave(&fifo->tx_lock, flags))) return NETDEV_TX_LOCKED; } if (sp->config.multiq) { if (__netif_subqueue_stopped(dev, fifo->fifo_no)) { spin_unlock_irqrestore(&fifo->tx_lock, flags); return NETDEV_TX_BUSY; } } else if (unlikely(fifo->queue_state == FIFO_QUEUE_STOP)) { if (netif_queue_stopped(dev)) { spin_unlock_irqrestore(&fifo->tx_lock, flags); return NETDEV_TX_BUSY; } } put_off = (u16)fifo->tx_curr_put_info.offset; get_off = (u16)fifo->tx_curr_get_info.offset; txdp = fifo->list_info[put_off].list_virt_addr; queue_len = fifo->tx_curr_put_info.fifo_len + 1; /* Avoid "put" pointer going beyond "get" pointer */ if (txdp->Host_Control || ((put_off+1) == queue_len ? 0 : (put_off+1)) == get_off) { DBG_PRINT(TX_DBG, "Error in xmit, No free TXDs.\n"); s2io_stop_tx_queue(sp, fifo->fifo_no); dev_kfree_skb(skb); spin_unlock_irqrestore(&fifo->tx_lock, flags); return NETDEV_TX_OK; } offload_type = s2io_offload_type(skb); if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { txdp->Control_1 |= TXD_TCP_LSO_EN; txdp->Control_1 |= TXD_TCP_LSO_MSS(s2io_tcp_mss(skb)); } if (skb->ip_summed == CHECKSUM_PARTIAL) { txdp->Control_2 |= (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN | TXD_TX_CKO_UDP_EN); } txdp->Control_1 |= TXD_GATHER_CODE_FIRST; txdp->Control_1 |= TXD_LIST_OWN_XENA; txdp->Control_2 |= TXD_INT_NUMBER(fifo->fifo_no); if (enable_per_list_interrupt) if (put_off & (queue_len >> 5)) txdp->Control_2 |= TXD_INT_TYPE_PER_LIST; if (vlan_tag) { txdp->Control_2 |= TXD_VLAN_ENABLE; txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag); } frg_len = skb_headlen(skb); if (offload_type == SKB_GSO_UDP) { int ufo_size; ufo_size = s2io_udp_mss(skb); ufo_size &= ~7; txdp->Control_1 |= TXD_UFO_EN; txdp->Control_1 |= TXD_UFO_MSS(ufo_size); txdp->Control_1 |= TXD_BUFFER0_SIZE(8); #ifdef __BIG_ENDIAN /* both variants do cpu_to_be64(be32_to_cpu(...)) */ fifo->ufo_in_band_v[put_off] = (__force u64)skb_shinfo(skb)->ip6_frag_id; #else fifo->ufo_in_band_v[put_off] = (__force u64)skb_shinfo(skb)->ip6_frag_id << 32; #endif txdp->Host_Control = (unsigned long)fifo->ufo_in_band_v; txdp->Buffer_Pointer = pci_map_single(sp->pdev, fifo->ufo_in_band_v, sizeof(u64), PCI_DMA_TODEVICE); if (pci_dma_mapping_error(sp->pdev, txdp->Buffer_Pointer)) goto pci_map_failed; txdp++; } txdp->Buffer_Pointer = pci_map_single(sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); if (pci_dma_mapping_error(sp->pdev, txdp->Buffer_Pointer)) goto pci_map_failed; txdp->Host_Control = (unsigned long)skb; txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len); if (offload_type == SKB_GSO_UDP) txdp->Control_1 |= TXD_UFO_EN; frg_cnt = skb_shinfo(skb)->nr_frags; /* For fragmented SKB. */ for (i = 0; i < frg_cnt; i++) { const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; /* A '0' length fragment will be ignored */ if (!skb_frag_size(frag)) continue; txdp++; txdp->Buffer_Pointer = (u64)skb_frag_dma_map(&sp->pdev->dev, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); txdp->Control_1 = TXD_BUFFER0_SIZE(skb_frag_size(frag)); if (offload_type == SKB_GSO_UDP) txdp->Control_1 |= TXD_UFO_EN; } txdp->Control_1 |= TXD_GATHER_CODE_LAST; if (offload_type == SKB_GSO_UDP) frg_cnt++; /* as Txd0 was used for inband header */ tx_fifo = mac_control->tx_FIFO_start[queue]; val64 = fifo->list_info[put_off].list_phy_addr; writeq(val64, &tx_fifo->TxDL_Pointer); val64 = (TX_FIFO_LAST_TXD_NUM(frg_cnt) | TX_FIFO_FIRST_LIST | TX_FIFO_LAST_LIST); if (offload_type) val64 |= TX_FIFO_SPECIAL_FUNC; writeq(val64, &tx_fifo->List_Control); mmiowb(); put_off++; if (put_off == fifo->tx_curr_put_info.fifo_len + 1) put_off = 0; fifo->tx_curr_put_info.offset = put_off; /* Avoid "put" pointer going beyond "get" pointer */ if (((put_off+1) == queue_len ? 0 : (put_off+1)) == get_off) { swstats->fifo_full_cnt++; DBG_PRINT(TX_DBG, "No free TxDs for xmit, Put: 0x%x Get:0x%x\n", put_off, get_off); s2io_stop_tx_queue(sp, fifo->fifo_no); } swstats->mem_allocated += skb->truesize; spin_unlock_irqrestore(&fifo->tx_lock, flags); if (sp->config.intr_type == MSI_X) tx_intr_handler(fifo); return NETDEV_TX_OK; pci_map_failed: swstats->pci_map_fail_cnt++; s2io_stop_tx_queue(sp, fifo->fifo_no); swstats->mem_freed += skb->truesize; dev_kfree_skb(skb); spin_unlock_irqrestore(&fifo->tx_lock, flags); return NETDEV_TX_OK; } static void s2io_alarm_handle(unsigned long data) { struct s2io_nic *sp = (struct s2io_nic *)data; struct net_device *dev = sp->dev; s2io_handle_errors(dev); mod_timer(&sp->alarm_timer, jiffies + HZ / 2); } static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id) { struct ring_info *ring = (struct ring_info *)dev_id; struct s2io_nic *sp = ring->nic; struct XENA_dev_config __iomem *bar0 = sp->bar0; if (unlikely(!is_s2io_card_up(sp))) return IRQ_HANDLED; if (sp->config.napi) { u8 __iomem *addr = NULL; u8 val8 = 0; addr = (u8 __iomem *)&bar0->xmsi_mask_reg; addr += (7 - ring->ring_no); val8 = (ring->ring_no == 0) ? 0x7f : 0xff; writeb(val8, addr); val8 = readb(addr); napi_schedule(&ring->napi); } else { rx_intr_handler(ring, 0); s2io_chk_rx_buffers(sp, ring); } return IRQ_HANDLED; } static irqreturn_t s2io_msix_fifo_handle(int irq, void *dev_id) { int i; struct fifo_info *fifos = (struct fifo_info *)dev_id; struct s2io_nic *sp = fifos->nic; struct XENA_dev_config __iomem *bar0 = sp->bar0; struct config_param *config = &sp->config; u64 reason; if (unlikely(!is_s2io_card_up(sp))) return IRQ_NONE; reason = readq(&bar0->general_int_status); if (unlikely(reason == S2IO_MINUS_ONE)) /* Nothing much can be done. Get out */ return IRQ_HANDLED; if (reason & (GEN_INTR_TXPIC | GEN_INTR_TXTRAFFIC)) { writeq(S2IO_MINUS_ONE, &bar0->general_int_mask); if (reason & GEN_INTR_TXPIC) s2io_txpic_intr_handle(sp); if (reason & GEN_INTR_TXTRAFFIC) writeq(S2IO_MINUS_ONE, &bar0->tx_traffic_int); for (i = 0; i < config->tx_fifo_num; i++) tx_intr_handler(&fifos[i]); writeq(sp->general_int_mask, &bar0->general_int_mask); readl(&bar0->general_int_status); return IRQ_HANDLED; } /* The interrupt was not raised by us */ return IRQ_NONE; } static void s2io_txpic_intr_handle(struct s2io_nic *sp) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64; val64 = readq(&bar0->pic_int_status); if (val64 & PIC_INT_GPIO) { val64 = readq(&bar0->gpio_int_reg); if ((val64 & GPIO_INT_REG_LINK_DOWN) && (val64 & GPIO_INT_REG_LINK_UP)) { /* * This is unstable state so clear both up/down * interrupt and adapter to re-evaluate the link state. */ val64 |= GPIO_INT_REG_LINK_DOWN; val64 |= GPIO_INT_REG_LINK_UP; writeq(val64, &bar0->gpio_int_reg); val64 = readq(&bar0->gpio_int_mask); val64 &= ~(GPIO_INT_MASK_LINK_UP | GPIO_INT_MASK_LINK_DOWN); writeq(val64, &bar0->gpio_int_mask); } else if (val64 & GPIO_INT_REG_LINK_UP) { val64 = readq(&bar0->adapter_status); /* Enable Adapter */ val64 = readq(&bar0->adapter_control); val64 |= ADAPTER_CNTL_EN; writeq(val64, &bar0->adapter_control); val64 |= ADAPTER_LED_ON; writeq(val64, &bar0->adapter_control); if (!sp->device_enabled_once) sp->device_enabled_once = 1; s2io_link(sp, LINK_UP); /* * unmask link down interrupt and mask link-up * intr */ val64 = readq(&bar0->gpio_int_mask); val64 &= ~GPIO_INT_MASK_LINK_DOWN; val64 |= GPIO_INT_MASK_LINK_UP; writeq(val64, &bar0->gpio_int_mask); } else if (val64 & GPIO_INT_REG_LINK_DOWN) { val64 = readq(&bar0->adapter_status); s2io_link(sp, LINK_DOWN); /* Link is down so unmaks link up interrupt */ val64 = readq(&bar0->gpio_int_mask); val64 &= ~GPIO_INT_MASK_LINK_UP; val64 |= GPIO_INT_MASK_LINK_DOWN; writeq(val64, &bar0->gpio_int_mask); /* turn off LED */ val64 = readq(&bar0->adapter_control); val64 = val64 & (~ADAPTER_LED_ON); writeq(val64, &bar0->adapter_control); } } val64 = readq(&bar0->gpio_int_mask); } /** * do_s2io_chk_alarm_bit - Check for alarm and incrment the counter * @value: alarm bits * @addr: address value * @cnt: counter variable * Description: Check for alarm and increment the counter * Return Value: * 1 - if alarm bit set * 0 - if alarm bit is not set */ static int do_s2io_chk_alarm_bit(u64 value, void __iomem *addr, unsigned long long *cnt) { u64 val64; val64 = readq(addr); if (val64 & value) { writeq(val64, addr); (*cnt)++; return 1; } return 0; } /** * s2io_handle_errors - Xframe error indication handler * @nic: device private variable * Description: Handle alarms such as loss of link, single or * double ECC errors, critical and serious errors. * Return Value: * NONE */ static void s2io_handle_errors(void *dev_id) { struct net_device *dev = (struct net_device *)dev_id; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 temp64 = 0, val64 = 0; int i = 0; struct swStat *sw_stat = &sp->mac_control.stats_info->sw_stat; struct xpakStat *stats = &sp->mac_control.stats_info->xpak_stat; if (!is_s2io_card_up(sp)) return; if (pci_channel_offline(sp->pdev)) return; memset(&sw_stat->ring_full_cnt, 0, sizeof(sw_stat->ring_full_cnt)); /* Handling the XPAK counters update */ if (stats->xpak_timer_count < 72000) { /* waiting for an hour */ stats->xpak_timer_count++; } else { s2io_updt_xpak_counter(dev); /* reset the count to zero */ stats->xpak_timer_count = 0; } /* Handling link status change error Intr */ if (s2io_link_fault_indication(sp) == MAC_RMAC_ERR_TIMER) { val64 = readq(&bar0->mac_rmac_err_reg); writeq(val64, &bar0->mac_rmac_err_reg); if (val64 & RMAC_LINK_STATE_CHANGE_INT) schedule_work(&sp->set_link_task); } /* In case of a serious error, the device will be Reset. */ if (do_s2io_chk_alarm_bit(SERR_SOURCE_ANY, &bar0->serr_source, &sw_stat->serious_err_cnt)) goto reset; /* Check for data parity error */ if (do_s2io_chk_alarm_bit(GPIO_INT_REG_DP_ERR_INT, &bar0->gpio_int_reg, &sw_stat->parity_err_cnt)) goto reset; /* Check for ring full counter */ if (sp->device_type == XFRAME_II_DEVICE) { val64 = readq(&bar0->ring_bump_counter1); for (i = 0; i < 4; i++) { temp64 = (val64 & vBIT(0xFFFF, (i*16), 16)); temp64 >>= 64 - ((i+1)*16); sw_stat->ring_full_cnt[i] += temp64; } val64 = readq(&bar0->ring_bump_counter2); for (i = 0; i < 4; i++) { temp64 = (val64 & vBIT(0xFFFF, (i*16), 16)); temp64 >>= 64 - ((i+1)*16); sw_stat->ring_full_cnt[i+4] += temp64; } } val64 = readq(&bar0->txdma_int_status); /*check for pfc_err*/ if (val64 & TXDMA_PFC_INT) { if (do_s2io_chk_alarm_bit(PFC_ECC_DB_ERR | PFC_SM_ERR_ALARM | PFC_MISC_0_ERR | PFC_MISC_1_ERR | PFC_PCIX_ERR, &bar0->pfc_err_reg, &sw_stat->pfc_err_cnt)) goto reset; do_s2io_chk_alarm_bit(PFC_ECC_SG_ERR, &bar0->pfc_err_reg, &sw_stat->pfc_err_cnt); } /*check for tda_err*/ if (val64 & TXDMA_TDA_INT) { if (do_s2io_chk_alarm_bit(TDA_Fn_ECC_DB_ERR | TDA_SM0_ERR_ALARM | TDA_SM1_ERR_ALARM, &bar0->tda_err_reg, &sw_stat->tda_err_cnt)) goto reset; do_s2io_chk_alarm_bit(TDA_Fn_ECC_SG_ERR | TDA_PCIX_ERR, &bar0->tda_err_reg, &sw_stat->tda_err_cnt); } /*check for pcc_err*/ if (val64 & TXDMA_PCC_INT) { if (do_s2io_chk_alarm_bit(PCC_SM_ERR_ALARM | PCC_WR_ERR_ALARM | PCC_N_SERR | PCC_6_COF_OV_ERR | PCC_7_COF_OV_ERR | PCC_6_LSO_OV_ERR | PCC_7_LSO_OV_ERR | PCC_FB_ECC_DB_ERR | PCC_TXB_ECC_DB_ERR, &bar0->pcc_err_reg, &sw_stat->pcc_err_cnt)) goto reset; do_s2io_chk_alarm_bit(PCC_FB_ECC_SG_ERR | PCC_TXB_ECC_SG_ERR, &bar0->pcc_err_reg, &sw_stat->pcc_err_cnt); } /*check for tti_err*/ if (val64 & TXDMA_TTI_INT) { if (do_s2io_chk_alarm_bit(TTI_SM_ERR_ALARM, &bar0->tti_err_reg, &sw_stat->tti_err_cnt)) goto reset; do_s2io_chk_alarm_bit(TTI_ECC_SG_ERR | TTI_ECC_DB_ERR, &bar0->tti_err_reg, &sw_stat->tti_err_cnt); } /*check for lso_err*/ if (val64 & TXDMA_LSO_INT) { if (do_s2io_chk_alarm_bit(LSO6_ABORT | LSO7_ABORT | LSO6_SM_ERR_ALARM | LSO7_SM_ERR_ALARM, &bar0->lso_err_reg, &sw_stat->lso_err_cnt)) goto reset; do_s2io_chk_alarm_bit(LSO6_SEND_OFLOW | LSO7_SEND_OFLOW, &bar0->lso_err_reg, &sw_stat->lso_err_cnt); } /*check for tpa_err*/ if (val64 & TXDMA_TPA_INT) { if (do_s2io_chk_alarm_bit(TPA_SM_ERR_ALARM, &bar0->tpa_err_reg, &sw_stat->tpa_err_cnt)) goto reset; do_s2io_chk_alarm_bit(TPA_TX_FRM_DROP, &bar0->tpa_err_reg, &sw_stat->tpa_err_cnt); } /*check for sm_err*/ if (val64 & TXDMA_SM_INT) { if (do_s2io_chk_alarm_bit(SM_SM_ERR_ALARM, &bar0->sm_err_reg, &sw_stat->sm_err_cnt)) goto reset; } val64 = readq(&bar0->mac_int_status); if (val64 & MAC_INT_STATUS_TMAC_INT) { if (do_s2io_chk_alarm_bit(TMAC_TX_BUF_OVRN | TMAC_TX_SM_ERR, &bar0->mac_tmac_err_reg, &sw_stat->mac_tmac_err_cnt)) goto reset; do_s2io_chk_alarm_bit(TMAC_ECC_SG_ERR | TMAC_ECC_DB_ERR | TMAC_DESC_ECC_SG_ERR | TMAC_DESC_ECC_DB_ERR, &bar0->mac_tmac_err_reg, &sw_stat->mac_tmac_err_cnt); } val64 = readq(&bar0->xgxs_int_status); if (val64 & XGXS_INT_STATUS_TXGXS) { if (do_s2io_chk_alarm_bit(TXGXS_ESTORE_UFLOW | TXGXS_TX_SM_ERR, &bar0->xgxs_txgxs_err_reg, &sw_stat->xgxs_txgxs_err_cnt)) goto reset; do_s2io_chk_alarm_bit(TXGXS_ECC_SG_ERR | TXGXS_ECC_DB_ERR, &bar0->xgxs_txgxs_err_reg, &sw_stat->xgxs_txgxs_err_cnt); } val64 = readq(&bar0->rxdma_int_status); if (val64 & RXDMA_INT_RC_INT_M) { if (do_s2io_chk_alarm_bit(RC_PRCn_ECC_DB_ERR | RC_FTC_ECC_DB_ERR | RC_PRCn_SM_ERR_ALARM | RC_FTC_SM_ERR_ALARM, &bar0->rc_err_reg, &sw_stat->rc_err_cnt)) goto reset; do_s2io_chk_alarm_bit(RC_PRCn_ECC_SG_ERR | RC_FTC_ECC_SG_ERR | RC_RDA_FAIL_WR_Rn, &bar0->rc_err_reg, &sw_stat->rc_err_cnt); if (do_s2io_chk_alarm_bit(PRC_PCI_AB_RD_Rn | PRC_PCI_AB_WR_Rn | PRC_PCI_AB_F_WR_Rn, &bar0->prc_pcix_err_reg, &sw_stat->prc_pcix_err_cnt)) goto reset; do_s2io_chk_alarm_bit(PRC_PCI_DP_RD_Rn | PRC_PCI_DP_WR_Rn | PRC_PCI_DP_F_WR_Rn, &bar0->prc_pcix_err_reg, &sw_stat->prc_pcix_err_cnt); } if (val64 & RXDMA_INT_RPA_INT_M) { if (do_s2io_chk_alarm_bit(RPA_SM_ERR_ALARM | RPA_CREDIT_ERR, &bar0->rpa_err_reg, &sw_stat->rpa_err_cnt)) goto reset; do_s2io_chk_alarm_bit(RPA_ECC_SG_ERR | RPA_ECC_DB_ERR, &bar0->rpa_err_reg, &sw_stat->rpa_err_cnt); } if (val64 & RXDMA_INT_RDA_INT_M) { if (do_s2io_chk_alarm_bit(RDA_RXDn_ECC_DB_ERR | RDA_FRM_ECC_DB_N_AERR | RDA_SM1_ERR_ALARM | RDA_SM0_ERR_ALARM | RDA_RXD_ECC_DB_SERR, &bar0->rda_err_reg, &sw_stat->rda_err_cnt)) goto reset; do_s2io_chk_alarm_bit(RDA_RXDn_ECC_SG_ERR | RDA_FRM_ECC_SG_ERR | RDA_MISC_ERR | RDA_PCIX_ERR, &bar0->rda_err_reg, &sw_stat->rda_err_cnt); } if (val64 & RXDMA_INT_RTI_INT_M) { if (do_s2io_chk_alarm_bit(RTI_SM_ERR_ALARM, &bar0->rti_err_reg, &sw_stat->rti_err_cnt)) goto reset; do_s2io_chk_alarm_bit(RTI_ECC_SG_ERR | RTI_ECC_DB_ERR, &bar0->rti_err_reg, &sw_stat->rti_err_cnt); } val64 = readq(&bar0->mac_int_status); if (val64 & MAC_INT_STATUS_RMAC_INT) { if (do_s2io_chk_alarm_bit(RMAC_RX_BUFF_OVRN | RMAC_RX_SM_ERR, &bar0->mac_rmac_err_reg, &sw_stat->mac_rmac_err_cnt)) goto reset; do_s2io_chk_alarm_bit(RMAC_UNUSED_INT | RMAC_SINGLE_ECC_ERR | RMAC_DOUBLE_ECC_ERR, &bar0->mac_rmac_err_reg, &sw_stat->mac_rmac_err_cnt); } val64 = readq(&bar0->xgxs_int_status); if (val64 & XGXS_INT_STATUS_RXGXS) { if (do_s2io_chk_alarm_bit(RXGXS_ESTORE_OFLOW | RXGXS_RX_SM_ERR, &bar0->xgxs_rxgxs_err_reg, &sw_stat->xgxs_rxgxs_err_cnt)) goto reset; } val64 = readq(&bar0->mc_int_status); if (val64 & MC_INT_STATUS_MC_INT) { if (do_s2io_chk_alarm_bit(MC_ERR_REG_SM_ERR, &bar0->mc_err_reg, &sw_stat->mc_err_cnt)) goto reset; /* Handling Ecc errors */ if (val64 & (MC_ERR_REG_ECC_ALL_SNG | MC_ERR_REG_ECC_ALL_DBL)) { writeq(val64, &bar0->mc_err_reg); if (val64 & MC_ERR_REG_ECC_ALL_DBL) { sw_stat->double_ecc_errs++; if (sp->device_type != XFRAME_II_DEVICE) { /* * Reset XframeI only if critical error */ if (val64 & (MC_ERR_REG_MIRI_ECC_DB_ERR_0 | MC_ERR_REG_MIRI_ECC_DB_ERR_1)) goto reset; } } else sw_stat->single_ecc_errs++; } } return; reset: s2io_stop_all_tx_queue(sp); schedule_work(&sp->rst_timer_task); sw_stat->soft_reset_cnt++; } /** * s2io_isr - ISR handler of the device . * @irq: the irq of the device. * @dev_id: a void pointer to the dev structure of the NIC. * Description: This function is the ISR handler of the device. It * identifies the reason for the interrupt and calls the relevant * service routines. As a contongency measure, this ISR allocates the * recv buffers, if their numbers are below the panic value which is * presently set to 25% of the original number of rcv buffers allocated. * Return value: * IRQ_HANDLED: will be returned if IRQ was handled by this routine * IRQ_NONE: will be returned if interrupt is not from our device */ static irqreturn_t s2io_isr(int irq, void *dev_id) { struct net_device *dev = (struct net_device *)dev_id; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; int i; u64 reason = 0; struct mac_info *mac_control; struct config_param *config; /* Pretend we handled any irq's from a disconnected card */ if (pci_channel_offline(sp->pdev)) return IRQ_NONE; if (!is_s2io_card_up(sp)) return IRQ_NONE; config = &sp->config; mac_control = &sp->mac_control; /* * Identify the cause for interrupt and call the appropriate * interrupt handler. Causes for the interrupt could be; * 1. Rx of packet. * 2. Tx complete. * 3. Link down. */ reason = readq(&bar0->general_int_status); if (unlikely(reason == S2IO_MINUS_ONE)) return IRQ_HANDLED; /* Nothing much can be done. Get out */ if (reason & (GEN_INTR_RXTRAFFIC | GEN_INTR_TXTRAFFIC | GEN_INTR_TXPIC)) { writeq(S2IO_MINUS_ONE, &bar0->general_int_mask); if (config->napi) { if (reason & GEN_INTR_RXTRAFFIC) { napi_schedule(&sp->napi); writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_mask); writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); readl(&bar0->rx_traffic_int); } } else { /* * rx_traffic_int reg is an R1 register, writing all 1's * will ensure that the actual interrupt causing bit * get's cleared and hence a read can be avoided. */ if (reason & GEN_INTR_RXTRAFFIC) writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; rx_intr_handler(ring, 0); } } /* * tx_traffic_int reg is an R1 register, writing all 1's * will ensure that the actual interrupt causing bit get's * cleared and hence a read can be avoided. */ if (reason & GEN_INTR_TXTRAFFIC) writeq(S2IO_MINUS_ONE, &bar0->tx_traffic_int); for (i = 0; i < config->tx_fifo_num; i++) tx_intr_handler(&mac_control->fifos[i]); if (reason & GEN_INTR_TXPIC) s2io_txpic_intr_handle(sp); /* * Reallocate the buffers from the interrupt handler itself. */ if (!config->napi) { for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; s2io_chk_rx_buffers(sp, ring); } } writeq(sp->general_int_mask, &bar0->general_int_mask); readl(&bar0->general_int_status); return IRQ_HANDLED; } else if (!reason) { /* The interrupt was not raised by us */ return IRQ_NONE; } return IRQ_HANDLED; } /** * s2io_updt_stats - */ static void s2io_updt_stats(struct s2io_nic *sp) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64; int cnt = 0; if (is_s2io_card_up(sp)) { /* Apprx 30us on a 133 MHz bus */ val64 = SET_UPDT_CLICKS(10) | STAT_CFG_ONE_SHOT_EN | STAT_CFG_STAT_EN; writeq(val64, &bar0->stat_cfg); do { udelay(100); val64 = readq(&bar0->stat_cfg); if (!(val64 & s2BIT(0))) break; cnt++; if (cnt == 5) break; /* Updt failed */ } while (1); } } /** * s2io_get_stats - Updates the device statistics structure. * @dev : pointer to the device structure. * Description: * This function updates the device statistics structure in the s2io_nic * structure and returns a pointer to the same. * Return value: * pointer to the updated net_device_stats structure. */ static struct net_device_stats *s2io_get_stats(struct net_device *dev) { struct s2io_nic *sp = netdev_priv(dev); struct mac_info *mac_control = &sp->mac_control; struct stat_block *stats = mac_control->stats_info; u64 delta; /* Configure Stats for immediate updt */ s2io_updt_stats(sp); /* A device reset will cause the on-adapter statistics to be zero'ed. * This can be done while running by changing the MTU. To prevent the * system from having the stats zero'ed, the driver keeps a copy of the * last update to the system (which is also zero'ed on reset). This * enables the driver to accurately know the delta between the last * update and the current update. */ delta = ((u64) le32_to_cpu(stats->rmac_vld_frms_oflow) << 32 | le32_to_cpu(stats->rmac_vld_frms)) - sp->stats.rx_packets; sp->stats.rx_packets += delta; dev->stats.rx_packets += delta; delta = ((u64) le32_to_cpu(stats->tmac_frms_oflow) << 32 | le32_to_cpu(stats->tmac_frms)) - sp->stats.tx_packets; sp->stats.tx_packets += delta; dev->stats.tx_packets += delta; delta = ((u64) le32_to_cpu(stats->rmac_data_octets_oflow) << 32 | le32_to_cpu(stats->rmac_data_octets)) - sp->stats.rx_bytes; sp->stats.rx_bytes += delta; dev->stats.rx_bytes += delta; delta = ((u64) le32_to_cpu(stats->tmac_data_octets_oflow) << 32 | le32_to_cpu(stats->tmac_data_octets)) - sp->stats.tx_bytes; sp->stats.tx_bytes += delta; dev->stats.tx_bytes += delta; delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_errors; sp->stats.rx_errors += delta; dev->stats.rx_errors += delta; delta = ((u64) le32_to_cpu(stats->tmac_any_err_frms_oflow) << 32 | le32_to_cpu(stats->tmac_any_err_frms)) - sp->stats.tx_errors; sp->stats.tx_errors += delta; dev->stats.tx_errors += delta; delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_dropped; sp->stats.rx_dropped += delta; dev->stats.rx_dropped += delta; delta = le64_to_cpu(stats->tmac_drop_frms) - sp->stats.tx_dropped; sp->stats.tx_dropped += delta; dev->stats.tx_dropped += delta; /* The adapter MAC interprets pause frames as multicast packets, but * does not pass them up. This erroneously increases the multicast * packet count and needs to be deducted when the multicast frame count * is queried. */ delta = (u64) le32_to_cpu(stats->rmac_vld_mcst_frms_oflow) << 32 | le32_to_cpu(stats->rmac_vld_mcst_frms); delta -= le64_to_cpu(stats->rmac_pause_ctrl_frms); delta -= sp->stats.multicast; sp->stats.multicast += delta; dev->stats.multicast += delta; delta = ((u64) le32_to_cpu(stats->rmac_usized_frms_oflow) << 32 | le32_to_cpu(stats->rmac_usized_frms)) + le64_to_cpu(stats->rmac_long_frms) - sp->stats.rx_length_errors; sp->stats.rx_length_errors += delta; dev->stats.rx_length_errors += delta; delta = le64_to_cpu(stats->rmac_fcs_err_frms) - sp->stats.rx_crc_errors; sp->stats.rx_crc_errors += delta; dev->stats.rx_crc_errors += delta; return &dev->stats; } /** * s2io_set_multicast - entry point for multicast address enable/disable. * @dev : pointer to the device structure * Description: * This function is a driver entry point which gets called by the kernel * whenever multicast addresses must be enabled/disabled. This also gets * called to set/reset promiscuous mode. Depending on the deivce flag, we * determine, if multicast address must be enabled or if promiscuous mode * is to be disabled etc. * Return value: * void. */ static void s2io_set_multicast(struct net_device *dev) { int i, j, prev_cnt; struct netdev_hw_addr *ha; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64 = 0, multi_mac = 0x010203040506ULL, mask = 0xfeffffffffffULL; u64 dis_addr = S2IO_DISABLE_MAC_ENTRY, mac_addr = 0; void __iomem *add; struct config_param *config = &sp->config; if ((dev->flags & IFF_ALLMULTI) && (!sp->m_cast_flg)) { /* Enable all Multicast addresses */ writeq(RMAC_ADDR_DATA0_MEM_ADDR(multi_mac), &bar0->rmac_addr_data0_mem); writeq(RMAC_ADDR_DATA1_MEM_MASK(mask), &bar0->rmac_addr_data1_mem); val64 = RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET(config->max_mc_addr - 1); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait till command completes */ wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET); sp->m_cast_flg = 1; sp->all_multi_pos = config->max_mc_addr - 1; } else if ((dev->flags & IFF_ALLMULTI) && (sp->m_cast_flg)) { /* Disable all Multicast addresses */ writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr), &bar0->rmac_addr_data0_mem); writeq(RMAC_ADDR_DATA1_MEM_MASK(0x0), &bar0->rmac_addr_data1_mem); val64 = RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait till command completes */ wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET); sp->m_cast_flg = 0; sp->all_multi_pos = 0; } if ((dev->flags & IFF_PROMISC) && (!sp->promisc_flg)) { /* Put the NIC into promiscuous mode */ add = &bar0->mac_cfg; val64 = readq(&bar0->mac_cfg); val64 |= MAC_CFG_RMAC_PROM_ENABLE; writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32)val64, add); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64 >> 32), (add + 4)); if (vlan_tag_strip != 1) { val64 = readq(&bar0->rx_pa_cfg); val64 &= ~RX_PA_CFG_STRIP_VLAN_TAG; writeq(val64, &bar0->rx_pa_cfg); sp->vlan_strip_flag = 0; } val64 = readq(&bar0->mac_cfg); sp->promisc_flg = 1; DBG_PRINT(INFO_DBG, "%s: entered promiscuous mode\n", dev->name); } else if (!(dev->flags & IFF_PROMISC) && (sp->promisc_flg)) { /* Remove the NIC from promiscuous mode */ add = &bar0->mac_cfg; val64 = readq(&bar0->mac_cfg); val64 &= ~MAC_CFG_RMAC_PROM_ENABLE; writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32)val64, add); writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); writel((u32) (val64 >> 32), (add + 4)); if (vlan_tag_strip != 0) { val64 = readq(&bar0->rx_pa_cfg); val64 |= RX_PA_CFG_STRIP_VLAN_TAG; writeq(val64, &bar0->rx_pa_cfg); sp->vlan_strip_flag = 1; } val64 = readq(&bar0->mac_cfg); sp->promisc_flg = 0; DBG_PRINT(INFO_DBG, "%s: left promiscuous mode\n", dev->name); } /* Update individual M_CAST address list */ if ((!sp->m_cast_flg) && netdev_mc_count(dev)) { if (netdev_mc_count(dev) > (config->max_mc_addr - config->max_mac_addr)) { DBG_PRINT(ERR_DBG, "%s: No more Rx filters can be added - " "please enable ALL_MULTI instead\n", dev->name); return; } prev_cnt = sp->mc_addr_count; sp->mc_addr_count = netdev_mc_count(dev); /* Clear out the previous list of Mc in the H/W. */ for (i = 0; i < prev_cnt; i++) { writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr), &bar0->rmac_addr_data0_mem); writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL), &bar0->rmac_addr_data1_mem); val64 = RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET (config->mc_start_offset + i); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait for command completes */ if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET)) { DBG_PRINT(ERR_DBG, "%s: Adding Multicasts failed\n", dev->name); return; } } /* Create the new Rx filter list and update the same in H/W. */ i = 0; netdev_for_each_mc_addr(ha, dev) { mac_addr = 0; for (j = 0; j < ETH_ALEN; j++) { mac_addr |= ha->addr[j]; mac_addr <<= 8; } mac_addr >>= 8; writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr), &bar0->rmac_addr_data0_mem); writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL), &bar0->rmac_addr_data1_mem); val64 = RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET (i + config->mc_start_offset); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait for command completes */ if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET)) { DBG_PRINT(ERR_DBG, "%s: Adding Multicasts failed\n", dev->name); return; } i++; } } } /* read from CAM unicast & multicast addresses and store it in * def_mac_addr structure */ static void do_s2io_store_unicast_mc(struct s2io_nic *sp) { int offset; u64 mac_addr = 0x0; struct config_param *config = &sp->config; /* store unicast & multicast mac addresses */ for (offset = 0; offset < config->max_mc_addr; offset++) { mac_addr = do_s2io_read_unicast_mc(sp, offset); /* if read fails disable the entry */ if (mac_addr == FAILURE) mac_addr = S2IO_DISABLE_MAC_ENTRY; do_s2io_copy_mac_addr(sp, offset, mac_addr); } } /* restore unicast & multicast MAC to CAM from def_mac_addr structure */ static void do_s2io_restore_unicast_mc(struct s2io_nic *sp) { int offset; struct config_param *config = &sp->config; /* restore unicast mac address */ for (offset = 0; offset < config->max_mac_addr; offset++) do_s2io_prog_unicast(sp->dev, sp->def_mac_addr[offset].mac_addr); /* restore multicast mac address */ for (offset = config->mc_start_offset; offset < config->max_mc_addr; offset++) do_s2io_add_mc(sp, sp->def_mac_addr[offset].mac_addr); } /* add a multicast MAC address to CAM */ static int do_s2io_add_mc(struct s2io_nic *sp, u8 *addr) { int i; u64 mac_addr = 0; struct config_param *config = &sp->config; for (i = 0; i < ETH_ALEN; i++) { mac_addr <<= 8; mac_addr |= addr[i]; } if ((0ULL == mac_addr) || (mac_addr == S2IO_DISABLE_MAC_ENTRY)) return SUCCESS; /* check if the multicast mac already preset in CAM */ for (i = config->mc_start_offset; i < config->max_mc_addr; i++) { u64 tmp64; tmp64 = do_s2io_read_unicast_mc(sp, i); if (tmp64 == S2IO_DISABLE_MAC_ENTRY) /* CAM entry is empty */ break; if (tmp64 == mac_addr) return SUCCESS; } if (i == config->max_mc_addr) { DBG_PRINT(ERR_DBG, "CAM full no space left for multicast MAC\n"); return FAILURE; } /* Update the internal structure with this new mac address */ do_s2io_copy_mac_addr(sp, i, mac_addr); return do_s2io_add_mac(sp, mac_addr, i); } /* add MAC address to CAM */ static int do_s2io_add_mac(struct s2io_nic *sp, u64 addr, int off) { u64 val64; struct XENA_dev_config __iomem *bar0 = sp->bar0; writeq(RMAC_ADDR_DATA0_MEM_ADDR(addr), &bar0->rmac_addr_data0_mem); val64 = RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET(off); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait till command completes */ if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET)) { DBG_PRINT(INFO_DBG, "do_s2io_add_mac failed\n"); return FAILURE; } return SUCCESS; } /* deletes a specified unicast/multicast mac entry from CAM */ static int do_s2io_delete_unicast_mc(struct s2io_nic *sp, u64 addr) { int offset; u64 dis_addr = S2IO_DISABLE_MAC_ENTRY, tmp64; struct config_param *config = &sp->config; for (offset = 1; offset < config->max_mc_addr; offset++) { tmp64 = do_s2io_read_unicast_mc(sp, offset); if (tmp64 == addr) { /* disable the entry by writing 0xffffffffffffULL */ if (do_s2io_add_mac(sp, dis_addr, offset) == FAILURE) return FAILURE; /* store the new mac list from CAM */ do_s2io_store_unicast_mc(sp); return SUCCESS; } } DBG_PRINT(ERR_DBG, "MAC address 0x%llx not found in CAM\n", (unsigned long long)addr); return FAILURE; } /* read mac entries from CAM */ static u64 do_s2io_read_unicast_mc(struct s2io_nic *sp, int offset) { u64 tmp64 = 0xffffffffffff0000ULL, val64; struct XENA_dev_config __iomem *bar0 = sp->bar0; /* read mac addr */ val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET(offset); writeq(val64, &bar0->rmac_addr_cmd_mem); /* Wait till command completes */ if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET)) { DBG_PRINT(INFO_DBG, "do_s2io_read_unicast_mc failed\n"); return FAILURE; } tmp64 = readq(&bar0->rmac_addr_data0_mem); return tmp64 >> 16; } /** * s2io_set_mac_addr driver entry point */ static int s2io_set_mac_addr(struct net_device *dev, void *p) { struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); /* store the MAC address in CAM */ return do_s2io_prog_unicast(dev, dev->dev_addr); } /** * do_s2io_prog_unicast - Programs the Xframe mac address * @dev : pointer to the device structure. * @addr: a uchar pointer to the new mac address which is to be set. * Description : This procedure will program the Xframe to receive * frames with new Mac Address * Return value: SUCCESS on success and an appropriate (-)ve integer * as defined in errno.h file on failure. */ static int do_s2io_prog_unicast(struct net_device *dev, u8 *addr) { struct s2io_nic *sp = netdev_priv(dev); register u64 mac_addr = 0, perm_addr = 0; int i; u64 tmp64; struct config_param *config = &sp->config; /* * Set the new MAC address as the new unicast filter and reflect this * change on the device address registered with the OS. It will be * at offset 0. */ for (i = 0; i < ETH_ALEN; i++) { mac_addr <<= 8; mac_addr |= addr[i]; perm_addr <<= 8; perm_addr |= sp->def_mac_addr[0].mac_addr[i]; } /* check if the dev_addr is different than perm_addr */ if (mac_addr == perm_addr) return SUCCESS; /* check if the mac already preset in CAM */ for (i = 1; i < config->max_mac_addr; i++) { tmp64 = do_s2io_read_unicast_mc(sp, i); if (tmp64 == S2IO_DISABLE_MAC_ENTRY) /* CAM entry is empty */ break; if (tmp64 == mac_addr) { DBG_PRINT(INFO_DBG, "MAC addr:0x%llx already present in CAM\n", (unsigned long long)mac_addr); return SUCCESS; } } if (i == config->max_mac_addr) { DBG_PRINT(ERR_DBG, "CAM full no space left for Unicast MAC\n"); return FAILURE; } /* Update the internal structure with this new mac address */ do_s2io_copy_mac_addr(sp, i, mac_addr); return do_s2io_add_mac(sp, mac_addr, i); } /** * s2io_ethtool_sset - Sets different link parameters. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @info: pointer to the structure with parameters given by ethtool to set * link information. * Description: * The function sets different link parameters provided by the user onto * the NIC. * Return value: * 0 on success. */ static int s2io_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info) { struct s2io_nic *sp = netdev_priv(dev); if ((info->autoneg == AUTONEG_ENABLE) || (ethtool_cmd_speed(info) != SPEED_10000) || (info->duplex != DUPLEX_FULL)) return -EINVAL; else { s2io_close(sp->dev); s2io_open(sp->dev); } return 0; } /** * s2io_ethtol_gset - Return link specific information. * @sp : private member of the device structure, pointer to the * s2io_nic structure. * @info : pointer to the structure with parameters given by ethtool * to return link information. * Description: * Returns link specific information like speed, duplex etc.. to ethtool. * Return value : * return 0 on success. */ static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info) { struct s2io_nic *sp = netdev_priv(dev); info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); info->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); info->port = PORT_FIBRE; /* info->transceiver */ info->transceiver = XCVR_EXTERNAL; if (netif_carrier_ok(sp->dev)) { ethtool_cmd_speed_set(info, SPEED_10000); info->duplex = DUPLEX_FULL; } else { ethtool_cmd_speed_set(info, -1); info->duplex = -1; } info->autoneg = AUTONEG_DISABLE; return 0; } /** * s2io_ethtool_gdrvinfo - Returns driver specific information. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @info : pointer to the structure with parameters given by ethtool to * return driver information. * Description: * Returns driver specefic information like name, version etc.. to ethtool. * Return value: * void */ static void s2io_ethtool_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct s2io_nic *sp = netdev_priv(dev); strlcpy(info->driver, s2io_driver_name, sizeof(info->driver)); strlcpy(info->version, s2io_driver_version, sizeof(info->version)); strlcpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info)); info->regdump_len = XENA_REG_SPACE; info->eedump_len = XENA_EEPROM_SPACE; } /** * s2io_ethtool_gregs - dumps the entire space of Xfame into the buffer. * @sp: private member of the device structure, which is a pointer to the * s2io_nic structure. * @regs : pointer to the structure with parameters given by ethtool for * dumping the registers. * @reg_space: The input argumnet into which all the registers are dumped. * Description: * Dumps the entire register space of xFrame NIC into the user given * buffer area. * Return value : * void . */ static void s2io_ethtool_gregs(struct net_device *dev, struct ethtool_regs *regs, void *space) { int i; u64 reg; u8 *reg_space = (u8 *)space; struct s2io_nic *sp = netdev_priv(dev); regs->len = XENA_REG_SPACE; regs->version = sp->pdev->subsystem_device; for (i = 0; i < regs->len; i += 8) { reg = readq(sp->bar0 + i); memcpy((reg_space + i), &reg, 8); } } /* * s2io_set_led - control NIC led */ static void s2io_set_led(struct s2io_nic *sp, bool on) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u16 subid = sp->pdev->subsystem_device; u64 val64; if ((sp->device_type == XFRAME_II_DEVICE) || ((subid & 0xFF) >= 0x07)) { val64 = readq(&bar0->gpio_control); if (on) val64 |= GPIO_CTRL_GPIO_0; else val64 &= ~GPIO_CTRL_GPIO_0; writeq(val64, &bar0->gpio_control); } else { val64 = readq(&bar0->adapter_control); if (on) val64 |= ADAPTER_LED_ON; else val64 &= ~ADAPTER_LED_ON; writeq(val64, &bar0->adapter_control); } } /** * s2io_ethtool_set_led - To physically identify the nic on the system. * @dev : network device * @state: led setting * * Description: Used to physically identify the NIC on the system. * The Link LED will blink for a time specified by the user for * identification. * NOTE: The Link has to be Up to be able to blink the LED. Hence * identification is possible only if it's link is up. */ static int s2io_ethtool_set_led(struct net_device *dev, enum ethtool_phys_id_state state) { struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; u16 subid = sp->pdev->subsystem_device; if ((sp->device_type == XFRAME_I_DEVICE) && ((subid & 0xFF) < 0x07)) { u64 val64 = readq(&bar0->adapter_control); if (!(val64 & ADAPTER_CNTL_EN)) { pr_err("Adapter Link down, cannot blink LED\n"); return -EAGAIN; } } switch (state) { case ETHTOOL_ID_ACTIVE: sp->adapt_ctrl_org = readq(&bar0->gpio_control); return 1; /* cycle on/off once per second */ case ETHTOOL_ID_ON: s2io_set_led(sp, true); break; case ETHTOOL_ID_OFF: s2io_set_led(sp, false); break; case ETHTOOL_ID_INACTIVE: if (CARDS_WITH_FAULTY_LINK_INDICATORS(sp->device_type, subid)) writeq(sp->adapt_ctrl_org, &bar0->gpio_control); } return 0; } static void s2io_ethtool_gringparam(struct net_device *dev, struct ethtool_ringparam *ering) { struct s2io_nic *sp = netdev_priv(dev); int i, tx_desc_count = 0, rx_desc_count = 0; if (sp->rxd_mode == RXD_MODE_1) { ering->rx_max_pending = MAX_RX_DESC_1; ering->rx_jumbo_max_pending = MAX_RX_DESC_1; } else { ering->rx_max_pending = MAX_RX_DESC_2; ering->rx_jumbo_max_pending = MAX_RX_DESC_2; } ering->tx_max_pending = MAX_TX_DESC; for (i = 0; i < sp->config.rx_ring_num; i++) rx_desc_count += sp->config.rx_cfg[i].num_rxd; ering->rx_pending = rx_desc_count; ering->rx_jumbo_pending = rx_desc_count; for (i = 0; i < sp->config.tx_fifo_num; i++) tx_desc_count += sp->config.tx_cfg[i].fifo_len; ering->tx_pending = tx_desc_count; DBG_PRINT(INFO_DBG, "max txds: %d\n", sp->config.max_txds); } /** * s2io_ethtool_getpause_data -Pause frame frame generation and reception. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @ep : pointer to the structure with pause parameters given by ethtool. * Description: * Returns the Pause frame generation and reception capability of the NIC. * Return value: * void */ static void s2io_ethtool_getpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) { u64 val64; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; val64 = readq(&bar0->rmac_pause_cfg); if (val64 & RMAC_PAUSE_GEN_ENABLE) ep->tx_pause = true; if (val64 & RMAC_PAUSE_RX_ENABLE) ep->rx_pause = true; ep->autoneg = false; } /** * s2io_ethtool_setpause_data - set/reset pause frame generation. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @ep : pointer to the structure with pause parameters given by ethtool. * Description: * It can be used to set or reset Pause frame generation or reception * support of the NIC. * Return value: * int, returns 0 on Success */ static int s2io_ethtool_setpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) { u64 val64; struct s2io_nic *sp = netdev_priv(dev); struct XENA_dev_config __iomem *bar0 = sp->bar0; val64 = readq(&bar0->rmac_pause_cfg); if (ep->tx_pause) val64 |= RMAC_PAUSE_GEN_ENABLE; else val64 &= ~RMAC_PAUSE_GEN_ENABLE; if (ep->rx_pause) val64 |= RMAC_PAUSE_RX_ENABLE; else val64 &= ~RMAC_PAUSE_RX_ENABLE; writeq(val64, &bar0->rmac_pause_cfg); return 0; } /** * read_eeprom - reads 4 bytes of data from user given offset. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @off : offset at which the data must be written * @data : Its an output parameter where the data read at the given * offset is stored. * Description: * Will read 4 bytes of data from the user given offset and return the * read data. * NOTE: Will allow to read only part of the EEPROM visible through the * I2C bus. * Return value: * -1 on failure and 0 on success. */ #define S2IO_DEV_ID 5 static int read_eeprom(struct s2io_nic *sp, int off, u64 *data) { int ret = -1; u32 exit_cnt = 0; u64 val64; struct XENA_dev_config __iomem *bar0 = sp->bar0; if (sp->device_type == XFRAME_I_DEVICE) { val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ | I2C_CONTROL_CNTL_START; SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); while (exit_cnt < 5) { val64 = readq(&bar0->i2c_control); if (I2C_CONTROL_CNTL_END(val64)) { *data = I2C_CONTROL_GET_DATA(val64); ret = 0; break; } msleep(50); exit_cnt++; } } if (sp->device_type == XFRAME_II_DEVICE) { val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 | SPI_CONTROL_BYTECNT(0x3) | SPI_CONTROL_CMD(0x3) | SPI_CONTROL_ADDR(off); SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF); val64 |= SPI_CONTROL_REQ; SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF); while (exit_cnt < 5) { val64 = readq(&bar0->spi_control); if (val64 & SPI_CONTROL_NACK) { ret = 1; break; } else if (val64 & SPI_CONTROL_DONE) { *data = readq(&bar0->spi_data); *data &= 0xffffff; ret = 0; break; } msleep(50); exit_cnt++; } } return ret; } /** * write_eeprom - actually writes the relevant part of the data value. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @off : offset at which the data must be written * @data : The data that is to be written * @cnt : Number of bytes of the data that are actually to be written into * the Eeprom. (max of 3) * Description: * Actually writes the relevant part of the data value into the Eeprom * through the I2C bus. * Return value: * 0 on success, -1 on failure. */ static int write_eeprom(struct s2io_nic *sp, int off, u64 data, int cnt) { int exit_cnt = 0, ret = -1; u64 val64; struct XENA_dev_config __iomem *bar0 = sp->bar0; if (sp->device_type == XFRAME_I_DEVICE) { val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA((u32)data) | I2C_CONTROL_CNTL_START; SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); while (exit_cnt < 5) { val64 = readq(&bar0->i2c_control); if (I2C_CONTROL_CNTL_END(val64)) { if (!(val64 & I2C_CONTROL_NACK)) ret = 0; break; } msleep(50); exit_cnt++; } } if (sp->device_type == XFRAME_II_DEVICE) { int write_cnt = (cnt == 8) ? 0 : cnt; writeq(SPI_DATA_WRITE(data, (cnt << 3)), &bar0->spi_data); val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 | SPI_CONTROL_BYTECNT(write_cnt) | SPI_CONTROL_CMD(0x2) | SPI_CONTROL_ADDR(off); SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF); val64 |= SPI_CONTROL_REQ; SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF); while (exit_cnt < 5) { val64 = readq(&bar0->spi_control); if (val64 & SPI_CONTROL_NACK) { ret = 1; break; } else if (val64 & SPI_CONTROL_DONE) { ret = 0; break; } msleep(50); exit_cnt++; } } return ret; } static void s2io_vpd_read(struct s2io_nic *nic) { u8 *vpd_data; u8 data; int i = 0, cnt, len, fail = 0; int vpd_addr = 0x80; struct swStat *swstats = &nic->mac_control.stats_info->sw_stat; if (nic->device_type == XFRAME_II_DEVICE) { strcpy(nic->product_name, "Xframe II 10GbE network adapter"); vpd_addr = 0x80; } else { strcpy(nic->product_name, "Xframe I 10GbE network adapter"); vpd_addr = 0x50; } strcpy(nic->serial_num, "NOT AVAILABLE"); vpd_data = kmalloc(256, GFP_KERNEL); if (!vpd_data) { swstats->mem_alloc_fail_cnt++; return; } swstats->mem_allocated += 256; for (i = 0; i < 256; i += 4) { pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); pci_read_config_byte(nic->pdev, (vpd_addr + 2), &data); pci_write_config_byte(nic->pdev, (vpd_addr + 3), 0); for (cnt = 0; cnt < 5; cnt++) { msleep(2); pci_read_config_byte(nic->pdev, (vpd_addr + 3), &data); if (data == 0x80) break; } if (cnt >= 5) { DBG_PRINT(ERR_DBG, "Read of VPD data failed\n"); fail = 1; break; } pci_read_config_dword(nic->pdev, (vpd_addr + 4), (u32 *)&vpd_data[i]); } if (!fail) { /* read serial number of adapter */ for (cnt = 0; cnt < 252; cnt++) { if ((vpd_data[cnt] == 'S') && (vpd_data[cnt+1] == 'N')) { len = vpd_data[cnt+2]; if (len < min(VPD_STRING_LEN, 256-cnt-2)) { memcpy(nic->serial_num, &vpd_data[cnt + 3], len); memset(nic->serial_num+len, 0, VPD_STRING_LEN-len); break; } } } } if ((!fail) && (vpd_data[1] < VPD_STRING_LEN)) { len = vpd_data[1]; memcpy(nic->product_name, &vpd_data[3], len); nic->product_name[len] = 0; } kfree(vpd_data); swstats->mem_freed += 256; } /** * s2io_ethtool_geeprom - reads the value stored in the Eeprom. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @eeprom : pointer to the user level structure provided by ethtool, * containing all relevant information. * @data_buf : user defined value to be written into Eeprom. * Description: Reads the values stored in the Eeprom at given offset * for a given length. Stores these values int the input argument data * buffer 'data_buf' and returns these to the caller (ethtool.) * Return value: * int 0 on success */ static int s2io_ethtool_geeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 * data_buf) { u32 i, valid; u64 data; struct s2io_nic *sp = netdev_priv(dev); eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16); if ((eeprom->offset + eeprom->len) > (XENA_EEPROM_SPACE)) eeprom->len = XENA_EEPROM_SPACE - eeprom->offset; for (i = 0; i < eeprom->len; i += 4) { if (read_eeprom(sp, (eeprom->offset + i), &data)) { DBG_PRINT(ERR_DBG, "Read of EEPROM failed\n"); return -EFAULT; } valid = INV(data); memcpy((data_buf + i), &valid, 4); } return 0; } /** * s2io_ethtool_seeprom - tries to write the user provided value in Eeprom * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @eeprom : pointer to the user level structure provided by ethtool, * containing all relevant information. * @data_buf ; user defined value to be written into Eeprom. * Description: * Tries to write the user provided value in the Eeprom, at the offset * given by the user. * Return value: * 0 on success, -EFAULT on failure. */ static int s2io_ethtool_seeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data_buf) { int len = eeprom->len, cnt = 0; u64 valid = 0, data; struct s2io_nic *sp = netdev_priv(dev); if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) { DBG_PRINT(ERR_DBG, "ETHTOOL_WRITE_EEPROM Err: " "Magic value is wrong, it is 0x%x should be 0x%x\n", (sp->pdev->vendor | (sp->pdev->device << 16)), eeprom->magic); return -EFAULT; } while (len) { data = (u32)data_buf[cnt] & 0x000000FF; if (data) valid = (u32)(data << 24); else valid = data; if (write_eeprom(sp, (eeprom->offset + cnt), valid, 0)) { DBG_PRINT(ERR_DBG, "ETHTOOL_WRITE_EEPROM Err: " "Cannot write into the specified offset\n"); return -EFAULT; } cnt++; len--; } return 0; } /** * s2io_register_test - reads and writes into all clock domains. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @data : variable that returns the result of each of the test conducted b * by the driver. * Description: * Read and write into all clock domains. The NIC has 3 clock domains, * see that registers in all the three regions are accessible. * Return value: * 0 on success. */ static int s2io_register_test(struct s2io_nic *sp, uint64_t *data) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64 = 0, exp_val; int fail = 0; val64 = readq(&bar0->pif_rd_swapper_fb); if (val64 != 0x123456789abcdefULL) { fail = 1; DBG_PRINT(INFO_DBG, "Read Test level %d fails\n", 1); } val64 = readq(&bar0->rmac_pause_cfg); if (val64 != 0xc000ffff00000000ULL) { fail = 1; DBG_PRINT(INFO_DBG, "Read Test level %d fails\n", 2); } val64 = readq(&bar0->rx_queue_cfg); if (sp->device_type == XFRAME_II_DEVICE) exp_val = 0x0404040404040404ULL; else exp_val = 0x0808080808080808ULL; if (val64 != exp_val) { fail = 1; DBG_PRINT(INFO_DBG, "Read Test level %d fails\n", 3); } val64 = readq(&bar0->xgxs_efifo_cfg); if (val64 != 0x000000001923141EULL) { fail = 1; DBG_PRINT(INFO_DBG, "Read Test level %d fails\n", 4); } val64 = 0x5A5A5A5A5A5A5A5AULL; writeq(val64, &bar0->xmsi_data); val64 = readq(&bar0->xmsi_data); if (val64 != 0x5A5A5A5A5A5A5A5AULL) { fail = 1; DBG_PRINT(ERR_DBG, "Write Test level %d fails\n", 1); } val64 = 0xA5A5A5A5A5A5A5A5ULL; writeq(val64, &bar0->xmsi_data); val64 = readq(&bar0->xmsi_data); if (val64 != 0xA5A5A5A5A5A5A5A5ULL) { fail = 1; DBG_PRINT(ERR_DBG, "Write Test level %d fails\n", 2); } *data = fail; return fail; } /** * s2io_eeprom_test - to verify that EEprom in the xena can be programmed. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @data:variable that returns the result of each of the test conducted by * the driver. * Description: * Verify that EEPROM in the xena can be programmed using I2C_CONTROL * register. * Return value: * 0 on success. */ static int s2io_eeprom_test(struct s2io_nic *sp, uint64_t *data) { int fail = 0; u64 ret_data, org_4F0, org_7F0; u8 saved_4F0 = 0, saved_7F0 = 0; struct net_device *dev = sp->dev; /* Test Write Error at offset 0 */ /* Note that SPI interface allows write access to all areas * of EEPROM. Hence doing all negative testing only for Xframe I. */ if (sp->device_type == XFRAME_I_DEVICE) if (!write_eeprom(sp, 0, 0, 3)) fail = 1; /* Save current values at offsets 0x4F0 and 0x7F0 */ if (!read_eeprom(sp, 0x4F0, &org_4F0)) saved_4F0 = 1; if (!read_eeprom(sp, 0x7F0, &org_7F0)) saved_7F0 = 1; /* Test Write at offset 4f0 */ if (write_eeprom(sp, 0x4F0, 0x012345, 3)) fail = 1; if (read_eeprom(sp, 0x4F0, &ret_data)) fail = 1; if (ret_data != 0x012345) { DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. " "Data written %llx Data read %llx\n", dev->name, (unsigned long long)0x12345, (unsigned long long)ret_data); fail = 1; } /* Reset the EEPROM data go FFFF */ write_eeprom(sp, 0x4F0, 0xFFFFFF, 3); /* Test Write Request Error at offset 0x7c */ if (sp->device_type == XFRAME_I_DEVICE) if (!write_eeprom(sp, 0x07C, 0, 3)) fail = 1; /* Test Write Request at offset 0x7f0 */ if (write_eeprom(sp, 0x7F0, 0x012345, 3)) fail = 1; if (read_eeprom(sp, 0x7F0, &ret_data)) fail = 1; if (ret_data != 0x012345) { DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. " "Data written %llx Data read %llx\n", dev->name, (unsigned long long)0x12345, (unsigned long long)ret_data); fail = 1; } /* Reset the EEPROM data go FFFF */ write_eeprom(sp, 0x7F0, 0xFFFFFF, 3); if (sp->device_type == XFRAME_I_DEVICE) { /* Test Write Error at offset 0x80 */ if (!write_eeprom(sp, 0x080, 0, 3)) fail = 1; /* Test Write Error at offset 0xfc */ if (!write_eeprom(sp, 0x0FC, 0, 3)) fail = 1; /* Test Write Error at offset 0x100 */ if (!write_eeprom(sp, 0x100, 0, 3)) fail = 1; /* Test Write Error at offset 4ec */ if (!write_eeprom(sp, 0x4EC, 0, 3)) fail = 1; } /* Restore values at offsets 0x4F0 and 0x7F0 */ if (saved_4F0) write_eeprom(sp, 0x4F0, org_4F0, 3); if (saved_7F0) write_eeprom(sp, 0x7F0, org_7F0, 3); *data = fail; return fail; } /** * s2io_bist_test - invokes the MemBist test of the card . * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @data:variable that returns the result of each of the test conducted by * the driver. * Description: * This invokes the MemBist test of the card. We give around * 2 secs time for the Test to complete. If it's still not complete * within this peiod, we consider that the test failed. * Return value: * 0 on success and -1 on failure. */ static int s2io_bist_test(struct s2io_nic *sp, uint64_t *data) { u8 bist = 0; int cnt = 0, ret = -1; pci_read_config_byte(sp->pdev, PCI_BIST, &bist); bist |= PCI_BIST_START; pci_write_config_word(sp->pdev, PCI_BIST, bist); while (cnt < 20) { pci_read_config_byte(sp->pdev, PCI_BIST, &bist); if (!(bist & PCI_BIST_START)) { *data = (bist & PCI_BIST_CODE_MASK); ret = 0; break; } msleep(100); cnt++; } return ret; } /** * s2io-link_test - verifies the link state of the nic * @sp ; private member of the device structure, which is a pointer to the * s2io_nic structure. * @data: variable that returns the result of each of the test conducted by * the driver. * Description: * The function verifies the link state of the NIC and updates the input * argument 'data' appropriately. * Return value: * 0 on success. */ static int s2io_link_test(struct s2io_nic *sp, uint64_t *data) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64; val64 = readq(&bar0->adapter_status); if (!(LINK_IS_UP(val64))) *data = 1; else *data = 0; return *data; } /** * s2io_rldram_test - offline test for access to the RldRam chip on the NIC * @sp - private member of the device structure, which is a pointer to the * s2io_nic structure. * @data - variable that returns the result of each of the test * conducted by the driver. * Description: * This is one of the offline test that tests the read and write * access to the RldRam chip on the NIC. * Return value: * 0 on success. */ static int s2io_rldram_test(struct s2io_nic *sp, uint64_t *data) { struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64; int cnt, iteration = 0, test_fail = 0; val64 = readq(&bar0->adapter_control); val64 &= ~ADAPTER_ECC_EN; writeq(val64, &bar0->adapter_control); val64 = readq(&bar0->mc_rldram_test_ctrl); val64 |= MC_RLDRAM_TEST_MODE; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF); val64 = readq(&bar0->mc_rldram_mrs); val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF); val64 |= MC_RLDRAM_MRS_ENABLE; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF); while (iteration < 2) { val64 = 0x55555555aaaa0000ULL; if (iteration == 1) val64 ^= 0xFFFFFFFFFFFF0000ULL; writeq(val64, &bar0->mc_rldram_test_d0); val64 = 0xaaaa5a5555550000ULL; if (iteration == 1) val64 ^= 0xFFFFFFFFFFFF0000ULL; writeq(val64, &bar0->mc_rldram_test_d1); val64 = 0x55aaaaaaaa5a0000ULL; if (iteration == 1) val64 ^= 0xFFFFFFFFFFFF0000ULL; writeq(val64, &bar0->mc_rldram_test_d2); val64 = (u64) (0x0000003ffffe0100ULL); writeq(val64, &bar0->mc_rldram_test_add); val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_WRITE | MC_RLDRAM_TEST_GO; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF); for (cnt = 0; cnt < 5; cnt++) { val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; msleep(200); } if (cnt == 5) break; val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF); for (cnt = 0; cnt < 5; cnt++) { val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; msleep(500); } if (cnt == 5) break; val64 = readq(&bar0->mc_rldram_test_ctrl); if (!(val64 & MC_RLDRAM_TEST_PASS)) test_fail = 1; iteration++; } *data = test_fail; /* Bring the adapter out of test mode */ SPECIAL_REG_WRITE(0, &bar0->mc_rldram_test_ctrl, LF); return test_fail; } /** * s2io_ethtool_test - conducts 6 tsets to determine the health of card. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @ethtest : pointer to a ethtool command specific structure that will be * returned to the user. * @data : variable that returns the result of each of the test * conducted by the driver. * Description: * This function conducts 6 tests ( 4 offline and 2 online) to determine * the health of the card. * Return value: * void */ static void s2io_ethtool_test(struct net_device *dev, struct ethtool_test *ethtest, uint64_t *data) { struct s2io_nic *sp = netdev_priv(dev); int orig_state = netif_running(sp->dev); if (ethtest->flags == ETH_TEST_FL_OFFLINE) { /* Offline Tests. */ if (orig_state) s2io_close(sp->dev); if (s2io_register_test(sp, &data[0])) ethtest->flags |= ETH_TEST_FL_FAILED; s2io_reset(sp); if (s2io_rldram_test(sp, &data[3])) ethtest->flags |= ETH_TEST_FL_FAILED; s2io_reset(sp); if (s2io_eeprom_test(sp, &data[1])) ethtest->flags |= ETH_TEST_FL_FAILED; if (s2io_bist_test(sp, &data[4])) ethtest->flags |= ETH_TEST_FL_FAILED; if (orig_state) s2io_open(sp->dev); data[2] = 0; } else { /* Online Tests. */ if (!orig_state) { DBG_PRINT(ERR_DBG, "%s: is not up, cannot run test\n", dev->name); data[0] = -1; data[1] = -1; data[2] = -1; data[3] = -1; data[4] = -1; } if (s2io_link_test(sp, &data[2])) ethtest->flags |= ETH_TEST_FL_FAILED; data[0] = 0; data[1] = 0; data[3] = 0; data[4] = 0; } } static void s2io_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *estats, u64 *tmp_stats) { int i = 0, k; struct s2io_nic *sp = netdev_priv(dev); struct stat_block *stats = sp->mac_control.stats_info; struct swStat *swstats = &stats->sw_stat; struct xpakStat *xstats = &stats->xpak_stat; s2io_updt_stats(sp); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_frms_oflow) << 32 | le32_to_cpu(stats->tmac_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_data_octets_oflow) << 32 | le32_to_cpu(stats->tmac_data_octets); tmp_stats[i++] = le64_to_cpu(stats->tmac_drop_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_mcst_frms_oflow) << 32 | le32_to_cpu(stats->tmac_mcst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_bcst_frms_oflow) << 32 | le32_to_cpu(stats->tmac_bcst_frms); tmp_stats[i++] = le64_to_cpu(stats->tmac_pause_ctrl_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_ttl_octets_oflow) << 32 | le32_to_cpu(stats->tmac_ttl_octets); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_ucst_frms_oflow) << 32 | le32_to_cpu(stats->tmac_ucst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_nucst_frms_oflow) << 32 | le32_to_cpu(stats->tmac_nucst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_any_err_frms_oflow) << 32 | le32_to_cpu(stats->tmac_any_err_frms); tmp_stats[i++] = le64_to_cpu(stats->tmac_ttl_less_fb_octets); tmp_stats[i++] = le64_to_cpu(stats->tmac_vld_ip_octets); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_vld_ip_oflow) << 32 | le32_to_cpu(stats->tmac_vld_ip); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_drop_ip_oflow) << 32 | le32_to_cpu(stats->tmac_drop_ip); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_icmp_oflow) << 32 | le32_to_cpu(stats->tmac_icmp); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_rst_tcp_oflow) << 32 | le32_to_cpu(stats->tmac_rst_tcp); tmp_stats[i++] = le64_to_cpu(stats->tmac_tcp); tmp_stats[i++] = (u64)le32_to_cpu(stats->tmac_udp_oflow) << 32 | le32_to_cpu(stats->tmac_udp); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_vld_frms_oflow) << 32 | le32_to_cpu(stats->rmac_vld_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_data_octets_oflow) << 32 | le32_to_cpu(stats->rmac_data_octets); tmp_stats[i++] = le64_to_cpu(stats->rmac_fcs_err_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_drop_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_vld_mcst_frms_oflow) << 32 | le32_to_cpu(stats->rmac_vld_mcst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_vld_bcst_frms_oflow) << 32 | le32_to_cpu(stats->rmac_vld_bcst_frms); tmp_stats[i++] = le32_to_cpu(stats->rmac_in_rng_len_err_frms); tmp_stats[i++] = le32_to_cpu(stats->rmac_out_rng_len_err_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_long_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_pause_ctrl_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_unsup_ctrl_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_ttl_octets_oflow) << 32 | le32_to_cpu(stats->rmac_ttl_octets); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_accepted_ucst_frms_oflow) << 32 | le32_to_cpu(stats->rmac_accepted_ucst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_accepted_nucst_frms_oflow) << 32 | le32_to_cpu(stats->rmac_accepted_nucst_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_discarded_frms_oflow) << 32 | le32_to_cpu(stats->rmac_discarded_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_drop_events_oflow) << 32 | le32_to_cpu(stats->rmac_drop_events); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_less_fb_octets); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_usized_frms_oflow) << 32 | le32_to_cpu(stats->rmac_usized_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_osized_frms_oflow) << 32 | le32_to_cpu(stats->rmac_osized_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_frag_frms_oflow) << 32 | le32_to_cpu(stats->rmac_frag_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_jabber_frms_oflow) << 32 | le32_to_cpu(stats->rmac_jabber_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_64_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_65_127_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_128_255_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_256_511_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_512_1023_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_1024_1518_frms); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_ip_oflow) << 32 | le32_to_cpu(stats->rmac_ip); tmp_stats[i++] = le64_to_cpu(stats->rmac_ip_octets); tmp_stats[i++] = le32_to_cpu(stats->rmac_hdr_err_ip); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_drop_ip_oflow) << 32 | le32_to_cpu(stats->rmac_drop_ip); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_icmp_oflow) << 32 | le32_to_cpu(stats->rmac_icmp); tmp_stats[i++] = le64_to_cpu(stats->rmac_tcp); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_udp_oflow) << 32 | le32_to_cpu(stats->rmac_udp); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_err_drp_udp_oflow) << 32 | le32_to_cpu(stats->rmac_err_drp_udp); tmp_stats[i++] = le64_to_cpu(stats->rmac_xgmii_err_sym); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q0); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q1); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q2); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q3); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q4); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q5); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q6); tmp_stats[i++] = le64_to_cpu(stats->rmac_frms_q7); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q0); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q1); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q2); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q3); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q4); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q5); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q6); tmp_stats[i++] = le16_to_cpu(stats->rmac_full_q7); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_pause_cnt_oflow) << 32 | le32_to_cpu(stats->rmac_pause_cnt); tmp_stats[i++] = le64_to_cpu(stats->rmac_xgmii_data_err_cnt); tmp_stats[i++] = le64_to_cpu(stats->rmac_xgmii_ctrl_err_cnt); tmp_stats[i++] = (u64)le32_to_cpu(stats->rmac_accepted_ip_oflow) << 32 | le32_to_cpu(stats->rmac_accepted_ip); tmp_stats[i++] = le32_to_cpu(stats->rmac_err_tcp); tmp_stats[i++] = le32_to_cpu(stats->rd_req_cnt); tmp_stats[i++] = le32_to_cpu(stats->new_rd_req_cnt); tmp_stats[i++] = le32_to_cpu(stats->new_rd_req_rtry_cnt); tmp_stats[i++] = le32_to_cpu(stats->rd_rtry_cnt); tmp_stats[i++] = le32_to_cpu(stats->wr_rtry_rd_ack_cnt); tmp_stats[i++] = le32_to_cpu(stats->wr_req_cnt); tmp_stats[i++] = le32_to_cpu(stats->new_wr_req_cnt); tmp_stats[i++] = le32_to_cpu(stats->new_wr_req_rtry_cnt); tmp_stats[i++] = le32_to_cpu(stats->wr_rtry_cnt); tmp_stats[i++] = le32_to_cpu(stats->wr_disc_cnt); tmp_stats[i++] = le32_to_cpu(stats->rd_rtry_wr_ack_cnt); tmp_stats[i++] = le32_to_cpu(stats->txp_wr_cnt); tmp_stats[i++] = le32_to_cpu(stats->txd_rd_cnt); tmp_stats[i++] = le32_to_cpu(stats->txd_wr_cnt); tmp_stats[i++] = le32_to_cpu(stats->rxd_rd_cnt); tmp_stats[i++] = le32_to_cpu(stats->rxd_wr_cnt); tmp_stats[i++] = le32_to_cpu(stats->txf_rd_cnt); tmp_stats[i++] = le32_to_cpu(stats->rxf_wr_cnt); /* Enhanced statistics exist only for Hercules */ if (sp->device_type == XFRAME_II_DEVICE) { tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_1519_4095_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_4096_8191_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_8192_max_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_ttl_gt_max_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_osized_alt_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_jabber_alt_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_gt_max_alt_frms); tmp_stats[i++] = le64_to_cpu(stats->rmac_vlan_frms); tmp_stats[i++] = le32_to_cpu(stats->rmac_len_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_fcs_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_pf_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_da_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_red_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_rts_discard); tmp_stats[i++] = le32_to_cpu(stats->rmac_ingm_full_discard); tmp_stats[i++] = le32_to_cpu(stats->link_fault_cnt); } tmp_stats[i++] = 0; tmp_stats[i++] = swstats->single_ecc_errs; tmp_stats[i++] = swstats->double_ecc_errs; tmp_stats[i++] = swstats->parity_err_cnt; tmp_stats[i++] = swstats->serious_err_cnt; tmp_stats[i++] = swstats->soft_reset_cnt; tmp_stats[i++] = swstats->fifo_full_cnt; for (k = 0; k < MAX_RX_RINGS; k++) tmp_stats[i++] = swstats->ring_full_cnt[k]; tmp_stats[i++] = xstats->alarm_transceiver_temp_high; tmp_stats[i++] = xstats->alarm_transceiver_temp_low; tmp_stats[i++] = xstats->alarm_laser_bias_current_high; tmp_stats[i++] = xstats->alarm_laser_bias_current_low; tmp_stats[i++] = xstats->alarm_laser_output_power_high; tmp_stats[i++] = xstats->alarm_laser_output_power_low; tmp_stats[i++] = xstats->warn_transceiver_temp_high; tmp_stats[i++] = xstats->warn_transceiver_temp_low; tmp_stats[i++] = xstats->warn_laser_bias_current_high; tmp_stats[i++] = xstats->warn_laser_bias_current_low; tmp_stats[i++] = xstats->warn_laser_output_power_high; tmp_stats[i++] = xstats->warn_laser_output_power_low; tmp_stats[i++] = swstats->clubbed_frms_cnt; tmp_stats[i++] = swstats->sending_both; tmp_stats[i++] = swstats->outof_sequence_pkts; tmp_stats[i++] = swstats->flush_max_pkts; if (swstats->num_aggregations) { u64 tmp = swstats->sum_avg_pkts_aggregated; int count = 0; /* * Since 64-bit divide does not work on all platforms, * do repeated subtraction. */ while (tmp >= swstats->num_aggregations) { tmp -= swstats->num_aggregations; count++; } tmp_stats[i++] = count; } else tmp_stats[i++] = 0; tmp_stats[i++] = swstats->mem_alloc_fail_cnt; tmp_stats[i++] = swstats->pci_map_fail_cnt; tmp_stats[i++] = swstats->watchdog_timer_cnt; tmp_stats[i++] = swstats->mem_allocated; tmp_stats[i++] = swstats->mem_freed; tmp_stats[i++] = swstats->link_up_cnt; tmp_stats[i++] = swstats->link_down_cnt; tmp_stats[i++] = swstats->link_up_time; tmp_stats[i++] = swstats->link_down_time; tmp_stats[i++] = swstats->tx_buf_abort_cnt; tmp_stats[i++] = swstats->tx_desc_abort_cnt; tmp_stats[i++] = swstats->tx_parity_err_cnt; tmp_stats[i++] = swstats->tx_link_loss_cnt; tmp_stats[i++] = swstats->tx_list_proc_err_cnt; tmp_stats[i++] = swstats->rx_parity_err_cnt; tmp_stats[i++] = swstats->rx_abort_cnt; tmp_stats[i++] = swstats->rx_parity_abort_cnt; tmp_stats[i++] = swstats->rx_rda_fail_cnt; tmp_stats[i++] = swstats->rx_unkn_prot_cnt; tmp_stats[i++] = swstats->rx_fcs_err_cnt; tmp_stats[i++] = swstats->rx_buf_size_err_cnt; tmp_stats[i++] = swstats->rx_rxd_corrupt_cnt; tmp_stats[i++] = swstats->rx_unkn_err_cnt; tmp_stats[i++] = swstats->tda_err_cnt; tmp_stats[i++] = swstats->pfc_err_cnt; tmp_stats[i++] = swstats->pcc_err_cnt; tmp_stats[i++] = swstats->tti_err_cnt; tmp_stats[i++] = swstats->tpa_err_cnt; tmp_stats[i++] = swstats->sm_err_cnt; tmp_stats[i++] = swstats->lso_err_cnt; tmp_stats[i++] = swstats->mac_tmac_err_cnt; tmp_stats[i++] = swstats->mac_rmac_err_cnt; tmp_stats[i++] = swstats->xgxs_txgxs_err_cnt; tmp_stats[i++] = swstats->xgxs_rxgxs_err_cnt; tmp_stats[i++] = swstats->rc_err_cnt; tmp_stats[i++] = swstats->prc_pcix_err_cnt; tmp_stats[i++] = swstats->rpa_err_cnt; tmp_stats[i++] = swstats->rda_err_cnt; tmp_stats[i++] = swstats->rti_err_cnt; tmp_stats[i++] = swstats->mc_err_cnt; } static int s2io_ethtool_get_regs_len(struct net_device *dev) { return XENA_REG_SPACE; } static int s2io_get_eeprom_len(struct net_device *dev) { return XENA_EEPROM_SPACE; } static int s2io_get_sset_count(struct net_device *dev, int sset) { struct s2io_nic *sp = netdev_priv(dev); switch (sset) { case ETH_SS_TEST: return S2IO_TEST_LEN; case ETH_SS_STATS: switch (sp->device_type) { case XFRAME_I_DEVICE: return XFRAME_I_STAT_LEN; case XFRAME_II_DEVICE: return XFRAME_II_STAT_LEN; default: return 0; } default: return -EOPNOTSUPP; } } static void s2io_ethtool_get_strings(struct net_device *dev, u32 stringset, u8 *data) { int stat_size = 0; struct s2io_nic *sp = netdev_priv(dev); switch (stringset) { case ETH_SS_TEST: memcpy(data, s2io_gstrings, S2IO_STRINGS_LEN); break; case ETH_SS_STATS: stat_size = sizeof(ethtool_xena_stats_keys); memcpy(data, &ethtool_xena_stats_keys, stat_size); if (sp->device_type == XFRAME_II_DEVICE) { memcpy(data + stat_size, &ethtool_enhanced_stats_keys, sizeof(ethtool_enhanced_stats_keys)); stat_size += sizeof(ethtool_enhanced_stats_keys); } memcpy(data + stat_size, &ethtool_driver_stats_keys, sizeof(ethtool_driver_stats_keys)); } } static int s2io_set_features(struct net_device *dev, netdev_features_t features) { struct s2io_nic *sp = netdev_priv(dev); netdev_features_t changed = (features ^ dev->features) & NETIF_F_LRO; if (changed && netif_running(dev)) { int rc; s2io_stop_all_tx_queue(sp); s2io_card_down(sp); dev->features = features; rc = s2io_card_up(sp); if (rc) s2io_reset(sp); else s2io_start_all_tx_queue(sp); return rc ? rc : 1; } return 0; } static const struct ethtool_ops netdev_ethtool_ops = { .get_settings = s2io_ethtool_gset, .set_settings = s2io_ethtool_sset, .get_drvinfo = s2io_ethtool_gdrvinfo, .get_regs_len = s2io_ethtool_get_regs_len, .get_regs = s2io_ethtool_gregs, .get_link = ethtool_op_get_link, .get_eeprom_len = s2io_get_eeprom_len, .get_eeprom = s2io_ethtool_geeprom, .set_eeprom = s2io_ethtool_seeprom, .get_ringparam = s2io_ethtool_gringparam, .get_pauseparam = s2io_ethtool_getpause_data, .set_pauseparam = s2io_ethtool_setpause_data, .self_test = s2io_ethtool_test, .get_strings = s2io_ethtool_get_strings, .set_phys_id = s2io_ethtool_set_led, .get_ethtool_stats = s2io_get_ethtool_stats, .get_sset_count = s2io_get_sset_count, }; /** * s2io_ioctl - Entry point for the Ioctl * @dev : Device pointer. * @ifr : An IOCTL specefic structure, that can contain a pointer to * a proprietary structure used to pass information to the driver. * @cmd : This is used to distinguish between the different commands that * can be passed to the IOCTL functions. * Description: * Currently there are no special functionality supported in IOCTL, hence * function always return EOPNOTSUPPORTED */ static int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { return -EOPNOTSUPP; } /** * s2io_change_mtu - entry point to change MTU size for the device. * @dev : device pointer. * @new_mtu : the new MTU size for the device. * Description: A driver entry point to change MTU size for the device. * Before changing the MTU the device must be stopped. * Return value: * 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ static int s2io_change_mtu(struct net_device *dev, int new_mtu) { struct s2io_nic *sp = netdev_priv(dev); int ret = 0; if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) { DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n", dev->name); return -EPERM; } dev->mtu = new_mtu; if (netif_running(dev)) { s2io_stop_all_tx_queue(sp); s2io_card_down(sp); ret = s2io_card_up(sp); if (ret) { DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", __func__); return ret; } s2io_wake_all_tx_queue(sp); } else { /* Device is down */ struct XENA_dev_config __iomem *bar0 = sp->bar0; u64 val64 = new_mtu; writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len); } return ret; } /** * s2io_set_link - Set the LInk status * @data: long pointer to device private structue * Description: Sets the link status for the adapter */ static void s2io_set_link(struct work_struct *work) { struct s2io_nic *nic = container_of(work, struct s2io_nic, set_link_task); struct net_device *dev = nic->dev; struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64; u16 subid; rtnl_lock(); if (!netif_running(dev)) goto out_unlock; if (test_and_set_bit(__S2IO_STATE_LINK_TASK, &(nic->state))) { /* The card is being reset, no point doing anything */ goto out_unlock; } subid = nic->pdev->subsystem_device; if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) { /* * Allow a small delay for the NICs self initiated * cleanup to complete. */ msleep(100); } val64 = readq(&bar0->adapter_status); if (LINK_IS_UP(val64)) { if (!(readq(&bar0->adapter_control) & ADAPTER_CNTL_EN)) { if (verify_xena_quiescence(nic)) { val64 = readq(&bar0->adapter_control); val64 |= ADAPTER_CNTL_EN; writeq(val64, &bar0->adapter_control); if (CARDS_WITH_FAULTY_LINK_INDICATORS( nic->device_type, subid)) { val64 = readq(&bar0->gpio_control); val64 |= GPIO_CTRL_GPIO_0; writeq(val64, &bar0->gpio_control); val64 = readq(&bar0->gpio_control); } else { val64 |= ADAPTER_LED_ON; writeq(val64, &bar0->adapter_control); } nic->device_enabled_once = true; } else { DBG_PRINT(ERR_DBG, "%s: Error: device is not Quiescent\n", dev->name); s2io_stop_all_tx_queue(nic); } } val64 = readq(&bar0->adapter_control); val64 |= ADAPTER_LED_ON; writeq(val64, &bar0->adapter_control); s2io_link(nic, LINK_UP); } else { if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type, subid)) { val64 = readq(&bar0->gpio_control); val64 &= ~GPIO_CTRL_GPIO_0; writeq(val64, &bar0->gpio_control); val64 = readq(&bar0->gpio_control); } /* turn off LED */ val64 = readq(&bar0->adapter_control); val64 = val64 & (~ADAPTER_LED_ON); writeq(val64, &bar0->adapter_control); s2io_link(nic, LINK_DOWN); } clear_bit(__S2IO_STATE_LINK_TASK, &(nic->state)); out_unlock: rtnl_unlock(); } static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, struct buffAdd *ba, struct sk_buff **skb, u64 *temp0, u64 *temp1, u64 *temp2, int size) { struct net_device *dev = sp->dev; struct swStat *stats = &sp->mac_control.stats_info->sw_stat; if ((sp->rxd_mode == RXD_MODE_1) && (rxdp->Host_Control == 0)) { struct RxD1 *rxdp1 = (struct RxD1 *)rxdp; /* allocate skb */ if (*skb) { DBG_PRINT(INFO_DBG, "SKB is not NULL\n"); /* * As Rx frame are not going to be processed, * using same mapped address for the Rxd * buffer pointer */ rxdp1->Buffer0_ptr = *temp0; } else { *skb = netdev_alloc_skb(dev, size); if (!(*skb)) { DBG_PRINT(INFO_DBG, "%s: Out of memory to allocate %s\n", dev->name, "1 buf mode SKBs"); stats->mem_alloc_fail_cnt++; return -ENOMEM ; } stats->mem_allocated += (*skb)->truesize; /* storing the mapped addr in a temp variable * such it will be used for next rxd whose * Host Control is NULL */ rxdp1->Buffer0_ptr = *temp0 = pci_map_single(sp->pdev, (*skb)->data, size - NET_IP_ALIGN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(sp->pdev, rxdp1->Buffer0_ptr)) goto memalloc_failed; rxdp->Host_Control = (unsigned long) (*skb); } } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) { struct RxD3 *rxdp3 = (struct RxD3 *)rxdp; /* Two buffer Mode */ if (*skb) { rxdp3->Buffer2_ptr = *temp2; rxdp3->Buffer0_ptr = *temp0; rxdp3->Buffer1_ptr = *temp1; } else { *skb = netdev_alloc_skb(dev, size); if (!(*skb)) { DBG_PRINT(INFO_DBG, "%s: Out of memory to allocate %s\n", dev->name, "2 buf mode SKBs"); stats->mem_alloc_fail_cnt++; return -ENOMEM; } stats->mem_allocated += (*skb)->truesize; rxdp3->Buffer2_ptr = *temp2 = pci_map_single(sp->pdev, (*skb)->data, dev->mtu + 4, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(sp->pdev, rxdp3->Buffer2_ptr)) goto memalloc_failed; rxdp3->Buffer0_ptr = *temp0 = pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(sp->pdev, rxdp3->Buffer0_ptr)) { pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer2_ptr, dev->mtu + 4, PCI_DMA_FROMDEVICE); goto memalloc_failed; } rxdp->Host_Control = (unsigned long) (*skb); /* Buffer-1 will be dummy buffer not used */ rxdp3->Buffer1_ptr = *temp1 = pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(sp->pdev, rxdp3->Buffer1_ptr)) { pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer0_ptr, BUF0_LEN, PCI_DMA_FROMDEVICE); pci_unmap_single(sp->pdev, (dma_addr_t)rxdp3->Buffer2_ptr, dev->mtu + 4, PCI_DMA_FROMDEVICE); goto memalloc_failed; } } } return 0; memalloc_failed: stats->pci_map_fail_cnt++; stats->mem_freed += (*skb)->truesize; dev_kfree_skb(*skb); return -ENOMEM; } static void set_rxd_buffer_size(struct s2io_nic *sp, struct RxD_t *rxdp, int size) { struct net_device *dev = sp->dev; if (sp->rxd_mode == RXD_MODE_1) { rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); } else if (sp->rxd_mode == RXD_MODE_3B) { rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); rxdp->Control_2 |= SET_BUFFER2_SIZE_3(dev->mtu + 4); } } static int rxd_owner_bit_reset(struct s2io_nic *sp) { int i, j, k, blk_cnt = 0, size; struct config_param *config = &sp->config; struct mac_info *mac_control = &sp->mac_control; struct net_device *dev = sp->dev; struct RxD_t *rxdp = NULL; struct sk_buff *skb = NULL; struct buffAdd *ba = NULL; u64 temp0_64 = 0, temp1_64 = 0, temp2_64 = 0; /* Calculate the size based on ring mode */ size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE + HEADER_802_2_SIZE + HEADER_SNAP_SIZE; if (sp->rxd_mode == RXD_MODE_1) size += NET_IP_ALIGN; else if (sp->rxd_mode == RXD_MODE_3B) size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4; for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; blk_cnt = rx_cfg->num_rxd / (rxd_count[sp->rxd_mode] + 1); for (j = 0; j < blk_cnt; j++) { for (k = 0; k < rxd_count[sp->rxd_mode]; k++) { rxdp = ring->rx_blocks[j].rxds[k].virt_addr; if (sp->rxd_mode == RXD_MODE_3B) ba = &ring->ba[j][k]; if (set_rxd_buffer_pointer(sp, rxdp, ba, &skb, (u64 *)&temp0_64, (u64 *)&temp1_64, (u64 *)&temp2_64, size) == -ENOMEM) { return 0; } set_rxd_buffer_size(sp, rxdp, size); wmb(); /* flip the Ownership bit to Hardware */ rxdp->Control_1 |= RXD_OWN_XENA; } } } return 0; } static int s2io_add_isr(struct s2io_nic *sp) { int ret = 0; struct net_device *dev = sp->dev; int err = 0; if (sp->config.intr_type == MSI_X) ret = s2io_enable_msi_x(sp); if (ret) { DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name); sp->config.intr_type = INTA; } /* * Store the values of the MSIX table in * the struct s2io_nic structure */ store_xmsi_data(sp); /* After proper initialization of H/W, register ISR */ if (sp->config.intr_type == MSI_X) { int i, msix_rx_cnt = 0; for (i = 0; i < sp->num_entries; i++) { if (sp->s2io_entries[i].in_use == MSIX_FLG) { if (sp->s2io_entries[i].type == MSIX_RING_TYPE) { sprintf(sp->desc[i], "%s:MSI-X-%d-RX", dev->name, i); err = request_irq(sp->entries[i].vector, s2io_msix_ring_handle, 0, sp->desc[i], sp->s2io_entries[i].arg); } else if (sp->s2io_entries[i].type == MSIX_ALARM_TYPE) { sprintf(sp->desc[i], "%s:MSI-X-%d-TX", dev->name, i); err = request_irq(sp->entries[i].vector, s2io_msix_fifo_handle, 0, sp->desc[i], sp->s2io_entries[i].arg); } /* if either data or addr is zero print it. */ if (!(sp->msix_info[i].addr && sp->msix_info[i].data)) { DBG_PRINT(ERR_DBG, "%s @Addr:0x%llx Data:0x%llx\n", sp->desc[i], (unsigned long long) sp->msix_info[i].addr, (unsigned long long) ntohl(sp->msix_info[i].data)); } else msix_rx_cnt++; if (err) { remove_msix_isr(sp); DBG_PRINT(ERR_DBG, "%s:MSI-X-%d registration " "failed\n", dev->name, i); DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name); sp->config.intr_type = INTA; break; } sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS; } } if (!err) { pr_info("MSI-X-RX %d entries enabled\n", --msix_rx_cnt); DBG_PRINT(INFO_DBG, "MSI-X-TX entries enabled through alarm vector\n"); } } if (sp->config.intr_type == INTA) { err = request_irq((int)sp->pdev->irq, s2io_isr, IRQF_SHARED, sp->name, dev); if (err) { DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n", dev->name); return -1; } } return 0; } static void s2io_rem_isr(struct s2io_nic *sp) { if (sp->config.intr_type == MSI_X) remove_msix_isr(sp); else remove_inta_isr(sp); } static void do_s2io_card_down(struct s2io_nic *sp, int do_io) { int cnt = 0; struct XENA_dev_config __iomem *bar0 = sp->bar0; register u64 val64 = 0; struct config_param *config; config = &sp->config; if (!is_s2io_card_up(sp)) return; del_timer_sync(&sp->alarm_timer); /* If s2io_set_link task is executing, wait till it completes. */ while (test_and_set_bit(__S2IO_STATE_LINK_TASK, &(sp->state))) msleep(50); clear_bit(__S2IO_STATE_CARD_UP, &sp->state); /* Disable napi */ if (sp->config.napi) { int off = 0; if (config->intr_type == MSI_X) { for (; off < sp->config.rx_ring_num; off++) napi_disable(&sp->mac_control.rings[off].napi); } else napi_disable(&sp->napi); } /* disable Tx and Rx traffic on the NIC */ if (do_io) stop_nic(sp); s2io_rem_isr(sp); /* stop the tx queue, indicate link down */ s2io_link(sp, LINK_DOWN); /* Check if the device is Quiescent and then Reset the NIC */ while (do_io) { /* As per the HW requirement we need to replenish the * receive buffer to avoid the ring bump. Since there is * no intention of processing the Rx frame at this pointwe are * just setting the ownership bit of rxd in Each Rx * ring to HW and set the appropriate buffer size * based on the ring mode */ rxd_owner_bit_reset(sp); val64 = readq(&bar0->adapter_status); if (verify_xena_quiescence(sp)) { if (verify_pcc_quiescent(sp, sp->device_enabled_once)) break; } msleep(50); cnt++; if (cnt == 10) { DBG_PRINT(ERR_DBG, "Device not Quiescent - " "adapter status reads 0x%llx\n", (unsigned long long)val64); break; } } if (do_io) s2io_reset(sp); /* Free all Tx buffers */ free_tx_buffers(sp); /* Free all Rx buffers */ free_rx_buffers(sp); clear_bit(__S2IO_STATE_LINK_TASK, &(sp->state)); } static void s2io_card_down(struct s2io_nic *sp) { do_s2io_card_down(sp, 1); } static int s2io_card_up(struct s2io_nic *sp) { int i, ret = 0; struct config_param *config; struct mac_info *mac_control; struct net_device *dev = (struct net_device *)sp->dev; u16 interruptible; /* Initialize the H/W I/O registers */ ret = init_nic(sp); if (ret != 0) { DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n", dev->name); if (ret != -EIO) s2io_reset(sp); return ret; } /* * Initializing the Rx buffers. For now we are considering only 1 * Rx ring and initializing buffers into 30 Rx blocks */ config = &sp->config; mac_control = &sp->mac_control; for (i = 0; i < config->rx_ring_num; i++) { struct ring_info *ring = &mac_control->rings[i]; ring->mtu = dev->mtu; ring->lro = !!(dev->features & NETIF_F_LRO); ret = fill_rx_buffers(sp, ring, 1); if (ret) { DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n", dev->name); s2io_reset(sp); free_rx_buffers(sp); return -ENOMEM; } DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i, ring->rx_bufs_left); } /* Initialise napi */ if (config->napi) { if (config->intr_type == MSI_X) { for (i = 0; i < sp->config.rx_ring_num; i++) napi_enable(&sp->mac_control.rings[i].napi); } else { napi_enable(&sp->napi); } } /* Maintain the state prior to the open */ if (sp->promisc_flg) sp->promisc_flg = 0; if (sp->m_cast_flg) { sp->m_cast_flg = 0; sp->all_multi_pos = 0; } /* Setting its receive mode */ s2io_set_multicast(dev); if (dev->features & NETIF_F_LRO) { /* Initialize max aggregatable pkts per session based on MTU */ sp->lro_max_aggr_per_sess = ((1<<16) - 1) / dev->mtu; /* Check if we can use (if specified) user provided value */ if (lro_max_pkts < sp->lro_max_aggr_per_sess) sp->lro_max_aggr_per_sess = lro_max_pkts; } /* Enable Rx Traffic and interrupts on the NIC */ if (start_nic(sp)) { DBG_PRINT(ERR_DBG, "%s: Starting NIC failed\n", dev->name); s2io_reset(sp); free_rx_buffers(sp); return -ENODEV; } /* Add interrupt service routine */ if (s2io_add_isr(sp) != 0) { if (sp->config.intr_type == MSI_X) s2io_rem_isr(sp); s2io_reset(sp); free_rx_buffers(sp); return -ENODEV; } S2IO_TIMER_CONF(sp->alarm_timer, s2io_alarm_handle, sp, (HZ/2)); set_bit(__S2IO_STATE_CARD_UP, &sp->state); /* Enable select interrupts */ en_dis_err_alarms(sp, ENA_ALL_INTRS, ENABLE_INTRS); if (sp->config.intr_type != INTA) { interruptible = TX_TRAFFIC_INTR | TX_PIC_INTR; en_dis_able_nic_intrs(sp, interruptible, ENABLE_INTRS); } else { interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR; interruptible |= TX_PIC_INTR; en_dis_able_nic_intrs(sp, interruptible, ENABLE_INTRS); } return 0; } /** * s2io_restart_nic - Resets the NIC. * @data : long pointer to the device private structure * Description: * This function is scheduled to be run by the s2io_tx_watchdog * function after 0.5 secs to reset the NIC. The idea is to reduce * the run time of the watch dog routine which is run holding a * spin lock. */ static void s2io_restart_nic(struct work_struct *work) { struct s2io_nic *sp = container_of(work, struct s2io_nic, rst_timer_task); struct net_device *dev = sp->dev; rtnl_lock(); if (!netif_running(dev)) goto out_unlock; s2io_card_down(sp); if (s2io_card_up(sp)) { DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", dev->name); } s2io_wake_all_tx_queue(sp); DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n", dev->name); out_unlock: rtnl_unlock(); } /** * s2io_tx_watchdog - Watchdog for transmit side. * @dev : Pointer to net device structure * Description: * This function is triggered if the Tx Queue is stopped * for a pre-defined amount of time when the Interface is still up. * If the Interface is jammed in such a situation, the hardware is * reset (by s2io_close) and restarted again (by s2io_open) to * overcome any problem that might have been caused in the hardware. * Return value: * void */ static void s2io_tx_watchdog(struct net_device *dev) { struct s2io_nic *sp = netdev_priv(dev); struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; if (netif_carrier_ok(dev)) { swstats->watchdog_timer_cnt++; schedule_work(&sp->rst_timer_task); swstats->soft_reset_cnt++; } } /** * rx_osm_handler - To perform some OS related operations on SKB. * @sp: private member of the device structure,pointer to s2io_nic structure. * @skb : the socket buffer pointer. * @len : length of the packet * @cksum : FCS checksum of the frame. * @ring_no : the ring from which this RxD was extracted. * Description: * This function is called by the Rx interrupt serivce routine to perform * some OS related operations on the SKB before passing it to the upper * layers. It mainly checks if the checksum is OK, if so adds it to the * SKBs cksum variable, increments the Rx packet count and passes the SKB * to the upper layer. If the checksum is wrong, it increments the Rx * packet error count, frees the SKB and returns error. * Return value: * SUCCESS on success and -1 on failure. */ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) { struct s2io_nic *sp = ring_data->nic; struct net_device *dev = (struct net_device *)ring_data->dev; struct sk_buff *skb = (struct sk_buff *) ((unsigned long)rxdp->Host_Control); int ring_no = ring_data->ring_no; u16 l3_csum, l4_csum; unsigned long long err = rxdp->Control_1 & RXD_T_CODE; struct lro *uninitialized_var(lro); u8 err_mask; struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; skb->dev = dev; if (err) { /* Check for parity error */ if (err & 0x1) swstats->parity_err_cnt++; err_mask = err >> 48; switch (err_mask) { case 1: swstats->rx_parity_err_cnt++; break; case 2: swstats->rx_abort_cnt++; break; case 3: swstats->rx_parity_abort_cnt++; break; case 4: swstats->rx_rda_fail_cnt++; break; case 5: swstats->rx_unkn_prot_cnt++; break; case 6: swstats->rx_fcs_err_cnt++; break; case 7: swstats->rx_buf_size_err_cnt++; break; case 8: swstats->rx_rxd_corrupt_cnt++; break; case 15: swstats->rx_unkn_err_cnt++; break; } /* * Drop the packet if bad transfer code. Exception being * 0x5, which could be due to unsupported IPv6 extension header. * In this case, we let stack handle the packet. * Note that in this case, since checksum will be incorrect, * stack will validate the same. */ if (err_mask != 0x5) { DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%x\n", dev->name, err_mask); dev->stats.rx_crc_errors++; swstats->mem_freed += skb->truesize; dev_kfree_skb(skb); ring_data->rx_bufs_left -= 1; rxdp->Host_Control = 0; return 0; } } rxdp->Host_Control = 0; if (sp->rxd_mode == RXD_MODE_1) { int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); skb_put(skb, len); } else if (sp->rxd_mode == RXD_MODE_3B) { int get_block = ring_data->rx_curr_get_info.block_index; int get_off = ring_data->rx_curr_get_info.offset; int buf0_len = RXD_GET_BUFFER0_SIZE_3(rxdp->Control_2); int buf2_len = RXD_GET_BUFFER2_SIZE_3(rxdp->Control_2); unsigned char *buff = skb_push(skb, buf0_len); struct buffAdd *ba = &ring_data->ba[get_block][get_off]; memcpy(buff, ba->ba_0, buf0_len); skb_put(skb, buf2_len); } if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && ((!ring_data->lro) || (ring_data->lro && (!(rxdp->Control_1 & RXD_FRAME_IP_FRAG)))) && (dev->features & NETIF_F_RXCSUM)) { l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1); l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1); if ((l3_csum == L3_CKSUM_OK) && (l4_csum == L4_CKSUM_OK)) { /* * NIC verifies if the Checksum of the received * frame is Ok or not and accordingly returns * a flag in the RxD. */ skb->ip_summed = CHECKSUM_UNNECESSARY; if (ring_data->lro) { u32 tcp_len = 0; u8 *tcp; int ret = 0; ret = s2io_club_tcp_session(ring_data, skb->data, &tcp, &tcp_len, &lro, rxdp, sp); switch (ret) { case 3: /* Begin anew */ lro->parent = skb; goto aggregate; case 1: /* Aggregate */ lro_append_pkt(sp, lro, skb, tcp_len); goto aggregate; case 4: /* Flush session */ lro_append_pkt(sp, lro, skb, tcp_len); queue_rx_frame(lro->parent, lro->vlan_tag); clear_lro_session(lro); swstats->flush_max_pkts++; goto aggregate; case 2: /* Flush both */ lro->parent->data_len = lro->frags_len; swstats->sending_both++; queue_rx_frame(lro->parent, lro->vlan_tag); clear_lro_session(lro); goto send_up; case 0: /* sessions exceeded */ case -1: /* non-TCP or not L2 aggregatable */ case 5: /* * First pkt in session not * L3/L4 aggregatable */ break; default: DBG_PRINT(ERR_DBG, "%s: Samadhana!!\n", __func__); BUG(); } } } else { /* * Packet with erroneous checksum, let the * upper layers deal with it. */ skb_checksum_none_assert(skb); } } else skb_checksum_none_assert(skb); swstats->mem_freed += skb->truesize; send_up: skb_record_rx_queue(skb, ring_no); queue_rx_frame(skb, RXD_GET_VLAN_TAG(rxdp->Control_2)); aggregate: sp->mac_control.rings[ring_no].rx_bufs_left -= 1; return SUCCESS; } /** * s2io_link - stops/starts the Tx queue. * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * @link : inidicates whether link is UP/DOWN. * Description: * This function stops/starts the Tx queue depending on whether the link * status of the NIC is is down or up. This is called by the Alarm * interrupt handler whenever a link change interrupt comes up. * Return value: * void. */ static void s2io_link(struct s2io_nic *sp, int link) { struct net_device *dev = (struct net_device *)sp->dev; struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; if (link != sp->last_link_state) { init_tti(sp, link); if (link == LINK_DOWN) { DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); s2io_stop_all_tx_queue(sp); netif_carrier_off(dev); if (swstats->link_up_cnt) swstats->link_up_time = jiffies - sp->start_time; swstats->link_down_cnt++; } else { DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); if (swstats->link_down_cnt) swstats->link_down_time = jiffies - sp->start_time; swstats->link_up_cnt++; netif_carrier_on(dev); s2io_wake_all_tx_queue(sp); } } sp->last_link_state = link; sp->start_time = jiffies; } /** * s2io_init_pci -Initialization of PCI and PCI-X configuration registers . * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. * Description: * This function initializes a few of the PCI and PCI-X configuration registers * with recommended values. * Return value: * void */ static void s2io_init_pci(struct s2io_nic *sp) { u16 pci_cmd = 0, pcix_cmd = 0; /* Enable Data Parity Error Recovery in PCI-X command register. */ pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pcix_cmd)); pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, (pcix_cmd | 1)); pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pcix_cmd)); /* Set the PErr Response bit in PCI command register. */ pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd); pci_write_config_word(sp->pdev, PCI_COMMAND, (pci_cmd | PCI_COMMAND_PARITY)); pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd); } static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type, u8 *dev_multiq) { int i; if ((tx_fifo_num > MAX_TX_FIFOS) || (tx_fifo_num < 1)) { DBG_PRINT(ERR_DBG, "Requested number of tx fifos " "(%d) not supported\n", tx_fifo_num); if (tx_fifo_num < 1) tx_fifo_num = 1; else tx_fifo_num = MAX_TX_FIFOS; DBG_PRINT(ERR_DBG, "Default to %d tx fifos\n", tx_fifo_num); } if (multiq) *dev_multiq = multiq; if (tx_steering_type && (1 == tx_fifo_num)) { if (tx_steering_type != TX_DEFAULT_STEERING) DBG_PRINT(ERR_DBG, "Tx steering is not supported with " "one fifo. Disabling Tx steering.\n"); tx_steering_type = NO_STEERING; } if ((tx_steering_type < NO_STEERING) || (tx_steering_type > TX_DEFAULT_STEERING)) { DBG_PRINT(ERR_DBG, "Requested transmit steering not supported\n"); DBG_PRINT(ERR_DBG, "Disabling transmit steering\n"); tx_steering_type = NO_STEERING; } if (rx_ring_num > MAX_RX_RINGS) { DBG_PRINT(ERR_DBG, "Requested number of rx rings not supported\n"); DBG_PRINT(ERR_DBG, "Default to %d rx rings\n", MAX_RX_RINGS); rx_ring_num = MAX_RX_RINGS; } if ((*dev_intr_type != INTA) && (*dev_intr_type != MSI_X)) { DBG_PRINT(ERR_DBG, "Wrong intr_type requested. " "Defaulting to INTA\n"); *dev_intr_type = INTA; } if ((*dev_intr_type == MSI_X) && ((pdev->device != PCI_DEVICE_ID_HERC_WIN) && (pdev->device != PCI_DEVICE_ID_HERC_UNI))) { DBG_PRINT(ERR_DBG, "Xframe I does not support MSI_X. " "Defaulting to INTA\n"); *dev_intr_type = INTA; } if ((rx_ring_mode != 1) && (rx_ring_mode != 2)) { DBG_PRINT(ERR_DBG, "Requested ring mode not supported\n"); DBG_PRINT(ERR_DBG, "Defaulting to 1-buffer mode\n"); rx_ring_mode = 1; } for (i = 0; i < MAX_RX_RINGS; i++) if (rx_ring_sz[i] > MAX_RX_BLOCKS_PER_RING) { DBG_PRINT(ERR_DBG, "Requested rx ring size not " "supported\nDefaulting to %d\n", MAX_RX_BLOCKS_PER_RING); rx_ring_sz[i] = MAX_RX_BLOCKS_PER_RING; } return SUCCESS; } /** * rts_ds_steer - Receive traffic steering based on IPv4 or IPv6 TOS * or Traffic class respectively. * @nic: device private variable * Description: The function configures the receive steering to * desired receive ring. * Return Value: SUCCESS on success and * '-1' on failure (endian settings incorrect). */ static int rts_ds_steer(struct s2io_nic *nic, u8 ds_codepoint, u8 ring) { struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; if (ds_codepoint > 63) return FAILURE; val64 = RTS_DS_MEM_DATA(ring); writeq(val64, &bar0->rts_ds_mem_data); val64 = RTS_DS_MEM_CTRL_WE | RTS_DS_MEM_CTRL_STROBE_NEW_CMD | RTS_DS_MEM_CTRL_OFFSET(ds_codepoint); writeq(val64, &bar0->rts_ds_mem_ctrl); return wait_for_cmd_complete(&bar0->rts_ds_mem_ctrl, RTS_DS_MEM_CTRL_STROBE_CMD_BEING_EXECUTED, S2IO_BIT_RESET); } static const struct net_device_ops s2io_netdev_ops = { .ndo_open = s2io_open, .ndo_stop = s2io_close, .ndo_get_stats = s2io_get_stats, .ndo_start_xmit = s2io_xmit, .ndo_validate_addr = eth_validate_addr, .ndo_set_rx_mode = s2io_set_multicast, .ndo_do_ioctl = s2io_ioctl, .ndo_set_mac_address = s2io_set_mac_addr, .ndo_change_mtu = s2io_change_mtu, .ndo_set_features = s2io_set_features, .ndo_tx_timeout = s2io_tx_watchdog, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = s2io_netpoll, #endif }; /** * s2io_init_nic - Initialization of the adapter . * @pdev : structure containing the PCI related information of the device. * @pre: List of PCI devices supported by the driver listed in s2io_tbl. * Description: * The function initializes an adapter identified by the pci_dec structure. * All OS related initialization including memory and device structure and * initlaization of the device private variable is done. Also the swapper * control register is initialized to enable read and write into the I/O * registers of the device. * Return value: * returns 0 on success and negative on failure. */ static int __devinit s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) { struct s2io_nic *sp; struct net_device *dev; int i, j, ret; int dma_flag = false; u32 mac_up, mac_down; u64 val64 = 0, tmp64 = 0; struct XENA_dev_config __iomem *bar0 = NULL; u16 subid; struct config_param *config; struct mac_info *mac_control; int mode; u8 dev_intr_type = intr_type; u8 dev_multiq = 0; ret = s2io_verify_parm(pdev, &dev_intr_type, &dev_multiq); if (ret) return ret; ret = pci_enable_device(pdev); if (ret) { DBG_PRINT(ERR_DBG, "%s: pci_enable_device failed\n", __func__); return ret; } if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { DBG_PRINT(INIT_DBG, "%s: Using 64bit DMA\n", __func__); dma_flag = true; if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) { DBG_PRINT(ERR_DBG, "Unable to obtain 64bit DMA " "for consistent allocations\n"); pci_disable_device(pdev); return -ENOMEM; } } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { DBG_PRINT(INIT_DBG, "%s: Using 32bit DMA\n", __func__); } else { pci_disable_device(pdev); return -ENOMEM; } ret = pci_request_regions(pdev, s2io_driver_name); if (ret) { DBG_PRINT(ERR_DBG, "%s: Request Regions failed - %x\n", __func__, ret); pci_disable_device(pdev); return -ENODEV; } if (dev_multiq) dev = alloc_etherdev_mq(sizeof(struct s2io_nic), tx_fifo_num); else dev = alloc_etherdev(sizeof(struct s2io_nic)); if (dev == NULL) { pci_disable_device(pdev); pci_release_regions(pdev); return -ENODEV; } pci_set_master(pdev); pci_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev); /* Private member variable initialized to s2io NIC structure */ sp = netdev_priv(dev); sp->dev = dev; sp->pdev = pdev; sp->high_dma_flag = dma_flag; sp->device_enabled_once = false; if (rx_ring_mode == 1) sp->rxd_mode = RXD_MODE_1; if (rx_ring_mode == 2) sp->rxd_mode = RXD_MODE_3B; sp->config.intr_type = dev_intr_type; if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) || (pdev->device == PCI_DEVICE_ID_HERC_UNI)) sp->device_type = XFRAME_II_DEVICE; else sp->device_type = XFRAME_I_DEVICE; /* Initialize some PCI/PCI-X fields of the NIC. */ s2io_init_pci(sp); /* * Setting the device configuration parameters. * Most of these parameters can be specified by the user during * module insertion as they are module loadable parameters. If * these parameters are not not specified during load time, they * are initialized with default values. */ config = &sp->config; mac_control = &sp->mac_control; config->napi = napi; config->tx_steering_type = tx_steering_type; /* Tx side parameters. */ if (config->tx_steering_type == TX_PRIORITY_STEERING) config->tx_fifo_num = MAX_TX_FIFOS; else config->tx_fifo_num = tx_fifo_num; /* Initialize the fifos used for tx steering */ if (config->tx_fifo_num < 5) { if (config->tx_fifo_num == 1) sp->total_tcp_fifos = 1; else sp->total_tcp_fifos = config->tx_fifo_num - 1; sp->udp_fifo_idx = config->tx_fifo_num - 1; sp->total_udp_fifos = 1; sp->other_fifo_idx = sp->total_tcp_fifos - 1; } else { sp->total_tcp_fifos = (tx_fifo_num - FIFO_UDP_MAX_NUM - FIFO_OTHER_MAX_NUM); sp->udp_fifo_idx = sp->total_tcp_fifos; sp->total_udp_fifos = FIFO_UDP_MAX_NUM; sp->other_fifo_idx = sp->udp_fifo_idx + FIFO_UDP_MAX_NUM; } config->multiq = dev_multiq; for (i = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; tx_cfg->fifo_len = tx_fifo_len[i]; tx_cfg->fifo_priority = i; } /* mapping the QoS priority to the configured fifos */ for (i = 0; i < MAX_TX_FIFOS; i++) config->fifo_mapping[i] = fifo_map[config->tx_fifo_num - 1][i]; /* map the hashing selector table to the configured fifos */ for (i = 0; i < config->tx_fifo_num; i++) sp->fifo_selector[i] = fifo_selector[i]; config->tx_intr_type = TXD_INT_TYPE_UTILZ; for (i = 0; i < config->tx_fifo_num; i++) { struct tx_fifo_config *tx_cfg = &config->tx_cfg[i]; tx_cfg->f_no_snoop = (NO_SNOOP_TXD | NO_SNOOP_TXD_BUFFER); if (tx_cfg->fifo_len < 65) { config->tx_intr_type = TXD_INT_TYPE_PER_LIST; break; } } /* + 2 because one Txd for skb->data and one Txd for UFO */ config->max_txds = MAX_SKB_FRAGS + 2; /* Rx side parameters. */ config->rx_ring_num = rx_ring_num; for (i = 0; i < config->rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; struct ring_info *ring = &mac_control->rings[i]; rx_cfg->num_rxd = rx_ring_sz[i] * (rxd_count[sp->rxd_mode] + 1); rx_cfg->ring_priority = i; ring->rx_bufs_left = 0; ring->rxd_mode = sp->rxd_mode; ring->rxd_count = rxd_count[sp->rxd_mode]; ring->pdev = sp->pdev; ring->dev = sp->dev; } for (i = 0; i < rx_ring_num; i++) { struct rx_ring_config *rx_cfg = &config->rx_cfg[i]; rx_cfg->ring_org = RING_ORG_BUFF1; rx_cfg->f_no_snoop = (NO_SNOOP_RXD | NO_SNOOP_RXD_BUFFER); } /* Setting Mac Control parameters */ mac_control->rmac_pause_time = rmac_pause_time; mac_control->mc_pause_threshold_q0q3 = mc_pause_threshold_q0q3; mac_control->mc_pause_threshold_q4q7 = mc_pause_threshold_q4q7; /* initialize the shared memory used by the NIC and the host */ if (init_shared_mem(sp)) { DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", dev->name); ret = -ENOMEM; goto mem_alloc_failed; } sp->bar0 = pci_ioremap_bar(pdev, 0); if (!sp->bar0) { DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem1\n", dev->name); ret = -ENOMEM; goto bar0_remap_failed; } sp->bar1 = pci_ioremap_bar(pdev, 2); if (!sp->bar1) { DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem2\n", dev->name); ret = -ENOMEM; goto bar1_remap_failed; } dev->irq = pdev->irq; dev->base_addr = (unsigned long)sp->bar0; /* Initializing the BAR1 address as the start of the FIFO pointer. */ for (j = 0; j < MAX_TX_FIFOS; j++) { mac_control->tx_FIFO_start[j] = sp->bar1 + (j * 0x00020000); } /* Driver entry points */ dev->netdev_ops = &s2io_netdev_ops; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_RXCSUM | NETIF_F_LRO; dev->features |= dev->hw_features | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; if (sp->device_type & XFRAME_II_DEVICE) { dev->hw_features |= NETIF_F_UFO; if (ufo) dev->features |= NETIF_F_UFO; } if (sp->high_dma_flag == true) dev->features |= NETIF_F_HIGHDMA; dev->watchdog_timeo = WATCH_DOG_TIMEOUT; INIT_WORK(&sp->rst_timer_task, s2io_restart_nic); INIT_WORK(&sp->set_link_task, s2io_set_link); pci_save_state(sp->pdev); /* Setting swapper control on the NIC, for proper reset operation */ if (s2io_set_swapper(sp)) { DBG_PRINT(ERR_DBG, "%s: swapper settings are wrong\n", dev->name); ret = -EAGAIN; goto set_swap_failed; } /* Verify if the Herc works on the slot its placed into */ if (sp->device_type & XFRAME_II_DEVICE) { mode = s2io_verify_pci_mode(sp); if (mode < 0) { DBG_PRINT(ERR_DBG, "%s: Unsupported PCI bus mode\n", __func__); ret = -EBADSLT; goto set_swap_failed; } } if (sp->config.intr_type == MSI_X) { sp->num_entries = config->rx_ring_num + 1; ret = s2io_enable_msi_x(sp); if (!ret) { ret = s2io_test_msi(sp); /* rollback MSI-X, will re-enable during add_isr() */ remove_msix_isr(sp); } if (ret) { DBG_PRINT(ERR_DBG, "MSI-X requested but failed to enable\n"); sp->config.intr_type = INTA; } } if (config->intr_type == MSI_X) { for (i = 0; i < config->rx_ring_num ; i++) { struct ring_info *ring = &mac_control->rings[i]; netif_napi_add(dev, &ring->napi, s2io_poll_msix, 64); } } else { netif_napi_add(dev, &sp->napi, s2io_poll_inta, 64); } /* Not needed for Herc */ if (sp->device_type & XFRAME_I_DEVICE) { /* * Fix for all "FFs" MAC address problems observed on * Alpha platforms */ fix_mac_address(sp); s2io_reset(sp); } /* * MAC address initialization. * For now only one mac address will be read and used. */ bar0 = sp->bar0; val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | RMAC_ADDR_CMD_MEM_OFFSET(0 + S2IO_MAC_ADDR_START_OFFSET); writeq(val64, &bar0->rmac_addr_cmd_mem); wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem, RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING, S2IO_BIT_RESET); tmp64 = readq(&bar0->rmac_addr_data0_mem); mac_down = (u32)tmp64; mac_up = (u32) (tmp64 >> 32); sp->def_mac_addr[0].mac_addr[3] = (u8) (mac_up); sp->def_mac_addr[0].mac_addr[2] = (u8) (mac_up >> 8); sp->def_mac_addr[0].mac_addr[1] = (u8) (mac_up >> 16); sp->def_mac_addr[0].mac_addr[0] = (u8) (mac_up >> 24); sp->def_mac_addr[0].mac_addr[5] = (u8) (mac_down >> 16); sp->def_mac_addr[0].mac_addr[4] = (u8) (mac_down >> 24); /* Set the factory defined MAC address initially */ dev->addr_len = ETH_ALEN; memcpy(dev->dev_addr, sp->def_mac_addr, ETH_ALEN); memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN); /* initialize number of multicast & unicast MAC entries variables */ if (sp->device_type == XFRAME_I_DEVICE) { config->max_mc_addr = S2IO_XENA_MAX_MC_ADDRESSES; config->max_mac_addr = S2IO_XENA_MAX_MAC_ADDRESSES; config->mc_start_offset = S2IO_XENA_MC_ADDR_START_OFFSET; } else if (sp->device_type == XFRAME_II_DEVICE) { config->max_mc_addr = S2IO_HERC_MAX_MC_ADDRESSES; config->max_mac_addr = S2IO_HERC_MAX_MAC_ADDRESSES; config->mc_start_offset = S2IO_HERC_MC_ADDR_START_OFFSET; } /* store mac addresses from CAM to s2io_nic structure */ do_s2io_store_unicast_mc(sp); /* Configure MSIX vector for number of rings configured plus one */ if ((sp->device_type == XFRAME_II_DEVICE) && (config->intr_type == MSI_X)) sp->num_entries = config->rx_ring_num + 1; /* Store the values of the MSIX table in the s2io_nic structure */ store_xmsi_data(sp); /* reset Nic and bring it to known state */ s2io_reset(sp); /* * Initialize link state flags * and the card state parameter */ sp->state = 0; /* Initialize spinlocks */ for (i = 0; i < sp->config.tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; spin_lock_init(&fifo->tx_lock); } /* * SXE-002: Configure link and activity LED to init state * on driver load. */ subid = sp->pdev->subsystem_device; if ((subid & 0xFF) >= 0x07) { val64 = readq(&bar0->gpio_control); val64 |= 0x0000800000000000ULL; writeq(val64, &bar0->gpio_control); val64 = 0x0411040400000000ULL; writeq(val64, (void __iomem *)bar0 + 0x2700); val64 = readq(&bar0->gpio_control); } sp->rx_csum = 1; /* Rx chksum verify enabled by default */ if (register_netdev(dev)) { DBG_PRINT(ERR_DBG, "Device registration failed\n"); ret = -ENODEV; goto register_failed; } s2io_vpd_read(sp); DBG_PRINT(ERR_DBG, "Copyright(c) 2002-2010 Exar Corp.\n"); DBG_PRINT(ERR_DBG, "%s: Neterion %s (rev %d)\n", dev->name, sp->product_name, pdev->revision); DBG_PRINT(ERR_DBG, "%s: Driver version %s\n", dev->name, s2io_driver_version); DBG_PRINT(ERR_DBG, "%s: MAC Address: %pM\n", dev->name, dev->dev_addr); DBG_PRINT(ERR_DBG, "Serial number: %s\n", sp->serial_num); if (sp->device_type & XFRAME_II_DEVICE) { mode = s2io_print_pci_mode(sp); if (mode < 0) { ret = -EBADSLT; unregister_netdev(dev); goto set_swap_failed; } } switch (sp->rxd_mode) { case RXD_MODE_1: DBG_PRINT(ERR_DBG, "%s: 1-Buffer receive mode enabled\n", dev->name); break; case RXD_MODE_3B: DBG_PRINT(ERR_DBG, "%s: 2-Buffer receive mode enabled\n", dev->name); break; } switch (sp->config.napi) { case 0: DBG_PRINT(ERR_DBG, "%s: NAPI disabled\n", dev->name); break; case 1: DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name); break; } DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name, sp->config.tx_fifo_num); DBG_PRINT(ERR_DBG, "%s: Using %d Rx ring(s)\n", dev->name, sp->config.rx_ring_num); switch (sp->config.intr_type) { case INTA: DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name); break; case MSI_X: DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI-X\n", dev->name); break; } if (sp->config.multiq) { for (i = 0; i < sp->config.tx_fifo_num; i++) { struct fifo_info *fifo = &mac_control->fifos[i]; fifo->multiq = config->multiq; } DBG_PRINT(ERR_DBG, "%s: Multiqueue support enabled\n", dev->name); } else DBG_PRINT(ERR_DBG, "%s: Multiqueue support disabled\n", dev->name); switch (sp->config.tx_steering_type) { case NO_STEERING: DBG_PRINT(ERR_DBG, "%s: No steering enabled for transmit\n", dev->name); break; case TX_PRIORITY_STEERING: DBG_PRINT(ERR_DBG, "%s: Priority steering enabled for transmit\n", dev->name); break; case TX_DEFAULT_STEERING: DBG_PRINT(ERR_DBG, "%s: Default steering enabled for transmit\n", dev->name); } DBG_PRINT(ERR_DBG, "%s: Large receive offload enabled\n", dev->name); if (ufo) DBG_PRINT(ERR_DBG, "%s: UDP Fragmentation Offload(UFO) enabled\n", dev->name); /* Initialize device name */ sprintf(sp->name, "%s Neterion %s", dev->name, sp->product_name); if (vlan_tag_strip) sp->vlan_strip_flag = 1; else sp->vlan_strip_flag = 0; /* * Make Link state as off at this point, when the Link change * interrupt comes the state will be automatically changed to * the right state. */ netif_carrier_off(dev); return 0; register_failed: set_swap_failed: iounmap(sp->bar1); bar1_remap_failed: iounmap(sp->bar0); bar0_remap_failed: mem_alloc_failed: free_shared_mem(sp); pci_disable_device(pdev); pci_release_regions(pdev); pci_set_drvdata(pdev, NULL); free_netdev(dev); return ret; } /** * s2io_rem_nic - Free the PCI device * @pdev: structure containing the PCI related information of the device. * Description: This function is called by the Pci subsystem to release a * PCI device and free up all resource held up by the device. This could * be in response to a Hot plug event or when the driver is to be removed * from memory. */ static void __devexit s2io_rem_nic(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct s2io_nic *sp; if (dev == NULL) { DBG_PRINT(ERR_DBG, "Driver Data is NULL!!\n"); return; } sp = netdev_priv(dev); cancel_work_sync(&sp->rst_timer_task); cancel_work_sync(&sp->set_link_task); unregister_netdev(dev); free_shared_mem(sp); iounmap(sp->bar0); iounmap(sp->bar1); pci_release_regions(pdev); pci_set_drvdata(pdev, NULL); free_netdev(dev); pci_disable_device(pdev); } /** * s2io_starter - Entry point for the driver * Description: This function is the entry point for the driver. It verifies * the module loadable parameters and initializes PCI configuration space. */ static int __init s2io_starter(void) { return pci_register_driver(&s2io_driver); } /** * s2io_closer - Cleanup routine for the driver * Description: This function is the cleanup routine for the driver. It unregist * ers the driver. */ static __exit void s2io_closer(void) { pci_unregister_driver(&s2io_driver); DBG_PRINT(INIT_DBG, "cleanup done\n"); } module_init(s2io_starter); module_exit(s2io_closer); static int check_L2_lro_capable(u8 *buffer, struct iphdr **ip, struct tcphdr **tcp, struct RxD_t *rxdp, struct s2io_nic *sp) { int ip_off; u8 l2_type = (u8)((rxdp->Control_1 >> 37) & 0x7), ip_len; if (!(rxdp->Control_1 & RXD_FRAME_PROTO_TCP)) { DBG_PRINT(INIT_DBG, "%s: Non-TCP frames not supported for LRO\n", __func__); return -1; } /* Checking for DIX type or DIX type with VLAN */ if ((l2_type == 0) || (l2_type == 4)) { ip_off = HEADER_ETHERNET_II_802_3_SIZE; /* * If vlan stripping is disabled and the frame is VLAN tagged, * shift the offset by the VLAN header size bytes. */ if ((!sp->vlan_strip_flag) && (rxdp->Control_1 & RXD_FRAME_VLAN_TAG)) ip_off += HEADER_VLAN_SIZE; } else { /* LLC, SNAP etc are considered non-mergeable */ return -1; } *ip = (struct iphdr *)((u8 *)buffer + ip_off); ip_len = (u8)((*ip)->ihl); ip_len <<= 2; *tcp = (struct tcphdr *)((unsigned long)*ip + ip_len); return 0; } static int check_for_socket_match(struct lro *lro, struct iphdr *ip, struct tcphdr *tcp) { DBG_PRINT(INFO_DBG, "%s: Been here...\n", __func__); if ((lro->iph->saddr != ip->saddr) || (lro->iph->daddr != ip->daddr) || (lro->tcph->source != tcp->source) || (lro->tcph->dest != tcp->dest)) return -1; return 0; } static inline int get_l4_pyld_length(struct iphdr *ip, struct tcphdr *tcp) { return ntohs(ip->tot_len) - (ip->ihl << 2) - (tcp->doff << 2); } static void initiate_new_session(struct lro *lro, u8 *l2h, struct iphdr *ip, struct tcphdr *tcp, u32 tcp_pyld_len, u16 vlan_tag) { DBG_PRINT(INFO_DBG, "%s: Been here...\n", __func__); lro->l2h = l2h; lro->iph = ip; lro->tcph = tcp; lro->tcp_next_seq = tcp_pyld_len + ntohl(tcp->seq); lro->tcp_ack = tcp->ack_seq; lro->sg_num = 1; lro->total_len = ntohs(ip->tot_len); lro->frags_len = 0; lro->vlan_tag = vlan_tag; /* * Check if we saw TCP timestamp. * Other consistency checks have already been done. */ if (tcp->doff == 8) { __be32 *ptr; ptr = (__be32 *)(tcp+1); lro->saw_ts = 1; lro->cur_tsval = ntohl(*(ptr+1)); lro->cur_tsecr = *(ptr+2); } lro->in_use = 1; } static void update_L3L4_header(struct s2io_nic *sp, struct lro *lro) { struct iphdr *ip = lro->iph; struct tcphdr *tcp = lro->tcph; __sum16 nchk; struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; DBG_PRINT(INFO_DBG, "%s: Been here...\n", __func__); /* Update L3 header */ ip->tot_len = htons(lro->total_len); ip->check = 0; nchk = ip_fast_csum((u8 *)lro->iph, ip->ihl); ip->check = nchk; /* Update L4 header */ tcp->ack_seq = lro->tcp_ack; tcp->window = lro->window; /* Update tsecr field if this session has timestamps enabled */ if (lro->saw_ts) { __be32 *ptr = (__be32 *)(tcp + 1); *(ptr+2) = lro->cur_tsecr; } /* Update counters required for calculation of * average no. of packets aggregated. */ swstats->sum_avg_pkts_aggregated += lro->sg_num; swstats->num_aggregations++; } static void aggregate_new_rx(struct lro *lro, struct iphdr *ip, struct tcphdr *tcp, u32 l4_pyld) { DBG_PRINT(INFO_DBG, "%s: Been here...\n", __func__); lro->total_len += l4_pyld; lro->frags_len += l4_pyld; lro->tcp_next_seq += l4_pyld; lro->sg_num++; /* Update ack seq no. and window ad(from this pkt) in LRO object */ lro->tcp_ack = tcp->ack_seq; lro->window = tcp->window; if (lro->saw_ts) { __be32 *ptr; /* Update tsecr and tsval from this packet */ ptr = (__be32 *)(tcp+1); lro->cur_tsval = ntohl(*(ptr+1)); lro->cur_tsecr = *(ptr + 2); } } static int verify_l3_l4_lro_capable(struct lro *l_lro, struct iphdr *ip, struct tcphdr *tcp, u32 tcp_pyld_len) { u8 *ptr; DBG_PRINT(INFO_DBG, "%s: Been here...\n", __func__); if (!tcp_pyld_len) { /* Runt frame or a pure ack */ return -1; } if (ip->ihl != 5) /* IP has options */ return -1; /* If we see CE codepoint in IP header, packet is not mergeable */ if (INET_ECN_is_ce(ipv4_get_dsfield(ip))) return -1; /* If we see ECE or CWR flags in TCP header, packet is not mergeable */ if (tcp->urg || tcp->psh || tcp->rst || tcp->syn || tcp->fin || tcp->ece || tcp->cwr || !tcp->ack) { /* * Currently recognize only the ack control word and * any other control field being set would result in * flushing the LRO session */ return -1; } /* * Allow only one TCP timestamp option. Don't aggregate if * any other options are detected. */ if (tcp->doff != 5 && tcp->doff != 8) return -1; if (tcp->doff == 8) { ptr = (u8 *)(tcp + 1); while (*ptr == TCPOPT_NOP) ptr++; if (*ptr != TCPOPT_TIMESTAMP || *(ptr+1) != TCPOLEN_TIMESTAMP) return -1; /* Ensure timestamp value increases monotonically */ if (l_lro) if (l_lro->cur_tsval > ntohl(*((__be32 *)(ptr+2)))) return -1; /* timestamp echo reply should be non-zero */ if (*((__be32 *)(ptr+6)) == 0) return -1; } return 0; } static int s2io_club_tcp_session(struct ring_info *ring_data, u8 *buffer, u8 **tcp, u32 *tcp_len, struct lro **lro, struct RxD_t *rxdp, struct s2io_nic *sp) { struct iphdr *ip; struct tcphdr *tcph; int ret = 0, i; u16 vlan_tag = 0; struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; ret = check_L2_lro_capable(buffer, &ip, (struct tcphdr **)tcp, rxdp, sp); if (ret) return ret; DBG_PRINT(INFO_DBG, "IP Saddr: %x Daddr: %x\n", ip->saddr, ip->daddr); vlan_tag = RXD_GET_VLAN_TAG(rxdp->Control_2); tcph = (struct tcphdr *)*tcp; *tcp_len = get_l4_pyld_length(ip, tcph); for (i = 0; i < MAX_LRO_SESSIONS; i++) { struct lro *l_lro = &ring_data->lro0_n[i]; if (l_lro->in_use) { if (check_for_socket_match(l_lro, ip, tcph)) continue; /* Sock pair matched */ *lro = l_lro; if ((*lro)->tcp_next_seq != ntohl(tcph->seq)) { DBG_PRINT(INFO_DBG, "%s: Out of sequence. " "expected 0x%x, actual 0x%x\n", __func__, (*lro)->tcp_next_seq, ntohl(tcph->seq)); swstats->outof_sequence_pkts++; ret = 2; break; } if (!verify_l3_l4_lro_capable(l_lro, ip, tcph, *tcp_len)) ret = 1; /* Aggregate */ else ret = 2; /* Flush both */ break; } } if (ret == 0) { /* Before searching for available LRO objects, * check if the pkt is L3/L4 aggregatable. If not * don't create new LRO session. Just send this * packet up. */ if (verify_l3_l4_lro_capable(NULL, ip, tcph, *tcp_len)) return 5; for (i = 0; i < MAX_LRO_SESSIONS; i++) { struct lro *l_lro = &ring_data->lro0_n[i]; if (!(l_lro->in_use)) { *lro = l_lro; ret = 3; /* Begin anew */ break; } } } if (ret == 0) { /* sessions exceeded */ DBG_PRINT(INFO_DBG, "%s: All LRO sessions already in use\n", __func__); *lro = NULL; return ret; } switch (ret) { case 3: initiate_new_session(*lro, buffer, ip, tcph, *tcp_len, vlan_tag); break; case 2: update_L3L4_header(sp, *lro); break; case 1: aggregate_new_rx(*lro, ip, tcph, *tcp_len); if ((*lro)->sg_num == sp->lro_max_aggr_per_sess) { update_L3L4_header(sp, *lro); ret = 4; /* Flush the LRO */ } break; default: DBG_PRINT(ERR_DBG, "%s: Don't know, can't say!!\n", __func__); break; } return ret; } static void clear_lro_session(struct lro *lro) { static u16 lro_struct_size = sizeof(struct lro); memset(lro, 0, lro_struct_size); } static void queue_rx_frame(struct sk_buff *skb, u16 vlan_tag) { struct net_device *dev = skb->dev; struct s2io_nic *sp = netdev_priv(dev); skb->protocol = eth_type_trans(skb, dev); if (vlan_tag && sp->vlan_strip_flag) __vlan_hwaccel_put_tag(skb, vlan_tag); if (sp->config.napi) netif_receive_skb(skb); else netif_rx(skb); } static void lro_append_pkt(struct s2io_nic *sp, struct lro *lro, struct sk_buff *skb, u32 tcp_len) { struct sk_buff *first = lro->parent; struct swStat *swstats = &sp->mac_control.stats_info->sw_stat; first->len += tcp_len; first->data_len = lro->frags_len; skb_pull(skb, (skb->len - tcp_len)); if (skb_shinfo(first)->frag_list) lro->last_frag->next = skb; else skb_shinfo(first)->frag_list = skb; first->truesize += skb->truesize; lro->last_frag = skb; swstats->clubbed_frms_cnt++; } /** * s2io_io_error_detected - 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 s2io_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); netif_device_detach(netdev); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; if (netif_running(netdev)) { /* Bring down the card, while avoiding PCI I/O */ do_s2io_card_down(sp, 0); } pci_disable_device(pdev); return PCI_ERS_RESULT_NEED_RESET; } /** * s2io_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. * At this point, the card has exprienced a hard reset, * followed by fixups by BIOS, and has its config space * set up identically to what it was at cold boot. */ static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); if (pci_enable_device(pdev)) { pr_err("Cannot re-enable PCI device after reset.\n"); return PCI_ERS_RESULT_DISCONNECT; } pci_set_master(pdev); s2io_reset(sp); return PCI_ERS_RESULT_RECOVERED; } /** * s2io_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 s2io_io_resume(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); if (netif_running(netdev)) { if (s2io_card_up(sp)) { pr_err("Can't bring device back up after reset.\n"); return; } if (s2io_set_mac_addr(netdev, netdev->dev_addr) == FAILURE) { s2io_card_down(sp); pr_err("Can't restore mac addr after reset.\n"); return; } } netif_device_attach(netdev); netif_tx_wake_all_queues(netdev); }
gpl-2.0
rjschwei/kiwi
doc/examples/suse-13.1/suse-vm-guest/config.sh
1327
#!/bin/bash #================ # FILE : config.sh #---------------- # PROJECT : openSUSE KIWI Image System # COPYRIGHT : (c) 2006 SUSE LINUX Products GmbH. All rights reserved # : # AUTHOR : Marcus Schaefer <[email protected]> # : # BELONGS TO : Operating System images # : # DESCRIPTION : configuration script for SUSE based # : operating systems # : # : # STATUS : BETA #---------------- #====================================== # Functions... #-------------------------------------- test -f /.kconfig && . /.kconfig test -f /.profile && . /.profile #====================================== # Greeting... #-------------------------------------- echo "Configure image: [$kiwi_iname]..." #====================================== # Setup baseproduct link #-------------------------------------- suseSetupProduct #====================================== # Activate services #-------------------------------------- suseActivateDefaultServices suseInsertService boot.device-mapper #====================================== # SuSEconfig #-------------------------------------- suseConfig #====================================== # Umount kernel filesystems #-------------------------------------- baseCleanMount exit 0
gpl-2.0
victoredwardocallaghan/m5a99fx
src/cpu/samsung/exynos5420/dp_lowlevel.c
27524
/* * Copyright (C) 2012 Samsung Electronics * * Author: Donghwa Lee <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <arch/io.h> #include <stdlib.h> #include <string.h> #include <timer.h> #include <delay.h> #include <console/console.h> #include "timer.h" #include "cpu.h" #include "power.h" #include "sysreg.h" #include <drivers/maxim/max77686/max77686.h> #include "device/i2c.h" #include "i2c.h" #include "fimd.h" #include "dp.h" /* in u-boot, there's a function you call to set a pointer * to a constant. Klever! */ struct exynos_dp *dp_regs = samsung_get_base_dp(); /* for debugging, it's nice to get control on a per-file basis. * I had a bit of a discussion with myself (boring!) about * how to do this and for the moment this is the easiest way. * These debugging statements allowed me to find the final bugs. */ #if 0 static inline void fwadl(unsigned long l,void *v) { writel(l, v); printk(BIOS_SPEW, "W %p %p\n", v, (void *)l); } #define lwrite32(a,b) fwadl((unsigned long)(a), (void *)(b)) static inline unsigned long fradl(void *v) { unsigned long l = readl(v); printk(BIOS_SPEW, "R %p %p\n", v, (void *)l); return l; } #define lread32(a) fradl((void *)(a)) #else #define lwrite32(a,b) write32((unsigned long)(a), (void *)(b)) #define lread32(a) read32((void *)(a)) #endif static void exynos_dp_enable_video_input(u32 enable) { u32 reg; reg = lread32(&dp_regs->video_ctl1); reg &= ~VIDEO_EN_MASK; /* enable video input*/ if (enable) reg |= VIDEO_EN_MASK; lwrite32(reg, &dp_regs->video_ctl1); return; } void exynos_dp_disable_video_bist(void) { u32 reg; reg = lread32(&dp_regs->video_ctl4); reg &= ~VIDEO_BIST_MASK; lwrite32(reg, &dp_regs->video_ctl4); } void exynos_dp_enable_video_mute(unsigned int enable) { u32 reg; reg = lread32(&dp_regs->video_ctl1); reg &= ~(VIDEO_MUTE_MASK); if (enable) reg |= VIDEO_MUTE_MASK; lwrite32(reg, &dp_regs->video_ctl1); return; } static void exynos_dp_init_analog_param(void) { u32 reg; /* * Set termination * Normal bandgap, Normal swing, Tx terminal registor 61 ohm * 24M Phy clock, TX digital logic power is 100:1.0625V */ reg = SEL_BG_NEW_BANDGAP | TX_TERMINAL_CTRL_61_OHM | SWING_A_30PER_G_NORMAL; lwrite32(reg, &dp_regs->analog_ctl1); reg = SEL_24M | TX_DVDD_BIT_1_0625V; lwrite32(reg, &dp_regs->analog_ctl2); /* * Set power source for internal clk driver to 1.0625v. * Select current reference of TX driver current to 00:Ipp/2+Ic/2. * Set VCO range of PLL +- 0uA */ reg = DRIVE_DVDD_BIT_1_0625V | SEL_CURRENT_DEFAULT | VCO_BIT_000_MICRO; lwrite32(reg, &dp_regs->analog_ctl3); /* * Set AUX TX terminal resistor to 102 ohm * Set AUX channel amplitude control */ reg = PD_RING_OSC | AUX_TERMINAL_CTRL_52_OHM | TX_CUR1_2X | TX_CUR_4_MA; lwrite32(reg, &dp_regs->pll_filter_ctl1); /* * PLL loop filter bandwidth * For 2.7Gbps: 175KHz, For 1.62Gbps: 234KHz * PLL digital power select: 1.2500V */ reg = CH3_AMP_0_MV | CH2_AMP_0_MV | CH1_AMP_0_MV | CH0_AMP_0_MV; lwrite32(reg, &dp_regs->amp_tuning_ctl); /* * PLL loop filter bandwidth * For 2.7Gbps: 175KHz, For 1.62Gbps: 234KHz * PLL digital power select: 1.1250V */ reg = DP_PLL_LOOP_BIT_DEFAULT | DP_PLL_REF_BIT_1_1250V; lwrite32(reg, &dp_regs->pll_ctl); } static void exynos_dp_init_interrupt(void) { /* Set interrupt registers to initial states */ /* * Disable interrupt * INT pin assertion polarity. It must be configured * correctly according to ICU setting. * 1 = assert high, 0 = assert low */ lwrite32(INT_POL, &dp_regs->int_ctl); /* Clear pending regisers */ lwrite32(0xff, &dp_regs->common_int_sta1); lwrite32(0xff, &dp_regs->common_int_sta2); lwrite32(0xff, &dp_regs->common_int_sta3); lwrite32(0xff, &dp_regs->common_int_sta4); lwrite32(0xff, &dp_regs->int_sta); /* 0:mask,1: unmask */ lwrite32(0x00, &dp_regs->int_sta_mask1); lwrite32(0x00, &dp_regs->int_sta_mask2); lwrite32(0x00, &dp_regs->int_sta_mask3); lwrite32(0x00, &dp_regs->int_sta_mask4); lwrite32(0x00, &dp_regs->int_sta_mask); } void exynos_dp_reset(void) { u32 reg_func_1; /*dp tx sw reset*/ lwrite32(RESET_DP_TX, &dp_regs->tx_sw_reset); exynos_dp_enable_video_input(DP_DISABLE); exynos_dp_disable_video_bist(); exynos_dp_enable_video_mute(DP_DISABLE); /* software reset */ reg_func_1 = MASTER_VID_FUNC_EN_N | SLAVE_VID_FUNC_EN_N | AUD_FIFO_FUNC_EN_N | AUD_FUNC_EN_N | HDCP_FUNC_EN_N | SW_FUNC_EN_N; lwrite32(reg_func_1, &dp_regs->func_en1); lwrite32(reg_func_1, &dp_regs->func_en2); mdelay(1); exynos_dp_init_analog_param(); exynos_dp_init_interrupt(); return; } void exynos_dp_enable_sw_func(unsigned int enable) { u32 reg; reg = lread32(&dp_regs->func_en1); reg &= ~(SW_FUNC_EN_N); if (!enable) reg |= SW_FUNC_EN_N; lwrite32(reg, &dp_regs->func_en1); return; } unsigned int exynos_dp_set_analog_power_down(unsigned int block, u32 enable) { u32 reg; reg = lread32(&dp_regs->phy_pd); switch (block) { case AUX_BLOCK: reg &= ~(AUX_PD); if (enable) reg |= AUX_PD; break; case CH0_BLOCK: reg &= ~(CH0_PD); if (enable) reg |= CH0_PD; break; case CH1_BLOCK: reg &= ~(CH1_PD); if (enable) reg |= CH1_PD; break; case CH2_BLOCK: reg &= ~(CH2_PD); if (enable) reg |= CH2_PD; break; case CH3_BLOCK: reg &= ~(CH3_PD); if (enable) reg |= CH3_PD; break; case ANALOG_TOTAL: reg &= ~PHY_PD; if (enable) reg |= PHY_PD; break; case POWER_ALL: reg &= ~(PHY_PD | AUX_PD | CH0_PD | CH1_PD | CH2_PD | CH3_PD); if (enable) reg |= (PHY_PD | AUX_PD | CH0_PD | CH1_PD | CH2_PD | CH3_PD); break; default: printk(BIOS_ERR, "DP undefined block number : %d\n", block); return -1; } lwrite32(reg, &dp_regs->phy_pd); return 0; } unsigned int exynos_dp_get_pll_lock_status(void) { u32 reg; reg = lread32(&dp_regs->debug_ctl); if (reg & PLL_LOCK) return PLL_LOCKED; else return PLL_UNLOCKED; } static void exynos_dp_set_pll_power(unsigned int enable) { u32 reg; reg = lread32(&dp_regs->pll_ctl); reg &= ~(DP_PLL_PD); if (!enable) reg |= DP_PLL_PD; lwrite32(reg, &dp_regs->pll_ctl); } int exynos_dp_init_analog_func(void) { int ret = EXYNOS_DP_SUCCESS; unsigned int retry_cnt = 10; u32 reg; /*Power On All Analog block */ exynos_dp_set_analog_power_down(POWER_ALL, DP_DISABLE); reg = PLL_LOCK_CHG; lwrite32(reg, &dp_regs->common_int_sta1); reg = lread32(&dp_regs->debug_ctl); reg &= ~(F_PLL_LOCK | PLL_LOCK_CTRL); lwrite32(reg, &dp_regs->debug_ctl); /*Assert DP PLL Reset*/ reg = lread32(&dp_regs->pll_ctl); reg |= DP_PLL_RESET; lwrite32(reg, &dp_regs->pll_ctl); mdelay(1); /*Deassert DP PLL Reset*/ reg = lread32(&dp_regs->pll_ctl); reg &= ~(DP_PLL_RESET); lwrite32(reg, &dp_regs->pll_ctl); exynos_dp_set_pll_power(DP_ENABLE); while (exynos_dp_get_pll_lock_status() == PLL_UNLOCKED) { mdelay(1); retry_cnt--; if (retry_cnt == 0) { printk(BIOS_ERR, "DP dp's pll lock failed : retry : %d\n", retry_cnt); return -1; } } printk(BIOS_DEBUG, "dp's pll lock success(%d)\n", retry_cnt); /* Enable Serdes FIFO function and Link symbol clock domain module */ reg = lread32(&dp_regs->func_en2); reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N | AUX_FUNC_EN_N); lwrite32(reg, &dp_regs->func_en2); return ret; } void exynos_dp_init_hpd(void) { u32 reg; /* Clear interrupts releated to Hot Plug Dectect */ reg = HOTPLUG_CHG | HPD_LOST | PLUG; lwrite32(reg, &dp_regs->common_int_sta4); reg = INT_HPD; lwrite32(reg, &dp_regs->int_sta); reg = lread32(&dp_regs->sys_ctl3); reg &= ~(F_HPD | HPD_CTRL); lwrite32(reg, &dp_regs->sys_ctl3); return; } static inline void exynos_dp_reset_aux(void) { u32 reg; /* Disable AUX channel module */ reg = lread32(&dp_regs->func_en2); reg |= AUX_FUNC_EN_N; lwrite32(reg, &dp_regs->func_en2); return; } void exynos_dp_init_aux(void) { u32 reg; /* Clear inerrupts related to AUX channel */ reg = RPLY_RECEIV | AUX_ERR; lwrite32(reg, &dp_regs->int_sta); exynos_dp_reset_aux(); /* Disable AUX transaction H/W retry */ reg = AUX_BIT_PERIOD_EXPECTED_DELAY(3) | AUX_HW_RETRY_COUNT_SEL(3)| AUX_HW_RETRY_INTERVAL_600_MICROSECONDS; lwrite32(reg, &dp_regs->aux_hw_retry_ctl); /* Receive AUX Channel DEFER commands equal to DEFFER_COUNT*64 */ reg = DEFER_CTRL_EN | DEFER_COUNT(1); lwrite32(reg, &dp_regs->aux_ch_defer_ctl); /* Enable AUX channel module */ reg = lread32(&dp_regs->func_en2); reg &= ~AUX_FUNC_EN_N; lwrite32(reg, &dp_regs->func_en2); return; } void exynos_dp_config_interrupt(void) { u32 reg; /* 0: mask, 1: unmask */ reg = COMMON_INT_MASK_1; lwrite32(reg, &dp_regs->common_int_mask1); reg = COMMON_INT_MASK_2; lwrite32(reg, &dp_regs->common_int_mask2); reg = COMMON_INT_MASK_3; lwrite32(reg, &dp_regs->common_int_mask3); reg = COMMON_INT_MASK_4; lwrite32(reg, &dp_regs->common_int_mask4); reg = INT_STA_MASK; lwrite32(reg, &dp_regs->int_sta_mask); return; } unsigned int exynos_dp_get_plug_in_status(void) { u32 reg; reg = lread32(&dp_regs->sys_ctl3); if (reg & HPD_STATUS) return 0; return -1; } unsigned int exynos_dp_detect_hpd(void) { int timeout_loop = DP_TIMEOUT_LOOP_COUNT; mdelay(2); while (exynos_dp_get_plug_in_status() != 0) { if (timeout_loop == 0) return -1; mdelay(10); timeout_loop--; } return EXYNOS_DP_SUCCESS; } unsigned int exynos_dp_start_aux_transaction(void) { u32 reg; unsigned int ret = 0; unsigned int retry_cnt; /* Enable AUX CH operation */ reg = lread32(&dp_regs->aux_ch_ctl2); reg |= AUX_EN; lwrite32(reg, &dp_regs->aux_ch_ctl2); retry_cnt = 10; while (retry_cnt) { reg = lread32(&dp_regs->int_sta); if (!(reg & RPLY_RECEIV)) { if (retry_cnt == 0) { printk(BIOS_ERR, "DP Reply Timeout!!\n"); ret = -1; return ret; } mdelay(1); retry_cnt--; } else break; } /* Clear interrupt source for AUX CH command reply */ lwrite32(reg, &dp_regs->int_sta); /* Clear interrupt source for AUX CH access error */ reg = lread32(&dp_regs->int_sta); if (reg & AUX_ERR) { printk(BIOS_ERR, "DP Aux Access Error\n"); lwrite32(AUX_ERR, &dp_regs->int_sta); ret = -1; return ret; } /* Check AUX CH error access status */ reg = lread32(&dp_regs->aux_ch_sta); if ((reg & AUX_STATUS_MASK) != 0) { printk(BIOS_DEBUG, "DP AUX CH error happens: %x\n", reg & AUX_STATUS_MASK); ret = -1; return ret; } return EXYNOS_DP_SUCCESS; } unsigned int exynos_dp_write_byte_to_dpcd(u32 reg_addr, u8 data) { u32 reg; unsigned int ret; /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr); lwrite32(reg, &dp_regs->aux_addr_7_0); reg = AUX_ADDR_15_8(reg_addr); lwrite32(reg, &dp_regs->aux_addr_15_8); reg = AUX_ADDR_19_16(reg_addr); lwrite32(reg, &dp_regs->aux_addr_19_16); /* Write data buffer */ reg = data; lwrite32(reg, &dp_regs->buf_data0); /* * Set DisplayPort transaction and write 1 byte * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_TX_COMM_DP_TRANSACTION | AUX_TX_COMM_WRITE; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ ret = exynos_dp_start_aux_transaction(); if (ret != EXYNOS_DP_SUCCESS) { printk(BIOS_ERR, "DP Aux transaction failed\n"); } return ret; } unsigned int exynos_dp_read_byte_from_dpcd(u32 reg_addr, unsigned char *data) { u32 reg; int retval; /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr); lwrite32(reg, &dp_regs->aux_addr_7_0); reg = AUX_ADDR_15_8(reg_addr); lwrite32(reg, &dp_regs->aux_addr_15_8); reg = AUX_ADDR_19_16(reg_addr); lwrite32(reg, &dp_regs->aux_addr_19_16); /* * Set DisplayPort transaction and read 1 byte * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_TX_COMM_DP_TRANSACTION | AUX_TX_COMM_READ; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ retval = exynos_dp_start_aux_transaction(); if (retval != EXYNOS_DP_SUCCESS) printk(BIOS_DEBUG, "DP Aux Transaction fail!\n"); /* Read data buffer */ reg = lread32(&dp_regs->buf_data0); *data = (unsigned char)(reg & 0xff); return retval; } unsigned int exynos_dp_write_bytes_to_dpcd(u32 reg_addr, unsigned int count, unsigned char data[]) { u32 reg; unsigned int start_offset; unsigned int cur_data_count; unsigned int cur_data_idx; unsigned int retry_cnt; unsigned int ret = 0; /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); start_offset = 0; while (start_offset < count) { /* Buffer size of AUX CH is 16 * 4bytes */ if ((count - start_offset) > 16) cur_data_count = 16; else cur_data_count = count - start_offset; retry_cnt = 5; while (retry_cnt) { /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_7_0); reg = AUX_ADDR_15_8(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_15_8); reg = AUX_ADDR_19_16(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_19_16); for (cur_data_idx = 0; cur_data_idx < cur_data_count; cur_data_idx++) { reg = data[start_offset + cur_data_idx]; lwrite32(reg, (void *)((unsigned int)&dp_regs->buf_data0 + (4 * cur_data_idx))); } /* * Set DisplayPort transaction and write * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_LENGTH(cur_data_count) | AUX_TX_COMM_DP_TRANSACTION | AUX_TX_COMM_WRITE; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ ret = exynos_dp_start_aux_transaction(); if (ret != EXYNOS_DP_SUCCESS) { if (retry_cnt == 0) { printk(BIOS_ERR, "DP Aux Transaction failed\n"); return ret; } retry_cnt--; } else break; } start_offset += cur_data_count; } return ret; } unsigned int exynos_dp_read_bytes_from_dpcd(u32 reg_addr, unsigned int count, unsigned char data[]) { u32 reg; unsigned int start_offset; unsigned int cur_data_count; unsigned int cur_data_idx; unsigned int retry_cnt; unsigned int ret = 0; /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); start_offset = 0; while (start_offset < count) { /* Buffer size of AUX CH is 16 * 4bytes */ if ((count - start_offset) > 16) cur_data_count = 16; else cur_data_count = count - start_offset; retry_cnt = 5; while (retry_cnt) { /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_7_0); reg = AUX_ADDR_15_8(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_15_8); reg = AUX_ADDR_19_16(reg_addr + start_offset); lwrite32(reg, &dp_regs->aux_addr_19_16); /* * Set DisplayPort transaction and read * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_LENGTH(cur_data_count) | AUX_TX_COMM_DP_TRANSACTION | AUX_TX_COMM_READ; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ ret = exynos_dp_start_aux_transaction(); if (ret != EXYNOS_DP_SUCCESS) { if (retry_cnt == 0) { printk(BIOS_ERR, "DP Aux Transaction failed\n"); return ret; } retry_cnt--; } else break; } for (cur_data_idx = 0; cur_data_idx < cur_data_count; cur_data_idx++) { reg = lread32((void *)((u32)&dp_regs->buf_data0 + 4 * cur_data_idx)); data[start_offset + cur_data_idx] = (unsigned char)reg; } start_offset += cur_data_count; } return ret; } int exynos_dp_select_i2c_device(u32 device_addr, u32 reg_addr) { u32 reg; int retval; /* Set EDID device address */ reg = device_addr; lwrite32(reg, &dp_regs->aux_addr_7_0); lwrite32(0x0, &dp_regs->aux_addr_15_8); lwrite32(0x0, &dp_regs->aux_addr_19_16); /* Set offset from base address of EDID device */ lwrite32(reg_addr, &dp_regs->buf_data0); /* * Set I2C transaction and write address * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_TX_COMM_I2C_TRANSACTION | AUX_TX_COMM_MOT | AUX_TX_COMM_WRITE; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ retval = exynos_dp_start_aux_transaction(); if (retval != 0) printk(BIOS_DEBUG, "%s: DP Aux Transaction fail!\n", __func__); return retval; } int exynos_dp_read_byte_from_i2c(u32 device_addr, u32 reg_addr, unsigned int *data) { u32 reg; int i; int retval; for (i = 0; i < 10; i++) { /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); /* Select EDID device */ retval = exynos_dp_select_i2c_device(device_addr, reg_addr); if (retval != 0) { printk(BIOS_DEBUG, "DP Select EDID device fail. retry !\n"); continue; } /* * Set I2C transaction and read data * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_TX_COMM_I2C_TRANSACTION | AUX_TX_COMM_READ; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ retval = exynos_dp_start_aux_transaction(); if (retval != EXYNOS_DP_SUCCESS) printk(BIOS_DEBUG, "%s: DP Aux Transaction fail!\n", __func__); } /* Read data */ if (retval == 0) *data = lread32(&dp_regs->buf_data0); return retval; } int exynos_dp_read_bytes_from_i2c(u32 device_addr, u32 reg_addr, unsigned int count, unsigned char edid[]) { u32 reg; unsigned int i, j; unsigned int cur_data_idx; unsigned int defer = 0; int retval = 0; for (i = 0; i < count; i += 16) { /* use 16 burst */ for (j = 0; j < 100; j++) { /* Clear AUX CH data buffer */ reg = BUF_CLR; lwrite32(reg, &dp_regs->buffer_data_ctl); /* Set normal AUX CH command */ reg = lread32(&dp_regs->aux_ch_ctl2); reg &= ~ADDR_ONLY; lwrite32(reg, &dp_regs->aux_ch_ctl2); /* * If Rx sends defer, Tx sends only reads * request without sending addres */ if (!defer) retval = exynos_dp_select_i2c_device(device_addr, reg_addr + i); else defer = 0; if (retval == EXYNOS_DP_SUCCESS) { /* * Set I2C transaction and write data * If bit 3 is 1, DisplayPort transaction. * If Bit 3 is 0, I2C transaction. */ reg = AUX_LENGTH(16) | AUX_TX_COMM_I2C_TRANSACTION | AUX_TX_COMM_READ; lwrite32(reg, &dp_regs->aux_ch_ctl1); /* Start AUX transaction */ retval = exynos_dp_start_aux_transaction(); if (retval == 0) break; else printk(BIOS_ERR, "DP Aux Transaction fail!\n"); } /* Check if Rx sends defer */ reg = lread32(&dp_regs->aux_rx_comm); if (reg == AUX_RX_COMM_AUX_DEFER || reg == AUX_RX_COMM_I2C_DEFER) { printk(BIOS_ERR, "DP Defer: %d\n\n", reg); defer = 1; } } for (cur_data_idx = 0; cur_data_idx < 16; cur_data_idx++) { reg = lread32((void *)((u32)&dp_regs->buf_data0 + 4 * cur_data_idx)); edid[i + cur_data_idx] = (unsigned char)reg; } } return retval; } void exynos_dp_reset_macro(void) { u32 reg; reg = lread32(&dp_regs->phy_test); reg |= MACRO_RST; lwrite32(reg, &dp_regs->phy_test); /* 10 us is the minimum Macro reset time. */ mdelay(1); reg &= ~MACRO_RST; lwrite32(reg, &dp_regs->phy_test); } void exynos_dp_set_link_bandwidth(unsigned char bwtype) { u32 reg; reg = (u32)bwtype; /* Set bandwidth to 2.7G or 1.62G */ if ((bwtype == DP_LANE_BW_1_62) || (bwtype == DP_LANE_BW_2_70)) lwrite32(reg, &dp_regs->link_bw_set); } unsigned char exynos_dp_get_link_bandwidth(void) { unsigned char ret; u32 reg; reg = lread32(&dp_regs->link_bw_set); ret = (unsigned char)reg; return ret; } void exynos_dp_set_lane_count(unsigned char count) { u32 reg; reg = (u32)count; if ((count == DP_LANE_CNT_1) || (count == DP_LANE_CNT_2) || (count == DP_LANE_CNT_4)) lwrite32(reg, &dp_regs->lane_count_set); } unsigned int exynos_dp_get_lane_count(void) { u32 reg; reg = lread32(&dp_regs->lane_count_set); return reg; } unsigned char exynos_dp_get_lanex_pre_emphasis(unsigned char lanecnt) { void *reg_list[DP_LANE_CNT_4] = { &dp_regs->ln0_link_training_ctl, &dp_regs->ln1_link_training_ctl, &dp_regs->ln2_link_training_ctl, &dp_regs->ln3_link_training_ctl, }; return lread32(reg_list[lanecnt]); } void exynos_dp_set_lanex_pre_emphasis(unsigned char request_val, unsigned char lanecnt) { void * reg_list[DP_LANE_CNT_4] = { &dp_regs->ln0_link_training_ctl, &dp_regs->ln1_link_training_ctl, &dp_regs->ln2_link_training_ctl, &dp_regs->ln3_link_training_ctl, }; lwrite32(request_val, reg_list[lanecnt]); } void exynos_dp_set_lane_pre_emphasis(unsigned int level, unsigned char lanecnt) { unsigned char i; u32 reg; void *reg_list[DP_LANE_CNT_4] = { &dp_regs->ln0_link_training_ctl, &dp_regs->ln1_link_training_ctl, &dp_regs->ln2_link_training_ctl, &dp_regs->ln3_link_training_ctl, }; u32 reg_shift[DP_LANE_CNT_4] = { PRE_EMPHASIS_SET_0_SHIFT, PRE_EMPHASIS_SET_1_SHIFT, PRE_EMPHASIS_SET_2_SHIFT, PRE_EMPHASIS_SET_3_SHIFT }; for (i = 0; i < lanecnt; i++) { reg = level << reg_shift[i]; lwrite32(reg, reg_list[i]); } } void exynos_dp_set_training_pattern(unsigned int pattern) { u32 reg = 0; switch (pattern) { case PRBS7: reg = SCRAMBLING_ENABLE | LINK_QUAL_PATTERN_SET_PRBS7; break; case D10_2: reg = SCRAMBLING_ENABLE | LINK_QUAL_PATTERN_SET_D10_2; break; case TRAINING_PTN1: reg = SCRAMBLING_DISABLE | SW_TRAINING_PATTERN_SET_PTN1; break; case TRAINING_PTN2: reg = SCRAMBLING_DISABLE | SW_TRAINING_PATTERN_SET_PTN2; break; case DP_NONE: reg = SCRAMBLING_ENABLE | LINK_QUAL_PATTERN_SET_DISABLE | SW_TRAINING_PATTERN_SET_NORMAL; break; default: break; } lwrite32(reg, &dp_regs->training_ptn_set); } void exynos_dp_enable_enhanced_mode(unsigned char enable) { u32 reg; reg = lread32(&dp_regs->sys_ctl4); reg &= ~ENHANCED; if (enable) reg |= ENHANCED; lwrite32(reg, &dp_regs->sys_ctl4); } void exynos_dp_enable_scrambling(unsigned int enable) { u32 reg; reg = lread32(&dp_regs->training_ptn_set); reg &= ~(SCRAMBLING_DISABLE); if (!enable) reg |= SCRAMBLING_DISABLE; lwrite32(reg, &dp_regs->training_ptn_set); } int exynos_dp_init_video(void) { unsigned int reg; /* Clear VID_CLK_CHG[1] and VID_FORMAT_CHG[3] and VSYNC_DET[7] */ reg = VSYNC_DET | VID_FORMAT_CHG | VID_CLK_CHG; lwrite32(reg, &dp_regs->common_int_sta1); /* I_STRM__CLK detect : DE_CTL : Auto detect */ reg &= ~DET_CTRL; lwrite32(reg, &dp_regs->sys_ctl1); return 0; } void exynos_dp_config_video_slave_mode(struct edp_video_info *video_info) { u32 reg; /* Video Slave mode setting */ reg = lread32(&dp_regs->func_en1); reg &= ~(MASTER_VID_FUNC_EN_N|SLAVE_VID_FUNC_EN_N); reg |= MASTER_VID_FUNC_EN_N; lwrite32(reg, &dp_regs->func_en1); /* Configure Interlaced for slave mode video */ reg = lread32(&dp_regs->video_ctl10); reg &= ~INTERACE_SCAN_CFG; reg |= (video_info->interlaced << INTERACE_SCAN_CFG_SHIFT); printk(BIOS_SPEW, "interlaced %d\n", video_info->interlaced); lwrite32(reg, &dp_regs->video_ctl10); /* Configure V sync polarity for slave mode video */ reg = lread32(&dp_regs->video_ctl10); reg &= ~VSYNC_POLARITY_CFG; reg |= (video_info->v_sync_polarity << V_S_POLARITY_CFG_SHIFT); lwrite32(reg, &dp_regs->video_ctl10); /* Configure H sync polarity for slave mode video */ reg = lread32(&dp_regs->video_ctl10); reg &= ~HSYNC_POLARITY_CFG; reg |= (video_info->h_sync_polarity << H_S_POLARITY_CFG_SHIFT); lwrite32(reg, &dp_regs->video_ctl10); /*Set video mode to slave mode */ reg = AUDIO_MODE_SPDIF_MODE | VIDEO_MODE_SLAVE_MODE; lwrite32(reg, &dp_regs->soc_general_ctl); } void exynos_dp_set_video_color_format(struct edp_video_info *video_info) { u32 reg; /* Configure the input color depth, color space, dynamic range */ reg = (video_info->dynamic_range << IN_D_RANGE_SHIFT) | (video_info->color_depth << IN_BPC_SHIFT) | (video_info->color_space << IN_COLOR_F_SHIFT); lwrite32(reg, &dp_regs->video_ctl2); /* Set Input Color YCbCr Coefficients to ITU601 or ITU709 */ reg = lread32(&dp_regs->video_ctl3); reg &= ~IN_YC_COEFFI_MASK; if (video_info->ycbcr_coeff) reg |= IN_YC_COEFFI_ITU709; else reg |= IN_YC_COEFFI_ITU601; lwrite32(reg, &dp_regs->video_ctl3); } unsigned int exynos_dp_is_slave_video_stream_clock_on(void) { u32 reg; /* Update Video stream clk detect status */ reg = lread32(&dp_regs->sys_ctl1); lwrite32(reg, &dp_regs->sys_ctl1); reg = lread32(&dp_regs->sys_ctl1); if (!(reg & DET_STA)) { printk(BIOS_DEBUG, "DP Input stream clock not detected.\n"); return -1; } return EXYNOS_DP_SUCCESS; } void exynos_dp_set_video_cr_mn(unsigned int type, unsigned int m_value, unsigned int n_value) { u32 reg; if (type == REGISTER_M) { reg = lread32(&dp_regs->sys_ctl4); reg |= FIX_M_VID; lwrite32(reg, &dp_regs->sys_ctl4); reg = M_VID0_CFG(m_value); lwrite32(reg, &dp_regs->m_vid0); reg = M_VID1_CFG(m_value); lwrite32(reg, &dp_regs->m_vid1); reg = M_VID2_CFG(m_value); lwrite32(reg, &dp_regs->m_vid2); reg = N_VID0_CFG(n_value); lwrite32(reg, &dp_regs->n_vid0); reg = N_VID1_CFG(n_value); lwrite32(reg, &dp_regs->n_vid1); reg = N_VID2_CFG(n_value); lwrite32(reg, &dp_regs->n_vid2); } else { reg = lread32(&dp_regs->sys_ctl4); reg &= ~FIX_M_VID; lwrite32(reg, &dp_regs->sys_ctl4); } } void exynos_dp_set_video_timing_mode(unsigned int type) { u32 reg; reg = lread32(&dp_regs->video_ctl10); reg &= ~FORMAT_SEL; if (type != VIDEO_TIMING_FROM_CAPTURE) reg |= FORMAT_SEL; lwrite32(reg, &dp_regs->video_ctl10); } void exynos_dp_enable_video_master(unsigned int enable) { u32 reg; reg = lread32(&dp_regs->soc_general_ctl); if (enable) { reg &= ~VIDEO_MODE_MASK; reg |= VIDEO_MASTER_MODE_EN | VIDEO_MODE_MASTER_MODE; } else { reg &= ~VIDEO_MODE_MASK; reg |= VIDEO_MODE_SLAVE_MODE; } lwrite32(reg, &dp_regs->soc_general_ctl); } void exynos_dp_start_video(void) { u32 reg; /* Enable Video input and disable Mute */ reg = lread32(&dp_regs->video_ctl1); reg |= VIDEO_EN; lwrite32(reg, &dp_regs->video_ctl1); } unsigned int exynos_dp_is_video_stream_on(void) { u32 reg; /* Update STRM_VALID */ reg = lread32(&dp_regs->sys_ctl3); lwrite32(reg, &dp_regs->sys_ctl3); reg = lread32(&dp_regs->sys_ctl3); if (!(reg & STRM_VALID)) return -1; return EXYNOS_DP_SUCCESS; } void dp_phy_control(unsigned int enable) { u32 cfg; struct exynos5_power *power = samsung_get_base_power(); cfg = lread32(&power->dptx_phy_control); if (enable) cfg |= EXYNOS_DP_PHY_ENABLE; else cfg &= ~EXYNOS_DP_PHY_ENABLE; lwrite32(cfg, &power->dptx_phy_control); }
gpl-2.0
metalex10/PPSSPP-X360
ffmpeg/doc/examples/Makefile
1354
# use pkg-config for getting CFLAGS and LDLIBS FFMPEG_LIBS= libavdevice \ libavformat \ libavfilter \ libavcodec \ libswresample \ libswscale \ libavutil \ CFLAGS += -Wall -g CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) EXAMPLES= decoding_encoding \ demuxing \ filtering_video \ filtering_audio \ metadata \ muxing \ resampling_audio \ scaling_video \ OBJS=$(addsuffix .o,$(EXAMPLES)) # the following examples make explicit use of the math library decoding_encoding: LDLIBS += -lm muxing: LDLIBS += -lm resampling_audio: LDLIBS += -lm .phony: all clean-test clean all: $(OBJS) $(EXAMPLES) clean-test: $(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg clean: clean-test $(RM) $(EXAMPLES) $(OBJS)
gpl-2.0
Scorpio92/android_kernel_c8690
drivers/media/video/samsung/mali/common/mali_kernel_utilization.c
5983
/* * Copyright (C) 2010-2012 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. * * A copy of the licence is included with the program, and can also be obtained from Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mali_kernel_utilization.h" #include "mali_osk.h" #include "mali_platform.h" /* Define how often to calculate and report GPU utilization, in milliseconds */ #define MALI_GPU_UTILIZATION_TIMEOUT 200 static _mali_osk_lock_t *time_data_lock; static _mali_osk_atomic_t num_running_cores; static u64 period_start_time = 0; static u64 work_start_time = 0; static u64 accumulated_work_time = 0; static _mali_osk_timer_t *utilization_timer = NULL; static mali_bool timer_running = MALI_FALSE; static void calculate_gpu_utilization(void* arg) { u64 time_now; u64 time_period; u32 leading_zeroes; u32 shift_val; u32 work_normalized; u32 period_normalized; u32 utilization; _mali_osk_lock_wait(time_data_lock, _MALI_OSK_LOCKMODE_RW); if (accumulated_work_time == 0 && work_start_time == 0) { /* Don't reschedule timer, this will be started if new work arrives */ timer_running = MALI_FALSE; _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); /* No work done for this period, report zero usage */ mali_gpu_utilization_handler(0); return; } time_now = _mali_osk_time_get_ns(); time_period = time_now - period_start_time; /* If we are currently busy, update working period up to now */ if (work_start_time != 0) { accumulated_work_time += (time_now - work_start_time); work_start_time = time_now; } /* * We have two 64-bit values, a dividend and a divisor. * To avoid dependencies to a 64-bit divider, we shift down the two values * equally first. * We shift the dividend up and possibly the divisor down, making the result X in 256. */ /* Shift the 64-bit values down so they fit inside a 32-bit integer */ leading_zeroes = _mali_osk_clz((u32)(time_period >> 32)); shift_val = 32 - leading_zeroes; work_normalized = (u32)(accumulated_work_time >> shift_val); period_normalized = (u32)(time_period >> shift_val); /* * Now, we should report the usage in parts of 256 * this means we must shift up the dividend or down the divisor by 8 * (we could do a combination, but we just use one for simplicity, * but the end result should be good enough anyway) */ if (period_normalized > 0x00FFFFFF) { /* The divisor is so big that it is safe to shift it down */ period_normalized >>= 8; } else { /* * The divisor is so small that we can shift up the dividend, without loosing any data. * (dividend is always smaller than the divisor) */ work_normalized <<= 8; } utilization = work_normalized / period_normalized; accumulated_work_time = 0; period_start_time = time_now; /* starting a new period */ _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); _mali_osk_timer_add(utilization_timer, _mali_osk_time_mstoticks(MALI_GPU_UTILIZATION_TIMEOUT)); mali_gpu_utilization_handler(utilization); } _mali_osk_errcode_t mali_utilization_init(void) { time_data_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_UTILIZATION); if (NULL == time_data_lock) { return _MALI_OSK_ERR_FAULT; } _mali_osk_atomic_init(&num_running_cores, 0); utilization_timer = _mali_osk_timer_init(); if (NULL == utilization_timer) { _mali_osk_lock_term(time_data_lock); return _MALI_OSK_ERR_FAULT; } _mali_osk_timer_setcallback(utilization_timer, calculate_gpu_utilization, NULL); return _MALI_OSK_ERR_OK; } void mali_utilization_suspend(void) { if (NULL != utilization_timer) { _mali_osk_timer_del(utilization_timer); timer_running = MALI_FALSE; } } void mali_utilization_term(void) { if (NULL != utilization_timer) { _mali_osk_timer_del(utilization_timer); timer_running = MALI_FALSE; _mali_osk_timer_term(utilization_timer); utilization_timer = NULL; } _mali_osk_atomic_term(&num_running_cores); _mali_osk_lock_term(time_data_lock); } void mali_utilization_core_start(u64 time_now) { if (_mali_osk_atomic_inc_return(&num_running_cores) == 1) { /* * We went from zero cores working, to one core working, * we now consider the entire GPU for being busy */ _mali_osk_lock_wait(time_data_lock, _MALI_OSK_LOCKMODE_RW); if (time_now < period_start_time) { /* * This might happen if the calculate_gpu_utilization() was able * to run between the sampling of time_now and us grabbing the lock above */ time_now = period_start_time; } work_start_time = time_now; if (timer_running != MALI_TRUE) { timer_running = MALI_TRUE; period_start_time = work_start_time; /* starting a new period */ _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); _mali_osk_timer_add(utilization_timer, _mali_osk_time_mstoticks(MALI_GPU_UTILIZATION_TIMEOUT)); } else { _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); } } } void mali_utilization_core_end(u64 time_now) { if (_mali_osk_atomic_dec_return(&num_running_cores) == 0) { /* * No more cores are working, so accumulate the time we was busy. */ _mali_osk_lock_wait(time_data_lock, _MALI_OSK_LOCKMODE_RW); if (time_now < work_start_time) { /* * This might happen if the calculate_gpu_utilization() was able * to run between the sampling of time_now and us grabbing the lock above */ time_now = work_start_time; } accumulated_work_time += (time_now - work_start_time); work_start_time = 0; _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); } }
gpl-2.0
rutgers-apl/Atomicity-Violation-Detector
tdebug-llvm/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
7830
//===--- Diagnostics.cpp - Helper class for error diagnostics -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "clang/ASTMatchers/Dynamic/Diagnostics.h" namespace clang { namespace ast_matchers { namespace dynamic { Diagnostics::ArgStream Diagnostics::pushContextFrame(ContextType Type, SourceRange Range) { ContextStack.emplace_back(); ContextFrame& data = ContextStack.back(); data.Type = Type; data.Range = Range; return ArgStream(&data.Args); } Diagnostics::Context::Context(ConstructMatcherEnum, Diagnostics *Error, StringRef MatcherName, const SourceRange &MatcherRange) : Error(Error) { Error->pushContextFrame(CT_MatcherConstruct, MatcherRange) << MatcherName; } Diagnostics::Context::Context(MatcherArgEnum, Diagnostics *Error, StringRef MatcherName, const SourceRange &MatcherRange, unsigned ArgNumber) : Error(Error) { Error->pushContextFrame(CT_MatcherArg, MatcherRange) << ArgNumber << MatcherName; } Diagnostics::Context::~Context() { Error->ContextStack.pop_back(); } Diagnostics::OverloadContext::OverloadContext(Diagnostics *Error) : Error(Error), BeginIndex(Error->Errors.size()) {} Diagnostics::OverloadContext::~OverloadContext() { // Merge all errors that happened while in this context. if (BeginIndex < Error->Errors.size()) { Diagnostics::ErrorContent &Dest = Error->Errors[BeginIndex]; for (size_t i = BeginIndex + 1, e = Error->Errors.size(); i < e; ++i) { Dest.Messages.push_back(Error->Errors[i].Messages[0]); } Error->Errors.resize(BeginIndex + 1); } } void Diagnostics::OverloadContext::revertErrors() { // Revert the errors. Error->Errors.resize(BeginIndex); } Diagnostics::ArgStream &Diagnostics::ArgStream::operator<<(const Twine &Arg) { Out->push_back(Arg.str()); return *this; } Diagnostics::ArgStream Diagnostics::addError(const SourceRange &Range, ErrorType Error) { Errors.emplace_back(); ErrorContent &Last = Errors.back(); Last.ContextStack = ContextStack; Last.Messages.emplace_back(); Last.Messages.back().Range = Range; Last.Messages.back().Type = Error; return ArgStream(&Last.Messages.back().Args); } static StringRef contextTypeToFormatString(Diagnostics::ContextType Type) { switch (Type) { case Diagnostics::CT_MatcherConstruct: return "Error building matcher $0."; case Diagnostics::CT_MatcherArg: return "Error parsing argument $0 for matcher $1."; } llvm_unreachable("Unknown ContextType value."); } static StringRef errorTypeToFormatString(Diagnostics::ErrorType Type) { switch (Type) { case Diagnostics::ET_RegistryMatcherNotFound: return "Matcher not found: $0"; case Diagnostics::ET_RegistryWrongArgCount: return "Incorrect argument count. (Expected = $0) != (Actual = $1)"; case Diagnostics::ET_RegistryWrongArgType: return "Incorrect type for arg $0. (Expected = $1) != (Actual = $2)"; case Diagnostics::ET_RegistryNotBindable: return "Matcher does not support binding."; case Diagnostics::ET_RegistryAmbiguousOverload: // TODO: Add type info about the overload error. return "Ambiguous matcher overload."; case Diagnostics::ET_RegistryValueNotFound: return "Value not found: $0"; case Diagnostics::ET_ParserStringError: return "Error parsing string token: <$0>"; case Diagnostics::ET_ParserNoOpenParen: return "Error parsing matcher. Found token <$0> while looking for '('."; case Diagnostics::ET_ParserNoCloseParen: return "Error parsing matcher. Found end-of-code while looking for ')'."; case Diagnostics::ET_ParserNoComma: return "Error parsing matcher. Found token <$0> while looking for ','."; case Diagnostics::ET_ParserNoCode: return "End of code found while looking for token."; case Diagnostics::ET_ParserNotAMatcher: return "Input value is not a matcher expression."; case Diagnostics::ET_ParserInvalidToken: return "Invalid token <$0> found when looking for a value."; case Diagnostics::ET_ParserMalformedBindExpr: return "Malformed bind() expression."; case Diagnostics::ET_ParserTrailingCode: return "Expected end of code."; case Diagnostics::ET_ParserUnsignedError: return "Error parsing unsigned token: <$0>"; case Diagnostics::ET_ParserOverloadedType: return "Input value has unresolved overloaded type: $0"; case Diagnostics::ET_None: return "<N/A>"; } llvm_unreachable("Unknown ErrorType value."); } static void formatErrorString(StringRef FormatString, ArrayRef<std::string> Args, llvm::raw_ostream &OS) { while (!FormatString.empty()) { std::pair<StringRef, StringRef> Pieces = FormatString.split("$"); OS << Pieces.first.str(); if (Pieces.second.empty()) break; const char Next = Pieces.second.front(); FormatString = Pieces.second.drop_front(); if (Next >= '0' && Next <= '9') { const unsigned Index = Next - '0'; if (Index < Args.size()) { OS << Args[Index]; } else { OS << "<Argument_Not_Provided>"; } } } } static void maybeAddLineAndColumn(const SourceRange &Range, llvm::raw_ostream &OS) { if (Range.Start.Line > 0 && Range.Start.Column > 0) { OS << Range.Start.Line << ":" << Range.Start.Column << ": "; } } static void printContextFrameToStream(const Diagnostics::ContextFrame &Frame, llvm::raw_ostream &OS) { maybeAddLineAndColumn(Frame.Range, OS); formatErrorString(contextTypeToFormatString(Frame.Type), Frame.Args, OS); } static void printMessageToStream(const Diagnostics::ErrorContent::Message &Message, const Twine Prefix, llvm::raw_ostream &OS) { maybeAddLineAndColumn(Message.Range, OS); OS << Prefix; formatErrorString(errorTypeToFormatString(Message.Type), Message.Args, OS); } static void printErrorContentToStream(const Diagnostics::ErrorContent &Content, llvm::raw_ostream &OS) { if (Content.Messages.size() == 1) { printMessageToStream(Content.Messages[0], "", OS); } else { for (size_t i = 0, e = Content.Messages.size(); i != e; ++i) { if (i != 0) OS << "\n"; printMessageToStream(Content.Messages[i], "Candidate " + Twine(i + 1) + ": ", OS); } } } void Diagnostics::printToStream(llvm::raw_ostream &OS) const { for (size_t i = 0, e = Errors.size(); i != e; ++i) { if (i != 0) OS << "\n"; printErrorContentToStream(Errors[i], OS); } } std::string Diagnostics::toString() const { std::string S; llvm::raw_string_ostream OS(S); printToStream(OS); return OS.str(); } void Diagnostics::printToStreamFull(llvm::raw_ostream &OS) const { for (size_t i = 0, e = Errors.size(); i != e; ++i) { if (i != 0) OS << "\n"; const ErrorContent &Error = Errors[i]; for (size_t i = 0, e = Error.ContextStack.size(); i != e; ++i) { printContextFrameToStream(Error.ContextStack[i], OS); OS << "\n"; } printErrorContentToStream(Error, OS); } } std::string Diagnostics::toStringFull() const { std::string S; llvm::raw_string_ostream OS(S); printToStreamFull(OS); return OS.str(); } } // namespace dynamic } // namespace ast_matchers } // namespace clang
gpl-2.0
billmagee/bottomline
sites/all/themes/corp/templates/page.tpl.php
6771
<?php /** *@file * Corp theme's implementation to display a single drupal page. */ global $base_url; $header_style = ''; //$header_bg_file = theme_get_setting('header_bg_file'); //if ($header_bg_file) { // $header_style .= 'filter:;background: url(' . $header_bg_file . ') repeat '; //} $header_bg_file = theme_get_setting('header_bg_file'); if ($header_bg_file) { $header_style .= 'filter:;background: url(' . $header_bg_file . ') repeat '; $header_style .= theme_get_setting('header_bg_alignment') . ';'; } ?> <div id="page" class="<?php print $classes; ?>"<?php print $attributes; ?>> <!-- ______________________ HEADER _______________________ --> <header id="header" style="<?php //echo $header_style; ?>> <?php if ($logo): ?> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"> <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>"/> </a> <?php endif; ?> <?php if ($site_name || $site_slogan): ?> <hgroup id="name-and-slogan"> <?php if ($site_name): ?> <?php if ($title): ?> <div id="site-name"> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><?php print $site_name; ?></a> </div> <?php else: /* Use h1 when the content title is empty */ ?> <h1 id="site-name"> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><?php print $site_name; ?></a> </h1> <?php endif; ?> <?php endif; ?> <?php if ($site_slogan): ?> <div id="site-slogan"><?php print $site_slogan; ?></div> <?php endif; ?> </hgroup> <?php endif; ?> <?php if ($page['header']): ?> <div id="header-region"> <?php print render($page['header']); ?> </div> <?php endif; ?> <!-- customize social links code --> <?php if (theme_get_setting('socialicon_display', 'corp')): ?> <?php $twitter_url = check_plain(theme_get_setting('twitter_url', 'corp')); $facebook_url = check_plain(theme_get_setting('facebook_url', 'corp')); $linkedin_url = check_plain(theme_get_setting('linkedin_url', 'corp')); $theme_path_social = base_path() . drupal_get_path('theme', 'corp'); ?> <div id="socialbar"> <ul class="social"> <?php if ($facebook_url): ?><li> <a href="<?php print $facebook_url; ?>" target="_blank"> <img src="<?php print $theme_path_social; ?>/images/facebook.png"> </a> </li> <?php endif; ?> <?php if ($twitter_url): ?><li> <a href="<?php print $twitter_url; ?>" target="_blank"> <img src="<?php print $theme_path_social; ?>/images/twitter.png"> </a> </li> <?php endif; ?> <?php if ($linkedin_url): ?><li> <a href="<?php print $linkedin_url; ?>" target="_blank"> <img src="<?php print $theme_path_social; ?>/images/in.png"> </a> </li> <?php endif; ?> <li> <a href="<?php print $front_page; ?>rss.xml"> <img src="<?php print $theme_path_social; ?>/images/rss.png"> </a> </li> </ul> </div> <?php endif; ?> <!-- customize social links code --> <div style="clear:both;"></div> </header> <!-- /header --> <?php if ($main_menu || $secondary_menu): ?> <nav id="navigation" class="menu <?php if (!empty($main_menu)) {print "with-primary";} if (!empty($secondary_menu)) {print " with-secondary";} ?>"> <?php print theme('links', array('links' => $main_menu, 'attributes' => array('id' => 'primary', 'class' => array('links', 'clearfix', 'main-menu')))); ?> <?php print theme('links', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary', 'class' => array('links', 'clearfix', 'sub-menu')))); ?> </nav> <!-- /navigation --> <?php endif; ?> <!--code to print the image in region--> <div id="banner_img" style="<?php echo $header_style; ?>"></div> <!-- ______________________ MAIN _______________________ --> <div id="main" class="clearfix"> <section id="content"> <?php if ($breadcrumb || $title|| $messages || $tabs || $action_links): ?> <div id="content-header"> <?php print $breadcrumb; ?> <?php if ($page['highlighted']): ?> <div id="highlighted"><?php print render($page['highlighted']) ?></div> <?php endif; ?> <?php print render($title_prefix); ?> <?php if ($title): ?> <h1 class="title"><?php print $title; ?></h1> <?php endif; ?> <?php print render($title_suffix); ?> <?php print $messages; ?> <?php print render($page['help']); ?> <?php if ($tabs): ?> <div class="tabs"><?php print render($tabs); ?></div> <?php endif; ?> <?php if ($action_links): ?> <ul class="action-links"><?php print render($action_links); ?></ul> <?php endif; ?> </div> <!-- /#content-header --> <?php endif; ?> <div id="content-area"> <?php print render($page['content']) ?> </div> <?php print $feed_icons; ?> </section> <!-- /content-inner /content --> <?php if ($page['sidebar_first']): ?> <aside id="sidebar-first" class="column sidebar first"> <?php print render($page['sidebar_first']); ?> </aside> <?php endif; ?> <!-- /sidebar-first --> <?php if ($page['sidebar_second']): ?> <aside id="sidebar-second" class="column sidebar second"> <?php print render($page['sidebar_second']); ?> </aside> <?php endif; ?> <!-- /sidebar-second --> </div> <!-- /main --> <!-- ______________________ PAGE BOTTOM _______________________ --> <div style="clear:both"></div> <?php if ($page['content_bottom']): ?> <div id="content-bottom"> <?php print render($page['content_bottom']); ?> </div> <!-- /footer --> <?php endif; ?> <!--Custom Bottom Columns--> <?php if ($page['bottom_column_first'] | $page['bottom_column_second'] | $page['bottom_column_third'] ) { ?> <div id="bottom-columns"> <?php print corp_build_columns( array( render($page['bottom_column_first']), render($page['bottom_column_second']), render($page['bottom_column_third']), )); ?> </div> <!--/bottom-columns --> <?php } ?> <!-- ______________________ FOOTER _______________________ --> <?php if ($page['footer']): ?> <footer id="footer"> <?php print render($page['footer']); ?> </footer> <!-- /footer --> <?php endif; ?> </div> <!-- /page -->
gpl-2.0
bpiwowar/lyx
src/Author.cpp
3160
/** * \file Author.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author John Levon * * Full author contact details are available in file CREDITS. */ #include <config.h> #include "Author.h" #include "support/lassert.h" #include "support/lstrings.h" #include <algorithm> #include <istream> using namespace std; using namespace lyx::support; namespace lyx { static int computeHash(docstring const & name, docstring const & email) { string const full_author_string = to_utf8(name + email); // Bernstein's hash function unsigned int hash = 5381; for (unsigned int i = 0; i < full_author_string.length(); ++i) hash = ((hash << 5) + hash) + (unsigned int)(full_author_string[i]); return int(hash); } Author::Author(docstring const & name, docstring const & email) : name_(name), email_(email), used_(true) { buffer_id_ = computeHash(name_, email_); } bool operator==(Author const & l, Author const & r) { return l.name() == r.name() && l.email() == r.email(); } ostream & operator<<(ostream & os, Author const & a) { // FIXME UNICODE os << a.buffer_id_ << " \"" << to_utf8(a.name_) << "\" " << to_utf8(a.email_); return os; } istream & operator>>(istream & is, Author & a) { string s; is >> a.buffer_id_; getline(is, s); // FIXME UNICODE a.name_ = from_utf8(trim(token(s, '\"', 1))); a.email_ = from_utf8(trim(token(s, '\"', 2))); return is; } bool author_smaller(Author const & lhs, Author const & rhs) { return lhs.bufferId() < rhs.bufferId(); } AuthorList::AuthorList() : last_id_(0) {} int AuthorList::record(Author const & a) { // If we record an author which equals the current // author, we copy the buffer_id, so that it will // keep the same id in the file. if (!authors_.empty() && a == authors_[0]) authors_[0].setBufferId(a.bufferId()); Authors::const_iterator it(authors_.begin()); Authors::const_iterator itend(authors_.end()); for (int i = 0; it != itend; ++it, ++i) { if (*it == a) return i; } authors_.push_back(a); return last_id_++; } void AuthorList::record(int id, Author const & a) { LBUFERR(unsigned(id) < authors_.size()); authors_[id] = a; } void AuthorList::recordCurrentAuthor(Author const & a) { // current author has id 0 record(0, a); } Author const & AuthorList::get(int id) const { LASSERT(id < (int)authors_.size() , return authors_[0]); return authors_[id]; } AuthorList::Authors::const_iterator AuthorList::begin() const { return authors_.begin(); } AuthorList::Authors::const_iterator AuthorList::end() const { return authors_.end(); } void AuthorList::sort() { std::sort(authors_.begin(), authors_.end(), author_smaller); } ostream & operator<<(ostream & os, AuthorList const & a) { // Copy the authorlist, because we don't want to sort the original AuthorList sorted = a; sorted.sort(); AuthorList::Authors::const_iterator a_it = sorted.begin(); AuthorList::Authors::const_iterator a_end = sorted.end(); for (a_it = sorted.begin(); a_it != a_end; ++a_it) { if (a_it->used()) os << "\\author " << *a_it << "\n"; } return os; } } // namespace lyx
gpl-2.0
carlobar/uclinux_leon3_UD
user/dhcp-isc/common/icmp.c
5553
/* icmp.c ICMP Protocol engine - for sending out pings and receiving responses. */ /* * Copyright (c) 1997, 1998 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of The Internet Software Consortium nor the names * of its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This software has been written for the Internet Software Consortium * by Ted Lemon <[email protected]> in cooperation with Vixie * Enterprises. To learn more about the Internet Software Consortium, * see ``http://www.vix.com/isc''. To learn more about Vixie * Enterprises, see ``http://www.vix.com''. */ #ifndef lint #ifndef EMBED static char copyright[] = "$Id: icmp.c,v 1.6 2003/09/11 06:51:21 matthewn Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /*!EMBED*/ #endif /* not lint */ #include "../includes/dhcpd.h" #include "../includes/netinet/ip.h" //#include <netinet/ip.h> #include "../includes/netinet/ip_icmp.h" static int icmp_protocol_initialized; static int icmp_protocol_fd; /* Initialize the ICMP protocol. */ void icmp_startup (routep, handler) int routep; void (*handler) PROTO ((struct iaddr *, u_int8_t *, int)); { #ifndef EMBED struct protoent *proto; #endif int protocol = 1; int state; /* Only initialize icmp once. */ if (icmp_protocol_initialized) error ("attempted to reinitialize icmp protocol"); icmp_protocol_initialized = 1; /* Get the protocol number (should be 1). */ #ifndef EMBED proto = getprotobyname ("icmp"); if (proto) protocol = proto -> p_proto; #endif /*!EMBED*/ /* Get a raw socket for the ICMP protocol. */ icmp_protocol_fd = socket (AF_INET, SOCK_RAW, protocol); if (icmp_protocol_fd < 0) error ("unable to create icmp socket: %m"); /* Make sure it does routing... */ state = 0; if (setsockopt (icmp_protocol_fd, SOL_SOCKET, SO_DONTROUTE, (char *)&state, sizeof state) < 0) error ("Unable to disable SO_DONTROUTE on ICMP socket: %m"); add_protocol ("icmp", icmp_protocol_fd, icmp_echoreply, (void *)handler); } int icmp_echorequest (addr) struct iaddr *addr; { struct sockaddr_in to; struct icmp icmp; int status; if (!icmp_protocol_initialized) error ("attempt to use ICMP protocol before initialization."); #ifdef HAVE_SA_LEN to.sin_len = sizeof to; #endif to.sin_family = AF_INET; to.sin_port = 0; /* unused. */ memcpy (&to.sin_addr, addr -> iabuf, sizeof to.sin_addr); /* XXX */ icmp.icmp_type = ICMP_ECHO; icmp.icmp_code = 0; icmp.icmp_cksum = 0; icmp.icmp_seq = 0; #ifdef PTRSIZE_64BIT icmp.icmp_id = (((u_int32_t)(u_int64_t)addr) ^ (u_int32_t)(((u_int64_t)addr) >> 32)); #else icmp.icmp_id = (u_int32_t)addr; #endif icmp.icmp_cksum = wrapsum (checksum ((unsigned char *)&icmp, sizeof icmp, 0)); /* Send the ICMP packet... */ status = sendto (icmp_protocol_fd, (char *)&icmp, sizeof icmp, 0, (struct sockaddr *)&to, sizeof to); if (status < 0) warn ("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr)); if (status != sizeof icmp) return 0; return 1; } void icmp_echoreply (protocol) struct protocol *protocol; { struct icmp *icfrom; struct sockaddr_in from; u_int8_t icbuf [1500]; int status; int len; struct iaddr ia; void (*handler) PROTO ((struct iaddr *, u_int8_t *, int)); len = sizeof from; status = recvfrom (protocol -> fd, (char *)icbuf, sizeof icbuf, 0, (struct sockaddr *)&from, &len); if (status < 0) { warn ("icmp_echoreply: %m"); return; } /* Probably not for us. */ if (status < (sizeof (struct ip)) + (sizeof *icfrom)) { return; } len = status - sizeof (struct ip); icfrom = (struct icmp *)(icbuf + sizeof (struct ip)); /* Silently discard ICMP packets that aren't echoreplies. */ if (icfrom -> icmp_type != ICMP_ECHOREPLY) { return; } /* If we were given a second-stage handler, call it. */ if (protocol -> local) { handler = ((void (*) PROTO ((struct iaddr *, u_int8_t *, int))) protocol -> local); memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr); ia.len = sizeof from.sin_addr; (*handler) (&ia, icbuf, len); } }
gpl-2.0
hackathon-3d/team-gryffindor-repo
www/touch/src/core/Ext-more.js
50756
//@tag dom,core //@define Ext-more //@require Ext.EventManager /** * @class Ext * * Ext is the global namespace for the whole Sencha Touch framework. Every class, function and configuration for the * whole framework exists under this single global variable. The Ext singleton itself contains a set of useful helper * functions (like {@link #apply}, {@link #min} and others), but most of the framework that you use day to day exists * in specialized classes (for example {@link Ext.Panel}, {@link Ext.Carousel} and others). * * If you are new to Sencha Touch we recommend starting with the [Getting Started Guide][getting_started] to * get a feel for how the framework operates. After that, use the more focused guides on subjects like panels, forms and data * to broaden your understanding. The MVC guides take you through the process of building full applications using the * framework, and detail how to deploy them to production. * * The functions listed below are mostly utility functions used internally by many of the classes shipped in the * framework, but also often useful in your own apps. * * A method that is crucial to beginning your application is {@link #setup Ext.setup}. Please refer to it's documentation, or the * [Getting Started Guide][getting_started] as a reference on beginning your application. * * Ext.setup({ * onReady: function() { * Ext.Viewport.add({ * xtype: 'component', * html: 'Hello world!' * }); * } * }); * * [getting_started]: #!/guide/getting_started */ Ext.setVersion('touch', '2.1.0'); Ext.apply(Ext, { /** * The version of the framework * @type String */ version: Ext.getVersion('touch'), /** * @private */ idSeed: 0, /** * Repaints the whole page. This fixes frequently encountered painting issues in mobile Safari. */ repaint: function() { var mask = Ext.getBody().createChild({ cls: Ext.baseCSSPrefix + 'mask ' + Ext.baseCSSPrefix + 'mask-transparent' }); setTimeout(function() { mask.destroy(); }, 0); }, /** * Generates unique ids. If the element already has an `id`, it is unchanged. * @param {Mixed} el (optional) The element to generate an id for. * @param {String} [prefix=ext-gen] (optional) The `id` prefix. * @return {String} The generated `id`. */ id: function(el, prefix) { if (el && el.id) { return el.id; } el = Ext.getDom(el) || {}; if (el === document || el === document.documentElement) { el.id = 'ext-application'; } else if (el === document.body) { el.id = 'ext-viewport'; } else if (el === window) { el.id = 'ext-window'; } el.id = el.id || ((prefix || 'ext-element-') + (++Ext.idSeed)); return el.id; }, /** * Returns the current document body as an {@link Ext.Element}. * @return {Ext.Element} The document body. */ getBody: function() { if (!Ext.documentBodyElement) { if (!document.body) { throw new Error("[Ext.getBody] document.body does not exist at this point"); } Ext.documentBodyElement = Ext.get(document.body); } return Ext.documentBodyElement; }, /** * Returns the current document head as an {@link Ext.Element}. * @return {Ext.Element} The document head. */ getHead: function() { if (!Ext.documentHeadElement) { Ext.documentHeadElement = Ext.get(document.head || document.getElementsByTagName('head')[0]); } return Ext.documentHeadElement; }, /** * Returns the current HTML document object as an {@link Ext.Element}. * @return {Ext.Element} The document. */ getDoc: function() { if (!Ext.documentElement) { Ext.documentElement = Ext.get(document); } return Ext.documentElement; }, /** * This is shorthand reference to {@link Ext.ComponentMgr#get}. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#getId id} * @param {String} id The component {@link Ext.Component#getId id} * @return {Ext.Component} The Component, `undefined` if not found, or `null` if a * Class was found. */ getCmp: function(id) { return Ext.ComponentMgr.get(id); }, /** * Copies a set of named properties from the source object to the destination object. * * Example: * * ImageComponent = Ext.extend(Ext.Component, { * initComponent: function() { * this.autoEl = { tag: 'img' }; * MyComponent.superclass.initComponent.apply(this, arguments); * this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height'); * } * }); * * Important note: To borrow class prototype methods, use {@link Ext.Base#borrow} instead. * * @param {Object} dest The destination object. * @param {Object} source The source object. * @param {String/String[]} names Either an Array of property names, or a comma-delimited list * of property names to copy. * @param {Boolean} [usePrototypeKeys=false] (optional) Pass `true` to copy keys off of the prototype as well as the instance. * @return {Object} The modified object. */ copyTo : function(dest, source, names, usePrototypeKeys) { if (typeof names == 'string') { names = names.split(/[,;\s]/); } Ext.each (names, function(name) { if (usePrototypeKeys || source.hasOwnProperty(name)) { dest[name] = source[name]; } }, this); return dest; }, /** * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the * DOM (if applicable) and calling their destroy functions (if available). This method is primarily * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}. * Any number of elements and/or components can be passed into this function in a single * call as separate arguments. * @param {Mixed...} args An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy. */ destroy: function() { var args = arguments, ln = args.length, i, item; for (i = 0; i < ln; i++) { item = args[i]; if (item) { if (Ext.isArray(item)) { this.destroy.apply(this, item); } else if (Ext.isFunction(item.destroy)) { item.destroy(); } } } }, /** * Return the dom node for the passed String (id), dom node, or Ext.Element. * Here are some examples: * * // gets dom node based on id * var elDom = Ext.getDom('elId'); * * // gets dom node based on the dom node * var elDom1 = Ext.getDom(elDom); * * // If we don't know if we are working with an * // Ext.Element or a dom node use Ext.getDom * function(el){ * var dom = Ext.getDom(el); * // do something with the dom node * } * * __Note:__ the dom node to be found actually needs to exist (be rendered, etc) * when this method is called to be successful. * @param {Mixed} el * @return {HTMLElement} */ getDom: function(el) { if (!el || !document) { return null; } return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el); }, /** * Removes this element from the document, removes all DOM event listeners, and deletes the cache reference. * All DOM event listeners are removed from this element. * @param {HTMLElement} node The node to remove. */ removeNode: function(node) { if (node && node.parentNode && node.tagName != 'BODY') { Ext.get(node).clearListeners(); node.parentNode.removeChild(node); delete Ext.cache[node.id]; } }, /** * @private */ defaultSetupConfig: { eventPublishers: { dom: { xclass: 'Ext.event.publisher.Dom' }, touchGesture: { xclass: 'Ext.event.publisher.TouchGesture', recognizers: { drag: { xclass: 'Ext.event.recognizer.Drag' }, tap: { xclass: 'Ext.event.recognizer.Tap' }, doubleTap: { xclass: 'Ext.event.recognizer.DoubleTap' }, longPress: { xclass: 'Ext.event.recognizer.LongPress' }, swipe: { xclass: 'Ext.event.recognizer.HorizontalSwipe' }, pinch: { xclass: 'Ext.event.recognizer.Pinch' }, rotate: { xclass: 'Ext.event.recognizer.Rotate' } } }, componentDelegation: { xclass: 'Ext.event.publisher.ComponentDelegation' }, componentPaint: { xclass: 'Ext.event.publisher.ComponentPaint' }, // componentSize: { // xclass: 'Ext.event.publisher.ComponentSize' // }, elementPaint: { xclass: 'Ext.event.publisher.ElementPaint' }, elementSize: { xclass: 'Ext.event.publisher.ElementSize' } }, //<feature logger> logger: { enabled: true, xclass: 'Ext.log.Logger', minPriority: 'deprecate', writers: { console: { xclass: 'Ext.log.writer.Console', throwOnErrors: true, formatter: { xclass: 'Ext.log.formatter.Default' } } } }, //</feature> animator: { xclass: 'Ext.fx.Runner' }, viewport: { xclass: 'Ext.viewport.Viewport' } }, /** * @private */ isSetup: false, /** * This indicate the start timestamp of current cycle. * It is only reliable during dom-event-initiated cycles and * {@link Ext.draw.Animator} initiated cycles. */ frameStartTime: +new Date(), /** * @private */ setupListeners: [], /** * @private */ onSetup: function(fn, scope) { if (Ext.isSetup) { fn.call(scope); } else { Ext.setupListeners.push({ fn: fn, scope: scope }); } }, /** * Ext.setup() is the entry-point to initialize a Sencha Touch application. Note that if your application makes * use of MVC architecture, use {@link Ext#application} instead. * * This method accepts one single argument in object format. The most basic use of Ext.setup() is as follows: * * Ext.setup({ * onReady: function() { * // ... * } * }); * * This sets up the viewport, initializes the event system, instantiates a default animation runner, and a default * logger (during development). When all of that is ready, it invokes the callback function given to the `onReady` key. * * The default scope (`this`) of `onReady` is the main viewport. By default the viewport instance is stored in * {@link Ext.Viewport}. For example, this snippet adds a 'Hello World' button that is centered on the screen: * * Ext.setup({ * onReady: function() { * this.add({ * xtype: 'button', * centered: true, * text: 'Hello world!' * }); // Equivalent to Ext.Viewport.add(...) * } * }); * * @param {Object} config An object with the following config options: * * @param {Function} config.onReady * A function to be called when the application is ready. Your application logic should be here. * * @param {Object} config.viewport * A custom config object to be used when creating the global {@link Ext.Viewport} instance. Please refer to the * {@link Ext.Viewport} documentation for more information. * * Ext.setup({ * viewport: { * width: 500, * height: 500 * }, * onReady: function() { * // ... * } * }); * * @param {String/Object} config.icon * Specifies a set of URLs to the application icon for different device form factors. This icon is displayed * when the application is added to the device's Home Screen. * * Ext.setup({ * icon: { * 57: 'resources/icons/Icon.png', * 72: 'resources/icons/Icon~ipad.png', * 114: 'resources/icons/[email protected]', * 144: 'resources/icons/[email protected]' * }, * onReady: function() { * // ... * } * }); * * Each key represents the dimension of the icon as a square shape. For example: '57' is the key for a 57 x 57 * icon image. Here is the breakdown of each dimension and its device target: * * - 57: Non-retina iPhone, iPod touch, and all Android devices * - 72: Retina iPhone and iPod touch * - 114: Non-retina iPad (first and second generation) * - 144: Retina iPad (third generation) * * Note that the dimensions of the icon images must be exactly 57x57, 72x72, 114x114 and 144x144 respectively. * * It is highly recommended that you provide all these different sizes to accommodate a full range of * devices currently available. However if you only have one icon in one size, make it 57x57 in size and * specify it as a string value. This same icon will be used on all supported devices. * * Ext.setup({ * icon: 'resources/icons/Icon.png', * onReady: function() { * // ... * } * }); * * @param {Object} config.startupImage * Specifies a set of URLs to the application startup images for different device form factors. This image is * displayed when the application is being launched from the Home Screen icon. Note that this currently only applies * to iOS devices. * * Ext.setup({ * startupImage: { * '320x460': 'resources/startup/320x460.jpg', * '640x920': 'resources/startup/640x920.png', * '640x1096': 'resources/startup/640x1096.png', * '768x1004': 'resources/startup/768x1004.png', * '748x1024': 'resources/startup/748x1024.png', * '1536x2008': 'resources/startup/1536x2008.png', * '1496x2048': 'resources/startup/1496x2048.png' * }, * onReady: function() { * // ... * } * }); * * Each key represents the dimension of the image. For example: '320x460' is the key for a 320px x 460px image. * Here is the breakdown of each dimension and its device target: * * - 320x460: Non-retina iPhone, iPod touch, and all Android devices * - 640x920: Retina iPhone and iPod touch * - 640x1096: iPhone 5 and iPod touch (fifth generation) * - 768x1004: Non-retina iPad (first and second generation) in portrait orientation * - 748x1024: Non-retina iPad (first and second generation) in landscape orientation * - 1536x2008: Retina iPad (third generation) in portrait orientation * - 1496x2048: Retina iPad (third generation) in landscape orientation * * Please note that there's no automatic fallback mechanism for the startup images. In other words, if you don't specify * a valid image for a certain device, nothing will be displayed while the application is being launched on that device. * * @param {Boolean} isIconPrecomposed * True to not having a glossy effect added to the icon by the OS, which will preserve its exact look. This currently * only applies to iOS devices. * * @param {String} statusBarStyle * The style of status bar to be shown on applications added to the iOS home screen. Valid options are: * * * `default` * * `black` * * `black-translucent` * * @param {String[]} config.requires * An array of required classes for your application which will be automatically loaded before `onReady` is invoked. * Please refer to {@link Ext.Loader} and {@link Ext.Loader#require} for more information. * * Ext.setup({ * requires: ['Ext.Button', 'Ext.tab.Panel'], * onReady: function() { * // ... * } * }); * * @param {Object} config.eventPublishers * Sencha Touch, by default, includes various {@link Ext.event.recognizer.Recognizer} subclasses to recognize events fired * in your application. The list of default recognizers can be found in the documentation for * {@link Ext.event.recognizer.Recognizer}. * * To change the default recognizers, you can use the following syntax: * * Ext.setup({ * eventPublishers: { * touchGesture: { * recognizers: { * swipe: { * // this will include both vertical and horizontal swipe recognizers * xclass: 'Ext.event.recognizer.Swipe' * } * } * } * }, * onReady: function() { * // ... * } * }); * * You can also disable recognizers using this syntax: * * Ext.setup({ * eventPublishers: { * touchGesture: { * recognizers: { * swipe: null, * pinch: null, * rotate: null * } * } * }, * onReady: function() { * // ... * } * }); */ setup: function(config) { var defaultSetupConfig = Ext.defaultSetupConfig, emptyFn = Ext.emptyFn, onReady = config.onReady || emptyFn, onUpdated = config.onUpdated || emptyFn, scope = config.scope, requires = Ext.Array.from(config.requires), extOnReady = Ext.onReady, head = Ext.getHead(), callback, viewport, precomposed; Ext.setup = function() { throw new Error("Ext.setup has already been called before"); }; delete config.requires; delete config.onReady; delete config.onUpdated; delete config.scope; Ext.require(['Ext.event.Dispatcher']); callback = function() { var listeners = Ext.setupListeners, ln = listeners.length, i, listener; delete Ext.setupListeners; Ext.isSetup = true; for (i = 0; i < ln; i++) { listener = listeners[i]; listener.fn.call(listener.scope); } Ext.onReady = extOnReady; Ext.onReady(onReady, scope); }; Ext.onUpdated = onUpdated; Ext.onReady = function(fn, scope) { var origin = onReady; onReady = function() { origin(); Ext.onReady(fn, scope); }; }; config = Ext.merge({}, defaultSetupConfig, config); Ext.onDocumentReady(function() { Ext.factoryConfig(config, function(data) { Ext.event.Dispatcher.getInstance().setPublishers(data.eventPublishers); if (data.logger) { Ext.Logger = data.logger; } if (data.animator) { Ext.Animator = data.animator; } if (data.viewport) { Ext.Viewport = viewport = data.viewport; if (!scope) { scope = viewport; } Ext.require(requires, function() { Ext.Viewport.on('ready', callback, null, {single: true}); }); } else { Ext.require(requires, callback); } }); }); function addMeta(name, content) { var meta = document.createElement('meta'); meta.setAttribute('name', name); meta.setAttribute('content', content); head.append(meta); } function addIcon(href, sizes, precomposed) { var link = document.createElement('link'); link.setAttribute('rel', 'apple-touch-icon' + (precomposed ? '-precomposed' : '')); link.setAttribute('href', href); if (sizes) { link.setAttribute('sizes', sizes); } head.append(link); } function addStartupImage(href, media) { var link = document.createElement('link'); link.setAttribute('rel', 'apple-touch-startup-image'); link.setAttribute('href', href); if (media) { link.setAttribute('media', media); } head.append(link); } var icon = config.icon, isIconPrecomposed = Boolean(config.isIconPrecomposed), startupImage = config.startupImage || {}, statusBarStyle = config.statusBarStyle, devicePixelRatio = window.devicePixelRatio || 1; if (navigator.standalone) { addMeta('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'); } else { addMeta('viewport', 'initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'); } addMeta('apple-mobile-web-app-capable', 'yes'); addMeta('apple-touch-fullscreen', 'yes'); // status bar style if (statusBarStyle) { addMeta('apple-mobile-web-app-status-bar-style', statusBarStyle); } if (Ext.isString(icon)) { icon = { 57: icon, 72: icon, 114: icon, 144: icon }; } else if (!icon) { icon = {}; } //<deprecated product=touch since=2.0.1> if ('phoneStartupScreen' in config) { //<debug warn> Ext.Logger.deprecate("[Ext.setup()] 'phoneStartupScreen' config is deprecated, please use 'startupImage' " + "config instead. Refer to the latest API docs for more details"); //</debug> config['320x460'] = config.phoneStartupScreen; } if ('tabletStartupScreen' in config) { //<debug warn> Ext.Logger.deprecate("[Ext.setup()] 'tabletStartupScreen' config is deprecated, please use 'startupImage' " + "config instead. Refer to the latest API docs for more details"); //</debug> config['768x1004'] = config.tabletStartupScreen; } if ('glossOnIcon' in config) { //<debug warn> Ext.Logger.deprecate("[Ext.setup()] 'glossOnIcon' config is deprecated, please use 'isIconPrecomposed' " + "config instead. Refer to the latest API docs for more details"); //</debug> isIconPrecomposed = Boolean(config.glossOnIcon); } //</deprecated> if (Ext.os.is.iPad) { if (devicePixelRatio >= 2) { // Retina iPad - Landscape if ('1496x2048' in startupImage) { addStartupImage(startupImage['1496x2048'], '(orientation: landscape)'); } // Retina iPad - Portrait if ('1536x2008' in startupImage) { addStartupImage(startupImage['1536x2008'], '(orientation: portrait)'); } // Retina iPad if ('144' in icon) { addIcon(icon['144'], '144x144', isIconPrecomposed); } } else { // Non-Retina iPad - Landscape if ('748x1024' in startupImage) { addStartupImage(startupImage['748x1024'], '(orientation: landscape)'); } // Non-Retina iPad - Portrait if ('768x1004' in startupImage) { addStartupImage(startupImage['768x1004'], '(orientation: portrait)'); } // Non-Retina iPad if ('72' in icon) { addIcon(icon['72'], '72x72', isIconPrecomposed); } } } else { // Retina iPhone, iPod touch with iOS version >= 4.3 if (devicePixelRatio >= 2 && Ext.os.version.gtEq('4.3')) { if (Ext.os.is.iPhone5) { addStartupImage(startupImage['640x1096']); } else { addStartupImage(startupImage['640x920']); } // Retina iPhone and iPod touch if ('114' in icon) { addIcon(icon['114'], '114x114', isIconPrecomposed); } } else { addStartupImage(startupImage['320x460']); // Non-Retina iPhone, iPod touch, and Android devices if ('57' in icon) { addIcon(icon['57'], null, isIconPrecomposed); } } } }, /** * @member Ext * @method application * * Loads Ext.app.Application class and starts it up with given configuration after the page is ready. * * Ext.application({ * launch: function() { * alert('Application launched!'); * } * }); * * See {@link Ext.app.Application} for details. * * @param {Object} config An object with the following config options: * * @param {Function} config.launch * A function to be called when the application is ready. Your application logic should be here. Please see {@link Ext.app.Application} * for details. * * @param {Object} config.viewport * An object to be used when creating the global {@link Ext.Viewport} instance. Please refer to the {@link Ext.Viewport} * documentation for more information. * * Ext.application({ * viewport: { * layout: 'vbox' * }, * launch: function() { * Ext.Viewport.add({ * flex: 1, * html: 'top (flex: 1)' * }); * * Ext.Viewport.add({ * flex: 4, * html: 'bottom (flex: 4)' * }); * } * }); * * @param {String/Object} config.icon * Specifies a set of URLs to the application icon for different device form factors. This icon is displayed * when the application is added to the device's Home Screen. * * Ext.application({ * icon: { * 57: 'resources/icons/Icon.png', * 72: 'resources/icons/Icon~ipad.png', * 114: 'resources/icons/[email protected]', * 144: 'resources/icons/[email protected]' * }, * launch: function() { * // ... * } * }); * * Each key represents the dimension of the icon as a square shape. For example: '57' is the key for a 57 x 57 * icon image. Here is the breakdown of each dimension and its device target: * * - 57: Non-retina iPhone, iPod touch, and all Android devices * - 72: Retina iPhone and iPod touch * - 114: Non-retina iPad (first and second generation) * - 144: Retina iPad (third generation) * * Note that the dimensions of the icon images must be exactly 57x57, 72x72, 114x114 and 144x144 respectively. * * It is highly recommended that you provide all these different sizes to accommodate a full range of * devices currently available. However if you only have one icon in one size, make it 57x57 in size and * specify it as a string value. This same icon will be used on all supported devices. * * Ext.setup({ * icon: 'resources/icons/Icon.png', * onReady: function() { * // ... * } * }); * * @param {Object} config.startupImage * Specifies a set of URLs to the application startup images for different device form factors. This image is * displayed when the application is being launched from the Home Screen icon. Note that this currently only applies * to iOS devices. * * Ext.application({ * startupImage: { * '320x460': 'resources/startup/320x460.jpg', * '640x920': 'resources/startup/640x920.png', * '640x1096': 'resources/startup/640x1096.png', * '768x1004': 'resources/startup/768x1004.png', * '748x1024': 'resources/startup/748x1024.png', * '1536x2008': 'resources/startup/1536x2008.png', * '1496x2048': 'resources/startup/1496x2048.png' * }, * launch: function() { * // ... * } * }); * * Each key represents the dimension of the image. For example: '320x460' is the key for a 320px x 460px image. * Here is the breakdown of each dimension and its device target: * * - 320x460: Non-retina iPhone, iPod touch, and all Android devices * - 640x920: Retina iPhone and iPod touch * - 640x1096: iPhone 5 and iPod touch (fifth generation) * - 768x1004: Non-retina iPad (first and second generation) in portrait orientation * - 748x1024: Non-retina iPad (first and second generation) in landscape orientation * - 1536x2008: Retina iPad (third generation) in portrait orientation * - 1496x2048: Retina iPad (third generation) in landscape orientation * * Please note that there's no automatic fallback mechanism for the startup images. In other words, if you don't specify * a valid image for a certain device, nothing will be displayed while the application is being launched on that device. * * @param {Boolean} config.isIconPrecomposed * True to not having a glossy effect added to the icon by the OS, which will preserve its exact look. This currently * only applies to iOS devices. * * @param {String} config.statusBarStyle * The style of status bar to be shown on applications added to the iOS home screen. Valid options are: * * * `default` * * `black` * * `black-translucent` * * @param {String[]} config.requires * An array of required classes for your application which will be automatically loaded if {@link Ext.Loader#enabled} is set * to `true`. Please refer to {@link Ext.Loader} and {@link Ext.Loader#require} for more information. * * Ext.application({ * requires: ['Ext.Button', 'Ext.tab.Panel'], * launch: function() { * // ... * } * }); * * @param {Object} config.eventPublishers * Sencha Touch, by default, includes various {@link Ext.event.recognizer.Recognizer} subclasses to recognize events fired * in your application. The list of default recognizers can be found in the documentation for {@link Ext.event.recognizer.Recognizer}. * * To change the default recognizers, you can use the following syntax: * * Ext.application({ * eventPublishers: { * touchGesture: { * recognizers: { * swipe: { * // this will include both vertical and horizontal swipe recognizers * xclass: 'Ext.event.recognizer.Swipe' * } * } * } * }, * launch: function() { * // ... * } * }); * * You can also disable recognizers using this syntax: * * Ext.application({ * eventPublishers: { * touchGesture: { * recognizers: { * swipe: null, * pinch: null, * rotate: null * } * } * }, * launch: function() { * // ... * } * }); */ application: function(config) { var appName = config.name, onReady, scope, requires; if (!config) { config = {}; } if (!Ext.Loader.config.paths[appName]) { Ext.Loader.setPath(appName, config.appFolder || 'app'); } requires = Ext.Array.from(config.requires); config.requires = ['Ext.app.Application']; onReady = config.onReady; scope = config.scope; config.onReady = function() { config.requires = requires; new Ext.app.Application(config); if (onReady) { onReady.call(scope); } }; Ext.setup(config); }, /** * @private * @param config * @param callback * @member Ext */ factoryConfig: function(config, callback) { var isSimpleObject = Ext.isSimpleObject(config); if (isSimpleObject && config.xclass) { var className = config.xclass; delete config.xclass; Ext.require(className, function() { Ext.factoryConfig(config, function(cfg) { callback(Ext.create(className, cfg)); }); }); return; } var isArray = Ext.isArray(config), keys = [], key, value, i, ln; if (isSimpleObject || isArray) { if (isSimpleObject) { for (key in config) { if (config.hasOwnProperty(key)) { value = config[key]; if (Ext.isSimpleObject(value) || Ext.isArray(value)) { keys.push(key); } } } } else { for (i = 0,ln = config.length; i < ln; i++) { value = config[i]; if (Ext.isSimpleObject(value) || Ext.isArray(value)) { keys.push(i); } } } i = 0; ln = keys.length; if (ln === 0) { callback(config); return; } function fn(value) { config[key] = value; i++; factory(); } function factory() { if (i >= ln) { callback(config); return; } key = keys[i]; value = config[key]; Ext.factoryConfig(value, fn); } factory(); return; } callback(config); }, /** * A global factory method to instantiate a class from a config object. For example, these two calls are equivalent: * * Ext.factory({ text: 'My Button' }, 'Ext.Button'); * Ext.create('Ext.Button', { text: 'My Button' }); * * If an existing instance is also specified, it will be updated with the supplied config object. This is useful * if you need to either create or update an object, depending on if an instance already exists. For example: * * var button; * button = Ext.factory({ text: 'New Button' }, 'Ext.Button', button); // Button created * button = Ext.factory({ text: 'Updated Button' }, 'Ext.Button', button); // Button updated * * @param {Object} config The config object to instantiate or update an instance with. * @param {String} classReference The class to instantiate from. * @param {Object} [instance] The instance to update. * @param [aliasNamespace] * @member Ext */ factory: function(config, classReference, instance, aliasNamespace) { var manager = Ext.ClassManager, newInstance; // If config is falsy or a valid instance, destroy the current instance // (if it exists) and replace with the new one if (!config || config.isInstance) { if (instance && instance !== config) { instance.destroy(); } return config; } if (aliasNamespace) { // If config is a string value, treat it as an alias if (typeof config == 'string') { return manager.instantiateByAlias(aliasNamespace + '.' + config); } // Same if 'type' is given in config else if (Ext.isObject(config) && 'type' in config) { return manager.instantiateByAlias(aliasNamespace + '.' + config.type, config); } } if (config === true) { return instance || manager.instantiate(classReference); } //<debug error> if (!Ext.isObject(config)) { Ext.Logger.error("Invalid config, must be a valid config object"); } //</debug> if ('xtype' in config) { newInstance = manager.instantiateByAlias('widget.' + config.xtype, config); } else if ('xclass' in config) { newInstance = manager.instantiate(config.xclass, config); } if (newInstance) { if (instance) { instance.destroy(); } return newInstance; } if (instance) { return instance.setConfig(config); } return manager.instantiate(classReference, config); }, /** * @private * @member Ext */ deprecateClassMember: function(cls, oldName, newName, message) { return this.deprecateProperty(cls.prototype, oldName, newName, message); }, /** * @private * @member Ext */ deprecateClassMembers: function(cls, members) { var prototype = cls.prototype, oldName, newName; for (oldName in members) { if (members.hasOwnProperty(oldName)) { newName = members[oldName]; this.deprecateProperty(prototype, oldName, newName); } } }, /** * @private * @member Ext */ deprecateProperty: function(object, oldName, newName, message) { if (!message) { message = "'" + oldName + "' is deprecated"; } if (newName) { message += ", please use '" + newName + "' instead"; } if (newName) { Ext.Object.defineProperty(object, oldName, { get: function() { //<debug warn> Ext.Logger.deprecate(message, 1); //</debug> return this[newName]; }, set: function(value) { //<debug warn> Ext.Logger.deprecate(message, 1); //</debug> this[newName] = value; }, configurable: true }); } }, /** * @private * @member Ext */ deprecatePropertyValue: function(object, name, value, message) { Ext.Object.defineProperty(object, name, { get: function() { //<debug warn> Ext.Logger.deprecate(message, 1); //</debug> return value; }, configurable: true }); }, /** * @private * @member Ext */ deprecateMethod: function(object, name, method, message) { object[name] = function() { //<debug warn> Ext.Logger.deprecate(message, 2); //</debug> if (method) { return method.apply(this, arguments); } }; }, /** * @private * @member Ext */ deprecateClassMethod: function(cls, name, method, message) { if (typeof name != 'string') { var from, to; for (from in name) { if (name.hasOwnProperty(from)) { to = name[from]; Ext.deprecateClassMethod(cls, from, to); } } return; } var isLateBinding = typeof method == 'string', member; if (!message) { message = "'" + name + "()' is deprecated, please use '" + (isLateBinding ? method : method.name) + "()' instead"; } if (isLateBinding) { member = function() { //<debug warn> Ext.Logger.deprecate(message, this); //</debug> return this[method].apply(this, arguments); }; } else { member = function() { //<debug warn> Ext.Logger.deprecate(message, this); //</debug> return method.apply(this, arguments); }; } if (name in cls.prototype) { Ext.Object.defineProperty(cls.prototype, name, { value: null, writable: true, configurable: true }); } cls.addMember(name, member); }, //<debug> /** * Useful snippet to show an exact, narrowed-down list of top-level Components that are not yet destroyed. * @private */ showLeaks: function() { var map = Ext.ComponentManager.all.map, leaks = [], parent; Ext.Object.each(map, function(id, component) { while ((parent = component.getParent()) && map.hasOwnProperty(parent.getId())) { component = parent; } if (leaks.indexOf(component) === -1) { leaks.push(component); } }); console.log(leaks); }, //</debug> /** * True when the document is fully initialized and ready for action * @type Boolean * @member Ext * @private */ isReady : false, /** * @private * @member Ext */ readyListeners: [], /** * @private * @member Ext */ triggerReady: function() { var listeners = Ext.readyListeners, i, ln, listener; if (!Ext.isReady) { Ext.isReady = true; for (i = 0,ln = listeners.length; i < ln; i++) { listener = listeners[i]; listener.fn.call(listener.scope); } delete Ext.readyListeners; } }, /** * @private * @member Ext */ onDocumentReady: function(fn, scope) { if (Ext.isReady) { fn.call(scope); } else { var triggerFn = Ext.triggerReady; Ext.readyListeners.push({ fn: fn, scope: scope }); if (Ext.browser.is.PhoneGap && !Ext.os.is.Desktop) { if (!Ext.readyListenerAttached) { Ext.readyListenerAttached = true; document.addEventListener('deviceready', triggerFn, false); } } else { if (document.readyState.match(/interactive|complete|loaded/) !== null) { triggerFn(); } else if (!Ext.readyListenerAttached) { Ext.readyListenerAttached = true; window.addEventListener('DOMContentLoaded', triggerFn, false); } } } }, /** * Calls function after specified delay, or right away when delay == 0. * @param {Function} callback The callback to execute. * @param {Object} scope (optional) The scope to execute in. * @param {Array} args (optional) The arguments to pass to the function. * @param {Number} delay (optional) Pass a number to delay the call by a number of milliseconds. * @member Ext */ callback: function(callback, scope, args, delay) { if (Ext.isFunction(callback)) { args = args || []; scope = scope || window; if (delay) { Ext.defer(callback, delay, scope, args); } else { callback.apply(scope, args); } } } }); //<debug> Ext.Object.defineProperty(Ext, 'Msg', { get: function() { Ext.Logger.error("Using Ext.Msg without requiring Ext.MessageBox"); return null; }, set: function(value) { Ext.Object.defineProperty(Ext, 'Msg', { value: value }); return value; }, configurable: true }); //</debug> //<deprecated product=touch since=2.0> Ext.deprecateMethod(Ext, 'getOrientation', function() { return Ext.Viewport.getOrientation(); }, "Ext.getOrientation() is deprecated, use Ext.Viewport.getOrientation() instead"); Ext.deprecateMethod(Ext, 'log', function(message) { return Ext.Logger.log(message); }, "Ext.log() is deprecated, please use Ext.Logger.log() instead"); /** * @member Ext.Function * @method createDelegate * @inheritdoc Ext.Function#bind * @deprecated 2.0.0 * Please use {@link Ext.Function#bind bind} instead */ Ext.deprecateMethod(Ext.Function, 'createDelegate', Ext.Function.bind, "Ext.createDelegate() is deprecated, please use Ext.Function.bind() instead"); /** * @member Ext * @method createInterceptor * @inheritdoc Ext.Function#createInterceptor * @deprecated 2.0.0 * Please use {@link Ext.Function#createInterceptor createInterceptor} instead */ Ext.deprecateMethod(Ext, 'createInterceptor', Ext.Function.createInterceptor, "Ext.createInterceptor() is deprecated, " + "please use Ext.Function.createInterceptor() instead"); /** * @member Ext * @property {Boolean} SSL_SECURE_URL * URL to a blank file used by Ext JS when in secure mode for iframe src and onReady * src to prevent the IE insecure content warning. * @removed 2.0.0 */ Ext.deprecateProperty(Ext, 'SSL_SECURE_URL', null, "Ext.SSL_SECURE_URL has been removed"); /** * @member Ext * @property {Boolean} enableGarbageCollector * `true` to automatically un-cache orphaned Ext.Elements periodically. * @removed 2.0.0 */ Ext.deprecateProperty(Ext, 'enableGarbageCollector', null, "Ext.enableGarbageCollector has been removed"); /** * @member Ext * @property {Boolean} enableListenerCollection * True to automatically purge event listeners during garbageCollection. * @removed 2.0.0 */ Ext.deprecateProperty(Ext, 'enableListenerCollection', null, "Ext.enableListenerCollection has been removed"); /** * @member Ext * @property {Boolean} isSecure * True if the page is running over SSL. * @removed 2.0.0 Please use {@link Ext.env.Browser#isSecure} instead */ Ext.deprecateProperty(Ext, 'isSecure', null, "Ext.enableListenerCollection has been removed, please use Ext.env.Browser.isSecure instead"); /** * @member Ext * @method dispatch * Dispatches a request to a controller action. * @removed 2.0.0 Please use {@link Ext.app.Application#dispatch} instead */ Ext.deprecateMethod(Ext, 'dispatch', null, "Ext.dispatch() is deprecated, please use Ext.app.Application.dispatch() instead"); /** * @member Ext * @method getOrientation * Returns the current orientation of the mobile device. * @removed 2.0.0 * Please use {@link Ext.Viewport#getOrientation getOrientation} instead */ Ext.deprecateMethod(Ext, 'getOrientation', null, "Ext.getOrientation() has been removed, " + "please use Ext.Viewport.getOrientation() instead"); /** * @member Ext * @method reg * Registers a new xtype. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'reg', null, "Ext.reg() has been removed"); /** * @member Ext * @method preg * Registers a new ptype. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'preg', null, "Ext.preg() has been removed"); /** * @member Ext * @method redirect * Dispatches a request to a controller action, adding to the History stack * and updating the page url as necessary. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'redirect', null, "Ext.redirect() has been removed"); /** * @member Ext * @method regApplication * Creates a new Application class from the specified config object. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'regApplication', null, "Ext.regApplication() has been removed"); /** * @member Ext * @method regController * Creates a new Controller class from the specified config object. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'regController', null, "Ext.regController() has been removed"); /** * @member Ext * @method regLayout * Registers new layout type. * @removed 2.0.0 */ Ext.deprecateMethod(Ext, 'regLayout', null, "Ext.regLayout() has been removed"); //</deprecated>
gpl-2.0
gazoo74/linux
crypto/testmgr.c
128184
/* * Algorithm testing framework and tests. * * Copyright (c) 2002 James Morris <[email protected]> * Copyright (c) 2002 Jean-Francois Dive <[email protected]> * Copyright (c) 2007 Nokia Siemens Networks * Copyright (c) 2008 Herbert Xu <[email protected]> * Copyright (c) 2019 Google LLC * * Updated RFC4106 AES-GCM testing. * Authors: Aidan O'Mahony ([email protected]) * Adrian Hoban <[email protected]> * Gabriele Paoloni <[email protected]> * Tadeusz Struk ([email protected]) * Copyright (c) 2010, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ #include <crypto/aead.h> #include <crypto/hash.h> #include <crypto/skcipher.h> #include <linux/err.h> #include <linux/fips.h> #include <linux/module.h> #include <linux/once.h> #include <linux/random.h> #include <linux/scatterlist.h> #include <linux/slab.h> #include <linux/string.h> #include <crypto/rng.h> #include <crypto/drbg.h> #include <crypto/akcipher.h> #include <crypto/kpp.h> #include <crypto/acompress.h> #include <crypto/internal/simd.h> #include "internal.h" static bool notests; module_param(notests, bool, 0644); MODULE_PARM_DESC(notests, "disable crypto self-tests"); static bool panic_on_fail; module_param(panic_on_fail, bool, 0444); #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS static bool noextratests; module_param(noextratests, bool, 0644); MODULE_PARM_DESC(noextratests, "disable expensive crypto self-tests"); static unsigned int fuzz_iterations = 100; module_param(fuzz_iterations, uint, 0644); MODULE_PARM_DESC(fuzz_iterations, "number of fuzz test iterations"); DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test); EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test); #endif #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS /* a perfect nop */ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) { return 0; } #else #include "testmgr.h" /* * Need slab memory for testing (size in number of pages). */ #define XBUFSIZE 8 /* * Used by test_cipher() */ #define ENCRYPT 1 #define DECRYPT 0 struct aead_test_suite { const struct aead_testvec *vecs; unsigned int count; }; struct cipher_test_suite { const struct cipher_testvec *vecs; unsigned int count; }; struct comp_test_suite { struct { const struct comp_testvec *vecs; unsigned int count; } comp, decomp; }; struct hash_test_suite { const struct hash_testvec *vecs; unsigned int count; }; struct cprng_test_suite { const struct cprng_testvec *vecs; unsigned int count; }; struct drbg_test_suite { const struct drbg_testvec *vecs; unsigned int count; }; struct akcipher_test_suite { const struct akcipher_testvec *vecs; unsigned int count; }; struct kpp_test_suite { const struct kpp_testvec *vecs; unsigned int count; }; struct alg_test_desc { const char *alg; const char *generic_driver; int (*test)(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask); int fips_allowed; /* set if alg is allowed in fips mode */ union { struct aead_test_suite aead; struct cipher_test_suite cipher; struct comp_test_suite comp; struct hash_test_suite hash; struct cprng_test_suite cprng; struct drbg_test_suite drbg; struct akcipher_test_suite akcipher; struct kpp_test_suite kpp; } suite; }; static void hexdump(unsigned char *buf, unsigned int len) { print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false); } static int __testmgr_alloc_buf(char *buf[XBUFSIZE], int order) { int i; for (i = 0; i < XBUFSIZE; i++) { buf[i] = (char *)__get_free_pages(GFP_KERNEL, order); if (!buf[i]) goto err_free_buf; } return 0; err_free_buf: while (i-- > 0) free_pages((unsigned long)buf[i], order); return -ENOMEM; } static int testmgr_alloc_buf(char *buf[XBUFSIZE]) { return __testmgr_alloc_buf(buf, 0); } static void __testmgr_free_buf(char *buf[XBUFSIZE], int order) { int i; for (i = 0; i < XBUFSIZE; i++) free_pages((unsigned long)buf[i], order); } static void testmgr_free_buf(char *buf[XBUFSIZE]) { __testmgr_free_buf(buf, 0); } #define TESTMGR_POISON_BYTE 0xfe #define TESTMGR_POISON_LEN 16 static inline void testmgr_poison(void *addr, size_t len) { memset(addr, TESTMGR_POISON_BYTE, len); } /* Is the memory region still fully poisoned? */ static inline bool testmgr_is_poison(const void *addr, size_t len) { return memchr_inv(addr, TESTMGR_POISON_BYTE, len) == NULL; } /* flush type for hash algorithms */ enum flush_type { /* merge with update of previous buffer(s) */ FLUSH_TYPE_NONE = 0, /* update with previous buffer(s) before doing this one */ FLUSH_TYPE_FLUSH, /* likewise, but also export and re-import the intermediate state */ FLUSH_TYPE_REIMPORT, }; /* finalization function for hash algorithms */ enum finalization_type { FINALIZATION_TYPE_FINAL, /* use final() */ FINALIZATION_TYPE_FINUP, /* use finup() */ FINALIZATION_TYPE_DIGEST, /* use digest() */ }; #define TEST_SG_TOTAL 10000 /** * struct test_sg_division - description of a scatterlist entry * * This struct describes one entry of a scatterlist being constructed to check a * crypto test vector. * * @proportion_of_total: length of this chunk relative to the total length, * given as a proportion out of TEST_SG_TOTAL so that it * scales to fit any test vector * @offset: byte offset into a 2-page buffer at which this chunk will start * @offset_relative_to_alignmask: if true, add the algorithm's alignmask to the * @offset * @flush_type: for hashes, whether an update() should be done now vs. * continuing to accumulate data * @nosimd: if doing the pending update(), do it with SIMD disabled? */ struct test_sg_division { unsigned int proportion_of_total; unsigned int offset; bool offset_relative_to_alignmask; enum flush_type flush_type; bool nosimd; }; /** * struct testvec_config - configuration for testing a crypto test vector * * This struct describes the data layout and other parameters with which each * crypto test vector can be tested. * * @name: name of this config, logged for debugging purposes if a test fails * @inplace: operate on the data in-place, if applicable for the algorithm type? * @req_flags: extra request_flags, e.g. CRYPTO_TFM_REQ_MAY_SLEEP * @src_divs: description of how to arrange the source scatterlist * @dst_divs: description of how to arrange the dst scatterlist, if applicable * for the algorithm type. Defaults to @src_divs if unset. * @iv_offset: misalignment of the IV in the range [0..MAX_ALGAPI_ALIGNMASK+1], * where 0 is aligned to a 2*(MAX_ALGAPI_ALIGNMASK+1) byte boundary * @iv_offset_relative_to_alignmask: if true, add the algorithm's alignmask to * the @iv_offset * @finalization_type: what finalization function to use for hashes * @nosimd: execute with SIMD disabled? Requires !CRYPTO_TFM_REQ_MAY_SLEEP. */ struct testvec_config { const char *name; bool inplace; u32 req_flags; struct test_sg_division src_divs[XBUFSIZE]; struct test_sg_division dst_divs[XBUFSIZE]; unsigned int iv_offset; bool iv_offset_relative_to_alignmask; enum finalization_type finalization_type; bool nosimd; }; #define TESTVEC_CONFIG_NAMELEN 192 /* * The following are the lists of testvec_configs to test for each algorithm * type when the basic crypto self-tests are enabled, i.e. when * CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is unset. They aim to provide good test * coverage, while keeping the test time much shorter than the full fuzz tests * so that the basic tests can be enabled in a wider range of circumstances. */ /* Configs for skciphers and aeads */ static const struct testvec_config default_cipher_testvec_configs[] = { { .name = "in-place", .inplace = true, .src_divs = { { .proportion_of_total = 10000 } }, }, { .name = "out-of-place", .src_divs = { { .proportion_of_total = 10000 } }, }, { .name = "unaligned buffer, offset=1", .src_divs = { { .proportion_of_total = 10000, .offset = 1 } }, .iv_offset = 1, }, { .name = "buffer aligned only to alignmask", .src_divs = { { .proportion_of_total = 10000, .offset = 1, .offset_relative_to_alignmask = true, }, }, .iv_offset = 1, .iv_offset_relative_to_alignmask = true, }, { .name = "two even aligned splits", .src_divs = { { .proportion_of_total = 5000 }, { .proportion_of_total = 5000 }, }, }, { .name = "uneven misaligned splits, may sleep", .req_flags = CRYPTO_TFM_REQ_MAY_SLEEP, .src_divs = { { .proportion_of_total = 1900, .offset = 33 }, { .proportion_of_total = 3300, .offset = 7 }, { .proportion_of_total = 4800, .offset = 18 }, }, .iv_offset = 3, }, { .name = "misaligned splits crossing pages, inplace", .inplace = true, .src_divs = { { .proportion_of_total = 7500, .offset = PAGE_SIZE - 32 }, { .proportion_of_total = 2500, .offset = PAGE_SIZE - 7 }, }, } }; static const struct testvec_config default_hash_testvec_configs[] = { { .name = "init+update+final aligned buffer", .src_divs = { { .proportion_of_total = 10000 } }, .finalization_type = FINALIZATION_TYPE_FINAL, }, { .name = "init+finup aligned buffer", .src_divs = { { .proportion_of_total = 10000 } }, .finalization_type = FINALIZATION_TYPE_FINUP, }, { .name = "digest aligned buffer", .src_divs = { { .proportion_of_total = 10000 } }, .finalization_type = FINALIZATION_TYPE_DIGEST, }, { .name = "init+update+final misaligned buffer", .src_divs = { { .proportion_of_total = 10000, .offset = 1 } }, .finalization_type = FINALIZATION_TYPE_FINAL, }, { .name = "digest buffer aligned only to alignmask", .src_divs = { { .proportion_of_total = 10000, .offset = 1, .offset_relative_to_alignmask = true, }, }, .finalization_type = FINALIZATION_TYPE_DIGEST, }, { .name = "init+update+update+final two even splits", .src_divs = { { .proportion_of_total = 5000 }, { .proportion_of_total = 5000, .flush_type = FLUSH_TYPE_FLUSH, }, }, .finalization_type = FINALIZATION_TYPE_FINAL, }, { .name = "digest uneven misaligned splits, may sleep", .req_flags = CRYPTO_TFM_REQ_MAY_SLEEP, .src_divs = { { .proportion_of_total = 1900, .offset = 33 }, { .proportion_of_total = 3300, .offset = 7 }, { .proportion_of_total = 4800, .offset = 18 }, }, .finalization_type = FINALIZATION_TYPE_DIGEST, }, { .name = "digest misaligned splits crossing pages", .src_divs = { { .proportion_of_total = 7500, .offset = PAGE_SIZE - 32, }, { .proportion_of_total = 2500, .offset = PAGE_SIZE - 7, }, }, .finalization_type = FINALIZATION_TYPE_DIGEST, }, { .name = "import/export", .src_divs = { { .proportion_of_total = 6500, .flush_type = FLUSH_TYPE_REIMPORT, }, { .proportion_of_total = 3500, .flush_type = FLUSH_TYPE_REIMPORT, }, }, .finalization_type = FINALIZATION_TYPE_FINAL, } }; static unsigned int count_test_sg_divisions(const struct test_sg_division *divs) { unsigned int remaining = TEST_SG_TOTAL; unsigned int ndivs = 0; do { remaining -= divs[ndivs++].proportion_of_total; } while (remaining); return ndivs; } #define SGDIVS_HAVE_FLUSHES BIT(0) #define SGDIVS_HAVE_NOSIMD BIT(1) static bool valid_sg_divisions(const struct test_sg_division *divs, unsigned int count, int *flags_ret) { unsigned int total = 0; unsigned int i; for (i = 0; i < count && total != TEST_SG_TOTAL; i++) { if (divs[i].proportion_of_total <= 0 || divs[i].proportion_of_total > TEST_SG_TOTAL - total) return false; total += divs[i].proportion_of_total; if (divs[i].flush_type != FLUSH_TYPE_NONE) *flags_ret |= SGDIVS_HAVE_FLUSHES; if (divs[i].nosimd) *flags_ret |= SGDIVS_HAVE_NOSIMD; } return total == TEST_SG_TOTAL && memchr_inv(&divs[i], 0, (count - i) * sizeof(divs[0])) == NULL; } /* * Check whether the given testvec_config is valid. This isn't strictly needed * since every testvec_config should be valid, but check anyway so that people * don't unknowingly add broken configs that don't do what they wanted. */ static bool valid_testvec_config(const struct testvec_config *cfg) { int flags = 0; if (cfg->name == NULL) return false; if (!valid_sg_divisions(cfg->src_divs, ARRAY_SIZE(cfg->src_divs), &flags)) return false; if (cfg->dst_divs[0].proportion_of_total) { if (!valid_sg_divisions(cfg->dst_divs, ARRAY_SIZE(cfg->dst_divs), &flags)) return false; } else { if (memchr_inv(cfg->dst_divs, 0, sizeof(cfg->dst_divs))) return false; /* defaults to dst_divs=src_divs */ } if (cfg->iv_offset + (cfg->iv_offset_relative_to_alignmask ? MAX_ALGAPI_ALIGNMASK : 0) > MAX_ALGAPI_ALIGNMASK + 1) return false; if ((flags & (SGDIVS_HAVE_FLUSHES | SGDIVS_HAVE_NOSIMD)) && cfg->finalization_type == FINALIZATION_TYPE_DIGEST) return false; if ((cfg->nosimd || (flags & SGDIVS_HAVE_NOSIMD)) && (cfg->req_flags & CRYPTO_TFM_REQ_MAY_SLEEP)) return false; return true; } struct test_sglist { char *bufs[XBUFSIZE]; struct scatterlist sgl[XBUFSIZE]; struct scatterlist sgl_saved[XBUFSIZE]; struct scatterlist *sgl_ptr; unsigned int nents; }; static int init_test_sglist(struct test_sglist *tsgl) { return __testmgr_alloc_buf(tsgl->bufs, 1 /* two pages per buffer */); } static void destroy_test_sglist(struct test_sglist *tsgl) { return __testmgr_free_buf(tsgl->bufs, 1 /* two pages per buffer */); } /** * build_test_sglist() - build a scatterlist for a crypto test * * @tsgl: the scatterlist to build. @tsgl->bufs[] contains an array of 2-page * buffers which the scatterlist @tsgl->sgl[] will be made to point into. * @divs: the layout specification on which the scatterlist will be based * @alignmask: the algorithm's alignmask * @total_len: the total length of the scatterlist to build in bytes * @data: if non-NULL, the buffers will be filled with this data until it ends. * Otherwise the buffers will be poisoned. In both cases, some bytes * past the end of each buffer will be poisoned to help detect overruns. * @out_divs: if non-NULL, the test_sg_division to which each scatterlist entry * corresponds will be returned here. This will match @divs except * that divisions resolving to a length of 0 are omitted as they are * not included in the scatterlist. * * Return: 0 or a -errno value */ static int build_test_sglist(struct test_sglist *tsgl, const struct test_sg_division *divs, const unsigned int alignmask, const unsigned int total_len, struct iov_iter *data, const struct test_sg_division *out_divs[XBUFSIZE]) { struct { const struct test_sg_division *div; size_t length; } partitions[XBUFSIZE]; const unsigned int ndivs = count_test_sg_divisions(divs); unsigned int len_remaining = total_len; unsigned int i; BUILD_BUG_ON(ARRAY_SIZE(partitions) != ARRAY_SIZE(tsgl->sgl)); if (WARN_ON(ndivs > ARRAY_SIZE(partitions))) return -EINVAL; /* Calculate the (div, length) pairs */ tsgl->nents = 0; for (i = 0; i < ndivs; i++) { unsigned int len_this_sg = min(len_remaining, (total_len * divs[i].proportion_of_total + TEST_SG_TOTAL / 2) / TEST_SG_TOTAL); if (len_this_sg != 0) { partitions[tsgl->nents].div = &divs[i]; partitions[tsgl->nents].length = len_this_sg; tsgl->nents++; len_remaining -= len_this_sg; } } if (tsgl->nents == 0) { partitions[tsgl->nents].div = &divs[0]; partitions[tsgl->nents].length = 0; tsgl->nents++; } partitions[tsgl->nents - 1].length += len_remaining; /* Set up the sgl entries and fill the data or poison */ sg_init_table(tsgl->sgl, tsgl->nents); for (i = 0; i < tsgl->nents; i++) { unsigned int offset = partitions[i].div->offset; void *addr; if (partitions[i].div->offset_relative_to_alignmask) offset += alignmask; while (offset + partitions[i].length + TESTMGR_POISON_LEN > 2 * PAGE_SIZE) { if (WARN_ON(offset <= 0)) return -EINVAL; offset /= 2; } addr = &tsgl->bufs[i][offset]; sg_set_buf(&tsgl->sgl[i], addr, partitions[i].length); if (out_divs) out_divs[i] = partitions[i].div; if (data) { size_t copy_len, copied; copy_len = min(partitions[i].length, data->count); copied = copy_from_iter(addr, copy_len, data); if (WARN_ON(copied != copy_len)) return -EINVAL; testmgr_poison(addr + copy_len, partitions[i].length + TESTMGR_POISON_LEN - copy_len); } else { testmgr_poison(addr, partitions[i].length + TESTMGR_POISON_LEN); } } sg_mark_end(&tsgl->sgl[tsgl->nents - 1]); tsgl->sgl_ptr = tsgl->sgl; memcpy(tsgl->sgl_saved, tsgl->sgl, tsgl->nents * sizeof(tsgl->sgl[0])); return 0; } /* * Verify that a scatterlist crypto operation produced the correct output. * * @tsgl: scatterlist containing the actual output * @expected_output: buffer containing the expected output * @len_to_check: length of @expected_output in bytes * @unchecked_prefix_len: number of ignored bytes in @tsgl prior to real result * @check_poison: verify that the poison bytes after each chunk are intact? * * Return: 0 if correct, -EINVAL if incorrect, -EOVERFLOW if buffer overrun. */ static int verify_correct_output(const struct test_sglist *tsgl, const char *expected_output, unsigned int len_to_check, unsigned int unchecked_prefix_len, bool check_poison) { unsigned int i; for (i = 0; i < tsgl->nents; i++) { struct scatterlist *sg = &tsgl->sgl_ptr[i]; unsigned int len = sg->length; unsigned int offset = sg->offset; const char *actual_output; if (unchecked_prefix_len) { if (unchecked_prefix_len >= len) { unchecked_prefix_len -= len; continue; } offset += unchecked_prefix_len; len -= unchecked_prefix_len; unchecked_prefix_len = 0; } len = min(len, len_to_check); actual_output = page_address(sg_page(sg)) + offset; if (memcmp(expected_output, actual_output, len) != 0) return -EINVAL; if (check_poison && !testmgr_is_poison(actual_output + len, TESTMGR_POISON_LEN)) return -EOVERFLOW; len_to_check -= len; expected_output += len; } if (WARN_ON(len_to_check != 0)) return -EINVAL; return 0; } static bool is_test_sglist_corrupted(const struct test_sglist *tsgl) { unsigned int i; for (i = 0; i < tsgl->nents; i++) { if (tsgl->sgl[i].page_link != tsgl->sgl_saved[i].page_link) return true; if (tsgl->sgl[i].offset != tsgl->sgl_saved[i].offset) return true; if (tsgl->sgl[i].length != tsgl->sgl_saved[i].length) return true; } return false; } struct cipher_test_sglists { struct test_sglist src; struct test_sglist dst; }; static struct cipher_test_sglists *alloc_cipher_test_sglists(void) { struct cipher_test_sglists *tsgls; tsgls = kmalloc(sizeof(*tsgls), GFP_KERNEL); if (!tsgls) return NULL; if (init_test_sglist(&tsgls->src) != 0) goto fail_kfree; if (init_test_sglist(&tsgls->dst) != 0) goto fail_destroy_src; return tsgls; fail_destroy_src: destroy_test_sglist(&tsgls->src); fail_kfree: kfree(tsgls); return NULL; } static void free_cipher_test_sglists(struct cipher_test_sglists *tsgls) { if (tsgls) { destroy_test_sglist(&tsgls->src); destroy_test_sglist(&tsgls->dst); kfree(tsgls); } } /* Build the src and dst scatterlists for an skcipher or AEAD test */ static int build_cipher_test_sglists(struct cipher_test_sglists *tsgls, const struct testvec_config *cfg, unsigned int alignmask, unsigned int src_total_len, unsigned int dst_total_len, const struct kvec *inputs, unsigned int nr_inputs) { struct iov_iter input; int err; iov_iter_kvec(&input, WRITE, inputs, nr_inputs, src_total_len); err = build_test_sglist(&tsgls->src, cfg->src_divs, alignmask, cfg->inplace ? max(dst_total_len, src_total_len) : src_total_len, &input, NULL); if (err) return err; if (cfg->inplace) { tsgls->dst.sgl_ptr = tsgls->src.sgl; tsgls->dst.nents = tsgls->src.nents; return 0; } return build_test_sglist(&tsgls->dst, cfg->dst_divs[0].proportion_of_total ? cfg->dst_divs : cfg->src_divs, alignmask, dst_total_len, NULL, NULL); } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS /* Generate a random length in range [0, max_len], but prefer smaller values */ static unsigned int generate_random_length(unsigned int max_len) { unsigned int len = prandom_u32() % (max_len + 1); switch (prandom_u32() % 4) { case 0: return len % 64; case 1: return len % 256; case 2: return len % 1024; default: return len; } } /* Sometimes make some random changes to the given data buffer */ static void mutate_buffer(u8 *buf, size_t count) { size_t num_flips; size_t i; size_t pos; /* Sometimes flip some bits */ if (prandom_u32() % 4 == 0) { num_flips = min_t(size_t, 1 << (prandom_u32() % 8), count * 8); for (i = 0; i < num_flips; i++) { pos = prandom_u32() % (count * 8); buf[pos / 8] ^= 1 << (pos % 8); } } /* Sometimes flip some bytes */ if (prandom_u32() % 4 == 0) { num_flips = min_t(size_t, 1 << (prandom_u32() % 8), count); for (i = 0; i < num_flips; i++) buf[prandom_u32() % count] ^= 0xff; } } /* Randomly generate 'count' bytes, but sometimes make them "interesting" */ static void generate_random_bytes(u8 *buf, size_t count) { u8 b; u8 increment; size_t i; if (count == 0) return; switch (prandom_u32() % 8) { /* Choose a generation strategy */ case 0: case 1: /* All the same byte, plus optional mutations */ switch (prandom_u32() % 4) { case 0: b = 0x00; break; case 1: b = 0xff; break; default: b = (u8)prandom_u32(); break; } memset(buf, b, count); mutate_buffer(buf, count); break; case 2: /* Ascending or descending bytes, plus optional mutations */ increment = (u8)prandom_u32(); b = (u8)prandom_u32(); for (i = 0; i < count; i++, b += increment) buf[i] = b; mutate_buffer(buf, count); break; default: /* Fully random bytes */ for (i = 0; i < count; i++) buf[i] = (u8)prandom_u32(); } } static char *generate_random_sgl_divisions(struct test_sg_division *divs, size_t max_divs, char *p, char *end, bool gen_flushes, u32 req_flags) { struct test_sg_division *div = divs; unsigned int remaining = TEST_SG_TOTAL; do { unsigned int this_len; const char *flushtype_str; if (div == &divs[max_divs - 1] || prandom_u32() % 2 == 0) this_len = remaining; else this_len = 1 + (prandom_u32() % remaining); div->proportion_of_total = this_len; if (prandom_u32() % 4 == 0) div->offset = (PAGE_SIZE - 128) + (prandom_u32() % 128); else if (prandom_u32() % 2 == 0) div->offset = prandom_u32() % 32; else div->offset = prandom_u32() % PAGE_SIZE; if (prandom_u32() % 8 == 0) div->offset_relative_to_alignmask = true; div->flush_type = FLUSH_TYPE_NONE; if (gen_flushes) { switch (prandom_u32() % 4) { case 0: div->flush_type = FLUSH_TYPE_REIMPORT; break; case 1: div->flush_type = FLUSH_TYPE_FLUSH; break; } } if (div->flush_type != FLUSH_TYPE_NONE && !(req_flags & CRYPTO_TFM_REQ_MAY_SLEEP) && prandom_u32() % 2 == 0) div->nosimd = true; switch (div->flush_type) { case FLUSH_TYPE_FLUSH: if (div->nosimd) flushtype_str = "<flush,nosimd>"; else flushtype_str = "<flush>"; break; case FLUSH_TYPE_REIMPORT: if (div->nosimd) flushtype_str = "<reimport,nosimd>"; else flushtype_str = "<reimport>"; break; default: flushtype_str = ""; break; } BUILD_BUG_ON(TEST_SG_TOTAL != 10000); /* for "%u.%u%%" */ p += scnprintf(p, end - p, "%s%u.%u%%@%s+%u%s", flushtype_str, this_len / 100, this_len % 100, div->offset_relative_to_alignmask ? "alignmask" : "", div->offset, this_len == remaining ? "" : ", "); remaining -= this_len; div++; } while (remaining); return p; } /* Generate a random testvec_config for fuzz testing */ static void generate_random_testvec_config(struct testvec_config *cfg, char *name, size_t max_namelen) { char *p = name; char * const end = name + max_namelen; memset(cfg, 0, sizeof(*cfg)); cfg->name = name; p += scnprintf(p, end - p, "random:"); if (prandom_u32() % 2 == 0) { cfg->inplace = true; p += scnprintf(p, end - p, " inplace"); } if (prandom_u32() % 2 == 0) { cfg->req_flags |= CRYPTO_TFM_REQ_MAY_SLEEP; p += scnprintf(p, end - p, " may_sleep"); } switch (prandom_u32() % 4) { case 0: cfg->finalization_type = FINALIZATION_TYPE_FINAL; p += scnprintf(p, end - p, " use_final"); break; case 1: cfg->finalization_type = FINALIZATION_TYPE_FINUP; p += scnprintf(p, end - p, " use_finup"); break; default: cfg->finalization_type = FINALIZATION_TYPE_DIGEST; p += scnprintf(p, end - p, " use_digest"); break; } if (!(cfg->req_flags & CRYPTO_TFM_REQ_MAY_SLEEP) && prandom_u32() % 2 == 0) { cfg->nosimd = true; p += scnprintf(p, end - p, " nosimd"); } p += scnprintf(p, end - p, " src_divs=["); p = generate_random_sgl_divisions(cfg->src_divs, ARRAY_SIZE(cfg->src_divs), p, end, (cfg->finalization_type != FINALIZATION_TYPE_DIGEST), cfg->req_flags); p += scnprintf(p, end - p, "]"); if (!cfg->inplace && prandom_u32() % 2 == 0) { p += scnprintf(p, end - p, " dst_divs=["); p = generate_random_sgl_divisions(cfg->dst_divs, ARRAY_SIZE(cfg->dst_divs), p, end, false, cfg->req_flags); p += scnprintf(p, end - p, "]"); } if (prandom_u32() % 2 == 0) { cfg->iv_offset = 1 + (prandom_u32() % MAX_ALGAPI_ALIGNMASK); p += scnprintf(p, end - p, " iv_offset=%u", cfg->iv_offset); } WARN_ON_ONCE(!valid_testvec_config(cfg)); } static void crypto_disable_simd_for_test(void) { preempt_disable(); __this_cpu_write(crypto_simd_disabled_for_test, true); } static void crypto_reenable_simd_for_test(void) { __this_cpu_write(crypto_simd_disabled_for_test, false); preempt_enable(); } /* * Given an algorithm name, build the name of the generic implementation of that * algorithm, assuming the usual naming convention. Specifically, this appends * "-generic" to every part of the name that is not a template name. Examples: * * aes => aes-generic * cbc(aes) => cbc(aes-generic) * cts(cbc(aes)) => cts(cbc(aes-generic)) * rfc7539(chacha20,poly1305) => rfc7539(chacha20-generic,poly1305-generic) * * Return: 0 on success, or -ENAMETOOLONG if the generic name would be too long */ static int build_generic_driver_name(const char *algname, char driver_name[CRYPTO_MAX_ALG_NAME]) { const char *in = algname; char *out = driver_name; size_t len = strlen(algname); if (len >= CRYPTO_MAX_ALG_NAME) goto too_long; do { const char *in_saved = in; while (*in && *in != '(' && *in != ')' && *in != ',') *out++ = *in++; if (*in != '(' && in > in_saved) { len += 8; if (len >= CRYPTO_MAX_ALG_NAME) goto too_long; memcpy(out, "-generic", 8); out += 8; } } while ((*out++ = *in++) != '\0'); return 0; too_long: pr_err("alg: generic driver name for \"%s\" would be too long\n", algname); return -ENAMETOOLONG; } #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static void crypto_disable_simd_for_test(void) { } static void crypto_reenable_simd_for_test(void) { } #endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int do_ahash_op(int (*op)(struct ahash_request *req), struct ahash_request *req, struct crypto_wait *wait, bool nosimd) { int err; if (nosimd) crypto_disable_simd_for_test(); err = op(req); if (nosimd) crypto_reenable_simd_for_test(); return crypto_wait_req(err, wait); } static int check_nonfinal_hash_op(const char *op, int err, u8 *result, unsigned int digestsize, const char *driver, const char *vec_name, const struct testvec_config *cfg) { if (err) { pr_err("alg: hash: %s %s() failed with err %d on test vector %s, cfg=\"%s\"\n", driver, op, err, vec_name, cfg->name); return err; } if (!testmgr_is_poison(result, digestsize)) { pr_err("alg: hash: %s %s() used result buffer on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return -EINVAL; } return 0; } static int test_hash_vec_cfg(const char *driver, const struct hash_testvec *vec, const char *vec_name, const struct testvec_config *cfg, struct ahash_request *req, struct test_sglist *tsgl, u8 *hashstate) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); const unsigned int alignmask = crypto_ahash_alignmask(tfm); const unsigned int digestsize = crypto_ahash_digestsize(tfm); const unsigned int statesize = crypto_ahash_statesize(tfm); const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags; const struct test_sg_division *divs[XBUFSIZE]; DECLARE_CRYPTO_WAIT(wait); struct kvec _input; struct iov_iter input; unsigned int i; struct scatterlist *pending_sgl; unsigned int pending_len; u8 result[HASH_MAX_DIGESTSIZE + TESTMGR_POISON_LEN]; int err; /* Set the key, if specified */ if (vec->ksize) { err = crypto_ahash_setkey(tfm, vec->key, vec->ksize); if (err) { if (err == vec->setkey_error) return 0; pr_err("alg: hash: %s setkey failed on test vector %s; expected_error=%d, actual_error=%d, flags=%#x\n", driver, vec_name, vec->setkey_error, err, crypto_ahash_get_flags(tfm)); return err; } if (vec->setkey_error) { pr_err("alg: hash: %s setkey unexpectedly succeeded on test vector %s; expected_error=%d\n", driver, vec_name, vec->setkey_error); return -EINVAL; } } /* Build the scatterlist for the source data */ _input.iov_base = (void *)vec->plaintext; _input.iov_len = vec->psize; iov_iter_kvec(&input, WRITE, &_input, 1, vec->psize); err = build_test_sglist(tsgl, cfg->src_divs, alignmask, vec->psize, &input, divs); if (err) { pr_err("alg: hash: %s: error preparing scatterlist for test vector %s, cfg=\"%s\"\n", driver, vec_name, cfg->name); return err; } /* Do the actual hashing */ testmgr_poison(req->__ctx, crypto_ahash_reqsize(tfm)); testmgr_poison(result, digestsize + TESTMGR_POISON_LEN); if (cfg->finalization_type == FINALIZATION_TYPE_DIGEST || vec->digest_error) { /* Just using digest() */ ahash_request_set_callback(req, req_flags, crypto_req_done, &wait); ahash_request_set_crypt(req, tsgl->sgl, result, vec->psize); err = do_ahash_op(crypto_ahash_digest, req, &wait, cfg->nosimd); if (err) { if (err == vec->digest_error) return 0; pr_err("alg: hash: %s digest() failed on test vector %s; expected_error=%d, actual_error=%d, cfg=\"%s\"\n", driver, vec_name, vec->digest_error, err, cfg->name); return err; } if (vec->digest_error) { pr_err("alg: hash: %s digest() unexpectedly succeeded on test vector %s; expected_error=%d, cfg=\"%s\"\n", driver, vec_name, vec->digest_error, cfg->name); return -EINVAL; } goto result_ready; } /* Using init(), zero or more update(), then final() or finup() */ ahash_request_set_callback(req, req_flags, crypto_req_done, &wait); ahash_request_set_crypt(req, NULL, result, 0); err = do_ahash_op(crypto_ahash_init, req, &wait, cfg->nosimd); err = check_nonfinal_hash_op("init", err, result, digestsize, driver, vec_name, cfg); if (err) return err; pending_sgl = NULL; pending_len = 0; for (i = 0; i < tsgl->nents; i++) { if (divs[i]->flush_type != FLUSH_TYPE_NONE && pending_sgl != NULL) { /* update() with the pending data */ ahash_request_set_callback(req, req_flags, crypto_req_done, &wait); ahash_request_set_crypt(req, pending_sgl, result, pending_len); err = do_ahash_op(crypto_ahash_update, req, &wait, divs[i]->nosimd); err = check_nonfinal_hash_op("update", err, result, digestsize, driver, vec_name, cfg); if (err) return err; pending_sgl = NULL; pending_len = 0; } if (divs[i]->flush_type == FLUSH_TYPE_REIMPORT) { /* Test ->export() and ->import() */ testmgr_poison(hashstate + statesize, TESTMGR_POISON_LEN); err = crypto_ahash_export(req, hashstate); err = check_nonfinal_hash_op("export", err, result, digestsize, driver, vec_name, cfg); if (err) return err; if (!testmgr_is_poison(hashstate + statesize, TESTMGR_POISON_LEN)) { pr_err("alg: hash: %s export() overran state buffer on test vector %s, cfg=\"%s\"\n", driver, vec_name, cfg->name); return -EOVERFLOW; } testmgr_poison(req->__ctx, crypto_ahash_reqsize(tfm)); err = crypto_ahash_import(req, hashstate); err = check_nonfinal_hash_op("import", err, result, digestsize, driver, vec_name, cfg); if (err) return err; } if (pending_sgl == NULL) pending_sgl = &tsgl->sgl[i]; pending_len += tsgl->sgl[i].length; } ahash_request_set_callback(req, req_flags, crypto_req_done, &wait); ahash_request_set_crypt(req, pending_sgl, result, pending_len); if (cfg->finalization_type == FINALIZATION_TYPE_FINAL) { /* finish with update() and final() */ err = do_ahash_op(crypto_ahash_update, req, &wait, cfg->nosimd); err = check_nonfinal_hash_op("update", err, result, digestsize, driver, vec_name, cfg); if (err) return err; err = do_ahash_op(crypto_ahash_final, req, &wait, cfg->nosimd); if (err) { pr_err("alg: hash: %s final() failed with err %d on test vector %s, cfg=\"%s\"\n", driver, err, vec_name, cfg->name); return err; } } else { /* finish with finup() */ err = do_ahash_op(crypto_ahash_finup, req, &wait, cfg->nosimd); if (err) { pr_err("alg: hash: %s finup() failed with err %d on test vector %s, cfg=\"%s\"\n", driver, err, vec_name, cfg->name); return err; } } result_ready: /* Check that the algorithm produced the correct digest */ if (memcmp(result, vec->digest, digestsize) != 0) { pr_err("alg: hash: %s test failed (wrong result) on test vector %s, cfg=\"%s\"\n", driver, vec_name, cfg->name); return -EINVAL; } if (!testmgr_is_poison(&result[digestsize], TESTMGR_POISON_LEN)) { pr_err("alg: hash: %s overran result buffer on test vector %s, cfg=\"%s\"\n", driver, vec_name, cfg->name); return -EOVERFLOW; } return 0; } static int test_hash_vec(const char *driver, const struct hash_testvec *vec, unsigned int vec_num, struct ahash_request *req, struct test_sglist *tsgl, u8 *hashstate) { char vec_name[16]; unsigned int i; int err; sprintf(vec_name, "%u", vec_num); for (i = 0; i < ARRAY_SIZE(default_hash_testvec_configs); i++) { err = test_hash_vec_cfg(driver, vec, vec_name, &default_hash_testvec_configs[i], req, tsgl, hashstate); if (err) return err; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS if (!noextratests) { struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; for (i = 0; i < fuzz_iterations; i++) { generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_hash_vec_cfg(driver, vec, vec_name, &cfg, req, tsgl, hashstate); if (err) return err; } } #endif return 0; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS /* * Generate a hash test vector from the given implementation. * Assumes the buffers in 'vec' were already allocated. */ static void generate_random_hash_testvec(struct crypto_shash *tfm, struct hash_testvec *vec, unsigned int maxkeysize, unsigned int maxdatasize, char *name, size_t max_namelen) { SHASH_DESC_ON_STACK(desc, tfm); /* Data */ vec->psize = generate_random_length(maxdatasize); generate_random_bytes((u8 *)vec->plaintext, vec->psize); /* * Key: length in range [1, maxkeysize], but usually choose maxkeysize. * If algorithm is unkeyed, then maxkeysize == 0 and set ksize = 0. */ vec->setkey_error = 0; vec->ksize = 0; if (maxkeysize) { vec->ksize = maxkeysize; if (prandom_u32() % 4 == 0) vec->ksize = 1 + (prandom_u32() % maxkeysize); generate_random_bytes((u8 *)vec->key, vec->ksize); vec->setkey_error = crypto_shash_setkey(tfm, vec->key, vec->ksize); /* If the key couldn't be set, no need to continue to digest. */ if (vec->setkey_error) goto done; } /* Digest */ desc->tfm = tfm; vec->digest_error = crypto_shash_digest(desc, vec->plaintext, vec->psize, (u8 *)vec->digest); done: snprintf(name, max_namelen, "\"random: psize=%u ksize=%u\"", vec->psize, vec->ksize); } /* * Test the hash algorithm represented by @req against the corresponding generic * implementation, if one is available. */ static int test_hash_vs_generic_impl(const char *driver, const char *generic_driver, unsigned int maxkeysize, struct ahash_request *req, struct test_sglist *tsgl, u8 *hashstate) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); const unsigned int digestsize = crypto_ahash_digestsize(tfm); const unsigned int blocksize = crypto_ahash_blocksize(tfm); const unsigned int maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN; const char *algname = crypto_hash_alg_common(tfm)->base.cra_name; char _generic_driver[CRYPTO_MAX_ALG_NAME]; struct crypto_shash *generic_tfm = NULL; unsigned int i; struct hash_testvec vec = { 0 }; char vec_name[64]; struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; if (noextratests) return 0; if (!generic_driver) { /* Use default naming convention? */ err = build_generic_driver_name(algname, _generic_driver); if (err) return err; generic_driver = _generic_driver; } if (strcmp(generic_driver, driver) == 0) /* Already the generic impl? */ return 0; generic_tfm = crypto_alloc_shash(generic_driver, 0, 0); if (IS_ERR(generic_tfm)) { err = PTR_ERR(generic_tfm); if (err == -ENOENT) { pr_warn("alg: hash: skipping comparison tests for %s because %s is unavailable\n", driver, generic_driver); return 0; } pr_err("alg: hash: error allocating %s (generic impl of %s): %d\n", generic_driver, algname, err); return err; } /* Check the algorithm properties for consistency. */ if (digestsize != crypto_shash_digestsize(generic_tfm)) { pr_err("alg: hash: digestsize for %s (%u) doesn't match generic impl (%u)\n", driver, digestsize, crypto_shash_digestsize(generic_tfm)); err = -EINVAL; goto out; } if (blocksize != crypto_shash_blocksize(generic_tfm)) { pr_err("alg: hash: blocksize for %s (%u) doesn't match generic impl (%u)\n", driver, blocksize, crypto_shash_blocksize(generic_tfm)); err = -EINVAL; goto out; } /* * Now generate test vectors using the generic implementation, and test * the other implementation against them. */ vec.key = kmalloc(maxkeysize, GFP_KERNEL); vec.plaintext = kmalloc(maxdatasize, GFP_KERNEL); vec.digest = kmalloc(digestsize, GFP_KERNEL); if (!vec.key || !vec.plaintext || !vec.digest) { err = -ENOMEM; goto out; } for (i = 0; i < fuzz_iterations * 8; i++) { generate_random_hash_testvec(generic_tfm, &vec, maxkeysize, maxdatasize, vec_name, sizeof(vec_name)); generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_hash_vec_cfg(driver, &vec, vec_name, &cfg, req, tsgl, hashstate); if (err) goto out; cond_resched(); } err = 0; out: kfree(vec.key); kfree(vec.plaintext); kfree(vec.digest); crypto_free_shash(generic_tfm); return err; } #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int test_hash_vs_generic_impl(const char *driver, const char *generic_driver, unsigned int maxkeysize, struct ahash_request *req, struct test_sglist *tsgl, u8 *hashstate) { return 0; } #endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int __alg_test_hash(const struct hash_testvec *vecs, unsigned int num_vecs, const char *driver, u32 type, u32 mask, const char *generic_driver, unsigned int maxkeysize) { struct crypto_ahash *tfm; struct ahash_request *req = NULL; struct test_sglist *tsgl = NULL; u8 *hashstate = NULL; unsigned int i; int err; tfm = crypto_alloc_ahash(driver, type, mask); if (IS_ERR(tfm)) { pr_err("alg: hash: failed to allocate transform for %s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) { pr_err("alg: hash: failed to allocate request for %s\n", driver); err = -ENOMEM; goto out; } tsgl = kmalloc(sizeof(*tsgl), GFP_KERNEL); if (!tsgl || init_test_sglist(tsgl) != 0) { pr_err("alg: hash: failed to allocate test buffers for %s\n", driver); kfree(tsgl); tsgl = NULL; err = -ENOMEM; goto out; } hashstate = kmalloc(crypto_ahash_statesize(tfm) + TESTMGR_POISON_LEN, GFP_KERNEL); if (!hashstate) { pr_err("alg: hash: failed to allocate hash state buffer for %s\n", driver); err = -ENOMEM; goto out; } for (i = 0; i < num_vecs; i++) { err = test_hash_vec(driver, &vecs[i], i, req, tsgl, hashstate); if (err) goto out; } err = test_hash_vs_generic_impl(driver, generic_driver, maxkeysize, req, tsgl, hashstate); out: kfree(hashstate); if (tsgl) { destroy_test_sglist(tsgl); kfree(tsgl); } ahash_request_free(req); crypto_free_ahash(tfm); return err; } static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { const struct hash_testvec *template = desc->suite.hash.vecs; unsigned int tcount = desc->suite.hash.count; unsigned int nr_unkeyed, nr_keyed; unsigned int maxkeysize = 0; int err; /* * For OPTIONAL_KEY algorithms, we have to do all the unkeyed tests * first, before setting a key on the tfm. To make this easier, we * require that the unkeyed test vectors (if any) are listed first. */ for (nr_unkeyed = 0; nr_unkeyed < tcount; nr_unkeyed++) { if (template[nr_unkeyed].ksize) break; } for (nr_keyed = 0; nr_unkeyed + nr_keyed < tcount; nr_keyed++) { if (!template[nr_unkeyed + nr_keyed].ksize) { pr_err("alg: hash: test vectors for %s out of order, " "unkeyed ones must come first\n", desc->alg); return -EINVAL; } maxkeysize = max_t(unsigned int, maxkeysize, template[nr_unkeyed + nr_keyed].ksize); } err = 0; if (nr_unkeyed) { err = __alg_test_hash(template, nr_unkeyed, driver, type, mask, desc->generic_driver, maxkeysize); template += nr_unkeyed; } if (!err && nr_keyed) err = __alg_test_hash(template, nr_keyed, driver, type, mask, desc->generic_driver, maxkeysize); return err; } static int test_aead_vec_cfg(const char *driver, int enc, const struct aead_testvec *vec, const char *vec_name, const struct testvec_config *cfg, struct aead_request *req, struct cipher_test_sglists *tsgls) { struct crypto_aead *tfm = crypto_aead_reqtfm(req); const unsigned int alignmask = crypto_aead_alignmask(tfm); const unsigned int ivsize = crypto_aead_ivsize(tfm); const unsigned int authsize = vec->clen - vec->plen; const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags; const char *op = enc ? "encryption" : "decryption"; DECLARE_CRYPTO_WAIT(wait); u8 _iv[3 * (MAX_ALGAPI_ALIGNMASK + 1) + MAX_IVLEN]; u8 *iv = PTR_ALIGN(&_iv[0], 2 * (MAX_ALGAPI_ALIGNMASK + 1)) + cfg->iv_offset + (cfg->iv_offset_relative_to_alignmask ? alignmask : 0); struct kvec input[2]; int expected_error; int err; /* Set the key */ if (vec->wk) crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS); else crypto_aead_clear_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS); err = crypto_aead_setkey(tfm, vec->key, vec->klen); if (err && err != vec->setkey_error) { pr_err("alg: aead: %s setkey failed on test vector %s; expected_error=%d, actual_error=%d, flags=%#x\n", driver, vec_name, vec->setkey_error, err, crypto_aead_get_flags(tfm)); return err; } if (!err && vec->setkey_error) { pr_err("alg: aead: %s setkey unexpectedly succeeded on test vector %s; expected_error=%d\n", driver, vec_name, vec->setkey_error); return -EINVAL; } /* Set the authentication tag size */ err = crypto_aead_setauthsize(tfm, authsize); if (err && err != vec->setauthsize_error) { pr_err("alg: aead: %s setauthsize failed on test vector %s; expected_error=%d, actual_error=%d\n", driver, vec_name, vec->setauthsize_error, err); return err; } if (!err && vec->setauthsize_error) { pr_err("alg: aead: %s setauthsize unexpectedly succeeded on test vector %s; expected_error=%d\n", driver, vec_name, vec->setauthsize_error); return -EINVAL; } if (vec->setkey_error || vec->setauthsize_error) return 0; /* The IV must be copied to a buffer, as the algorithm may modify it */ if (WARN_ON(ivsize > MAX_IVLEN)) return -EINVAL; if (vec->iv) memcpy(iv, vec->iv, ivsize); else memset(iv, 0, ivsize); /* Build the src/dst scatterlists */ input[0].iov_base = (void *)vec->assoc; input[0].iov_len = vec->alen; input[1].iov_base = enc ? (void *)vec->ptext : (void *)vec->ctext; input[1].iov_len = enc ? vec->plen : vec->clen; err = build_cipher_test_sglists(tsgls, cfg, alignmask, vec->alen + (enc ? vec->plen : vec->clen), vec->alen + (enc ? vec->clen : vec->plen), input, 2); if (err) { pr_err("alg: aead: %s %s: error preparing scatterlists for test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } /* Do the actual encryption or decryption */ testmgr_poison(req->__ctx, crypto_aead_reqsize(tfm)); aead_request_set_callback(req, req_flags, crypto_req_done, &wait); aead_request_set_crypt(req, tsgls->src.sgl_ptr, tsgls->dst.sgl_ptr, enc ? vec->plen : vec->clen, iv); aead_request_set_ad(req, vec->alen); if (cfg->nosimd) crypto_disable_simd_for_test(); err = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); if (cfg->nosimd) crypto_reenable_simd_for_test(); err = crypto_wait_req(err, &wait); /* Check that the algorithm didn't overwrite things it shouldn't have */ if (req->cryptlen != (enc ? vec->plen : vec->clen) || req->assoclen != vec->alen || req->iv != iv || req->src != tsgls->src.sgl_ptr || req->dst != tsgls->dst.sgl_ptr || crypto_aead_reqtfm(req) != tfm || req->base.complete != crypto_req_done || req->base.flags != req_flags || req->base.data != &wait) { pr_err("alg: aead: %s %s corrupted request struct on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); if (req->cryptlen != (enc ? vec->plen : vec->clen)) pr_err("alg: aead: changed 'req->cryptlen'\n"); if (req->assoclen != vec->alen) pr_err("alg: aead: changed 'req->assoclen'\n"); if (req->iv != iv) pr_err("alg: aead: changed 'req->iv'\n"); if (req->src != tsgls->src.sgl_ptr) pr_err("alg: aead: changed 'req->src'\n"); if (req->dst != tsgls->dst.sgl_ptr) pr_err("alg: aead: changed 'req->dst'\n"); if (crypto_aead_reqtfm(req) != tfm) pr_err("alg: aead: changed 'req->base.tfm'\n"); if (req->base.complete != crypto_req_done) pr_err("alg: aead: changed 'req->base.complete'\n"); if (req->base.flags != req_flags) pr_err("alg: aead: changed 'req->base.flags'\n"); if (req->base.data != &wait) pr_err("alg: aead: changed 'req->base.data'\n"); return -EINVAL; } if (is_test_sglist_corrupted(&tsgls->src)) { pr_err("alg: aead: %s %s corrupted src sgl on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return -EINVAL; } if (tsgls->dst.sgl_ptr != tsgls->src.sgl && is_test_sglist_corrupted(&tsgls->dst)) { pr_err("alg: aead: %s %s corrupted dst sgl on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return -EINVAL; } /* Check for success or failure */ expected_error = vec->novrfy ? -EBADMSG : vec->crypt_error; if (err) { if (err == expected_error) return 0; pr_err("alg: aead: %s %s failed on test vector %s; expected_error=%d, actual_error=%d, cfg=\"%s\"\n", driver, op, vec_name, expected_error, err, cfg->name); return err; } if (expected_error) { pr_err("alg: aead: %s %s unexpectedly succeeded on test vector %s; expected_error=%d, cfg=\"%s\"\n", driver, op, vec_name, expected_error, cfg->name); return -EINVAL; } /* Check for the correct output (ciphertext or plaintext) */ err = verify_correct_output(&tsgls->dst, enc ? vec->ctext : vec->ptext, enc ? vec->clen : vec->plen, vec->alen, enc || !cfg->inplace); if (err == -EOVERFLOW) { pr_err("alg: aead: %s %s overran dst buffer on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } if (err) { pr_err("alg: aead: %s %s test failed (wrong result) on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } return 0; } static int test_aead_vec(const char *driver, int enc, const struct aead_testvec *vec, unsigned int vec_num, struct aead_request *req, struct cipher_test_sglists *tsgls) { char vec_name[16]; unsigned int i; int err; if (enc && vec->novrfy) return 0; sprintf(vec_name, "%u", vec_num); for (i = 0; i < ARRAY_SIZE(default_cipher_testvec_configs); i++) { err = test_aead_vec_cfg(driver, enc, vec, vec_name, &default_cipher_testvec_configs[i], req, tsgls); if (err) return err; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS if (!noextratests) { struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; for (i = 0; i < fuzz_iterations; i++) { generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_aead_vec_cfg(driver, enc, vec, vec_name, &cfg, req, tsgls); if (err) return err; } } #endif return 0; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS /* * Generate an AEAD test vector from the given implementation. * Assumes the buffers in 'vec' were already allocated. */ static void generate_random_aead_testvec(struct aead_request *req, struct aead_testvec *vec, unsigned int maxkeysize, unsigned int maxdatasize, char *name, size_t max_namelen) { struct crypto_aead *tfm = crypto_aead_reqtfm(req); const unsigned int ivsize = crypto_aead_ivsize(tfm); unsigned int maxauthsize = crypto_aead_alg(tfm)->maxauthsize; unsigned int authsize; unsigned int total_len; int i; struct scatterlist src[2], dst; u8 iv[MAX_IVLEN]; DECLARE_CRYPTO_WAIT(wait); /* Key: length in [0, maxkeysize], but usually choose maxkeysize */ vec->klen = maxkeysize; if (prandom_u32() % 4 == 0) vec->klen = prandom_u32() % (maxkeysize + 1); generate_random_bytes((u8 *)vec->key, vec->klen); vec->setkey_error = crypto_aead_setkey(tfm, vec->key, vec->klen); /* IV */ generate_random_bytes((u8 *)vec->iv, ivsize); /* Tag length: in [0, maxauthsize], but usually choose maxauthsize */ authsize = maxauthsize; if (prandom_u32() % 4 == 0) authsize = prandom_u32() % (maxauthsize + 1); if (WARN_ON(authsize > maxdatasize)) authsize = maxdatasize; maxdatasize -= authsize; vec->setauthsize_error = crypto_aead_setauthsize(tfm, authsize); /* Plaintext and associated data */ total_len = generate_random_length(maxdatasize); if (prandom_u32() % 4 == 0) vec->alen = 0; else vec->alen = generate_random_length(total_len); vec->plen = total_len - vec->alen; generate_random_bytes((u8 *)vec->assoc, vec->alen); generate_random_bytes((u8 *)vec->ptext, vec->plen); vec->clen = vec->plen + authsize; /* * If the key or authentication tag size couldn't be set, no need to * continue to encrypt. */ if (vec->setkey_error || vec->setauthsize_error) goto done; /* Ciphertext */ sg_init_table(src, 2); i = 0; if (vec->alen) sg_set_buf(&src[i++], vec->assoc, vec->alen); if (vec->plen) sg_set_buf(&src[i++], vec->ptext, vec->plen); sg_init_one(&dst, vec->ctext, vec->alen + vec->clen); memcpy(iv, vec->iv, ivsize); aead_request_set_callback(req, 0, crypto_req_done, &wait); aead_request_set_crypt(req, src, &dst, vec->plen, iv); aead_request_set_ad(req, vec->alen); vec->crypt_error = crypto_wait_req(crypto_aead_encrypt(req), &wait); if (vec->crypt_error == 0) memmove((u8 *)vec->ctext, vec->ctext + vec->alen, vec->clen); done: snprintf(name, max_namelen, "\"random: alen=%u plen=%u authsize=%u klen=%u\"", vec->alen, vec->plen, authsize, vec->klen); } /* * Test the AEAD algorithm represented by @req against the corresponding generic * implementation, if one is available. */ static int test_aead_vs_generic_impl(const char *driver, const struct alg_test_desc *test_desc, struct aead_request *req, struct cipher_test_sglists *tsgls) { struct crypto_aead *tfm = crypto_aead_reqtfm(req); const unsigned int ivsize = crypto_aead_ivsize(tfm); const unsigned int maxauthsize = crypto_aead_alg(tfm)->maxauthsize; const unsigned int blocksize = crypto_aead_blocksize(tfm); const unsigned int maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN; const char *algname = crypto_aead_alg(tfm)->base.cra_name; const char *generic_driver = test_desc->generic_driver; char _generic_driver[CRYPTO_MAX_ALG_NAME]; struct crypto_aead *generic_tfm = NULL; struct aead_request *generic_req = NULL; unsigned int maxkeysize; unsigned int i; struct aead_testvec vec = { 0 }; char vec_name[64]; struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; if (noextratests) return 0; if (!generic_driver) { /* Use default naming convention? */ err = build_generic_driver_name(algname, _generic_driver); if (err) return err; generic_driver = _generic_driver; } if (strcmp(generic_driver, driver) == 0) /* Already the generic impl? */ return 0; generic_tfm = crypto_alloc_aead(generic_driver, 0, 0); if (IS_ERR(generic_tfm)) { err = PTR_ERR(generic_tfm); if (err == -ENOENT) { pr_warn("alg: aead: skipping comparison tests for %s because %s is unavailable\n", driver, generic_driver); return 0; } pr_err("alg: aead: error allocating %s (generic impl of %s): %d\n", generic_driver, algname, err); return err; } generic_req = aead_request_alloc(generic_tfm, GFP_KERNEL); if (!generic_req) { err = -ENOMEM; goto out; } /* Check the algorithm properties for consistency. */ if (maxauthsize != crypto_aead_alg(generic_tfm)->maxauthsize) { pr_err("alg: aead: maxauthsize for %s (%u) doesn't match generic impl (%u)\n", driver, maxauthsize, crypto_aead_alg(generic_tfm)->maxauthsize); err = -EINVAL; goto out; } if (ivsize != crypto_aead_ivsize(generic_tfm)) { pr_err("alg: aead: ivsize for %s (%u) doesn't match generic impl (%u)\n", driver, ivsize, crypto_aead_ivsize(generic_tfm)); err = -EINVAL; goto out; } if (blocksize != crypto_aead_blocksize(generic_tfm)) { pr_err("alg: aead: blocksize for %s (%u) doesn't match generic impl (%u)\n", driver, blocksize, crypto_aead_blocksize(generic_tfm)); err = -EINVAL; goto out; } /* * Now generate test vectors using the generic implementation, and test * the other implementation against them. */ maxkeysize = 0; for (i = 0; i < test_desc->suite.aead.count; i++) maxkeysize = max_t(unsigned int, maxkeysize, test_desc->suite.aead.vecs[i].klen); vec.key = kmalloc(maxkeysize, GFP_KERNEL); vec.iv = kmalloc(ivsize, GFP_KERNEL); vec.assoc = kmalloc(maxdatasize, GFP_KERNEL); vec.ptext = kmalloc(maxdatasize, GFP_KERNEL); vec.ctext = kmalloc(maxdatasize, GFP_KERNEL); if (!vec.key || !vec.iv || !vec.assoc || !vec.ptext || !vec.ctext) { err = -ENOMEM; goto out; } for (i = 0; i < fuzz_iterations * 8; i++) { generate_random_aead_testvec(generic_req, &vec, maxkeysize, maxdatasize, vec_name, sizeof(vec_name)); generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_aead_vec_cfg(driver, ENCRYPT, &vec, vec_name, &cfg, req, tsgls); if (err) goto out; err = test_aead_vec_cfg(driver, DECRYPT, &vec, vec_name, &cfg, req, tsgls); if (err) goto out; cond_resched(); } err = 0; out: kfree(vec.key); kfree(vec.iv); kfree(vec.assoc); kfree(vec.ptext); kfree(vec.ctext); crypto_free_aead(generic_tfm); aead_request_free(generic_req); return err; } #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int test_aead_vs_generic_impl(const char *driver, const struct alg_test_desc *test_desc, struct aead_request *req, struct cipher_test_sglists *tsgls) { return 0; } #endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int test_aead(const char *driver, int enc, const struct aead_test_suite *suite, struct aead_request *req, struct cipher_test_sglists *tsgls) { unsigned int i; int err; for (i = 0; i < suite->count; i++) { err = test_aead_vec(driver, enc, &suite->vecs[i], i, req, tsgls); if (err) return err; } return 0; } static int alg_test_aead(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { const struct aead_test_suite *suite = &desc->suite.aead; struct crypto_aead *tfm; struct aead_request *req = NULL; struct cipher_test_sglists *tsgls = NULL; int err; if (suite->count <= 0) { pr_err("alg: aead: empty test suite for %s\n", driver); return -EINVAL; } tfm = crypto_alloc_aead(driver, type, mask); if (IS_ERR(tfm)) { pr_err("alg: aead: failed to allocate transform for %s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } req = aead_request_alloc(tfm, GFP_KERNEL); if (!req) { pr_err("alg: aead: failed to allocate request for %s\n", driver); err = -ENOMEM; goto out; } tsgls = alloc_cipher_test_sglists(); if (!tsgls) { pr_err("alg: aead: failed to allocate test buffers for %s\n", driver); err = -ENOMEM; goto out; } err = test_aead(driver, ENCRYPT, suite, req, tsgls); if (err) goto out; err = test_aead(driver, DECRYPT, suite, req, tsgls); if (err) goto out; err = test_aead_vs_generic_impl(driver, desc, req, tsgls); out: free_cipher_test_sglists(tsgls); aead_request_free(req); crypto_free_aead(tfm); return err; } static int test_cipher(struct crypto_cipher *tfm, int enc, const struct cipher_testvec *template, unsigned int tcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm)); unsigned int i, j, k; char *q; const char *e; const char *input, *result; void *data; char *xbuf[XBUFSIZE]; int ret = -ENOMEM; if (testmgr_alloc_buf(xbuf)) goto out_nobuf; if (enc == ENCRYPT) e = "encryption"; else e = "decryption"; j = 0; for (i = 0; i < tcount; i++) { if (fips_enabled && template[i].fips_skip) continue; input = enc ? template[i].ptext : template[i].ctext; result = enc ? template[i].ctext : template[i].ptext; j++; ret = -EINVAL; if (WARN_ON(template[i].len > PAGE_SIZE)) goto out; data = xbuf[0]; memcpy(data, input, template[i].len); crypto_cipher_clear_flags(tfm, ~0); if (template[i].wk) crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS); ret = crypto_cipher_setkey(tfm, template[i].key, template[i].klen); if (ret) { if (ret == template[i].setkey_error) continue; pr_err("alg: cipher: %s setkey failed on test vector %u; expected_error=%d, actual_error=%d, flags=%#x\n", algo, j, template[i].setkey_error, ret, crypto_cipher_get_flags(tfm)); goto out; } if (template[i].setkey_error) { pr_err("alg: cipher: %s setkey unexpectedly succeeded on test vector %u; expected_error=%d\n", algo, j, template[i].setkey_error); ret = -EINVAL; goto out; } for (k = 0; k < template[i].len; k += crypto_cipher_blocksize(tfm)) { if (enc) crypto_cipher_encrypt_one(tfm, data + k, data + k); else crypto_cipher_decrypt_one(tfm, data + k, data + k); } q = data; if (memcmp(q, result, template[i].len)) { printk(KERN_ERR "alg: cipher: Test %d failed " "on %s for %s\n", j, e, algo); hexdump(q, template[i].len); ret = -EINVAL; goto out; } } ret = 0; out: testmgr_free_buf(xbuf); out_nobuf: return ret; } static int test_skcipher_vec_cfg(const char *driver, int enc, const struct cipher_testvec *vec, const char *vec_name, const struct testvec_config *cfg, struct skcipher_request *req, struct cipher_test_sglists *tsgls) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); const unsigned int alignmask = crypto_skcipher_alignmask(tfm); const unsigned int ivsize = crypto_skcipher_ivsize(tfm); const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags; const char *op = enc ? "encryption" : "decryption"; DECLARE_CRYPTO_WAIT(wait); u8 _iv[3 * (MAX_ALGAPI_ALIGNMASK + 1) + MAX_IVLEN]; u8 *iv = PTR_ALIGN(&_iv[0], 2 * (MAX_ALGAPI_ALIGNMASK + 1)) + cfg->iv_offset + (cfg->iv_offset_relative_to_alignmask ? alignmask : 0); struct kvec input; int err; /* Set the key */ if (vec->wk) crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS); else crypto_skcipher_clear_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS); err = crypto_skcipher_setkey(tfm, vec->key, vec->klen); if (err) { if (err == vec->setkey_error) return 0; pr_err("alg: skcipher: %s setkey failed on test vector %s; expected_error=%d, actual_error=%d, flags=%#x\n", driver, vec_name, vec->setkey_error, err, crypto_skcipher_get_flags(tfm)); return err; } if (vec->setkey_error) { pr_err("alg: skcipher: %s setkey unexpectedly succeeded on test vector %s; expected_error=%d\n", driver, vec_name, vec->setkey_error); return -EINVAL; } /* The IV must be copied to a buffer, as the algorithm may modify it */ if (ivsize) { if (WARN_ON(ivsize > MAX_IVLEN)) return -EINVAL; if (vec->generates_iv && !enc) memcpy(iv, vec->iv_out, ivsize); else if (vec->iv) memcpy(iv, vec->iv, ivsize); else memset(iv, 0, ivsize); } else { if (vec->generates_iv) { pr_err("alg: skcipher: %s has ivsize=0 but test vector %s generates IV!\n", driver, vec_name); return -EINVAL; } iv = NULL; } /* Build the src/dst scatterlists */ input.iov_base = enc ? (void *)vec->ptext : (void *)vec->ctext; input.iov_len = vec->len; err = build_cipher_test_sglists(tsgls, cfg, alignmask, vec->len, vec->len, &input, 1); if (err) { pr_err("alg: skcipher: %s %s: error preparing scatterlists for test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } /* Do the actual encryption or decryption */ testmgr_poison(req->__ctx, crypto_skcipher_reqsize(tfm)); skcipher_request_set_callback(req, req_flags, crypto_req_done, &wait); skcipher_request_set_crypt(req, tsgls->src.sgl_ptr, tsgls->dst.sgl_ptr, vec->len, iv); if (cfg->nosimd) crypto_disable_simd_for_test(); err = enc ? crypto_skcipher_encrypt(req) : crypto_skcipher_decrypt(req); if (cfg->nosimd) crypto_reenable_simd_for_test(); err = crypto_wait_req(err, &wait); /* Check that the algorithm didn't overwrite things it shouldn't have */ if (req->cryptlen != vec->len || req->iv != iv || req->src != tsgls->src.sgl_ptr || req->dst != tsgls->dst.sgl_ptr || crypto_skcipher_reqtfm(req) != tfm || req->base.complete != crypto_req_done || req->base.flags != req_flags || req->base.data != &wait) { pr_err("alg: skcipher: %s %s corrupted request struct on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); if (req->cryptlen != vec->len) pr_err("alg: skcipher: changed 'req->cryptlen'\n"); if (req->iv != iv) pr_err("alg: skcipher: changed 'req->iv'\n"); if (req->src != tsgls->src.sgl_ptr) pr_err("alg: skcipher: changed 'req->src'\n"); if (req->dst != tsgls->dst.sgl_ptr) pr_err("alg: skcipher: changed 'req->dst'\n"); if (crypto_skcipher_reqtfm(req) != tfm) pr_err("alg: skcipher: changed 'req->base.tfm'\n"); if (req->base.complete != crypto_req_done) pr_err("alg: skcipher: changed 'req->base.complete'\n"); if (req->base.flags != req_flags) pr_err("alg: skcipher: changed 'req->base.flags'\n"); if (req->base.data != &wait) pr_err("alg: skcipher: changed 'req->base.data'\n"); return -EINVAL; } if (is_test_sglist_corrupted(&tsgls->src)) { pr_err("alg: skcipher: %s %s corrupted src sgl on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return -EINVAL; } if (tsgls->dst.sgl_ptr != tsgls->src.sgl && is_test_sglist_corrupted(&tsgls->dst)) { pr_err("alg: skcipher: %s %s corrupted dst sgl on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return -EINVAL; } /* Check for success or failure */ if (err) { if (err == vec->crypt_error) return 0; pr_err("alg: skcipher: %s %s failed on test vector %s; expected_error=%d, actual_error=%d, cfg=\"%s\"\n", driver, op, vec_name, vec->crypt_error, err, cfg->name); return err; } if (vec->crypt_error) { pr_err("alg: skcipher: %s %s unexpectedly succeeded on test vector %s; expected_error=%d, cfg=\"%s\"\n", driver, op, vec_name, vec->crypt_error, cfg->name); return -EINVAL; } /* Check for the correct output (ciphertext or plaintext) */ err = verify_correct_output(&tsgls->dst, enc ? vec->ctext : vec->ptext, vec->len, 0, true); if (err == -EOVERFLOW) { pr_err("alg: skcipher: %s %s overran dst buffer on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } if (err) { pr_err("alg: skcipher: %s %s test failed (wrong result) on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); return err; } /* If applicable, check that the algorithm generated the correct IV */ if (vec->iv_out && memcmp(iv, vec->iv_out, ivsize) != 0) { pr_err("alg: skcipher: %s %s test failed (wrong output IV) on test vector %s, cfg=\"%s\"\n", driver, op, vec_name, cfg->name); hexdump(iv, ivsize); return -EINVAL; } return 0; } static int test_skcipher_vec(const char *driver, int enc, const struct cipher_testvec *vec, unsigned int vec_num, struct skcipher_request *req, struct cipher_test_sglists *tsgls) { char vec_name[16]; unsigned int i; int err; if (fips_enabled && vec->fips_skip) return 0; sprintf(vec_name, "%u", vec_num); for (i = 0; i < ARRAY_SIZE(default_cipher_testvec_configs); i++) { err = test_skcipher_vec_cfg(driver, enc, vec, vec_name, &default_cipher_testvec_configs[i], req, tsgls); if (err) return err; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS if (!noextratests) { struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; for (i = 0; i < fuzz_iterations; i++) { generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_skcipher_vec_cfg(driver, enc, vec, vec_name, &cfg, req, tsgls); if (err) return err; } } #endif return 0; } #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS /* * Generate a symmetric cipher test vector from the given implementation. * Assumes the buffers in 'vec' were already allocated. */ static void generate_random_cipher_testvec(struct skcipher_request *req, struct cipher_testvec *vec, unsigned int maxdatasize, char *name, size_t max_namelen) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); const unsigned int maxkeysize = tfm->keysize; const unsigned int ivsize = crypto_skcipher_ivsize(tfm); struct scatterlist src, dst; u8 iv[MAX_IVLEN]; DECLARE_CRYPTO_WAIT(wait); /* Key: length in [0, maxkeysize], but usually choose maxkeysize */ vec->klen = maxkeysize; if (prandom_u32() % 4 == 0) vec->klen = prandom_u32() % (maxkeysize + 1); generate_random_bytes((u8 *)vec->key, vec->klen); vec->setkey_error = crypto_skcipher_setkey(tfm, vec->key, vec->klen); /* IV */ generate_random_bytes((u8 *)vec->iv, ivsize); /* Plaintext */ vec->len = generate_random_length(maxdatasize); generate_random_bytes((u8 *)vec->ptext, vec->len); /* If the key couldn't be set, no need to continue to encrypt. */ if (vec->setkey_error) goto done; /* Ciphertext */ sg_init_one(&src, vec->ptext, vec->len); sg_init_one(&dst, vec->ctext, vec->len); memcpy(iv, vec->iv, ivsize); skcipher_request_set_callback(req, 0, crypto_req_done, &wait); skcipher_request_set_crypt(req, &src, &dst, vec->len, iv); vec->crypt_error = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); done: snprintf(name, max_namelen, "\"random: len=%u klen=%u\"", vec->len, vec->klen); } /* * Test the skcipher algorithm represented by @req against the corresponding * generic implementation, if one is available. */ static int test_skcipher_vs_generic_impl(const char *driver, const char *generic_driver, struct skcipher_request *req, struct cipher_test_sglists *tsgls) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); const unsigned int ivsize = crypto_skcipher_ivsize(tfm); const unsigned int blocksize = crypto_skcipher_blocksize(tfm); const unsigned int maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN; const char *algname = crypto_skcipher_alg(tfm)->base.cra_name; char _generic_driver[CRYPTO_MAX_ALG_NAME]; struct crypto_skcipher *generic_tfm = NULL; struct skcipher_request *generic_req = NULL; unsigned int i; struct cipher_testvec vec = { 0 }; char vec_name[64]; struct testvec_config cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; if (noextratests) return 0; /* Keywrap isn't supported here yet as it handles its IV differently. */ if (strncmp(algname, "kw(", 3) == 0) return 0; if (!generic_driver) { /* Use default naming convention? */ err = build_generic_driver_name(algname, _generic_driver); if (err) return err; generic_driver = _generic_driver; } if (strcmp(generic_driver, driver) == 0) /* Already the generic impl? */ return 0; generic_tfm = crypto_alloc_skcipher(generic_driver, 0, 0); if (IS_ERR(generic_tfm)) { err = PTR_ERR(generic_tfm); if (err == -ENOENT) { pr_warn("alg: skcipher: skipping comparison tests for %s because %s is unavailable\n", driver, generic_driver); return 0; } pr_err("alg: skcipher: error allocating %s (generic impl of %s): %d\n", generic_driver, algname, err); return err; } generic_req = skcipher_request_alloc(generic_tfm, GFP_KERNEL); if (!generic_req) { err = -ENOMEM; goto out; } /* Check the algorithm properties for consistency. */ if (tfm->keysize != generic_tfm->keysize) { pr_err("alg: skcipher: max keysize for %s (%u) doesn't match generic impl (%u)\n", driver, tfm->keysize, generic_tfm->keysize); err = -EINVAL; goto out; } if (ivsize != crypto_skcipher_ivsize(generic_tfm)) { pr_err("alg: skcipher: ivsize for %s (%u) doesn't match generic impl (%u)\n", driver, ivsize, crypto_skcipher_ivsize(generic_tfm)); err = -EINVAL; goto out; } if (blocksize != crypto_skcipher_blocksize(generic_tfm)) { pr_err("alg: skcipher: blocksize for %s (%u) doesn't match generic impl (%u)\n", driver, blocksize, crypto_skcipher_blocksize(generic_tfm)); err = -EINVAL; goto out; } /* * Now generate test vectors using the generic implementation, and test * the other implementation against them. */ vec.key = kmalloc(tfm->keysize, GFP_KERNEL); vec.iv = kmalloc(ivsize, GFP_KERNEL); vec.ptext = kmalloc(maxdatasize, GFP_KERNEL); vec.ctext = kmalloc(maxdatasize, GFP_KERNEL); if (!vec.key || !vec.iv || !vec.ptext || !vec.ctext) { err = -ENOMEM; goto out; } for (i = 0; i < fuzz_iterations * 8; i++) { generate_random_cipher_testvec(generic_req, &vec, maxdatasize, vec_name, sizeof(vec_name)); generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); err = test_skcipher_vec_cfg(driver, ENCRYPT, &vec, vec_name, &cfg, req, tsgls); if (err) goto out; err = test_skcipher_vec_cfg(driver, DECRYPT, &vec, vec_name, &cfg, req, tsgls); if (err) goto out; cond_resched(); } err = 0; out: kfree(vec.key); kfree(vec.iv); kfree(vec.ptext); kfree(vec.ctext); crypto_free_skcipher(generic_tfm); skcipher_request_free(generic_req); return err; } #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int test_skcipher_vs_generic_impl(const char *driver, const char *generic_driver, struct skcipher_request *req, struct cipher_test_sglists *tsgls) { return 0; } #endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ static int test_skcipher(const char *driver, int enc, const struct cipher_test_suite *suite, struct skcipher_request *req, struct cipher_test_sglists *tsgls) { unsigned int i; int err; for (i = 0; i < suite->count; i++) { err = test_skcipher_vec(driver, enc, &suite->vecs[i], i, req, tsgls); if (err) return err; } return 0; } static int alg_test_skcipher(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { const struct cipher_test_suite *suite = &desc->suite.cipher; struct crypto_skcipher *tfm; struct skcipher_request *req = NULL; struct cipher_test_sglists *tsgls = NULL; int err; if (suite->count <= 0) { pr_err("alg: skcipher: empty test suite for %s\n", driver); return -EINVAL; } tfm = crypto_alloc_skcipher(driver, type, mask); if (IS_ERR(tfm)) { pr_err("alg: skcipher: failed to allocate transform for %s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } req = skcipher_request_alloc(tfm, GFP_KERNEL); if (!req) { pr_err("alg: skcipher: failed to allocate request for %s\n", driver); err = -ENOMEM; goto out; } tsgls = alloc_cipher_test_sglists(); if (!tsgls) { pr_err("alg: skcipher: failed to allocate test buffers for %s\n", driver); err = -ENOMEM; goto out; } err = test_skcipher(driver, ENCRYPT, suite, req, tsgls); if (err) goto out; err = test_skcipher(driver, DECRYPT, suite, req, tsgls); if (err) goto out; err = test_skcipher_vs_generic_impl(driver, desc->generic_driver, req, tsgls); out: free_cipher_test_sglists(tsgls); skcipher_request_free(req); crypto_free_skcipher(tfm); return err; } static int test_comp(struct crypto_comp *tfm, const struct comp_testvec *ctemplate, const struct comp_testvec *dtemplate, int ctcount, int dtcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm)); char *output, *decomp_output; unsigned int i; int ret; output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!output) return -ENOMEM; decomp_output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!decomp_output) { kfree(output); return -ENOMEM; } for (i = 0; i < ctcount; i++) { int ilen; unsigned int dlen = COMP_BUF_SIZE; memset(output, 0, COMP_BUF_SIZE); memset(decomp_output, 0, COMP_BUF_SIZE); ilen = ctemplate[i].inlen; ret = crypto_comp_compress(tfm, ctemplate[i].input, ilen, output, &dlen); if (ret) { printk(KERN_ERR "alg: comp: compression failed " "on test %d for %s: ret=%d\n", i + 1, algo, -ret); goto out; } ilen = dlen; dlen = COMP_BUF_SIZE; ret = crypto_comp_decompress(tfm, output, ilen, decomp_output, &dlen); if (ret) { pr_err("alg: comp: compression failed: decompress: on test %d for %s failed: ret=%d\n", i + 1, algo, -ret); goto out; } if (dlen != ctemplate[i].inlen) { printk(KERN_ERR "alg: comp: Compression test %d " "failed for %s: output len = %d\n", i + 1, algo, dlen); ret = -EINVAL; goto out; } if (memcmp(decomp_output, ctemplate[i].input, ctemplate[i].inlen)) { pr_err("alg: comp: compression failed: output differs: on test %d for %s\n", i + 1, algo); hexdump(decomp_output, dlen); ret = -EINVAL; goto out; } } for (i = 0; i < dtcount; i++) { int ilen; unsigned int dlen = COMP_BUF_SIZE; memset(decomp_output, 0, COMP_BUF_SIZE); ilen = dtemplate[i].inlen; ret = crypto_comp_decompress(tfm, dtemplate[i].input, ilen, decomp_output, &dlen); if (ret) { printk(KERN_ERR "alg: comp: decompression failed " "on test %d for %s: ret=%d\n", i + 1, algo, -ret); goto out; } if (dlen != dtemplate[i].outlen) { printk(KERN_ERR "alg: comp: Decompression test %d " "failed for %s: output len = %d\n", i + 1, algo, dlen); ret = -EINVAL; goto out; } if (memcmp(decomp_output, dtemplate[i].output, dlen)) { printk(KERN_ERR "alg: comp: Decompression test %d " "failed for %s\n", i + 1, algo); hexdump(decomp_output, dlen); ret = -EINVAL; goto out; } } ret = 0; out: kfree(decomp_output); kfree(output); return ret; } static int test_acomp(struct crypto_acomp *tfm, const struct comp_testvec *ctemplate, const struct comp_testvec *dtemplate, int ctcount, int dtcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm)); unsigned int i; char *output, *decomp_out; int ret; struct scatterlist src, dst; struct acomp_req *req; struct crypto_wait wait; output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!output) return -ENOMEM; decomp_out = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!decomp_out) { kfree(output); return -ENOMEM; } for (i = 0; i < ctcount; i++) { unsigned int dlen = COMP_BUF_SIZE; int ilen = ctemplate[i].inlen; void *input_vec; input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL); if (!input_vec) { ret = -ENOMEM; goto out; } memset(output, 0, dlen); crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); req = acomp_request_alloc(tfm); if (!req) { pr_err("alg: acomp: request alloc failed for %s\n", algo); kfree(input_vec); ret = -ENOMEM; goto out; } acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); ret = crypto_wait_req(crypto_acomp_compress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); kfree(input_vec); acomp_request_free(req); goto out; } ilen = req->dlen; dlen = COMP_BUF_SIZE; sg_init_one(&src, output, ilen); sg_init_one(&dst, decomp_out, dlen); crypto_init_wait(&wait); acomp_request_set_params(req, &src, &dst, ilen, dlen); ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); kfree(input_vec); acomp_request_free(req); goto out; } if (req->dlen != ctemplate[i].inlen) { pr_err("alg: acomp: Compression test %d failed for %s: output len = %d\n", i + 1, algo, req->dlen); ret = -EINVAL; kfree(input_vec); acomp_request_free(req); goto out; } if (memcmp(input_vec, decomp_out, req->dlen)) { pr_err("alg: acomp: Compression test %d failed for %s\n", i + 1, algo); hexdump(output, req->dlen); ret = -EINVAL; kfree(input_vec); acomp_request_free(req); goto out; } kfree(input_vec); acomp_request_free(req); } for (i = 0; i < dtcount; i++) { unsigned int dlen = COMP_BUF_SIZE; int ilen = dtemplate[i].inlen; void *input_vec; input_vec = kmemdup(dtemplate[i].input, ilen, GFP_KERNEL); if (!input_vec) { ret = -ENOMEM; goto out; } memset(output, 0, dlen); crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); req = acomp_request_alloc(tfm); if (!req) { pr_err("alg: acomp: request alloc failed for %s\n", algo); kfree(input_vec); ret = -ENOMEM; goto out; } acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: decompression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); kfree(input_vec); acomp_request_free(req); goto out; } if (req->dlen != dtemplate[i].outlen) { pr_err("alg: acomp: Decompression test %d failed for %s: output len = %d\n", i + 1, algo, req->dlen); ret = -EINVAL; kfree(input_vec); acomp_request_free(req); goto out; } if (memcmp(output, dtemplate[i].output, req->dlen)) { pr_err("alg: acomp: Decompression test %d failed for %s\n", i + 1, algo); hexdump(output, req->dlen); ret = -EINVAL; kfree(input_vec); acomp_request_free(req); goto out; } kfree(input_vec); acomp_request_free(req); } ret = 0; out: kfree(decomp_out); kfree(output); return ret; } static int test_cprng(struct crypto_rng *tfm, const struct cprng_testvec *template, unsigned int tcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm)); int err = 0, i, j, seedsize; u8 *seed; char result[32]; seedsize = crypto_rng_seedsize(tfm); seed = kmalloc(seedsize, GFP_KERNEL); if (!seed) { printk(KERN_ERR "alg: cprng: Failed to allocate seed space " "for %s\n", algo); return -ENOMEM; } for (i = 0; i < tcount; i++) { memset(result, 0, 32); memcpy(seed, template[i].v, template[i].vlen); memcpy(seed + template[i].vlen, template[i].key, template[i].klen); memcpy(seed + template[i].vlen + template[i].klen, template[i].dt, template[i].dtlen); err = crypto_rng_reset(tfm, seed, seedsize); if (err) { printk(KERN_ERR "alg: cprng: Failed to reset rng " "for %s\n", algo); goto out; } for (j = 0; j < template[i].loops; j++) { err = crypto_rng_get_bytes(tfm, result, template[i].rlen); if (err < 0) { printk(KERN_ERR "alg: cprng: Failed to obtain " "the correct amount of random data for " "%s (requested %d)\n", algo, template[i].rlen); goto out; } } err = memcmp(result, template[i].result, template[i].rlen); if (err) { printk(KERN_ERR "alg: cprng: Test %d failed for %s\n", i, algo); hexdump(result, template[i].rlen); err = -EINVAL; goto out; } } out: kfree(seed); return err; } static int alg_test_cipher(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { const struct cipher_test_suite *suite = &desc->suite.cipher; struct crypto_cipher *tfm; int err; tfm = crypto_alloc_cipher(driver, type, mask); if (IS_ERR(tfm)) { printk(KERN_ERR "alg: cipher: Failed to load transform for " "%s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } err = test_cipher(tfm, ENCRYPT, suite->vecs, suite->count); if (!err) err = test_cipher(tfm, DECRYPT, suite->vecs, suite->count); crypto_free_cipher(tfm); return err; } static int alg_test_comp(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { struct crypto_comp *comp; struct crypto_acomp *acomp; int err; u32 algo_type = type & CRYPTO_ALG_TYPE_ACOMPRESS_MASK; if (algo_type == CRYPTO_ALG_TYPE_ACOMPRESS) { acomp = crypto_alloc_acomp(driver, type, mask); if (IS_ERR(acomp)) { pr_err("alg: acomp: Failed to load transform for %s: %ld\n", driver, PTR_ERR(acomp)); return PTR_ERR(acomp); } err = test_acomp(acomp, desc->suite.comp.comp.vecs, desc->suite.comp.decomp.vecs, desc->suite.comp.comp.count, desc->suite.comp.decomp.count); crypto_free_acomp(acomp); } else { comp = crypto_alloc_comp(driver, type, mask); if (IS_ERR(comp)) { pr_err("alg: comp: Failed to load transform for %s: %ld\n", driver, PTR_ERR(comp)); return PTR_ERR(comp); } err = test_comp(comp, desc->suite.comp.comp.vecs, desc->suite.comp.decomp.vecs, desc->suite.comp.comp.count, desc->suite.comp.decomp.count); crypto_free_comp(comp); } return err; } static int alg_test_crc32c(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { struct crypto_shash *tfm; __le32 val; int err; err = alg_test_hash(desc, driver, type, mask); if (err) return err; tfm = crypto_alloc_shash(driver, type, mask); if (IS_ERR(tfm)) { if (PTR_ERR(tfm) == -ENOENT) { /* * This crc32c implementation is only available through * ahash API, not the shash API, so the remaining part * of the test is not applicable to it. */ return 0; } printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: " "%ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } do { SHASH_DESC_ON_STACK(shash, tfm); u32 *ctx = (u32 *)shash_desc_ctx(shash); shash->tfm = tfm; *ctx = 420553207; err = crypto_shash_final(shash, (u8 *)&val); if (err) { printk(KERN_ERR "alg: crc32c: Operation failed for " "%s: %d\n", driver, err); break; } if (val != cpu_to_le32(~420553207)) { pr_err("alg: crc32c: Test failed for %s: %u\n", driver, le32_to_cpu(val)); err = -EINVAL; } } while (0); crypto_free_shash(tfm); return err; } static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { struct crypto_rng *rng; int err; rng = crypto_alloc_rng(driver, type, mask); if (IS_ERR(rng)) { printk(KERN_ERR "alg: cprng: Failed to load transform for %s: " "%ld\n", driver, PTR_ERR(rng)); return PTR_ERR(rng); } err = test_cprng(rng, desc->suite.cprng.vecs, desc->suite.cprng.count); crypto_free_rng(rng); return err; } static int drbg_cavs_test(const struct drbg_testvec *test, int pr, const char *driver, u32 type, u32 mask) { int ret = -EAGAIN; struct crypto_rng *drng; struct drbg_test_data test_data; struct drbg_string addtl, pers, testentropy; unsigned char *buf = kzalloc(test->expectedlen, GFP_KERNEL); if (!buf) return -ENOMEM; drng = crypto_alloc_rng(driver, type, mask); if (IS_ERR(drng)) { printk(KERN_ERR "alg: drbg: could not allocate DRNG handle for " "%s\n", driver); kzfree(buf); return -ENOMEM; } test_data.testentropy = &testentropy; drbg_string_fill(&testentropy, test->entropy, test->entropylen); drbg_string_fill(&pers, test->pers, test->perslen); ret = crypto_drbg_reset_test(drng, &pers, &test_data); if (ret) { printk(KERN_ERR "alg: drbg: Failed to reset rng\n"); goto outbuf; } drbg_string_fill(&addtl, test->addtla, test->addtllen); if (pr) { drbg_string_fill(&testentropy, test->entpra, test->entprlen); ret = crypto_drbg_get_bytes_addtl_test(drng, buf, test->expectedlen, &addtl, &test_data); } else { ret = crypto_drbg_get_bytes_addtl(drng, buf, test->expectedlen, &addtl); } if (ret < 0) { printk(KERN_ERR "alg: drbg: could not obtain random data for " "driver %s\n", driver); goto outbuf; } drbg_string_fill(&addtl, test->addtlb, test->addtllen); if (pr) { drbg_string_fill(&testentropy, test->entprb, test->entprlen); ret = crypto_drbg_get_bytes_addtl_test(drng, buf, test->expectedlen, &addtl, &test_data); } else { ret = crypto_drbg_get_bytes_addtl(drng, buf, test->expectedlen, &addtl); } if (ret < 0) { printk(KERN_ERR "alg: drbg: could not obtain random data for " "driver %s\n", driver); goto outbuf; } ret = memcmp(test->expected, buf, test->expectedlen); outbuf: crypto_free_rng(drng); kzfree(buf); return ret; } static int alg_test_drbg(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { int err = 0; int pr = 0; int i = 0; const struct drbg_testvec *template = desc->suite.drbg.vecs; unsigned int tcount = desc->suite.drbg.count; if (0 == memcmp(driver, "drbg_pr_", 8)) pr = 1; for (i = 0; i < tcount; i++) { err = drbg_cavs_test(&template[i], pr, driver, type, mask); if (err) { printk(KERN_ERR "alg: drbg: Test %d failed for %s\n", i, driver); err = -EINVAL; break; } } return err; } static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, const char *alg) { struct kpp_request *req; void *input_buf = NULL; void *output_buf = NULL; void *a_public = NULL; void *a_ss = NULL; void *shared_secret = NULL; struct crypto_wait wait; unsigned int out_len_max; int err = -ENOMEM; struct scatterlist src, dst; req = kpp_request_alloc(tfm, GFP_KERNEL); if (!req) return err; crypto_init_wait(&wait); err = crypto_kpp_set_secret(tfm, vec->secret, vec->secret_size); if (err < 0) goto free_req; out_len_max = crypto_kpp_maxsize(tfm); output_buf = kzalloc(out_len_max, GFP_KERNEL); if (!output_buf) { err = -ENOMEM; goto free_req; } /* Use appropriate parameter as base */ kpp_request_set_input(req, NULL, 0); sg_init_one(&dst, output_buf, out_len_max); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); /* Compute party A's public key */ err = crypto_wait_req(crypto_kpp_generate_public_key(req), &wait); if (err) { pr_err("alg: %s: Party A: generate public key test failed. err %d\n", alg, err); goto free_output; } if (vec->genkey) { /* Save party A's public key */ a_public = kmemdup(sg_virt(req->dst), out_len_max, GFP_KERNEL); if (!a_public) { err = -ENOMEM; goto free_output; } } else { /* Verify calculated public key */ if (memcmp(vec->expected_a_public, sg_virt(req->dst), vec->expected_a_public_size)) { pr_err("alg: %s: Party A: generate public key test failed. Invalid output\n", alg); err = -EINVAL; goto free_output; } } /* Calculate shared secret key by using counter part (b) public key. */ input_buf = kmemdup(vec->b_public, vec->b_public_size, GFP_KERNEL); if (!input_buf) { err = -ENOMEM; goto free_output; } sg_init_one(&src, input_buf, vec->b_public_size); sg_init_one(&dst, output_buf, out_len_max); kpp_request_set_input(req, &src, vec->b_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), &wait); if (err) { pr_err("alg: %s: Party A: compute shared secret test failed. err %d\n", alg, err); goto free_all; } if (vec->genkey) { /* Save the shared secret obtained by party A */ a_ss = kmemdup(sg_virt(req->dst), vec->expected_ss_size, GFP_KERNEL); if (!a_ss) { err = -ENOMEM; goto free_all; } /* * Calculate party B's shared secret by using party A's * public key. */ err = crypto_kpp_set_secret(tfm, vec->b_secret, vec->b_secret_size); if (err < 0) goto free_all; sg_init_one(&src, a_public, vec->expected_a_public_size); sg_init_one(&dst, output_buf, out_len_max); kpp_request_set_input(req, &src, vec->expected_a_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), &wait); if (err) { pr_err("alg: %s: Party B: compute shared secret failed. err %d\n", alg, err); goto free_all; } shared_secret = a_ss; } else { shared_secret = (void *)vec->expected_ss; } /* * verify shared secret from which the user will derive * secret key by executing whatever hash it has chosen */ if (memcmp(shared_secret, sg_virt(req->dst), vec->expected_ss_size)) { pr_err("alg: %s: compute shared secret test failed. Invalid output\n", alg); err = -EINVAL; } free_all: kfree(a_ss); kfree(input_buf); free_output: kfree(a_public); kfree(output_buf); free_req: kpp_request_free(req); return err; } static int test_kpp(struct crypto_kpp *tfm, const char *alg, const struct kpp_testvec *vecs, unsigned int tcount) { int ret, i; for (i = 0; i < tcount; i++) { ret = do_test_kpp(tfm, vecs++, alg); if (ret) { pr_err("alg: %s: test failed on vector %d, err=%d\n", alg, i + 1, ret); return ret; } } return 0; } static int alg_test_kpp(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { struct crypto_kpp *tfm; int err = 0; tfm = crypto_alloc_kpp(driver, type, mask); if (IS_ERR(tfm)) { pr_err("alg: kpp: Failed to load tfm for %s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } if (desc->suite.kpp.vecs) err = test_kpp(tfm, desc->alg, desc->suite.kpp.vecs, desc->suite.kpp.count); crypto_free_kpp(tfm); return err; } static u8 *test_pack_u32(u8 *dst, u32 val) { memcpy(dst, &val, sizeof(val)); return dst + sizeof(val); } static int test_akcipher_one(struct crypto_akcipher *tfm, const struct akcipher_testvec *vecs) { char *xbuf[XBUFSIZE]; struct akcipher_request *req; void *outbuf_enc = NULL; void *outbuf_dec = NULL; struct crypto_wait wait; unsigned int out_len_max, out_len = 0; int err = -ENOMEM; struct scatterlist src, dst, src_tab[3]; const char *m, *c; unsigned int m_size, c_size; const char *op; u8 *key, *ptr; if (testmgr_alloc_buf(xbuf)) return err; req = akcipher_request_alloc(tfm, GFP_KERNEL); if (!req) goto free_xbuf; crypto_init_wait(&wait); key = kmalloc(vecs->key_len + sizeof(u32) * 2 + vecs->param_len, GFP_KERNEL); if (!key) goto free_xbuf; memcpy(key, vecs->key, vecs->key_len); ptr = key + vecs->key_len; ptr = test_pack_u32(ptr, vecs->algo); ptr = test_pack_u32(ptr, vecs->param_len); memcpy(ptr, vecs->params, vecs->param_len); if (vecs->public_key_vec) err = crypto_akcipher_set_pub_key(tfm, key, vecs->key_len); else err = crypto_akcipher_set_priv_key(tfm, key, vecs->key_len); if (err) goto free_req; /* * First run test which do not require a private key, such as * encrypt or verify. */ err = -ENOMEM; out_len_max = crypto_akcipher_maxsize(tfm); outbuf_enc = kzalloc(out_len_max, GFP_KERNEL); if (!outbuf_enc) goto free_req; if (!vecs->siggen_sigver_test) { m = vecs->m; m_size = vecs->m_size; c = vecs->c; c_size = vecs->c_size; op = "encrypt"; } else { /* Swap args so we could keep plaintext (digest) * in vecs->m, and cooked signature in vecs->c. */ m = vecs->c; /* signature */ m_size = vecs->c_size; c = vecs->m; /* digest */ c_size = vecs->m_size; op = "verify"; } if (WARN_ON(m_size > PAGE_SIZE)) goto free_all; memcpy(xbuf[0], m, m_size); sg_init_table(src_tab, 3); sg_set_buf(&src_tab[0], xbuf[0], 8); sg_set_buf(&src_tab[1], xbuf[0] + 8, m_size - 8); if (vecs->siggen_sigver_test) { if (WARN_ON(c_size > PAGE_SIZE)) goto free_all; memcpy(xbuf[1], c, c_size); sg_set_buf(&src_tab[2], xbuf[1], c_size); akcipher_request_set_crypt(req, src_tab, NULL, m_size, c_size); } else { sg_init_one(&dst, outbuf_enc, out_len_max); akcipher_request_set_crypt(req, src_tab, &dst, m_size, out_len_max); } akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, crypto_req_done, &wait); err = crypto_wait_req(vecs->siggen_sigver_test ? /* Run asymmetric signature verification */ crypto_akcipher_verify(req) : /* Run asymmetric encrypt */ crypto_akcipher_encrypt(req), &wait); if (err) { pr_err("alg: akcipher: %s test failed. err %d\n", op, err); goto free_all; } if (!vecs->siggen_sigver_test) { if (req->dst_len != c_size) { pr_err("alg: akcipher: %s test failed. Invalid output len\n", op); err = -EINVAL; goto free_all; } /* verify that encrypted message is equal to expected */ if (memcmp(c, outbuf_enc, c_size) != 0) { pr_err("alg: akcipher: %s test failed. Invalid output\n", op); hexdump(outbuf_enc, c_size); err = -EINVAL; goto free_all; } } /* * Don't invoke (decrypt or sign) test which require a private key * for vectors with only a public key. */ if (vecs->public_key_vec) { err = 0; goto free_all; } outbuf_dec = kzalloc(out_len_max, GFP_KERNEL); if (!outbuf_dec) { err = -ENOMEM; goto free_all; } op = vecs->siggen_sigver_test ? "sign" : "decrypt"; if (WARN_ON(c_size > PAGE_SIZE)) goto free_all; memcpy(xbuf[0], c, c_size); sg_init_one(&src, xbuf[0], c_size); sg_init_one(&dst, outbuf_dec, out_len_max); crypto_init_wait(&wait); akcipher_request_set_crypt(req, &src, &dst, c_size, out_len_max); err = crypto_wait_req(vecs->siggen_sigver_test ? /* Run asymmetric signature generation */ crypto_akcipher_sign(req) : /* Run asymmetric decrypt */ crypto_akcipher_decrypt(req), &wait); if (err) { pr_err("alg: akcipher: %s test failed. err %d\n", op, err); goto free_all; } out_len = req->dst_len; if (out_len < m_size) { pr_err("alg: akcipher: %s test failed. Invalid output len %u\n", op, out_len); err = -EINVAL; goto free_all; } /* verify that decrypted message is equal to the original msg */ if (memchr_inv(outbuf_dec, 0, out_len - m_size) || memcmp(m, outbuf_dec + out_len - m_size, m_size)) { pr_err("alg: akcipher: %s test failed. Invalid output\n", op); hexdump(outbuf_dec, out_len); err = -EINVAL; } free_all: kfree(outbuf_dec); kfree(outbuf_enc); free_req: akcipher_request_free(req); kfree(key); free_xbuf: testmgr_free_buf(xbuf); return err; } static int test_akcipher(struct crypto_akcipher *tfm, const char *alg, const struct akcipher_testvec *vecs, unsigned int tcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_akcipher_tfm(tfm)); int ret, i; for (i = 0; i < tcount; i++) { ret = test_akcipher_one(tfm, vecs++); if (!ret) continue; pr_err("alg: akcipher: test %d failed for %s, err=%d\n", i + 1, algo, ret); return ret; } return 0; } static int alg_test_akcipher(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { struct crypto_akcipher *tfm; int err = 0; tfm = crypto_alloc_akcipher(driver, type, mask); if (IS_ERR(tfm)) { pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n", driver, PTR_ERR(tfm)); return PTR_ERR(tfm); } if (desc->suite.akcipher.vecs) err = test_akcipher(tfm, desc->alg, desc->suite.akcipher.vecs, desc->suite.akcipher.count); crypto_free_akcipher(tfm); return err; } static int alg_test_null(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { return 0; } #define __VECS(tv) { .vecs = tv, .count = ARRAY_SIZE(tv) } /* Please keep this list sorted by algorithm name. */ static const struct alg_test_desc alg_test_descs[] = { { .alg = "adiantum(xchacha12,aes)", .generic_driver = "adiantum(xchacha12-generic,aes-generic,nhpoly1305-generic)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(adiantum_xchacha12_aes_tv_template) }, }, { .alg = "adiantum(xchacha20,aes)", .generic_driver = "adiantum(xchacha20-generic,aes-generic,nhpoly1305-generic)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(adiantum_xchacha20_aes_tv_template) }, }, { .alg = "aegis128", .test = alg_test_aead, .suite = { .aead = __VECS(aegis128_tv_template) } }, { .alg = "aegis128l", .test = alg_test_aead, .suite = { .aead = __VECS(aegis128l_tv_template) } }, { .alg = "aegis256", .test = alg_test_aead, .suite = { .aead = __VECS(aegis256_tv_template) } }, { .alg = "ansi_cprng", .test = alg_test_cprng, .suite = { .cprng = __VECS(ansi_cprng_aes_tv_template) } }, { .alg = "authenc(hmac(md5),ecb(cipher_null))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_md5_ecb_cipher_null_tv_template) } }, { .alg = "authenc(hmac(sha1),cbc(aes))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha1_aes_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha1),cbc(des))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha1_des_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha1),cbc(des3_ede))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha1_des3_ede_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha1),ctr(aes))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha1),ecb(cipher_null))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha1_ecb_cipher_null_tv_temp) } }, { .alg = "authenc(hmac(sha1),rfc3686(ctr(aes)))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha224),cbc(des))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha224_des_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha224),cbc(des3_ede))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha224_des3_ede_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha256),cbc(aes))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha256_aes_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha256),cbc(des))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha256_des_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha256),cbc(des3_ede))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha256_des3_ede_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha256),ctr(aes))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha256),rfc3686(ctr(aes)))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha384),cbc(des))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha384_des_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha384),cbc(des3_ede))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha384_des3_ede_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha384),ctr(aes))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha384),rfc3686(ctr(aes)))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha512),cbc(aes))", .fips_allowed = 1, .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha512_aes_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha512),cbc(des))", .test = alg_test_aead, .suite = { .aead = __VECS(hmac_sha512_des_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha512),cbc(des3_ede))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(hmac_sha512_des3_ede_cbc_tv_temp) } }, { .alg = "authenc(hmac(sha512),ctr(aes))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "authenc(hmac(sha512),rfc3686(ctr(aes)))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "cbc(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_cbc_tv_template) }, }, { .alg = "cbc(anubis)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(anubis_cbc_tv_template) }, }, { .alg = "cbc(blowfish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(bf_cbc_tv_template) }, }, { .alg = "cbc(camellia)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(camellia_cbc_tv_template) }, }, { .alg = "cbc(cast5)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast5_cbc_tv_template) }, }, { .alg = "cbc(cast6)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast6_cbc_tv_template) }, }, { .alg = "cbc(des)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(des_cbc_tv_template) }, }, { .alg = "cbc(des3_ede)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(des3_ede_cbc_tv_template) }, }, { /* Same as cbc(aes) except the key is stored in * hardware secure memory which we reference by index */ .alg = "cbc(paes)", .test = alg_test_null, .fips_allowed = 1, }, { /* Same as cbc(sm4) except the key is stored in * hardware secure memory which we reference by index */ .alg = "cbc(psm4)", .test = alg_test_null, }, { .alg = "cbc(serpent)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(serpent_cbc_tv_template) }, }, { .alg = "cbc(sm4)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(sm4_cbc_tv_template) } }, { .alg = "cbc(twofish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tf_cbc_tv_template) }, }, { .alg = "cbcmac(aes)", .fips_allowed = 1, .test = alg_test_hash, .suite = { .hash = __VECS(aes_cbcmac_tv_template) } }, { .alg = "ccm(aes)", .generic_driver = "ccm_base(ctr(aes-generic),cbcmac(aes-generic))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(aes_ccm_tv_template) } }, { .alg = "cfb(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_cfb_tv_template) }, }, { .alg = "chacha20", .test = alg_test_skcipher, .suite = { .cipher = __VECS(chacha20_tv_template) }, }, { .alg = "cmac(aes)", .fips_allowed = 1, .test = alg_test_hash, .suite = { .hash = __VECS(aes_cmac128_tv_template) } }, { .alg = "cmac(des3_ede)", .fips_allowed = 1, .test = alg_test_hash, .suite = { .hash = __VECS(des3_ede_cmac64_tv_template) } }, { .alg = "compress_null", .test = alg_test_null, }, { .alg = "crc32", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(crc32_tv_template) } }, { .alg = "crc32c", .test = alg_test_crc32c, .fips_allowed = 1, .suite = { .hash = __VECS(crc32c_tv_template) } }, { .alg = "crct10dif", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(crct10dif_tv_template) } }, { .alg = "ctr(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_ctr_tv_template) } }, { .alg = "ctr(blowfish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(bf_ctr_tv_template) } }, { .alg = "ctr(camellia)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(camellia_ctr_tv_template) } }, { .alg = "ctr(cast5)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast5_ctr_tv_template) } }, { .alg = "ctr(cast6)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast6_ctr_tv_template) } }, { .alg = "ctr(des)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(des_ctr_tv_template) } }, { .alg = "ctr(des3_ede)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(des3_ede_ctr_tv_template) } }, { /* Same as ctr(aes) except the key is stored in * hardware secure memory which we reference by index */ .alg = "ctr(paes)", .test = alg_test_null, .fips_allowed = 1, }, { /* Same as ctr(sm4) except the key is stored in * hardware secure memory which we reference by index */ .alg = "ctr(psm4)", .test = alg_test_null, }, { .alg = "ctr(serpent)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(serpent_ctr_tv_template) } }, { .alg = "ctr(sm4)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(sm4_ctr_tv_template) } }, { .alg = "ctr(twofish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tf_ctr_tv_template) } }, { .alg = "cts(cbc(aes))", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(cts_mode_tv_template) } }, { /* Same as cts(cbc((aes)) except the key is stored in * hardware secure memory which we reference by index */ .alg = "cts(cbc(paes))", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "deflate", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(deflate_comp_tv_template), .decomp = __VECS(deflate_decomp_tv_template) } } }, { .alg = "dh", .test = alg_test_kpp, .fips_allowed = 1, .suite = { .kpp = __VECS(dh_tv_template) } }, { .alg = "digest_null", .test = alg_test_null, }, { .alg = "drbg_nopr_ctr_aes128", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_nopr_ctr_aes128_tv_template) } }, { .alg = "drbg_nopr_ctr_aes192", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_nopr_ctr_aes192_tv_template) } }, { .alg = "drbg_nopr_ctr_aes256", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_nopr_ctr_aes256_tv_template) } }, { /* * There is no need to specifically test the DRBG with every * backend cipher -- covered by drbg_nopr_hmac_sha256 test */ .alg = "drbg_nopr_hmac_sha1", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_nopr_hmac_sha256", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_nopr_hmac_sha256_tv_template) } }, { /* covered by drbg_nopr_hmac_sha256 test */ .alg = "drbg_nopr_hmac_sha384", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_nopr_hmac_sha512", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "drbg_nopr_sha1", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_nopr_sha256", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_nopr_sha256_tv_template) } }, { /* covered by drbg_nopr_sha256 test */ .alg = "drbg_nopr_sha384", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_nopr_sha512", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_ctr_aes128", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_pr_ctr_aes128_tv_template) } }, { /* covered by drbg_pr_ctr_aes128 test */ .alg = "drbg_pr_ctr_aes192", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_ctr_aes256", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_hmac_sha1", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_hmac_sha256", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_pr_hmac_sha256_tv_template) } }, { /* covered by drbg_pr_hmac_sha256 test */ .alg = "drbg_pr_hmac_sha384", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_hmac_sha512", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "drbg_pr_sha1", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_sha256", .test = alg_test_drbg, .fips_allowed = 1, .suite = { .drbg = __VECS(drbg_pr_sha256_tv_template) } }, { /* covered by drbg_pr_sha256 test */ .alg = "drbg_pr_sha384", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "drbg_pr_sha512", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "ecb(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_tv_template) } }, { .alg = "ecb(anubis)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(anubis_tv_template) } }, { .alg = "ecb(arc4)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(arc4_tv_template) } }, { .alg = "ecb(blowfish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(bf_tv_template) } }, { .alg = "ecb(camellia)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(camellia_tv_template) } }, { .alg = "ecb(cast5)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast5_tv_template) } }, { .alg = "ecb(cast6)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast6_tv_template) } }, { .alg = "ecb(cipher_null)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "ecb(des)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(des_tv_template) } }, { .alg = "ecb(des3_ede)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(des3_ede_tv_template) } }, { .alg = "ecb(fcrypt)", .test = alg_test_skcipher, .suite = { .cipher = { .vecs = fcrypt_pcbc_tv_template, .count = 1 } } }, { .alg = "ecb(khazad)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(khazad_tv_template) } }, { /* Same as ecb(aes) except the key is stored in * hardware secure memory which we reference by index */ .alg = "ecb(paes)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "ecb(seed)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(seed_tv_template) } }, { .alg = "ecb(serpent)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(serpent_tv_template) } }, { .alg = "ecb(sm4)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(sm4_tv_template) } }, { .alg = "ecb(tea)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tea_tv_template) } }, { .alg = "ecb(tnepres)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tnepres_tv_template) } }, { .alg = "ecb(twofish)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tf_tv_template) } }, { .alg = "ecb(xeta)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(xeta_tv_template) } }, { .alg = "ecb(xtea)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(xtea_tv_template) } }, { .alg = "ecdh", .test = alg_test_kpp, .fips_allowed = 1, .suite = { .kpp = __VECS(ecdh_tv_template) } }, { .alg = "ecrdsa", .test = alg_test_akcipher, .suite = { .akcipher = __VECS(ecrdsa_tv_template) } }, { .alg = "gcm(aes)", .generic_driver = "gcm_base(ctr(aes-generic),ghash-generic)", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(aes_gcm_tv_template) } }, { .alg = "ghash", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(ghash_tv_template) } }, { .alg = "hmac(md5)", .test = alg_test_hash, .suite = { .hash = __VECS(hmac_md5_tv_template) } }, { .alg = "hmac(rmd128)", .test = alg_test_hash, .suite = { .hash = __VECS(hmac_rmd128_tv_template) } }, { .alg = "hmac(rmd160)", .test = alg_test_hash, .suite = { .hash = __VECS(hmac_rmd160_tv_template) } }, { .alg = "hmac(sha1)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha1_tv_template) } }, { .alg = "hmac(sha224)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha224_tv_template) } }, { .alg = "hmac(sha256)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha256_tv_template) } }, { .alg = "hmac(sha3-224)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha3_224_tv_template) } }, { .alg = "hmac(sha3-256)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha3_256_tv_template) } }, { .alg = "hmac(sha3-384)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha3_384_tv_template) } }, { .alg = "hmac(sha3-512)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha3_512_tv_template) } }, { .alg = "hmac(sha384)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha384_tv_template) } }, { .alg = "hmac(sha512)", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(hmac_sha512_tv_template) } }, { .alg = "hmac(streebog256)", .test = alg_test_hash, .suite = { .hash = __VECS(hmac_streebog256_tv_template) } }, { .alg = "hmac(streebog512)", .test = alg_test_hash, .suite = { .hash = __VECS(hmac_streebog512_tv_template) } }, { .alg = "jitterentropy_rng", .fips_allowed = 1, .test = alg_test_null, }, { .alg = "kw(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_kw_tv_template) } }, { .alg = "lrw(aes)", .generic_driver = "lrw(ecb(aes-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(aes_lrw_tv_template) } }, { .alg = "lrw(camellia)", .generic_driver = "lrw(ecb(camellia-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(camellia_lrw_tv_template) } }, { .alg = "lrw(cast6)", .generic_driver = "lrw(ecb(cast6-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast6_lrw_tv_template) } }, { .alg = "lrw(serpent)", .generic_driver = "lrw(ecb(serpent-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(serpent_lrw_tv_template) } }, { .alg = "lrw(twofish)", .generic_driver = "lrw(ecb(twofish-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tf_lrw_tv_template) } }, { .alg = "lz4", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(lz4_comp_tv_template), .decomp = __VECS(lz4_decomp_tv_template) } } }, { .alg = "lz4hc", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(lz4hc_comp_tv_template), .decomp = __VECS(lz4hc_decomp_tv_template) } } }, { .alg = "lzo", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(lzo_comp_tv_template), .decomp = __VECS(lzo_decomp_tv_template) } } }, { .alg = "md4", .test = alg_test_hash, .suite = { .hash = __VECS(md4_tv_template) } }, { .alg = "md5", .test = alg_test_hash, .suite = { .hash = __VECS(md5_tv_template) } }, { .alg = "michael_mic", .test = alg_test_hash, .suite = { .hash = __VECS(michael_mic_tv_template) } }, { .alg = "morus1280", .test = alg_test_aead, .suite = { .aead = __VECS(morus1280_tv_template) } }, { .alg = "morus640", .test = alg_test_aead, .suite = { .aead = __VECS(morus640_tv_template) } }, { .alg = "nhpoly1305", .test = alg_test_hash, .suite = { .hash = __VECS(nhpoly1305_tv_template) } }, { .alg = "ofb(aes)", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_ofb_tv_template) } }, { /* Same as ofb(aes) except the key is stored in * hardware secure memory which we reference by index */ .alg = "ofb(paes)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "pcbc(fcrypt)", .test = alg_test_skcipher, .suite = { .cipher = __VECS(fcrypt_pcbc_tv_template) } }, { .alg = "pkcs1pad(rsa,sha224)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "pkcs1pad(rsa,sha256)", .test = alg_test_akcipher, .fips_allowed = 1, .suite = { .akcipher = __VECS(pkcs1pad_rsa_tv_template) } }, { .alg = "pkcs1pad(rsa,sha384)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "pkcs1pad(rsa,sha512)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "poly1305", .test = alg_test_hash, .suite = { .hash = __VECS(poly1305_tv_template) } }, { .alg = "rfc3686(ctr(aes))", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_ctr_rfc3686_tv_template) } }, { .alg = "rfc4106(gcm(aes))", .generic_driver = "rfc4106(gcm_base(ctr(aes-generic),ghash-generic))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(aes_gcm_rfc4106_tv_template) } }, { .alg = "rfc4309(ccm(aes))", .generic_driver = "rfc4309(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))", .test = alg_test_aead, .fips_allowed = 1, .suite = { .aead = __VECS(aes_ccm_rfc4309_tv_template) } }, { .alg = "rfc4543(gcm(aes))", .generic_driver = "rfc4543(gcm_base(ctr(aes-generic),ghash-generic))", .test = alg_test_aead, .suite = { .aead = __VECS(aes_gcm_rfc4543_tv_template) } }, { .alg = "rfc7539(chacha20,poly1305)", .test = alg_test_aead, .suite = { .aead = __VECS(rfc7539_tv_template) } }, { .alg = "rfc7539esp(chacha20,poly1305)", .test = alg_test_aead, .suite = { .aead = __VECS(rfc7539esp_tv_template) } }, { .alg = "rmd128", .test = alg_test_hash, .suite = { .hash = __VECS(rmd128_tv_template) } }, { .alg = "rmd160", .test = alg_test_hash, .suite = { .hash = __VECS(rmd160_tv_template) } }, { .alg = "rmd256", .test = alg_test_hash, .suite = { .hash = __VECS(rmd256_tv_template) } }, { .alg = "rmd320", .test = alg_test_hash, .suite = { .hash = __VECS(rmd320_tv_template) } }, { .alg = "rsa", .test = alg_test_akcipher, .fips_allowed = 1, .suite = { .akcipher = __VECS(rsa_tv_template) } }, { .alg = "salsa20", .test = alg_test_skcipher, .suite = { .cipher = __VECS(salsa20_stream_tv_template) } }, { .alg = "sha1", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha1_tv_template) } }, { .alg = "sha224", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha224_tv_template) } }, { .alg = "sha256", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha256_tv_template) } }, { .alg = "sha3-224", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha3_224_tv_template) } }, { .alg = "sha3-256", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha3_256_tv_template) } }, { .alg = "sha3-384", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha3_384_tv_template) } }, { .alg = "sha3-512", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha3_512_tv_template) } }, { .alg = "sha384", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha384_tv_template) } }, { .alg = "sha512", .test = alg_test_hash, .fips_allowed = 1, .suite = { .hash = __VECS(sha512_tv_template) } }, { .alg = "sm3", .test = alg_test_hash, .suite = { .hash = __VECS(sm3_tv_template) } }, { .alg = "streebog256", .test = alg_test_hash, .suite = { .hash = __VECS(streebog256_tv_template) } }, { .alg = "streebog512", .test = alg_test_hash, .suite = { .hash = __VECS(streebog512_tv_template) } }, { .alg = "tgr128", .test = alg_test_hash, .suite = { .hash = __VECS(tgr128_tv_template) } }, { .alg = "tgr160", .test = alg_test_hash, .suite = { .hash = __VECS(tgr160_tv_template) } }, { .alg = "tgr192", .test = alg_test_hash, .suite = { .hash = __VECS(tgr192_tv_template) } }, { .alg = "vmac64(aes)", .test = alg_test_hash, .suite = { .hash = __VECS(vmac64_aes_tv_template) } }, { .alg = "wp256", .test = alg_test_hash, .suite = { .hash = __VECS(wp256_tv_template) } }, { .alg = "wp384", .test = alg_test_hash, .suite = { .hash = __VECS(wp384_tv_template) } }, { .alg = "wp512", .test = alg_test_hash, .suite = { .hash = __VECS(wp512_tv_template) } }, { .alg = "xcbc(aes)", .test = alg_test_hash, .suite = { .hash = __VECS(aes_xcbc128_tv_template) } }, { .alg = "xchacha12", .test = alg_test_skcipher, .suite = { .cipher = __VECS(xchacha12_tv_template) }, }, { .alg = "xchacha20", .test = alg_test_skcipher, .suite = { .cipher = __VECS(xchacha20_tv_template) }, }, { .alg = "xts(aes)", .generic_driver = "xts(ecb(aes-generic))", .test = alg_test_skcipher, .fips_allowed = 1, .suite = { .cipher = __VECS(aes_xts_tv_template) } }, { .alg = "xts(camellia)", .generic_driver = "xts(ecb(camellia-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(camellia_xts_tv_template) } }, { .alg = "xts(cast6)", .generic_driver = "xts(ecb(cast6-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(cast6_xts_tv_template) } }, { /* Same as xts(aes) except the key is stored in * hardware secure memory which we reference by index */ .alg = "xts(paes)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "xts(serpent)", .generic_driver = "xts(ecb(serpent-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(serpent_xts_tv_template) } }, { .alg = "xts(twofish)", .generic_driver = "xts(ecb(twofish-generic))", .test = alg_test_skcipher, .suite = { .cipher = __VECS(tf_xts_tv_template) } }, { .alg = "xts4096(paes)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "xts512(paes)", .test = alg_test_null, .fips_allowed = 1, }, { .alg = "zlib-deflate", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(zlib_deflate_comp_tv_template), .decomp = __VECS(zlib_deflate_decomp_tv_template) } } }, { .alg = "zstd", .test = alg_test_comp, .fips_allowed = 1, .suite = { .comp = { .comp = __VECS(zstd_comp_tv_template), .decomp = __VECS(zstd_decomp_tv_template) } } } }; static void alg_check_test_descs_order(void) { int i; for (i = 1; i < ARRAY_SIZE(alg_test_descs); i++) { int diff = strcmp(alg_test_descs[i - 1].alg, alg_test_descs[i].alg); if (WARN_ON(diff > 0)) { pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n", alg_test_descs[i - 1].alg, alg_test_descs[i].alg); } if (WARN_ON(diff == 0)) { pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n", alg_test_descs[i].alg); } } } static void alg_check_testvec_configs(void) { int i; for (i = 0; i < ARRAY_SIZE(default_cipher_testvec_configs); i++) WARN_ON(!valid_testvec_config( &default_cipher_testvec_configs[i])); for (i = 0; i < ARRAY_SIZE(default_hash_testvec_configs); i++) WARN_ON(!valid_testvec_config( &default_hash_testvec_configs[i])); } static void testmgr_onetime_init(void) { alg_check_test_descs_order(); alg_check_testvec_configs(); #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS pr_warn("alg: extra crypto tests enabled. This is intended for developer use only.\n"); #endif } static int alg_find_test(const char *alg) { int start = 0; int end = ARRAY_SIZE(alg_test_descs); while (start < end) { int i = (start + end) / 2; int diff = strcmp(alg_test_descs[i].alg, alg); if (diff > 0) { end = i; continue; } if (diff < 0) { start = i + 1; continue; } return i; } return -1; } int alg_test(const char *driver, const char *alg, u32 type, u32 mask) { int i; int j; int rc; if (!fips_enabled && notests) { printk_once(KERN_INFO "alg: self-tests disabled\n"); return 0; } DO_ONCE(testmgr_onetime_init); if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { char nalg[CRYPTO_MAX_ALG_NAME]; if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >= sizeof(nalg)) return -ENAMETOOLONG; i = alg_find_test(nalg); if (i < 0) goto notest; if (fips_enabled && !alg_test_descs[i].fips_allowed) goto non_fips_alg; rc = alg_test_cipher(alg_test_descs + i, driver, type, mask); goto test_done; } i = alg_find_test(alg); j = alg_find_test(driver); if (i < 0 && j < 0) goto notest; if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) || (j >= 0 && !alg_test_descs[j].fips_allowed))) goto non_fips_alg; rc = 0; if (i >= 0) rc |= alg_test_descs[i].test(alg_test_descs + i, driver, type, mask); if (j >= 0 && j != i) rc |= alg_test_descs[j].test(alg_test_descs + j, driver, type, mask); test_done: if (rc && (fips_enabled || panic_on_fail)) panic("alg: self-tests for %s (%s) failed in %s mode!\n", driver, alg, fips_enabled ? "fips" : "panic_on_fail"); if (fips_enabled && !rc) pr_info("alg: self-tests for %s (%s) passed\n", driver, alg); return rc; notest: printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver); return 0; non_fips_alg: return -EINVAL; } #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */ EXPORT_SYMBOL_GPL(alg_test);
gpl-2.0
SeanGo/kernel2.6
drivers/macintosh/windfarm_core.c
11175
/* * Windfarm PowerMac thermal control. Core * * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp. * <[email protected]> * * Released under the term of the GNU GPL v2. * * This core code tracks the list of sensors & controls, register * clients, and holds the kernel thread used for control. * * TODO: * * Add some information about sensor/control type and data format to * sensors/controls, and have the sysfs attribute stuff be moved * generically here instead of hard coded in the platform specific * driver as it us currently * * This however requires solving some annoying lifetime issues with * sysfs which doesn't seem to have lifetime rules for struct attribute, * I may have to create full features kobjects for every sensor/control * instead which is a bit of an overkill imho */ #include <linux/types.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/kthread.h> #include <linux/jiffies.h> #include <linux/reboot.h> #include <linux/device.h> #include <linux/platform_device.h> #include <linux/mutex.h> #include <linux/freezer.h> #include <asm/prom.h> #include "windfarm.h" #define VERSION "0.2" #undef DEBUG #ifdef DEBUG #define DBG(args...) printk(args) #else #define DBG(args...) do { } while(0) #endif static LIST_HEAD(wf_controls); static LIST_HEAD(wf_sensors); static DEFINE_MUTEX(wf_lock); static BLOCKING_NOTIFIER_HEAD(wf_client_list); static int wf_client_count; static unsigned int wf_overtemp; static unsigned int wf_overtemp_counter; struct task_struct *wf_thread; static struct platform_device wf_platform_device = { .name = "windfarm", }; /* * Utilities & tick thread */ static inline void wf_notify(int event, void *param) { blocking_notifier_call_chain(&wf_client_list, event, param); } int wf_critical_overtemp(void) { static char * critical_overtemp_path = "/sbin/critical_overtemp"; char *argv[] = { critical_overtemp_path, NULL }; static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; return call_usermodehelper(critical_overtemp_path, argv, envp, UMH_WAIT_EXEC); } EXPORT_SYMBOL_GPL(wf_critical_overtemp); static int wf_thread_func(void *data) { unsigned long next, delay; next = jiffies; DBG("wf: thread started\n"); set_freezable(); while (!kthread_should_stop()) { try_to_freeze(); if (time_after_eq(jiffies, next)) { wf_notify(WF_EVENT_TICK, NULL); if (wf_overtemp) { wf_overtemp_counter++; /* 10 seconds overtemp, notify userland */ if (wf_overtemp_counter > 10) wf_critical_overtemp(); /* 30 seconds, shutdown */ if (wf_overtemp_counter > 30) { printk(KERN_ERR "windfarm: Overtemp " "for more than 30" " seconds, shutting down\n"); machine_power_off(); } } next += HZ; } delay = next - jiffies; if (delay <= HZ) schedule_timeout_interruptible(delay); } DBG("wf: thread stopped\n"); return 0; } static void wf_start_thread(void) { wf_thread = kthread_run(wf_thread_func, NULL, "kwindfarm"); if (IS_ERR(wf_thread)) { printk(KERN_ERR "windfarm: failed to create thread,err %ld\n", PTR_ERR(wf_thread)); wf_thread = NULL; } } static void wf_stop_thread(void) { if (wf_thread) kthread_stop(wf_thread); wf_thread = NULL; } /* * Controls */ static void wf_control_release(struct kref *kref) { struct wf_control *ct = container_of(kref, struct wf_control, ref); DBG("wf: Deleting control %s\n", ct->name); if (ct->ops && ct->ops->release) ct->ops->release(ct); else kfree(ct); } static ssize_t wf_show_control(struct device *dev, struct device_attribute *attr, char *buf) { struct wf_control *ctrl = container_of(attr, struct wf_control, attr); s32 val = 0; int err; err = ctrl->ops->get_value(ctrl, &val); if (err < 0) return err; return sprintf(buf, "%d\n", val); } /* This is really only for debugging... */ static ssize_t wf_store_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct wf_control *ctrl = container_of(attr, struct wf_control, attr); int val; int err; char *endp; val = simple_strtoul(buf, &endp, 0); while (endp < buf + count && (*endp == ' ' || *endp == '\n')) ++endp; if (endp - buf < count) return -EINVAL; err = ctrl->ops->set_value(ctrl, val); if (err < 0) return err; return count; } int wf_register_control(struct wf_control *new_ct) { struct wf_control *ct; mutex_lock(&wf_lock); list_for_each_entry(ct, &wf_controls, link) { if (!strcmp(ct->name, new_ct->name)) { printk(KERN_WARNING "windfarm: trying to register" " duplicate control %s\n", ct->name); mutex_unlock(&wf_lock); return -EEXIST; } } kref_init(&new_ct->ref); list_add(&new_ct->link, &wf_controls); new_ct->attr.attr.name = new_ct->name; new_ct->attr.attr.mode = 0644; new_ct->attr.show = wf_show_control; new_ct->attr.store = wf_store_control; if (device_create_file(&wf_platform_device.dev, &new_ct->attr)) printk(KERN_WARNING "windfarm: device_create_file failed" " for %s\n", new_ct->name); /* the subsystem still does useful work without the file */ DBG("wf: Registered control %s\n", new_ct->name); wf_notify(WF_EVENT_NEW_CONTROL, new_ct); mutex_unlock(&wf_lock); return 0; } EXPORT_SYMBOL_GPL(wf_register_control); void wf_unregister_control(struct wf_control *ct) { mutex_lock(&wf_lock); list_del(&ct->link); mutex_unlock(&wf_lock); DBG("wf: Unregistered control %s\n", ct->name); kref_put(&ct->ref, wf_control_release); } EXPORT_SYMBOL_GPL(wf_unregister_control); struct wf_control * wf_find_control(const char *name) { struct wf_control *ct; mutex_lock(&wf_lock); list_for_each_entry(ct, &wf_controls, link) { if (!strcmp(ct->name, name)) { if (wf_get_control(ct)) ct = NULL; mutex_unlock(&wf_lock); return ct; } } mutex_unlock(&wf_lock); return NULL; } EXPORT_SYMBOL_GPL(wf_find_control); int wf_get_control(struct wf_control *ct) { if (!try_module_get(ct->ops->owner)) return -ENODEV; kref_get(&ct->ref); return 0; } EXPORT_SYMBOL_GPL(wf_get_control); void wf_put_control(struct wf_control *ct) { struct module *mod = ct->ops->owner; kref_put(&ct->ref, wf_control_release); module_put(mod); } EXPORT_SYMBOL_GPL(wf_put_control); /* * Sensors */ static void wf_sensor_release(struct kref *kref) { struct wf_sensor *sr = container_of(kref, struct wf_sensor, ref); DBG("wf: Deleting sensor %s\n", sr->name); if (sr->ops && sr->ops->release) sr->ops->release(sr); else kfree(sr); } static ssize_t wf_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) { struct wf_sensor *sens = container_of(attr, struct wf_sensor, attr); s32 val = 0; int err; err = sens->ops->get_value(sens, &val); if (err < 0) return err; return sprintf(buf, "%d.%03d\n", FIX32TOPRINT(val)); } int wf_register_sensor(struct wf_sensor *new_sr) { struct wf_sensor *sr; mutex_lock(&wf_lock); list_for_each_entry(sr, &wf_sensors, link) { if (!strcmp(sr->name, new_sr->name)) { printk(KERN_WARNING "windfarm: trying to register" " duplicate sensor %s\n", sr->name); mutex_unlock(&wf_lock); return -EEXIST; } } kref_init(&new_sr->ref); list_add(&new_sr->link, &wf_sensors); new_sr->attr.attr.name = new_sr->name; new_sr->attr.attr.mode = 0444; new_sr->attr.show = wf_show_sensor; new_sr->attr.store = NULL; if (device_create_file(&wf_platform_device.dev, &new_sr->attr)) printk(KERN_WARNING "windfarm: device_create_file failed" " for %s\n", new_sr->name); /* the subsystem still does useful work without the file */ DBG("wf: Registered sensor %s\n", new_sr->name); wf_notify(WF_EVENT_NEW_SENSOR, new_sr); mutex_unlock(&wf_lock); return 0; } EXPORT_SYMBOL_GPL(wf_register_sensor); void wf_unregister_sensor(struct wf_sensor *sr) { mutex_lock(&wf_lock); list_del(&sr->link); mutex_unlock(&wf_lock); DBG("wf: Unregistered sensor %s\n", sr->name); wf_put_sensor(sr); } EXPORT_SYMBOL_GPL(wf_unregister_sensor); struct wf_sensor * wf_find_sensor(const char *name) { struct wf_sensor *sr; mutex_lock(&wf_lock); list_for_each_entry(sr, &wf_sensors, link) { if (!strcmp(sr->name, name)) { if (wf_get_sensor(sr)) sr = NULL; mutex_unlock(&wf_lock); return sr; } } mutex_unlock(&wf_lock); return NULL; } EXPORT_SYMBOL_GPL(wf_find_sensor); int wf_get_sensor(struct wf_sensor *sr) { if (!try_module_get(sr->ops->owner)) return -ENODEV; kref_get(&sr->ref); return 0; } EXPORT_SYMBOL_GPL(wf_get_sensor); void wf_put_sensor(struct wf_sensor *sr) { struct module *mod = sr->ops->owner; kref_put(&sr->ref, wf_sensor_release); module_put(mod); } EXPORT_SYMBOL_GPL(wf_put_sensor); /* * Client & notification */ int wf_register_client(struct notifier_block *nb) { int rc; struct wf_control *ct; struct wf_sensor *sr; mutex_lock(&wf_lock); rc = blocking_notifier_chain_register(&wf_client_list, nb); if (rc != 0) goto bail; wf_client_count++; list_for_each_entry(ct, &wf_controls, link) wf_notify(WF_EVENT_NEW_CONTROL, ct); list_for_each_entry(sr, &wf_sensors, link) wf_notify(WF_EVENT_NEW_SENSOR, sr); if (wf_client_count == 1) wf_start_thread(); bail: mutex_unlock(&wf_lock); return rc; } EXPORT_SYMBOL_GPL(wf_register_client); int wf_unregister_client(struct notifier_block *nb) { mutex_lock(&wf_lock); blocking_notifier_chain_unregister(&wf_client_list, nb); wf_client_count--; if (wf_client_count == 0) wf_stop_thread(); mutex_unlock(&wf_lock); return 0; } EXPORT_SYMBOL_GPL(wf_unregister_client); void wf_set_overtemp(void) { mutex_lock(&wf_lock); wf_overtemp++; if (wf_overtemp == 1) { printk(KERN_WARNING "windfarm: Overtemp condition detected !\n"); wf_overtemp_counter = 0; wf_notify(WF_EVENT_OVERTEMP, NULL); } mutex_unlock(&wf_lock); } EXPORT_SYMBOL_GPL(wf_set_overtemp); void wf_clear_overtemp(void) { mutex_lock(&wf_lock); WARN_ON(wf_overtemp == 0); if (wf_overtemp == 0) { mutex_unlock(&wf_lock); return; } wf_overtemp--; if (wf_overtemp == 0) { printk(KERN_WARNING "windfarm: Overtemp condition cleared !\n"); wf_notify(WF_EVENT_NORMALTEMP, NULL); } mutex_unlock(&wf_lock); } EXPORT_SYMBOL_GPL(wf_clear_overtemp); int wf_is_overtemp(void) { return (wf_overtemp != 0); } EXPORT_SYMBOL_GPL(wf_is_overtemp); static int __init windfarm_core_init(void) { DBG("wf: core loaded\n"); /* Don't register on old machines that use therm_pm72 for now */ if (machine_is_compatible("PowerMac7,2") || machine_is_compatible("PowerMac7,3") || machine_is_compatible("RackMac3,1")) return -ENODEV; platform_device_register(&wf_platform_device); return 0; } static void __exit windfarm_core_exit(void) { BUG_ON(wf_client_count != 0); DBG("wf: core unloaded\n"); platform_device_unregister(&wf_platform_device); } module_init(windfarm_core_init); module_exit(windfarm_core_exit); MODULE_AUTHOR("Benjamin Herrenschmidt <[email protected]>"); MODULE_DESCRIPTION("Core component of PowerMac thermal control"); MODULE_LICENSE("GPL");
gpl-2.0
yourealwaysbe/viking
src/vikmapslayer.h
3020
/* * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * * Copyright (C) 2003-2005, Evan Battaglia <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _VIKING_MAPSLAYER_H #define _VIKING_MAPSLAYER_H #include "vikcoord.h" #include "viklayer.h" #include "vikviewport.h" #include "vikmapsource.h" #include "mapcoord.h" #include "vikmapslayer_compat.h" G_BEGIN_DECLS #define VIK_MAPS_LAYER_TYPE (vik_maps_layer_get_type ()) #define VIK_MAPS_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_MAPS_LAYER_TYPE, VikMapsLayer)) #define VIK_MAPS_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_MAPS_LAYER_TYPE, VikMapsLayerClass)) #define IS_VIK_MAPS_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_MAPS_LAYER_TYPE)) #define IS_VIK_MAPS_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_MAPS_LAYER_TYPE)) typedef struct _VikMapsLayerClass VikMapsLayerClass; struct _VikMapsLayerClass { VikLayerClass object_class; }; GType vik_maps_layer_get_type (); typedef struct _VikMapsLayer VikMapsLayer; typedef enum { VIK_MAPS_CACHE_LAYOUT_VIKING=0, // CacheDir/t<MapId>s<VikingZoom>z0/X/Y (NB no file extension) - Legacy default layout VIK_MAPS_CACHE_LAYOUT_OSM, // CacheDir/<OptionalMapName>/OSMZoomLevel/X/Y.ext (Default ext=png) VIK_MAPS_CACHE_LAYOUT_NUM // Last enum } VikMapsCacheLayout; // OSM definition is a TMS derivative, (Global Mercator profile with Flipped Y) // http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames // http://wiki.openstreetmap.org/wiki/TMS // http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification void maps_layer_init (); void maps_layer_set_autodownload_default ( gboolean autodownload ); void maps_layer_set_cache_default ( VikMapsCacheLayout layout ); guint vik_maps_layer_get_default_map_type (); void maps_layer_register_map_source ( VikMapSource *map ); void vik_maps_layer_download_section ( VikMapsLayer *vml, VikViewport *vvp, VikCoord *ul, VikCoord *br, gdouble zoom ); guint vik_maps_layer_get_map_type(VikMapsLayer *vml); void vik_maps_layer_set_map_type(VikMapsLayer *vml, guint map_type); gchar *vik_maps_layer_get_map_label(VikMapsLayer *vml); gchar *maps_layer_default_dir (); void vik_maps_layer_download ( VikMapsLayer *vml, VikViewport *vvp, gboolean only_new ); G_END_DECLS #endif
gpl-2.0
hetter/NPLRuntime
Client/trunk/ParaEngineClient/renderer/ParaVertexBuffer.h
3023
#pragma once namespace ParaEngine { #ifdef USE_DIRECTX_RENDERER typedef IDirect3DVertexBuffer9* VertexBufferDevicePtr_type; typedef IDirect3DIndexBuffer9* IndexBufferDevicePtr_type; #elif defined(USE_OPENGL_RENDERER) typedef GLuint VertexBufferDevicePtr_type; typedef GLuint IndexBufferDevicePtr_type; #else typedef int32_t VertexBufferDevicePtr_type; typedef int32_t IndexBufferDevicePtr_type; #endif /** cross platform vertex/index buffer. * this is light weighted, use this like an int, and copy by value. */ class ParaVertexBuffer { public: ParaVertexBuffer(); ~ParaVertexBuffer(); enum EnumBufferType { BufferType_VertexBuffer = 0, BufferType_IndexBuffer, BufferType_MemoryBuffer, }; public: VertexBufferDevicePtr_type GetDevicePointer(); IndexBufferDevicePtr_type GetDevicePointerAsIndexBuffer(); char* GetMemoryPointer(); /** recreate the buffer based on the new size * @param dwFormat: only used in DirectX, ignored in openGL * @param dwUsage: only used in DirectX, ignored in openGL */ bool CreateBuffer(uint32 nBufferSize, DWORD dwFormat = 0, DWORD dwUsage = 0, D3DPOOL dwPool = D3DPOOL_MANAGED); bool CreateIndexBuffer(uint32 nBufferSize, DWORD dwFormat = 0, DWORD dwUsage = 0); bool CreateMemoryBuffer(uint32 nBufferSize, DWORD dwFormat = 0, DWORD dwUsage = 0); /** release the buffer. Please note one must manually call this function. The function will not be called when class is destroyed. */ void ReleaseBuffer(); /** lock and return a writable buffer into which one can fill the buffer. */ bool Lock(void** ppData, uint32 offsetToLock = 0, uint32 sizeToLock = 0, DWORD dwFlag = 0); /** unlock the buffer */ void Unlock(); /** get the current buffer size. */ uint32 GetBufferSize(); /** boolean: test validity */ bool IsValid() const; operator bool() const { return IsValid(); }; bool operator !() const { return !IsValid(); }; void RendererRecreated(); void UploadMemoryBuffer(const char* pBuffer, int32 nBufSize = -1); protected: union { IndexBufferDevicePtr_type m_indexBuffer; VertexBufferDevicePtr_type m_vertexBuffer; }; uint32 m_nBufferSize; // only valid between Lock and Unlock or type is BufferType_MemoryBuffer char* m_buffer; EnumBufferType m_bufferType; }; /** in OpenGL, there is no different between vertex and index buffer. in directX, vertex and index buffer has similar interface, but different interface type. so here we just wrap around ParaVertexBuffer. */ class ParaIndexBuffer : public ParaVertexBuffer { public: bool CreateBuffer(uint32 nBufferSize, DWORD dwFormat = 0, DWORD dwUsage = 0); IndexBufferDevicePtr_type GetDevicePointer(); }; /** pure memory buffer, useful for filling in another thread and then upload to a real vertex buffer in the render thread. */ class ParaMemoryBuffer : public ParaVertexBuffer { public: bool CreateBuffer(uint32 nBufferSize, DWORD dwFormat = 0, DWORD dwUsage = 0); char* GetDevicePointer(); }; }
gpl-2.0
lajus/customr
src/extra/tre/tre-compile.h
662
/* tre-compile.h: Regex compilation definitions This software is released under a BSD-style license. See the file LICENSE for details and copyright. */ #ifndef TRE_COMPILE_H #define TRE_COMPILE_H 1 typedef struct { int position; #if 0 /* [i_a] must be able to carry the full span of all [Unicode] character codes *PLUS* these 'specials': TAG, PARAMETER, BACKREF, ASSERTION and EMPTY */ tre_cint_t code_min; tre_cint_t code_max; #else int code_min; int code_max; #endif int *tags; int assertions; tre_ctype_t classt; tre_ctype_t *neg_classes; int backref; int *params; } tre_pos_and_tags_t; #endif /* TRE_COMPILE_H */ /* EOF */
gpl-2.0
epicsdeb/rtems-gdb
gdb/sparc-tdep.h
6236
/* Target-dependent code for SPARC. Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SPARC_TDEP_H #define SPARC_TDEP_H 1 struct frame_info; struct gdbarch; struct regcache; struct regset; struct trad_frame_saved_reg; /* Register offsets for the general-purpose register set. */ struct sparc_gregset { int r_psr_offset; int r_pc_offset; int r_npc_offset; int r_y_offset; int r_wim_offset; int r_tbr_offset; int r_g1_offset; int r_l0_offset; int r_y_size; }; /* SPARC architecture-specific information. */ struct gdbarch_tdep { /* Register numbers for the PN and nPC registers. The definitions for (64-bit) UltraSPARC differ from the (32-bit) SPARC definitions. */ int pc_regnum; int npc_regnum; /* Register sets. */ struct regset *gregset; size_t sizeof_gregset; struct regset *fpregset; size_t sizeof_fpregset; /* Offset of saved PC in jmp_buf. */ int jb_pc_offset; /* Size of an Procedure Linkage Table (PLT) entry, 0 if we shouldn't treat the PLT special when doing prologue analysis. */ size_t plt_entry_size; /* Alternative location for trap return. Used for single-stepping. */ CORE_ADDR (*step_trap) (struct frame_info *frame, unsigned long insn); /* ISA-specific data types. */ struct type *sparc_psr_type; struct type *sparc_fsr_type; struct type *sparc64_pstate_type; struct type *sparc64_fsr_type; struct type *sparc64_fprs_type; }; /* Register numbers of various important registers. */ enum sparc_regnum { SPARC_G0_REGNUM, /* %g0 */ SPARC_G1_REGNUM, SPARC_G2_REGNUM, SPARC_G3_REGNUM, SPARC_G4_REGNUM, SPARC_G5_REGNUM, SPARC_G6_REGNUM, SPARC_G7_REGNUM, /* %g7 */ SPARC_O0_REGNUM, /* %o0 */ SPARC_O1_REGNUM, SPARC_O2_REGNUM, SPARC_O3_REGNUM, SPARC_O4_REGNUM, SPARC_O5_REGNUM, SPARC_SP_REGNUM, /* %sp (%o6) */ SPARC_O7_REGNUM, /* %o7 */ SPARC_L0_REGNUM, /* %l0 */ SPARC_L1_REGNUM, SPARC_L2_REGNUM, SPARC_L3_REGNUM, SPARC_L4_REGNUM, SPARC_L5_REGNUM, SPARC_L6_REGNUM, SPARC_L7_REGNUM, /* %l7 */ SPARC_I0_REGNUM, /* %i0 */ SPARC_I1_REGNUM, SPARC_I2_REGNUM, SPARC_I3_REGNUM, SPARC_I4_REGNUM, SPARC_I5_REGNUM, SPARC_FP_REGNUM, /* %fp (%i6) */ SPARC_I7_REGNUM, /* %i7 */ SPARC_F0_REGNUM, /* %f0 */ SPARC_F1_REGNUM, SPARC_F31_REGNUM /* %f31 */ = SPARC_F0_REGNUM + 31 }; enum sparc32_regnum { SPARC32_Y_REGNUM /* %y */ = SPARC_F31_REGNUM + 1, SPARC32_PSR_REGNUM, /* %psr */ SPARC32_WIM_REGNUM, /* %wim */ SPARC32_TBR_REGNUM, /* %tbr */ SPARC32_PC_REGNUM, /* %pc */ SPARC32_NPC_REGNUM, /* %npc */ SPARC32_FSR_REGNUM, /* %fsr */ SPARC32_CSR_REGNUM, /* %csr */ /* Pseudo registers. */ SPARC32_D0_REGNUM, /* %d0 */ SPARC32_D30_REGNUM /* %d30 */ = SPARC32_D0_REGNUM + 15 }; struct sparc_frame_cache { /* Base address. */ CORE_ADDR base; CORE_ADDR pc; /* Do we have a frame? */ int frameless_p; /* Do we have a Structure, Union or Quad-Precision return value? */ int struct_return_p; /* Table of saved registers. */ struct trad_frame_saved_reg *saved_regs; }; /* Fetch the instruction at PC. */ extern unsigned long sparc_fetch_instruction (CORE_ADDR pc); /* Fetch StackGhost Per-Process XOR cookie. */ extern ULONGEST sparc_fetch_wcookie (struct gdbarch *gdbarch); extern CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct sparc_frame_cache *cache); extern struct sparc_frame_cache * sparc_frame_cache (struct frame_info *this_frame, void **this_cache); extern struct sparc_frame_cache * sparc32_frame_cache (struct frame_info *this_frame, void **this_cache); extern int sparc_software_single_step (struct frame_info *frame); extern void sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum); extern void sparc_collect_rwindow (const struct regcache *regcache, CORE_ADDR sp, int regnum); /* Register offsets for SunOS 4. */ extern const struct sparc_gregset sparc32_sunos4_gregset; extern void sparc32_supply_gregset (const struct sparc_gregset *gregset, struct regcache *regcache, int regnum, const void *gregs); extern void sparc32_collect_gregset (const struct sparc_gregset *gregset, const struct regcache *regcache, int regnum, void *gregs); extern void sparc32_supply_fpregset (struct regcache *regcache, int regnum, const void *fpregs); extern void sparc32_collect_fpregset (const struct regcache *regcache, int regnum, void *fpregs); /* Functions and variables exported from sparc-sol2-tdep.c. */ /* Register offsets for Solaris 2. */ extern const struct sparc_gregset sparc32_sol2_gregset; extern int sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name); extern char *sparc_sol2_static_transform_name (char *name); extern void sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); /* Functions and variables exported from sparcnbsd-tdep.c. */ /* Register offsets for NetBSD. */ extern const struct sparc_gregset sparc32nbsd_gregset; /* Return the address of a system call's alternative return address. */ extern CORE_ADDR sparcnbsd_step_trap (struct frame_info *frame, unsigned long insn); extern void sparc32nbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); extern struct trad_frame_saved_reg * sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame); #endif /* sparc-tdep.h */
gpl-2.0
wyuka/calligra
plugins/musicshape/dialogs/PartsWidget.h
1591
/* This file is part of the KDE project * Copyright (C) 2007 Marijn Kruisselbrink <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef PARTSWIDGET_H #define PARTSWIDGET_H #include <ui_PartsWidget.h> #include <QWidget> class MusicTool; class MusicShape; namespace MusicCore { class Sheet; } class PartsWidget : public QWidget { Q_OBJECT public: explicit PartsWidget(MusicTool *tool, QWidget *parent = 0); public slots: void setShape(MusicShape* shape); private slots: void partDoubleClicked(const QModelIndex & index); void selectionChanged(const QModelIndex& current, const QModelIndex& prev); void addPart(); void removePart(); void editPart(); private: Ui::PartsWidget widget; MusicTool *m_tool; MusicShape *m_shape; MusicCore::Sheet* m_sheet; }; #endif // PARTSWIDGET_H
gpl-2.0
yuvalt/xbmc
xbmc/video/windows/GUIWindowFullScreen.cpp
19632
/* * Copyright (C) 2005-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #include "threads/SystemClock.h" #include "system.h" #include "GUIWindowFullScreen.h" #include "Application.h" #include "messaging/ApplicationMessenger.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif #include "GUIInfoManager.h" #include "guilib/GUIProgressControl.h" #include "guilib/GUILabelControl.h" #include "video/dialogs/GUIDialogVideoOSD.h" #include "guilib/GUIWindowManager.h" #include "input/Key.h" #include "video/dialogs/GUIDialogFullScreenInfo.h" #include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "FileItem.h" #include "video/VideoReferenceClock.h" #include "utils/CPUInfo.h" #include "guilib/LocalizeStrings.h" #include "threads/SingleLock.h" #include "utils/StringUtils.h" #include "XBDateTime.h" #include "input/ButtonTranslator.h" #include "windowing/WindowingFactory.h" #include "cores/IPlayer.h" #include "guiinfo/GUIInfoLabels.h" #include <stdio.h> #include <algorithm> #if defined(TARGET_DARWIN) #include "linux/LinuxResourceCounter.h" #endif using namespace KODI::MESSAGING; #define BLUE_BAR 0 #define LABEL_ROW1 10 #define LABEL_ROW2 11 #define LABEL_ROW3 12 //Displays current position, visible after seek or when forced //Alt, use conditional visibility Player.DisplayAfterSeek #define LABEL_CURRENT_TIME 22 //Displays when video is rebuffering //Alt, use conditional visibility Player.IsCaching #define LABEL_BUFFERING 24 //Progressbar used for buffering status and after seeking #define CONTROL_PROGRESS 23 #if defined(TARGET_DARWIN) static CLinuxResourceCounter m_resourceCounter; #endif CGUIWindowFullScreen::CGUIWindowFullScreen(void) : CGUIWindow(WINDOW_FULLSCREEN_VIDEO, "VideoFullScreen.xml") { m_timeCodeStamp[0] = 0; m_timeCodePosition = 0; m_timeCodeShow = false; m_timeCodeTimeout = 0; m_bShowViewModeInfo = false; m_dwShowViewModeTimeout = 0; m_bShowCurrentTime = false; m_loadType = KEEP_IN_MEMORY; // audio // - language // - volume // - stream // video // - Create Bookmark (294) // - Cycle bookmarks (295) // - Clear bookmarks (296) // - jump to specific time // - slider // - av delay // subtitles // - delay // - language } CGUIWindowFullScreen::~CGUIWindowFullScreen(void) {} bool CGUIWindowFullScreen::OnAction(const CAction &action) { if (m_timeCodePosition > 0 && action.GetButtonCode()) { // check whether we have a mapping in our virtual videotimeseek "window" and have a select action CKey key(action.GetButtonCode()); CAction timeSeek = CButtonTranslator::GetInstance().GetAction(WINDOW_VIDEO_TIME_SEEK, key, false); if (timeSeek.GetID() == ACTION_SELECT_ITEM) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } } switch (action.GetID()) { case ACTION_SHOW_OSD: ToggleOSD(); return true; case ACTION_TRIGGER_OSD: TriggerOSD(); return true; case ACTION_SHOW_GUI: { // switch back to the menu g_windowManager.PreviousWindow(); return true; } break; case ACTION_PLAYER_PLAY: case ACTION_PAUSE: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } break; case ACTION_SMALL_STEP_BACK: case ACTION_STEP_BACK: case ACTION_BIG_STEP_BACK: case ACTION_CHAPTER_OR_BIG_STEP_BACK: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD); return true; } break; case ACTION_STEP_FORWARD: case ACTION_BIG_STEP_FORWARD: case ACTION_CHAPTER_OR_BIG_STEP_FORWARD: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD); return true; } break; case ACTION_SHOW_OSD_TIME: m_bShowCurrentTime = !m_bShowCurrentTime; if(!m_bShowCurrentTime) g_infoManager.SetDisplayAfterSeek(0); //Force display off g_infoManager.SetShowTime(m_bShowCurrentTime); return true; break; case ACTION_SHOW_INFO: { CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) { CFileItem item(g_application.CurrentFileItem()); pDialog->Open(); return true; } break; } case REMOTE_0: case REMOTE_1: case REMOTE_2: case REMOTE_3: case REMOTE_4: case REMOTE_5: case REMOTE_6: case REMOTE_7: case REMOTE_8: case REMOTE_9: { if (!g_application.CurrentFileItem().IsLiveTV()) { ChangetheTimeCode(action.GetID()); return true; } } break; case ACTION_ASPECT_RATIO: { // toggle the aspect ratio mode (only if the info is onscreen) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK g_renderManager.SetViewMode(++CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); #endif } m_bShowViewModeInfo = true; m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis(); } return true; break; case ACTION_SHOW_PLAYLIST: { CFileItem item(g_application.CurrentFileItem()); if (item.HasPVRChannelInfoTag()) g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); else if (item.HasVideoInfoTag()) g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST); else if (item.HasMusicInfoTag()) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } return true; break; default: break; } return CGUIWindow::OnAction(action); } void CGUIWindowFullScreen::ClearBackground() { if (g_renderManager.IsVideoLayer()) #ifdef HAS_IMXVPU g_graphicsContext.Clear((16 << 16)|(8 << 8)|16); #else g_graphicsContext.Clear(0); #endif } void CGUIWindowFullScreen::OnWindowLoaded() { CGUIWindow::OnWindowLoaded(); // override the clear colour - we must never clear fullscreen m_clearBackground = 0; CGUIProgressControl* pProgress = dynamic_cast<CGUIProgressControl*>(GetControl(CONTROL_PROGRESS)); if(pProgress) { if( pProgress->GetInfo() == 0 || !pProgress->HasVisibleCondition()) { pProgress->SetInfo(PLAYER_PROGRESS); pProgress->SetVisibleCondition("player.displayafterseek"); pProgress->SetVisible(true); } } CGUILabelControl* pLabel = dynamic_cast<CGUILabelControl*>(GetControl(LABEL_BUFFERING)); if(pLabel && !pLabel->HasVisibleCondition()) { pLabel->SetVisibleCondition("player.caching"); pLabel->SetVisible(true); } pLabel = dynamic_cast<CGUILabelControl*>(GetControl(LABEL_CURRENT_TIME)); if(pLabel && !pLabel->HasVisibleCondition()) { pLabel->SetVisibleCondition("player.displayafterseek"); pLabel->SetVisible(true); pLabel->SetLabel("$INFO(VIDEOPLAYER.TIME) / $INFO(VIDEOPLAYER.DURATION)"); } m_showCodec.Parse("player.showcodec", GetID()); } bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { // check whether we've come back here from a window during which time we've actually // stopped playing videos if (message.GetParam1() == WINDOW_INVALID && !g_application.m_pPlayer->IsPlayingVideo()) { // why are we here if nothing is playing??? g_windowManager.PreviousWindow(); return true; } g_infoManager.SetShowInfo(false); g_infoManager.SetShowCodec(false); m_bShowCurrentTime = false; g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off. // switch resolution g_graphicsContext.SetFullScreenVideo(true); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(); #endif // now call the base class to load our windows CGUIWindow::OnMessage(message); m_bShowViewModeInfo = false; return true; } case GUI_MSG_WINDOW_DEINIT: { // close all active modal dialogs g_windowManager.CloseInternalModalDialogs(true); CGUIWindow::OnMessage(message); CSettings::Get().Save(); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); lock.Leave(); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(); g_renderManager.FrameFinish(); #endif return true; } case GUI_MSG_SETFOCUS: case GUI_MSG_LOSTFOCUS: if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true; break; } return CGUIWindow::OnMessage(message); } EVENT_RESULT CGUIWindowFullScreen::OnMouseEvent(const CPoint &point, const CMouseEvent &event) { if (event.m_id == ACTION_MOUSE_RIGHT_CLICK) { // no control found to absorb this click - go back to GUI OnAction(CAction(ACTION_SHOW_GUI)); return EVENT_RESULT_HANDLED; } if (event.m_id == ACTION_MOUSE_WHEEL_UP) { return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_FORWARD, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED; } if (event.m_id == ACTION_MOUSE_WHEEL_DOWN) { return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_BACK, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED; } if (event.m_id >= ACTION_GESTURE_NOTIFY && event.m_id <= ACTION_GESTURE_END) // gestures return EVENT_RESULT_UNHANDLED; return EVENT_RESULT_UNHANDLED; } void CGUIWindowFullScreen::FrameMove() { if (g_application.m_pPlayer->GetPlaySpeed() != 1) g_infoManager.SetDisplayAfterSeek(); if (m_bShowCurrentTime) g_infoManager.SetDisplayAfterSeek(); if (!g_application.m_pPlayer->HasPlayer()) return; if( g_application.m_pPlayer->IsCaching() ) { g_infoManager.SetDisplayAfterSeek(0); //Make sure these stuff aren't visible now } //------------------------ m_showCodec.Update(); if (m_showCodec) { // show audio codec info std::string strAudio, strVideo, strGeneral; g_application.m_pPlayer->GetAudioInfo(strAudio); { CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); msg.SetLabel(strAudio); OnMessage(msg); } // show video codec info g_application.m_pPlayer->GetVideoInfo(strVideo); { CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2); msg.SetLabel(strVideo); OnMessage(msg); } // show general info g_application.m_pPlayer->GetGeneralInfo(strGeneral); { std::string strGeneralFPS; #if defined(TARGET_DARWIN) // We show CPU usage for the entire process, as it's arguably more useful. double dCPU = m_resourceCounter.GetCPUUsage(); std::string strCores; strCores = StringUtils::Format("cpu:%.0f%%", dCPU); #else std::string strCores = g_cpuInfo.GetCoresUsageString(); #endif int missedvblanks; double refreshrate; double clockspeed; std::string strClock; if (g_VideoReferenceClock.GetClockInfo(missedvblanks, clockspeed, refreshrate)) strClock = StringUtils::Format("S( refresh:%.3f missed:%i speed:%+.3f%% %s )" , refreshrate , missedvblanks , clockspeed - 100.0 , g_renderManager.GetVSyncState().c_str()); strGeneralFPS = StringUtils::Format("%s\nW( %s )\n%s" , strGeneral.c_str() , strCores.c_str(), strClock.c_str() ); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3); msg.SetLabel(strGeneralFPS); OnMessage(msg); } } //---------------------- // ViewMode Information //---------------------- if (m_bShowViewModeInfo && XbmcThreads::SystemClockMillis() - m_dwShowViewModeTimeout > 2500) { m_bShowViewModeInfo = false; } if (m_bShowViewModeInfo) { RESOLUTION_INFO res = g_graphicsContext.GetResInfo(); { // get the "View Mode" string std::string strTitle = g_localizeStrings.Get(629); std::string strMode = g_localizeStrings.Get(630 + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); std::string strInfo = StringUtils::Format("%s : %s", strTitle.c_str(), strMode.c_str()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); msg.SetLabel(strInfo); OnMessage(msg); } // show sizing information SPlayerVideoStreamInfo info; g_application.m_pPlayer->GetVideoStreamInfo(info); { // Splitres scaling factor float xscale = (float)res.iScreenWidth / (float)res.iWidth; float yscale = (float)res.iScreenHeight / (float)res.iHeight; std::string strSizing = StringUtils::Format(g_localizeStrings.Get(245).c_str(), (int)info.SrcRect.Width(), (int)info.SrcRect.Height(), (int)(info.DestRect.Width() * xscale), (int)(info.DestRect.Height() * yscale), CDisplaySettings::Get().GetZoomAmount(), info.videoAspectRatio*CDisplaySettings::Get().GetPixelRatio(), CDisplaySettings::Get().GetPixelRatio(), CDisplaySettings::Get().GetVerticalShift()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2); msg.SetLabel(strSizing); OnMessage(msg); } // show resolution information { std::string strStatus; if (g_Windowing.IsFullScreen()) strStatus = StringUtils::Format("%s %ix%i@%.2fHz - %s", g_localizeStrings.Get(13287).c_str(), res.iScreenWidth, res.iScreenHeight, res.fRefreshRate, g_localizeStrings.Get(244).c_str()); else strStatus = StringUtils::Format("%s %ix%i - %s", g_localizeStrings.Get(13287).c_str(), res.iScreenWidth, res.iScreenHeight, g_localizeStrings.Get(242).c_str()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3); msg.SetLabel(strStatus); OnMessage(msg); } } if (m_timeCodeShow && m_timeCodePosition != 0) { if ( (XbmcThreads::SystemClockMillis() - m_timeCodeTimeout) >= 2500) { m_timeCodeShow = false; m_timeCodePosition = 0; } std::string strDispTime = "00:00:00"; CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); for (int pos = 7, i = m_timeCodePosition; pos >= 0 && i > 0; pos--) { if (strDispTime[pos] != ':') { i -= 1; strDispTime[pos] = (char)m_timeCodeStamp[i] + '0'; } } strDispTime += "/" + g_infoManager.GetDuration(TIME_FORMAT_HH_MM_SS) + " [" + g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS) + "]"; // duration [ time ] msg.SetLabel(strDispTime); OnMessage(msg); } if (m_showCodec || m_bShowViewModeInfo) { SET_CONTROL_VISIBLE(LABEL_ROW1); SET_CONTROL_VISIBLE(LABEL_ROW2); SET_CONTROL_VISIBLE(LABEL_ROW3); SET_CONTROL_VISIBLE(BLUE_BAR); } else if (m_timeCodeShow) { SET_CONTROL_VISIBLE(LABEL_ROW1); SET_CONTROL_HIDDEN(LABEL_ROW2); SET_CONTROL_HIDDEN(LABEL_ROW3); SET_CONTROL_VISIBLE(BLUE_BAR); } else { SET_CONTROL_HIDDEN(LABEL_ROW1); SET_CONTROL_HIDDEN(LABEL_ROW2); SET_CONTROL_HIDDEN(LABEL_ROW3); SET_CONTROL_HIDDEN(BLUE_BAR); } g_renderManager.FrameMove(); } void CGUIWindowFullScreen::Process(unsigned int currentTime, CDirtyRegionList &dirtyregion) { if (g_renderManager.IsGuiLayer()) MarkDirtyRegion(); CGUIWindow::Process(currentTime, dirtyregion); // TODO: This isn't quite optimal - ideally we'd only be dirtying up the actual video render rect // which is probably the job of the renderer as it can more easily track resizing etc. m_renderRegion.SetRect(0, 0, (float)g_graphicsContext.GetWidth(), (float)g_graphicsContext.GetHeight()); } void CGUIWindowFullScreen::Render() { g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetVideoResolution(), false); g_renderManager.Render(true, 0, 255); g_graphicsContext.SetRenderingResolution(m_coordsRes, m_needsScaling); CGUIWindow::Render(); } void CGUIWindowFullScreen::RenderEx() { CGUIWindow::RenderEx(); g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetVideoResolution(), false); #ifdef HAS_VIDEO_PLAYBACK g_renderManager.Render(false, 0, 255, false); g_renderManager.FrameFinish(); #endif } void CGUIWindowFullScreen::ChangetheTimeCode(int remote) { if (remote >= REMOTE_0 && remote <= REMOTE_9) { m_timeCodeShow = true; m_timeCodeTimeout = XbmcThreads::SystemClockMillis(); if (m_timeCodePosition < 6) m_timeCodeStamp[m_timeCodePosition++] = remote - REMOTE_0; else { // rotate around for (int i = 0; i < 5; i++) m_timeCodeStamp[i] = m_timeCodeStamp[i+1]; m_timeCodeStamp[5] = remote - REMOTE_0; } } } void CGUIWindowFullScreen::SeekToTimeCodeStamp(SEEK_TYPE type, SEEK_DIRECTION direction) { double total = GetTimeCodeStamp(); if (type == SEEK_RELATIVE) total = g_application.GetTime() + (((direction == SEEK_FORWARD) ? 1 : -1) * total); if (total < g_application.GetTotalTime()) g_application.SeekTime(total); m_timeCodePosition = 0; m_timeCodeShow = false; } double CGUIWindowFullScreen::GetTimeCodeStamp() { // Convert the timestamp into an integer int tot = 0; for (int i = 0; i < m_timeCodePosition; i++) tot = tot * 10 + m_timeCodeStamp[i]; // Interpret result as HHMMSS int s = tot % 100; tot /= 100; int m = tot % 100; tot /= 100; int h = tot % 100; return h * 3600 + m * 60 + s; } void CGUIWindowFullScreen::SeekChapter(int iChapter) { g_application.m_pPlayer->SeekChapter(iChapter); // Make sure gui items are visible. g_infoManager.SetDisplayAfterSeek(); } void CGUIWindowFullScreen::ToggleOSD() { CGUIDialogVideoOSD *pOSD = (CGUIDialogVideoOSD *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pOSD) { if (pOSD->IsDialogRunning()) pOSD->Close(); else pOSD->Open(); } MarkDirtyRegion(); } void CGUIWindowFullScreen::TriggerOSD() { CGUIDialogVideoOSD *pOSD = (CGUIDialogVideoOSD *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pOSD && !pOSD->IsDialogRunning()) { pOSD->SetAutoClose(3000); pOSD->Open(); } }
gpl-2.0
kkvskkkk/NPLRuntime
Client/trunk/ParaEngineClient/jabber/ParaRingBuffer.h
8867
#pragma once #include <boost/circular_buffer.hpp> #include <boost/thread.hpp> #include "util/mutex.h" #include <queue> namespace ParaEngine { /** * CParaRingBuffer is normally used in a producer-consumer mode when producer threads produce items and store them in the container and consumer threads remove these items and process them. * The bounded buffer has to guarantee that producers do not insert items into the container when the container is full, * that consumers do not try to remove items when the container is empty, and that each produced item is consumed by exactly one consumer. * @note: most functions are thread-safe, a light mutex is used in place. */ template <class T> class CParaRingBuffer { public: typedef boost::circular_buffer<T> container_type; typedef typename container_type::size_type size_type; typedef typename container_type::value_type value_type; enum BufferStatus { BufferOverFlow = 0, BufferFull = 1, BufferNormal = 2, BufferEmpty = 3, BufferFirst = 3, }; explicit CParaRingBuffer(size_type capacity) : m_container(capacity) {} public: /** try push to back of the queue. * @param item: the object to add * @return: return buffer status after the item is added. If BufferOverFlow, it means adding is failed; if BufferFirst, this is the first item added. * if BufferFull, the buffer is full after inserting the new one, in other cases, BufferNormal is returned. @note: thread safe */ BufferStatus try_push(const value_type& item) { Lock lock(m_mutex); if(m_container.full()) { return BufferOverFlow; } else { BufferStatus bufferStatus = m_container.empty() ? BufferFirst : BufferNormal; m_container.push_back(item); return m_container.full() ? BufferFull : bufferStatus; } } /** * same as try_push, except that it also returns pointer to the front object. * @param ppFrontItem there is no guarantee that the front object pointer is valid after return. * please ensure no other thread is popping items when you are accessing the front item. */ BufferStatus try_push_get_front(const value_type& item, value_type** ppFrontItem) { Lock lock(m_mutex); if(m_container.full()) { return BufferOverFlow; } else { BufferStatus bufferStatus = m_container.empty() ? BufferFirst : BufferNormal; m_container.push_back(item); *ppFrontItem = &(m_container.front()); return m_container.full() ? BufferFull : bufferStatus; } } /** push to the front of the queue. this is usually for high priority messages. If queue is full, the last one will be removed. * @param item: the object to add * @note: thread safe */ void push_front(const value_type& item) { Lock lock(m_mutex); m_container.push_front(item); } /** try push to back of the queue. * @return: return buffer status after the item is added. If BufferOverFlow, it means adding is failed; if BufferFirst, this is the first item added. * if BufferFull, the buffer is full after inserting the new one, in other cases, BufferNormal is returned. * @note: thread safe */ BufferStatus try_push_array(const value_type* pItems, int nCount) { Lock lock(m_mutex); if(m_container.capacity()<nCount) { return BufferFull; } else { BufferStatus bufferStatus = m_container.empty() ? BufferFirst : BufferNormal; for (int i=0; i<nCount;++i) { m_container.push_back(*(pItems+i)); } return m_container.full() ? BufferFull : bufferStatus; } } /** * @return: get a pointer to the front object if exist, or NULL. * @note this is thread safe, however the returned object may be invalid if it is pop when you use it. */ value_type * try_front() { Lock lock(m_mutex); return m_container.empty() ? NULL : &(m_container.front()); } /** try pop from the front of the queue. * @param ppValueFront: get a pointer to the front object after the operation. @return: return true if succeed, false if queue is empty. @note: thread safe */ bool try_pop(value_type& item) { Lock lock(m_mutex); if(m_container.empty()) { return false; } else { item = m_container.front(); m_container.pop_front(); return true; } } /** try pop from the front of the queue and return the front object after the pop. * @param ppValueFront: get a pointer to the front object after the operation. @return: return true if succeed, false if queue is empty. @note: thread safe */ bool try_next(value_type** ppItem) { Lock lock(m_mutex); if(m_container.empty()) { return false; } else { m_container.pop_front(); if(ppItem!=0 && !m_container.empty()) { *ppItem = &(m_container.front()); } return true; } } size_type size() const { Lock lock(m_mutex); return m_container.size(); }; bool empty() const { Lock lock(m_mutex); return m_container.empty(); }; bool full() const { Lock lock(m_mutex); return m_container.full(); }; public: container_type m_container; mutex m_mutex; }; /** * it implements a producer/consumer(s) queue design pattern. * One or more producers push(data) to the queue, and multiple consumers wait_and_pop(data) from the queue. * Internally a fixed-sized ring buffer is used. if buffer is full, older messages are dropped without notification. * all functions are thread-safe. */ template<typename Data> class concurrent_queue { protected: typedef boost::circular_buffer<Data> container_type; typedef typename container_type::size_type size_type; typedef typename container_type::value_type value_type; mutable boost::mutex m_mutex; boost::condition_variable m_condition_variable; /** whether to use event to inform consumer when new data items are added to the queue. Default to true. * if one uses polling,such as in the main game thread, there is no need to enable use_event. * when enabled, there is a performance hit. */ bool m_use_event; container_type m_container; public: enum BufferStatus { BufferOverFlow = 0, BufferFull = 1, BufferNormal = 2, BufferEmpty = 3, BufferFirst = 3, }; explicit concurrent_queue(size_type capacity) : m_container(capacity),m_use_event(true) {} /** whether to use event to inform consumer when new data items are added to the queue. Default to true. * if one uses polling,such as in the main game thread, there is no need to enable use_event. * when enabled, there is a performance hit. */ void SetUseEvent(bool bUseEvent) { boost::mutex::scoped_lock lock(m_mutex); m_use_event = bUseEvent; } /** try push to back of the queue. * @param item: the object to add * @return: return buffer status after the item is added. If BufferOverFlow, it means adding is failed; if BufferFirst, this is the first item added. * if BufferFull, the buffer is full after inserting the new one, in other cases, BufferNormal is returned. @note: thread safe */ BufferStatus try_push(value_type& item) { boost::mutex::scoped_lock lock(m_mutex); BufferStatus bufferStatus = m_container.empty() ? BufferFirst : BufferNormal; if(m_container.full()) { bufferStatus = BufferOverFlow; } else { m_container.push_back(item); bufferStatus = m_container.full() ? BufferFull : bufferStatus; } lock.unlock(); if(m_use_event) m_condition_variable.notify_one(); return bufferStatus; } /** add a data item to the back of the queue. if buffer is full, the more recent messages remain in the queue. */ void push(value_type& data) { boost::mutex::scoped_lock lock(m_mutex); m_container.push_back(data); lock.unlock(); if(m_use_event) m_condition_variable.notify_one(); } /** add a data item to the front of the queue. This ensures that message is always added even queue is full, where the recent message are dropped. This function is only used to insert high priority command, otherwise use push() function instead. */ void push_front(value_type & data) { boost::mutex::scoped_lock lock(m_mutex); m_container.push_front(data); lock.unlock(); m_condition_variable.notify_one(); } bool empty() const { boost::mutex::scoped_lock lock(m_mutex); return m_container.empty(); } bool try_pop(value_type& popped_value) { boost::mutex::scoped_lock lock(m_mutex); if(m_container.empty()) { return false; } popped_value=m_container.front(); m_container.pop_front(); return true; } void wait_and_pop(value_type& popped_value) { boost::mutex::scoped_lock lock(m_mutex); while(m_container.empty()) { m_condition_variable.wait(lock); } popped_value=m_container.front(); m_container.pop_front(); } }; }
gpl-2.0
hamzasheikh/Seagull
seagull/trunk/src/generator-model/C_ProtocolControl.cpp
14839
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * (c)Copyright 2006 Hewlett-Packard Development Company, LP. * */ #include "C_ProtocolControl.hpp" #include "Utils.hpp" #include "GeneratorTrace.hpp" #include "GeneratorError.h" #include "C_ProtocolBinary.hpp" #include "C_ProtocolExternal.hpp" #include "C_ProtocolBinaryBodyNotInterpreted.hpp" #include "C_ProtocolBinarySeparator.hpp" #include "C_ProtocolText.hpp" #include "C_ProtocolTlv.hpp" #define XML_PROTOCOL_SECTION (char*)"protocol" #define XML_PROTOCOL_NAME (char*)"name" #define XML_PROTOCOL_TYPE (char*)"type" C_ProtocolControl::C_ProtocolControl(C_TransportControl *P_transport_control) { GEN_DEBUG(1, "C_ProtocolControl::C_ProtocolControl() start"); NEW_VAR(m_name_map, T_ProtocolNameMap()); m_name_map->clear() ; m_protocol_table = NULL ; m_protocol_name_table = NULL ; m_protocol_table_size = 0 ; NEW_VAR(m_id_gen, C_IdGenerator()); m_transport_control = P_transport_control ; GEN_DEBUG(1, "C_ProtocolControl::C_ProtocolControl() end"); } C_ProtocolControl::~C_ProtocolControl() { int L_i ; GEN_DEBUG(1, "C_ProtocolControl::~C_ProtocolControl() start"); if (!m_name_map->empty()) { m_name_map->erase(m_name_map->begin(), m_name_map->end()); } DELETE_VAR(m_name_map); if (m_protocol_table_size != 0) { for (L_i = 0 ; L_i < m_protocol_table_size; L_i++) { DELETE_VAR(m_protocol_table[L_i]); } FREE_TABLE(m_protocol_table); FREE_TABLE(m_protocol_name_table); m_protocol_table_size = 0 ; } DELETE_VAR(m_id_gen) ; m_transport_control = NULL ; GEN_DEBUG(1, "C_ProtocolControl::~C_ProtocolControl() end"); } char* C_ProtocolControl::get_protocol_name(C_XmlData *P_data) { return (P_data->find_value(XML_PROTOCOL_NAME)) ; } char* C_ProtocolControl::get_protocol_type(C_XmlData *P_data) { return (P_data->find_value(XML_PROTOCOL_TYPE)) ; } bool C_ProtocolControl::fromXml (C_XmlData *P_data, T_pConfigValueList P_config_value_list, bool P_display_protocol_stats) { bool L_ret = true ; T_pXmlData_List L_subList ; T_XmlData_List::iterator L_subListIt ; C_XmlData *L_data ; char *L_protocol_name, *L_protocol_type ; int L_protocol_id ; T_ProtocolInstList L_protocol_inst_list ; T_pProtocolInstanceInfo L_protocol_info ; T_ProtocolInstList::iterator L_it ; GEN_DEBUG(1, "C_ProtocolControl::fromXml() start"); if (P_data != NULL) { if ((L_subList = P_data->get_sub_data()) != NULL) { for (L_subListIt = L_subList->begin() ; L_subListIt != L_subList->end() ; L_subListIt++) { L_data = *L_subListIt ; if (L_data != NULL) { if (strcmp(L_data->get_name(), XML_PROTOCOL_SECTION) == 0) { // protocol section definition found L_protocol_name = get_protocol_name (L_data) ; // check protocol type for creation L_protocol_type = get_protocol_type (L_data) ; // check name/type presence if (L_protocol_name == NULL) { GEN_ERROR(E_GEN_FATAL_ERROR, "name mandatory for section " << XML_PROTOCOL_SECTION); L_ret = false ; break ; } if (L_protocol_type == NULL) { GEN_ERROR(E_GEN_FATAL_ERROR, "type mandatory for section " << XML_PROTOCOL_SECTION); L_ret = false ; break ; } // check protocol name unicity if (m_name_map->find(T_ProtocolNameMap::key_type(L_protocol_name)) != m_name_map->end()) { GEN_ERROR(E_GEN_FATAL_ERROR, XML_PROTOCOL_SECTION << " with name [" << L_protocol_name << "] already defined"); L_ret = false ; break ; } // check protocol type or sub type if (strcmp(L_protocol_type, "binary") == 0) { // create protocol instance C_ProtocolBinary *L_protocol_instance = NULL ; T_ConstructorResult L_res ; NEW_VAR(L_protocol_instance, C_ProtocolBinary()); L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ; if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { // store new instance if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else if (strcmp(L_protocol_type, "binary-tlv") == 0) { // create protocol instance C_ProtocolTlv *L_protocol_instance = NULL ; T_ConstructorResult L_res ; NEW_VAR(L_protocol_instance, C_ProtocolTlv()); L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ; if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { // store new instance if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else if (strcmp(L_protocol_type, "binary-body-not-interpreted") == 0) { // create protocol instance C_ProtocolBinaryBodyNotInterpreted *L_protocol_instance = NULL ; T_ConstructorResult L_res ; NEW_VAR(L_protocol_instance, C_ProtocolBinaryBodyNotInterpreted()); L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ; if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { // store new instance if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else if (strcmp(L_protocol_type, "binary-separator") == 0) { // create protocol instance C_ProtocolBinarySeparator *L_protocol_instance = NULL ; T_ConstructorResult L_res ; NEW_VAR(L_protocol_instance, C_ProtocolBinarySeparator()); L_protocol_instance ->construction_data(L_data, &L_protocol_name, &L_res) ; if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { // store new instance if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else if (strcmp(L_protocol_type, "external-library") == 0) { C_ProtocolExternal *L_protocol_instance = NULL ; T_ConstructorResult L_res = E_CONSTRUCTOR_OK ; NEW_VAR(L_protocol_instance, C_ProtocolExternal(m_transport_control, L_data, &L_protocol_name, P_config_value_list, &L_res)); if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } // store new instance L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else if (strcmp(L_protocol_type, "text") == 0) { C_ProtocolText *L_protocol_instance = NULL ; T_ConstructorResult L_res = E_CONSTRUCTOR_OK ; NEW_VAR(L_protocol_instance, C_ProtocolText()); L_protocol_instance->analyze_data(L_data, &L_protocol_name, P_config_value_list, &L_res); if (L_res != E_CONSTRUCTOR_OK) { GEN_ERROR(E_GEN_FATAL_ERROR, "Error found in protocol definition"); DELETE_VAR(L_protocol_instance); L_ret = false ; break ; } else { if (P_display_protocol_stats == true) { C_ProtocolStats *L_protocol_stats ; NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance)); L_protocol_instance->set_stats(L_protocol_stats); } // store new instance L_protocol_id = m_id_gen->new_id() ; ALLOC_VAR(L_protocol_info, T_pProtocolInstanceInfo, sizeof(T_ProtocolInstanceInfo)); L_protocol_info->m_instance = L_protocol_instance ; L_protocol_info->m_id = L_protocol_id ; L_protocol_info->m_name = L_protocol_name ; L_protocol_inst_list.push_back(L_protocol_info); m_name_map ->insert(T_ProtocolNameMap::value_type(L_protocol_name, L_protocol_id)) ; } } else { GEN_ERROR(E_GEN_FATAL_ERROR, XML_PROTOCOL_SECTION << " [" << L_protocol_name << "] with type [" << L_protocol_type << "] unsupported"); L_ret = false ; } } } } if (L_ret != false) { if (!L_protocol_inst_list.empty()) { m_protocol_table_size = L_protocol_inst_list.size() ; ALLOC_TABLE(m_protocol_table, T_pC_ProtocolFrame*, sizeof(T_pC_ProtocolFrame), m_protocol_table_size) ; ALLOC_TABLE(m_protocol_name_table, char**, sizeof(char*), m_protocol_table_size) ; for (L_it = L_protocol_inst_list.begin(); L_it != L_protocol_inst_list.end() ; L_it++) { L_protocol_info = *L_it ; m_protocol_table[L_protocol_info->m_id] = L_protocol_info->m_instance ; m_protocol_name_table[L_protocol_info->m_id] = L_protocol_info->m_name ; } } else { GEN_ERROR(E_GEN_FATAL_ERROR, "No protocol definition found"); L_ret = false ; } } // if L_ret != false if (!L_protocol_inst_list.empty()) { for (L_it = L_protocol_inst_list.begin(); L_it != L_protocol_inst_list.end() ; L_it++) { FREE_VAR(*L_it); } L_protocol_inst_list.erase(L_protocol_inst_list.begin(), L_protocol_inst_list.end()); } } } GEN_DEBUG(1, "C_ProtocolControl::fromXml() end ret=" << L_ret); return (L_ret); } C_ProtocolFrame* C_ProtocolControl::get_protocol (char *P_name) { C_ProtocolFrame *L_ret = NULL ; int L_id ; L_id = get_protocol_id (P_name) ; if (L_id != ERROR_PROTOCOL_UNKNOWN) { L_ret = m_protocol_table[L_id] ; } return (L_ret) ; } C_ProtocolFrame* C_ProtocolControl::get_protocol (int P_id) { C_ProtocolFrame *L_ret = NULL ; if ((P_id < m_protocol_table_size) && (P_id >= 0)) { L_ret = m_protocol_table[P_id] ; } return (L_ret); } int C_ProtocolControl::get_protocol_id (char *P_name) { int L_ret = ERROR_PROTOCOL_UNKNOWN ; T_ProtocolNameMap::iterator L_it ; L_it = m_name_map->find(T_ProtocolNameMap::key_type(P_name)) ; if (L_it != m_name_map->end()) { L_ret = L_it->second ; } return (L_ret) ; } int C_ProtocolControl::get_nb_protocol () { return (m_protocol_table_size); } char* C_ProtocolControl::get_protocol_name (int P_id) { char *L_ret = NULL ; if ((P_id < m_protocol_table_size) && (P_id >= 0)) { L_ret = m_protocol_name_table[P_id] ; } return (L_ret); }
gpl-2.0
SalvationDevelopment/Salvation-Scripts-TCG
c34358408.lua
1255
--儀式魔人プレサイダー function c34358408.initial_effect(c) --ritual material local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EXTRA_RITUAL_MATERIAL) e1:SetValue(1) c:RegisterEffect(e1) --become material local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetCode(EVENT_BE_MATERIAL) e2:SetCondition(c34358408.condition) e2:SetOperation(c34358408.operation) c:RegisterEffect(e2) end function c34358408.condition(e,tp,eg,ep,ev,re,r,rp) return r==REASON_RITUAL end function c34358408.operation(e,tp,eg,ep,ev,re,r,rp) local rc=eg:GetFirst() while rc do if rc:GetFlagEffect(34358408)==0 then --draw local e1=Effect.CreateEffect(e:GetHandler()) e1:SetDescription(aux.Stringid(34358408,0)) e1:SetProperty(EFFECT_FLAG_CLIENT_HINT) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_BATTLE_DESTROYING) e1:SetOperation(c34358408.drawop) e1:SetReset(RESET_EVENT+0x1fe0000) rc:RegisterEffect(e1,true) rc:RegisterFlagEffect(34358408,RESET_EVENT+0x1fe0000,0,1) end rc=eg:GetNext() end end function c34358408.drawop(e,tp,eg,ep,ev,re,r,rp) Duel.Draw(tp,1,REASON_EFFECT) end
gpl-2.0
palomagc/MovieChatter
src/icaro/infraestructura/entidadesBasicas/descEntidadesOrganizacion/jaxb/ObjectFactory.java
6481
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2012.07.04 at 04:19:28 PM CEST // package icaro.infraestructura.entidadesBasicas.descEntidadesOrganizacion.jaxb; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the icaro.aplicaciones.descripcionorganizaciones package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { private final static QName _DescOrganizacion_QNAME = new QName("urn:icaro:aplicaciones:descripcionOrganizaciones", "DescOrganizacion"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: icaro.aplicaciones.descripcionorganizaciones * */ public ObjectFactory() { } /** * Create an instance of {@link RecursosAplicacion } * */ public RecursosAplicacion createRecursosAplicacion() { return new RecursosAplicacion(); } /** * Create an instance of {@link InstanciaGestor } * */ public InstanciaGestor createInstanciaGestor() { return new InstanciaGestor(); } /** * Create an instance of {@link ListaPropiedades } * */ public ListaPropiedades createListaPropiedades() { return new ListaPropiedades(); } /** * Create an instance of {@link Nodo } * */ public Nodo createNodo() { return new Nodo(); } /** * Create an instance of {@link PropiedadesGlobales } * */ public PropiedadesGlobales createPropiedadesGlobales() { return new PropiedadesGlobales(); } /** * Create an instance of {@link DescripcionComponentes } * */ public DescripcionComponentes createDescripcionComponentes() { return new DescripcionComponentes(); } /** * Create an instance of {@link AgentesAplicacion } * */ public AgentesAplicacion createAgentesAplicacion() { return new AgentesAplicacion(); } /** * Create an instance of {@link ListaNodosEjecucion } * */ public ListaNodosEjecucion createListaNodosEjecucion() { return new ListaNodosEjecucion(); } /** * Create an instance of {@link DescComportamientoAgentesAplicacion } * */ public DescComportamientoAgentesAplicacion createDescComportamientoAgentesAplicacion() { return new DescComportamientoAgentesAplicacion(); } /** * Create an instance of {@link DescInstancias } * */ public DescInstancias createDescInstancias() { return new DescInstancias(); } /** * Create an instance of {@link DescRecursosAplicacion } * */ public DescRecursosAplicacion createDescRecursosAplicacion() { return new DescRecursosAplicacion(); } /** * Create an instance of {@link DescComportamientoGestores } * */ public DescComportamientoGestores createDescComportamientoGestores() { return new DescComportamientoGestores(); } /** * Create an instance of {@link Propiedad } * */ public Propiedad createPropiedad() { return new Propiedad(); } /** * Create an instance of {@link Gestores } * */ public Gestores createGestores() { return new Gestores(); } /** * Create an instance of {@link DescComportamientoAgentes } * */ public DescComportamientoAgentes createDescComportamientoAgentes() { return new DescComportamientoAgentes(); } /** * Create an instance of {@link ComponentesGestionados } * */ public ComponentesGestionados createComponentesGestionados() { return new ComponentesGestionados(); } /** * Create an instance of {@link DescRecursoAplicacion } * */ public DescRecursoAplicacion createDescRecursoAplicacion() { return new DescRecursoAplicacion(); } /** * Create an instance of {@link Instancia } * */ public Instancia createInstancia() { return new Instancia(); } /** * Create an instance of {@link DescComportamientoAgente } * */ public DescComportamientoAgente createDescComportamientoAgente() { return new DescComportamientoAgente(); } /** * Create an instance of {@link ComponenteGestionado } * */ public ComponenteGestionado createComponenteGestionado() { return new ComponenteGestionado(); } /** * Create an instance of {@link DescComportamientoAgenteReactivo } * */ public DescComportamientoAgenteReactivo createDescComportamientoAgenteReactivo() { return new DescComportamientoAgenteReactivo(); } /** * Create an instance of {@link DescOrganizacion } * */ public DescOrganizacion createDescOrganizacion() { return new DescOrganizacion(); } /** * Create an instance of {@link DescComportamientoAgenteCognitivo } * */ public DescComportamientoAgenteCognitivo createDescComportamientoAgenteCognitivo() { return new DescComportamientoAgenteCognitivo(); } /** * Create an instance of {@link JAXBElement }{@code <}{@link DescOrganizacion }{@code >}} * */ @XmlElementDecl(namespace = "urn:icaro:aplicaciones:descripcionOrganizaciones", name = "DescOrganizacion") public JAXBElement<DescOrganizacion> createDescOrganizacion(DescOrganizacion value) { return new JAXBElement<DescOrganizacion>(_DescOrganizacion_QNAME, DescOrganizacion.class, null, value); } }
gpl-2.0
Chilledheart/glibc
sysdeps/nacl/rmdir.c
1036
/* Remove a directory. NaCl version. Copyright (C) 2015-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <nacl-interfaces.h> /* Remove the directory PATH. */ int __rmdir (const char *path) { return NACL_CALL (__nacl_irt_dev_filename.rmdir (path), 0); } weak_alias (__rmdir, rmdir)
gpl-2.0
NamelessRom/android_kernel_samsung_latona
drivers/usb/host/ehci-hub.c
37701
/* * Copyright (C) 2001-2004 by David Brownell * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* this file is part of ehci-hcd.c */ /*-------------------------------------------------------------------------*/ /* * EHCI Root Hub ... the nonsharable stuff * * Registers don't need cpu_to_le32, that happens transparently */ /*-------------------------------------------------------------------------*/ #include <linux/usb/otg.h> #include <linux/gpio.h> #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) #ifdef CONFIG_PM static int ehci_hub_control( struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength ); /* After a power loss, ports that were owned by the companion must be * reset so that the companion can still own them. */ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) { u32 __iomem *reg; u32 status; int port; __le32 buf; struct usb_hcd *hcd = ehci_to_hcd(ehci); if (!ehci->owned_ports) return; /* Give the connections some time to appear */ msleep(20); port = HCS_N_PORTS(ehci->hcs_params); while (port--) { if (test_bit(port, &ehci->owned_ports)) { reg = &ehci->regs->port_status[port]; status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; /* Port already owned by companion? */ if (status & PORT_OWNER) clear_bit(port, &ehci->owned_ports); else if (test_bit(port, &ehci->companion_ports)) ehci_writel(ehci, status & ~PORT_PE, reg); else ehci_hub_control(hcd, SetPortFeature, USB_PORT_FEAT_RESET, port + 1, NULL, 0); } } if (!ehci->owned_ports) return; msleep(90); /* Wait for resets to complete */ port = HCS_N_PORTS(ehci->hcs_params); while (port--) { if (test_bit(port, &ehci->owned_ports)) { ehci_hub_control(hcd, GetPortStatus, 0, port + 1, (char *) &buf, sizeof(buf)); /* The companion should now own the port, * but if something went wrong the port must not * remain enabled. */ reg = &ehci->regs->port_status[port]; status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; if (status & PORT_OWNER) ehci_writel(ehci, status | PORT_CSC, reg); else { ehci_dbg(ehci, "failed handover port %d: %x\n", port + 1, status); ehci_writel(ehci, status & ~PORT_PE, reg); } } } ehci->owned_ports = 0; } static int ehci_port_change(struct ehci_hcd *ehci) { int i = HCS_N_PORTS(ehci->hcs_params); /* First check if the controller indicates a change event */ if (ehci_readl(ehci, &ehci->regs->status) & STS_PCD) return 1; /* * Not all controllers appear to update this while going from D3 to D0, * so check the individual port status registers as well */ while (i--) if (ehci_readl(ehci, &ehci->regs->port_status[i]) & PORT_CSC) return 1; return 0; } static __maybe_unused void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, bool suspending, bool do_wakeup) { int port; u32 temp; unsigned long flags; /* If remote wakeup is enabled for the root hub but disabled * for the controller, we must adjust all the port wakeup flags * when the controller is suspended or resumed. In all other * cases they don't need to be changed. */ if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) return; spin_lock_irqsave(&ehci->lock, flags); /* clear phy low-power mode before changing wakeup flags */ if (ehci->has_hostpc) { port = HCS_N_PORTS(ehci->hcs_params); while (port--) { u32 __iomem *hostpc_reg; hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs + HOSTPC0 + 4 * port); temp = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg); } spin_unlock_irqrestore(&ehci->lock, flags); msleep(5); spin_lock_irqsave(&ehci->lock, flags); } port = HCS_N_PORTS(ehci->hcs_params); while (port--) { u32 __iomem *reg = &ehci->regs->port_status[port]; u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; u32 t2 = t1 & ~PORT_WAKE_BITS; /* If we are suspending the controller, clear the flags. * If we are resuming the controller, set the wakeup flags. */ if (!suspending) { if (t1 & PORT_CONNECT) t2 |= PORT_WKOC_E | PORT_WKDISC_E; else t2 |= PORT_WKOC_E | PORT_WKCONN_E; } ehci_vdbg(ehci, "port %d, %08x -> %08x\n", port + 1, t1, t2); ehci_writel(ehci, t2, reg); } /* enter phy low-power mode again */ if (ehci->has_hostpc) { port = HCS_N_PORTS(ehci->hcs_params); while (port--) { u32 __iomem *hostpc_reg; hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs + HOSTPC0 + 4 * port); temp = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg); } } /* Does the root hub have a port wakeup pending? */ if (!suspending && ehci_port_change(ehci)) usb_hcd_resume_root_hub(ehci_to_hcd(ehci)); spin_unlock_irqrestore(&ehci->lock, flags); } static int ehci_bus_suspend (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); int port; int mask; int changed; ehci_dbg(ehci, "suspend root hub\n"); if (time_before (jiffies, ehci->next_statechange)) msleep(5); del_timer_sync(&ehci->watchdog); del_timer_sync(&ehci->iaa_watchdog); spin_lock_irq (&ehci->lock); /* Once the controller is stopped, port resumes that are already * in progress won't complete. Hence if remote wakeup is enabled * for the root hub and any ports are in the middle of a resume or * remote wakeup, we must fail the suspend. */ if (hcd->self.root_hub->do_remote_wakeup) { port = HCS_N_PORTS(ehci->hcs_params); while (port--) { if (ehci->reset_done[port] != 0) { spin_unlock_irq(&ehci->lock); ehci_dbg(ehci, "suspend failed because " "port %d is resuming\n", port + 1); return -EBUSY; } } } /* stop schedules, clean any completed work */ if (HC_IS_RUNNING(hcd->state)) { ehci_quiesce (ehci); hcd->state = HC_STATE_QUIESCING; } ehci->command = ehci_readl(ehci, &ehci->regs->command); ehci_work(ehci); /* Unlike other USB host controller types, EHCI doesn't have * any notion of "global" or bus-wide suspend. The driver has * to manually suspend all the active unsuspended ports, and * then manually resume them in the bus_resume() routine. */ ehci->bus_suspended = 0; ehci->owned_ports = 0; changed = 0; port = HCS_N_PORTS(ehci->hcs_params); while (port--) { u32 __iomem *reg = &ehci->regs->port_status [port]; u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; u32 t2 = t1 & ~PORT_WAKE_BITS; /* keep track of which ports we suspend */ if (t1 & PORT_OWNER) set_bit(port, &ehci->owned_ports); else if ((t1 & PORT_PE) && !(t1 & PORT_SUSPEND)) { t2 |= PORT_SUSPEND; set_bit(port, &ehci->bus_suspended); } /* enable remote wakeup on all ports, if told to do so */ if (hcd->self.root_hub->do_remote_wakeup) { /* only enable appropriate wake bits, otherwise the * hardware can not go phy low power mode. If a race * condition happens here(connection change during bits * set), the port change detection will finally fix it. */ if (t1 & PORT_CONNECT) t2 |= PORT_WKOC_E | PORT_WKDISC_E; else t2 |= PORT_WKOC_E | PORT_WKCONN_E; } if (t1 != t2) { ehci_vdbg (ehci, "port %d, %08x -> %08x\n", port + 1, t1, t2); ehci_writel(ehci, t2, reg); changed = 1; } } if (changed && ehci->has_hostpc) { spin_unlock_irq(&ehci->lock); msleep(5); /* 5 ms for HCD to enter low-power mode */ spin_lock_irq(&ehci->lock); port = HCS_N_PORTS(ehci->hcs_params); while (port--) { u32 __iomem *hostpc_reg; u32 t3; hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs + HOSTPC0 + 4 * port); t3 = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg); t3 = ehci_readl(ehci, hostpc_reg); ehci_dbg(ehci, "Port %d phy low-power mode %s\n", port, (t3 & HOSTPC_PHCD) ? "succeeded" : "failed"); } } /* Apparently some devices need a >= 1-uframe delay here */ if (ehci->bus_suspended) udelay(150); /* turn off now-idle HC */ ehci_halt (ehci); hcd->state = HC_STATE_SUSPENDED; if (ehci->reclaim) end_unlink_async(ehci); /* allow remote wakeup */ mask = INTR_MASK; if (!hcd->self.root_hub->do_remote_wakeup) mask &= ~STS_PCD; ehci_writel(ehci, mask, &ehci->regs->intr_enable); ehci_readl(ehci, &ehci->regs->intr_enable); ehci->next_statechange = jiffies + msecs_to_jiffies(10); spin_unlock_irq (&ehci->lock); /* ehci_work() may have re-enabled the watchdog timer, which we do not * want, and so we must delete any pending watchdog timer events. */ del_timer_sync(&ehci->watchdog); return 0; } /* caller has locked the root hub, and should reset/reinit on error */ static int ehci_bus_resume (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); u32 temp; u32 power_okay; int i; unsigned long resume_needed = 0; if (time_before (jiffies, ehci->next_statechange)) msleep(5); spin_lock_irq (&ehci->lock); if (!HCD_HW_ACCESSIBLE(hcd)) { spin_unlock_irq(&ehci->lock); return -ESHUTDOWN; } if (unlikely(ehci->debug)) { if (!dbgp_reset_prep()) ehci->debug = NULL; else dbgp_external_startup(); } /* Ideally and we've got a real resume here, and no port's power * was lost. (For PCI, that means Vaux was maintained.) But we * could instead be restoring a swsusp snapshot -- so that BIOS was * the last user of the controller, not reset/pm hardware keeping * state we gave to it. */ power_okay = ehci_readl(ehci, &ehci->regs->intr_enable); ehci_dbg(ehci, "resume root hub%s\n", power_okay ? "" : " after power loss"); /* at least some APM implementations will try to deliver * IRQs right away, so delay them until we're ready. */ ehci_writel(ehci, 0, &ehci->regs->intr_enable); /* re-init operational registers */ ehci_writel(ehci, 0, &ehci->regs->segment); ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next); /* restore CMD_RUN, framelist size, and irq threshold */ ehci_writel(ehci, ehci->command, &ehci->regs->command); /* Some controller/firmware combinations need a delay during which * they set up the port statuses. See Bugzilla #8190. */ spin_unlock_irq(&ehci->lock); msleep(8); spin_lock_irq(&ehci->lock); /* clear phy low-power mode before resume */ if (ehci->bus_suspended && ehci->has_hostpc) { i = HCS_N_PORTS(ehci->hcs_params); while (i--) { if (test_bit(i, &ehci->bus_suspended)) { u32 __iomem *hostpc_reg; hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs + HOSTPC0 + 4 * i); temp = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg); } } spin_unlock_irq(&ehci->lock); msleep(5); spin_lock_irq(&ehci->lock); } /* manually resume the ports we suspended during bus_suspend() */ i = HCS_N_PORTS (ehci->hcs_params); while (i--) { temp = ehci_readl(ehci, &ehci->regs->port_status [i]); temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); if (test_bit(i, &ehci->bus_suspended) && (temp & PORT_SUSPEND)) { temp |= PORT_RESUME; set_bit(i, &resume_needed); } ehci_writel(ehci, temp, &ehci->regs->port_status [i]); } /* msleep for 20ms only if code is trying to resume port */ if (resume_needed) { spin_unlock_irq(&ehci->lock); msleep(20); spin_lock_irq(&ehci->lock); } i = HCS_N_PORTS (ehci->hcs_params); while (i--) { temp = ehci_readl(ehci, &ehci->regs->port_status [i]); if (test_bit(i, &resume_needed)) { temp &= ~(PORT_RWC_BITS | PORT_RESUME); ehci_writel(ehci, temp, &ehci->regs->port_status [i]); ehci_vdbg (ehci, "resumed port %d\n", i + 1); } } (void) ehci_readl(ehci, &ehci->regs->command); /* maybe re-activate the schedule(s) */ temp = 0; if (ehci->async->qh_next.qh) temp |= CMD_ASE; if (ehci->periodic_sched) temp |= CMD_PSE; if (temp) { ehci->command |= temp; ehci_writel(ehci, ehci->command, &ehci->regs->command); } ehci->next_statechange = jiffies + msecs_to_jiffies(5); hcd->state = HC_STATE_RUNNING; /* Now we can safely re-enable irqs */ ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); spin_unlock_irq (&ehci->lock); ehci_handover_companion_ports(ehci); return 0; } #else #define ehci_bus_suspend NULL #define ehci_bus_resume NULL #endif /* CONFIG_PM */ /*-------------------------------------------------------------------------*/ /* Display the ports dedicated to the companion controller */ static ssize_t show_companion(struct device *dev, struct device_attribute *attr, char *buf) { struct ehci_hcd *ehci; int nports, index, n; int count = PAGE_SIZE; char *ptr = buf; ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); nports = HCS_N_PORTS(ehci->hcs_params); for (index = 0; index < nports; ++index) { if (test_bit(index, &ehci->companion_ports)) { n = scnprintf(ptr, count, "%d\n", index + 1); ptr += n; count -= n; } } return ptr - buf; } /* * Sets the owner of a port */ static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) { u32 __iomem *status_reg; u32 port_status; int try; status_reg = &ehci->regs->port_status[portnum]; /* * The controller won't set the OWNER bit if the port is * enabled, so this loop will sometimes require at least two * iterations: one to disable the port and one to set OWNER. */ for (try = 4; try > 0; --try) { spin_lock_irq(&ehci->lock); port_status = ehci_readl(ehci, status_reg); if ((port_status & PORT_OWNER) == new_owner || (port_status & (PORT_OWNER | PORT_CONNECT)) == 0) try = 0; else { port_status ^= PORT_OWNER; port_status &= ~(PORT_PE | PORT_RWC_BITS); ehci_writel(ehci, port_status, status_reg); } spin_unlock_irq(&ehci->lock); if (try > 1) msleep(5); } } /* * Dedicate or undedicate a port to the companion controller. * Syntax is "[-]portnum", where a leading '-' sign means * return control of the port to the EHCI controller. */ static ssize_t store_companion(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct ehci_hcd *ehci; int portnum, new_owner; ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); new_owner = PORT_OWNER; /* Owned by companion */ if (sscanf(buf, "%d", &portnum) != 1) return -EINVAL; if (portnum < 0) { portnum = - portnum; new_owner = 0; /* Owned by EHCI */ } if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) return -ENOENT; portnum--; if (new_owner) set_bit(portnum, &ehci->companion_ports); else clear_bit(portnum, &ehci->companion_ports); set_owner(ehci, portnum, new_owner); return count; } static DEVICE_ATTR(companion, 0644, show_companion, store_companion); static inline int create_companion_file(struct ehci_hcd *ehci) { int i = 0; /* with integrated TT there is no companion! */ if (!ehci_is_TDI(ehci)) i = device_create_file(ehci_to_hcd(ehci)->self.controller, &dev_attr_companion); return i; } static inline void remove_companion_file(struct ehci_hcd *ehci) { /* with integrated TT there is no companion! */ if (!ehci_is_TDI(ehci)) device_remove_file(ehci_to_hcd(ehci)->self.controller, &dev_attr_companion); } /*-------------------------------------------------------------------------*/ static int check_reset_complete ( struct ehci_hcd *ehci, int index, u32 __iomem *status_reg, int port_status ) { if (!(port_status & PORT_CONNECT)) return port_status; /* if reset finished and it's still not enabled -- handoff */ if (!(port_status & PORT_PE)) { /* with integrated TT, there's nobody to hand it to! */ if (ehci_is_TDI(ehci)) { ehci_dbg (ehci, "Failed to enable port %d on root hub TT\n", index+1); return port_status; } if (ehci->no_companion_port_handoff) { /* on omap, we can't hand off companion port */ ehci_dbg(ehci, "port %d FS device detected - cannot handoff port\n", index + 1); return port_status; } ehci_dbg (ehci, "port %d full speed --> companion\n", index + 1); // what happens if HCS_N_CC(params) == 0 ? port_status |= PORT_OWNER; port_status &= ~PORT_RWC_BITS; ehci_writel(ehci, port_status, status_reg); /* ensure 440EPX ohci controller state is operational */ if (ehci->has_amcc_usb23) set_ohci_hcfs(ehci, 1); } else { ehci_dbg (ehci, "port %d high speed\n", index + 1); /* ensure 440EPx ohci controller state is suspended */ if (ehci->has_amcc_usb23) set_ohci_hcfs(ehci, 0); } return port_status; } /*-------------------------------------------------------------------------*/ /* build "status change" packet (one or two bytes) from HC registers */ static int ehci_hub_status_data (struct usb_hcd *hcd, char *buf) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); u32 temp, status = 0; u32 mask; int ports, i, retval = 1; unsigned long flags; u32 ppcd = 0; /* if !USB_SUSPEND, root hub timers won't get shut down ... */ if (!HC_IS_RUNNING(hcd->state)) return 0; /* init status to no-changes */ buf [0] = 0; ports = HCS_N_PORTS (ehci->hcs_params); if (ports > 7) { buf [1] = 0; retval++; } /* Some boards (mostly VIA?) report bogus overcurrent indications, * causing massive log spam unless we completely ignore them. It * may be relevant that VIA VT8235 controllers, where PORT_POWER is * always set, seem to clear PORT_OCC and PORT_CSC when writing to * PORT_POWER; that's surprising, but maybe within-spec. */ if (!ignore_oc) mask = PORT_CSC | PORT_PEC | PORT_OCC; else mask = PORT_CSC | PORT_PEC; // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND /* no hub change reports (bit 0) for now (power, ...) */ /* port N changes (bit N)? */ spin_lock_irqsave (&ehci->lock, flags); /* get per-port change detect bits */ if (ehci->has_ppcd) ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16; for (i = 0; i < ports; i++) { /* leverage per-port change bits feature */ if (ehci->has_ppcd && !(ppcd & (1 << i))) continue; temp = ehci_readl(ehci, &ehci->regs->port_status [i]); /* * Return status information even for ports with OWNER set. * Otherwise khubd wouldn't see the disconnect event when a * high-speed device is switched over to the companion * controller by the user. */ if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) || (ehci->reset_done[i] && time_after_eq( jiffies, ehci->reset_done[i]))) { if (i < 7) buf [0] |= 1 << (i + 1); else buf [1] |= 1 << (i - 7); status = STS_PCD; } } /* FIXME autosuspend idle root hubs */ spin_unlock_irqrestore (&ehci->lock, flags); return status ? retval : 0; } /*-------------------------------------------------------------------------*/ static void ehci_hub_descriptor ( struct ehci_hcd *ehci, struct usb_hub_descriptor *desc ) { int ports = HCS_N_PORTS (ehci->hcs_params); u16 temp; desc->bDescriptorType = 0x29; desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */ desc->bHubContrCurrent = 0; desc->bNbrPorts = ports; temp = 1 + (ports / 8); desc->bDescLength = 7 + 2 * temp; /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */ memset(&desc->u.hs.DeviceRemovable[0], 0, temp); memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); temp = 0x0008; /* per-port overcurrent reporting */ if (HCS_PPC (ehci->hcs_params)) temp |= 0x0001; /* per-port power control */ else temp |= 0x0002; /* no power switching */ #if 0 // re-enable when we support USB_PORT_FEAT_INDICATOR below. if (HCS_INDICATOR (ehci->hcs_params)) temp |= 0x0080; /* per-port indicators (LEDs) */ #endif desc->wHubCharacteristics = cpu_to_le16(temp); } /*-------------------------------------------------------------------------*/ int omap_ehci_ulpi_write(const struct usb_hcd *hcd, u8 val, u8 reg, u8 retry_times); void omap_ehci_hw_phy_reset(const struct usb_hcd *hcd); #define CM_L3INIT_HSUSBHOST_CLKCTRL (0x4A009358) #define L3INIT_HSUSBHOST_CLKCTRL (0x4A009358) #define OMAP_UHH_SYSCONFIG (0x4a064010) #define OMAP_UHH_SYSSTATUS (0x4a064014) #define OMAP_UHH_HOSTCONFIG (0x4a064040) void uhh_omap_reset_link(struct ehci_hcd *ehci) { u32 usbcmd_backup; u32 usbintr_backup; u32 asynclistaddr_backup, periodiclistbase_backup; u32 portsc0_backup; u32 uhh_sysconfig_backup, uhh_hostconfig_backup; u32 temp_reg; u8 count; u16 orig_val, val; /* switch to internal 60Mhz clock */ temp_reg = omap_readl(L3INIT_HSUSBHOST_CLKCTRL); temp_reg |= 1 << 8; temp_reg &= ~(1 << 24); omap_writel(temp_reg, L3INIT_HSUSBHOST_CLKCTRL); /* Backup current registers of EHCI */ usbcmd_backup = ehci_readl(ehci, &ehci->regs->command); ehci_writel(ehci, usbcmd_backup & ~(CMD_IAAD | CMD_ASE | CMD_PSE | CMD_RUN), &ehci->regs->command); mdelay(3); /* check controller stopped */ handshake(ehci, &ehci->regs->status, STS_HALT, 1, 150); asynclistaddr_backup = ehci_readl(ehci, &ehci->regs->async_next); periodiclistbase_backup = ehci_readl(ehci, &ehci->regs->frame_list); portsc0_backup = ehci_readl(ehci, &ehci->regs->port_status[0]); usbintr_backup = ehci_readl(ehci, &ehci->regs->intr_enable); uhh_sysconfig_backup = omap_readl(OMAP_UHH_SYSCONFIG); uhh_hostconfig_backup = omap_readl(OMAP_UHH_HOSTCONFIG); /* Soft reset EHCI controller */ omap_writel(omap_readl(OMAP_UHH_SYSCONFIG) | (1<<0), OMAP_UHH_SYSCONFIG); /* wait for reset done */ count = 10; while ((omap_readl(OMAP_UHH_SYSCONFIG) & (1<<0)) && count--) mdelay(1); if (!count) pr_err("ehci:link_reset: soft-reset fail\n"); /* PHY reset via RESETB pin */ omap_ehci_hw_phy_reset(ehci_to_hcd(ehci)); /* switch back to external 60Mhz clock */ temp_reg &= ~(1 << 8); temp_reg |= 1 << 24; omap_writel(temp_reg, L3INIT_HSUSBHOST_CLKCTRL); mdelay(5); /*soft reset ehci registers */ ehci_writel(ehci, (1<<1), &ehci->regs->command); count = 10; while ((ehci_readl(ehci, &ehci->regs->command) & (1<<1)) && count--) mdelay(1); if (!count) pr_err("ehci:link_reset: soft-reset fail\n"); /* Restore registers after reset */ omap_writel(uhh_sysconfig_backup, OMAP_UHH_SYSCONFIG); omap_writel(uhh_hostconfig_backup, OMAP_UHH_HOSTCONFIG); ehci_writel(ehci, periodiclistbase_backup, &ehci->regs->frame_list); ehci_writel(ehci, asynclistaddr_backup, &ehci->regs->async_next); ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); ehci_writel(ehci, 0, &ehci->regs->intr_enable); ehci_writel(ehci, usbcmd_backup, &ehci->regs->command); mdelay(2); ehci_writel(ehci, PORT_POWER, &ehci->regs->port_status[0]); /* Put PHY in good default state */ if (omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x20, 0x5, 20) < 0) { /* Toggle STP line */ orig_val = val = omap_readw(0x4A1000C4); val |= 0x1F; omap_writew(val, 0x4A1000C4); mdelay(3); omap_writew(orig_val, 0x4A1000C4); omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x20, 0x5, 20); } omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x41, 0x4, 20); omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x18, 0x7, 20); omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x66, 0xA, 20); omap_ehci_ulpi_write(ehci_to_hcd(ehci), 0x45, 0x4, 20); handshake(ehci, &ehci->regs->port_status[0], PORT_CONNECT, 1, 2000); ehci_writel(ehci, usbintr_backup, &ehci->regs->intr_enable); } static int ehci_hub_control ( struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength ) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); int ports = HCS_N_PORTS (ehci->hcs_params); u32 __iomem *status_reg = &ehci->regs->port_status[ (wIndex & 0xff) - 1]; u32 __iomem *hostpc_reg = NULL; u32 temp, temp1, status; unsigned long flags; int retval = 0; unsigned selector; u32 runstop; /* * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. * HCS_INDICATOR may say we can change LEDs to off/amber/green. * (track current state ourselves) ... blink for diagnostics, * power, "this is the one", etc. EHCI spec supports this. */ if (ehci->has_hostpc) hostpc_reg = (u32 __iomem *)((u8 *)ehci->regs + HOSTPC0 + 4 * ((wIndex & 0xff) - 1)); spin_lock_irqsave (&ehci->lock, flags); switch (typeReq) { case ClearHubFeature: switch (wValue) { case C_HUB_LOCAL_POWER: case C_HUB_OVER_CURRENT: /* no hub-wide feature/status flags */ break; default: goto error; } break; case ClearPortFeature: if (!wIndex || wIndex > ports) goto error; wIndex--; temp = ehci_readl(ehci, status_reg); /* * Even if OWNER is set, so the port is owned by the * companion controller, khubd needs to be able to clear * the port-change status bits (especially * USB_PORT_STAT_C_CONNECTION). */ switch (wValue) { case USB_PORT_FEAT_ENABLE: ehci_writel(ehci, temp & ~PORT_PE, status_reg); break; case USB_PORT_FEAT_C_ENABLE: ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC, status_reg); break; case USB_PORT_FEAT_SUSPEND: if (temp & PORT_RESET) goto error; if (ehci->no_selective_suspend) break; #ifdef CONFIG_USB_OTG if ((hcd->self.otg_port == (wIndex + 1)) && hcd->self.b_hnp_enable) { otg_start_hnp(ehci->transceiver); break; } #endif if (!(temp & PORT_SUSPEND)) break; if ((temp & PORT_PE) == 0) goto error; /* clear phy low-power mode before resume */ if (hostpc_reg) { temp1 = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, temp1 & ~HOSTPC_PHCD, hostpc_reg); spin_unlock_irqrestore(&ehci->lock, flags); msleep(5);/* wait to leave low-power mode */ spin_lock_irqsave(&ehci->lock, flags); } /* resume signaling for 20 msec */ temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); ehci_writel(ehci, temp | PORT_RESUME, status_reg); ehci->reset_done[wIndex] = jiffies + msecs_to_jiffies(20); break; case USB_PORT_FEAT_C_SUSPEND: clear_bit(wIndex, &ehci->port_c_suspend); break; case USB_PORT_FEAT_POWER: if (HCS_PPC (ehci->hcs_params)) ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_POWER), status_reg); break; case USB_PORT_FEAT_C_CONNECTION: if (ehci->has_lpm) { /* clear PORTSC bits on disconnect */ temp &= ~PORT_LPM; temp &= ~PORT_DEV_ADDR; } ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, status_reg); break; case USB_PORT_FEAT_C_OVER_CURRENT: ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC, status_reg); break; case USB_PORT_FEAT_C_RESET: /* GetPortStatus clears reset */ break; default: goto error; } ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */ break; case GetHubDescriptor: ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *) buf); break; case GetHubStatus: /* no hub-wide feature/status flags */ memset (buf, 0, 4); //cpu_to_le32s ((u32 *) buf); break; case GetPortStatus: if (!wIndex || wIndex > ports) goto error; wIndex--; status = 0; temp = ehci_readl(ehci, status_reg); // wPortChange bits if (temp & PORT_CSC) status |= USB_PORT_STAT_C_CONNECTION << 16; if (temp & PORT_PEC) status |= USB_PORT_STAT_C_ENABLE << 16; if ((temp & PORT_OCC) && !ignore_oc){ status |= USB_PORT_STAT_C_OVERCURRENT << 16; /* * Hubs should disable port power on over-current. * However, not all EHCI implementations do this * automatically, even if they _do_ support per-port * power switching; they're allowed to just limit the * current. khubd will turn the power back on. */ if ((temp & PORT_OC) && HCS_PPC(ehci->hcs_params)) { ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_POWER), status_reg); temp = ehci_readl(ehci, status_reg); } } /* whoever resumes must GetPortStatus to complete it!! */ if (temp & PORT_RESUME) { /* Remote Wakeup received? */ if (!ehci->reset_done[wIndex]) { /* resume signaling for 20 msec */ ehci->reset_done[wIndex] = jiffies + msecs_to_jiffies(20); /* check the port again */ mod_timer(&ehci_to_hcd(ehci)->rh_timer, ehci->reset_done[wIndex]); } /* resume completed? */ else if (time_after_eq(jiffies, ehci->reset_done[wIndex])) { clear_bit(wIndex, &ehci->suspended_ports); set_bit(wIndex, &ehci->port_c_suspend); ehci->reset_done[wIndex] = 0; /* Workaround for OMAP errata: * The errata affects suspend-resume and * remote-wakeup. We need to halt the * controller before clearing the resume bit */ runstop = ehci_readl(ehci, &ehci->regs->command); ehci_writel(ehci, (runstop & ~1), &ehci->regs->command); (void) ehci_readl(ehci, &ehci->regs->command); handshake(ehci, &ehci->regs->status, STS_HALT, STS_HALT, 2000); /* stop resume signaling */ temp = ehci_readl(ehci, status_reg); ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESUME), status_reg); retval = handshake(ehci, status_reg, PORT_RESUME, 0, 2000 /* 2msec */); ehci_writel(ehci, runstop, &ehci->regs->command); (void) ehci_readl(ehci, &ehci->regs->command); if (retval != 0) { ehci_err(ehci, "port %d resume error %d\n", wIndex + 1, retval); if (ehci->has_smsc_ulpi_bug) ehci->resume_error_flag = 1; uhh_omap_reset_link(ehci); goto error; } /* restore registers value to its original state*/ if (ehci->resume_error_flag) { omap_ehci_ulpi_write(hcd, 0x00, 0x32, 20); omap_ehci_ulpi_write(hcd, 0x04, 0x39, 20); } temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10)); } } /* whoever resets must GetPortStatus to complete it!! */ if ((temp & PORT_RESET) && time_after_eq(jiffies, ehci->reset_done[wIndex])) { status |= USB_PORT_STAT_C_RESET << 16; ehci->reset_done [wIndex] = 0; /* force reset to complete */ ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), status_reg); /* REVISIT: some hardware needs 550+ usec to clear * this bit; seems too long to spin routinely... */ retval = handshake(ehci, status_reg, PORT_RESET, 0, 1000); if (retval != 0) { ehci_err (ehci, "port %d reset error %d\n", wIndex + 1, retval); goto error; } /* see what we found out */ temp = check_reset_complete (ehci, wIndex, status_reg, ehci_readl(ehci, status_reg)); } if (!(temp & (PORT_RESUME|PORT_RESET))) ehci->reset_done[wIndex] = 0; /* transfer dedicated ports to the companion hc */ if ((temp & PORT_CONNECT) && test_bit(wIndex, &ehci->companion_ports)) { temp &= ~PORT_RWC_BITS; temp |= PORT_OWNER; ehci_writel(ehci, temp, status_reg); ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1); temp = ehci_readl(ehci, status_reg); } /* * Even if OWNER is set, there's no harm letting khubd * see the wPortStatus values (they should all be 0 except * for PORT_POWER anyway). */ if (temp & PORT_CONNECT) { status |= USB_PORT_STAT_CONNECTION; // status may be from integrated TT if (ehci->has_hostpc) { temp1 = ehci_readl(ehci, hostpc_reg); status |= ehci_port_speed(ehci, temp1); } else status |= ehci_port_speed(ehci, temp); } if (temp & PORT_PE) status |= USB_PORT_STAT_ENABLE; /* maybe the port was unsuspended without our knowledge */ if (temp & (PORT_SUSPEND|PORT_RESUME)) { status |= USB_PORT_STAT_SUSPEND; } else if (test_bit(wIndex, &ehci->suspended_ports)) { clear_bit(wIndex, &ehci->suspended_ports); ehci->reset_done[wIndex] = 0; if (temp & PORT_PE) set_bit(wIndex, &ehci->port_c_suspend); } if (temp & PORT_OC) status |= USB_PORT_STAT_OVERCURRENT; if (temp & PORT_RESET) status |= USB_PORT_STAT_RESET; if (temp & PORT_POWER) status |= USB_PORT_STAT_POWER; if (test_bit(wIndex, &ehci->port_c_suspend)) status |= USB_PORT_STAT_C_SUSPEND << 16; #ifndef VERBOSE_DEBUG if (status & ~0xffff) /* only if wPortChange is interesting */ #endif dbg_port (ehci, "GetStatus", wIndex + 1, temp); put_unaligned_le32(status, buf); break; case SetHubFeature: switch (wValue) { case C_HUB_LOCAL_POWER: case C_HUB_OVER_CURRENT: /* no hub-wide feature/status flags */ break; default: goto error; } break; case SetPortFeature: selector = wIndex >> 8; wIndex &= 0xff; if (unlikely(ehci->debug)) { /* If the debug port is active any port * feature requests should get denied */ if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) && (readl(&ehci->debug->control) & DBGP_ENABLED)) { retval = -ENODEV; goto error_exit; } } if (!wIndex || wIndex > ports) goto error; wIndex--; temp = ehci_readl(ehci, status_reg); if (temp & PORT_OWNER) break; temp &= ~PORT_RWC_BITS; switch (wValue) { case USB_PORT_FEAT_SUSPEND: if (ehci->no_selective_suspend) break; if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) goto error; /* * Special workaround for resume error * - Write 04h to register 32h : inserts a 2uA source current on DP * - Write 14h to register 39h : enables 125kohm pull up resistors on DP */ if (ehci->resume_error_flag) { omap_ehci_ulpi_write(hcd, 0x04, 0x32, 20); omap_ehci_ulpi_write(hcd, 0x14, 0x39, 20); } /* After above check the port must be connected. * Set appropriate bit thus could put phy into low power * mode if we have hostpc feature */ temp &= ~PORT_WKCONN_E; temp |= PORT_WKDISC_E | PORT_WKOC_E; ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); /* * Special workaround sequence: * - Set suspend bit * - Wait 4ms for suspend to take effect * - alternatively read the line state * in PORTSC * - switch to internal 60 MHz clock * - wait 1ms * - switch back to external clock */ { u32 temp_reg; mdelay(4); temp_reg = omap_readl(L3INIT_HSUSBHOST_CLKCTRL); temp_reg |= 1 << 8; temp_reg &= ~(1 << 24); omap_writel(temp_reg, L3INIT_HSUSBHOST_CLKCTRL); mdelay(1); temp_reg &= ~(1 << 8); temp_reg |= 1 << 24; omap_writel(temp_reg, L3INIT_HSUSBHOST_CLKCTRL); } if (hostpc_reg) { spin_unlock_irqrestore(&ehci->lock, flags); msleep(5);/* 5ms for HCD enter low pwr mode */ spin_lock_irqsave(&ehci->lock, flags); temp1 = ehci_readl(ehci, hostpc_reg); ehci_writel(ehci, temp1 | HOSTPC_PHCD, hostpc_reg); temp1 = ehci_readl(ehci, hostpc_reg); ehci_dbg(ehci, "Port%d phy low pwr mode %s\n", wIndex, (temp1 & HOSTPC_PHCD) ? "succeeded" : "failed"); } set_bit(wIndex, &ehci->suspended_ports); break; case USB_PORT_FEAT_POWER: if (HCS_PPC (ehci->hcs_params)) ehci_writel(ehci, temp | PORT_POWER, status_reg); break; case USB_PORT_FEAT_RESET: if (temp & PORT_RESUME) goto error; /* line status bits may report this as low speed, * which can be fine if this root hub has a * transaction translator built in. */ if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT && !ehci_is_TDI(ehci) && PORT_USB11 (temp)) { ehci_dbg (ehci, "port %d low speed --> companion\n", wIndex + 1); temp |= PORT_OWNER; } else { ehci_vdbg (ehci, "port %d reset\n", wIndex + 1); temp |= PORT_RESET; temp &= ~PORT_PE; /* * caller must wait, then call GetPortStatus * usb 2.0 spec says 50 ms resets on root */ ehci->reset_done [wIndex] = jiffies + msecs_to_jiffies (50); } ehci_writel(ehci, temp, status_reg); break; /* For downstream facing ports (these): one hub port is put * into test mode according to USB2 11.24.2.13, then the hub * must be reset (which for root hub now means rmmod+modprobe, * or else system reboot). See EHCI 2.3.9 and 4.14 for info * about the EHCI-specific stuff. */ case USB_PORT_FEAT_TEST: if (!selector || selector > 5) goto error; ehci_quiesce(ehci); /* Put all enabled ports into suspend */ while (ports--) { u32 __iomem *sreg = &ehci->regs->port_status[ports]; temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS; if (temp & PORT_PE) ehci_writel(ehci, temp | PORT_SUSPEND, sreg); } ehci_halt(ehci); temp = ehci_readl(ehci, status_reg); temp |= selector << 16; ehci_writel(ehci, temp, status_reg); break; default: goto error; } ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ break; default: error: /* "stall" on error */ retval = -EPIPE; } error_exit: spin_unlock_irqrestore (&ehci->lock, flags); return retval; } #ifndef CONFIG_USB_EHCI_HCD_OMAP static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); if (ehci_is_TDI(ehci)) return; set_owner(ehci, --portnum, PORT_OWNER); } static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); u32 __iomem *reg; if (ehci_is_TDI(ehci)) return 0; reg = &ehci->regs->port_status[portnum - 1]; return ehci_readl(ehci, reg) & PORT_OWNER; } #endif
gpl-2.0
unofficial-opensource-apple/gccfast
libf2c/libF77/r_tan.c
96
#include "f2c.h" #undef abs #include <math.h> double r_tan (real * x) { return (tan (*x)); }
gpl-2.0
iamrekcah/cyclone
tests/compress/ppm-old/arithcode.h
962
/* Declarations for arithmetic coding. Alistair Moffat, [email protected], July 1987. @(#)arithcode.h 1.1 5/3/91 */ #define codevaluebits 16 #if (codevaluebits<16) typedef unsigned short codevalue; #else typedef unsigned long codevalue; #endif #define topvalue ((codevalue)((1<<codevaluebits)-1)) #define maxfrequency ((topvalue+1)/4 + 1) #define firstqtr (topvalue/4+1) #define half (2*firstqtr) #define thirdqtr (3*firstqtr) #define escape_event U->totalcnt-U->notfound, U->totalcnt, U->totalcnt void arithmetic_encode(); /* codevalue arithmetic_decode_target(); */ #define arithmetic_decode_target(totl) \ ( ((S_value-S_low+1)*totl-1) / (S_high-S_low+1) ) void arithmetic_decode(); void startencoding(); void startoutputingbits(); void doneoutputingbits(); void doneencoding(); void startinputingbits(); void startdecoding(); codevalue S_low, S_high, S_value; long S_bitstofollow; int S_buffer, S_bitstogo; long cmpbytes, rawbytes;
gpl-2.0
TheThumbsupguy/Ross-Upholstery-Inc
wp-content/plugins/wordpress-seo/src/conditionals/xmlrpc-conditional.php
440
<?php namespace Yoast\WP\SEO\Conditionals; /** * Conditional that is met when the current request is an XML-RPC request. */ class XMLRPC_Conditional implements Conditional { /** * Returns whether the current request is an XML-RPC request. * * @return bool `true` when the current request is an XML-RPC request, `false` if not. */ public function is_met() { return ( \defined( 'XMLRPC_REQUEST' ) && \XMLRPC_REQUEST ); } }
gpl-2.0
Gurgel100/gcc
gcc/testsuite/gcc.dg/stack-usage-1.c
3351
/* { dg-do compile } */ /* { dg-options "-fstack-usage" } */ /* nvptx doesn't have a reg allocator, and hence no stack usage data. */ /* { dg-skip-if "" { nvptx-*-* } } */ /* This is aimed at testing basic support for -fstack-usage in the back-ends. See the SPARC back-end for example (grep flag_stack_usage_info in sparc.c). Once it is implemented, adjust SIZE below so that the stack usage for the function FOO is reported as 256 or 264 in the stack usage (.su) file. Then check that this is the actual stack usage in the assembly file. */ #if defined(__aarch64__) # define SIZE 256 /* No frame pointer for leaf functions (default) */ #elif defined(__arc__) # define SIZE (256-4) #elif defined(__i386__) # define SIZE 248 #elif defined(__x86_64__) # ifndef _WIN64 # define SIZE 356 # else # define SIZE (256 - 24) # endif #elif defined (__sparc__) # if defined (__arch64__) # define SIZE 76 # else # define SIZE 160 # endif #elif defined(__hppa__) # define SIZE 192 #elif defined (__alpha__) # define SIZE 240 #elif defined (__ia64__) # define SIZE 272 #elif defined(__mips__) # if defined (__mips_abicalls) \ || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64)) # define SIZE 240 # else # define SIZE 248 # endif #elif defined (__nds32__) # define SIZE 248 /* 256 - 8 bytes, only $fp and padding bytes are saved in the register save area under O0 optimization level. */ #elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \ || defined (__PPC64__) # if _CALL_ELF == 2 # define SIZE 208 # else # define SIZE 180 # endif #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \ || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) # if defined (__ALTIVEC__) # if defined (__APPLE__) # define SIZE 204 # else # define SIZE 220 # endif # elif defined (_AIX) # define SIZE 208 # else # define SIZE 240 # endif #elif defined (__riscv) # if defined (__riscv_32e) # define SIZE 252 # else # define SIZE 240 # endif #elif defined (__AVR__) #if defined (__AVR_3_BYTE_PC__ ) # define SIZE 251 /* 256 - 2 bytes for Y - 3 bytes for return address */ #else # define SIZE 252 /* 256 - 2 bytes for Y - 2 bytes for return address */ #endif #elif defined (__s390x__) # define SIZE 96 /* 256 - 160 bytes for register save area */ #elif defined (__s390__) # define SIZE 160 /* 256 - 96 bytes for register save area */ #elif defined (__epiphany__) # define SIZE (256 - __EPIPHANY_STACK_OFFSET__) #elif defined (__RL78__) # define SIZE 254 #elif defined (__sh__) # define SIZE 252 #elif defined (__frv__) # define SIZE 248 #elif defined (xstormy16) # define SIZE 254 #elif defined (__nios2__) # define SIZE 252 #elif defined (__PRU__) # define SIZE 252 #elif defined (__v850__) #define SIZE 260 #elif defined (__mn10300__) #define SIZE 252 #elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || defined (__H8300__) #define SIZE 252 #elif defined (__M32R__) #define SIZE 252 #elif defined (__csky__) # define SIZE 252 #else # define SIZE 256 #endif int foo (void) { char arr[SIZE]; arr[0] = 1; return 0; } /* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */ /* { dg-final { cleanup-stack-usage } } */
gpl-2.0
duongtung4691/javacpp.presets
opencv/src/main/java/com/googlecode/javacpp/opencv_highgui.java
75386
// Targeted by JavaCPP version 0.8-SNAPSHOT package com.googlecode.javacpp; import com.googlecode.javacpp.*; import com.googlecode.javacpp.annotation.*; import java.nio.*; import static com.googlecode.javacpp.opencv_core.*; import static com.googlecode.javacpp.opencv_imgproc.*; public class opencv_highgui extends com.googlecode.javacpp.helper.opencv_highgui { static { Loader.load(); } // Parsed from /usr/local/include/opencv2/highgui/highgui_c.h /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // Intel License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000, Intel Corporation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of Intel Corporation may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/ // #ifndef __OPENCV_HIGHGUI_H__ // #define __OPENCV_HIGHGUI_H__ // #include "opencv2/core/core_c.h" // #ifdef __cplusplus // #endif /* __cplusplus */ /****************************************************************************************\ * Basic GUI functions * \****************************************************************************************/ //YV //-----------New for Qt /* For font */ /** enum */ public static final int CV_FONT_LIGHT = 25,//QFont::Light, CV_FONT_NORMAL = 50,//QFont::Normal, CV_FONT_DEMIBOLD = 63,//QFont::DemiBold, CV_FONT_BOLD = 75,//QFont::Bold, CV_FONT_BLACK = 87; //QFont::Black /** enum */ public static final int CV_STYLE_NORMAL = 0,//QFont::StyleNormal, CV_STYLE_ITALIC = 1,//QFont::StyleItalic, CV_STYLE_OBLIQUE = 2; //QFont::StyleOblique /* ---------*/ //for color cvScalar(blue_component, green_component, red\_component[, alpha_component]) //and alpha= 0 <-> 0xFF (not transparent <-> transparent) public static native @ByVal @Platform("linux") CvFont cvFontQt(@Cast("const char*") BytePointer nameFont, int pointSize/*CV_DEFAULT(-1)*/, @ByVal CvScalar color/*CV_DEFAULT(cvScalarAll(0))*/, int weight/*CV_DEFAULT(CV_FONT_NORMAL)*/, int style/*CV_DEFAULT(CV_STYLE_NORMAL)*/, int spacing/*CV_DEFAULT(0)*/); public static native @ByVal @Platform("linux") CvFont cvFontQt(@Cast("const char*") BytePointer nameFont); public static native @ByVal @Platform("linux") CvFont cvFontQt(String nameFont, int pointSize/*CV_DEFAULT(-1)*/, @ByVal CvScalar color/*CV_DEFAULT(cvScalarAll(0))*/, int weight/*CV_DEFAULT(CV_FONT_NORMAL)*/, int style/*CV_DEFAULT(CV_STYLE_NORMAL)*/, int spacing/*CV_DEFAULT(0)*/); public static native @ByVal @Platform("linux") CvFont cvFontQt(String nameFont); public static native @Platform("linux") void cvAddText(@Const CvArr img, @Cast("const char*") BytePointer text, @ByVal CvPoint org, CvFont arg2); public static native @Platform("linux") void cvAddText(@Const CvArr img, String text, @ByVal @Cast("CvPoint*") IntBuffer org, CvFont arg2); public static native @Platform("linux") void cvAddText(@Const CvArr img, @Cast("const char*") BytePointer text, @ByVal @Cast("CvPoint*") int[] org, CvFont arg2); public static native @Platform("linux") void cvAddText(@Const CvArr img, String text, @ByVal CvPoint org, CvFont arg2); public static native @Platform("linux") void cvAddText(@Const CvArr img, @Cast("const char*") BytePointer text, @ByVal @Cast("CvPoint*") IntBuffer org, CvFont arg2); public static native @Platform("linux") void cvAddText(@Const CvArr img, String text, @ByVal @Cast("CvPoint*") int[] org, CvFont arg2); public static native @Platform("linux") void cvDisplayOverlay(@Cast("const char*") BytePointer name, @Cast("const char*") BytePointer text, int delayms/*CV_DEFAULT(0)*/); public static native @Platform("linux") void cvDisplayOverlay(@Cast("const char*") BytePointer name, @Cast("const char*") BytePointer text); public static native @Platform("linux") void cvDisplayOverlay(String name, String text, int delayms/*CV_DEFAULT(0)*/); public static native @Platform("linux") void cvDisplayOverlay(String name, String text); public static native @Platform("linux") void cvDisplayStatusBar(@Cast("const char*") BytePointer name, @Cast("const char*") BytePointer text, int delayms/*CV_DEFAULT(0)*/); public static native @Platform("linux") void cvDisplayStatusBar(@Cast("const char*") BytePointer name, @Cast("const char*") BytePointer text); public static native @Platform("linux") void cvDisplayStatusBar(String name, String text, int delayms/*CV_DEFAULT(0)*/); public static native @Platform("linux") void cvDisplayStatusBar(String name, String text); public static native @Platform("linux") void cvSaveWindowParameters(@Cast("const char*") BytePointer name); public static native @Platform("linux") void cvSaveWindowParameters(String name); public static native @Platform("linux") void cvLoadWindowParameters(@Cast("const char*") BytePointer name); public static native @Platform("linux") void cvLoadWindowParameters(String name); public static class Pt2Func_int_PointerPointer extends FunctionPointer { static { Loader.load(); } public Pt2Func_int_PointerPointer(Pointer p) { super(p); } protected Pt2Func_int_PointerPointer() { allocate(); } private native void allocate(); public native int call(int argc, @Cast("char**") PointerPointer argv); } public static native @Platform("linux") int cvStartLoop(Pt2Func_int_PointerPointer pt2Func, int argc, @Cast("char**") PointerPointer argv); public static class Pt2Func_int_BytePointer extends FunctionPointer { static { Loader.load(); } public Pt2Func_int_BytePointer(Pointer p) { super(p); } protected Pt2Func_int_BytePointer() { allocate(); } private native void allocate(); public native int call(int argc, @Cast("char**") @ByPtrPtr BytePointer argv); } public static native @Platform("linux") int cvStartLoop(Pt2Func_int_BytePointer pt2Func, int argc, @Cast("char**") @ByPtrPtr BytePointer argv); public static class Pt2Func_int_ByteBuffer extends FunctionPointer { static { Loader.load(); } public Pt2Func_int_ByteBuffer(Pointer p) { super(p); } protected Pt2Func_int_ByteBuffer() { allocate(); } private native void allocate(); public native int call(int argc, @Cast("char**") @ByPtrPtr ByteBuffer argv); } public static native @Platform("linux") int cvStartLoop(Pt2Func_int_ByteBuffer pt2Func, int argc, @Cast("char**") @ByPtrPtr ByteBuffer argv); public static class Pt2Func_int_byte__ extends FunctionPointer { static { Loader.load(); } public Pt2Func_int_byte__(Pointer p) { super(p); } protected Pt2Func_int_byte__() { allocate(); } private native void allocate(); public native int call(int argc, @Cast("char**") @ByPtrPtr byte[] argv); } public static native @Platform("linux") int cvStartLoop(Pt2Func_int_byte__ pt2Func, int argc, @Cast("char**") @ByPtrPtr byte[] argv); public static native @Platform("linux") void cvStopLoop( ); @Convention("CV_CDECL") public static class CvButtonCallback extends FunctionPointer { static { Loader.load(); } public CvButtonCallback(Pointer p) { super(p); } protected CvButtonCallback() { allocate(); } private native void allocate(); public native void call(int state, Pointer userdata); } /** enum */ public static final int CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2; public static native @Platform("linux") int cvCreateButton( @Cast("const char*") BytePointer button_name/*CV_DEFAULT(NULL)*/,CvButtonCallback on_change/*CV_DEFAULT(NULL)*/, Pointer userdata/*CV_DEFAULT(NULL)*/, int button_type/*CV_DEFAULT(CV_PUSH_BUTTON)*/, int initial_button_state/*CV_DEFAULT(0)*/); public static native @Platform("linux") int cvCreateButton(); public static native @Platform("linux") int cvCreateButton( String button_name/*CV_DEFAULT(NULL)*/,CvButtonCallback on_change/*CV_DEFAULT(NULL)*/, Pointer userdata/*CV_DEFAULT(NULL)*/, int button_type/*CV_DEFAULT(CV_PUSH_BUTTON)*/, int initial_button_state/*CV_DEFAULT(0)*/); //---------------------- /* this function is used to set some external parameters in case of X Window */ public static native int cvInitSystem( int argc, @Cast("char**") PointerPointer argv ); public static native int cvInitSystem( int argc, @Cast("char**") @ByPtrPtr BytePointer argv ); public static native int cvInitSystem( int argc, @Cast("char**") @ByPtrPtr ByteBuffer argv ); public static native int cvInitSystem( int argc, @Cast("char**") @ByPtrPtr byte[] argv ); public static native int cvStartWindowThread( ); // --------- YV --------- /** enum */ public static final int //These 3 flags are used by cvSet/GetWindowProperty CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed CV_WINDOW_OPENGL = 0x00001000, //window with opengl support //Those flags are only for Qt CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar CV_GUI_NORMAL = 0x00000010, //old fashious way //These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint) CV_WINDOW_KEEPRATIO = 0x00000000;//the ration image is respected. /* create window */ public static native int cvNamedWindow( @Cast("const char*") BytePointer name, int flags/*CV_DEFAULT(CV_WINDOW_AUTOSIZE)*/ ); public static native int cvNamedWindow( @Cast("const char*") BytePointer name ); public static native int cvNamedWindow( String name, int flags/*CV_DEFAULT(CV_WINDOW_AUTOSIZE)*/ ); public static native int cvNamedWindow( String name ); /* Set and Get Property of the window */ public static native void cvSetWindowProperty(@Cast("const char*") BytePointer name, int prop_id, double prop_value); public static native void cvSetWindowProperty(String name, int prop_id, double prop_value); public static native double cvGetWindowProperty(@Cast("const char*") BytePointer name, int prop_id); public static native double cvGetWindowProperty(String name, int prop_id); /* display image within window (highgui windows remember their content) */ public static native void cvShowImage( @Cast("const char*") BytePointer name, @Const CvArr image ); public static native void cvShowImage( String name, @Const CvArr image ); /* resize/move window */ public static native void cvResizeWindow( @Cast("const char*") BytePointer name, int width, int height ); public static native void cvResizeWindow( String name, int width, int height ); public static native void cvMoveWindow( @Cast("const char*") BytePointer name, int x, int y ); public static native void cvMoveWindow( String name, int x, int y ); /* destroy window and all the trackers associated with it */ public static native void cvDestroyWindow( @Cast("const char*") BytePointer name ); public static native void cvDestroyWindow( String name ); public static native void cvDestroyAllWindows(); /* get native window handle (HWND in case of Win32 and Widget in case of X Window) */ public static native Pointer cvGetWindowHandle( @Cast("const char*") BytePointer name ); public static native Pointer cvGetWindowHandle( String name ); /* get name of highgui window given its native handle */ public static native @Cast("const char*") BytePointer cvGetWindowName( Pointer window_handle ); @Convention("CV_CDECL") public static class CvTrackbarCallback extends FunctionPointer { static { Loader.load(); } public CvTrackbarCallback(Pointer p) { super(p); } protected CvTrackbarCallback() { allocate(); } private native void allocate(); public native void call(int pos); } /* create trackbar and display it on top of given window, set callback */ public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntPointer value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntPointer value, int count); public static native int cvCreateTrackbar( String trackbar_name, String window_name, IntBuffer value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( String trackbar_name, String window_name, IntBuffer value, int count); public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, int[] value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, int[] value, int count); public static native int cvCreateTrackbar( String trackbar_name, String window_name, IntPointer value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( String trackbar_name, String window_name, IntPointer value, int count); public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntBuffer value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntBuffer value, int count); public static native int cvCreateTrackbar( String trackbar_name, String window_name, int[] value, int count, CvTrackbarCallback on_change/*CV_DEFAULT(NULL)*/); public static native int cvCreateTrackbar( String trackbar_name, String window_name, int[] value, int count); @Convention("CV_CDECL") public static class CvTrackbarCallback2 extends FunctionPointer { static { Loader.load(); } public CvTrackbarCallback2(Pointer p) { super(p); } protected CvTrackbarCallback2() { allocate(); } private native void allocate(); public native void call(int pos, Pointer userdata); } public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntPointer value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntPointer value, int count, CvTrackbarCallback2 on_change); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, IntBuffer value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, IntBuffer value, int count, CvTrackbarCallback2 on_change); public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, int[] value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, int[] value, int count, CvTrackbarCallback2 on_change); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, IntPointer value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, IntPointer value, int count, CvTrackbarCallback2 on_change); public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntBuffer value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, IntBuffer value, int count, CvTrackbarCallback2 on_change); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, int[] value, int count, CvTrackbarCallback2 on_change, Pointer userdata/*CV_DEFAULT(0)*/); public static native int cvCreateTrackbar2( String trackbar_name, String window_name, int[] value, int count, CvTrackbarCallback2 on_change); /* retrieve or set trackbar position */ public static native int cvGetTrackbarPos( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name ); public static native int cvGetTrackbarPos( String trackbar_name, String window_name ); public static native void cvSetTrackbarPos( @Cast("const char*") BytePointer trackbar_name, @Cast("const char*") BytePointer window_name, int pos ); public static native void cvSetTrackbarPos( String trackbar_name, String window_name, int pos ); /** enum */ public static final int CV_EVENT_MOUSEMOVE = 0, CV_EVENT_LBUTTONDOWN = 1, CV_EVENT_RBUTTONDOWN = 2, CV_EVENT_MBUTTONDOWN = 3, CV_EVENT_LBUTTONUP = 4, CV_EVENT_RBUTTONUP = 5, CV_EVENT_MBUTTONUP = 6, CV_EVENT_LBUTTONDBLCLK = 7, CV_EVENT_RBUTTONDBLCLK = 8, CV_EVENT_MBUTTONDBLCLK = 9; /** enum */ public static final int CV_EVENT_FLAG_LBUTTON = 1, CV_EVENT_FLAG_RBUTTON = 2, CV_EVENT_FLAG_MBUTTON = 4, CV_EVENT_FLAG_CTRLKEY = 8, CV_EVENT_FLAG_SHIFTKEY = 16, CV_EVENT_FLAG_ALTKEY = 32; @Convention("CV_CDECL") public static class CvMouseCallback extends FunctionPointer { static { Loader.load(); } public CvMouseCallback(Pointer p) { super(p); } protected CvMouseCallback() { allocate(); } private native void allocate(); public native void call(int event, int x, int y, int flags, Pointer param); } /* assign callback for mouse events */ public static native void cvSetMouseCallback( @Cast("const char*") BytePointer window_name, CvMouseCallback on_mouse, Pointer param/*CV_DEFAULT(NULL)*/); public static native void cvSetMouseCallback( @Cast("const char*") BytePointer window_name, CvMouseCallback on_mouse); public static native void cvSetMouseCallback( String window_name, CvMouseCallback on_mouse, Pointer param/*CV_DEFAULT(NULL)*/); public static native void cvSetMouseCallback( String window_name, CvMouseCallback on_mouse); /** enum */ public static final int /* 8bit, color or not */ CV_LOAD_IMAGE_UNCHANGED = -1, /* 8bit, gray */ CV_LOAD_IMAGE_GRAYSCALE = 0, /* ?, color */ CV_LOAD_IMAGE_COLOR = 1, /* any depth, ? */ CV_LOAD_IMAGE_ANYDEPTH = 2, /* ?, any color */ CV_LOAD_IMAGE_ANYCOLOR = 4; /* load image from file iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED overrides the other flags using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit */ public static native IplImage cvLoadImage( @Cast("const char*") BytePointer filename, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native IplImage cvLoadImage( @Cast("const char*") BytePointer filename); public static native IplImage cvLoadImage( String filename, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native IplImage cvLoadImage( String filename); public static native CvMat cvLoadImageM( @Cast("const char*") BytePointer filename, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native CvMat cvLoadImageM( @Cast("const char*") BytePointer filename); public static native CvMat cvLoadImageM( String filename, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native CvMat cvLoadImageM( String filename); /** enum */ public static final int CV_IMWRITE_JPEG_QUALITY = 1, CV_IMWRITE_PNG_COMPRESSION = 16, CV_IMWRITE_PNG_STRATEGY = 17, CV_IMWRITE_PNG_BILEVEL = 18, CV_IMWRITE_PNG_STRATEGY_DEFAULT = 0, CV_IMWRITE_PNG_STRATEGY_FILTERED = 1, CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2, CV_IMWRITE_PNG_STRATEGY_RLE = 3, CV_IMWRITE_PNG_STRATEGY_FIXED = 4, CV_IMWRITE_PXM_BINARY = 32; /* save image to file */ public static native int cvSaveImage( @Cast("const char*") BytePointer filename, @Const CvArr image, @Const IntPointer params/*CV_DEFAULT(0)*/ ); public static native int cvSaveImage( @Cast("const char*") BytePointer filename, @Const CvArr image ); public static native int cvSaveImage( String filename, @Const CvArr image, @Const IntBuffer params/*CV_DEFAULT(0)*/ ); public static native int cvSaveImage( String filename, @Const CvArr image ); public static native int cvSaveImage( @Cast("const char*") BytePointer filename, @Const CvArr image, @Const int[] params/*CV_DEFAULT(0)*/ ); public static native int cvSaveImage( String filename, @Const CvArr image, @Const IntPointer params/*CV_DEFAULT(0)*/ ); public static native int cvSaveImage( @Cast("const char*") BytePointer filename, @Const CvArr image, @Const IntBuffer params/*CV_DEFAULT(0)*/ ); public static native int cvSaveImage( String filename, @Const CvArr image, @Const int[] params/*CV_DEFAULT(0)*/ ); /* decode image stored in the buffer */ public static native IplImage cvDecodeImage( @Const CvMat buf, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native IplImage cvDecodeImage( @Const CvMat buf); public static native CvMat cvDecodeImageM( @Const CvMat buf, int iscolor/*CV_DEFAULT(CV_LOAD_IMAGE_COLOR)*/); public static native CvMat cvDecodeImageM( @Const CvMat buf); /* encode image and store the result as a byte vector (single-row 8uC1 matrix) */ public static native CvMat cvEncodeImage( @Cast("const char*") BytePointer ext, @Const CvArr image, @Const IntPointer params/*CV_DEFAULT(0)*/ ); public static native CvMat cvEncodeImage( @Cast("const char*") BytePointer ext, @Const CvArr image ); public static native CvMat cvEncodeImage( String ext, @Const CvArr image, @Const IntBuffer params/*CV_DEFAULT(0)*/ ); public static native CvMat cvEncodeImage( String ext, @Const CvArr image ); public static native CvMat cvEncodeImage( @Cast("const char*") BytePointer ext, @Const CvArr image, @Const int[] params/*CV_DEFAULT(0)*/ ); public static native CvMat cvEncodeImage( String ext, @Const CvArr image, @Const IntPointer params/*CV_DEFAULT(0)*/ ); public static native CvMat cvEncodeImage( @Cast("const char*") BytePointer ext, @Const CvArr image, @Const IntBuffer params/*CV_DEFAULT(0)*/ ); public static native CvMat cvEncodeImage( String ext, @Const CvArr image, @Const int[] params/*CV_DEFAULT(0)*/ ); /** enum */ public static final int CV_CVTIMG_FLIP = 1, CV_CVTIMG_SWAP_RB = 2; /* utility function: convert one image to another with optional vertical flip */ public static native void cvConvertImage( @Const CvArr src, CvArr dst, int flags/*CV_DEFAULT(0)*/); public static native void cvConvertImage( @Const CvArr src, CvArr dst); /* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ public static native int cvWaitKey(int delay/*CV_DEFAULT(0)*/); public static native int cvWaitKey(); // OpenGL support @Convention("CV_CDECL") public static class CvOpenGlDrawCallback extends FunctionPointer { static { Loader.load(); } public CvOpenGlDrawCallback(Pointer p) { super(p); } protected CvOpenGlDrawCallback() { allocate(); } private native void allocate(); public native void call(Pointer userdata); } public static native void cvSetOpenGlDrawCallback(@Cast("const char*") BytePointer window_name, CvOpenGlDrawCallback callback, Pointer userdata/*CV_DEFAULT(NULL)*/); public static native void cvSetOpenGlDrawCallback(@Cast("const char*") BytePointer window_name, CvOpenGlDrawCallback callback); public static native void cvSetOpenGlDrawCallback(String window_name, CvOpenGlDrawCallback callback, Pointer userdata/*CV_DEFAULT(NULL)*/); public static native void cvSetOpenGlDrawCallback(String window_name, CvOpenGlDrawCallback callback); public static native void cvSetOpenGlContext(@Cast("const char*") BytePointer window_name); public static native void cvSetOpenGlContext(String window_name); public static native void cvUpdateWindow(@Cast("const char*") BytePointer window_name); public static native void cvUpdateWindow(String window_name); /****************************************************************************************\ * Working with Video Files and Cameras * \****************************************************************************************/ /* "black box" capture structure */ @Opaque public static class CvCapture extends Pointer { public CvCapture() { } public CvCapture(Pointer p) { super(p); } } /* start capturing frames from video file */ public static native CvCapture cvCreateFileCapture( @Cast("const char*") BytePointer filename ); public static native CvCapture cvCreateFileCapture( String filename ); /** enum */ public static final int CV_CAP_ANY = 0, // autodetect CV_CAP_MIL = 100, // MIL proprietary drivers CV_CAP_VFW = 200, // platform native CV_CAP_V4L = 200, CV_CAP_V4L2 = 200, CV_CAP_FIREWARE = 300, // IEEE 1394 drivers CV_CAP_FIREWIRE = 300, CV_CAP_IEEE1394 = 300, CV_CAP_DC1394 = 300, CV_CAP_CMU1394 = 300, CV_CAP_STEREO = 400, // TYZX proprietary drivers CV_CAP_TYZX = 400, CV_TYZX_LEFT = 400, CV_TYZX_RIGHT = 401, CV_TYZX_COLOR = 402, CV_TYZX_Z = 403, CV_CAP_QT = 500, // QuickTime CV_CAP_UNICAP = 600, // Unicap drivers CV_CAP_DSHOW = 700, // DirectShow (via videoInput) CV_CAP_MSMF = 1400, // Microsoft Media Foundation (via videoInput) CV_CAP_PVAPI = 800, // PvAPI, Prosilica GigE SDK CV_CAP_OPENNI = 900, // OpenNI (for Kinect) CV_CAP_OPENNI_ASUS = 910, // OpenNI (for Asus Xtion) CV_CAP_ANDROID = 1000, // Android CV_CAP_ANDROID_BACK = CV_CAP_ANDROID+99, // Android back camera CV_CAP_ANDROID_FRONT = CV_CAP_ANDROID+98, // Android front camera CV_CAP_XIAPI = 1100, // XIMEA Camera API CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API) CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK CV_CAP_INTELPERC = 1500; // Intel Perceptual Computing SDK /* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */ public static native CvCapture cvCreateCameraCapture( int index ); /* grab a frame, return 1 on success, 0 on fail. this function is thought to be fast */ public static native int cvGrabFrame( CvCapture capture ); /* get the frame grabbed with cvGrabFrame(..) This function may apply some frame processing like frame decompression, flipping etc. !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ public static native IplImage cvRetrieveFrame( CvCapture capture, int streamIdx/*CV_DEFAULT(0)*/ ); public static native IplImage cvRetrieveFrame( CvCapture capture ); /* Just a combination of cvGrabFrame and cvRetrieveFrame !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ public static native IplImage cvQueryFrame( CvCapture capture ); /* stop capturing/reading and free resources */ public static native void cvReleaseCapture( @Cast("CvCapture**") PointerPointer capture ); public static native void cvReleaseCapture( @ByPtrPtr CvCapture capture ); /** enum */ public static final int // modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode) // every feature can have only one mode turned on at a time CV_CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically) CV_CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user CV_CAP_PROP_DC1394_MODE_AUTO = -2, CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, CV_CAP_PROP_POS_MSEC = 0, CV_CAP_PROP_POS_FRAMES = 1, CV_CAP_PROP_POS_AVI_RATIO = 2, CV_CAP_PROP_FRAME_WIDTH = 3, CV_CAP_PROP_FRAME_HEIGHT = 4, CV_CAP_PROP_FPS = 5, CV_CAP_PROP_FOURCC = 6, CV_CAP_PROP_FRAME_COUNT = 7, CV_CAP_PROP_FORMAT = 8, CV_CAP_PROP_MODE = 9, CV_CAP_PROP_BRIGHTNESS = 10, CV_CAP_PROP_CONTRAST = 11, CV_CAP_PROP_SATURATION = 12, CV_CAP_PROP_HUE = 13, CV_CAP_PROP_GAIN = 14, CV_CAP_PROP_EXPOSURE = 15, CV_CAP_PROP_CONVERT_RGB = 16, CV_CAP_PROP_WHITE_BALANCE_BLUE_U = 17, CV_CAP_PROP_RECTIFICATION = 18, CV_CAP_PROP_MONOCROME = 19, CV_CAP_PROP_SHARPNESS = 20, CV_CAP_PROP_AUTO_EXPOSURE = 21, // exposure control done by camera, // user can adjust refernce level // using this feature CV_CAP_PROP_GAMMA = 22, CV_CAP_PROP_TEMPERATURE = 23, CV_CAP_PROP_TRIGGER = 24, CV_CAP_PROP_TRIGGER_DELAY = 25, CV_CAP_PROP_WHITE_BALANCE_RED_V = 26, CV_CAP_PROP_ZOOM = 27, CV_CAP_PROP_FOCUS = 28, CV_CAP_PROP_GUID = 29, CV_CAP_PROP_ISO_SPEED = 30, CV_CAP_PROP_MAX_DC1394 = 31, CV_CAP_PROP_BACKLIGHT = 32, CV_CAP_PROP_PAN = 33, CV_CAP_PROP_TILT = 34, CV_CAP_PROP_ROLL = 35, CV_CAP_PROP_IRIS = 36, CV_CAP_PROP_SETTINGS = 37, CV_CAP_PROP_AUTOGRAB = 1024, // property for highgui class CvCapture_Android only CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING= 1025, // readonly, tricky property, returns cpnst char* indeed CV_CAP_PROP_PREVIEW_FORMAT= 1026, // readonly, tricky property, returns cpnst char* indeed // OpenNI map generators CV_CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, CV_CAP_OPENNI_GENERATORS_MASK = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_OPENNI_IMAGE_GENERATOR, // Properties of cameras available through OpenNI interfaces CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100, CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels CV_CAP_PROP_OPENNI_REGISTRATION = 104, // flag CV_CAP_PROP_OPENNI_REGISTRATION_ON = CV_CAP_PROP_OPENNI_REGISTRATION, // flag that synchronizes the remapping depth map to image map // by changing depth generator's view point (if the flag is "on") or // sets this view point to its normal one (if the flag is "off"). CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, CV_CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, CV_CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, CV_CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE, CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE, CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH, CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION, CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, // Properties of cameras available through GStreamer interface CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1 CV_CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast // Properties of cameras available through XIMEA SDK interface CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels). CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels). CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger. CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition) CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%). CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %) CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds // Properties for Android cameras CV_CAP_PROP_ANDROID_FLASH_MODE = 8001, CV_CAP_PROP_ANDROID_FOCUS_MODE = 8002, CV_CAP_PROP_ANDROID_WHITE_BALANCE = 8003, CV_CAP_PROP_ANDROID_ANTIBANDING = 8004, CV_CAP_PROP_ANDROID_FOCAL_LENGTH = 8005, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008, // Properties of cameras available through AVFOUNDATION interface CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001, CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, CV_CAP_PROP_IOS_DEVICE_FLASH = 9003, CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, CV_CAP_PROP_IOS_DEVICE_TORCH = 9005, // Properties of cameras available through Smartek Giganetix Ethernet Vision interface /* --- Vladimir Litvinenko ([email protected]) --- */ CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006, CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, // Intel PerC streams CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR; /** enum */ public static final int // Data given from depth generator. CV_CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1) CV_CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3) CV_CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1) CV_CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1) CV_CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1 // Data given from RGB image generator. CV_CAP_OPENNI_BGR_IMAGE = 5, CV_CAP_OPENNI_GRAY_IMAGE = 6; // Supported output modes of OpenNI image generator /** enum */ public static final int CV_CAP_OPENNI_VGA_30HZ = 0, CV_CAP_OPENNI_SXGA_15HZ = 1, CV_CAP_OPENNI_SXGA_30HZ = 2, CV_CAP_OPENNI_QVGA_30HZ = 3, CV_CAP_OPENNI_QVGA_60HZ = 4; //supported by Android camera output formats /** enum */ public static final int CV_CAP_ANDROID_COLOR_FRAME_BGR = 0, //BGR CV_CAP_ANDROID_COLOR_FRAME = CV_CAP_ANDROID_COLOR_FRAME_BGR, CV_CAP_ANDROID_GREY_FRAME = 1, //Y CV_CAP_ANDROID_COLOR_FRAME_RGB = 2, CV_CAP_ANDROID_COLOR_FRAME_BGRA = 3, CV_CAP_ANDROID_COLOR_FRAME_RGBA = 4; // supported Android camera flash modes /** enum */ public static final int CV_CAP_ANDROID_FLASH_MODE_AUTO = 0, CV_CAP_ANDROID_FLASH_MODE_OFF = 1, CV_CAP_ANDROID_FLASH_MODE_ON = 2, CV_CAP_ANDROID_FLASH_MODE_RED_EYE = 3, CV_CAP_ANDROID_FLASH_MODE_TORCH = 4; // supported Android camera focus modes /** enum */ public static final int CV_CAP_ANDROID_FOCUS_MODE_AUTO = 0, CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO = 1, CV_CAP_ANDROID_FOCUS_MODE_EDOF = 2, CV_CAP_ANDROID_FOCUS_MODE_FIXED = 3, CV_CAP_ANDROID_FOCUS_MODE_INFINITY = 4, CV_CAP_ANDROID_FOCUS_MODE_MACRO = 5; // supported Android camera white balance modes /** enum */ public static final int CV_CAP_ANDROID_WHITE_BALANCE_AUTO = 0, CV_CAP_ANDROID_WHITE_BALANCE_CLOUDY_DAYLIGHT = 1, CV_CAP_ANDROID_WHITE_BALANCE_DAYLIGHT = 2, CV_CAP_ANDROID_WHITE_BALANCE_FLUORESCENT = 3, CV_CAP_ANDROID_WHITE_BALANCE_INCANDESCENT = 4, CV_CAP_ANDROID_WHITE_BALANCE_SHADE = 5, CV_CAP_ANDROID_WHITE_BALANCE_TWILIGHT = 6, CV_CAP_ANDROID_WHITE_BALANCE_WARM_FLUORESCENT = 7; // supported Android camera antibanding modes /** enum */ public static final int CV_CAP_ANDROID_ANTIBANDING_50HZ = 0, CV_CAP_ANDROID_ANTIBANDING_60HZ = 1, CV_CAP_ANDROID_ANTIBANDING_AUTO = 2, CV_CAP_ANDROID_ANTIBANDING_OFF = 3; /** enum */ public static final int CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. CV_CAP_INTELPERC_IMAGE = 3; /* retrieve or set capture properties */ public static native double cvGetCaptureProperty( CvCapture capture, int property_id ); public static native int cvSetCaptureProperty( CvCapture capture, int property_id, double value ); // Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP), which is unknown if created with CV_CAP_ANY public static native int cvGetCaptureDomain( CvCapture capture); /* "black box" video file writer structure */ @Opaque public static class CvVideoWriter extends Pointer { public CvVideoWriter() { } public CvVideoWriter(Pointer p) { super(p); } } // #define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24)) public static native int CV_FOURCC(@Cast("char") byte c1, @Cast("char") byte c2, @Cast("char") byte c3, @Cast("char") byte c4); public static final int CV_FOURCC_PROMPT = -1; /* Open Codec Selection Dialog (Windows only) */ public static native @MemberGetter int CV_FOURCC_DEFAULT(); public static final int CV_FOURCC_DEFAULT = CV_FOURCC_DEFAULT(); /* Use default codec for specified filename (Linux only) */ /* initialize video file writer */ public static native CvVideoWriter cvCreateVideoWriter( @Cast("const char*") BytePointer filename, int fourcc, double fps, @ByVal CvSize frame_size, int is_color/*CV_DEFAULT(1)*/); public static native CvVideoWriter cvCreateVideoWriter( @Cast("const char*") BytePointer filename, int fourcc, double fps, @ByVal CvSize frame_size); public static native CvVideoWriter cvCreateVideoWriter( String filename, int fourcc, double fps, @ByVal CvSize frame_size, int is_color/*CV_DEFAULT(1)*/); public static native CvVideoWriter cvCreateVideoWriter( String filename, int fourcc, double fps, @ByVal CvSize frame_size); //CVAPI(CvVideoWriter*) cvCreateImageSequenceWriter( const char* filename, // int is_color CV_DEFAULT(1)); /* write frame to video file */ public static native int cvWriteFrame( CvVideoWriter writer, @Const IplImage image ); /* close video file writer */ public static native void cvReleaseVideoWriter( @Cast("CvVideoWriter**") PointerPointer writer ); public static native void cvReleaseVideoWriter( @ByPtrPtr CvVideoWriter writer ); /****************************************************************************************\ * Obsolete functions/synonyms * \****************************************************************************************/ public static native CvCapture cvCaptureFromFile(@Cast("const char*") BytePointer arg1); public static native CvCapture cvCaptureFromFile(String arg1); public static native CvCapture cvCaptureFromCAM(int arg1); public static native CvCapture cvCaptureFromAVI(@Cast("const char*") BytePointer arg1); public static native CvCapture cvCaptureFromAVI(String arg1); public static native CvVideoWriter cvCreateAVIWriter(@Cast("const char*") BytePointer arg1, int arg2, double arg3, @ByVal CvSize arg4, int arg5); public static native CvVideoWriter cvCreateAVIWriter(String arg1, int arg2, double arg3, @ByVal CvSize arg4, int arg5); public static native int cvWriteToAVI(CvVideoWriter arg1, IplImage arg2); public static native void cvAddSearchPath(@Cast("const char*") BytePointer path); public static native void cvAddSearchPath(String path); public static native int cvvInitSystem(int arg1, @Cast("char**") PointerPointer arg2); public static native int cvvInitSystem(int arg1, @Cast("char**") @ByPtrPtr BytePointer arg2); public static native int cvvInitSystem(int arg1, @Cast("char**") @ByPtrPtr ByteBuffer arg2); public static native int cvvInitSystem(int arg1, @Cast("char**") @ByPtrPtr byte[] arg2); public static native void cvvNamedWindow(@Cast("const char*") BytePointer arg1, int arg2); public static native void cvvNamedWindow(String arg1, int arg2); public static native void cvvShowImage(@Cast("const char*") BytePointer arg1, CvArr arg2); public static native void cvvShowImage(String arg1, CvArr arg2); public static native void cvvResizeWindow(@Cast("const char*") BytePointer arg1, int arg2, int arg3); public static native void cvvResizeWindow(String arg1, int arg2, int arg3); public static native void cvvDestroyWindow(@Cast("const char*") BytePointer arg1); public static native void cvvDestroyWindow(String arg1); public static native int cvvCreateTrackbar(@Cast("const char*") BytePointer arg1, @Cast("const char*") BytePointer arg2, IntPointer arg3, int arg4, CvTrackbarCallback arg5); public static native int cvvCreateTrackbar(String arg1, String arg2, IntBuffer arg3, int arg4, CvTrackbarCallback arg5); public static native int cvvCreateTrackbar(@Cast("const char*") BytePointer arg1, @Cast("const char*") BytePointer arg2, int[] arg3, int arg4, CvTrackbarCallback arg5); public static native int cvvCreateTrackbar(String arg1, String arg2, IntPointer arg3, int arg4, CvTrackbarCallback arg5); public static native int cvvCreateTrackbar(@Cast("const char*") BytePointer arg1, @Cast("const char*") BytePointer arg2, IntBuffer arg3, int arg4, CvTrackbarCallback arg5); public static native int cvvCreateTrackbar(String arg1, String arg2, int[] arg3, int arg4, CvTrackbarCallback arg5); public static native IplImage cvvLoadImage(@Cast("const char*") BytePointer name); public static native IplImage cvvLoadImage(String name); public static native int cvvSaveImage(@Cast("const char*") BytePointer arg1, CvArr arg2, IntPointer arg3); public static native int cvvSaveImage(String arg1, CvArr arg2, IntBuffer arg3); public static native int cvvSaveImage(@Cast("const char*") BytePointer arg1, CvArr arg2, int[] arg3); public static native int cvvSaveImage(String arg1, CvArr arg2, IntPointer arg3); public static native int cvvSaveImage(@Cast("const char*") BytePointer arg1, CvArr arg2, IntBuffer arg3); public static native int cvvSaveImage(String arg1, CvArr arg2, int[] arg3); public static native void cvvAddSearchPath(@Cast("const char*") BytePointer arg1); public static native void cvvAddSearchPath(String arg1); public static native int cvvWaitKey(@Cast("const char*") BytePointer name); public static native int cvvWaitKey(String name); public static native int cvvWaitKeyEx(@Cast("const char*") BytePointer name, int delay); public static native int cvvWaitKeyEx(String name, int delay); public static native void cvvConvertImage(CvArr arg1, CvArr arg2, int arg3); public static final int HG_AUTOSIZE = CV_WINDOW_AUTOSIZE; // #define set_preprocess_func cvSetPreprocessFuncWin32 // #define set_postprocess_func cvSetPostprocessFuncWin32 // #if defined WIN32 || defined _WIN32 // #endif // #ifdef __cplusplus // #endif // #endif // Parsed from /usr/local/include/opencv2/highgui/highgui.hpp /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of the copyright holders may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/ // #ifndef __OPENCV_HIGHGUI_HPP__ // #define __OPENCV_HIGHGUI_HPP__ // #include "opencv2/core/core.hpp" // #include "opencv2/highgui/highgui_c.h" // #ifdef __cplusplus /** enum cv:: */ public static final int // Flags for namedWindow WINDOW_NORMAL = CV_WINDOW_NORMAL, // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size WINDOW_AUTOSIZE = CV_WINDOW_AUTOSIZE, // the user cannot resize the window, the size is constrainted by the image displayed WINDOW_OPENGL = CV_WINDOW_OPENGL, // window with opengl support // Flags for set / getWindowProperty WND_PROP_FULLSCREEN = CV_WND_PROP_FULLSCREEN, // fullscreen property WND_PROP_AUTOSIZE = CV_WND_PROP_AUTOSIZE, // autosize property WND_PROP_ASPECT_RATIO = CV_WND_PROP_ASPECTRATIO, // window's aspect ration WND_PROP_OPENGL = CV_WND_PROP_OPENGL; // opengl support @Namespace("cv") public static native void namedWindow(@StdString BytePointer winname, int flags/*=WINDOW_AUTOSIZE*/); @Namespace("cv") public static native void namedWindow(@StdString BytePointer winname); @Namespace("cv") public static native void namedWindow(@StdString String winname, int flags/*=WINDOW_AUTOSIZE*/); @Namespace("cv") public static native void namedWindow(@StdString String winname); @Namespace("cv") public static native void destroyWindow(@StdString BytePointer winname); @Namespace("cv") public static native void destroyWindow(@StdString String winname); @Namespace("cv") public static native void destroyAllWindows(); @Namespace("cv") public static native int startWindowThread(); @Namespace("cv") public static native int waitKey(int delay/*=0*/); @Namespace("cv") public static native int waitKey(); @Namespace("cv") public static native void imshow(@StdString BytePointer winname, @ByVal Mat mat); @Namespace("cv") public static native void imshow(@StdString String winname, @ByVal Mat mat); @Namespace("cv") public static native void resizeWindow(@StdString BytePointer winname, int width, int height); @Namespace("cv") public static native void resizeWindow(@StdString String winname, int width, int height); @Namespace("cv") public static native void moveWindow(@StdString BytePointer winname, int x, int y); @Namespace("cv") public static native void moveWindow(@StdString String winname, int x, int y); @Namespace("cv") public static native void setWindowProperty(@StdString BytePointer winname, int prop_id, double prop_value); @Namespace("cv") public static native void setWindowProperty(@StdString String winname, int prop_id, double prop_value);//YV @Namespace("cv") public static native double getWindowProperty(@StdString BytePointer winname, int prop_id); @Namespace("cv") public static native double getWindowProperty(@StdString String winname, int prop_id);//YV /** enum cv:: */ public static final int EVENT_MOUSEMOVE = 0, EVENT_LBUTTONDOWN = 1, EVENT_RBUTTONDOWN = 2, EVENT_MBUTTONDOWN = 3, EVENT_LBUTTONUP = 4, EVENT_RBUTTONUP = 5, EVENT_MBUTTONUP = 6, EVENT_LBUTTONDBLCLK = 7, EVENT_RBUTTONDBLCLK = 8, EVENT_MBUTTONDBLCLK = 9; /** enum cv:: */ public static final int EVENT_FLAG_LBUTTON = 1, EVENT_FLAG_RBUTTON = 2, EVENT_FLAG_MBUTTON = 4, EVENT_FLAG_CTRLKEY = 8, EVENT_FLAG_SHIFTKEY = 16, EVENT_FLAG_ALTKEY = 32; public static class MouseCallback extends FunctionPointer { static { Loader.load(); } public MouseCallback(Pointer p) { super(p); } protected MouseCallback() { allocate(); } private native void allocate(); public native void call(int event, int x, int y, int flags, Pointer userdata); } /** assigns callback for mouse events */ @Namespace("cv") public static native void setMouseCallback(@StdString BytePointer winname, MouseCallback onMouse, Pointer userdata/*=0*/); @Namespace("cv") public static native void setMouseCallback(@StdString BytePointer winname, MouseCallback onMouse); @Namespace("cv") public static native void setMouseCallback(@StdString String winname, MouseCallback onMouse, Pointer userdata/*=0*/); @Namespace("cv") public static native void setMouseCallback(@StdString String winname, MouseCallback onMouse); @Convention("CV_CDECL") public static class TrackbarCallback extends FunctionPointer { static { Loader.load(); } public TrackbarCallback(Pointer p) { super(p); } protected TrackbarCallback() { allocate(); } private native void allocate(); public native void call(int pos, Pointer userdata); } @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, IntPointer value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, IntPointer value, int count); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, IntBuffer value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, IntBuffer value, int count); @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, int[] value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, int[] value, int count); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, IntPointer value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, IntPointer value, int count); @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, IntBuffer value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString BytePointer trackbarname, @StdString BytePointer winname, IntBuffer value, int count); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, int[] value, int count, TrackbarCallback onChange/*=0*/, Pointer userdata/*=0*/); @Namespace("cv") public static native int createTrackbar(@StdString String trackbarname, @StdString String winname, int[] value, int count); @Namespace("cv") public static native int getTrackbarPos(@StdString BytePointer trackbarname, @StdString BytePointer winname); @Namespace("cv") public static native int getTrackbarPos(@StdString String trackbarname, @StdString String winname); @Namespace("cv") public static native void setTrackbarPos(@StdString BytePointer trackbarname, @StdString BytePointer winname, int pos); @Namespace("cv") public static native void setTrackbarPos(@StdString String trackbarname, @StdString String winname, int pos); // OpenGL support public static class OpenGlDrawCallback extends FunctionPointer { static { Loader.load(); } public OpenGlDrawCallback(Pointer p) { super(p); } protected OpenGlDrawCallback() { allocate(); } private native void allocate(); public native void call(Pointer userdata); } @Namespace("cv") public static native void setOpenGlDrawCallback(@StdString BytePointer winname, OpenGlDrawCallback onOpenGlDraw, Pointer userdata/*=0*/); @Namespace("cv") public static native void setOpenGlDrawCallback(@StdString BytePointer winname, OpenGlDrawCallback onOpenGlDraw); @Namespace("cv") public static native void setOpenGlDrawCallback(@StdString String winname, OpenGlDrawCallback onOpenGlDraw, Pointer userdata/*=0*/); @Namespace("cv") public static native void setOpenGlDrawCallback(@StdString String winname, OpenGlDrawCallback onOpenGlDraw); @Namespace("cv") public static native void setOpenGlContext(@StdString BytePointer winname); @Namespace("cv") public static native void setOpenGlContext(@StdString String winname); @Namespace("cv") public static native void updateWindow(@StdString BytePointer winname); @Namespace("cv") public static native void updateWindow(@StdString String winname); // < Deperecated @Namespace("cv") public static native void pointCloudShow(@StdString BytePointer winname, @Const @ByRef GlCamera camera, @Const @ByRef GlArrays arr); @Namespace("cv") public static native void pointCloudShow(@StdString String winname, @Const @ByRef GlCamera camera, @Const @ByRef GlArrays arr); @Namespace("cv") public static native void pointCloudShow(@StdString BytePointer winname, @Const @ByRef GlCamera camera, @ByVal Mat points, @ByVal Mat colors/*=noArray()*/); @Namespace("cv") public static native void pointCloudShow(@StdString BytePointer winname, @Const @ByRef GlCamera camera, @ByVal Mat points); @Namespace("cv") public static native void pointCloudShow(@StdString String winname, @Const @ByRef GlCamera camera, @ByVal Mat points, @ByVal Mat colors/*=noArray()*/); @Namespace("cv") public static native void pointCloudShow(@StdString String winname, @Const @ByRef GlCamera camera, @ByVal Mat points); // > //Only for Qt @Namespace("cv") public static native @ByVal CvFont fontQt(@StdString BytePointer nameFont, int pointSize/*=-1*/, @ByVal Scalar color/*=Scalar::all(0)*/, int weight/*=CV_FONT_NORMAL*/, int style/*=CV_STYLE_NORMAL*/, int spacing/*=0*/); @Namespace("cv") public static native @ByVal CvFont fontQt(@StdString BytePointer nameFont); @Namespace("cv") public static native @ByVal CvFont fontQt(@StdString String nameFont, int pointSize/*=-1*/, @ByVal Scalar color/*=Scalar::all(0)*/, int weight/*=CV_FONT_NORMAL*/, int style/*=CV_STYLE_NORMAL*/, int spacing/*=0*/); @Namespace("cv") public static native @ByVal CvFont fontQt(@StdString String nameFont); @Namespace("cv") public static native void addText( @Const @ByRef Mat img, @StdString BytePointer text, @ByVal Point org, @ByVal CvFont font); @Namespace("cv") public static native void addText( @Const @ByRef Mat img, @StdString String text, @ByVal Point org, @ByVal CvFont font); @Namespace("cv") public static native void displayOverlay(@StdString BytePointer winname, @StdString BytePointer text, int delayms/*CV_DEFAULT(0)*/); @Namespace("cv") public static native void displayOverlay(@StdString BytePointer winname, @StdString BytePointer text); @Namespace("cv") public static native void displayOverlay(@StdString String winname, @StdString String text, int delayms/*CV_DEFAULT(0)*/); @Namespace("cv") public static native void displayOverlay(@StdString String winname, @StdString String text); @Namespace("cv") public static native void displayStatusBar(@StdString BytePointer winname, @StdString BytePointer text, int delayms/*CV_DEFAULT(0)*/); @Namespace("cv") public static native void displayStatusBar(@StdString BytePointer winname, @StdString BytePointer text); @Namespace("cv") public static native void displayStatusBar(@StdString String winname, @StdString String text, int delayms/*CV_DEFAULT(0)*/); @Namespace("cv") public static native void displayStatusBar(@StdString String winname, @StdString String text); @Namespace("cv") public static native void saveWindowParameters(@StdString BytePointer windowName); @Namespace("cv") public static native void saveWindowParameters(@StdString String windowName); @Namespace("cv") public static native void loadWindowParameters(@StdString BytePointer windowName); @Namespace("cv") public static native void loadWindowParameters(@StdString String windowName); @Namespace("cv") public static native int startLoop(Pt2Func_int_PointerPointer pt2Func, int argc, @Cast("char**") PointerPointer argv); @Namespace("cv") public static native int startLoop(Pt2Func_int_BytePointer pt2Func, int argc, @Cast("char**") @ByPtrPtr BytePointer argv); @Namespace("cv") public static native int startLoop(Pt2Func_int_ByteBuffer pt2Func, int argc, @Cast("char**") @ByPtrPtr ByteBuffer argv); @Namespace("cv") public static native int startLoop(Pt2Func_int_byte__ pt2Func, int argc, @Cast("char**") @ByPtrPtr byte[] argv); @Namespace("cv") public static native void stopLoop(); @Convention("CV_CDECL") public static class ButtonCallback extends FunctionPointer { static { Loader.load(); } public ButtonCallback(Pointer p) { super(p); } protected ButtonCallback() { allocate(); } private native void allocate(); public native void call(int state, Pointer userdata); } @Namespace("cv") public static native int createButton( @StdString BytePointer bar_name, ButtonCallback on_change, Pointer userdata/*=NULL*/, int type/*=CV_PUSH_BUTTON*/, @Cast("bool") boolean initial_button_state/*=0*/); @Namespace("cv") public static native int createButton( @StdString BytePointer bar_name, ButtonCallback on_change); @Namespace("cv") public static native int createButton( @StdString String bar_name, ButtonCallback on_change, Pointer userdata/*=NULL*/, int type/*=CV_PUSH_BUTTON*/, @Cast("bool") boolean initial_button_state/*=0*/); @Namespace("cv") public static native int createButton( @StdString String bar_name, ButtonCallback on_change); //------------------------- /** enum cv:: */ public static final int // 8bit, color or not IMREAD_UNCHANGED = -1, // 8bit, gray IMREAD_GRAYSCALE = 0, // ?, color IMREAD_COLOR = 1, // any depth, ? IMREAD_ANYDEPTH = 2, // ?, any color IMREAD_ANYCOLOR = 4; /** enum cv:: */ public static final int IMWRITE_JPEG_QUALITY = 1, IMWRITE_PNG_COMPRESSION = 16, IMWRITE_PNG_STRATEGY = 17, IMWRITE_PNG_BILEVEL = 18, IMWRITE_PNG_STRATEGY_DEFAULT = 0, IMWRITE_PNG_STRATEGY_FILTERED = 1, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2, IMWRITE_PNG_STRATEGY_RLE = 3, IMWRITE_PNG_STRATEGY_FIXED = 4, IMWRITE_PXM_BINARY = 32; @Namespace("cv") public static native @ByVal Mat imread( @StdString BytePointer filename, int flags/*=1*/ ); @Namespace("cv") public static native @ByVal Mat imread( @StdString BytePointer filename ); @Namespace("cv") public static native @ByVal Mat imread( @StdString String filename, int flags/*=1*/ ); @Namespace("cv") public static native @ByVal Mat imread( @StdString String filename ); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString BytePointer filename, @ByVal Mat img, @StdVector IntPointer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString BytePointer filename, @ByVal Mat img); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString String filename, @ByVal Mat img, @StdVector IntBuffer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString String filename, @ByVal Mat img); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString BytePointer filename, @ByVal Mat img, @StdVector int[] params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString String filename, @ByVal Mat img, @StdVector IntPointer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString BytePointer filename, @ByVal Mat img, @StdVector IntBuffer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imwrite( @StdString String filename, @ByVal Mat img, @StdVector int[] params/*=vector<int>()*/); @Namespace("cv") public static native @ByVal Mat imdecode( @ByVal Mat buf, int flags ); @Namespace("cv") public static native @ByVal Mat imdecode( @ByVal Mat buf, int flags, Mat dst ); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector BytePointer buf, @StdVector IntPointer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector BytePointer buf); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector ByteBuffer buf, @StdVector IntBuffer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector ByteBuffer buf); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector byte[] buf, @StdVector int[] params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector byte[] buf); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector BytePointer buf, @StdVector IntPointer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector BytePointer buf); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector ByteBuffer buf, @StdVector IntBuffer params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString BytePointer ext, @ByVal Mat img, @Cast("uchar*") @StdVector ByteBuffer buf); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector byte[] buf, @StdVector int[] params/*=vector<int>()*/); @Namespace("cv") public static native @Cast("bool") boolean imencode( @StdString String ext, @ByVal Mat img, @Cast("uchar*") @StdVector byte[] buf); // #ifndef CV_NO_VIDEO_CAPTURE_CPP_API @Namespace("cv") @NoOffset public static class VideoCapture extends Pointer { static { Loader.load(); } public VideoCapture(Pointer p) { super(p); } public VideoCapture() { allocate(); } private native void allocate(); public VideoCapture(@StdString BytePointer filename) { allocate(filename); } private native void allocate(@StdString BytePointer filename); public VideoCapture(@StdString String filename) { allocate(filename); } private native void allocate(@StdString String filename); public VideoCapture(int device) { allocate(device); } private native void allocate(int device); public native @Cast("bool") boolean open(@StdString BytePointer filename); public native @Cast("bool") boolean open(@StdString String filename); public native @Cast("bool") boolean open(int device); public native @Cast("bool") boolean isOpened(); public native void release(); public native @Cast("bool") boolean grab(); public native @Cast("bool") boolean retrieve(@ByRef Mat image, int channel/*=0*/); public native @Cast("bool") boolean retrieve(@ByRef Mat image); public native @ByRef @Name("operator>>") VideoCapture shiftRight(@ByRef Mat image); public native @Cast("bool") boolean read(@ByRef Mat image); public native @Cast("bool") boolean set(int propId, double value); public native double get(int propId); } @Namespace("cv") @NoOffset public static class VideoWriter extends Pointer { static { Loader.load(); } public VideoWriter(Pointer p) { super(p); } public VideoWriter(int size) { allocateArray(size); } private native void allocateArray(int size); @Override public VideoWriter position(int position) { return (VideoWriter)super.position(position); } public VideoWriter() { allocate(); } private native void allocate(); public VideoWriter(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/) { allocate(filename, fourcc, fps, frameSize, isColor); } private native void allocate(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/); public VideoWriter(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize) { allocate(filename, fourcc, fps, frameSize); } private native void allocate(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize); public VideoWriter(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/) { allocate(filename, fourcc, fps, frameSize, isColor); } private native void allocate(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/); public VideoWriter(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize) { allocate(filename, fourcc, fps, frameSize); } private native void allocate(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize); public native @Cast("bool") boolean open(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/); public native @Cast("bool") boolean open(@StdString BytePointer filename, int fourcc, double fps, @ByVal Size frameSize); public native @Cast("bool") boolean open(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize, @Cast("bool") boolean isColor/*=true*/); public native @Cast("bool") boolean open(@StdString String filename, int fourcc, double fps, @ByVal Size frameSize); public native @Cast("bool") boolean isOpened(); public native void release(); public native @ByRef @Name("operator<<") VideoWriter shiftLeft(@Const @ByRef Mat image); public native void write(@Const @ByRef Mat image); } // #endif // #endif // #endif }
gpl-2.0
janschulz/pandoc
tests/Tests/Arbitrary.hs
8350
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, ScopedTypeVariables #-} -- provides Arbitrary instance for Pandoc types module Tests.Arbitrary () where import Test.QuickCheck.Gen import Test.QuickCheck.Arbitrary import Control.Monad (liftM, liftM2) import Text.Pandoc.Definition import Text.Pandoc.Shared (normalize, escapeURI) import Text.Pandoc.Builder realString :: Gen String realString = resize 8 $ listOf $ frequency [ (9, elements [' '..'\127']) , (1, elements ['\128'..'\9999']) ] arbAttr :: Gen Attr arbAttr = do id' <- elements ["","loc"] classes <- elements [[],["haskell"],["c","numberLines"]] keyvals <- elements [[],[("start","22")],[("a","11"),("b_2","a b c")]] return (id',classes,keyvals) instance Arbitrary Inlines where arbitrary = liftM (fromList :: [Inline] -> Inlines) arbitrary instance Arbitrary Blocks where arbitrary = liftM (fromList :: [Block] -> Blocks) arbitrary instance Arbitrary Inline where arbitrary = resize 3 $ arbInline 2 arbInlines :: Int -> Gen [Inline] arbInlines n = listOf1 (arbInline n) `suchThat` (not . startsWithSpace) where startsWithSpace (Space:_) = True startsWithSpace _ = False -- restrict to 3 levels of nesting max; otherwise we get -- bogged down in indefinitely large structures arbInline :: Int -> Gen Inline arbInline n = frequency $ [ (60, liftM Str realString) , (60, return Space) , (10, liftM2 Code arbAttr realString) , (5, elements [ RawInline (Format "html") "<a id=\"eek\">" , RawInline (Format "latex") "\\my{command}" ]) ] ++ [ x | x <- nesters, n > 1] where nesters = [ (10, liftM Emph $ arbInlines (n-1)) , (10, liftM Strong $ arbInlines (n-1)) , (10, liftM Strikeout $ arbInlines (n-1)) , (10, liftM Superscript $ arbInlines (n-1)) , (10, liftM Subscript $ arbInlines (n-1)) , (10, liftM SmallCaps $ arbInlines (n-1)) , (10, do x1 <- arbitrary x2 <- arbInlines (n-1) return $ Quoted x1 x2) , (10, do x1 <- arbitrary x2 <- realString return $ Math x1 x2) , (10, do x0 <- arbAttr x1 <- arbInlines (n-1) x3 <- realString x2 <- liftM escapeURI realString return $ Link x0 x1 (x2,x3)) , (10, do x0 <- arbAttr x1 <- arbInlines (n-1) x3 <- realString x2 <- liftM escapeURI realString return $ Image x0 x1 (x2,x3)) , (2, liftM2 Cite arbitrary (arbInlines 1)) , (2, liftM Note $ resize 3 $ listOf1 $ arbBlock (n-1)) ] instance Arbitrary Block where arbitrary = resize 3 $ arbBlock 2 arbBlock :: Int -> Gen Block arbBlock n = frequency $ [ (10, liftM Plain $ arbInlines (n-1)) , (15, liftM Para $ arbInlines (n-1)) , (5, liftM2 CodeBlock arbAttr realString) , (2, elements [ RawBlock (Format "html") "<div>\n*&amp;*\n</div>" , RawBlock (Format "latex") "\\begin[opt]{env}\nhi\n{\\end{env}" ]) , (5, do x1 <- choose (1 :: Int, 6) x2 <- arbInlines (n-1) return (Header x1 nullAttr x2)) , (2, return HorizontalRule) ] ++ [x | x <- nesters, n > 0] where nesters = [ (5, liftM BlockQuote $ listOf1 $ arbBlock (n-1)) , (5, do x2 <- arbitrary x3 <- arbitrary x1 <- arbitrary `suchThat` (> 0) x4 <- listOf1 $ listOf1 $ arbBlock (n-1) return $ OrderedList (x1,x2,x3) x4 ) , (5, liftM BulletList $ (listOf1 $ listOf1 $ arbBlock (n-1))) , (5, do items <- listOf1 $ do x1 <- listOf1 $ listOf1 $ arbBlock (n-1) x2 <- arbInlines (n-1) return (x2,x1) return $ DefinitionList items) , (2, do rs <- choose (1 :: Int, 4) cs <- choose (1 :: Int, 4) x1 <- arbInlines (n-1) x2 <- vector cs x3 <- vectorOf cs $ elements [0, 0.25] x4 <- vectorOf cs $ listOf $ arbBlock (n-1) x5 <- vectorOf rs $ vectorOf cs $ listOf $ arbBlock (n-1) return (Table x1 x2 x3 x4 x5)) ] instance Arbitrary Pandoc where arbitrary = resize 8 $ liftM normalize $ liftM2 Pandoc arbitrary arbitrary instance Arbitrary CitationMode where arbitrary = do x <- choose (0 :: Int, 2) case x of 0 -> return AuthorInText 1 -> return SuppressAuthor 2 -> return NormalCitation _ -> error "FATAL ERROR: Arbitrary instance, logic bug" instance Arbitrary Citation where arbitrary = do x1 <- listOf $ elements $ ['a'..'z'] ++ ['0'..'9'] ++ ['_'] x2 <- arbInlines 1 x3 <- arbInlines 1 x4 <- arbitrary x5 <- arbitrary x6 <- arbitrary return (Citation x1 x2 x3 x4 x5 x6) instance Arbitrary MathType where arbitrary = do x <- choose (0 :: Int, 1) case x of 0 -> return DisplayMath 1 -> return InlineMath _ -> error "FATAL ERROR: Arbitrary instance, logic bug" instance Arbitrary QuoteType where arbitrary = do x <- choose (0 :: Int, 1) case x of 0 -> return SingleQuote 1 -> return DoubleQuote _ -> error "FATAL ERROR: Arbitrary instance, logic bug" instance Arbitrary Meta where arbitrary = do (x1 :: Inlines) <- arbitrary (x2 :: [Inlines]) <- liftM (filter (not . isNull)) arbitrary (x3 :: Inlines) <- arbitrary return $ setMeta "title" x1 $ setMeta "author" x2 $ setMeta "date" x3 $ nullMeta instance Arbitrary Alignment where arbitrary = do x <- choose (0 :: Int, 3) case x of 0 -> return AlignLeft 1 -> return AlignRight 2 -> return AlignCenter 3 -> return AlignDefault _ -> error "FATAL ERROR: Arbitrary instance, logic bug" instance Arbitrary ListNumberStyle where arbitrary = do x <- choose (0 :: Int, 6) case x of 0 -> return DefaultStyle 1 -> return Example 2 -> return Decimal 3 -> return LowerRoman 4 -> return UpperRoman 5 -> return LowerAlpha 6 -> return UpperAlpha _ -> error "FATAL ERROR: Arbitrary instance, logic bug" instance Arbitrary ListNumberDelim where arbitrary = do x <- choose (0 :: Int, 3) case x of 0 -> return DefaultDelim 1 -> return Period 2 -> return OneParen 3 -> return TwoParens _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
gpl-2.0
hook42/towel
modules/contrib/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php
4942
<?php namespace Drupal\admin_toolbar_tools\Controller; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\CronInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Drupal\Core\Menu\ContextualLinkManager; use Drupal\Core\Menu\LocalActionManager; use Drupal\Core\Menu\LocalTaskManager; use Drupal\Core\Menu\MenuLinkManager; /** * Class ToolbarController * @package Drupal\admin_toolbar_tools\Controller */ class ToolbarController extends ControllerBase { /** * The cron service. * * @var $cron \Drupal\Core\CronInterface */ protected $cron; protected $menuLinkManager; protected $contextualLinkManager; protected $localTaskLinkManager; protected $localActionLinkManager; protected $cacheRender; /** * Constructs a CronController object. * * @param \Drupal\Core\CronInterface $cron * The cron service. */ public function __construct(CronInterface $cron, MenuLinkManager $menuLinkManager, ContextualLinkManager $contextualLinkManager, LocalTaskManager $localTaskLinkManager, LocalActionManager $localActionLinkManager, CacheBackendInterface $cacheRender) { $this->cron = $cron; $this->menuLinkManager = $menuLinkManager; $this->contextualLinkManager = $contextualLinkManager; $this->localTaskLinkManager = $localTaskLinkManager; $this->localActionLinkManager = $localActionLinkManager; $this->cacheRender = $cacheRender; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('cron'), $container->get('plugin.manager.menu.link'), $container->get('plugin.manager.menu.contextual_link'), $container->get('plugin.manager.menu.local_task'), $container->get('plugin.manager.menu.local_action'), $container->get('cache.render') ); } // Reload the previous page. public function reload_page() { $request = \Drupal::request(); if($request->server->get('HTTP_REFERER')) { return $request->server->get('HTTP_REFERER'); } else{ return '/'; } } // Flushes all caches. public function flushAll() { drupal_flush_all_caches(); drupal_set_message($this->t('All caches cleared.')); return new RedirectResponse($this->reload_page()); } // Flushes css and javascript caches. public function flush_js_css() { \Drupal::state() ->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); drupal_set_message($this->t('CSS and JavaScript cache cleared.')); return new RedirectResponse($this->reload_page()); } // Flushes plugins caches. public function flush_plugins() { \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); drupal_set_message($this->t('Plugins cache cleared.')); return new RedirectResponse($this->reload_page()); } // Resets all static caches. public function flush_static() { drupal_static_reset(); drupal_set_message($this->t('Static cache cleared.')); return new RedirectResponse($this->reload_page()); } // Clears all cached menu data. public function flush_menu() { menu_cache_clear_all(); $this->menuLinkManager->rebuild(); $this->contextualLinkManager->clearCachedDefinitions(); $this->localTaskLinkManager->clearCachedDefinitions(); $this->localActionLinkManager->clearCachedDefinitions(); drupal_set_message($this->t('Routing and links cache cleared.')); return new RedirectResponse($this->reload_page()); } // Links to drupal.org home page. public function drupal_org() { $response = new RedirectResponse("https://www.drupal.org"); $response->send(); return $response; } // Displays the administration link Development. public function development() { return new RedirectResponse('/admin/structure/menu/'); } // Access to Drupal 8 changes (list changes of the different versions of drupal core). public function list_changes() { $response = new RedirectResponse("https://www.drupal.org/list-changes"); $response->send(); return $response; } // Adds a link to the Drupal 8 documentation. public function documentation() { $response = new RedirectResponse("https://api.drupal.org/api/drupal/8"); $response->send(); return $response; } public function runCron() { $this->cron->run(); drupal_set_message($this->t('CRON ran successfully.')); return new RedirectResponse($this->reload_page()); } public function cacheRender() { $this->cacheRender->invalidateAll(); drupal_set_message($this->t('Render cache cleared.')); return new RedirectResponse($this->reload_page()); } }
gpl-2.0
ShevT/android_kernel_d1_p1
arch/arm/mach-omap2/Makefile
12478
################################################################################ # Edit History # # ÎÊÌâµ¥ ÐÞ¸ÄÈË ÈÕÆÚ Ô­Òò ################################################################################ # # Makefile for the linux kernel. # # FIXME: For OMAP4 target - the sequence of Obj-files inclusion in # Makefile is strictly related to sequence of the Kernel xxx_initcall # functions calls. Any changes in the sequence of Obj-files inclusion # in this file should be done carefully and can cause unpredictable # system behaviour - especially it can have impact on OMAP4 PM # initialization procedure. # # Known valid sequence: # - pm.o # - sr_device.o # - smartreflex.o # - smartreflex-class3.o # - smartreflex-class1p5.o # - pm44xx.o # Common support obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \ common.o gpio.o dma.o wd_timer.o omap_pmic.o dmtimer.o omap-2-3-common = irq.o sdrc.o hwmod-common = omap_hwmod.o \ omap_hwmod_common_data.o clock-common = clock.o clock_common_data.o \ clkt_dpll.o clkt_clksel.o obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(hwmod-common) obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(hwmod-common) obj-$(CONFIG_ARCH_OMAP4) += prm44xx.o $(hwmod-common) #obj-$(CONFIG_ARCH_OMAP4) += emif.o lpddr2_jedec_data.o lpddr2_elpida_data.o # EMIF obj-$(CONFIG_ARCH_OMAP4) += emif.o lpddr2_jedec_data.o #LPDDR2 obj-$(CONFIG_ELPIDA_DDR_2G_S4) += lpddr2_elpida_data.o obj-$(CONFIG_SAMSUNG_DDR_4G_S4) += lpddr2_samsung_data.o obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o obj-$(CONFIG_TWL4030_CORE) += omap_twl.o obj-$(CONFIG_OMAP_TPS6236X) += omap_tps6236x.o obj-$(CONFIG_OMAP_TEMP_SENSOR) +=temp_sensor_device.o obj-$(CONFIG_OMAP4_PCB_SENSOR) += pcb_temp_sensor_device.o # SMP support ONLY available for OMAP4 obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o obj-$(CONFIG_LOCAL_TIMERS) += timer-mpu.o obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o obj-$(CONFIG_ARCH_OMAP4) += omap44xx-smc.o omap4-common.o \ omap-wakeupgen.o plus_sec := $(call as-instr,.arch_extension sec,+sec) AFLAGS_omap-headsmp.o :=-Wa,-march=armv7-a$(plus_sec) AFLAGS_omap44xx-smc.o :=-Wa,-march=armv7-a$(plus_sec) # Functions loaded to SRAM obj-$(CONFIG_SOC_OMAP2420) += sram242x.o obj-$(CONFIG_SOC_OMAP2430) += sram243x.o obj-$(CONFIG_ARCH_OMAP3) += sram34xx.o AFLAGS_sram242x.o :=-Wa,-march=armv6 AFLAGS_sram243x.o :=-Wa,-march=armv6 AFLAGS_sram34xx.o :=-Wa,-march=armv7-a # Pin multiplexing obj-$(CONFIG_SOC_OMAP2420) += mux2420.o obj-$(CONFIG_SOC_OMAP2430) += mux2430.o obj-$(CONFIG_ARCH_OMAP3) += mux34xx.o obj-$(CONFIG_ARCH_OMAP4) += mux44xx.o # SMS/SDRC obj-$(CONFIG_ARCH_OMAP2) += sdrc2xxx.o # obj-$(CONFIG_ARCH_OMAP3) += sdrc3xxx.o # OPP table initialization ifeq ($(CONFIG_PM_OPP),y) obj-y += opp.o obj-$(CONFIG_ARCH_OMAP3) += opp3xxx_data.o obj-$(CONFIG_ARCH_OMAP4) += opp4xxx_data.o endif # Smartreflex AVS initialization obj-$(CONFIG_OMAP_SMARTREFLEX) += sr_device.o smartreflex.o obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3) += smartreflex-class3.o obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS1P5) += smartreflex-class1p5.o # CPUFREQ driver obj-$(CONFIG_CPU_FREQ) += omap2plus-cpufreq.o # Power Management ifeq ($(CONFIG_PM),y) obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o \ cpuidle34xx.o obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o \ omap4-mpuss-lowpower.o sleep44xx.o \ cpuidle44xx.o resetreason.o obj-$(CONFIG_PM_DEBUG) += pm-debug.o ifeq ($(CONFIG_PM_DEBUG),y) obj-$(CONFIG_ARCH_OMAP4) += prcm-debug.o endif AFLAGS_sleep24xx.o :=-Wa,-march=armv6 AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec) AFLAGS_sleep44xx.o :=-Wa,-march=armv7-a$(plus_sec) ifeq ($(CONFIG_PM_VERBOSE),y) CFLAGS_pm_bus.o += -DDEBUG endif endif # PRCM obj-$(CONFIG_ARCH_OMAP2) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o obj-$(CONFIG_ARCH_OMAP3) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o \ vc3xxx_data.o vp3xxx_data.o # XXX The presence of cm2xxx_3xxx.o on the line below is temporary and # will be removed once the OMAP4 part of the codebase is converted to # use OMAP4-specific PRCM functions. obj-$(CONFIG_ARCH_OMAP4) += prcm.o cm2xxx_3xxx.o cminst44xx.o \ cm44xx.o prcm_mpu44xx.o \ prminst44xx.o vc44xx_data.o \ vp44xx_data.o omap4-sar.o # OMAP voltage domains ifeq ($(CONFIG_PM),y) voltagedomain-common := voltage.o vc.o vp.o obj-$(CONFIG_ARCH_OMAP2) += $(voltagedomain-common) \ voltagedomains2xxx_data.o obj-$(CONFIG_ARCH_OMAP3) += $(voltagedomain-common) \ voltagedomains3xxx_data.o \ ldo.o ldo3xxx_data.o dvfs.o obj-$(CONFIG_ARCH_OMAP4) += $(voltagedomain-common) \ voltagedomains44xx_data.o \ ldo.o ldo4xxx_data.o dvfs.o endif # OMAP powerdomain framework powerdomain-common += powerdomain.o powerdomain-common.o obj-$(CONFIG_ARCH_OMAP2) += $(powerdomain-common) \ powerdomain2xxx_3xxx.o \ powerdomains2xxx_data.o \ powerdomains2xxx_3xxx_data.o obj-$(CONFIG_ARCH_OMAP3) += $(powerdomain-common) \ powerdomain2xxx_3xxx.o \ powerdomains3xxx_data.o \ powerdomains2xxx_3xxx_data.o obj-$(CONFIG_ARCH_OMAP4) += $(powerdomain-common) \ powerdomain44xx.o \ powerdomains44xx_data.o # PRCM clockdomain control obj-$(CONFIG_ARCH_OMAP2) += clockdomain.o \ clockdomain2xxx_3xxx.o \ clockdomains2xxx_3xxx_data.o obj-$(CONFIG_ARCH_OMAP3) += clockdomain.o \ clockdomain2xxx_3xxx.o \ clockdomains2xxx_3xxx_data.o obj-$(CONFIG_ARCH_OMAP4) += clockdomain.o \ clockdomain44xx.o \ clockdomains44xx_data.o # Clock framework obj-$(CONFIG_ARCH_OMAP2) += $(clock-common) clock2xxx.o \ clkt2xxx_sys.o \ clkt2xxx_dpllcore.o \ clkt2xxx_virt_prcm_set.o \ clkt2xxx_apll.o clkt2xxx_osc.o \ clkt2xxx_dpll.o clkt_iclk.o obj-$(CONFIG_SOC_OMAP2420) += clock2420_data.o obj-$(CONFIG_SOC_OMAP2430) += clock2430.o clock2430_data.o obj-$(CONFIG_ARCH_OMAP3) += $(clock-common) clock3xxx.o \ clock34xx.o clkt34xx_dpll3m2.o \ clock3517.o clock36xx.o \ dpll3xxx.o clock3xxx_data.o \ clkt_iclk.o obj-$(CONFIG_ARCH_OMAP4) += $(clock-common) clock44xx_data.o \ dpll3xxx.o dpll44xx.o # OMAP2 clock rate set data (old "OPP" data) obj-$(CONFIG_SOC_OMAP2420) += opp2420_data.o obj-$(CONFIG_SOC_OMAP2430) += opp2430_data.o # hwmod data obj-$(CONFIG_SOC_OMAP2420) += omap_hwmod_2420_data.o obj-$(CONFIG_SOC_OMAP2430) += omap_hwmod_2430_data.o obj-$(CONFIG_ARCH_OMAP3) += omap_hwmod_3xxx_data.o obj-$(CONFIG_ARCH_OMAP4) += omap_hwmod_44xx_data.o # EMU peripherals obj-$(CONFIG_OMAP3_EMU) += emu.o # L3 interconnect obj-$(CONFIG_ARCH_OMAP3) += omap_l3_smx.o obj-$(CONFIG_ARCH_OMAP4) += omap_l3_noc.o # LDO stuff obj-$(CONFIG_ARCH_OMAP4) += omap4_trim_quirks.o obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o mailbox_mach-objs := mailbox.o obj-$(CONFIG_OMAP_IOMMU) += iommu2.o omap-iommu.o i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o obj-y += $(i2c-omap-m) $(i2c-omap-y) ifneq ($(CONFIG_TIDSPBRIDGE),) obj-y += dsp.o endif # Specific board support obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \ hsmmc.o obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP_LDP) += board-ldp.o \ board-flash.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP3530_LV_SOM) += board-omap3logic.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP3_TORPEDO) += board-omap3logic.o \ hsmmc.o obj-$(CONFIG_MACH_OVERO) += board-overo.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP3EVM) += board-omap3evm.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP3_PANDORA) += board-omap3pandora.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP_3430SDP) += board-3430sdp.o \ hsmmc.o \ board-flash.o obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0.o obj-$(CONFIG_MACH_NOKIA_RM680) += board-rm680.o \ sdram-nokia.o \ hsmmc.o obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51.o \ sdram-nokia.o \ board-rx51-peripherals.o \ board-rx51-video.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP_ZOOM2) += board-zoom.o \ board-zoom-peripherals.o \ board-zoom-display.o \ board-flash.o \ hsmmc.o \ board-zoom-debugboard.o obj-$(CONFIG_MACH_OMAP_ZOOM3) += board-zoom.o \ board-zoom-peripherals.o \ board-zoom-display.o \ board-flash.o \ hsmmc.o \ board-zoom-debugboard.o obj-$(CONFIG_MACH_OMAP_3630SDP) += board-3630sdp.o \ board-zoom-peripherals.o \ board-zoom-display.o \ board-flash.o \ hsmmc.o obj-$(CONFIG_MACH_CM_T35) += board-cm-t35.o \ hsmmc.o obj-$(CONFIG_MACH_CM_T3517) += board-cm-t3517.o obj-$(CONFIG_MACH_IGEP0020) += board-igep0020.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK) += board-omap3touchbook.o \ hsmmc.o obj-$(CONFIG_MACH_OMAP_4430SDP) += board-4430sdp.o \ board-blaze-touch.o \ board-blaze-panel.o \ board-blaze-keypad.o \ board-blaze-sensors.o \ board-blaze-modem.o \ board-44xx-identity.o \ board-44xx-power.o \ board-44xx-serial.o \ hsmmc.o \ omap_phy_internal.o \ omap4_apps_brd_id.o obj-$(CONFIG_MACH_OMAP_BLAZE) += board-44xx-tablet.o \ board-44xx-identity.o \ board-44xx-power.o \ board-44xx-serial.o \ board-44xx-tablet-touch.o \ board-44xx-tablet-sensors.o \ board-44xx-tablet-panel.o \ board-44xx-tablet-buttons.o \ omap4_apps_brd_id.o obj-$(CONFIG_TOUCHSCREEN_CYPRESS_TTSP) += board-touch-cyttsp4_core.o obj-$(CONFIG_MACH_OMAP_XMM) += xmd.o ifneq ($(CONFIG_MACH_OMAP_XMM),) xmd-objs := xmd-boot-common.o ifneq ($(CONFIG_OMAP4_XMM_SPI),) xmd-objs += xmd-boot-spi.o xmd-spi.o xmd-mux.o xmd-smd.o smd_tty.o msm_rmnet.o endif ifneq ($(CONFIG_OMAP4_XMM_HSI),) xmd-objs += xmd-boot-hsi.o xmd-tty.o xmd-hsi-mcm.o xmd_hsi_mem.o xmd-rmnet.o xmd-hsi-ll.o endif ifneq ($(CONFIG_OMAP4_XMM_C2C),) xmd-objs += xmd-boot-c2c.o xmd-c2c.o endif endif obj-$(CONFIG_OMAP_C2C) += c2c-omap.o \ c2c-driver.o \ c2c-gen.o \ c2c-sscm.o ifneq ($(CONFIG_HSI_FLASHLESS_SUPPORT),) xmd-objs += xmd_boot_tty.o endif obj-$(CONFIG_MACH_OMAP4_PANDA) += board-omap4panda.o \ hsmmc.o \ board-44xx-identity.o \ omap4_apps_brd_id.o \ omap_phy_internal.o obj-$(CONFIG_MACH_OMAP3517EVM) += board-am3517evm.o \ omap_phy_internal.o \ ifeq ($(CONFIG_ARCH_OMAP4),y) obj-$(CONFIG_TIWLAN_SDIO) += board-4430sdp-wifi.o endif ifeq ($(CONFIG_ARCH_OMAP3),y) obj-$(CONFIG_TIWLAN_SDIO) += board-zoom2-wifi.o endif obj-$(CONFIG_MACH_OMAP3517EVM) += board-am3517evm.o obj-$(CONFIG_MACH_CRANEBOARD) += board-am3517crane.o obj-$(CONFIG_MACH_SBC3530) += board-omap3stalker.o \ hsmmc.o obj-$(CONFIG_MACH_TI8168EVM) += board-ti8168evm.o # Platform specific device init code usbfs-$(CONFIG_ARCH_OMAP_OTG) := usb-fs.o obj-y += $(usbfs-m) $(usbfs-y) obj-y += usb-musb.o obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o obj-y += usb-host.o onenand-$(CONFIG_MTD_ONENAND_OMAP2) := gpmc-onenand.o obj-y += $(onenand-m) $(onenand-y) nand-$(CONFIG_MTD_NAND_OMAP2) := gpmc-nand.o obj-y += $(nand-m) $(nand-y) smc91x-$(CONFIG_SMC91X) := gpmc-smc91x.o obj-y += $(smc91x-m) $(smc91x-y) smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o obj-y += $(smsc911x-m) $(smsc911x-y) obj-$(CONFIG_ARCH_OMAP4) += hwspinlock.o disp-$(CONFIG_OMAP2_DSS) := display.o obj-y += $(disp-m) $(disp-y) obj-y += common-board-devices.o obj-$(CONFIG_OMAP_REMOTE_PROC) += remoteproc.o obj-$(CONFIG_OMAP_HSI_DEVICE) += omap_hsi.o obj-$(CONFIG_ION_OMAP) += omap4_ion.o obj-$(CONFIG_ARCH_OMAP4) += omap_dmm.o obj-$(CONFIG_OMAP_FIQ_DEBUGGER) += omap_fiq_debugger.o ifeq ($(CONFIG_OMAP_REBOOT_REASON),y) obj-$(CONFIG_ARCH_OMAP4) += omap4-reboot-reason.o endif obj-$(CONFIG_OMAP_RAM_CONSOLE) += omap_ram_console.o obj-$(CONFIG_ARCH_OMAP4) += omap_gcxxx.o
gpl-2.0
chusopr/kdepim-ktimetracker-akonadi
kleopatra/conf/smimevalidationconfigurationpage.h
2240
/* -*- mode: c++; c-basic-offset:4 -*- conf/smimevalidationconfigurationpage.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2008 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef KLEOPATRA_SMIMEVALIDATIONCONFIGURATIONPAGE_H #define KLEOPATRA_SMIMEVALIDATIONCONFIGURATIONPAGE_H #include <kcmodule.h> namespace Kleo { namespace Config { class SMimeValidationConfigurationWidget; class SMimeValidationConfigurationPage : public KCModule { Q_OBJECT public: explicit SMimeValidationConfigurationPage( const KComponentData &instance, QWidget *parent=0, const QVariantList &args=QVariantList() ); /* reimp */ void load(); /* reimp */ void save(); /* reimp */ void defaults(); private: SMimeValidationConfigurationWidget * mWidget; }; } } #endif // KLEOPATRA_SMIMEVALIDATIONCONFIGURATIONPAGE_H
gpl-2.0
dkmorb/axoloti
firmware/mutable_instruments/streams/vactrol.h
4137
// Copyright 2014 Olivier Gillet. // // Author: Olivier Gillet ([email protected]) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // See http://creativecommons.org/licenses/MIT/ for more information. // // ----------------------------------------------------------------------------- // // Vactrol. #ifndef STREAMS_VACTROL_H_ #define STREAMS_VACTROL_H_ #include "stmlib/stmlib.h" #include "streams/meta_parameters.h" #include "streams/resources.h" namespace streams { class Vactrol { public: Vactrol() { } ~Vactrol() { } void Init(); void Process( int16_t audio, int16_t excite, uint16_t* gain, uint16_t* frequency); void Configure(bool alternate, int32_t* parameters, int32_t* globals) { uint16_t attack_time; uint16_t decay_time; if (globals) { // Attack: 10ms to 1000ms attack_time = 128 + (globals[0] >> 8); // Decay: 10ms to 5000ms decay_time = 128 + (globals[2] * 355 >> 16); ComputeAmountOffset( parameters[1], &target_frequency_amount_, &target_frequency_offset_); } else { uint16_t shape = parameters[0]; ComputeAmountOffset( parameters[1], &target_frequency_amount_, &target_frequency_offset_); if (shape < 32768) { // attack: 10ms attack_time = 128; // decay: 50ms to 2000ms decay_time = 227 + (shape * 196 >> 15); } else if (shape < 49512) { shape -= 32768; // attack: 10ms to 500ms. attack_time = 128 + (shape * 227 >> 15); // decay: 2000ms to 1000ms. decay_time = 423 - (89 * shape >> 15); } else { shape -= 49512; // attack: 500ms to 50ms. attack_time = 355 - (shape >> 7); // decay: 1000ms to 100ms. decay_time = 384 - (128 * shape >> 15); } } attack_coefficient_ = lut_lp_coefficients[attack_time]; fast_attack_coefficient_ = lut_lp_coefficients[attack_time - 128]; decay_coefficient_ = lut_lp_coefficients[decay_time]; fast_decay_coefficient_ = lut_lp_coefficients[decay_time - 128]; plucked_ = alternate; if (alternate) { fast_attack_coefficient_ <<= 4; } else { decay_coefficient_ >>= 1; } int32_t ringing_tail = 8192; int32_t headroom = 65535 - target_frequency_offset_; if (ringing_tail > headroom) { ringing_tail = headroom; } if (ringing_tail > target_frequency_amount_) { ringing_tail = target_frequency_amount_; } target_frequency_offset_ += ringing_tail; target_frequency_amount_ -= ringing_tail; } private: int32_t target_frequency_amount_; int32_t target_frequency_offset_; int32_t frequency_amount_; int32_t frequency_offset_; int32_t attack_coefficient_; int32_t decay_coefficient_; int32_t fast_attack_coefficient_; int32_t fast_decay_coefficient_; int32_t state_[4]; int32_t excite_; bool gate_; bool plucked_; DISALLOW_COPY_AND_ASSIGN(Vactrol); }; } // namespace streams #endif // STREAMS_VACTROL_H_
gpl-3.0
losingle/ccnet
net/common/processors/echo-proc.h
1115
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #ifndef CCNET_ECHO_PROC_H #define CCNET_ECHO_PROC_H #include <glib-object.h> #include "processor.h" #define CCNET_TYPE_ECHO_PROC (ccnet_echo_proc_get_type ()) #define CCNET_ECHO_PROC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCNET_TYPE_ECHO_PROC, CcnetEchoProc)) #define CCNET_IS_ECHO_PROC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCNET_TYPE_ECHO_PROC)) #define CCNET_ECHO_PROC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCNET_TYPE_ECHO_PROC, CcnetEchoProcClass)) #define CCNET_IS_ECHO_PROC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCNET_TYPE_ECHO_PROC)) #define CCNET_ECHO_PROC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCNET_TYPE_ECHO_PROC, CcnetEchoProcClass)) typedef struct _CcnetEchoProc CcnetEchoProc; typedef struct _CcnetEchoProcClass CcnetEchoProcClass; struct _CcnetEchoProc { CcnetProcessor parent_instance; }; struct _CcnetEchoProcClass { CcnetProcessorClass parent_class; }; GType ccnet_echo_proc_get_type (); #endif
gpl-3.0
apnfq/oxid_test
out/azure/src/js/widgets/oxcenterelementonhover.js
1679
/** * This file is part of OXID eShop Community Edition. * * OXID eShop Community Edition is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OXID eShop Community Edition is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OXID eShop Community Edition. If not, see <http://www.gnu.org/licenses/>. * * @link http://www.oxid-esales.com * @package out * @copyright (C) OXID eSales AG 2003-2013 * @version OXID eShop CE * @version SVN: $Id: oxpromocategory.js 35529 2011-05-23 07:31:20Z vilma $ */ ( function( $ ) { oxCenterElementOnHover = { _create: function(){ var self = this; var el = self.element; el.hover(function(){ var targetObj = $(".viewAllHover", el); var targetObjWidth = targetObj.outerWidth() / 2; var parentObjWidth = el.width() / 2; targetObj.css("left", parentObjWidth - targetObjWidth + "px"); targetObj.show(); }, function(){ $(".viewAllHover", el).hide(); }); } } $.widget( "ui.oxCenterElementOnHover", oxCenterElementOnHover ); } )( jQuery );
gpl-3.0
OXIDprojects/oxid-ce-hot-offer
core/oxfb.php
3426
<?php /** * This file is part of OXID eShop Community Edition. * * OXID eShop Community Edition is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OXID eShop Community Edition is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OXID eShop Community Edition. If not, see <http://www.gnu.org/licenses/>. * * @link http://www.oxid-esales.com * @package core * @copyright (C) OXID eSales AG 2003-2011 * @version OXID eShop CE * @version SVN: $Id: oxfb.php 25467 2010-02-01 14:14:26Z alfonsas $ */ try { include_once getShopBasePath() . "core/facebook/facebook.php"; } catch ( Exception $oEx ) { // skipping class includion if curl or json is not active oxConfig::getInstance()->setConfigParam( "bl_showFbConnect", false ); return; } error_reporting($iOldErrorReproting); /** * Facebook API * * @package core */ class oxFb extends Facebook { /** * oxUtils class instance. * * @var oxutils */ private static $_instance = null; /** * oxUtils class instance. * * @var oxutils */ protected $_blIsConnected = null; /** * Sets default application parameters - FB application ID, * secure key and cookie support. * * @return null */ public function __construct() { $oConfig = oxConfig::getInstance(); $aFbConfig["appId"] = $oConfig->getConfigParam( "sFbAppId" ); $aFbConfig["secret"] = $oConfig->getConfigParam( "sFbSecretKey" ); $aFbConfig["cookie"] = true; parent::__construct( $aFbConfig ); } /** * Returns object instance * * @return oxPictureHandler */ public static function getInstance() { // disable caching for test modules if ( defined( 'OXID_PHP_UNIT' ) ) { self::$_instance = modInstances::getMod( __CLASS__ ); } if ( !self::$_instance instanceof oxFb ) { self::$_instance = oxNew( 'oxFb' ); if ( defined( 'OXID_PHP_UNIT' ) ) { modInstances::addMod( __CLASS__, self::$_instance); } } return self::$_instance; } /** * Checks is user is connected using Facebook connect. * * @return bool */ public function isConnected() { $oConfig = oxConfig::getInstance(); if ( !$oConfig->getConfigParam( "bl_showFbConnect" ) ) { return false; } if ( $this->_blIsConnected !== null ) { return $this->_blIsConnected; } $this->_blIsConnected = false; $oSession = $this->getSession(); if ( $oSession ) { try { if ( $this->getUser() ) { $this->_blIsConnected = true; } } catch (FacebookApiException $e) { $this->_blIsConnected = false; } } return $this->_blIsConnected; } }
gpl-3.0
deependhulla/powermail-debian9
files/rootdir/usr/local/src/groupoffice-6.2/groupoffice-6.2-setup-www/go/vendor/PHPExcel/PHPExcel/Shared/Date.php
12755
<?php /** * PHPExcel * * Copyright (c) 2006 - 2013 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel_Shared * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 1.7.9, 2013-06-02 */ /** * PHPExcel_Shared_Date * * @category PHPExcel * @package PHPExcel_Shared * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Date { /** constants */ const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 /* * Names of the months of the year, indexed by shortname * Planned usage for locale settings * * @public * @var string[] */ public static $_monthNames = array( 'Jan' => 'January', 'Feb' => 'February', 'Mar' => 'March', 'Apr' => 'April', 'May' => 'May', 'Jun' => 'June', 'Jul' => 'July', 'Aug' => 'August', 'Sep' => 'September', 'Oct' => 'October', 'Nov' => 'November', 'Dec' => 'December', ); /* * Names of the months of the year, indexed by shortname * Planned usage for locale settings * * @public * @var string[] */ public static $_numberSuffixes = array( 'st', 'nd', 'rd', 'th', ); /* * Base calendar year to use for calculations * * @private * @var int */ protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900; /** * Set the Excel calendar (Windows 1900 or Mac 1904) * * @param integer $baseDate Excel base date (1900 or 1904) * @return boolean Success or failure */ public static function setExcelCalendar($baseDate) { if (($baseDate == self::CALENDAR_WINDOWS_1900) || ($baseDate == self::CALENDAR_MAC_1904)) { self::$_excelBaseDate = $baseDate; return TRUE; } return FALSE; } // function setExcelCalendar() /** * Return the Excel calendar (Windows 1900 or Mac 1904) * * @return integer Excel base date (1900 or 1904) */ public static function getExcelCalendar() { return self::$_excelBaseDate; } // function getExcelCalendar() /** * Convert a date from Excel to PHP * * @param long $dateValue Excel date/time value * @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as * a UST timestamp, or adjusted to UST * @param StringHelper $timezone The timezone for finding the adjustment from UST * @return long PHP serialized date/time */ public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) { if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) { $my_excelBaseDate = 25569; // Adjust for the spurious 29-Feb-1900 (Day 60) if ($dateValue < 60) { --$my_excelBaseDate; } } else { $my_excelBaseDate = 24107; } // Perform conversion if ($dateValue >= 1) { $utcDays = $dateValue - $my_excelBaseDate; $returnValue = round($utcDays * 86400); if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) { $returnValue = (integer) $returnValue; } } else { $hours = round($dateValue * 24); $mins = round($dateValue * 1440) - round($hours * 60); $secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60); $returnValue = (integer) gmmktime($hours, $mins, $secs); } $timezoneAdjustment = ($adjustToTimezone) ? PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) : 0; // Return return $returnValue + $timezoneAdjustment; } // function ExcelToPHP() /** * Convert a date from Excel to a PHP Date/Time object * * @param integer $dateValue Excel date/time value * @return integer PHP date/time object */ public static function ExcelToPHPObject($dateValue = 0) { $dateTime = self::ExcelToPHP($dateValue); $days = floor($dateTime / 86400); $time = round((($dateTime / 86400) - $days) * 86400); $hours = round($time / 3600); $minutes = round($time / 60) - ($hours * 60); $seconds = round($time) - ($hours * 3600) - ($minutes * 60); $dateObj = date_create('1-Jan-1970+'.$days.' days'); $dateObj->setTime($hours,$minutes,$seconds); return $dateObj; } // function ExcelToPHPObject() /** * Convert a date from PHP to Excel * * @param mixed $dateValue PHP serialized date/time or date object * @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as * a UST timestamp, or adjusted to UST * @param StringHelper $timezone The timezone for finding the adjustment from UST * @return mixed Excel date/time value * or boolean FALSE on failure */ public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) { $saveTimeZone = date_default_timezone_get(); date_default_timezone_set('UTC'); $retValue = FALSE; if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { $retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') ); } elseif (is_numeric($dateValue)) { $retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue), date('H',$dateValue), date('i',$dateValue), date('s',$dateValue) ); } date_default_timezone_set($saveTimeZone); return $retValue; } // function PHPToExcel() /** * FormattedPHPToExcel * * @param long $year * @param long $month * @param long $day * @param long $hours * @param long $minutes * @param long $seconds * @return long Excel date/time value */ public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) { // // Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel // This affects every date following 28th February 1900 // $excel1900isLeapYear = TRUE; if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; } $my_excelBaseDate = 2415020; } else { $my_excelBaseDate = 2416481; $excel1900isLeapYear = FALSE; } // Julian base date Adjustment if ($month > 2) { $month -= 3; } else { $month += 9; --$year; } // Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) $century = substr($year,0,2); $decade = substr($year,2,2); $excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear; $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400; return (float) $excelDate + $excelTime; } // function FormattedPHPToExcel() /** * Is a given cell a date/time? * * @param PHPExcel_Cell $pCell * @return boolean */ public static function isDateTime(PHPExcel_Cell $pCell) { return self::isDateTimeFormat( $pCell->getWorksheet()->getStyle( $pCell->getCoordinate() )->getNumberFormat() ); } // function isDateTime() /** * Is a given number format a date/time? * * @param PHPExcel_Style_NumberFormat $pFormat * @return boolean */ public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) { return self::isDateTimeFormatCode($pFormat->getFormatCode()); } // function isDateTimeFormat() private static $possibleDateFormatCharacters = 'eymdHs'; /** * Is a given number format code a date/time? * * @param string $pFormatCode * @return boolean */ public static function isDateTimeFormatCode($pFormatCode = '') { // Switch on formatcode switch ($pFormatCode) { // General contains an epoch letter 'e', so we trap for it explicitly here case PHPExcel_Style_NumberFormat::FORMAT_GENERAL: return FALSE; // Explicitly defined date formats case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD: case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2: case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY: case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH: case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS: case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS: case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS: case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7: case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8: case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH: case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14: case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15: case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16: case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17: case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22: return TRUE; } // Typically number, currency or accounting (or occasionally fraction) formats if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) { return FALSE; } // Try checking for any of the date formatting characters that don't appear within square braces if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) { // We might also have a format mask containing quoted strings... // we don't want to test for any of our characters within the quoted blocks if (strpos($pFormatCode,'"') !== FALSE) { $segMatcher = FALSE; foreach(explode('"',$pFormatCode) as $subVal) { // Only test in alternate array entries (the non-quoted blocks) if (($segMatcher = !$segMatcher) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { return TRUE; } } return FALSE; } return TRUE; } // No date... return FALSE; } // function isDateTimeFormatCode() /** * Convert a date/time string to Excel time * * @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10' * @return float|FALSE Excel date/time serial value */ public static function stringToExcel($dateValue = '') { if (strlen($dateValue) < 2) return FALSE; if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) return FALSE; $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) { return FALSE; } else { if (strpos($dateValue, ':') !== FALSE) { $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue); if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) { return FALSE; } $dateValueNew += $timeValue; } return $dateValueNew; } } public static function monthStringToNumber($month) { $monthIndex = 1; foreach(self::$_monthNames as $shortMonthName => $longMonthName) { if (($month === $longMonthName) || ($month === $shortMonthName)) { return $monthIndex; } ++$monthIndex; } return $month; } public static function dayStringToNumber($day) { $strippedDayValue = (str_replace(self::$_numberSuffixes,'',$day)); if (is_numeric($strippedDayValue)) { return $strippedDayValue; } return $day; } }
gpl-3.0
robertsmieja/Gw2InfoViewer
lib/mockito-1.9.5/javadoc/org/mockito/internal/listeners/package-tree.html
10363
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_35) on Sat Oct 06 21:59:21 CEST 2012 --> <TITLE> org.mockito.internal.listeners Class Hierarchy (Mockito 1.9.5 API) </TITLE> <META NAME="date" CONTENT="2012-10-06"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="org.mockito.internal.listeners Class Hierarchy (Mockito 1.9.5 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <!-- Note there is a weird javadoc task bug if using the double quote char \" that causes an 'illegal package name' error --> <!-- using the beautify plugin for jQuery from https://bitbucket.org/larscorneliussen/beautyofcode/ --> <script type="text/javascript"> var shBaseURL = '../../../../js/sh-2.1.382/'; </script> <script type="text/javascript" src="../../../../js/jquery-1.7.min.js"></script> <script type="text/javascript" src="../../../../js/jquery.beautyOfCode-min.js"></script> <script type="text/javascript"> /* Apply beautification of code */ var usingOldIE = false; if($.browser.msie && parseInt($.browser.version) < 9) usingOldIE = true; if(!usingOldIE) { $.beautyOfCode.init({ theme : 'Eclipse', brushes: ['Java'] }); /* Add name & version to header */ $(function() { $('td.NavBarCell1[colspan=2]').each(function(index, element) { var jqueryTD = $(element); jqueryTD.after( $('<td><em><strong>Mockito 1.9.5 API</strong></em></td>').attr('class','NavBarCell1').attr('id','mockito-version-header') ); jqueryTD.removeAttr('colspan'); }) }) } </script> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../org/mockito/internal/junit/package-tree.html"><B>PREV</B></A>&nbsp; &nbsp;<A HREF="../../../../org/mockito/internal/matchers/package-tree.html"><B>NEXT</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?org/mockito/internal/listeners/package-tree.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-tree.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> Hierarchy For Package org.mockito.internal.listeners </H2> </CENTER> <DL> <DT><B>Package Hierarchies:</B><DD><A HREF="../../../../overview-tree.html">All Packages</A></DL> <HR> <H2> Class Hierarchy </H2> <UL> <LI TYPE="circle">java.lang.Object<UL> <LI TYPE="circle">org.mockito.internal.listeners.<A HREF="../../../../org/mockito/internal/listeners/CollectCreatedMocks.html" title="class in org.mockito.internal.listeners"><B>CollectCreatedMocks</B></A> (implements org.mockito.internal.listeners.<A HREF="../../../../org/mockito/internal/listeners/MockingStartedListener.html" title="interface in org.mockito.internal.listeners">MockingStartedListener</A>) <LI TYPE="circle">org.mockito.internal.listeners.<A HREF="../../../../org/mockito/internal/listeners/NotifiedMethodInvocationReport.html" title="class in org.mockito.internal.listeners"><B>NotifiedMethodInvocationReport</B></A> (implements org.mockito.listeners.<A HREF="../../../../org/mockito/listeners/MethodInvocationReport.html" title="interface in org.mockito.listeners">MethodInvocationReport</A>) </UL> </UL> <H2> Interface Hierarchy </H2> <UL> <LI TYPE="circle">org.mockito.internal.listeners.<A HREF="../../../../org/mockito/internal/listeners/MockingProgressListener.html" title="interface in org.mockito.internal.listeners"><B>MockingProgressListener</B></A><UL> <LI TYPE="circle">org.mockito.internal.listeners.<A HREF="../../../../org/mockito/internal/listeners/MockingStartedListener.html" title="interface in org.mockito.internal.listeners"><B>MockingStartedListener</B></A></UL> </UL> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <!-- Note there is a weird javadoc task bug if using the double quote char \" that causes an 'illegal package name' error --> <!-- using the beautify plugin for jQuery from https://bitbucket.org/larscorneliussen/beautyofcode/ --> <script type="text/javascript"> var shBaseURL = '../../../../js/sh-2.1.382/'; </script> <script type="text/javascript" src="../../../../js/jquery-1.7.min.js"></script> <script type="text/javascript" src="../../../../js/jquery.beautyOfCode-min.js"></script> <script type="text/javascript"> /* Apply beautification of code */ var usingOldIE = false; if($.browser.msie && parseInt($.browser.version) < 9) usingOldIE = true; if(!usingOldIE) { $.beautyOfCode.init({ theme : 'Eclipse', brushes: ['Java'] }); /* Add name & version to header */ $(function() { $('td.NavBarCell1[colspan=2]').each(function(index, element) { var jqueryTD = $(element); jqueryTD.after( $('<td><em><strong>Mockito 1.9.5 API</strong></em></td>').attr('class','NavBarCell1').attr('id','mockito-version-header') ); jqueryTD.removeAttr('colspan'); }) }) } </script> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../org/mockito/internal/junit/package-tree.html"><B>PREV</B></A>&nbsp; &nbsp;<A HREF="../../../../org/mockito/internal/matchers/package-tree.html"><B>NEXT</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?org/mockito/internal/listeners/package-tree.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-tree.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
gpl-3.0
Stub-O-Matic-BA/stubo-app
stubo/static/giraffe/js/giraffe.js
20491
// Generated by CoffeeScript 1.5.0 var auth, changeDashboard, createGraph, dashboard, dataPoll, default_graphite_url, default_period, description, generateDataURL, generateEventsURL, generateGraphiteTargets, getTargetColor, graphScaffold, graphite_url, graphs, init, metrics, period, refresh, refreshSummary, refreshTimer, scheme, toggleCss, _avg, _formatBase1024KMGTP, _last, _max, _min, _sum; graphite_url = graphite_url || 'demo'; default_graphite_url = graphite_url; default_period = 1440; if (scheme === void 0) { scheme = 'classic9'; } period = default_period; dashboard = dashboards[0]; metrics = dashboard['metrics']; description = dashboard['description']; refresh = dashboard['refresh']; refreshTimer = null; auth = auth != null ? auth : false; graphs = []; dataPoll = function() { var graph, _i, _len, _results; _results = []; for (_i = 0, _len = graphs.length; _i < _len; _i++) { graph = graphs[_i]; _results.push(graph.refreshGraph(period)); } return _results; }; _sum = function(series) { return _.reduce(series, (function(memo, val) { return memo + val; }), 0); }; _avg = function(series) { return _sum(series) / series.length; }; _max = function(series) { return _.reduce(series, (function(memo, val) { if (memo === null) { return val; } if (val > memo) { return val; } return memo; }), null); }; _min = function(series) { return _.reduce(series, (function(memo, val) { if (memo === null) { return val; } if (val < memo) { return val; } return memo; }), null); }; _last = function(series) { return _.reduce(series, (function(memo, val) { if (val !== null) { return val; } return memo; }), null); }; _formatBase1024KMGTP = function(y, formatter) { var abs_y; if (formatter == null) { formatter = d3.format(".2r"); } abs_y = Math.abs(y); if (abs_y >= 1125899906842624) { return formatter(y / 1125899906842624) + "P"; } else if (abs_y >= 1099511627776) { return formatter(y / 1099511627776) + "T"; } else if (abs_y >= 1073741824) { return formatter(y / 1073741824) + "G"; } else if (abs_y >= 1048576) { return formatter(y / 1048576) + "M"; } else if (abs_y >= 1024) { return formatter(y / 1024) + "K"; } else if (abs_y < 1 && y > 0) { return formatter(y); } else if (abs_y === 0) { return 0; } else { return formatter(y); } }; refreshSummary = function(graph) { var summary_func, y_data, _ref; if (!((_ref = graph.args) != null ? _ref.summary : void 0)) { return; } if (graph.args.summary === "sum") { summary_func = _sum; } if (graph.args.summary === "avg") { summary_func = _avg; } if (graph.args.summary === "min") { summary_func = _min; } if (graph.args.summary === "max") { summary_func = _max; } if (graph.args.summary === "last") { summary_func = _last; } if (typeof graph.args.summary === "function") { summary_func = graph.args.summary; } if (!summary_func) { console.log("unknown summary function " + graph.args.summary); } y_data = _.map(_.flatten(_.pluck(graph.graph.series, 'data')), function(d) { return d.y; }); return $("" + graph.args.anchor + " .graph-summary").html(graph.args.summary_formatter(summary_func(y_data))); }; graphScaffold = function() { var colspan, context, converter, graph_template, i, metric, offset, _i, _len; graph_template = "{{#dashboard_description}}\n <div class=\"well\">{{{dashboard_description}}}</div>\n{{/dashboard_description}}\n{{#metrics}}\n {{#start_row}}\n <div class=\"row-fluid\">\n {{/start_row}}\n <div class=\"{{span}}\" id=\"graph-{{graph_id}}\">\n <h2>{{metric_alias}} <span class=\"pull-right graph-summary\"><span></h2>\n <div class=\"chart\"></div>\n <div class=\"timeline\"></div>\n <p>{{metric_description}}</p>\n <div class=\"legend\"></div>\n </div>\n {{#end_row}}\n </div>\n {{/end_row}}\n{{/metrics}}"; $('#graphs').empty(); context = { metrics: [] }; converter = new Markdown.Converter(); if (description) { context['dashboard_description'] = converter.makeHtml(description); } offset = 0; for (i = _i = 0, _len = metrics.length; _i < _len; i = ++_i) { metric = metrics[i]; colspan = metric.colspan != null ? metric.colspan : 1; context['metrics'].push({ start_row: offset % 3 === 0, end_row: offset % 3 === 2, graph_id: i, span: 'span' + (4 * colspan), metric_alias: metric.alias, metric_description: metric.description }); offset += colspan; } return $('#graphs').append(Mustache.render(graph_template, context)); }; init = function() { var dash, i, metric, refreshInterval, _i, _j, _len, _len1; $('.dropdown-menu').empty(); for (_i = 0, _len = dashboards.length; _i < _len; _i++) { dash = dashboards[_i]; $('.dropdown-menu').append("<li><a href=\"#\">" + dash.name + "</a></li>"); } graphScaffold(); graphs = []; for (i = _j = 0, _len1 = metrics.length; _j < _len1; i = ++_j) { metric = metrics[i]; graphs.push(createGraph("#graph-" + i, metric)); } $('.page-header h1').empty().append(dashboard.name); refreshInterval = refresh || 10000; if (refreshTimer) { clearInterval(refreshTimer); } return refreshTimer = setInterval(dataPoll, refreshInterval); }; getTargetColor = function(targets, target) { var t, _i, _len; if (typeof targets !== 'object') { return; } for (_i = 0, _len = targets.length; _i < _len; _i++) { t = targets[_i]; if (!t.color) { continue; } if (t.target === target || t.alias === target) { return t.color; } } }; generateGraphiteTargets = function(targets) { var graphite_targets, target, _i, _len; if (typeof targets === "string") { return "&target=" + targets; } if (typeof targets === "function") { return "&target=" + (targets()); } graphite_targets = ""; for (_i = 0, _len = targets.length; _i < _len; _i++) { target = targets[_i]; if (typeof target === "string") { graphite_targets += "&target=" + target; } if (typeof target === "function") { graphite_targets += "&target=" + (target()); } if (typeof target === "object") { graphite_targets += "&target=" + ((target != null ? target.target : void 0) || ''); } } return graphite_targets; }; generateDataURL = function(targets, annotator_target, max_data_points) { var data_targets; annotator_target = annotator_target ? "&target=" + annotator_target : ""; data_targets = generateGraphiteTargets(targets); return "" + graphite_url + "/render?from=-" + period + "minutes&" + data_targets + annotator_target + "&maxDataPoints=" + max_data_points + "&format=json&jsonp=?"; }; generateEventsURL = function(event_tags) { var jsonp, tags; tags = event_tags === '*' ? '' : "&tags=" + event_tags; jsonp = window.json_fallback ? '' : "&jsonp=?"; return "" + graphite_url + "/events/get_data?from=-" + period + "minutes" + tags + jsonp; }; createGraph = function(anchor, metric) { var graph, graph_provider, _ref, _ref1; if (graphite_url === 'demo') { graph_provider = Rickshaw.Graph.Demo; } else { graph_provider = Rickshaw.Graph.JSONP.Graphite; } return graph = new graph_provider({ anchor: anchor, targets: metric.target || metric.targets, summary: metric.summary, summary_formatter: metric.summary_formatter || _formatBase1024KMGTP, scheme: metric.scheme || dashboard.scheme || scheme || 'classic9', annotator_target: ((_ref = metric.annotator) != null ? _ref.target : void 0) || metric.annotator, annotator_description: ((_ref1 = metric.annotator) != null ? _ref1.description : void 0) || 'deployment', events: metric.events, element: $("" + anchor + " .chart")[0], width: $("" + anchor + " .chart").width(), height: metric.height || 300, min: metric.min || 0, max: metric.max, null_as: metric.null_as === void 0 ? null : metric.null_as, renderer: metric.renderer || 'area', interpolation: metric.interpolation || 'step-before', unstack: metric.unstack, stroke: metric.stroke === false ? false : true, strokeWidth: metric.stroke_width, dataURL: generateDataURL(metric.target || metric.targets), onRefresh: function(transport) { return refreshSummary(transport); }, onComplete: function(transport) { var detail, hover_formatter, shelving, xAxis, yAxis; graph = transport.graph; xAxis = new Rickshaw.Graph.Axis.Time({ graph: graph }); xAxis.render(); yAxis = new Rickshaw.Graph.Axis.Y({ graph: graph, tickFormat: function(y) { return _formatBase1024KMGTP(y); }, ticksTreatment: 'glow' }); yAxis.render(); hover_formatter = metric.hover_formatter || _formatBase1024KMGTP; detail = new Rickshaw.Graph.HoverDetail({ graph: graph, yFormatter: function(y) { return hover_formatter(y); } }); $("" + anchor + " .legend").empty(); this.legend = new Rickshaw.Graph.Legend({ graph: graph, element: $("" + anchor + " .legend")[0] }); shelving = new Rickshaw.Graph.Behavior.Series.Toggle({ graph: graph, legend: this.legend }); if (metric.annotator || metric.events) { this.annotator = new GiraffeAnnotate({ graph: graph, element: $("" + anchor + " .timeline")[0] }); } return refreshSummary(this); } }); }; Rickshaw.Graph.JSONP.Graphite = Rickshaw.Class.create(Rickshaw.Graph.JSONP, { request: function() { return this.refreshGraph(period); }, refreshGraph: function(period) { var deferred, _this = this; deferred = this.getAjaxData(period); return deferred.done(function(result) { var annotations, el, i, result_data, series, _i, _len; if (result.length <= 0) { return; } result_data = _.filter(result, function(el) { var _ref; return el.target !== ((_ref = _this.args.annotator_target) != null ? _ref.replace(/["']/g, '') : void 0); }); result_data = _this.preProcess(result_data); if (!_this.graph) { _this.success(_this.parseGraphiteData(result_data, _this.args.null_as)); } series = _this.parseGraphiteData(result_data, _this.args.null_as); if (_this.args.annotator_target) { annotations = _this.parseGraphiteData(_.filter(result, function(el) { return el.target === _this.args.annotator_target.replace(/["']/g, ''); }), _this.args.null_as); } for (i = _i = 0, _len = series.length; _i < _len; i = ++_i) { el = series[i]; _this.graph.series[i].data = el.data; _this.addTotals(i); } _this.graph.renderer.unstack = _this.args.unstack; _this.graph.render(); if (_this.args.events) { deferred = _this.getEvents(period); deferred.done(function(result) { return _this.addEventAnnotations(result); }); } _this.addAnnotations(annotations, _this.args.annotator_description); return _this.args.onRefresh(_this); }); }, addTotals: function(i) { var avg, label, max, min, series_data, sum; label = $(this.legend.lines[i].element).find('span.label').text(); $(this.legend.lines[i].element).find('span.totals').remove(); series_data = _.map(this.legend.lines[i].series.data, function(d) { return d.y; }); sum = _formatBase1024KMGTP(_sum(series_data)); max = _formatBase1024KMGTP(_max(series_data)); min = _formatBase1024KMGTP(_min(series_data)); avg = _formatBase1024KMGTP(_avg(series_data)); return $(this.legend.lines[i].element).append("<span class='totals pull-right'> &Sigma;: " + sum + " <i class='icon-caret-down'></i>: " + min + " <i class='icon-caret-up'></i>: " + max + " <i class='icon-sort'></i>: " + avg + "</span>"); }, preProcess: function(result) { var item, _i, _len; for (_i = 0, _len = result.length; _i < _len; _i++) { item = result[_i]; if (item.datapoints.length === 1) { item.datapoints[0][1] = 0; if (this.args.unstack) { item.datapoints.push([0, 1]); } else { item.datapoints.push([item.datapoints[0][0], 1]); } } } return result; }, parseGraphiteData: function(d, null_as) { var palette, rev_xy, targets; if (null_as == null) { null_as = null; } rev_xy = function(datapoints) { return _.map(datapoints, function(point) { return { 'x': point[1], 'y': point[0] !== null ? point[0] : null_as }; }); }; palette = new Rickshaw.Color.Palette({ scheme: this.args.scheme }); targets = this.args.target || this.args.targets; d = _.map(d, function(el) { var color, _ref; if ((_ref = typeof targets) === "string" || _ref === "function") { color = palette.color(); } else { color = getTargetColor(targets, el.target) || palette.color(); } return { "color": color, "name": el.target, "data": rev_xy(el.datapoints) }; }); Rickshaw.Series.zeroFill(d); return d; }, addEventAnnotations: function(events_json) { var active_annotation, event, _i, _len, _ref, _ref1; if (!events_json) { return; } this.annotator || (this.annotator = new GiraffeAnnotate({ graph: this.graph, element: $("" + this.args.anchor + " .timeline")[0] })); this.annotator.data = {}; $(this.annotator.elements.timeline).empty(); active_annotation = $(this.annotator.elements.timeline).parent().find('.annotation_line.active').size() > 0; if ((_ref = $(this.annotator.elements.timeline).parent()) != null) { _ref.find('.annotation_line').remove(); } for (_i = 0, _len = events_json.length; _i < _len; _i++) { event = events_json[_i]; this.annotator.add(event.when, "" + event.what + " " + (event.data || '')); } this.annotator.update(); if (active_annotation) { return (_ref1 = $(this.annotator.elements.timeline).parent()) != null ? _ref1.find('.annotation_line').addClass('active') : void 0; } }, addAnnotations: function(annotations, description) { var annotation_timestamps, _ref; if (!annotations) { return; } annotation_timestamps = _((_ref = annotations[0]) != null ? _ref.data : void 0).filter(function(el) { return el.y !== 0 && el.y !== null; }); return this.addEventAnnotations(_.map(annotation_timestamps, function(a) { return { when: a.x, what: description }; })); }, getEvents: function(period) { var deferred, _this = this; this.period = period; return deferred = $.ajax({ dataType: 'json', url: generateEventsURL(this.args.events), error: function(xhr, textStatus, errorThrown) { if (textStatus === 'parsererror' && /was not called/.test(errorThrown.message)) { window.json_fallback = true; return _this.refreshGraph(period); } else { return console.log("error loading eventsURL: " + generateEventsURL(_this.args.events)); } } }); }, getAjaxData: function(period) { var deferred; this.period = period; return deferred = $.ajax({ dataType: 'json', url: generateDataURL(this.args.targets, this.args.annotator_target, this.args.width), error: this.error.bind(this) }); } }); Rickshaw.Graph.Demo = Rickshaw.Class.create(Rickshaw.Graph.JSONP.Graphite, { success: function(data) { var i, palette, _i; palette = new Rickshaw.Color.Palette({ scheme: this.args.scheme }); this.seriesData = [[], [], [], [], [], [], [], [], []]; this.random = new Rickshaw.Fixtures.RandomData(period / 60 + 10); for (i = _i = 0; _i <= 60; i = ++_i) { this.random.addData(this.seriesData); } this.graph = new Rickshaw.Graph({ element: this.args.element, width: this.args.width, height: this.args.height, min: this.args.min, max: this.args.max, renderer: this.args.renderer, interpolation: this.args.interpolation, stroke: this.args.stroke, strokeWidth: this.args.strokeWidth, series: [ { color: palette.color(), data: this.seriesData[0], name: 'Moscow' }, { color: palette.color(), data: this.seriesData[1], name: 'Shanghai' }, { color: palette.color(), data: this.seriesData[2], name: 'Amsterdam' }, { color: palette.color(), data: this.seriesData[3], name: 'Paris' }, { color: palette.color(), data: this.seriesData[4], name: 'Tokyo' }, { color: palette.color(), data: this.seriesData[5], name: 'London' }, { color: palette.color(), data: this.seriesData[6], name: 'New York' } ] }); this.graph.renderer.unstack = this.args.unstack; this.graph.render(); return this.onComplete(this); }, refreshGraph: function(period) { var i, _i, _ref, _results; if (!this.graph) { return this.success(); } else { this.random.addData(this.seriesData); this.random.addData(this.seriesData); _.each(this.seriesData, function(d) { return d.shift(); }); this.args.onRefresh(this); this.graph.render(); _results = []; for (i = _i = 0, _ref = this.graph.series.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { _results.push(this.addTotals(i)); } return _results; } } }); /* # Events and interaction */ $('.dropdown-menu').on('click', 'a', function() { changeDashboard($(this).text()); $('.dropdown').removeClass('open'); return false; }); changeDashboard = function(dash_name) { dashboard = _.where(dashboards, { name: dash_name })[0] || dashboards[0]; graphite_url = dashboard['graphite_url'] || default_graphite_url; description = dashboard['description']; metrics = dashboard['metrics']; refresh = dashboard['refresh']; period || (period = default_period); init(); return $.bbq.pushState({ dashboard: dashboard.name }); }; $('.timepanel').on('click', 'a.range', function() { var dash, timeFrame, _ref; if (graphite_url === 'demo') { changeDashboard(dashboard.name); } period = $(this).attr('data-timeframe') || default_period; dataPoll(); timeFrame = $(this).attr('href').replace(/^#/, ''); dash = (_ref = $.bbq.getState()) != null ? _ref.dashboard : void 0; $.bbq.pushState({ timeFrame: timeFrame, dashboard: dash || dashboard.name }); $(this).parent('.btn-group').find('a').removeClass('active'); $(this).addClass('active'); return false; }); toggleCss = function(css_selector) { if ($.rule(css_selector).text().match('display: ?none')) { return $.rule(css_selector, 'style').remove(); } else { return $.rule("" + css_selector + " {display:none;}").appendTo('style'); } }; $('#legend-toggle').on('click', function() { $(this).toggleClass('active'); $('.legend').toggle(); return false; }); $('#axis-toggle').on('click', function() { $(this).toggleClass('active'); toggleCss('.y_grid'); toggleCss('.y_ticks'); toggleCss('.x_tick'); return false; }); $('#x-label-toggle').on('click', function() { toggleCss('.rickshaw_graph .detail .x_label'); $(this).toggleClass('active'); return false; }); $('#x-item-toggle').on('click', function() { toggleCss('.rickshaw_graph .detail .item.active'); $(this).toggleClass('active'); return false; }); $(window).bind('hashchange', function(e) { var dash, timeFrame, _ref, _ref1; timeFrame = ((_ref = e.getState()) != null ? _ref.timeFrame : void 0) || $(".timepanel a.range[data-timeframe='" + default_period + "']")[0].text || "1d"; dash = (_ref1 = e.getState()) != null ? _ref1.dashboard : void 0; if (dash !== dashboard.name) { changeDashboard(dash); } return $('.timepanel a.range[href="#' + timeFrame + '"]').click(); }); $(function() { $(window).trigger('hashchange'); return init(); });
gpl-3.0
cwalther/Plasma-nobink-test
Sources/Plasma/NucleusLib/pnMessage/plServerReplyMsg.cpp
2654
/*==LICENSE==* CyanWorlds.com Engine - MMOG client, server and tools Copyright (C) 2011 Cyan Worlds, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Additional permissions under GNU GPL version 3 section 7 If you modify this Program, or any covered work, by linking or combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK (or a modified version of those libraries), containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the licensors of this Program grant you additional permission to convey the resulting work. Corresponding Source for a non-source form of such a combination shall include the source code for the parts of OpenSSL and IJG JPEG Library used as well as that of the covered work. You can contact Cyan Worlds, Inc. by email [email protected] or by snail mail at: Cyan Worlds, Inc. 14617 N Newport Hwy Mead, WA 99021 *==LICENSE==*/ #include "plServerReplyMsg.h" #include "hsStream.h" #include "hsBitVector.h" void plServerReplyMsg::Read(hsStream* stream, hsResMgr* mgr) { plMessage::IMsgRead(stream, mgr); stream->ReadLE(&fType); } void plServerReplyMsg::Write(hsStream* stream, hsResMgr* mgr) { plMessage::IMsgWrite(stream, mgr); stream->WriteLE(fType); } enum ServerReplyFlags { kServerReplyType, }; void plServerReplyMsg::ReadVersion(hsStream* s, hsResMgr* mgr) { plMessage::IMsgReadVersion(s, mgr); hsBitVector contentFlags; contentFlags.Read(s); if (contentFlags.IsBitSet(kServerReplyType)) s->ReadLE(&fType); } void plServerReplyMsg::WriteVersion(hsStream* s, hsResMgr* mgr) { plMessage::IMsgWriteVersion(s, mgr); hsBitVector contentFlags; contentFlags.SetBit(kServerReplyType); contentFlags.Write(s); // kServerReplyType s->WriteLE(fType); }
gpl-3.0
Turasa/libsignal-service-java
service/src/main/java/org/whispersystems/signalservice/api/storage/StorageId.java
2421
package org.whispersystems.signalservice.api.storage; import org.whispersystems.libsignal.util.guava.Preconditions; import org.whispersystems.signalservice.internal.storage.protos.ManifestRecord; import java.util.Arrays; import java.util.Objects; public class StorageId { private final int type; private final byte[] raw; public static StorageId forContact(byte[] raw) { return new StorageId(ManifestRecord.Identifier.Type.CONTACT_VALUE, Preconditions.checkNotNull(raw)); } public static StorageId forGroupV1(byte[] raw) { return new StorageId(ManifestRecord.Identifier.Type.GROUPV1_VALUE, Preconditions.checkNotNull(raw)); } public static StorageId forGroupV2(byte[] raw) { return new StorageId(ManifestRecord.Identifier.Type.GROUPV2_VALUE, Preconditions.checkNotNull(raw)); } public static StorageId forAccount(byte[] raw) { return new StorageId(ManifestRecord.Identifier.Type.ACCOUNT_VALUE, Preconditions.checkNotNull(raw)); } public static StorageId forType(byte[] raw, int type) { return new StorageId(type, raw); } public boolean isUnknown() { return !isKnownType(type); } private StorageId(int type, byte[] raw) { this.type = type; this.raw = raw; } public int getType() { return type; } public byte[] getRaw() { return raw; } public StorageId withNewBytes(byte[] key) { return new StorageId(type, key); } public static boolean isKnownType(int val) { for (ManifestRecord.Identifier.Type type : ManifestRecord.Identifier.Type.values()) { if (type != ManifestRecord.Identifier.Type.UNRECOGNIZED && type.getNumber() == val) { return true; } } return false; } public static int largestKnownType() { int max = 0; for (ManifestRecord.Identifier.Type type : ManifestRecord.Identifier.Type.values()) { if (type != ManifestRecord.Identifier.Type.UNRECOGNIZED) { max = Math.max(type.getNumber(), max); } } return max; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StorageId storageId = (StorageId) o; return type == storageId.type && Arrays.equals(raw, storageId.raw); } @Override public int hashCode() { int result = Objects.hash(type); result = 31 * result + Arrays.hashCode(raw); return result; } }
gpl-3.0
mvo5/snappy
kernel/validate.go
2124
// -*- Mode: Go; indent-tabs-mode: t -*- /* * Copyright (C) 2020 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ package kernel import ( "fmt" "path/filepath" "strings" "github.com/snapcore/snapd/osutil" ) func validateAssetsContent(kernelRoot string, info *Info) error { // bare structure content is checked to exist during layout // make sure that filesystem content source paths exist as well for name, as := range info.Assets { for _, assetContent := range as.Content { c := assetContent // a single trailing / is allowed and indicates a directory isDir := strings.HasSuffix(c, "/") if isDir { c = strings.TrimSuffix(c, "/") } if filepath.Clean(c) != c || strings.Contains(c, "..") || c == "/" { return fmt.Errorf("asset %q: invalid content %q", name, assetContent) } realSource := filepath.Join(kernelRoot, c) if !osutil.FileExists(realSource) { return fmt.Errorf("asset %q: content %q source path does not exist", name, assetContent) } if isDir { // expecting a directory if !osutil.IsDirectory(realSource + "/") { return fmt.Errorf("asset %q: content %q is not a directory", name, assetContent) } } } } return nil } // Validate checks whether the given directory contains valid kernel snap // metadata and a matching content. func Validate(kernelRoot string) error { info, err := ReadInfo(kernelRoot) if err != nil { return fmt.Errorf("invalid kernel metadata: %v", err) } if err := validateAssetsContent(kernelRoot, info); err != nil { return err } return nil }
gpl-3.0
mgood7123/UPM
perl-5.26.1/perl5.26.1/lib/5.26.1/unicore/lib/Ccc/BR.pl
531
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 9.0.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. Use Unicode::UCD to access the Unicode character data # base. return <<'END'; V8 1434 1435 1453 1454 6457 6458 12333 12334 END
gpl-3.0
PatchRanger/mautic
app/bundles/LeadBundle/Views/FormTheme/Filter/_leadlist_filters_entry_widget.html.php
2233
<?php /* * @copyright 2015 Mautic Contributors. All rights reserved * @author Mautic * * @link http://mautic.org * * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ $isPrototype = ($form->vars['name'] == '__name__'); $filterType = $form['field']->vars['value']; $inGroup = $form->vars['data']['glue'] === 'and'; $object = (isset($form->vars['data']['object'])) ? $form->vars['data']['object'] : 'lead'; $class = (isset($form->vars['data']['object']) && $form->vars['data']['object'] == 'company') ? 'fa-building' : 'fa-user'; ?> <div class="panel<?php echo ($inGroup && $first === false) ? ' in-group' : ''; ?>"> <div class="panel-heading <?php if (!$isPrototype && $form->vars['name'] === '0') { echo ' hide'; } ?>"> <div class="panel-glue col-sm-2 pl-0 "> <?php echo $view['form']->widget($form['glue']); ?> </div> </div> <div class="panel-body"> <div class="col-xs-6 col-sm-3 field-name"> <i class="object-icon fa <?php echo $class; ?>" aria-hidden="true"></i> <span><?php echo ($isPrototype) ? '__label__' : $fields[$object][$filterType]['label']; ?></span> </div> <div class="col-xs-6 col-sm-3 padding-none"> <?php echo $view['form']->widget($form['operator']); ?> </div> <?php $hasErrors = count($form['filter']->vars['errors']) || count($form['display']->vars['errors']); ?> <div class="col-xs-10 col-sm-5 padding-none<?php if ($hasErrors) { echo ' has-error'; } ?>"> <?php echo $view['form']->widget($form['filter']); ?> <?php echo $view['form']->errors($form['filter']); ?> <?php echo $view['form']->widget($form['display']); ?> <?php echo $view['form']->errors($form['display']); ?> </div> <div class="col-xs-2 col-sm-1"> <a href="javascript: void(0);" class="remove-selected btn btn-default text-danger pull-right"><i class="fa fa-trash-o"></i></a> </div> <?php echo $view['form']->widget($form['field']); ?> <?php echo $view['form']->widget($form['type']); ?> <?php echo $view['form']->widget($form['object']); ?> </div> </div>
gpl-3.0
alejandroarturom/frostwire-desktop
src/org/limewire/collection/UnmodifiableIterator.java
355
package org.limewire.collection; import java.util.Iterator; /** * A convenience class to aid in developing iterators that cannot be modified. */ public abstract class UnmodifiableIterator<E> implements Iterator<E> { /** Throws UnsupportedOperationException */ public final void remove() { throw new UnsupportedOperationException(); } }
gpl-3.0
vinutah/apps
tools/llvm/llvm_39/opt/lib/Target/XCore/XCoreISelDAGToDAG.cpp
10390
//===-- XCoreISelDAGToDAG.cpp - A dag to dag inst selector for XCore ------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines an instruction selector for the XCore target. // //===----------------------------------------------------------------------===// #include "XCore.h" #include "XCoreTargetMachine.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetLowering.h" using namespace llvm; /// XCoreDAGToDAGISel - XCore specific code to select XCore machine /// instructions for SelectionDAG operations. /// namespace { class XCoreDAGToDAGISel : public SelectionDAGISel { public: XCoreDAGToDAGISel(XCoreTargetMachine &TM, CodeGenOpt::Level OptLevel) : SelectionDAGISel(TM, OptLevel) {} SDNode *Select(SDNode *N) override; SDNode *SelectBRIND(SDNode *N); /// getI32Imm - Return a target constant with the specified value, of type /// i32. inline SDValue getI32Imm(unsigned Imm, SDLoc dl) { return CurDAG->getTargetConstant(Imm, dl, MVT::i32); } inline bool immMskBitp(SDNode *inN) const { ConstantSDNode *N = cast<ConstantSDNode>(inN); uint32_t value = (uint32_t)N->getZExtValue(); if (!isMask_32(value)) { return false; } int msksize = 32 - countLeadingZeros(value); return (msksize >= 1 && msksize <= 8) || msksize == 16 || msksize == 24 || msksize == 32; } // Complex Pattern Selectors. bool SelectADDRspii(SDValue Addr, SDValue &Base, SDValue &Offset); bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, std::vector<SDValue> &OutOps) override; const char *getPassName() const override { return "XCore DAG->DAG Pattern Instruction Selection"; } // Include the pieces autogenerated from the target description. #include "XCoreGenDAGISel.inc" }; } // end anonymous namespace /// createXCoreISelDag - This pass converts a legalized DAG into a /// XCore-specific DAG, ready for instruction scheduling. /// FunctionPass *llvm::createXCoreISelDag(XCoreTargetMachine &TM, CodeGenOpt::Level OptLevel) { return new XCoreDAGToDAGISel(TM, OptLevel); } bool XCoreDAGToDAGISel::SelectADDRspii(SDValue Addr, SDValue &Base, SDValue &Offset) { FrameIndexSDNode *FIN = nullptr; if ((FIN = dyn_cast<FrameIndexSDNode>(Addr))) { Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32); return true; } if (Addr.getOpcode() == ISD::ADD) { ConstantSDNode *CN = nullptr; if ((FIN = dyn_cast<FrameIndexSDNode>(Addr.getOperand(0))) && (CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) && (CN->getSExtValue() % 4 == 0 && CN->getSExtValue() >= 0)) { // Constant positive word offset from frame index Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); Offset = CurDAG->getTargetConstant(CN->getSExtValue(), SDLoc(Addr), MVT::i32); return true; } } return false; } bool XCoreDAGToDAGISel:: SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, std::vector<SDValue> &OutOps) { SDValue Reg; switch (ConstraintID) { default: return true; case InlineAsm::Constraint_m: // Memory. switch (Op.getOpcode()) { default: return true; case XCoreISD::CPRelativeWrapper: Reg = CurDAG->getRegister(XCore::CP, MVT::i32); break; case XCoreISD::DPRelativeWrapper: Reg = CurDAG->getRegister(XCore::DP, MVT::i32); break; } } OutOps.push_back(Reg); OutOps.push_back(Op.getOperand(0)); return false; } SDNode *XCoreDAGToDAGISel::Select(SDNode *N) { SDLoc dl(N); switch (N->getOpcode()) { default: break; case ISD::Constant: { uint64_t Val = cast<ConstantSDNode>(N)->getZExtValue(); if (immMskBitp(N)) { // Transformation function: get the size of a mask // Look for the first non-zero bit SDValue MskSize = getI32Imm(32 - countLeadingZeros((uint32_t)Val), dl); return CurDAG->getMachineNode(XCore::MKMSK_rus, dl, MVT::i32, MskSize); } else if (!isUInt<16>(Val)) { SDValue CPIdx = CurDAG->getTargetConstantPool( ConstantInt::get(Type::getInt32Ty(*CurDAG->getContext()), Val), getTargetLowering()->getPointerTy(CurDAG->getDataLayout())); SDNode *node = CurDAG->getMachineNode(XCore::LDWCP_lru6, dl, MVT::i32, MVT::Other, CPIdx, CurDAG->getEntryNode()); MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); MemOp[0] = MF->getMachineMemOperand(MachinePointerInfo::getConstantPool(*MF), MachineMemOperand::MOLoad, 4, 4); cast<MachineSDNode>(node)->setMemRefs(MemOp, MemOp + 1); return node; } break; } case XCoreISD::LADD: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2) }; return CurDAG->getMachineNode(XCore::LADD_l5r, dl, MVT::i32, MVT::i32, Ops); } case XCoreISD::LSUB: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2) }; return CurDAG->getMachineNode(XCore::LSUB_l5r, dl, MVT::i32, MVT::i32, Ops); } case XCoreISD::MACCU: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2), N->getOperand(3) }; return CurDAG->getMachineNode(XCore::MACCU_l4r, dl, MVT::i32, MVT::i32, Ops); } case XCoreISD::MACCS: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2), N->getOperand(3) }; return CurDAG->getMachineNode(XCore::MACCS_l4r, dl, MVT::i32, MVT::i32, Ops); } case XCoreISD::LMUL: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2), N->getOperand(3) }; return CurDAG->getMachineNode(XCore::LMUL_l6r, dl, MVT::i32, MVT::i32, Ops); } case XCoreISD::CRC8: { SDValue Ops[] = { N->getOperand(0), N->getOperand(1), N->getOperand(2) }; return CurDAG->getMachineNode(XCore::CRC8_l4r, dl, MVT::i32, MVT::i32, Ops); } case ISD::BRIND: if (SDNode *ResNode = SelectBRIND(N)) return ResNode; break; // Other cases are autogenerated. } return SelectCode(N); } /// Given a chain return a new chain where any appearance of Old is replaced /// by New. There must be at most one instruction between Old and Chain and /// this instruction must be a TokenFactor. Returns an empty SDValue if /// these conditions don't hold. static SDValue replaceInChain(SelectionDAG *CurDAG, SDValue Chain, SDValue Old, SDValue New) { if (Chain == Old) return New; if (Chain->getOpcode() != ISD::TokenFactor) return SDValue(); SmallVector<SDValue, 8> Ops; bool found = false; for (unsigned i = 0, e = Chain->getNumOperands(); i != e; ++i) { if (Chain->getOperand(i) == Old) { Ops.push_back(New); found = true; } else { Ops.push_back(Chain->getOperand(i)); } } if (!found) return SDValue(); return CurDAG->getNode(ISD::TokenFactor, SDLoc(Chain), MVT::Other, Ops); } SDNode *XCoreDAGToDAGISel::SelectBRIND(SDNode *N) { SDLoc dl(N); // (brind (int_xcore_checkevent (addr))) SDValue Chain = N->getOperand(0); SDValue Addr = N->getOperand(1); if (Addr->getOpcode() != ISD::INTRINSIC_W_CHAIN) return nullptr; unsigned IntNo = cast<ConstantSDNode>(Addr->getOperand(1))->getZExtValue(); if (IntNo != Intrinsic::xcore_checkevent) return nullptr; SDValue nextAddr = Addr->getOperand(2); SDValue CheckEventChainOut(Addr.getNode(), 1); if (!CheckEventChainOut.use_empty()) { // If the chain out of the checkevent intrinsic is an operand of the // indirect branch or used in a TokenFactor which is the operand of the // indirect branch then build a new chain which uses the chain coming into // the checkevent intrinsic instead. SDValue CheckEventChainIn = Addr->getOperand(0); SDValue NewChain = replaceInChain(CurDAG, Chain, CheckEventChainOut, CheckEventChainIn); if (!NewChain.getNode()) return nullptr; Chain = NewChain; } // Enable events on the thread using setsr 1 and then disable them immediately // after with clrsr 1. If any resources owned by the thread are ready an event // will be taken. If no resource is ready we branch to the address which was // the operand to the checkevent intrinsic. SDValue constOne = getI32Imm(1, dl); SDValue Glue = SDValue(CurDAG->getMachineNode(XCore::SETSR_branch_u6, dl, MVT::Glue, constOne, Chain), 0); Glue = SDValue(CurDAG->getMachineNode(XCore::CLRSR_branch_u6, dl, MVT::Glue, constOne, Glue), 0); if (nextAddr->getOpcode() == XCoreISD::PCRelativeWrapper && nextAddr->getOperand(0)->getOpcode() == ISD::TargetBlockAddress) { return CurDAG->SelectNodeTo(N, XCore::BRFU_lu6, MVT::Other, nextAddr->getOperand(0), Glue); } return CurDAG->SelectNodeTo(N, XCore::BAU_1r, MVT::Other, nextAddr, Glue); }
gpl-3.0
arendst/Sonoff-Tasmota
lib/IRremoteESP8266-2.7.8.10/docs/doxygen/html/search/all_1b.html
1257
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head><title></title> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta name="generator" content="Doxygen 1.8.17"/> <link rel="stylesheet" type="text/css" href="search.css"/> <script type="text/javascript" src="all_1b.js"></script> <script type="text/javascript" src="search.js"></script> </head> <body class="SRPage"> <div id="SRIndex"> <div class="SRStatus" id="Loading">Loading...</div> <div id="SRResults"></div> <script type="text/javascript"><!-- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ createResults(); /* @license-end */ --></script> <div class="SRStatus" id="Searching">Searching...</div> <div class="SRStatus" id="NoMatches">No Matches</div> <script type="text/javascript"><!-- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ document.getElementById("Loading").style.display="none"; document.getElementById("NoMatches").style.display="none"; var searchResults = new SearchResults("searchResults"); searchResults.Search(); /* @license-end */ --></script> </div> </body> </html>
gpl-3.0
Smiljanic/Esspresso-Code
src/core/lb-boundaries.cpp
25248
/* Copyright (C) 2010,2011,2012,2013,2014 The ESPResSo project Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Max-Planck-Institute for Polymer Research, Theory Group, This file is part of ESPResSo. ESPResSo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ESPResSo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** \file lb-boundaries.cpp * * Boundary conditions for Lattice Boltzmann fluid dynamics. * Header file for \ref lb-boundaries.hpp. * */ #include "utils.hpp" #include "constraint.hpp" #include "lb-boundaries.hpp" #include "lbgpu.hpp" #include "lb.hpp" #include "electrokinetics.hpp" #include "electrokinetics_pdb_parse.hpp" #include "interaction_data.hpp" #include "communication.hpp" #if defined (LB_BOUNDARIES) || defined (LB_BOUNDARIES_GPU) int n_lb_boundaries = 0; LB_Boundary *lb_boundaries = NULL; void lbboundary_mindist_position(double pos[3], double* mindist, double distvec[3], int* no) { double vec[3] = {1e100, 1e100, 1e100}; double dist=1e100; *mindist = 1e100; int n; Particle* p1=0; for(n=0;n<n_lb_boundaries;n++) { switch(lb_boundaries[n].type) { case LB_BOUNDARY_WAL: calculate_wall_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.wal, &dist, vec); break; case LB_BOUNDARY_SPH: calculate_sphere_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.sph, &dist, vec); break; case LB_BOUNDARY_CYL: calculate_cylinder_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.cyl, &dist, vec); break; case LB_BOUNDARY_RHOMBOID: calculate_rhomboid_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.rhomboid, &dist, vec); break; case LB_BOUNDARY_POR: calculate_pore_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.pore, &dist, vec); break; case LB_BOUNDARY_STOMATOCYTE: calculate_stomatocyte_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.stomatocyte, &dist, vec); break; case LB_BOUNDARY_HOLLOW_CONE: calculate_hollow_cone_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.hollow_cone, &dist, vec); break; case CONSTRAINT_SPHEROCYLINDER: calculate_spherocylinder_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.spherocyl, &dist, vec); break; case LB_BOUNDARY_VOXEL: // needed for fluid calculation ??? calculate_voxel_dist(p1, pos, (Particle*) NULL, &lb_boundaries[n].c.voxel, &dist, vec); break; } if (dist<*mindist || n == 0) { *no=n; *mindist=dist; distvec[0] = vec[0]; distvec[1] = vec[1]; distvec[2] = vec[2]; } } } /** Initialize boundary conditions for all constraints in the system. */ void lb_init_boundaries() { int n, x, y, z; //char *errtxt; double pos[3], dist, dist_tmp=0.0, dist_vec[3]; if (lattice_switch & LATTICE_LB_GPU) { #if defined (LB_GPU) && defined (LB_BOUNDARIES_GPU) int number_of_boundnodes = 0; int *host_boundary_node_list= (int*)Utils::malloc(sizeof(int)); int *host_boundary_index_list= (int*)Utils::malloc(sizeof(int)); size_t size_of_index; int boundary_number = -1; // the number the boundary will actually belong to. #ifdef EK_BOUNDARIES ekfloat *host_wallcharge_species_density = NULL; float node_wallcharge = 0.0f; int wallcharge_species = -1, charged_boundaries = 0; int node_charged = 0; for(n = 0; n < int(n_lb_boundaries); n++) lb_boundaries[n].net_charge = 0.0; if (ek_initialized) { host_wallcharge_species_density = (ekfloat*) Utils::malloc(ek_parameters.number_of_nodes * sizeof(ekfloat)); for(n = 0; n < int(n_lb_boundaries); n++) { if(lb_boundaries[n].charge_density != 0.0) { charged_boundaries = 1; break; } } if (pdb_charge_lattice) { charged_boundaries = 1; } for(n = 0; n < int(ek_parameters.number_of_species); n++) if(ek_parameters.valency[n] != 0.0) { wallcharge_species = n; break; } if(wallcharge_species == -1 && charged_boundaries) { ostringstream msg; msg <<"no charged species available to create wall charge\n"; runtimeError(msg); } } #endif for(z=0; z<int(lbpar_gpu.dim_z); z++) { for(y=0; y<int(lbpar_gpu.dim_y); y++) { for (x=0; x<int(lbpar_gpu.dim_x); x++) { pos[0] = (x+0.5)*lbpar_gpu.agrid; pos[1] = (y+0.5)*lbpar_gpu.agrid; pos[2] = (z+0.5)*lbpar_gpu.agrid; dist = 1e99; #ifdef EK_BOUNDARIES if (ek_initialized) { host_wallcharge_species_density[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x] = 0.0f; node_charged = 0; node_wallcharge = 0.0f; } #endif for (n=0; n < n_lb_boundaries; n++) { switch (lb_boundaries[n].type) { case LB_BOUNDARY_WAL: calculate_wall_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.wal, &dist_tmp, dist_vec); break; case LB_BOUNDARY_SPH: calculate_sphere_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.sph, &dist_tmp, dist_vec); break; case LB_BOUNDARY_CYL: calculate_cylinder_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.cyl, &dist_tmp, dist_vec); break; case LB_BOUNDARY_RHOMBOID: calculate_rhomboid_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.rhomboid, &dist_tmp, dist_vec); break; case LB_BOUNDARY_POR: calculate_pore_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.pore, &dist_tmp, dist_vec); break; case LB_BOUNDARY_STOMATOCYTE: calculate_stomatocyte_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.stomatocyte, &dist_tmp, dist_vec); break; case LB_BOUNDARY_HOLLOW_CONE: calculate_hollow_cone_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.hollow_cone, &dist_tmp, dist_vec); break; case LB_BOUNDARY_SPHEROCYLINDER: calculate_spherocylinder_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.spherocyl, &dist_tmp, dist_vec); break; case LB_BOUNDARY_VOXEL: // voxel data do not need dist //calculate_voxel_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.voxel, &dist_tmp, dist_vec); dist_tmp=1e99; break; default: ostringstream msg; msg <<"lbboundary type "<< lb_boundaries[n].type << " not implemented in lb_init_boundaries()\n"; runtimeError(msg); } if (dist > dist_tmp || n == 0) { dist = dist_tmp; boundary_number = n; } #ifdef EK_BOUNDARIES if (ek_initialized) { if(dist_tmp <= 0 && lb_boundaries[n].charge_density != 0.0f) { node_charged = 1; node_wallcharge += lb_boundaries[n].charge_density * ek_parameters.agrid*ek_parameters.agrid*ek_parameters.agrid; lb_boundaries[n].net_charge += lb_boundaries[n].charge_density * ek_parameters.agrid*ek_parameters.agrid*ek_parameters.agrid; } } #endif } #ifdef EK_BOUNDARIES if(pdb_boundary_lattice && pdb_boundary_lattice[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x]) { dist = -1; boundary_number = n_lb_boundaries; // Makes sure that boundary_number is not used by a constraint } #endif if (dist <= 0 && boundary_number >= 0 && (n_lb_boundaries > 0 || pdb_boundary_lattice)) { size_of_index = (number_of_boundnodes+1)*sizeof(int); host_boundary_node_list = (int *) Utils::realloc(host_boundary_node_list, size_of_index); host_boundary_index_list = (int *) Utils::realloc(host_boundary_index_list, size_of_index); host_boundary_node_list[number_of_boundnodes] = x + lbpar_gpu.dim_x*y + lbpar_gpu.dim_x*lbpar_gpu.dim_y*z; host_boundary_index_list[number_of_boundnodes] = boundary_number + 1; number_of_boundnodes++; //printf("boundindex %i: \n", number_of_boundnodes); } #ifdef EK_BOUNDARIES if (ek_initialized) { ek_parameters.number_of_boundary_nodes = number_of_boundnodes; if(wallcharge_species != -1) { if(pdb_charge_lattice && pdb_charge_lattice[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x] != 0.0f) { node_charged = 1; node_wallcharge += pdb_charge_lattice[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x]; } if(node_charged) host_wallcharge_species_density[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x] = node_wallcharge / ek_parameters.valency[wallcharge_species]; else if(dist <= 0) host_wallcharge_species_density[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x] = 0.0f; else host_wallcharge_species_density[ek_parameters.dim_y*ek_parameters.dim_x*z + ek_parameters.dim_x*y + x] = ek_parameters.density[wallcharge_species] * ek_parameters.agrid*ek_parameters.agrid*ek_parameters.agrid; } } #endif } } } /**call of cuda fkt*/ float* boundary_velocity = (float *) Utils::malloc(3*(n_lb_boundaries+1)*sizeof(float)); for (n=0; n<n_lb_boundaries; n++) { boundary_velocity[3*n+0]=lb_boundaries[n].velocity[0]; boundary_velocity[3*n+1]=lb_boundaries[n].velocity[1]; boundary_velocity[3*n+2]=lb_boundaries[n].velocity[2]; } boundary_velocity[3*n_lb_boundaries+0] = 0.0f; boundary_velocity[3*n_lb_boundaries+1] = 0.0f; boundary_velocity[3*n_lb_boundaries+2] = 0.0f; if (n_lb_boundaries || pdb_boundary_lattice) lb_init_boundaries_GPU(n_lb_boundaries, number_of_boundnodes, host_boundary_node_list, host_boundary_index_list, boundary_velocity); free(boundary_velocity); free(host_boundary_node_list); free(host_boundary_index_list); #ifdef EK_BOUNDARIES if (ek_initialized) { ek_init_species_density_wallcharge(host_wallcharge_species_density, wallcharge_species); free(host_wallcharge_species_density); } #endif #endif /* defined (LB_GPU) && defined (LB_BOUNDARIES_GPU) */ } else { #if defined (LB) && defined (LB_BOUNDARIES) int node_domain_position[3], offset[3]; int the_boundary=-1; map_node_array(this_node, node_domain_position); offset[0] = node_domain_position[0]*lblattice.grid[0]; offset[1] = node_domain_position[1]*lblattice.grid[1]; offset[2] = node_domain_position[2]*lblattice.grid[2]; for (n=0;n<lblattice.halo_grid_volume;n++) { lbfields[n].boundary = 0; } if (lblattice.halo_grid_volume==0) return; for (z=0; z<lblattice.grid[2]+2; z++) { for (y=0; y<lblattice.grid[1]+2; y++) { for (x=0; x<lblattice.grid[0]+2; x++) { pos[0] = (offset[0]+(x-0.5))*lblattice.agrid[0]; pos[1] = (offset[1]+(y-0.5))*lblattice.agrid[1]; pos[2] = (offset[2]+(z-0.5))*lblattice.agrid[2]; dist = 1e99; for (n=0;n<n_lb_boundaries;n++) { switch (lb_boundaries[n].type) { case LB_BOUNDARY_WAL: calculate_wall_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.wal, &dist_tmp, dist_vec); break; case LB_BOUNDARY_SPH: calculate_sphere_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.sph, &dist_tmp, dist_vec); break; case LB_BOUNDARY_CYL: calculate_cylinder_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.cyl, &dist_tmp, dist_vec); break; case LB_BOUNDARY_RHOMBOID: calculate_rhomboid_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.rhomboid, &dist_tmp, dist_vec); break; case LB_BOUNDARY_POR: calculate_pore_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.pore, &dist_tmp, dist_vec); break; case LB_BOUNDARY_STOMATOCYTE: calculate_stomatocyte_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.stomatocyte, &dist_tmp, dist_vec); break; case LB_BOUNDARY_HOLLOW_CONE: calculate_hollow_cone_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.hollow_cone, &dist_tmp, dist_vec); break; case LB_BOUNDARY_VOXEL: // voxel data do not need dist dist_tmp=1e99; //calculate_voxel_dist((Particle*) NULL, pos, (Particle*) NULL, &lb_boundaries[n].c.voxel, &dist_tmp, dist_vec); break; default: ostringstream msg; msg <<"lbboundary type " << lb_boundaries[n].type << " not implemented in lb_init_boundaries()\n"; runtimeError(msg); } if (dist_tmp<dist || n == 0) { dist = dist_tmp; the_boundary = n; } } if (dist <= 0 && the_boundary >= 0 && n_lb_boundaries > 0) { lbfields[get_linear_index(x,y,z,lblattice.halo_grid)].boundary = the_boundary+1; //printf("boundindex %i: \n", get_linear_index(x,y,z,lblattice.halo_grid)); } else { lbfields[get_linear_index(x,y,z,lblattice.halo_grid)].boundary = 0; } } } } //printf("init voxels\n\n"); // SET VOXEL BOUNDARIES DIRECTLY int xxx,yyy,zzz=0; char line[80]; for (n=0;n<n_lb_boundaries;n++) { switch (lb_boundaries[n].type) { case LB_BOUNDARY_VOXEL: //lbfields[get_linear_index(lb_boundaries[n].c.voxel.pos[0],lb_boundaries[n].c.voxel.pos[1],lb_boundaries[n].c.voxel.pos[2],lblattice.halo_grid)].boundary = n+1; FILE *fp; //fp=fopen("/home/mgusenbauer/Daten/Copy/DUK/GentlePump/Optimierer/NSvsLBM/geometry_files/bottleneck_fine_voxel_data_d20_converted_noMirror.csv", "r"); //fp=fopen("/home/mgusenbauer/Daten/Copy/DUK/GentlePump/Optimierer/NSvsLBM/geometry_files/bottleneck_fine_voxel_data_d80_converted_noMirror.csv", "r"); //fp=fopen("/home/mgusenbauer/Daten/Copy/DUK/GentlePump/Optimierer/NSvsLBM/geometry_files/bottleneck_fine_voxel_data_d80_converted.csv", "r"); fp=fopen(lb_boundaries[n].c.voxel.filename, "r"); while(fgets(line, 80, fp) != NULL) { /* get a line, up to 80 chars from fp, done if NULL */ sscanf (line, "%d %d %d", &xxx,&yyy,&zzz); //printf("%d %d %d\n", xxx,yyy,zzz); //lbfields[get_linear_index(xxx,yyy+30,zzz,lblattice.halo_grid)].boundary = n+1; lbfields[get_linear_index(xxx,yyy,zzz,lblattice.halo_grid)].boundary = n+1; } fclose(fp); break; default: break; } } // CHECK FOR BOUNDARY NEIGHBOURS AND SET FLUID NORMAL VECTOR //int neighbours = {0,0,0,0,0,0}; //int x=0,y=0,z=0; //double nn[]={0.0,0.0,0.0,0.0,0.0,0.0}; //for (n=0;n<n_lb_boundaries;n++) { //switch (lb_boundaries[n].type) { //case LB_BOUNDARY_VOXEL: //x=lb_boundaries[n].c.voxel.pos[0]; //y=lb_boundaries[n].c.voxel.pos[1]; //z=lb_boundaries[n].c.voxel.pos[2]; //if(((x-1) >= 0) && (lbfields[get_linear_index(x-1,y,z,lblattice.halo_grid)].boundary == 0)) nn[0] = -1.0;//neighbours[0] = -1; //if(((x+1) <= lblattice.grid[0]) && (lbfields[get_linear_index(x+1,y,z,lblattice.halo_grid)].boundary == 0)) nn[1] = 1.0;//neighbours[1] = 1; ////printf("%.0lf %.0lf ",nn[0],nn[1]); //lb_boundaries[n].c.voxel.n[0] = nn[0]+nn[1]; ////nn=0.0; //if(((y-1) >= 0) && (lbfields[get_linear_index(x,y-1,z,lblattice.halo_grid)].boundary == 0)) nn[2] = -1.0;//neighbours[2] = -1; //if(((y+1) <= lblattice.grid[1]) && (lbfields[get_linear_index(x,y+1,z,lblattice.halo_grid)].boundary == 0)) nn[3] = 1.0;//neighbours[3] = 1; ////printf("%.0lf %.0lf ",nn[2],nn[3]); //lb_boundaries[n].c.voxel.n[1] = nn[2]+nn[3]; ////nn=0.0; //if(((z-1) >= 0) && (lbfields[get_linear_index(x,y,z-1,lblattice.halo_grid)].boundary == 0)) nn[4] = -1.0;//neighbours[4] = -1; //if(((z+1) <= lblattice.grid[2]) && (lbfields[get_linear_index(x,y,z+1,lblattice.halo_grid)].boundary == 0)) nn[5] = 1.0;//neighbours[5]= 1; ////printf("%.0lf %.0lf ",nn[4],nn[5]); //lb_boundaries[n].c.voxel.n[2] = nn[4]+nn[5]; //nn[0]=0.0,nn[1]=0.0,nn[2]=0.0,nn[3]=0.0,nn[4]=0.0,nn[5]=0.0; ////printf("t %d pos: %.0lf %.0lf %.0lf, fluid normal %.0lf %.0lf %.0lf\n",n, x,y,z,lb_boundaries[n].c.voxel.normal[0],lb_boundaries[n].c.voxel.normal[1],lb_boundaries[n].c.voxel.normal[2]); ////printf("boundaries: %d %d %d %d %d %d\n",lbfields[get_linear_index(x-1,y,z,lblattice.halo_grid)].boundary,lbfields[get_linear_index(x+1,y,z,lblattice.halo_grid)].boundary,lbfields[get_linear_index(x,y-1,z,lblattice.halo_grid)].boundary,lbfields[get_linear_index(x,y+1,z,lblattice.halo_grid)].boundary,lbfields[get_linear_index(x,y,z-1,lblattice.halo_grid)].boundary,lbfields[get_linear_index(x,y,z+1,lblattice.halo_grid)].boundary); //break; //default: //break; //} //} //// DO THE SAME FOR THE CONSTRAINTS: CONSTRAINTS MUST BE SET AND THE SAME AS LB_BOUNDARY !!! //for(n=0;n<n_constraints;n++) { //switch(constraints[n].type) { //case CONSTRAINT_VOXEL: //x=constraints[n].c.voxel.pos[0]; //y=constraints[n].c.voxel.pos[1]; //z=constraints[n].c.voxel.pos[2]; //if(((x-1) >= 0) && (lbfields[get_linear_index(x-1,y,z,lblattice.halo_grid)].boundary == 0)) nn[0] = -1.0;//neighbours[0] = -1; //if(((x+1) <= lblattice.grid[0]) && (lbfields[get_linear_index(x+1,y,z,lblattice.halo_grid)].boundary == 0)) nn[1] = 1.0;//neighbours[1] = 1; ////printf("%.0lf %.0lf ",nn[0],nn[1]); //constraints[n].c.voxel.n[0] = nn[0]+nn[1]; ////nn=0.0; //if(((y-1) >= 0) && (lbfields[get_linear_index(x,y-1,z,lblattice.halo_grid)].boundary == 0)) nn[2] = -1.0;//neighbours[2] = -1; //if(((y+1) <= lblattice.grid[1]) && (lbfields[get_linear_index(x,y+1,z,lblattice.halo_grid)].boundary == 0)) nn[3] = 1.0;//neighbours[3] = 1; ////printf("%.0lf %.0lf ",nn[2],nn[3]); //constraints[n].c.voxel.n[1] = nn[2]+nn[3]; ////nn=0.0; //if(((z-1) >= 0) && (lbfields[get_linear_index(x,y,z-1,lblattice.halo_grid)].boundary == 0)) nn[4] = -1.0;//neighbours[4] = -1; //if(((z+1) <= lblattice.grid[2]) && (lbfields[get_linear_index(x,y,z+1,lblattice.halo_grid)].boundary == 0)) nn[5] = 1.0;//neighbours[5]= 1; ////printf("%.0lf %.0lf ",nn[4],nn[5]); //constraints[n].c.voxel.n[2] = nn[4]+nn[5]; //nn[0]=0.0,nn[1]=0.0,nn[2]=0.0,nn[3]=0.0,nn[4]=0.0,nn[5]=0.0; //break; //default: //break; //} //} //#ifdef VOXEL_BOUNDARIES /* for (z=0; z<lblattice.grid[2]+2; z++) { for (y=0; y<lblattice.grid[1]+2; y++) { for (x=0; x<lblattice.grid[0]+2; x++) { lbfields[get_linear_index(x,y,z,lblattice.halo_grid)].boundary = 1; } } } static const char filename[] = "/home/mgusenbauer/Daten/Copy/DUK/GentlePump/Optimierer/voxels/stl/data_final.csv"; FILE *file = fopen ( filename, "r" ); int coords[3]; printf("start new\n"); if ( file != NULL ){ char line [ 128 ]; // or other suitable maximum line size while ( fgets ( line, sizeof line, file ) != NULL ) {// read a line //fputs ( line, stdout ); // write the line //coords = line.Split(' ').Select(n => Convert.ToInt32(n)).ToArray(); //printf("readline: %s\n",line); int i; sscanf(line, "%d %d %d", &coords[0],&coords[1],&coords[2]); //printf("%d %d %d\n", coords[0],coords[1],coords[2]); lbfields[get_linear_index(coords[0]+5,coords[1]+5,coords[2]+5,lblattice.halo_grid)].boundary = 0; } fclose ( file ); } printf("end new\n"); */ #endif } } int lbboundary_get_force(int no, double* f) { #if defined (LB_BOUNDARIES) || defined (LB_BOUNDARIES_GPU) double* forces = (double *) Utils::malloc(3*n_lb_boundaries*sizeof(double)); if (lattice_switch & LATTICE_LB_GPU) { #if defined (LB_BOUNDARIES_GPU) && defined (LB_GPU) lb_gpu_get_boundary_forces(forces); f[0]=-forces[3*no+0]; f[1]=-forces[3*no+1]; f[2]=-forces[3*no+2]; #else return ES_ERROR; #endif } else { #if defined (LB_BOUNDARIES) && defined (LB) mpi_gather_stats(8, forces, NULL, NULL, NULL); f[0]=forces[3*no+0]*lbpar.agrid/lbpar.tau/lbpar.tau; f[1]=forces[3*no+1]*lbpar.agrid/lbpar.tau/lbpar.tau; f[2]=forces[3*no+2]*lbpar.agrid/lbpar.tau/lbpar.tau; #else return ES_ERROR; #endif } free(forces); #endif return 0; } #endif /* LB_BOUNDARIES or LB_BOUNDARIES_GPU */ #ifdef LB_BOUNDARIES void lb_bounce_back() { #ifdef D3Q19 #ifndef PULL int k,i,l; int yperiod = lblattice.halo_grid[0]; int zperiod = lblattice.halo_grid[0]*lblattice.halo_grid[1]; int next[19]; int x,y,z; double population_shift; double modes[19]; next[0] = 0; // ( 0, 0, 0) = next[1] = 1; // ( 1, 0, 0) + next[2] = - 1; // (-1, 0, 0) next[3] = yperiod; // ( 0, 1, 0) + next[4] = - yperiod; // ( 0,-1, 0) next[5] = zperiod; // ( 0, 0, 1) + next[6] = - zperiod; // ( 0, 0,-1) next[7] = (1+yperiod); // ( 1, 1, 0) + next[8] = - (1+yperiod); // (-1,-1, 0) next[9] = (1-yperiod); // ( 1,-1, 0) next[10] = - (1-yperiod); // (-1, 1, 0) + next[11] = (1+zperiod); // ( 1, 0, 1) + next[12] = - (1+zperiod); // (-1, 0,-1) next[13] = (1-zperiod); // ( 1, 0,-1) next[14] = - (1-zperiod); // (-1, 0, 1) + next[15] = (yperiod+zperiod); // ( 0, 1, 1) + next[16] = - (yperiod+zperiod); // ( 0,-1,-1) next[17] = (yperiod-zperiod); // ( 0, 1,-1) next[18] = - (yperiod-zperiod); // ( 0,-1, 1) + int reverse[] = { 0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17 }; /* bottom-up sweep */ // for (k=lblattice.halo_offset;k<lblattice.halo_grid_volume;k++) { for (z=0; z<lblattice.grid[2]+2; z++) { for (y=0; y<lblattice.grid[1]+2; y++) { for (x=0; x<lblattice.grid[0]+2; x++) { k= get_linear_index(x,y,z,lblattice.halo_grid); if (lbfields[k].boundary) { lb_calc_modes(k, modes); for (i=0; i<19; i++) { population_shift=0; for (l=0; l<3; l++) { population_shift-=lbpar.agrid*lbpar.agrid*lbpar.agrid*lbpar.agrid*lbpar.agrid*lbpar.rho[0]*2*lbmodel.c[i][l]*lbmodel.w[i]*lb_boundaries[lbfields[k].boundary-1].velocity[l]/lbmodel.c_sound_sq; } if ( x-lbmodel.c[i][0] > 0 && x -lbmodel.c[i][0] < lblattice.grid[0]+1 && y-lbmodel.c[i][1] > 0 && y -lbmodel.c[i][1] < lblattice.grid[1]+1 && z-lbmodel.c[i][2] > 0 && z -lbmodel.c[i][2] < lblattice.grid[2]+1) { if ( !lbfields[k-next[i]].boundary ) { for (l=0; l<3; l++) { lb_boundaries[lbfields[k].boundary-1].force[l]+=(2*lbfluid[1][i][k]+population_shift)*lbmodel.c[i][l]; } lbfluid[1][reverse[i]][k-next[i]] = lbfluid[1][i][k]+ population_shift; } else { lbfluid[1][reverse[i]][k-next[i]] = lbfluid[1][i][k] = 0.0; } } } } } } } #else #error Bounce back boundary conditions are only implemented for PUSH scheme! #endif #else #error Bounce back boundary conditions are only implemented for D3Q19! #endif } #endif
gpl-3.0