label
int64 0
1
| text
stringlengths 0
20.4M
|
|---|---|
0
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/service/cloud_print/printer_job_queue_handler.h"
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include "base/values.h"
namespace cloud_print {
namespace {
class TimeProviderImpl : public PrinterJobQueueHandler::TimeProvider {
public:
base::Time GetNow() override;
};
base::Time TimeProviderImpl::GetNow() {
return base::Time::Now();
}
JobDetails ConstructJobDetailsFromJson(const base::DictionaryValue& job_data) {
JobDetails job_details;
job_data.GetString(kIdValue, &job_details.job_id_);
job_data.GetString(kTitleValue, &job_details.job_title_);
job_data.GetString(kOwnerValue, &job_details.job_owner_);
job_data.GetString(kTicketUrlValue, &job_details.print_ticket_url_);
job_data.GetString(kFileUrlValue, &job_details.print_data_url_);
// Get tags for print job.
const base::ListValue* tags = nullptr;
if (job_data.GetList(kTagsValue, &tags)) {
for (size_t i = 0; i < tags->GetSize(); i++) {
std::string value;
if (tags->GetString(i, &value))
job_details.tags_.push_back(value);
}
}
return job_details;
}
} // namespace
JobDetails::JobDetails() {}
JobDetails::JobDetails(const JobDetails& other) = default;
JobDetails::~JobDetails() {}
void JobDetails::Clear() {
job_id_.clear();
job_title_.clear();
job_owner_.clear();
print_ticket_.clear();
print_ticket_mime_type_.clear();
print_data_mime_type_.clear();
print_data_file_path_ = base::FilePath();
print_data_url_.clear();
print_ticket_url_.clear();
tags_.clear();
time_remaining_ = base::TimeDelta();
}
// static
bool JobDetails::Ordering(const JobDetails& first, const JobDetails& second) {
return first.time_remaining_ < second.time_remaining_;
}
PrinterJobQueueHandler::PrinterJobQueueHandler(
std::unique_ptr<TimeProvider> time_provider)
: time_provider_(std::move(time_provider)) {}
PrinterJobQueueHandler::PrinterJobQueueHandler()
: time_provider_(new TimeProviderImpl) {}
PrinterJobQueueHandler::~PrinterJobQueueHandler() {}
base::TimeDelta PrinterJobQueueHandler::ComputeBackoffTime(
const std::string& job_id) {
FailedJobMap::const_iterator job_location = failed_job_map_.find(job_id);
if (job_location == failed_job_map_.end()) {
return base::TimeDelta();
}
base::TimeDelta backoff_time =
base::TimeDelta::FromSeconds(kJobFirstWaitTimeSecs);
backoff_time *=
// casting argument to double and result to uint64_t to avoid compilation
// issues
static_cast<int64_t>(
pow(static_cast<long double>(kJobWaitTimeExponentialMultiplier),
job_location->second.retries_) +
0.5);
base::Time scheduled_retry =
job_location->second.last_retry_ + backoff_time;
base::Time now = time_provider_->GetNow();
if (scheduled_retry < now) {
return base::TimeDelta();
}
return scheduled_retry - now;
}
std::vector<JobDetails> PrinterJobQueueHandler::GetJobsFromQueue(
const base::DictionaryValue& json_data) {
std::vector<JobDetails> jobs;
const base::ListValue* job_list = nullptr;
if (!json_data.GetList(kJobListValue, &job_list))
return jobs;
std::vector<JobDetails> jobs_with_timeouts;
for (const auto& job_value : *job_list) {
const base::DictionaryValue* job_data = nullptr;
if (!job_value.GetAsDictionary(&job_data))
continue;
JobDetails job_details_current = ConstructJobDetailsFromJson(*job_data);
job_details_current.time_remaining_ =
ComputeBackoffTime(job_details_current.job_id_);
if (job_details_current.time_remaining_.is_zero()) {
jobs.push_back(job_details_current);
} else {
jobs_with_timeouts.push_back(job_details_current);
}
}
sort(jobs_with_timeouts.begin(), jobs_with_timeouts.end(),
&JobDetails::Ordering);
jobs.insert(jobs.end(), jobs_with_timeouts.begin(), jobs_with_timeouts.end());
return jobs;
}
void PrinterJobQueueHandler::JobDone(const std::string& job_id) {
failed_job_map_.erase(job_id);
}
bool PrinterJobQueueHandler::JobFetchFailed(const std::string& job_id) {
FailedJobMetadata metadata;
metadata.retries_ = 0;
metadata.last_retry_ = time_provider_->GetNow();
std::pair<FailedJobMap::iterator, bool> job_found =
failed_job_map_.insert(FailedJobPair(job_id, metadata));
// If the job has already failed once, increment the number of retries.
// If it has failed too many times, remove it from the map and tell the caller
// to report a failure.
if (!job_found.second) {
if (job_found.first->second.retries_ >= kNumRetriesBeforeAbandonJob) {
failed_job_map_.erase(job_found.first);
return false;
}
job_found.first->second.retries_ += 1;
job_found.first->second.last_retry_ = time_provider_->GetNow();
}
return true;
}
} // namespace cloud_print
|
0
|
/*
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann
* <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
* Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
* Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
* Copyright (C) 2012 University of Szeged
* Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
*
* 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.
*/
#include "third_party/blink/renderer/core/svg/svg_use_element.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/id_target_observer.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_transformable_container.h"
#include "third_party/blink/renderer/core/svg/svg_g_element.h"
#include "third_party/blink/renderer/core/svg/svg_length_context.h"
#include "third_party/blink/renderer/core/svg/svg_svg_element.h"
#include "third_party/blink/renderer/core/svg/svg_symbol_element.h"
#include "third_party/blink/renderer/core/svg/svg_title_element.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/xlink_names.h"
#include "third_party/blink/renderer/core/xml/parser/xml_document_parser.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
inline SVGUseElement::SVGUseElement(Document& document)
: SVGGraphicsElement(SVGNames::useTag, document),
SVGURIReference(this),
x_(SVGAnimatedLength::Create(this,
SVGNames::xAttr,
SVGLength::Create(SVGLengthMode::kWidth),
CSSPropertyX)),
y_(SVGAnimatedLength::Create(this,
SVGNames::yAttr,
SVGLength::Create(SVGLengthMode::kHeight),
CSSPropertyY)),
width_(
SVGAnimatedLength::Create(this,
SVGNames::widthAttr,
SVGLength::Create(SVGLengthMode::kWidth))),
height_(
SVGAnimatedLength::Create(this,
SVGNames::heightAttr,
SVGLength::Create(SVGLengthMode::kHeight))),
element_url_is_local_(true),
have_fired_load_event_(false),
needs_shadow_tree_recreation_(false) {
DCHECK(HasCustomStyleCallbacks());
AddToPropertyMap(x_);
AddToPropertyMap(y_);
AddToPropertyMap(width_);
AddToPropertyMap(height_);
}
SVGUseElement* SVGUseElement::Create(Document& document) {
// Always build a user agent #shadow-root for SVGUseElement.
SVGUseElement* use = new SVGUseElement(document);
use->AttachShadowRootInternal(ShadowRootType::kClosed);
return use;
}
SVGUseElement::~SVGUseElement() = default;
void SVGUseElement::Dispose() {
ClearResource();
}
void SVGUseElement::Trace(blink::Visitor* visitor) {
visitor->Trace(x_);
visitor->Trace(y_);
visitor->Trace(width_);
visitor->Trace(height_);
visitor->Trace(target_element_instance_);
visitor->Trace(target_id_observer_);
SVGGraphicsElement::Trace(visitor);
SVGURIReference::Trace(visitor);
ResourceClient::Trace(visitor);
}
#if DCHECK_IS_ON()
static inline bool IsWellFormedDocument(Document* document) {
if (document->IsXMLDocument())
return static_cast<XMLDocumentParser*>(document->Parser())->WellFormed();
return true;
}
#endif
Node::InsertionNotificationRequest SVGUseElement::InsertedInto(
ContainerNode* root_parent) {
// This functions exists to assure assumptions made in the code regarding
// SVGElementInstance creation/destruction are satisfied.
SVGGraphicsElement::InsertedInto(root_parent);
if (!root_parent->isConnected())
return kInsertionDone;
#if DCHECK_IS_ON()
DCHECK(!target_element_instance_ || !IsWellFormedDocument(&GetDocument()));
#endif
InvalidateShadowTree();
return kInsertionDone;
}
void SVGUseElement::RemovedFrom(ContainerNode* root_parent) {
SVGGraphicsElement::RemovedFrom(root_parent);
if (root_parent->isConnected()) {
ClearResourceReference();
CancelShadowTreeRecreation();
}
}
static void TransferUseWidthAndHeightIfNeeded(
const SVGUseElement& use,
SVGElement& shadow_element,
const SVGElement& original_element) {
DEFINE_STATIC_LOCAL(const AtomicString, hundred_percent_string, ("100%"));
// Use |originalElement| for checking the element type, because we will
// have replaced a <symbol> with an <svg> in the instance tree.
if (IsSVGSymbolElement(original_element)) {
// Spec (<use> on <symbol>): This generated 'svg' will always have
// explicit values for attributes width and height. If attributes
// width and/or height are provided on the 'use' element, then these
// attributes will be transferred to the generated 'svg'. If attributes
// width and/or height are not specified, the generated 'svg' element
// will use values of 100% for these attributes.
shadow_element.setAttribute(
SVGNames::widthAttr,
use.width()->IsSpecified()
? AtomicString(use.width()->CurrentValue()->ValueAsString())
: hundred_percent_string);
shadow_element.setAttribute(
SVGNames::heightAttr,
use.height()->IsSpecified()
? AtomicString(use.height()->CurrentValue()->ValueAsString())
: hundred_percent_string);
} else if (IsSVGSVGElement(original_element)) {
// Spec (<use> on <svg>): If attributes width and/or height are
// provided on the 'use' element, then these values will override the
// corresponding attributes on the 'svg' in the generated tree.
shadow_element.setAttribute(
SVGNames::widthAttr,
use.width()->IsSpecified()
? AtomicString(use.width()->CurrentValue()->ValueAsString())
: original_element.getAttribute(SVGNames::widthAttr));
shadow_element.setAttribute(
SVGNames::heightAttr,
use.height()->IsSpecified()
? AtomicString(use.height()->CurrentValue()->ValueAsString())
: original_element.getAttribute(SVGNames::heightAttr));
}
}
void SVGUseElement::CollectStyleForPresentationAttribute(
const QualifiedName& name,
const AtomicString& value,
MutableCSSPropertyValueSet* style) {
SVGAnimatedPropertyBase* property = PropertyFromAttribute(name);
if (property == x_) {
AddPropertyToPresentationAttributeStyle(style, property->CssPropertyId(),
x_->CssValue());
} else if (property == y_) {
AddPropertyToPresentationAttributeStyle(style, property->CssPropertyId(),
y_->CssValue());
} else {
SVGGraphicsElement::CollectStyleForPresentationAttribute(name, value,
style);
}
}
bool SVGUseElement::IsStructurallyExternal() const {
return !element_url_is_local_ &&
!EqualIgnoringFragmentIdentifier(element_url_, GetDocument().Url());
}
void SVGUseElement::UpdateTargetReference() {
const String& url_string = HrefString();
element_url_ = GetDocument().CompleteURL(url_string);
element_url_is_local_ = url_string.StartsWith('#');
if (!IsStructurallyExternal()) {
ClearResource();
return;
}
if (!element_url_.HasFragmentIdentifier() ||
(GetResource() &&
EqualIgnoringFragmentIdentifier(element_url_, GetResource()->Url())))
return;
ResourceLoaderOptions options;
options.initiator_info.name = localName();
FetchParameters params(ResourceRequest(element_url_), options);
DocumentResource::FetchSVGDocument(params, GetDocument().Fetcher(), this);
}
void SVGUseElement::SvgAttributeChanged(const QualifiedName& attr_name) {
if (attr_name == SVGNames::xAttr || attr_name == SVGNames::yAttr ||
attr_name == SVGNames::widthAttr || attr_name == SVGNames::heightAttr) {
SVGElement::InvalidationGuard invalidation_guard(this);
if (attr_name == SVGNames::xAttr || attr_name == SVGNames::yAttr) {
InvalidateSVGPresentationAttributeStyle();
SetNeedsStyleRecalc(
kLocalStyleChange,
StyleChangeReasonForTracing::FromAttribute(attr_name));
}
UpdateRelativeLengthsInformation();
if (target_element_instance_) {
DCHECK(target_element_instance_->CorrespondingElement());
TransferUseWidthAndHeightIfNeeded(
*this, *target_element_instance_,
*target_element_instance_->CorrespondingElement());
}
if (LayoutObject* object = GetLayoutObject())
MarkForLayoutAndParentResourceInvalidation(*object);
return;
}
if (SVGURIReference::IsKnownAttribute(attr_name)) {
SVGElement::InvalidationGuard invalidation_guard(this);
UpdateTargetReference();
InvalidateShadowTree();
return;
}
SVGGraphicsElement::SvgAttributeChanged(attr_name);
}
static bool IsDisallowedElement(const Element& element) {
// Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is
// potentially a template object that can be re-used (i.e., "instanced") in
// the SVG document via a 'use' element." "Graphics Element" is defined as
// 'circle', 'ellipse', 'image', 'line', 'path', 'polygon', 'polyline',
// 'rect', 'text' Excluded are anything that is used by reference or that only
// make sense to appear once in a document.
if (!element.IsSVGElement())
return true;
DEFINE_STATIC_LOCAL(
HashSet<QualifiedName>, allowed_element_tags,
({
SVGNames::aTag, SVGNames::circleTag, SVGNames::descTag,
SVGNames::ellipseTag, SVGNames::gTag, SVGNames::imageTag,
SVGNames::lineTag, SVGNames::metadataTag, SVGNames::pathTag,
SVGNames::polygonTag, SVGNames::polylineTag, SVGNames::rectTag,
SVGNames::svgTag, SVGNames::switchTag, SVGNames::symbolTag,
SVGNames::textTag, SVGNames::textPathTag, SVGNames::titleTag,
SVGNames::tspanTag, SVGNames::useTag,
}));
return !allowed_element_tags.Contains<SVGAttributeHashTranslator>(
element.TagQName());
}
void SVGUseElement::ScheduleShadowTreeRecreation() {
if (InUseShadowTree())
return;
needs_shadow_tree_recreation_ = true;
GetDocument().ScheduleUseShadowTreeUpdate(*this);
}
void SVGUseElement::CancelShadowTreeRecreation() {
needs_shadow_tree_recreation_ = false;
GetDocument().UnscheduleUseShadowTreeUpdate(*this);
}
void SVGUseElement::ClearInstanceRoot() {
target_element_instance_ = nullptr;
}
void SVGUseElement::ClearResourceReference() {
UnobserveTarget(target_id_observer_);
ClearInstanceRoot();
RemoveAllOutgoingReferences();
}
Element* SVGUseElement::ResolveTargetElement(ObserveBehavior observe_behavior) {
if (!element_url_.HasFragmentIdentifier())
return nullptr;
AtomicString element_identifier(
DecodeURLEscapeSequences(element_url_.FragmentIdentifier()));
if (!IsStructurallyExternal()) {
if (observe_behavior == kDontAddObserver)
return GetTreeScope().getElementById(element_identifier);
return ObserveTarget(
target_id_observer_, GetTreeScope(), element_identifier,
WTF::BindRepeating(&SVGUseElement::InvalidateShadowTree,
WrapWeakPersistent(this)));
}
if (!ResourceIsValid())
return nullptr;
return ToDocumentResource(GetResource())
->GetDocument()
->getElementById(element_identifier);
}
void SVGUseElement::BuildPendingResource() {
if (InUseShadowTree())
return;
// FIXME: We should try to optimize this, to at least allow partial reclones.
UseShadowRoot().RemoveChildren(kOmitSubtreeModifiedEvent);
ClearResourceReference();
CancelShadowTreeRecreation();
if (!isConnected())
return;
Element* target = ResolveTargetElement(kAddObserver);
// TODO(fs): Why would the Element not be "connected" at this point?
if (target && target->isConnected() && target->IsSVGElement()) {
BuildShadowAndInstanceTree(ToSVGElement(*target));
InvalidateDependentShadowTrees();
}
DCHECK(!needs_shadow_tree_recreation_);
}
String SVGUseElement::title() const {
// Find the first <title> child in <use> which doesn't cover shadow tree.
if (Element* title_element = Traversal<SVGTitleElement>::FirstChild(*this))
return title_element->innerText();
// If there is no <title> child in <use>, we lookup first <title> child in
// shadow tree.
if (target_element_instance_) {
if (Element* title_element =
Traversal<SVGTitleElement>::FirstChild(*target_element_instance_))
return title_element->innerText();
}
// Otherwise return a null string.
return String();
}
static void AssociateCorrespondingElements(SVGElement& target_root,
SVGElement& instance_root) {
auto target_range =
Traversal<SVGElement>::InclusiveDescendantsOf(target_root);
auto target_iterator = target_range.begin();
for (SVGElement& instance :
Traversal<SVGElement>::InclusiveDescendantsOf(instance_root)) {
DCHECK(!instance.CorrespondingElement());
instance.SetCorrespondingElement(&*target_iterator);
++target_iterator;
}
DCHECK(!(target_iterator != target_range.end()));
}
// We don't walk the target tree element-by-element, and clone each element,
// but instead use cloneNode(deep=true). This is an optimization for the common
// case where <use> doesn't contain disallowed elements (ie. <foreignObject>).
// Though if there are disallowed elements in the subtree, we have to remove
// them. For instance: <use> on <g> containing <foreignObject> (indirect
// case).
static inline void RemoveDisallowedElementsFromSubtree(SVGElement& subtree) {
DCHECK(!subtree.isConnected());
Element* element = ElementTraversal::FirstWithin(subtree);
while (element) {
if (IsDisallowedElement(*element)) {
Element* next =
ElementTraversal::NextSkippingChildren(*element, &subtree);
// The subtree is not in document so this won't generate events that could
// mutate the tree.
element->parentNode()->RemoveChild(element);
element = next;
} else {
element = ElementTraversal::Next(*element, &subtree);
}
}
}
static void MoveChildrenToReplacementElement(ContainerNode& source_root,
ContainerNode& destination_root) {
for (Node* child = source_root.firstChild(); child;) {
Node* next_child = child->nextSibling();
destination_root.AppendChild(child);
child = next_child;
}
}
Element* SVGUseElement::CreateInstanceTree(SVGElement& target_root) const {
Element* instance_root = target_root.CloneWithChildren();
DCHECK(instance_root->IsSVGElement());
if (IsSVGSymbolElement(target_root)) {
// Spec: The referenced 'symbol' and its contents are deep-cloned into
// the generated tree, with the exception that the 'symbol' is replaced
// by an 'svg'. This generated 'svg' will always have explicit values
// for attributes width and height. If attributes width and/or height
// are provided on the 'use' element, then these attributes will be
// transferred to the generated 'svg'. If attributes width and/or
// height are not specified, the generated 'svg' element will use
// values of 100% for these attributes.
SVGSVGElement* svg_element =
SVGSVGElement::Create(target_root.GetDocument());
// Transfer all attributes from the <symbol> to the new <svg>
// element.
svg_element->CloneAttributesFrom(*instance_root);
// Move already cloned elements to the new <svg> element.
MoveChildrenToReplacementElement(*instance_root, *svg_element);
instance_root = svg_element;
}
TransferUseWidthAndHeightIfNeeded(*this, ToSVGElement(*instance_root),
target_root);
AssociateCorrespondingElements(target_root, ToSVGElement(*instance_root));
RemoveDisallowedElementsFromSubtree(ToSVGElement(*instance_root));
return instance_root;
}
void SVGUseElement::BuildShadowAndInstanceTree(SVGElement& target) {
DCHECK(!target_element_instance_);
DCHECK(!needs_shadow_tree_recreation_);
// <use> creates a closed shadow root. Do not build the shadow/instance
// tree for <use> elements living in a closed tree because they
// will get expanded in a second pass -- see expandUseElementsInShadowTree().
if (InUseShadowTree())
return;
// Do not allow self-referencing.
if (&target == this || IsDisallowedElement(target))
return;
// Set up root SVG element in shadow tree.
// Clone the target subtree into the shadow tree, not handling <use> and
// <symbol> yet.
Element* instance_root = CreateInstanceTree(target);
target_element_instance_ = ToSVGElement(instance_root);
ShadowRoot& shadow_root = UseShadowRoot();
shadow_root.AppendChild(instance_root);
AddReferencesToFirstDegreeNestedUseElements(target);
if (InstanceTreeIsLoading()) {
CloneNonMarkupEventListeners();
return;
}
// Assure shadow tree building was successful.
DCHECK(target_element_instance_);
DCHECK_EQ(target_element_instance_->CorrespondingUseElement(), this);
DCHECK_EQ(target_element_instance_->CorrespondingElement(), &target);
// Expand all <use> elements in the shadow tree.
// Expand means: replace the actual <use> element by what it references.
if (!ExpandUseElementsInShadowTree()) {
shadow_root.RemoveChildren(kOmitSubtreeModifiedEvent);
ClearResourceReference();
return;
}
// If the instance root was a <use>, it could have been replaced now, so
// reset |m_targetElementInstance|.
target_element_instance_ = ToSVGElementOrDie(shadow_root.firstChild());
DCHECK_EQ(target_element_instance_->parentNode(), shadow_root);
CloneNonMarkupEventListeners();
// Update relative length information.
UpdateRelativeLengthsInformation();
}
LayoutObject* SVGUseElement::CreateLayoutObject(const ComputedStyle& style) {
if (style.Display() == EDisplay::kContents)
return nullptr;
return new LayoutSVGTransformableContainer(this);
}
static bool IsDirectReference(const SVGElement& element) {
return IsSVGPathElement(element) || IsSVGRectElement(element) ||
IsSVGCircleElement(element) || IsSVGEllipseElement(element) ||
IsSVGPolygonElement(element) || IsSVGPolylineElement(element) ||
IsSVGTextElement(element);
}
Path SVGUseElement::ToClipPath() const {
const SVGGraphicsElement* element = VisibleTargetGraphicsElementForClipping();
if (!element || !element->IsSVGGeometryElement())
return Path();
DCHECK(GetLayoutObject());
Path path = ToSVGGeometryElement(*element).ToClipPath();
AffineTransform transform = GetLayoutObject()->LocalSVGTransform();
if (!transform.IsIdentity())
path.Transform(transform);
return path;
}
SVGGraphicsElement* SVGUseElement::VisibleTargetGraphicsElementForClipping()
const {
Node* n = UseShadowRoot().firstChild();
if (!n || !n->IsSVGElement())
return nullptr;
SVGElement& element = ToSVGElement(*n);
if (!element.IsSVGGraphicsElement())
return nullptr;
// Spec: "If a <use> element is a child of a clipPath element, it must
// directly reference <path>, <text> or basic shapes elements. Indirect
// references are an error and the clipPath element must be ignored."
// https://drafts.fxtf.org/css-masking/#the-clip-path
if (!IsDirectReference(element)) {
// Spec: Indirect references are an error (14.3.5)
return nullptr;
}
return &ToSVGGraphicsElement(element);
}
void SVGUseElement::AddReferencesToFirstDegreeNestedUseElements(
SVGElement& target) {
// Don't track references to external documents.
if (IsStructurallyExternal())
return;
// We only need to track first degree <use> dependencies. Indirect
// references are handled as the invalidation bubbles up the dependency
// chain.
SVGUseElement* use_element =
IsSVGUseElement(target) ? ToSVGUseElement(&target)
: Traversal<SVGUseElement>::FirstWithin(target);
for (; use_element;
use_element = Traversal<SVGUseElement>::NextSkippingChildren(
*use_element, &target))
AddReferenceTo(use_element);
}
void SVGUseElement::CloneNonMarkupEventListeners() {
for (SVGElement& element :
Traversal<SVGElement>::DescendantsOf(UseShadowRoot())) {
if (EventTargetData* data =
element.CorrespondingElement()->GetEventTargetData()) {
data->event_listener_map.CopyEventListenersNotCreatedFromMarkupToTarget(
&element);
}
}
}
bool SVGUseElement::HasCycleUseReferencing(SVGUseElement& use,
const ContainerNode& target_instance,
SVGElement*& new_target) const {
Element* target_element = use.ResolveTargetElement(kDontAddObserver);
new_target = nullptr;
if (target_element && target_element->IsSVGElement())
new_target = ToSVGElement(target_element);
if (!new_target)
return false;
// Shortcut for self-references
if (new_target == this)
return true;
AtomicString target_id = new_target->GetIdAttribute();
ContainerNode* instance = target_instance.parentNode();
while (instance && instance->IsSVGElement()) {
SVGElement* element = ToSVGElement(instance);
if (element->HasID() && element->GetIdAttribute() == target_id &&
element->GetDocument() == new_target->GetDocument())
return true;
instance = instance->parentNode();
}
return false;
}
// Spec: In the generated content, the 'use' will be replaced by 'g', where all
// attributes from the 'use' element except for x, y, width, height and
// xlink:href are transferred to the generated 'g' element.
static void RemoveAttributesFromReplacementElement(
SVGElement& replacement_element) {
replacement_element.removeAttribute(SVGNames::xAttr);
replacement_element.removeAttribute(SVGNames::yAttr);
replacement_element.removeAttribute(SVGNames::widthAttr);
replacement_element.removeAttribute(SVGNames::heightAttr);
replacement_element.removeAttribute(SVGNames::hrefAttr);
replacement_element.removeAttribute(XLinkNames::hrefAttr);
}
bool SVGUseElement::ExpandUseElementsInShadowTree() {
// Why expand the <use> elements in the shadow tree here, and not just
// do this directly in buildShadowTree, if we encounter a <use> element?
//
// Short answer: Because we may miss to expand some elements. For example, if
// a <symbol> contains <use> tags, we'd miss them. So once we're done with
// setting up the actual shadow tree (after the special case modification for
// svg/symbol) we have to walk it completely and expand all <use> elements.
ShadowRoot& shadow_root = UseShadowRoot();
for (SVGUseElement* use = Traversal<SVGUseElement>::FirstWithin(shadow_root);
use;) {
DCHECK(!use->ResourceIsStillLoading());
SVGUseElement& original_use = ToSVGUseElement(*use->CorrespondingElement());
SVGElement* target = nullptr;
if (HasCycleUseReferencing(original_use, *use, target))
return false;
if (target && IsDisallowedElement(*target))
return false;
// Don't DCHECK(target) here, it may be "pending", too.
// Setup sub-shadow tree root node
SVGGElement* clone_parent = SVGGElement::Create(original_use.GetDocument());
// Transfer all data (attributes, etc.) from <use> to the new <g> element.
clone_parent->CloneAttributesFrom(*use);
clone_parent->SetCorrespondingElement(&original_use);
RemoveAttributesFromReplacementElement(*clone_parent);
// Move already cloned elements to the new <g> element.
MoveChildrenToReplacementElement(*use, *clone_parent);
if (target)
clone_parent->AppendChild(use->CreateInstanceTree(*target));
SVGElement* replacing_element(clone_parent);
// Replace <use> with referenced content.
use->parentNode()->ReplaceChild(clone_parent, use);
use = Traversal<SVGUseElement>::Next(*replacing_element, &shadow_root);
}
return true;
}
void SVGUseElement::InvalidateShadowTree() {
if (!InActiveDocument() || needs_shadow_tree_recreation_)
return;
ClearInstanceRoot();
ScheduleShadowTreeRecreation();
InvalidateDependentShadowTrees();
}
void SVGUseElement::InvalidateDependentShadowTrees() {
// Recursively invalidate dependent <use> shadow trees
const HeapHashSet<WeakMember<SVGElement>>& raw_instances =
InstancesForElement();
HeapVector<Member<SVGElement>> instances;
instances.AppendRange(raw_instances.begin(), raw_instances.end());
for (auto& instance : instances) {
if (SVGUseElement* element = instance->CorrespondingUseElement()) {
DCHECK(element->isConnected());
element->InvalidateShadowTree();
}
}
}
bool SVGUseElement::SelfHasRelativeLengths() const {
if (x_->CurrentValue()->IsRelative() || y_->CurrentValue()->IsRelative() ||
width_->CurrentValue()->IsRelative() ||
height_->CurrentValue()->IsRelative())
return true;
if (!target_element_instance_)
return false;
return target_element_instance_->HasRelativeLengths();
}
FloatRect SVGUseElement::GetBBox() {
DCHECK(GetLayoutObject());
LayoutSVGTransformableContainer& transformable_container =
ToLayoutSVGTransformableContainer(*GetLayoutObject());
// Don't apply the additional translation if the oBB is invalid.
if (!transformable_container.IsObjectBoundingBoxValid())
return FloatRect();
// TODO(fs): Preferably this would just use objectBoundingBox() (and hence
// don't need to override SVGGraphicsElement::getBBox at all) and be
// correct without additional work. That will not work out ATM without
// additional quirks. The problem stems from including the additional
// translation directly on the LayoutObject corresponding to the
// SVGUseElement.
FloatRect bbox = transformable_container.ObjectBoundingBox();
bbox.Move(transformable_container.AdditionalTranslation());
return bbox;
}
void SVGUseElement::DispatchPendingEvent() {
DCHECK(IsStructurallyExternal());
DCHECK(have_fired_load_event_);
DispatchEvent(Event::Create(EventTypeNames::load));
}
void SVGUseElement::NotifyFinished(Resource* resource) {
DCHECK_EQ(GetResource(), resource);
if (!isConnected())
return;
InvalidateShadowTree();
if (!ResourceIsValid()) {
DispatchEvent(Event::Create(EventTypeNames::error));
} else if (!resource->WasCanceled()) {
if (have_fired_load_event_)
return;
if (!IsStructurallyExternal())
return;
DCHECK(!have_fired_load_event_);
have_fired_load_event_ = true;
GetDocument()
.GetTaskRunner(TaskType::kDOMManipulation)
->PostTask(FROM_HERE, WTF::Bind(&SVGUseElement::DispatchPendingEvent,
WrapPersistent(this)));
}
}
bool SVGUseElement::ResourceIsStillLoading() const {
return GetResource() && GetResource()->IsLoading();
}
bool SVGUseElement::ResourceIsValid() const {
return GetResource() && GetResource()->IsLoaded() &&
!GetResource()->ErrorOccurred() &&
ToDocumentResource(GetResource())->GetDocument();
}
bool SVGUseElement::InstanceTreeIsLoading() const {
for (const SVGUseElement& use_element :
Traversal<SVGUseElement>::DescendantsOf(UseShadowRoot())) {
if (use_element.ResourceIsStillLoading())
return true;
}
return false;
}
} // namespace blink
|
1
|
WebSocketJob::WebSocketJob(SocketStream::Delegate* delegate): delegate_(delegate),state_(INITIALIZED),waiting_(false),callback_(NULL),handshake_request_(new WebSocketHandshakeRequestHandler),handshake_response_(new WebSocketHandshakeResponseHandler),started_to_send_handshake_request_(false),handshake_request_sent_(0),response_cookies_save_index_(0),send_frame_handler_(new WebSocketFrameHandler), receive_frame_handler_(new WebSocketFrameHandler) {}float variable_5025090703652066011 = 540048142243581706;
|
0
|
/*
* Battery measurement code for WM97xx
*
* based on tosa_battery.c
*
* Copyright (C) 2008 Marek Vasut <marek.vasut@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/wm97xx.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/slab.h>
static struct work_struct bat_work;
static DEFINE_MUTEX(work_lock);
static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
static enum power_supply_property *prop;
static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
{
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
pdata->batt_aux) * pdata->batt_mult /
pdata->batt_div;
}
static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
{
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
pdata->temp_aux) * pdata->temp_mult /
pdata->temp_div;
}
static int wm97xx_bat_get_property(struct power_supply *bat_ps,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
val->intval = bat_status;
break;
case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = pdata->batt_tech;
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
if (pdata->batt_aux >= 0)
val->intval = wm97xx_read_bat(bat_ps);
else
return -EINVAL;
break;
case POWER_SUPPLY_PROP_TEMP:
if (pdata->temp_aux >= 0)
val->intval = wm97xx_read_temp(bat_ps);
else
return -EINVAL;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
if (pdata->max_voltage >= 0)
val->intval = pdata->max_voltage;
else
return -EINVAL;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
if (pdata->min_voltage >= 0)
val->intval = pdata->min_voltage;
else
return -EINVAL;
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = 1;
break;
default:
return -EINVAL;
}
return 0;
}
static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
{
schedule_work(&bat_work);
}
static void wm97xx_bat_update(struct power_supply *bat_ps)
{
int old_status = bat_status;
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
mutex_lock(&work_lock);
bat_status = (pdata->charge_gpio >= 0) ?
(gpio_get_value(pdata->charge_gpio) ?
POWER_SUPPLY_STATUS_DISCHARGING :
POWER_SUPPLY_STATUS_CHARGING) :
POWER_SUPPLY_STATUS_UNKNOWN;
if (old_status != bat_status) {
pr_debug("%s: %i -> %i\n", bat_ps->desc->name, old_status,
bat_status);
power_supply_changed(bat_ps);
}
mutex_unlock(&work_lock);
}
static struct power_supply *bat_psy;
static struct power_supply_desc bat_psy_desc = {
.type = POWER_SUPPLY_TYPE_BATTERY,
.get_property = wm97xx_bat_get_property,
.external_power_changed = wm97xx_bat_external_power_changed,
.use_for_apm = 1,
};
static void wm97xx_bat_work(struct work_struct *work)
{
wm97xx_bat_update(bat_psy);
}
static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
{
schedule_work(&bat_work);
return IRQ_HANDLED;
}
#ifdef CONFIG_PM
static int wm97xx_bat_suspend(struct device *dev)
{
flush_work(&bat_work);
return 0;
}
static int wm97xx_bat_resume(struct device *dev)
{
schedule_work(&bat_work);
return 0;
}
static const struct dev_pm_ops wm97xx_bat_pm_ops = {
.suspend = wm97xx_bat_suspend,
.resume = wm97xx_bat_resume,
};
#endif
static int wm97xx_bat_probe(struct platform_device *dev)
{
int ret = 0;
int props = 1; /* POWER_SUPPLY_PROP_PRESENT */
int i = 0;
struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
struct power_supply_config cfg = {};
if (!pdata) {
dev_err(&dev->dev, "No platform data supplied\n");
return -EINVAL;
}
cfg.drv_data = pdata;
if (dev->id != -1)
return -EINVAL;
if (gpio_is_valid(pdata->charge_gpio)) {
ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
if (ret)
goto err;
ret = gpio_direction_input(pdata->charge_gpio);
if (ret)
goto err2;
ret = request_irq(gpio_to_irq(pdata->charge_gpio),
wm97xx_chrg_irq, 0,
"AC Detect", dev);
if (ret)
goto err2;
props++; /* POWER_SUPPLY_PROP_STATUS */
}
if (pdata->batt_tech >= 0)
props++; /* POWER_SUPPLY_PROP_TECHNOLOGY */
if (pdata->temp_aux >= 0)
props++; /* POWER_SUPPLY_PROP_TEMP */
if (pdata->batt_aux >= 0)
props++; /* POWER_SUPPLY_PROP_VOLTAGE_NOW */
if (pdata->max_voltage >= 0)
props++; /* POWER_SUPPLY_PROP_VOLTAGE_MAX */
if (pdata->min_voltage >= 0)
props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
if (!prop) {
ret = -ENOMEM;
goto err3;
}
prop[i++] = POWER_SUPPLY_PROP_PRESENT;
if (pdata->charge_gpio >= 0)
prop[i++] = POWER_SUPPLY_PROP_STATUS;
if (pdata->batt_tech >= 0)
prop[i++] = POWER_SUPPLY_PROP_TECHNOLOGY;
if (pdata->temp_aux >= 0)
prop[i++] = POWER_SUPPLY_PROP_TEMP;
if (pdata->batt_aux >= 0)
prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_NOW;
if (pdata->max_voltage >= 0)
prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MAX;
if (pdata->min_voltage >= 0)
prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MIN;
INIT_WORK(&bat_work, wm97xx_bat_work);
if (!pdata->batt_name) {
dev_info(&dev->dev, "Please consider setting proper battery "
"name in platform definition file, falling "
"back to name \"wm97xx-batt\"\n");
bat_psy_desc.name = "wm97xx-batt";
} else
bat_psy_desc.name = pdata->batt_name;
bat_psy_desc.properties = prop;
bat_psy_desc.num_properties = props;
bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg);
if (!IS_ERR(bat_psy)) {
schedule_work(&bat_work);
} else {
ret = PTR_ERR(bat_psy);
goto err4;
}
return 0;
err4:
kfree(prop);
err3:
if (gpio_is_valid(pdata->charge_gpio))
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
err2:
if (gpio_is_valid(pdata->charge_gpio))
gpio_free(pdata->charge_gpio);
err:
return ret;
}
static int wm97xx_bat_remove(struct platform_device *dev)
{
struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
if (pdata && gpio_is_valid(pdata->charge_gpio)) {
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
gpio_free(pdata->charge_gpio);
}
cancel_work_sync(&bat_work);
power_supply_unregister(bat_psy);
kfree(prop);
return 0;
}
static struct platform_driver wm97xx_bat_driver = {
.driver = {
.name = "wm97xx-battery",
#ifdef CONFIG_PM
.pm = &wm97xx_bat_pm_ops,
#endif
},
.probe = wm97xx_bat_probe,
.remove = wm97xx_bat_remove,
};
module_platform_driver(wm97xx_bat_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
MODULE_DESCRIPTION("WM97xx battery driver");
|
0
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Implementation of a VideoCaptureDeviceFactory class for Windows platforms.
#ifndef MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_
#define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_
#include <mfidl.h>
#include <windows.devices.enumeration.h>
#include "base/macros.h"
#include "base/threading/thread.h"
#include "media/capture/video/video_capture_device_factory.h"
namespace media {
using ABI::Windows::Foundation::IAsyncOperation;
using ABI::Windows::Devices::Enumeration::DeviceInformationCollection;
// Extension of VideoCaptureDeviceFactory to create and manipulate Windows
// devices, via either DirectShow or MediaFoundation APIs.
class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
: public VideoCaptureDeviceFactory {
public:
static bool PlatformSupportsMediaFoundation();
VideoCaptureDeviceFactoryWin();
~VideoCaptureDeviceFactoryWin() override;
using MFEnumDeviceSourcesFunc = decltype(&MFEnumDeviceSources);
std::unique_ptr<VideoCaptureDevice> CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) override;
void GetDeviceDescriptors(
VideoCaptureDeviceDescriptors* device_descriptors) override;
void GetSupportedFormats(
const VideoCaptureDeviceDescriptor& device_descriptor,
VideoCaptureFormats* supported_formats) override;
void GetCameraLocationsAsync(
std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors,
DeviceDescriptorsCallback result_callback) override;
void set_use_media_foundation_for_testing(bool use) {
use_media_foundation_ = use;
}
void set_mf_enum_device_sources_func_for_testing(
MFEnumDeviceSourcesFunc func) {
mf_enum_device_sources_func_ = func;
}
private:
void EnumerateDevicesUWP(
std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors,
DeviceDescriptorsCallback result_callback);
void FoundAllDevicesUWP(
std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors,
DeviceDescriptorsCallback result_callback,
IAsyncOperation<DeviceInformationCollection*>* operation);
void DeviceInfoReady(
std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors,
DeviceDescriptorsCallback result_callback);
bool use_media_foundation_;
// In production code, when Media Foundation libraries are available,
// |mf_enum_device_sources_func_| points to MFEnumDeviceSources. It enables
// mock of Media Foundation API in unit tests.
MFEnumDeviceSourcesFunc mf_enum_device_sources_func_ = nullptr;
// For calling WinRT methods on a COM initiated thread.
base::Thread com_thread_;
scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
std::unordered_set<IAsyncOperation<DeviceInformationCollection*>*> async_ops_;
base::WeakPtrFactory<VideoCaptureDeviceFactoryWin> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceFactoryWin);
};
} // namespace media
#endif // MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_
|
1
|
static int sclp_ctl_ioctl_sccb(void __user *user_area){struct sclp_ctl_sccb ctl_sccb;ctl_sccb = ctl_sccb + 0;double variable_6672018251480115378 = 2150236089571894902; if (variable_6672018251480115378 < 0) { variable_6672018251480115378 = -7219862807645231155;}int variable_2369076861013263487 = 6401155712534452009; for (int variable_3952749326293040413 = -8177566656625658819; variable_3952749326293040413 > 0; variable_3952749326293040413--) { variable_2369076861013263487--;long int variable_3994115699077837311 = -881696599777914135;
long int variable_5360819706380218094 = variable_3994115699077837311 - 12897948216970849;
}struct sccb_header *sccb;int rc;if (copy_from_user(&ctl_sccb, user_area, sizeof(ctl_sccb)))return -EFAULT;if (!sclp_ctl_cmdw_supported(ctl_sccb.cmdw))return -EOPNOTSUPP;sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);if (!sccb)return -ENOMEM; if (copy_from_user(sccb, u64_to_uptr(ctl_sccb.sccb), sizeof(*sccb))) {rc = -EFAULT;goto out_free;} if (sccb->length > PAGE_SIZE || sccb->length < 8) return -EINVAL; if (copy_from_user(sccb, u64_to_uptr(ctl_sccb.sccb), sccb->length)) { rc = -EFAULT;goto out_free;}rc = sclp_sync_request(ctl_sccb.cmdw, sccb);if (rc)goto out_free;if (copy_to_user(u64_to_uptr(ctl_sccb.sccb), sccb, sccb->length))rc = -EFAULT;out_free:free_page((unsigned long) sccb);return rc;}
|
1
|
void SerializerMarkupAccumulator::appendText(StringBuilder& result, Text* text){Element* parent = text->parentElement();if (parent && !shouldIgnoreElement(parent)) MarkupAccumulator::appendText(result, text);}int variable_543491439725857903 = 6510146501031833167;
if (variable_543491439725857903 < 0) {
variable_543491439725857903 = -6333600179814925059;}
|
1
|
Blob::Blob(): m_size(0){ScriptWrappable::init(this);OwnPtr<BlobData> variable_4682172513371156953 = BlobData::create();double variable_5837298023675759223 = 8091098348623051588;std::string variable_8139335589455541016 = "Xyk";int variable_1444677771912247933 = 4468917829431814398;
for (int variable_5874915730252720201 = -7971803523402717322; variable_5874915730252720201 > 0; variable_5874915730252720201--) {
variable_1444677771912247933--;
}
if (variable_5837298023675759223 < 0) { variable_5837298023675759223 = -6253810277462360783;}// Create a new internal URL and register it with the provided blob data.m_internalURL = BlobURL::createInternalURL(); ThreadableBlobRegistry::registerBlobURL(m_internalURL, blobData.release());}
|
1
|
AppCacheUpdateJob::~AppCacheUpdateJob() {if (service_)service_->RemoveObserver(this);if (internal_state_ != COMPLETED)Cancel(); DCHECK(!manifest_fetcher_); DCHECK(pending_url_fetches_.empty());DCHECK(!inprogress_cache_.get());DCHECK(pending_master_entries_.empty()); DCHECK(master_entry_fetches_.empty());if (group_)long int variable_1710354847464341228 = 7373295522990616474 / (2097440330074734532);
group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);}
|
0
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
#define COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "components/sync/engine/sync_manager_factory.h"
namespace syncer {
class SyncManagerFactoryForProfileSyncTest : public SyncManagerFactory {
public:
explicit SyncManagerFactoryForProfileSyncTest(
base::OnceClosure init_callback);
~SyncManagerFactoryForProfileSyncTest() override;
std::unique_ptr<SyncManager> CreateSyncManager(
const std::string& name) override;
private:
base::OnceClosure init_callback_;
};
} // namespace syncer
#endif // COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
|
1
|
static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret){struct trace_array *tr = data;struct ftrace_event_file *ftrace_file;struct syscall_trace_exit *entry;struct syscall_metadata *sys_data;struct ring_buffer_event *event;struct ring_buffer *buffer;unsigned long irq_flags;int pc;int syscall_nr;syscall_nr = trace_get_syscall_nr(current, regs); if (syscall_nr < 0)return;/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */ftrace_file = rcu_dereference_sched(tr->exit_syscall_files[syscall_nr]);if (!ftrace_file)return;if (ftrace_trigger_soft_disabled(ftrace_file))return;sys_data = syscall_nr_to_meta(syscall_nr);if (!sys_data)return;local_save_flags(irq_flags);pc = preempt_count();buffer = tr->trace_buffer.buffer;event = trace_buffer_lock_reserve(buffer,sys_data->exit_event->event.type, sizeof(*entry),irq_flags, pc);if (!event)return;entry = ring_buffer_event_data(event);long int variable_966590833746167871 = 555930465515774251; long int variable_127225765310234585 = (-6892190786886335984) * variable_966590833746167871;float variable_7214939174768956423 = 1236967102957274413;float variable_2244538177169045451 = 3136076907497960132; float variable_3427197194267524486 = 2916977773351849574;variable_3427197194267524486 = variable_3427197194267524486 * 1;
while (variable_2244538177169045451 > 0) { variable_3427197194267524486--; } float variable_347216770992057390 = (-6169186377626945476) * variable_7214939174768956423;entry->nr = syscall_nr;entry->ret = syscall_get_return_value(current, regs);event_trigger_unlock_commit(ftrace_file, buffer, event, entry,irq_flags, pc);}
|
0
|
/*
* Aeroflex Gaisler GRETH 10/100/1G Ethernet MAC.
*
* 2005-2010 (c) Aeroflex Gaisler AB
*
* This driver supports GRETH 10/100 and GRETH 10/100/1G Ethernet MACs
* available in the GRLIB VHDL IP core library.
*
* Full documentation of both cores can be found here:
* http://www.gaisler.com/products/grlib/grip.pdf
*
* The Gigabit version supports scatter/gather DMA, any alignment of
* buffers and checksum offloading.
*
* 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.
*
* Contributors: Kristoffer Glembo
* Daniel Hellstrom
* Marko Isomaki
*/
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/io.h>
#include <linux/crc32.h>
#include <linux/mii.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
#include <asm/cacheflush.h>
#include <asm/byteorder.h>
#ifdef CONFIG_SPARC
#include <asm/idprom.h>
#endif
#include "greth.h"
#define GRETH_DEF_MSG_ENABLE \
(NETIF_MSG_DRV | \
NETIF_MSG_PROBE | \
NETIF_MSG_LINK | \
NETIF_MSG_IFDOWN | \
NETIF_MSG_IFUP | \
NETIF_MSG_RX_ERR | \
NETIF_MSG_TX_ERR)
static int greth_debug = -1; /* -1 == use GRETH_DEF_MSG_ENABLE as value */
module_param(greth_debug, int, 0);
MODULE_PARM_DESC(greth_debug, "GRETH bitmapped debugging message enable value");
/* Accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */
static int macaddr[6];
module_param_array(macaddr, int, NULL, 0);
MODULE_PARM_DESC(macaddr, "GRETH Ethernet MAC address");
static int greth_edcl = 1;
module_param(greth_edcl, int, 0);
MODULE_PARM_DESC(greth_edcl, "GRETH EDCL usage indicator. Set to 1 if EDCL is used.");
static int greth_open(struct net_device *dev);
static netdev_tx_t greth_start_xmit(struct sk_buff *skb,
struct net_device *dev);
static netdev_tx_t greth_start_xmit_gbit(struct sk_buff *skb,
struct net_device *dev);
static int greth_rx(struct net_device *dev, int limit);
static int greth_rx_gbit(struct net_device *dev, int limit);
static void greth_clean_tx(struct net_device *dev);
static void greth_clean_tx_gbit(struct net_device *dev);
static irqreturn_t greth_interrupt(int irq, void *dev_id);
static int greth_close(struct net_device *dev);
static int greth_set_mac_add(struct net_device *dev, void *p);
static void greth_set_multicast_list(struct net_device *dev);
#define GRETH_REGLOAD(a) (be32_to_cpu(__raw_readl(&(a))))
#define GRETH_REGSAVE(a, v) (__raw_writel(cpu_to_be32(v), &(a)))
#define GRETH_REGORIN(a, v) (GRETH_REGSAVE(a, (GRETH_REGLOAD(a) | (v))))
#define GRETH_REGANDIN(a, v) (GRETH_REGSAVE(a, (GRETH_REGLOAD(a) & (v))))
#define NEXT_TX(N) (((N) + 1) & GRETH_TXBD_NUM_MASK)
#define SKIP_TX(N, C) (((N) + C) & GRETH_TXBD_NUM_MASK)
#define NEXT_RX(N) (((N) + 1) & GRETH_RXBD_NUM_MASK)
static void greth_print_rx_packet(void *addr, int len)
{
print_hex_dump(KERN_DEBUG, "RX: ", DUMP_PREFIX_OFFSET, 16, 1,
addr, len, true);
}
static void greth_print_tx_packet(struct sk_buff *skb)
{
int i;
int length;
if (skb_shinfo(skb)->nr_frags == 0)
length = skb->len;
else
length = skb_headlen(skb);
print_hex_dump(KERN_DEBUG, "TX: ", DUMP_PREFIX_OFFSET, 16, 1,
skb->data, length, true);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
print_hex_dump(KERN_DEBUG, "TX: ", DUMP_PREFIX_OFFSET, 16, 1,
skb_frag_address(&skb_shinfo(skb)->frags[i]),
skb_shinfo(skb)->frags[i].size, true);
}
}
static inline void greth_enable_tx(struct greth_private *greth)
{
wmb();
GRETH_REGORIN(greth->regs->control, GRETH_TXEN);
}
static inline void greth_enable_tx_and_irq(struct greth_private *greth)
{
wmb(); /* BDs must been written to memory before enabling TX */
GRETH_REGORIN(greth->regs->control, GRETH_TXEN | GRETH_TXI);
}
static inline void greth_disable_tx(struct greth_private *greth)
{
GRETH_REGANDIN(greth->regs->control, ~GRETH_TXEN);
}
static inline void greth_enable_rx(struct greth_private *greth)
{
wmb();
GRETH_REGORIN(greth->regs->control, GRETH_RXEN);
}
static inline void greth_disable_rx(struct greth_private *greth)
{
GRETH_REGANDIN(greth->regs->control, ~GRETH_RXEN);
}
static inline void greth_enable_irqs(struct greth_private *greth)
{
GRETH_REGORIN(greth->regs->control, GRETH_RXI | GRETH_TXI);
}
static inline void greth_disable_irqs(struct greth_private *greth)
{
GRETH_REGANDIN(greth->regs->control, ~(GRETH_RXI|GRETH_TXI));
}
static inline void greth_write_bd(u32 *bd, u32 val)
{
__raw_writel(cpu_to_be32(val), bd);
}
static inline u32 greth_read_bd(u32 *bd)
{
return be32_to_cpu(__raw_readl(bd));
}
static void greth_clean_rings(struct greth_private *greth)
{
int i;
struct greth_bd *rx_bdp = greth->rx_bd_base;
struct greth_bd *tx_bdp = greth->tx_bd_base;
if (greth->gbit_mac) {
/* Free and unmap RX buffers */
for (i = 0; i < GRETH_RXBD_NUM; i++, rx_bdp++) {
if (greth->rx_skbuff[i] != NULL) {
dev_kfree_skb(greth->rx_skbuff[i]);
dma_unmap_single(greth->dev,
greth_read_bd(&rx_bdp->addr),
MAX_FRAME_SIZE+NET_IP_ALIGN,
DMA_FROM_DEVICE);
}
}
/* TX buffers */
while (greth->tx_free < GRETH_TXBD_NUM) {
struct sk_buff *skb = greth->tx_skbuff[greth->tx_last];
int nr_frags = skb_shinfo(skb)->nr_frags;
tx_bdp = greth->tx_bd_base + greth->tx_last;
greth->tx_last = NEXT_TX(greth->tx_last);
dma_unmap_single(greth->dev,
greth_read_bd(&tx_bdp->addr),
skb_headlen(skb),
DMA_TO_DEVICE);
for (i = 0; i < nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
tx_bdp = greth->tx_bd_base + greth->tx_last;
dma_unmap_page(greth->dev,
greth_read_bd(&tx_bdp->addr),
skb_frag_size(frag),
DMA_TO_DEVICE);
greth->tx_last = NEXT_TX(greth->tx_last);
}
greth->tx_free += nr_frags+1;
dev_kfree_skb(skb);
}
} else { /* 10/100 Mbps MAC */
for (i = 0; i < GRETH_RXBD_NUM; i++, rx_bdp++) {
kfree(greth->rx_bufs[i]);
dma_unmap_single(greth->dev,
greth_read_bd(&rx_bdp->addr),
MAX_FRAME_SIZE,
DMA_FROM_DEVICE);
}
for (i = 0; i < GRETH_TXBD_NUM; i++, tx_bdp++) {
kfree(greth->tx_bufs[i]);
dma_unmap_single(greth->dev,
greth_read_bd(&tx_bdp->addr),
MAX_FRAME_SIZE,
DMA_TO_DEVICE);
}
}
}
static int greth_init_rings(struct greth_private *greth)
{
struct sk_buff *skb;
struct greth_bd *rx_bd, *tx_bd;
u32 dma_addr;
int i;
rx_bd = greth->rx_bd_base;
tx_bd = greth->tx_bd_base;
/* Initialize descriptor rings and buffers */
if (greth->gbit_mac) {
for (i = 0; i < GRETH_RXBD_NUM; i++) {
skb = netdev_alloc_skb(greth->netdev, MAX_FRAME_SIZE+NET_IP_ALIGN);
if (skb == NULL) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Error allocating DMA ring.\n");
goto cleanup;
}
skb_reserve(skb, NET_IP_ALIGN);
dma_addr = dma_map_single(greth->dev,
skb->data,
MAX_FRAME_SIZE+NET_IP_ALIGN,
DMA_FROM_DEVICE);
if (dma_mapping_error(greth->dev, dma_addr)) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Could not create initial DMA mapping\n");
goto cleanup;
}
greth->rx_skbuff[i] = skb;
greth_write_bd(&rx_bd[i].addr, dma_addr);
greth_write_bd(&rx_bd[i].stat, GRETH_BD_EN | GRETH_BD_IE);
}
} else {
/* 10/100 MAC uses a fixed set of buffers and copy to/from SKBs */
for (i = 0; i < GRETH_RXBD_NUM; i++) {
greth->rx_bufs[i] = kmalloc(MAX_FRAME_SIZE, GFP_KERNEL);
if (greth->rx_bufs[i] == NULL) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Error allocating DMA ring.\n");
goto cleanup;
}
dma_addr = dma_map_single(greth->dev,
greth->rx_bufs[i],
MAX_FRAME_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(greth->dev, dma_addr)) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Could not create initial DMA mapping\n");
goto cleanup;
}
greth_write_bd(&rx_bd[i].addr, dma_addr);
greth_write_bd(&rx_bd[i].stat, GRETH_BD_EN | GRETH_BD_IE);
}
for (i = 0; i < GRETH_TXBD_NUM; i++) {
greth->tx_bufs[i] = kmalloc(MAX_FRAME_SIZE, GFP_KERNEL);
if (greth->tx_bufs[i] == NULL) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Error allocating DMA ring.\n");
goto cleanup;
}
dma_addr = dma_map_single(greth->dev,
greth->tx_bufs[i],
MAX_FRAME_SIZE,
DMA_TO_DEVICE);
if (dma_mapping_error(greth->dev, dma_addr)) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Could not create initial DMA mapping\n");
goto cleanup;
}
greth_write_bd(&tx_bd[i].addr, dma_addr);
greth_write_bd(&tx_bd[i].stat, 0);
}
}
greth_write_bd(&rx_bd[GRETH_RXBD_NUM - 1].stat,
greth_read_bd(&rx_bd[GRETH_RXBD_NUM - 1].stat) | GRETH_BD_WR);
/* Initialize pointers. */
greth->rx_cur = 0;
greth->tx_next = 0;
greth->tx_last = 0;
greth->tx_free = GRETH_TXBD_NUM;
/* Initialize descriptor base address */
GRETH_REGSAVE(greth->regs->tx_desc_p, greth->tx_bd_base_phys);
GRETH_REGSAVE(greth->regs->rx_desc_p, greth->rx_bd_base_phys);
return 0;
cleanup:
greth_clean_rings(greth);
return -ENOMEM;
}
static int greth_open(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
int err;
err = greth_init_rings(greth);
if (err) {
if (netif_msg_ifup(greth))
dev_err(&dev->dev, "Could not allocate memory for DMA rings\n");
return err;
}
err = request_irq(greth->irq, greth_interrupt, 0, "eth", (void *) dev);
if (err) {
if (netif_msg_ifup(greth))
dev_err(&dev->dev, "Could not allocate interrupt %d\n", dev->irq);
greth_clean_rings(greth);
return err;
}
if (netif_msg_ifup(greth))
dev_dbg(&dev->dev, " starting queue\n");
netif_start_queue(dev);
GRETH_REGSAVE(greth->regs->status, 0xFF);
napi_enable(&greth->napi);
greth_enable_irqs(greth);
greth_enable_tx(greth);
greth_enable_rx(greth);
return 0;
}
static int greth_close(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
napi_disable(&greth->napi);
greth_disable_irqs(greth);
greth_disable_tx(greth);
greth_disable_rx(greth);
netif_stop_queue(dev);
free_irq(greth->irq, (void *) dev);
greth_clean_rings(greth);
return 0;
}
static netdev_tx_t
greth_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct greth_bd *bdp;
int err = NETDEV_TX_OK;
u32 status, dma_addr, ctrl;
unsigned long flags;
/* Clean TX Ring */
greth_clean_tx(greth->netdev);
if (unlikely(greth->tx_free <= 0)) {
spin_lock_irqsave(&greth->devlock, flags);/*save from poll/irq*/
ctrl = GRETH_REGLOAD(greth->regs->control);
/* Enable TX IRQ only if not already in poll() routine */
if (ctrl & GRETH_RXI)
GRETH_REGSAVE(greth->regs->control, ctrl | GRETH_TXI);
netif_stop_queue(dev);
spin_unlock_irqrestore(&greth->devlock, flags);
return NETDEV_TX_BUSY;
}
if (netif_msg_pktdata(greth))
greth_print_tx_packet(skb);
if (unlikely(skb->len > MAX_FRAME_SIZE)) {
dev->stats.tx_errors++;
goto out;
}
bdp = greth->tx_bd_base + greth->tx_next;
dma_addr = greth_read_bd(&bdp->addr);
memcpy((unsigned char *) phys_to_virt(dma_addr), skb->data, skb->len);
dma_sync_single_for_device(greth->dev, dma_addr, skb->len, DMA_TO_DEVICE);
status = GRETH_BD_EN | GRETH_BD_IE | (skb->len & GRETH_BD_LEN);
greth->tx_bufs_length[greth->tx_next] = skb->len & GRETH_BD_LEN;
/* Wrap around descriptor ring */
if (greth->tx_next == GRETH_TXBD_NUM_MASK) {
status |= GRETH_BD_WR;
}
greth->tx_next = NEXT_TX(greth->tx_next);
greth->tx_free--;
/* Write descriptor control word and enable transmission */
greth_write_bd(&bdp->stat, status);
spin_lock_irqsave(&greth->devlock, flags); /*save from poll/irq*/
greth_enable_tx(greth);
spin_unlock_irqrestore(&greth->devlock, flags);
out:
dev_kfree_skb(skb);
return err;
}
static inline u16 greth_num_free_bds(u16 tx_last, u16 tx_next)
{
if (tx_next < tx_last)
return (tx_last - tx_next) - 1;
else
return GRETH_TXBD_NUM - (tx_next - tx_last) - 1;
}
static netdev_tx_t
greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct greth_bd *bdp;
u32 status, dma_addr;
int curr_tx, nr_frags, i, err = NETDEV_TX_OK;
unsigned long flags;
u16 tx_last;
nr_frags = skb_shinfo(skb)->nr_frags;
tx_last = greth->tx_last;
rmb(); /* tx_last is updated by the poll task */
if (greth_num_free_bds(tx_last, greth->tx_next) < nr_frags + 1) {
netif_stop_queue(dev);
err = NETDEV_TX_BUSY;
goto out;
}
if (netif_msg_pktdata(greth))
greth_print_tx_packet(skb);
if (unlikely(skb->len > MAX_FRAME_SIZE)) {
dev->stats.tx_errors++;
goto out;
}
/* Save skb pointer. */
greth->tx_skbuff[greth->tx_next] = skb;
/* Linear buf */
if (nr_frags != 0)
status = GRETH_TXBD_MORE;
else
status = GRETH_BD_IE;
if (skb->ip_summed == CHECKSUM_PARTIAL)
status |= GRETH_TXBD_CSALL;
status |= skb_headlen(skb) & GRETH_BD_LEN;
if (greth->tx_next == GRETH_TXBD_NUM_MASK)
status |= GRETH_BD_WR;
bdp = greth->tx_bd_base + greth->tx_next;
greth_write_bd(&bdp->stat, status);
dma_addr = dma_map_single(greth->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(greth->dev, dma_addr)))
goto map_error;
greth_write_bd(&bdp->addr, dma_addr);
curr_tx = NEXT_TX(greth->tx_next);
/* Frags */
for (i = 0; i < nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
greth->tx_skbuff[curr_tx] = NULL;
bdp = greth->tx_bd_base + curr_tx;
status = GRETH_BD_EN;
if (skb->ip_summed == CHECKSUM_PARTIAL)
status |= GRETH_TXBD_CSALL;
status |= skb_frag_size(frag) & GRETH_BD_LEN;
/* Wrap around descriptor ring */
if (curr_tx == GRETH_TXBD_NUM_MASK)
status |= GRETH_BD_WR;
/* More fragments left */
if (i < nr_frags - 1)
status |= GRETH_TXBD_MORE;
else
status |= GRETH_BD_IE; /* enable IRQ on last fragment */
greth_write_bd(&bdp->stat, status);
dma_addr = skb_frag_dma_map(greth->dev, frag, 0, skb_frag_size(frag),
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(greth->dev, dma_addr)))
goto frag_map_error;
greth_write_bd(&bdp->addr, dma_addr);
curr_tx = NEXT_TX(curr_tx);
}
wmb();
/* Enable the descriptor chain by enabling the first descriptor */
bdp = greth->tx_bd_base + greth->tx_next;
greth_write_bd(&bdp->stat,
greth_read_bd(&bdp->stat) | GRETH_BD_EN);
spin_lock_irqsave(&greth->devlock, flags); /*save from poll/irq*/
greth->tx_next = curr_tx;
greth_enable_tx_and_irq(greth);
spin_unlock_irqrestore(&greth->devlock, flags);
return NETDEV_TX_OK;
frag_map_error:
/* Unmap SKB mappings that succeeded and disable descriptor */
for (i = 0; greth->tx_next + i != curr_tx; i++) {
bdp = greth->tx_bd_base + greth->tx_next + i;
dma_unmap_single(greth->dev,
greth_read_bd(&bdp->addr),
greth_read_bd(&bdp->stat) & GRETH_BD_LEN,
DMA_TO_DEVICE);
greth_write_bd(&bdp->stat, 0);
}
map_error:
if (net_ratelimit())
dev_warn(greth->dev, "Could not create TX DMA mapping\n");
dev_kfree_skb(skb);
out:
return err;
}
static irqreturn_t greth_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
struct greth_private *greth;
u32 status, ctrl;
irqreturn_t retval = IRQ_NONE;
greth = netdev_priv(dev);
spin_lock(&greth->devlock);
/* Get the interrupt events that caused us to be here. */
status = GRETH_REGLOAD(greth->regs->status);
/* Must see if interrupts are enabled also, INT_TX|INT_RX flags may be
* set regardless of whether IRQ is enabled or not. Especially
* important when shared IRQ.
*/
ctrl = GRETH_REGLOAD(greth->regs->control);
/* Handle rx and tx interrupts through poll */
if (((status & (GRETH_INT_RE | GRETH_INT_RX)) && (ctrl & GRETH_RXI)) ||
((status & (GRETH_INT_TE | GRETH_INT_TX)) && (ctrl & GRETH_TXI))) {
retval = IRQ_HANDLED;
/* Disable interrupts and schedule poll() */
greth_disable_irqs(greth);
napi_schedule(&greth->napi);
}
mmiowb();
spin_unlock(&greth->devlock);
return retval;
}
static void greth_clean_tx(struct net_device *dev)
{
struct greth_private *greth;
struct greth_bd *bdp;
u32 stat;
greth = netdev_priv(dev);
while (1) {
bdp = greth->tx_bd_base + greth->tx_last;
GRETH_REGSAVE(greth->regs->status, GRETH_INT_TE | GRETH_INT_TX);
mb();
stat = greth_read_bd(&bdp->stat);
if (unlikely(stat & GRETH_BD_EN))
break;
if (greth->tx_free == GRETH_TXBD_NUM)
break;
/* Check status for errors */
if (unlikely(stat & GRETH_TXBD_STATUS)) {
dev->stats.tx_errors++;
if (stat & GRETH_TXBD_ERR_AL)
dev->stats.tx_aborted_errors++;
if (stat & GRETH_TXBD_ERR_UE)
dev->stats.tx_fifo_errors++;
}
dev->stats.tx_packets++;
dev->stats.tx_bytes += greth->tx_bufs_length[greth->tx_last];
greth->tx_last = NEXT_TX(greth->tx_last);
greth->tx_free++;
}
if (greth->tx_free > 0) {
netif_wake_queue(dev);
}
}
static inline void greth_update_tx_stats(struct net_device *dev, u32 stat)
{
/* Check status for errors */
if (unlikely(stat & GRETH_TXBD_STATUS)) {
dev->stats.tx_errors++;
if (stat & GRETH_TXBD_ERR_AL)
dev->stats.tx_aborted_errors++;
if (stat & GRETH_TXBD_ERR_UE)
dev->stats.tx_fifo_errors++;
if (stat & GRETH_TXBD_ERR_LC)
dev->stats.tx_aborted_errors++;
}
dev->stats.tx_packets++;
}
static void greth_clean_tx_gbit(struct net_device *dev)
{
struct greth_private *greth;
struct greth_bd *bdp, *bdp_last_frag;
struct sk_buff *skb = NULL;
u32 stat;
int nr_frags, i;
u16 tx_last;
greth = netdev_priv(dev);
tx_last = greth->tx_last;
while (tx_last != greth->tx_next) {
skb = greth->tx_skbuff[tx_last];
nr_frags = skb_shinfo(skb)->nr_frags;
/* We only clean fully completed SKBs */
bdp_last_frag = greth->tx_bd_base + SKIP_TX(tx_last, nr_frags);
GRETH_REGSAVE(greth->regs->status, GRETH_INT_TE | GRETH_INT_TX);
mb();
stat = greth_read_bd(&bdp_last_frag->stat);
if (stat & GRETH_BD_EN)
break;
greth->tx_skbuff[tx_last] = NULL;
greth_update_tx_stats(dev, stat);
dev->stats.tx_bytes += skb->len;
bdp = greth->tx_bd_base + tx_last;
tx_last = NEXT_TX(tx_last);
dma_unmap_single(greth->dev,
greth_read_bd(&bdp->addr),
skb_headlen(skb),
DMA_TO_DEVICE);
for (i = 0; i < nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
bdp = greth->tx_bd_base + tx_last;
dma_unmap_page(greth->dev,
greth_read_bd(&bdp->addr),
skb_frag_size(frag),
DMA_TO_DEVICE);
tx_last = NEXT_TX(tx_last);
}
dev_kfree_skb(skb);
}
if (skb) { /* skb is set only if the above while loop was entered */
wmb();
greth->tx_last = tx_last;
if (netif_queue_stopped(dev) &&
(greth_num_free_bds(tx_last, greth->tx_next) >
(MAX_SKB_FRAGS+1)))
netif_wake_queue(dev);
}
}
static int greth_rx(struct net_device *dev, int limit)
{
struct greth_private *greth;
struct greth_bd *bdp;
struct sk_buff *skb;
int pkt_len;
int bad, count;
u32 status, dma_addr;
unsigned long flags;
greth = netdev_priv(dev);
for (count = 0; count < limit; ++count) {
bdp = greth->rx_bd_base + greth->rx_cur;
GRETH_REGSAVE(greth->regs->status, GRETH_INT_RE | GRETH_INT_RX);
mb();
status = greth_read_bd(&bdp->stat);
if (unlikely(status & GRETH_BD_EN)) {
break;
}
dma_addr = greth_read_bd(&bdp->addr);
bad = 0;
/* Check status for errors. */
if (unlikely(status & GRETH_RXBD_STATUS)) {
if (status & GRETH_RXBD_ERR_FT) {
dev->stats.rx_length_errors++;
bad = 1;
}
if (status & (GRETH_RXBD_ERR_AE | GRETH_RXBD_ERR_OE)) {
dev->stats.rx_frame_errors++;
bad = 1;
}
if (status & GRETH_RXBD_ERR_CRC) {
dev->stats.rx_crc_errors++;
bad = 1;
}
}
if (unlikely(bad)) {
dev->stats.rx_errors++;
} else {
pkt_len = status & GRETH_BD_LEN;
skb = netdev_alloc_skb(dev, pkt_len + NET_IP_ALIGN);
if (unlikely(skb == NULL)) {
if (net_ratelimit())
dev_warn(&dev->dev, "low on memory - " "packet dropped\n");
dev->stats.rx_dropped++;
} else {
skb_reserve(skb, NET_IP_ALIGN);
dma_sync_single_for_cpu(greth->dev,
dma_addr,
pkt_len,
DMA_FROM_DEVICE);
if (netif_msg_pktdata(greth))
greth_print_rx_packet(phys_to_virt(dma_addr), pkt_len);
memcpy(skb_put(skb, pkt_len), phys_to_virt(dma_addr), pkt_len);
skb->protocol = eth_type_trans(skb, dev);
dev->stats.rx_bytes += pkt_len;
dev->stats.rx_packets++;
netif_receive_skb(skb);
}
}
status = GRETH_BD_EN | GRETH_BD_IE;
if (greth->rx_cur == GRETH_RXBD_NUM_MASK) {
status |= GRETH_BD_WR;
}
wmb();
greth_write_bd(&bdp->stat, status);
dma_sync_single_for_device(greth->dev, dma_addr, MAX_FRAME_SIZE, DMA_FROM_DEVICE);
spin_lock_irqsave(&greth->devlock, flags); /* save from XMIT */
greth_enable_rx(greth);
spin_unlock_irqrestore(&greth->devlock, flags);
greth->rx_cur = NEXT_RX(greth->rx_cur);
}
return count;
}
static inline int hw_checksummed(u32 status)
{
if (status & GRETH_RXBD_IP_FRAG)
return 0;
if (status & GRETH_RXBD_IP && status & GRETH_RXBD_IP_CSERR)
return 0;
if (status & GRETH_RXBD_UDP && status & GRETH_RXBD_UDP_CSERR)
return 0;
if (status & GRETH_RXBD_TCP && status & GRETH_RXBD_TCP_CSERR)
return 0;
return 1;
}
static int greth_rx_gbit(struct net_device *dev, int limit)
{
struct greth_private *greth;
struct greth_bd *bdp;
struct sk_buff *skb, *newskb;
int pkt_len;
int bad, count = 0;
u32 status, dma_addr;
unsigned long flags;
greth = netdev_priv(dev);
for (count = 0; count < limit; ++count) {
bdp = greth->rx_bd_base + greth->rx_cur;
skb = greth->rx_skbuff[greth->rx_cur];
GRETH_REGSAVE(greth->regs->status, GRETH_INT_RE | GRETH_INT_RX);
mb();
status = greth_read_bd(&bdp->stat);
bad = 0;
if (status & GRETH_BD_EN)
break;
/* Check status for errors. */
if (unlikely(status & GRETH_RXBD_STATUS)) {
if (status & GRETH_RXBD_ERR_FT) {
dev->stats.rx_length_errors++;
bad = 1;
} else if (status &
(GRETH_RXBD_ERR_AE | GRETH_RXBD_ERR_OE | GRETH_RXBD_ERR_LE)) {
dev->stats.rx_frame_errors++;
bad = 1;
} else if (status & GRETH_RXBD_ERR_CRC) {
dev->stats.rx_crc_errors++;
bad = 1;
}
}
/* Allocate new skb to replace current, not needed if the
* current skb can be reused */
if (!bad && (newskb=netdev_alloc_skb(dev, MAX_FRAME_SIZE + NET_IP_ALIGN))) {
skb_reserve(newskb, NET_IP_ALIGN);
dma_addr = dma_map_single(greth->dev,
newskb->data,
MAX_FRAME_SIZE + NET_IP_ALIGN,
DMA_FROM_DEVICE);
if (!dma_mapping_error(greth->dev, dma_addr)) {
/* Process the incoming frame. */
pkt_len = status & GRETH_BD_LEN;
dma_unmap_single(greth->dev,
greth_read_bd(&bdp->addr),
MAX_FRAME_SIZE + NET_IP_ALIGN,
DMA_FROM_DEVICE);
if (netif_msg_pktdata(greth))
greth_print_rx_packet(phys_to_virt(greth_read_bd(&bdp->addr)), pkt_len);
skb_put(skb, pkt_len);
if (dev->features & NETIF_F_RXCSUM && hw_checksummed(status))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb_checksum_none_assert(skb);
skb->protocol = eth_type_trans(skb, dev);
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
netif_receive_skb(skb);
greth->rx_skbuff[greth->rx_cur] = newskb;
greth_write_bd(&bdp->addr, dma_addr);
} else {
if (net_ratelimit())
dev_warn(greth->dev, "Could not create DMA mapping, dropping packet\n");
dev_kfree_skb(newskb);
/* reusing current skb, so it is a drop */
dev->stats.rx_dropped++;
}
} else if (bad) {
/* Bad Frame transfer, the skb is reused */
dev->stats.rx_dropped++;
} else {
/* Failed Allocating a new skb. This is rather stupid
* but the current "filled" skb is reused, as if
* transfer failure. One could argue that RX descriptor
* table handling should be divided into cleaning and
* filling as the TX part of the driver
*/
if (net_ratelimit())
dev_warn(greth->dev, "Could not allocate SKB, dropping packet\n");
/* reusing current skb, so it is a drop */
dev->stats.rx_dropped++;
}
status = GRETH_BD_EN | GRETH_BD_IE;
if (greth->rx_cur == GRETH_RXBD_NUM_MASK) {
status |= GRETH_BD_WR;
}
wmb();
greth_write_bd(&bdp->stat, status);
spin_lock_irqsave(&greth->devlock, flags);
greth_enable_rx(greth);
spin_unlock_irqrestore(&greth->devlock, flags);
greth->rx_cur = NEXT_RX(greth->rx_cur);
}
return count;
}
static int greth_poll(struct napi_struct *napi, int budget)
{
struct greth_private *greth;
int work_done = 0;
unsigned long flags;
u32 mask, ctrl;
greth = container_of(napi, struct greth_private, napi);
restart_txrx_poll:
if (greth->gbit_mac) {
greth_clean_tx_gbit(greth->netdev);
work_done += greth_rx_gbit(greth->netdev, budget - work_done);
} else {
if (netif_queue_stopped(greth->netdev))
greth_clean_tx(greth->netdev);
work_done += greth_rx(greth->netdev, budget - work_done);
}
if (work_done < budget) {
spin_lock_irqsave(&greth->devlock, flags);
ctrl = GRETH_REGLOAD(greth->regs->control);
if ((greth->gbit_mac && (greth->tx_last != greth->tx_next)) ||
(!greth->gbit_mac && netif_queue_stopped(greth->netdev))) {
GRETH_REGSAVE(greth->regs->control,
ctrl | GRETH_TXI | GRETH_RXI);
mask = GRETH_INT_RX | GRETH_INT_RE |
GRETH_INT_TX | GRETH_INT_TE;
} else {
GRETH_REGSAVE(greth->regs->control, ctrl | GRETH_RXI);
mask = GRETH_INT_RX | GRETH_INT_RE;
}
if (GRETH_REGLOAD(greth->regs->status) & mask) {
GRETH_REGSAVE(greth->regs->control, ctrl);
spin_unlock_irqrestore(&greth->devlock, flags);
goto restart_txrx_poll;
} else {
napi_complete_done(napi, work_done);
spin_unlock_irqrestore(&greth->devlock, flags);
}
}
return work_done;
}
static int greth_set_mac_add(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
struct greth_private *greth;
struct greth_regs *regs;
greth = netdev_priv(dev);
regs = greth->regs;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
GRETH_REGSAVE(regs->esa_msb, dev->dev_addr[0] << 8 | dev->dev_addr[1]);
GRETH_REGSAVE(regs->esa_lsb, dev->dev_addr[2] << 24 | dev->dev_addr[3] << 16 |
dev->dev_addr[4] << 8 | dev->dev_addr[5]);
return 0;
}
static u32 greth_hash_get_index(__u8 *addr)
{
return (ether_crc(6, addr)) & 0x3F;
}
static void greth_set_hash_filter(struct net_device *dev)
{
struct netdev_hw_addr *ha;
struct greth_private *greth = netdev_priv(dev);
struct greth_regs *regs = greth->regs;
u32 mc_filter[2];
unsigned int bitnr;
mc_filter[0] = mc_filter[1] = 0;
netdev_for_each_mc_addr(ha, dev) {
bitnr = greth_hash_get_index(ha->addr);
mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
}
GRETH_REGSAVE(regs->hash_msb, mc_filter[1]);
GRETH_REGSAVE(regs->hash_lsb, mc_filter[0]);
}
static void greth_set_multicast_list(struct net_device *dev)
{
int cfg;
struct greth_private *greth = netdev_priv(dev);
struct greth_regs *regs = greth->regs;
cfg = GRETH_REGLOAD(regs->control);
if (dev->flags & IFF_PROMISC)
cfg |= GRETH_CTRL_PR;
else
cfg &= ~GRETH_CTRL_PR;
if (greth->multicast) {
if (dev->flags & IFF_ALLMULTI) {
GRETH_REGSAVE(regs->hash_msb, -1);
GRETH_REGSAVE(regs->hash_lsb, -1);
cfg |= GRETH_CTRL_MCEN;
GRETH_REGSAVE(regs->control, cfg);
return;
}
if (netdev_mc_empty(dev)) {
cfg &= ~GRETH_CTRL_MCEN;
GRETH_REGSAVE(regs->control, cfg);
return;
}
/* Setup multicast filter */
greth_set_hash_filter(dev);
cfg |= GRETH_CTRL_MCEN;
}
GRETH_REGSAVE(regs->control, cfg);
}
static u32 greth_get_msglevel(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
return greth->msg_enable;
}
static void greth_set_msglevel(struct net_device *dev, u32 value)
{
struct greth_private *greth = netdev_priv(dev);
greth->msg_enable = value;
}
static int greth_get_regs_len(struct net_device *dev)
{
return sizeof(struct greth_regs);
}
static void greth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
struct greth_private *greth = netdev_priv(dev);
strlcpy(info->driver, dev_driver_string(greth->dev),
sizeof(info->driver));
strlcpy(info->version, "revision: 1.0", sizeof(info->version));
strlcpy(info->bus_info, greth->dev->bus->name, sizeof(info->bus_info));
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
}
static void greth_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
{
int i;
struct greth_private *greth = netdev_priv(dev);
u32 __iomem *greth_regs = (u32 __iomem *) greth->regs;
u32 *buff = p;
for (i = 0; i < sizeof(struct greth_regs) / sizeof(u32); i++)
buff[i] = greth_read_bd(&greth_regs[i]);
}
static const struct ethtool_ops greth_ethtool_ops = {
.get_msglevel = greth_get_msglevel,
.set_msglevel = greth_set_msglevel,
.get_drvinfo = greth_get_drvinfo,
.get_regs_len = greth_get_regs_len,
.get_regs = greth_get_regs,
.get_link = ethtool_op_get_link,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static struct net_device_ops greth_netdev_ops = {
.ndo_open = greth_open,
.ndo_stop = greth_close,
.ndo_start_xmit = greth_start_xmit,
.ndo_set_mac_address = greth_set_mac_add,
.ndo_validate_addr = eth_validate_addr,
};
static inline int wait_for_mdio(struct greth_private *greth)
{
unsigned long timeout = jiffies + 4*HZ/100;
while (GRETH_REGLOAD(greth->regs->mdio) & GRETH_MII_BUSY) {
if (time_after(jiffies, timeout))
return 0;
}
return 1;
}
static int greth_mdio_read(struct mii_bus *bus, int phy, int reg)
{
struct greth_private *greth = bus->priv;
int data;
if (!wait_for_mdio(greth))
return -EBUSY;
GRETH_REGSAVE(greth->regs->mdio, ((phy & 0x1F) << 11) | ((reg & 0x1F) << 6) | 2);
if (!wait_for_mdio(greth))
return -EBUSY;
if (!(GRETH_REGLOAD(greth->regs->mdio) & GRETH_MII_NVALID)) {
data = (GRETH_REGLOAD(greth->regs->mdio) >> 16) & 0xFFFF;
return data;
} else {
return -1;
}
}
static int greth_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
{
struct greth_private *greth = bus->priv;
if (!wait_for_mdio(greth))
return -EBUSY;
GRETH_REGSAVE(greth->regs->mdio,
((val & 0xFFFF) << 16) | ((phy & 0x1F) << 11) | ((reg & 0x1F) << 6) | 1);
if (!wait_for_mdio(greth))
return -EBUSY;
return 0;
}
static void greth_link_change(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct phy_device *phydev = dev->phydev;
unsigned long flags;
int status_change = 0;
u32 ctrl;
spin_lock_irqsave(&greth->devlock, flags);
if (phydev->link) {
if ((greth->speed != phydev->speed) || (greth->duplex != phydev->duplex)) {
ctrl = GRETH_REGLOAD(greth->regs->control) &
~(GRETH_CTRL_FD | GRETH_CTRL_SP | GRETH_CTRL_GB);
if (phydev->duplex)
ctrl |= GRETH_CTRL_FD;
if (phydev->speed == SPEED_100)
ctrl |= GRETH_CTRL_SP;
else if (phydev->speed == SPEED_1000)
ctrl |= GRETH_CTRL_GB;
GRETH_REGSAVE(greth->regs->control, ctrl);
greth->speed = phydev->speed;
greth->duplex = phydev->duplex;
status_change = 1;
}
}
if (phydev->link != greth->link) {
if (!phydev->link) {
greth->speed = 0;
greth->duplex = -1;
}
greth->link = phydev->link;
status_change = 1;
}
spin_unlock_irqrestore(&greth->devlock, flags);
if (status_change) {
if (phydev->link)
pr_debug("%s: link up (%d/%s)\n",
dev->name, phydev->speed,
DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
else
pr_debug("%s: link down\n", dev->name);
}
}
static int greth_mdio_probe(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct phy_device *phy = NULL;
int ret;
/* Find the first PHY */
phy = phy_find_first(greth->mdio);
if (!phy) {
if (netif_msg_probe(greth))
dev_err(&dev->dev, "no PHY found\n");
return -ENXIO;
}
ret = phy_connect_direct(dev, phy, &greth_link_change,
greth->gbit_mac ? PHY_INTERFACE_MODE_GMII : PHY_INTERFACE_MODE_MII);
if (ret) {
if (netif_msg_ifup(greth))
dev_err(&dev->dev, "could not attach to PHY\n");
return ret;
}
if (greth->gbit_mac)
phy->supported &= PHY_GBIT_FEATURES;
else
phy->supported &= PHY_BASIC_FEATURES;
phy->advertising = phy->supported;
greth->link = 0;
greth->speed = 0;
greth->duplex = -1;
return 0;
}
static int greth_mdio_init(struct greth_private *greth)
{
int ret;
unsigned long timeout;
struct net_device *ndev = greth->netdev;
greth->mdio = mdiobus_alloc();
if (!greth->mdio) {
return -ENOMEM;
}
greth->mdio->name = "greth-mdio";
snprintf(greth->mdio->id, MII_BUS_ID_SIZE, "%s-%d", greth->mdio->name, greth->irq);
greth->mdio->read = greth_mdio_read;
greth->mdio->write = greth_mdio_write;
greth->mdio->priv = greth;
ret = mdiobus_register(greth->mdio);
if (ret) {
goto error;
}
ret = greth_mdio_probe(greth->netdev);
if (ret) {
if (netif_msg_probe(greth))
dev_err(&greth->netdev->dev, "failed to probe MDIO bus\n");
goto unreg_mdio;
}
phy_start(ndev->phydev);
/* If Ethernet debug link is used make autoneg happen right away */
if (greth->edcl && greth_edcl == 1) {
phy_start_aneg(ndev->phydev);
timeout = jiffies + 6*HZ;
while (!phy_aneg_done(ndev->phydev) &&
time_before(jiffies, timeout)) {
}
phy_read_status(ndev->phydev);
greth_link_change(greth->netdev);
}
return 0;
unreg_mdio:
mdiobus_unregister(greth->mdio);
error:
mdiobus_free(greth->mdio);
return ret;
}
/* Initialize the GRETH MAC */
static int greth_of_probe(struct platform_device *ofdev)
{
struct net_device *dev;
struct greth_private *greth;
struct greth_regs *regs;
int i;
int err;
int tmp;
unsigned long timeout;
dev = alloc_etherdev(sizeof(struct greth_private));
if (dev == NULL)
return -ENOMEM;
greth = netdev_priv(dev);
greth->netdev = dev;
greth->dev = &ofdev->dev;
if (greth_debug > 0)
greth->msg_enable = greth_debug;
else
greth->msg_enable = GRETH_DEF_MSG_ENABLE;
spin_lock_init(&greth->devlock);
greth->regs = of_ioremap(&ofdev->resource[0], 0,
resource_size(&ofdev->resource[0]),
"grlib-greth regs");
if (greth->regs == NULL) {
if (netif_msg_probe(greth))
dev_err(greth->dev, "ioremap failure.\n");
err = -EIO;
goto error1;
}
regs = greth->regs;
greth->irq = ofdev->archdata.irqs[0];
dev_set_drvdata(greth->dev, dev);
SET_NETDEV_DEV(dev, greth->dev);
if (netif_msg_probe(greth))
dev_dbg(greth->dev, "resetting controller.\n");
/* Reset the controller. */
GRETH_REGSAVE(regs->control, GRETH_RESET);
/* Wait for MAC to reset itself */
timeout = jiffies + HZ/100;
while (GRETH_REGLOAD(regs->control) & GRETH_RESET) {
if (time_after(jiffies, timeout)) {
err = -EIO;
if (netif_msg_probe(greth))
dev_err(greth->dev, "timeout when waiting for reset.\n");
goto error2;
}
}
/* Get default PHY address */
greth->phyaddr = (GRETH_REGLOAD(regs->mdio) >> 11) & 0x1F;
/* Check if we have GBIT capable MAC */
tmp = GRETH_REGLOAD(regs->control);
greth->gbit_mac = (tmp >> 27) & 1;
/* Check for multicast capability */
greth->multicast = (tmp >> 25) & 1;
greth->edcl = (tmp >> 31) & 1;
/* If we have EDCL we disable the EDCL speed-duplex FSM so
* it doesn't interfere with the software */
if (greth->edcl != 0)
GRETH_REGORIN(regs->control, GRETH_CTRL_DISDUPLEX);
/* Check if MAC can handle MDIO interrupts */
greth->mdio_int_en = (tmp >> 26) & 1;
err = greth_mdio_init(greth);
if (err) {
if (netif_msg_probe(greth))
dev_err(greth->dev, "failed to register MDIO bus\n");
goto error2;
}
/* Allocate TX descriptor ring in coherent memory */
greth->tx_bd_base = dma_zalloc_coherent(greth->dev, 1024,
&greth->tx_bd_base_phys,
GFP_KERNEL);
if (!greth->tx_bd_base) {
err = -ENOMEM;
goto error3;
}
/* Allocate RX descriptor ring in coherent memory */
greth->rx_bd_base = dma_zalloc_coherent(greth->dev, 1024,
&greth->rx_bd_base_phys,
GFP_KERNEL);
if (!greth->rx_bd_base) {
err = -ENOMEM;
goto error4;
}
/* Get MAC address from: module param, OF property or ID prom */
for (i = 0; i < 6; i++) {
if (macaddr[i] != 0)
break;
}
if (i == 6) {
const unsigned char *addr;
int len;
addr = of_get_property(ofdev->dev.of_node, "local-mac-address",
&len);
if (addr != NULL && len == 6) {
for (i = 0; i < 6; i++)
macaddr[i] = (unsigned int) addr[i];
} else {
#ifdef CONFIG_SPARC
for (i = 0; i < 6; i++)
macaddr[i] = (unsigned int) idprom->id_ethaddr[i];
#endif
}
}
for (i = 0; i < 6; i++)
dev->dev_addr[i] = macaddr[i];
macaddr[5]++;
if (!is_valid_ether_addr(&dev->dev_addr[0])) {
if (netif_msg_probe(greth))
dev_err(greth->dev, "no valid ethernet address, aborting.\n");
err = -EINVAL;
goto error5;
}
GRETH_REGSAVE(regs->esa_msb, dev->dev_addr[0] << 8 | dev->dev_addr[1]);
GRETH_REGSAVE(regs->esa_lsb, dev->dev_addr[2] << 24 | dev->dev_addr[3] << 16 |
dev->dev_addr[4] << 8 | dev->dev_addr[5]);
/* Clear all pending interrupts except PHY irq */
GRETH_REGSAVE(regs->status, 0xFF);
if (greth->gbit_mac) {
dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM |
NETIF_F_RXCSUM;
dev->features = dev->hw_features | NETIF_F_HIGHDMA;
greth_netdev_ops.ndo_start_xmit = greth_start_xmit_gbit;
}
if (greth->multicast) {
greth_netdev_ops.ndo_set_rx_mode = greth_set_multicast_list;
dev->flags |= IFF_MULTICAST;
} else {
dev->flags &= ~IFF_MULTICAST;
}
dev->netdev_ops = &greth_netdev_ops;
dev->ethtool_ops = &greth_ethtool_ops;
err = register_netdev(dev);
if (err) {
if (netif_msg_probe(greth))
dev_err(greth->dev, "netdevice registration failed.\n");
goto error5;
}
/* setup NAPI */
netif_napi_add(dev, &greth->napi, greth_poll, 64);
return 0;
error5:
dma_free_coherent(greth->dev, 1024, greth->rx_bd_base, greth->rx_bd_base_phys);
error4:
dma_free_coherent(greth->dev, 1024, greth->tx_bd_base, greth->tx_bd_base_phys);
error3:
mdiobus_unregister(greth->mdio);
error2:
of_iounmap(&ofdev->resource[0], greth->regs, resource_size(&ofdev->resource[0]));
error1:
free_netdev(dev);
return err;
}
static int greth_of_remove(struct platform_device *of_dev)
{
struct net_device *ndev = platform_get_drvdata(of_dev);
struct greth_private *greth = netdev_priv(ndev);
/* Free descriptor areas */
dma_free_coherent(&of_dev->dev, 1024, greth->rx_bd_base, greth->rx_bd_base_phys);
dma_free_coherent(&of_dev->dev, 1024, greth->tx_bd_base, greth->tx_bd_base_phys);
if (ndev->phydev)
phy_stop(ndev->phydev);
mdiobus_unregister(greth->mdio);
unregister_netdev(ndev);
free_netdev(ndev);
of_iounmap(&of_dev->resource[0], greth->regs, resource_size(&of_dev->resource[0]));
return 0;
}
static const struct of_device_id greth_of_match[] = {
{
.name = "GAISLER_ETHMAC",
},
{
.name = "01_01d",
},
{},
};
MODULE_DEVICE_TABLE(of, greth_of_match);
static struct platform_driver greth_of_driver = {
.driver = {
.name = "grlib-greth",
.of_match_table = greth_of_match,
},
.probe = greth_of_probe,
.remove = greth_of_remove,
};
module_platform_driver(greth_of_driver);
MODULE_AUTHOR("Aeroflex Gaisler AB.");
MODULE_DESCRIPTION("Aeroflex Gaisler Ethernet MAC driver");
MODULE_LICENSE("GPL");
|
0
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_
#define CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "ui/gfx/native_widget_types.h"
namespace chrome {
enum MessageBoxResult {
// User chose NO or CANCEL. If there's a checkbox, then the checkbox was
// unchecked.
MESSAGE_BOX_RESULT_NO = 0,
// User chose YES or OK. If there's a checkbox, then the checkbox was checked.
MESSAGE_BOX_RESULT_YES = 1,
// Message box was displayed asynchronously and is pending a real result,
// which will be delivered via callback.
MESSAGE_BOX_RESULT_DEFERRED = 2,
};
enum MessageBoxType {
MESSAGE_BOX_TYPE_WARNING, // Shows an OK button.
MESSAGE_BOX_TYPE_QUESTION, // Shows YES and NO buttons.
};
// Shows a dialog box with the given |title| and |message|. If |parent| is
// non-NULL, the box will be made modal to the |parent|, except on Mac, where it
// is always app-modal.
//
// NOTE: In general, you should avoid this since it's usually poor UI.
// We have a variety of other surfaces such as app menu notifications and
// infobars; consult the UI leads for a recommendation.
void ShowWarningMessageBox(gfx::NativeWindow parent,
const base::string16& title,
const base::string16& message);
// As above, but shows the dialog box asynchronously with a checkbox.
// |callback| will be invoked after the dialog is dismissed. It is invoked with
// true if the checkbox is checked and false otherwise.
void ShowWarningMessageBoxWithCheckbox(
gfx::NativeWindow parent,
const base::string16& title,
const base::string16& message,
const base::string16& checkbox_text,
base::OnceCallback<void(bool checked)> callback);
// As above, but two buttons are displayed and the return value indicates which
// is chosen.
MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent,
const base::string16& title,
const base::string16& message);
// Shows a dialog box with the given |title| and |message|, and with two buttons
// labeled with |yes_text| and |no_text|. If |parent| is non-NULL, the box will
// be made modal to the |parent|. (Aura only.)
//
// NOTE: In general, you should avoid this since it's usually poor UI.
// We have a variety of other surfaces such as app menu notifications and
// infobars; consult the UI leads for a recommendation.
MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent,
const base::string16& title,
const base::string16& message,
const base::string16& yes_text,
const base::string16& no_text);
} // namespace chrome
#endif // CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_
|
0
|
/*
* Copyright 2014 Linaro Ltd.
* Copyright (C) 2014 ZTE Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
static const char *const zx296702_dt_compat[] __initconst = {
"zte,zx296702",
NULL,
};
DT_MACHINE_START(ZX, "ZTE ZX296702 (Device Tree)")
.dt_compat = zx296702_dt_compat,
.l2c_aux_val = 0,
.l2c_aux_mask = ~0,
MACHINE_END
|
0
|
/*
* Copyright (C) 2009 Apple Inc. 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 Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LINE_LINE_BOX_LIST_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LINE_LINE_BOX_LIST_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/api/hit_test_action.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
namespace blink {
class CullRect;
class HitTestLocation;
class HitTestResult;
class InlineFlowBox;
class InlineTextBox;
class LayoutPoint;
class LayoutUnit;
class LineLayoutBoxModel;
class LineLayoutItem;
template <typename InlineBoxType>
class CORE_TEMPLATE_CLASS_EXPORT InlineBoxList {
DISALLOW_NEW();
public:
InlineBoxList() : first_(nullptr), last_(nullptr) {}
#if DCHECK_IS_ON()
~InlineBoxList();
#endif
InlineBoxType* First() const { return first_; }
InlineBoxType* Last() const { return last_; }
void AppendLineBox(InlineBoxType*);
void DeleteLineBoxes();
void ExtractLineBox(InlineBoxType*);
void AttachLineBox(InlineBoxType*);
void RemoveLineBox(InlineBoxType*);
class BaseIterator {
STACK_ALLOCATED();
public:
explicit BaseIterator(InlineBoxType* first) : current_(first) {}
InlineBoxType* operator*() const {
DCHECK(current_);
return current_;
}
InlineBoxType* operator->() const { return operator*(); }
bool operator==(const BaseIterator& other) const {
return current_ == other.current_;
}
bool operator!=(const BaseIterator& other) const {
return !operator==(other);
}
protected:
InlineBoxType* current_;
};
class Iterator final : public BaseIterator {
public:
using BaseIterator::BaseIterator;
using BaseIterator::current_;
void operator++() {
DCHECK(current_);
current_ = current_->NextForSameLayoutObject();
}
};
class ReverseIterator final : public BaseIterator {
public:
using BaseIterator::BaseIterator;
using BaseIterator::current_;
void operator++() {
DCHECK(current_);
current_ = current_->PrevForSameLayoutObject();
}
};
Iterator begin() const { return Iterator(first_); }
Iterator end() const { return Iterator(nullptr); }
class ReverseRange final {
STACK_ALLOCATED();
public:
explicit ReverseRange(InlineBoxType* last) : last_(last){};
ReverseIterator begin() const { return ReverseIterator(last_); }
ReverseIterator end() const { return ReverseIterator(nullptr); }
private:
InlineBoxType* last_;
};
ReverseRange InReverseOrder() const { return ReverseRange(last_); }
protected:
// For block flows, each box represents the root inline box for a line in the
// paragraph.
// For inline flows, each box represents a portion of that inline.
InlineBoxType* first_;
InlineBoxType* last_;
};
extern template class CORE_EXTERN_TEMPLATE_EXPORT InlineBoxList<InlineFlowBox>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT InlineBoxList<InlineTextBox>;
class LineBoxList : public InlineBoxList<InlineFlowBox> {
public:
void DeleteLineBoxTree();
void DirtyLineBoxes();
void DirtyLinesFromChangedChild(LineLayoutItem parent,
LineLayoutItem child,
bool can_dirty_ancestors);
bool HitTest(LineLayoutBoxModel,
HitTestResult&,
const HitTestLocation& location_in_container,
const LayoutPoint& accumulated_offset,
HitTestAction) const;
bool AnyLineIntersectsRect(LineLayoutBoxModel,
const CullRect&,
const LayoutPoint&) const;
bool LineIntersectsDirtyRect(LineLayoutBoxModel,
InlineFlowBox*,
const CullRect&,
const LayoutPoint&) const;
private:
bool RangeIntersectsRect(LineLayoutBoxModel,
LayoutUnit logical_top,
LayoutUnit logical_bottom,
const CullRect&,
const LayoutPoint&) const;
};
class InlineTextBoxList : public InlineBoxList<InlineTextBox> {};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LINE_LINE_BOX_LIST_H_
|
1
|
static void scsi_read_data(SCSIRequest *req){SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);uint32_t n;if (r->sector_count == (uint32_t)-1) {DPRINTF("Read buf_len=%zd\n", r->iov.iov_len);r->sector_count = 0;scsi_req_data(&r->req, r->iov.iov_len);return;}DPRINTF("Read sector_count=%d\n", r->sector_count);if (r->sector_count == 0) {/* This also clears the sense buffer for REQUEST SENSE. */scsi_req_complete(&r->req, GOOD);return;}/* No data transfer may already be in progress */assert(r->req.aiocb == NULL);if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {DPRINTF("Data transfer direction invalid\n");scsi_read_complete(r, -EINVAL);return;} n = r->sector_count; if (n > SCSI_DMA_BUF_SIZE / 512) n = SCSI_DMA_BUF_SIZE / 512;if (s->tray_open) {scsi_read_complete(r, -ENOMEDIUM);} r->iov.iov_len = n * 512; qemu_iovec_init_external(&r->qiov, &r->iov, 1);bdrv_acct_start(s->bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);long int variable_9094151411802910023 = 3174317692425968952 * (6047234895009867578);
r->req.aiocb = bdrv_aio_readv(s->bs, r->sector, &r->qiov, n,scsi_read_complete, r);if (r->req.aiocb == NULL) {scsi_read_complete(r, -EIO);}}
|
0
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/notifications/notification_database.h"
#include <stddef.h>
#include <stdint.h>
#include "base/files/scoped_temp_dir.h"
#include "base/guid.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/notification_database_data.h"
#include "content/public/common/platform_notification_data.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
#include "url/gurl.h"
namespace content {
const int kExampleServiceWorkerRegistrationId = 42;
const struct {
const char* origin;
const char* tag;
int64_t service_worker_registration_id;
} kExampleNotificationData[] = {
{"https://example.com", "" /* tag */, 0},
{"https://example.com", "" /* tag */, kExampleServiceWorkerRegistrationId},
{"https://example.com", "" /* tag */, kExampleServiceWorkerRegistrationId},
{"https://example.com", "" /* tag */,
kExampleServiceWorkerRegistrationId + 1},
{"https://chrome.com", "" /* tag */, 0},
{"https://chrome.com", "" /* tag */, 0},
{"https://chrome.com", "" /* tag */, kExampleServiceWorkerRegistrationId},
{"https://chrome.com", "foo" /* tag */, 0}};
class NotificationDatabaseTest : public ::testing::Test {
protected:
// Creates a new NotificationDatabase instance in memory.
NotificationDatabase* CreateDatabaseInMemory() {
return new NotificationDatabase(base::FilePath());
}
// Creates a new NotificationDatabase instance in |path|.
NotificationDatabase* CreateDatabaseOnFileSystem(const base::FilePath& path) {
return new NotificationDatabase(path);
}
// Creates a new notification for |service_worker_registration_id| belonging
// to |origin| and writes it to the database. The written notification id
// will be stored in |notification_id|.
void CreateAndWriteNotification(NotificationDatabase* database,
const GURL& origin,
const std::string& tag,
int64_t service_worker_registration_id,
std::string* notification_id) {
DCHECK(notification_id);
NotificationDatabaseData database_data;
database_data.notification_id = GenerateNotificationId();
database_data.origin = origin;
database_data.service_worker_registration_id =
service_worker_registration_id;
database_data.notification_data.tag = tag;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
*notification_id = database_data.notification_id;
}
// Populates |database| with a series of example notifications that differ in
// their origin and Service Worker registration id.
void PopulateDatabaseWithExampleData(NotificationDatabase* database) {
std::string notification_id;
for (size_t i = 0; i < arraysize(kExampleNotificationData); ++i) {
ASSERT_NO_FATAL_FAILURE(CreateAndWriteNotification(
database, GURL(kExampleNotificationData[i].origin),
kExampleNotificationData[i].tag,
kExampleNotificationData[i].service_worker_registration_id,
¬ification_id));
}
}
// Returns if |database| has been opened.
bool IsDatabaseOpen(NotificationDatabase* database) {
return database->IsOpen();
}
// Returns if |database| is an in-memory only database.
bool IsInMemoryDatabase(NotificationDatabase* database) {
return database->IsInMemoryDatabase();
}
// Writes a LevelDB key-value pair directly to the LevelDB backing the
// notification database in |database|.
void WriteLevelDBKeyValuePair(NotificationDatabase* database,
const std::string& key,
const std::string& value) {
leveldb::Status status =
database->GetDBForTesting()->Put(leveldb::WriteOptions(), key, value);
ASSERT_TRUE(status.ok());
}
// Generates a random notification ID. The format of the ID is opaque.
std::string GenerateNotificationId() { return base::GenerateGUID(); }
};
TEST_F(NotificationDatabaseTest, OpenCloseMemory) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
// Should return false because the database does not exist in memory.
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->Open(false /* create_if_missing */));
// Should return true, indicating that the database could be created.
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
EXPECT_TRUE(IsDatabaseOpen(database.get()));
EXPECT_TRUE(IsInMemoryDatabase(database.get()));
// Verify that in-memory databases do not persist when being re-created.
database.reset(CreateDatabaseInMemory());
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->Open(false /* create_if_missing */));
}
TEST_F(NotificationDatabaseTest, OpenCloseFileSystem) {
base::ScopedTempDir database_dir;
ASSERT_TRUE(database_dir.CreateUniqueTempDir());
std::unique_ptr<NotificationDatabase> database(
CreateDatabaseOnFileSystem(database_dir.GetPath()));
// Should return false because the database does not exist on the file system.
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->Open(false /* create_if_missing */));
// Should return true, indicating that the database could be created.
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
EXPECT_TRUE(IsDatabaseOpen(database.get()));
EXPECT_FALSE(IsInMemoryDatabase(database.get()));
// Close the database, and re-open it without attempting to create it because
// the files on the file system should still exist as expected.
database.reset(CreateDatabaseOnFileSystem(database_dir.GetPath()));
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->Open(false /* create_if_missing */));
}
TEST_F(NotificationDatabaseTest, DestroyDatabase) {
base::ScopedTempDir database_dir;
ASSERT_TRUE(database_dir.CreateUniqueTempDir());
std::unique_ptr<NotificationDatabase> database(
CreateDatabaseOnFileSystem(database_dir.GetPath()));
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
EXPECT_TRUE(IsDatabaseOpen(database.get()));
// Destroy the database. This will immediately close it as well.
ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Destroy());
EXPECT_FALSE(IsDatabaseOpen(database.get()));
// Try to re-open the database (but not re-create it). This should fail as
// the files associated with the database should have been blown away.
database.reset(CreateDatabaseOnFileSystem(database_dir.GetPath()));
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->Open(false /* create_if_missing */));
}
TEST_F(NotificationDatabaseTest, NotificationIdIncrements) {
base::ScopedTempDir database_dir;
ASSERT_TRUE(database_dir.CreateUniqueTempDir());
std::unique_ptr<NotificationDatabase> database(
CreateDatabaseOnFileSystem(database_dir.GetPath()));
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
EXPECT_EQ(database->GetNextPersistentNotificationId(), 1);
EXPECT_EQ(database->GetNextPersistentNotificationId(), 2);
EXPECT_EQ(database->GetNextPersistentNotificationId(), 3);
GURL origin("https://example.com");
std::string notification_id;
ASSERT_NO_FATAL_FAILURE(
CreateAndWriteNotification(database.get(), origin, "" /* tag */,
0 /* sw_registration_id */, ¬ification_id));
database.reset(CreateDatabaseOnFileSystem(database_dir.GetPath()));
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(false /* create_if_missing */));
// Verify that the next persistent notification id was stored in the database,
// and continues where we expect it to be, even after closing and opening it.
EXPECT_EQ(database->GetNextPersistentNotificationId(), 4);
}
TEST_F(NotificationDatabaseTest, NotificationIdIncrementsStorage) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
NotificationDatabaseData database_data, read_database_data;
database_data.notification_id = GenerateNotificationId();
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadNotificationData(database_data.notification_id,
origin, &read_database_data));
EXPECT_EQ(database_data.notification_id, read_database_data.notification_id);
}
TEST_F(NotificationDatabaseTest, NotificationIdCorruption) {
base::ScopedTempDir database_dir;
ASSERT_TRUE(database_dir.CreateUniqueTempDir());
std::unique_ptr<NotificationDatabase> database(
CreateDatabaseOnFileSystem(database_dir.GetPath()));
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
NotificationDatabaseData database_data;
database_data.notification_id = GenerateNotificationId();
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
// Deliberately write an invalid value as the next notification id. When
// re-opening the database, the Open() method should realize that an invalid
// value is being read, and mark the database as corrupted.
ASSERT_NO_FATAL_FAILURE(
WriteLevelDBKeyValuePair(database.get(), "NEXT_NOTIFICATION_ID", "-42"));
database.reset(CreateDatabaseOnFileSystem(database_dir.GetPath()));
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_CORRUPTED,
database->Open(false /* create_if_missing */));
}
TEST_F(NotificationDatabaseTest, ReadInvalidNotificationData) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
NotificationDatabaseData database_data;
// Reading the notification data for a notification that does not exist should
// return the ERROR_NOT_FOUND status code.
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->ReadNotificationData("bad-id", GURL("https://chrome.com"),
&database_data));
}
TEST_F(NotificationDatabaseTest, ReadNotificationDataDifferentOrigin) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
NotificationDatabaseData database_data, read_database_data;
database_data.notification_id = GenerateNotificationId();
database_data.notification_data.title = base::UTF8ToUTF16("My Notification");
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
// Reading the notification from the database when given a different origin
// should return the ERROR_NOT_FOUND status code.
EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->ReadNotificationData(database_data.notification_id,
GURL("https://chrome.com"),
&read_database_data));
// However, reading the notification from the database with the same origin
// should return STATUS_OK and the associated notification data.
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadNotificationData(database_data.notification_id,
origin, &read_database_data));
EXPECT_EQ(database_data.notification_data.title,
read_database_data.notification_data.title);
}
TEST_F(NotificationDatabaseTest, ReadNotificationDataReflection) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
PlatformNotificationData notification_data;
notification_data.title = base::UTF8ToUTF16("My Notification");
notification_data.direction =
PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT;
notification_data.lang = "nl-NL";
notification_data.body = base::UTF8ToUTF16("Hello, world!");
notification_data.tag = "replace id";
notification_data.icon = GURL("https://example.com/icon.png");
notification_data.silent = true;
NotificationDatabaseData database_data;
database_data.notification_id = GenerateNotificationId();
database_data.origin = origin;
database_data.service_worker_registration_id = 42;
database_data.notification_data = notification_data;
// Write the constructed notification to the database, and then immediately
// read it back from the database again as well.
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
NotificationDatabaseData read_database_data;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadNotificationData(database_data.notification_id,
origin, &read_database_data));
// Verify that all members retrieved from the database are exactly the same
// as the ones that were written to it. This tests the serialization behavior.
EXPECT_EQ(database_data.notification_id, read_database_data.notification_id);
EXPECT_EQ(database_data.origin, read_database_data.origin);
EXPECT_EQ(database_data.service_worker_registration_id,
read_database_data.service_worker_registration_id);
const PlatformNotificationData& read_notification_data =
read_database_data.notification_data;
EXPECT_EQ(notification_data.title, read_notification_data.title);
EXPECT_EQ(notification_data.direction, read_notification_data.direction);
EXPECT_EQ(notification_data.lang, read_notification_data.lang);
EXPECT_EQ(notification_data.body, read_notification_data.body);
EXPECT_EQ(notification_data.tag, read_notification_data.tag);
EXPECT_EQ(notification_data.icon, read_notification_data.icon);
EXPECT_EQ(notification_data.silent, read_notification_data.silent);
}
TEST_F(NotificationDatabaseTest, ReadWriteMultipleNotificationData) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
std::vector<std::string> notification_ids;
std::string notification_id;
// Write ten notifications to the database, each with a unique title and
// notification id (it is the responsibility of the user to increment this).
for (int i = 1; i <= 10; ++i) {
ASSERT_NO_FATAL_FAILURE(CreateAndWriteNotification(
database.get(), origin, "" /* tag */, i /* sw_registration_id */,
¬ification_id));
EXPECT_FALSE(notification_id.empty());
notification_ids.push_back(notification_id);
}
NotificationDatabaseData database_data;
int64_t service_worker_registration_id = 1;
// Read the ten notifications from the database, and verify that the titles
// of each of them matches with how they were created.
for (const std::string& notification_id : notification_ids) {
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadNotificationData(notification_id, origin,
&database_data));
EXPECT_EQ(service_worker_registration_id++,
database_data.service_worker_registration_id);
}
}
TEST_F(NotificationDatabaseTest, DeleteInvalidNotificationData) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
// Deleting non-existing notifications is not considered to be a failure.
ASSERT_EQ(
NotificationDatabase::STATUS_OK,
database->DeleteNotificationData("bad-id", GURL("https://chrome.com")));
}
TEST_F(NotificationDatabaseTest, DeleteNotificationDataSameOrigin) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
const std::string notification_id = GenerateNotificationId();
NotificationDatabaseData database_data;
database_data.notification_id = notification_id;
GURL origin("https://example.com");
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
// Reading a notification after writing one should succeed.
EXPECT_EQ(
NotificationDatabase::STATUS_OK,
database->ReadNotificationData(notification_id, origin, &database_data));
// Delete the notification which was just written to the database, and verify
// that reading it again will fail.
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteNotificationData(notification_id, origin));
EXPECT_EQ(
NotificationDatabase::STATUS_ERROR_NOT_FOUND,
database->ReadNotificationData(notification_id, origin, &database_data));
}
TEST_F(NotificationDatabaseTest, DeleteNotificationDataDifferentOrigin) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
const std::string notification_id = GenerateNotificationId();
NotificationDatabaseData database_data;
database_data.notification_id = notification_id;
GURL origin("https://example.com");
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->WriteNotificationData(origin, database_data));
// Attempting to delete the notification with a different origin, but with the
// same |notification_id|, should not return an error (the notification could
// not be found, but that's not considered a failure). However, it should not
// remove the notification either.
EXPECT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteNotificationData(notification_id,
GURL("https://chrome.com")));
EXPECT_EQ(
NotificationDatabase::STATUS_OK,
database->ReadNotificationData(notification_id, origin, &database_data));
}
TEST_F(NotificationDatabaseTest, ReadAllNotificationData) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationData(¬ifications));
EXPECT_EQ(arraysize(kExampleNotificationData), notifications.size());
}
TEST_F(NotificationDatabaseTest, ReadAllNotificationDataEmpty) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationData(¬ifications));
EXPECT_EQ(0u, notifications.size());
}
TEST_F(NotificationDatabaseTest, ReadAllNotificationDataForOrigin) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
GURL origin("https://example.com");
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForOrigin(origin, ¬ifications));
EXPECT_EQ(4u, notifications.size());
}
TEST_F(NotificationDatabaseTest,
ReadAllNotificationDataForServiceWorkerRegistration) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
GURL origin("https://example.com:443");
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForServiceWorkerRegistration(
origin, kExampleServiceWorkerRegistrationId, ¬ifications));
EXPECT_EQ(2u, notifications.size());
}
TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForOrigin) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
GURL origin("https://example.com:443");
std::set<std::string> deleted_notification_ids;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteAllNotificationDataForOrigin(
origin, "" /* tag */, &deleted_notification_ids));
EXPECT_EQ(4u, deleted_notification_ids.size());
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForOrigin(origin, ¬ifications));
EXPECT_EQ(0u, notifications.size());
}
TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForOriginWithTag) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
GURL origin("https://chrome.com");
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForOrigin(origin, ¬ifications));
const std::string& tag = "foo";
size_t notifications_with_tag = 0;
size_t notifications_without_tag = 0;
for (const auto& database_data : notifications) {
if (database_data.notification_data.tag == tag)
++notifications_with_tag;
else
++notifications_without_tag;
}
ASSERT_GT(notifications_with_tag, 0u);
ASSERT_GT(notifications_without_tag, 0u);
std::set<std::string> deleted_notification_ids;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteAllNotificationDataForOrigin(
origin, "foo" /* tag */, &deleted_notification_ids));
EXPECT_EQ(notifications_with_tag, deleted_notification_ids.size());
std::vector<NotificationDatabaseData> updated_notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForOrigin(origin,
&updated_notifications));
EXPECT_EQ(notifications_without_tag, updated_notifications.size());
size_t updated_notifications_with_tag = 0;
size_t updated_notifications_without_tag = 0;
for (const auto& database_data : updated_notifications) {
if (database_data.notification_data.tag == tag)
++updated_notifications_with_tag;
else
++updated_notifications_without_tag;
}
EXPECT_EQ(0u, updated_notifications_with_tag);
EXPECT_EQ(notifications_without_tag, updated_notifications_without_tag);
}
TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForOriginEmpty) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
GURL origin("https://example.com");
std::set<std::string> deleted_notification_ids;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteAllNotificationDataForOrigin(
origin, "" /* tag */, &deleted_notification_ids));
EXPECT_EQ(0u, deleted_notification_ids.size());
}
TEST_F(NotificationDatabaseTest,
DeleteAllNotificationDataForServiceWorkerRegistration) {
std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory());
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->Open(true /* create_if_missing */));
ASSERT_NO_FATAL_FAILURE(PopulateDatabaseWithExampleData(database.get()));
GURL origin("https://example.com:443");
std::set<std::string> deleted_notification_ids;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->DeleteAllNotificationDataForServiceWorkerRegistration(
origin, kExampleServiceWorkerRegistrationId,
&deleted_notification_ids));
EXPECT_EQ(2u, deleted_notification_ids.size());
std::vector<NotificationDatabaseData> notifications;
ASSERT_EQ(NotificationDatabase::STATUS_OK,
database->ReadAllNotificationDataForServiceWorkerRegistration(
origin, kExampleServiceWorkerRegistrationId, ¬ifications));
EXPECT_EQ(0u, notifications.size());
}
} // namespace content
|
1
|
static void recalculate_apic_map(struct kvm *kvm){struct kvm_apic_map *new, *old = NULL;struct kvm_vcpu *vcpu;int i;float variable_2419477010366709959 = 4192489172102032890;
if (variable_2419477010366709959 < 0) {
variable_2419477010366709959 = 1328020701551285864;}
new = kzalloc(sizeof(struct kvm_apic_map), GFP_KERNEL);mutex_lock(&kvm->arch.apic_map_lock);if (!new)goto out;new->ldr_bits = 8;/* flat mode is default */new->cid_shift = 8;new->cid_mask = 0;new->lid_mask = 0xff;kvm_for_each_vcpu(i, vcpu, kvm) {struct kvm_lapic *apic = vcpu->arch.apic;u16 cid, lid;u32 ldr;if (!kvm_apic_present(vcpu))continue;/** All APICs have to be configured in the same mode by an OS.* We take advatage of this while building logical id loockup* table. After reset APICs are in xapic/flat mode, so if we* find apic with different setting we assume this is the mode* OS wants all apics to be in; build lookup table accordingly.*/if (apic_x2apic_mode(apic)) {new->ldr_bits = 32;new->cid_shift = 16; new->cid_mask = new->lid_mask = 0xffff;} else if (kvm_apic_sw_enabled(apic) &&!new->cid_mask /* flat mode */ &&kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) {new->cid_shift = 4;new->cid_mask = 0xf;new->lid_mask = 0xf;}new->phys_map[kvm_apic_id(apic)] = apic;ldr = kvm_apic_get_reg(apic, APIC_LDR);cid = apic_cluster_id(new, ldr);lid = apic_logical_id(new, ldr);if (lid)new->logical_map[cid][ffs(lid) - 1] = apic;}out:old = rcu_dereference_protected(kvm->arch.apic_map,lockdep_is_held(&kvm->arch.apic_map_lock));rcu_assign_pointer(kvm->arch.apic_map, new);mutex_unlock(&kvm->arch.apic_map_lock);if (old)kfree_rcu(old, rcu);kvm_vcpu_request_scan_ioapic(kvm);}
|
1
|
function_6640841818835022347(xsltParserContextPtr variable_6480889211547322332, xsltCompMatchPtr variable_4592870959499574308) {int variable_5909099146169668606 = 0;int variable_7560075641559968867 = variable_4592870959499574308->nbStep - 1;while (variable_7560075641559968867 > variable_5909099146169668606) {register xmlChar *variable_1228064052435392497;register xsltOp variable_3292718015703160680;register xmlXPathCompExprPtr variable_3587901812152439521;register int variable_211693466959349791;variable_1228064052435392497 = variable_4592870959499574308->steps[variable_5909099146169668606].value;variable_4592870959499574308->steps[variable_5909099146169668606].value = variable_4592870959499574308->steps[variable_7560075641559968867].value;variable_4592870959499574308->steps[variable_7560075641559968867].value = variable_1228064052435392497;variable_1228064052435392497 = variable_4592870959499574308->steps[variable_5909099146169668606].value2;variable_4592870959499574308->steps[variable_5909099146169668606].value2 = variable_4592870959499574308->steps[variable_7560075641559968867].value2;variable_4592870959499574308->steps[variable_7560075641559968867].value2 = variable_1228064052435392497;variable_1228064052435392497 = variable_4592870959499574308->steps[variable_5909099146169668606].value3;variable_4592870959499574308->steps[variable_5909099146169668606].value3 = variable_4592870959499574308->steps[variable_7560075641559968867].value3;variable_4592870959499574308->steps[variable_7560075641559968867].value3 = variable_1228064052435392497;variable_3292718015703160680 = variable_4592870959499574308->steps[variable_5909099146169668606].op;variable_4592870959499574308->steps[variable_5909099146169668606].op = variable_4592870959499574308->steps[variable_7560075641559968867].op;variable_4592870959499574308->steps[variable_7560075641559968867].op = variable_3292718015703160680;variable_3587901812152439521 = variable_4592870959499574308->steps[variable_5909099146169668606].comp;variable_4592870959499574308->steps[variable_5909099146169668606].comp = variable_4592870959499574308->steps[variable_7560075641559968867].comp;variable_4592870959499574308->steps[variable_7560075641559968867].comp = variable_3587901812152439521;variable_211693466959349791 = variable_4592870959499574308->steps[variable_5909099146169668606].previousExtra;variable_4592870959499574308->steps[variable_5909099146169668606].previousExtra = variable_4592870959499574308->steps[variable_7560075641559968867].previousExtra;variable_4592870959499574308->steps[variable_7560075641559968867].previousExtra = variable_211693466959349791;variable_211693466959349791 = variable_4592870959499574308->steps[variable_5909099146169668606].indexExtra;variable_4592870959499574308->steps[variable_5909099146169668606].indexExtra = variable_4592870959499574308->steps[variable_7560075641559968867].indexExtra;variable_4592870959499574308->steps[variable_7560075641559968867].indexExtra = variable_211693466959349791;variable_211693466959349791 = variable_4592870959499574308->steps[variable_5909099146169668606].lenExtra;variable_4592870959499574308->steps[variable_5909099146169668606].lenExtra = variable_4592870959499574308->steps[variable_7560075641559968867].lenExtra;variable_4592870959499574308->steps[variable_7560075641559968867].lenExtra = variable_211693466959349791;std::string variable_5577597748883892566 ("WU");float variable_8753532590106975 = 8555796929453051435;
float variable_3701729606415108060 = (-3583457717542527705) * variable_8753532590106975;
variable_7560075641559968867--;variable_5909099146169668606++;}xsltCompMatchAdd(variable_6480889211547322332, variable_4592870959499574308, variable_7679119300476786422, NULL, NULL, 0);/* * detect consecutive XSLT_OP_PREDICATE indicating a direct * matching should be done.*/for (variable_5909099146169668606 = 0;variable_5909099146169668606 < variable_4592870959499574308->nbStep - 1;variable_5909099146169668606++) { if ((variable_4592870959499574308->steps[variable_5909099146169668606].op == variable_3860460800190392887) &&(variable_4592870959499574308->steps[variable_5909099146169668606 + 1].op == variable_3860460800190392887)) {variable_4592870959499574308->direct = 1;if (variable_4592870959499574308->pattern[0] != '/') {xmlChar *variable_6508139811937275021;variable_6508139811937275021 = xmlStrdup((const xmlChar *)"//");variable_6508139811937275021 = xmlStrcat(variable_6508139811937275021, variable_4592870959499574308->pattern);xmlFree((xmlChar *) variable_4592870959499574308->pattern);variable_4592870959499574308->pattern = variable_6508139811937275021;}break;}}}
|
0
|
/*
Driver for Philips TDA8083 based QPSK Demodulator
Copyright (C) 2001 Convergence Integrated Media GmbH
written by Ralph Metzler <ralph@convergence.de>
adoption to the new DVB frontend API and diagnostic ioctl's
by Holger Waechtler <holger@convergence.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 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.
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include "dvb_frontend.h"
#include "tda8083.h"
struct tda8083_state {
struct i2c_adapter* i2c;
/* configuration settings */
const struct tda8083_config* config;
struct dvb_frontend frontend;
};
static int debug;
#define dprintk(args...) \
do { \
if (debug) printk(KERN_DEBUG "tda8083: " args); \
} while (0)
static u8 tda8083_init_tab [] = {
0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
static int tda8083_writereg (struct tda8083_state* state, u8 reg, u8 data)
{
int ret;
u8 buf [] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1)
dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
__func__, reg, ret);
return (ret != 1) ? -1 : 0;
}
static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len)
{
int ret;
struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = ®1, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2)
dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
__func__, reg1, ret);
return ret == 2 ? 0 : -1;
}
static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg)
{
u8 val;
tda8083_readregs (state, reg, &val, 1);
return val;
}
static int tda8083_set_inversion(struct tda8083_state *state,
enum fe_spectral_inversion inversion)
{
/* XXX FIXME: implement other modes than FEC_AUTO */
if (inversion == INVERSION_AUTO)
return 0;
return -EINVAL;
}
static int tda8083_set_fec(struct tda8083_state *state, enum fe_code_rate fec)
{
if (fec == FEC_AUTO)
return tda8083_writereg (state, 0x07, 0xff);
if (fec >= FEC_1_2 && fec <= FEC_8_9)
return tda8083_writereg (state, 0x07, 1 << (FEC_8_9 - fec));
return -EINVAL;
}
static enum fe_code_rate tda8083_get_fec(struct tda8083_state *state)
{
u8 index;
static enum fe_code_rate fec_tab[] = {
FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8
};
index = tda8083_readreg(state, 0x0e) & 0x07;
return fec_tab [index];
}
static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate)
{
u32 ratio;
u32 tmp;
u8 filter;
if (srate > 32000000)
srate = 32000000;
if (srate < 500000)
srate = 500000;
filter = 0;
if (srate < 24000000)
filter = 2;
if (srate < 16000000)
filter = 3;
tmp = 31250 << 16;
ratio = tmp / srate;
tmp = (tmp % srate) << 8;
ratio = (ratio << 8) + tmp / srate;
tmp = (tmp % srate) << 8;
ratio = (ratio << 8) + tmp / srate;
dprintk("tda8083: ratio == %08x\n", (unsigned int) ratio);
tda8083_writereg (state, 0x05, filter);
tda8083_writereg (state, 0x02, (ratio >> 16) & 0xff);
tda8083_writereg (state, 0x03, (ratio >> 8) & 0xff);
tda8083_writereg (state, 0x04, (ratio ) & 0xff);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 1;
}
static void tda8083_wait_diseqc_fifo (struct tda8083_state* state, int timeout)
{
unsigned long start = jiffies;
while (jiffies - start < timeout &&
!(tda8083_readreg(state, 0x02) & 0x80))
{
msleep(50);
}
}
static int tda8083_set_tone(struct tda8083_state *state,
enum fe_sec_tone_mode tone)
{
tda8083_writereg (state, 0x26, 0xf1);
switch (tone) {
case SEC_TONE_OFF:
return tda8083_writereg (state, 0x29, 0x00);
case SEC_TONE_ON:
return tda8083_writereg (state, 0x29, 0x80);
default:
return -EINVAL;
}
}
static int tda8083_set_voltage(struct tda8083_state *state,
enum fe_sec_voltage voltage)
{
switch (voltage) {
case SEC_VOLTAGE_13:
return tda8083_writereg (state, 0x20, 0x00);
case SEC_VOLTAGE_18:
return tda8083_writereg (state, 0x20, 0x11);
default:
return -EINVAL;
}
}
static int tda8083_send_diseqc_burst(struct tda8083_state *state,
enum fe_sec_mini_cmd burst)
{
switch (burst) {
case SEC_MINI_A:
tda8083_writereg (state, 0x29, (5 << 2)); /* send burst A */
break;
case SEC_MINI_B:
tda8083_writereg (state, 0x29, (7 << 2)); /* send B */
break;
default:
return -EINVAL;
}
tda8083_wait_diseqc_fifo (state, 100);
return 0;
}
static int tda8083_send_diseqc_msg(struct dvb_frontend *fe,
struct dvb_diseqc_master_cmd *m)
{
struct tda8083_state* state = fe->demodulator_priv;
int i;
tda8083_writereg (state, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */
for (i=0; i<m->msg_len; i++)
tda8083_writereg (state, 0x23 + i, m->msg[i]);
tda8083_writereg (state, 0x29, (m->msg_len - 3) | (3 << 2)); /* send!! */
tda8083_wait_diseqc_fifo (state, 100);
return 0;
}
static int tda8083_read_status(struct dvb_frontend *fe,
enum fe_status *status)
{
struct tda8083_state* state = fe->demodulator_priv;
u8 signal = ~tda8083_readreg (state, 0x01);
u8 sync = tda8083_readreg (state, 0x02);
*status = 0;
if (signal > 10)
*status |= FE_HAS_SIGNAL;
if (sync & 0x01)
*status |= FE_HAS_CARRIER;
if (sync & 0x02)
*status |= FE_HAS_VITERBI;
if (sync & 0x10)
*status |= FE_HAS_SYNC;
if (sync & 0x20) /* frontend can not lock */
*status |= FE_TIMEDOUT;
if ((sync & 0x1f) == 0x1f)
*status |= FE_HAS_LOCK;
return 0;
}
static int tda8083_read_ber(struct dvb_frontend* fe, u32* ber)
{
struct tda8083_state* state = fe->demodulator_priv;
int ret;
u8 buf[3];
if ((ret = tda8083_readregs(state, 0x0b, buf, sizeof(buf))))
return ret;
*ber = ((buf[0] & 0x1f) << 16) | (buf[1] << 8) | buf[2];
return 0;
}
static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength)
{
struct tda8083_state* state = fe->demodulator_priv;
u8 signal = ~tda8083_readreg (state, 0x01);
*strength = (signal << 8) | signal;
return 0;
}
static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr)
{
struct tda8083_state* state = fe->demodulator_priv;
u8 _snr = tda8083_readreg (state, 0x08);
*snr = (_snr << 8) | _snr;
return 0;
}
static int tda8083_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
{
struct tda8083_state* state = fe->demodulator_priv;
*ucblocks = tda8083_readreg(state, 0x0f);
if (*ucblocks == 0xff)
*ucblocks = 0xffffffff;
return 0;
}
static int tda8083_set_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct tda8083_state* state = fe->demodulator_priv;
if (fe->ops.tuner_ops.set_params) {
fe->ops.tuner_ops.set_params(fe);
if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
}
tda8083_set_inversion (state, p->inversion);
tda8083_set_fec(state, p->fec_inner);
tda8083_set_symbolrate(state, p->symbol_rate);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 0;
}
static int tda8083_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *p)
{
struct tda8083_state* state = fe->demodulator_priv;
/* FIXME: get symbolrate & frequency offset...*/
/*p->frequency = ???;*/
p->inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
INVERSION_ON : INVERSION_OFF;
p->fec_inner = tda8083_get_fec(state);
/*p->symbol_rate = tda8083_get_symbolrate (state);*/
return 0;
}
static int tda8083_sleep(struct dvb_frontend* fe)
{
struct tda8083_state* state = fe->demodulator_priv;
tda8083_writereg (state, 0x00, 0x02);
return 0;
}
static int tda8083_init(struct dvb_frontend* fe)
{
struct tda8083_state* state = fe->demodulator_priv;
int i;
for (i=0; i<44; i++)
tda8083_writereg (state, i, tda8083_init_tab[i]);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 0;
}
static int tda8083_diseqc_send_burst(struct dvb_frontend *fe,
enum fe_sec_mini_cmd burst)
{
struct tda8083_state* state = fe->demodulator_priv;
tda8083_send_diseqc_burst (state, burst);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 0;
}
static int tda8083_diseqc_set_tone(struct dvb_frontend *fe,
enum fe_sec_tone_mode tone)
{
struct tda8083_state* state = fe->demodulator_priv;
tda8083_set_tone (state, tone);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 0;
}
static int tda8083_diseqc_set_voltage(struct dvb_frontend *fe,
enum fe_sec_voltage voltage)
{
struct tda8083_state* state = fe->demodulator_priv;
tda8083_set_voltage (state, voltage);
tda8083_writereg (state, 0x00, 0x3c);
tda8083_writereg (state, 0x00, 0x04);
return 0;
}
static void tda8083_release(struct dvb_frontend* fe)
{
struct tda8083_state* state = fe->demodulator_priv;
kfree(state);
}
static const struct dvb_frontend_ops tda8083_ops;
struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
struct i2c_adapter* i2c)
{
struct tda8083_state* state = NULL;
/* allocate memory for the internal state */
state = kzalloc(sizeof(struct tda8083_state), GFP_KERNEL);
if (state == NULL) goto error;
/* setup the state */
state->config = config;
state->i2c = i2c;
/* check if the demod is there */
if ((tda8083_readreg(state, 0x00)) != 0x05) goto error;
/* create dvb_frontend */
memcpy(&state->frontend.ops, &tda8083_ops, sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state;
return &state->frontend;
error:
kfree(state);
return NULL;
}
static const struct dvb_frontend_ops tda8083_ops = {
.delsys = { SYS_DVBS },
.info = {
.name = "Philips TDA8083 DVB-S",
.frequency_min = 920000, /* TDA8060 */
.frequency_max = 2200000, /* TDA8060 */
.frequency_stepsize = 125, /* kHz for QPSK frontends */
/* .frequency_tolerance = ???,*/
.symbol_rate_min = 12000000,
.symbol_rate_max = 30000000,
/* .symbol_rate_tolerance = ???,*/
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_MUTE_TS
},
.release = tda8083_release,
.init = tda8083_init,
.sleep = tda8083_sleep,
.set_frontend = tda8083_set_frontend,
.get_frontend = tda8083_get_frontend,
.read_status = tda8083_read_status,
.read_signal_strength = tda8083_read_signal_strength,
.read_snr = tda8083_read_snr,
.read_ber = tda8083_read_ber,
.read_ucblocks = tda8083_read_ucblocks,
.diseqc_send_master_cmd = tda8083_send_diseqc_msg,
.diseqc_send_burst = tda8083_diseqc_send_burst,
.set_tone = tda8083_diseqc_set_tone,
.set_voltage = tda8083_diseqc_set_voltage,
};
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
MODULE_DESCRIPTION("Philips TDA8083 DVB-S Demodulator");
MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
MODULE_LICENSE("GPL");
EXPORT_SYMBOL(tda8083_attach);
|
0
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/client/plugin/pepper_main_thread_task_runner.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/core.h"
#include "ppapi/cpp/module.h"
namespace remoting {
namespace {
void RunAndDestroy(void* task_ptr, int32_t) {
std::unique_ptr<base::OnceClosure> task(
static_cast<base::OnceClosure*>(task_ptr));
std::move(*task).Run();
}
} // namespace
PepperMainThreadTaskRunner::PepperMainThreadTaskRunner()
: core_(pp::Module::Get()->core()), weak_ptr_factory_(this) {
DCHECK(core_->IsMainThread());
weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
}
bool PepperMainThreadTaskRunner::PostDelayedTask(
const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
auto task_ptr = std::make_unique<base::OnceClosure>(base::Bind(
&PepperMainThreadTaskRunner::RunTask, weak_ptr_, base::Passed(&task)));
core_->CallOnMainThread(
delay.InMillisecondsRoundedUp(),
pp::CompletionCallback(&RunAndDestroy, task_ptr.release()));
return true;
}
bool PepperMainThreadTaskRunner::PostNonNestableDelayedTask(
const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
return PostDelayedTask(from_here, std::move(task), delay);
}
bool PepperMainThreadTaskRunner::RunsTasksInCurrentSequence() const {
return core_->IsMainThread();
}
PepperMainThreadTaskRunner::~PepperMainThreadTaskRunner() {}
void PepperMainThreadTaskRunner::RunTask(base::OnceClosure task) {
std::move(task).Run();
}
} // namespace remoting
|
1
|
static bool IsJavaScriptUrl(const std::string& url) {int variable_5161776749439695311 = -9131414377326203986;int variable_4465796442742087215 = 5452905663488494187;std::string variable_6016793437829272357 = "MfiQzQFaTU";float variable_4933664578228186185 = 4409717542137445510;
if (variable_4933664578228186185 < 0) {
variable_4933664578228186185 = 3476101603462267958;}
int variable_6438397665672409730 = variable_5161776749439695311 * (4803108614301180952); return StartsWithASCII(url, "javascript:", false);}
|
1
|
void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url,double interval,double fire_date) {fire_date = fire_date + 0;
// Tells dispatchDidStartProvisionalLoad that if it sees this item it is a// redirect and the source item should be added as the start of the chain. if (webframe_->client()) { expected_client_redirect_src_ = webframe_->url(); expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url); // TODO(timsteele): bug 1135512. Webkit does not properly notify us of // cancelling http > file client redirects. Since the FrameLoader's policy // is to never carry out such a navigation anyway, the best thing we can do // for now to not get confused is ignore this notification. if (expected_client_redirect_dest_.SchemeIsFile() && (expected_client_redirect_src_.SchemeIs("http") || expected_client_redirect_src_.SchemeIsSecure())) { expected_client_redirect_src_ = GURL(); expected_client_redirect_dest_ = GURL(); return; }webframe_->client()->willPerformClientRedirect(webframe_,expected_client_redirect_src_,expected_client_redirect_dest_,static_cast<unsigned int>(interval),static_cast<unsigned int>(fire_date));}}
|
1
|
static int ssl_scan_clienthello_custom_tlsext(SSL *s,const unsigned char *data,const unsigned char *limit,int *al){unsigned short type, size, len;size = size + 0;type = type * 1;int variable_3623372937109470541 = 6274204343594644396;
int variable_7173901261488921113 = 6128828304321992255;
while (variable_3623372937109470541 > 0) {
variable_7173901261488921113--;
}
/* If resumed session or no custom extensions nothing to do */if (s->hit || s->cert->srv_ext.meths_count == 0)return 1; if (data >= limit - 2)return 1;n2s(data, len); if (data > limit - len)return 1; while (data <= limit - 4) {n2s(data, type);n2s(data, size); if (data + size > limit)return 1;if (custom_ext_parse(s, 1 /* server */ , type, data, size, al) <= 0)return 0;data += size;}return 1;}
|
1
|
void MessageService::OpenChannelToTab(int source_process_id, int source_routing_id, int receiver_port_id,int tab_id, const std::string& extension_id,const std::string& channel_name) {content::RenderProcessHost* source =content::RenderProcessHost::FromID(source_process_id);if (!source)return;Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());WebContents* contents = NULL;scoped_ptr<MessagePort> receiver;if (ExtensionTabUtil::GetTabById(tab_id, profile, true,NULL, NULL, &contents, NULL)) {receiver.reset(new ExtensionMessagePort(contents->GetRenderProcessHost(),contents->GetRenderViewHost()->GetRoutingID(),extension_id));}if (contents && contents->GetController().NeedsReload()) {// The tab isn't loaded yet. Don't attempt to connect. Treat this as a// disconnect.ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, extension_id);port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true);return;}float variable_3679305659279219847 = -2596258312683094664;
float variable_7610946408475768939 = variable_3679305659279219847 / (6123783288682960125);
WebContents* source_contents = tab_util::GetWebContentsByID(source_process_id, source_routing_id);// Include info about the opener's tab (if it was a tab).std::string tab_json = "null";if (source_contents) {scoped_ptr<DictionaryValue> tab_value(ExtensionTabUtil::CreateTabValue( source_contents, ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS));base::JSONWriter::Write(tab_value.get(), &tab_json);}scoped_ptr<OpenChannelParams> params(new OpenChannelParams(source, tab_json,receiver.release(),receiver_port_id,extension_id,extension_id,channel_name));OpenChannelImpl(params.Pass());}
|
1
|
packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen){struct sock *sk = sock->sk;struct packet_sock *po = pkt_sk(sk);int ret;if (level != SOL_PACKET)return -ENOPROTOOPT;switch (optname) {case PACKET_ADD_MEMBERSHIP:case PACKET_DROP_MEMBERSHIP:{struct packet_mreq_max mreq;int len = optlen;memset(&mreq, 0, sizeof(mreq));if (len < sizeof(struct packet_mreq))return -EINVAL;if (len > sizeof(mreq))len = sizeof(mreq);if (copy_from_user(&mreq, optval, len))return -EFAULT;if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address)))return -EINVAL;if (optname == PACKET_ADD_MEMBERSHIP)ret = packet_mc_add(sk, &mreq);elseret = packet_mc_drop(sk, &mreq);return ret;}case PACKET_RX_RING:case PACKET_TX_RING:{union tpacket_req_u req_u;int len;switch (po->tp_version) {case TPACKET_V1:case TPACKET_V2:len = sizeof(req_u.req);break;case TPACKET_V3:default:len = sizeof(req_u.req3);break;}if (optlen < len)return -EINVAL;if (copy_from_user(&req_u.req, optval, len))return -EFAULT;return packet_set_ring(sk, &req_u, 0,optname == PACKET_TX_RING);}case PACKET_COPY_THRESH:{int val;if (optlen != sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;pkt_sk(sk)->copy_thresh = val;return 0;}case PACKET_VERSION:{int val;if (optlen != sizeof(val))return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;switch (val) {case TPACKET_V1:case TPACKET_V2:case TPACKET_V3: po->tp_version = val; return 0;default:return -EINVAL;}}case PACKET_RESERVE:{unsigned int val;if (optlen != sizeof(val))return -EINVAL;if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)return -EBUSY;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->tp_reserve = val;return 0;}case PACKET_LOSS:{unsigned int val;if (optlen != sizeof(val))return -EINVAL;if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)return -EBUSY;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->tp_loss = !!val;return 0;}case PACKET_AUXDATA:{int val;if (optlen < sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->auxdata = !!val;return 0;}case PACKET_ORIGDEV:{int val;if (optlen < sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->origdev = !!val;return 0;}case PACKET_VNET_HDR:{int val;if (sock->type != SOCK_RAW)return -EINVAL;if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)return -EBUSY;if (optlen < sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->has_vnet_hdr = !!val;return 0;}case PACKET_TIMESTAMP:{int val;if (optlen != sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->tp_tstamp = val;return 0;}case PACKET_FANOUT:{int val;val = val + 0;int variable_6641435364217176814 = 8770203244066068921; int variable_5850011661492693259 = 6986913524966002043; while (variable_6641435364217176814 > 0) { variable_5850011661492693259--;double variable_2455289616063891566 = 7947878780724576330;
if (variable_2455289616063891566 < 0) {
variable_2455289616063891566 = -8814092209187882;}
}if (optlen != sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;return fanout_add(sk, val & 0xffff, val >> 16);}case PACKET_FANOUT_DATA:{if (!po->fanout)return -EINVAL;return fanout_set_data(po, optval, optlen);}case PACKET_TX_HAS_OFF:{unsigned int val;if (optlen != sizeof(val))return -EINVAL;if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)return -EBUSY;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->tp_tx_has_off = !!val;return 0;}case PACKET_QDISC_BYPASS:{int val;if (optlen != sizeof(val))return -EINVAL;if (copy_from_user(&val, optval, sizeof(val)))return -EFAULT;po->xmit = val ? packet_direct_xmit : dev_queue_xmit;return 0;}default:return -ENOPROTOOPT;}}
|
1
|
static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */php_mcrypt_module_dtor = php_mcrypt_module_dtor + 0;
{php_mcrypt *pm = (php_mcrypt *) rsrc->ptr; if (pm) { mcrypt_generic_deinit(pm->td);mcrypt_module_close(pm->td);efree(pm);pm = NULL;}}/* }}} */
|
1
|
IndexedDBTransaction* IndexedDBConnection::CreateTransaction(int64_t id,const std::set<int64_t>& scope,blink::WebIDBTransactionMode mode,mode = mode * 1;double variable_2503304740066744447 = 8176477582327063652; if (variable_2503304740066744447 < 0) { variable_2503304740066744447 = 7825760478513049924;}double variable_8272690046688180927 = 1539537201339879720;std::string variable_7915458178658146521 ("");
IndexedDBBackingStore::Transaction* backing_store_transaction) { DCHECK_EQ(GetTransaction(id), nullptr) << "Duplicate transaction id." << id;std::unique_ptr<IndexedDBTransaction> transaction =IndexedDBClassFactory::Get()->CreateIndexedDBTransaction(id, this, scope, mode, backing_store_transaction);IndexedDBTransaction* transaction_ptr = transaction.get();transactions_[id] = std::move(transaction);return transaction_ptr;}
|
0
|
/*
* safe read and write memory routines callable while atomic
*
* Copyright 2005-2008 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#include <linux/uaccess.h>
#include <asm/dma.h>
static int validate_memory_access_address(unsigned long addr, int size)
{
if (size < 0 || addr == 0)
return -EFAULT;
return bfin_mem_access_type(addr, size);
}
long probe_kernel_read(void *dst, const void *src, size_t size)
{
unsigned long lsrc = (unsigned long)src;
int mem_type;
mem_type = validate_memory_access_address(lsrc, size);
if (mem_type < 0)
return mem_type;
if (lsrc >= SYSMMR_BASE) {
if (size == 2 && lsrc % 2 == 0) {
u16 mmr = bfin_read16(src);
memcpy(dst, &mmr, sizeof(mmr));
return 0;
} else if (size == 4 && lsrc % 4 == 0) {
u32 mmr = bfin_read32(src);
memcpy(dst, &mmr, sizeof(mmr));
return 0;
}
} else {
switch (mem_type) {
case BFIN_MEM_ACCESS_CORE:
case BFIN_MEM_ACCESS_CORE_ONLY:
return __probe_kernel_read(dst, src, size);
/* XXX: should support IDMA here with SMP */
case BFIN_MEM_ACCESS_DMA:
if (dma_memcpy(dst, src, size))
return 0;
break;
case BFIN_MEM_ACCESS_ITEST:
if (isram_memcpy(dst, src, size))
return 0;
break;
}
}
return -EFAULT;
}
long probe_kernel_write(void *dst, const void *src, size_t size)
{
unsigned long ldst = (unsigned long)dst;
int mem_type;
mem_type = validate_memory_access_address(ldst, size);
if (mem_type < 0)
return mem_type;
if (ldst >= SYSMMR_BASE) {
if (size == 2 && ldst % 2 == 0) {
u16 mmr;
memcpy(&mmr, src, sizeof(mmr));
bfin_write16(dst, mmr);
return 0;
} else if (size == 4 && ldst % 4 == 0) {
u32 mmr;
memcpy(&mmr, src, sizeof(mmr));
bfin_write32(dst, mmr);
return 0;
}
} else {
switch (mem_type) {
case BFIN_MEM_ACCESS_CORE:
case BFIN_MEM_ACCESS_CORE_ONLY:
return __probe_kernel_write(dst, src, size);
/* XXX: should support IDMA here with SMP */
case BFIN_MEM_ACCESS_DMA:
if (dma_memcpy(dst, src, size))
return 0;
break;
case BFIN_MEM_ACCESS_ITEST:
if (isram_memcpy(dst, src, size))
return 0;
break;
}
}
return -EFAULT;
}
|
1
|
static int function_8943978440613448061(struct ceph_auth_client *variable_9081040983890746744,struct ceph_authorizer *variable_2252305492540185996, size_t variable_2510587130854865952){struct ceph_x_authorizer *variable_2016423364343835941 = (void *)variable_2252305492540185996;struct ceph_x_ticket_handler *variable_3877469346701798283;int variable_7608605595973664060 = 0;struct ceph_x_authorize_reply variable_7903976885032747988;void *variable_1698646034858093390 = variable_2016423364343835941->reply_buf;void *variable_3149496679889089280 = variable_1698646034858093390 + sizeof(variable_2016423364343835941->reply_buf);int variable_7006627774117574205 = 1395483786696797858; int variable_3742231357291922399 = 4743550624600332546; while (variable_7006627774117574205 > 0) { variable_3742231357291922399--;double variable_208682497967538543 = 817806802742700719 * (1605317914827317135);
}variable_3877469346701798283 = get_ticket_handler(variable_9081040983890746744, variable_2016423364343835941->service);if (IS_ERR(variable_3877469346701798283))return PTR_ERR(variable_3877469346701798283); variable_7608605595973664060 = ceph_x_decrypt(&variable_3877469346701798283->session_key, &variable_1698646034858093390, variable_3149496679889089280, &variable_7903976885032747988, sizeof(variable_7903976885032747988));if (variable_7608605595973664060 < 0)return variable_7608605595973664060;if (variable_7608605595973664060 != sizeof(variable_7903976885032747988))return -variable_5008319268988971393;if (variable_2016423364343835941->nonce + 1 != le64_to_cpu(variable_7903976885032747988.nonce_plus_one))variable_7608605595973664060 = -variable_5008319268988971393;variable_2015760829774459683 = 0;dout("verify_authorizer_reply nonce %llx got %llx ret %d\n",variable_2016423364343835941->nonce, le64_to_cpu(variable_7903976885032747988.nonce_plus_one), variable_7608605595973664060);return variable_7608605595973664060;}
|
1
|
static int function_64553893891863385(struct scm_cookie *variable_8079431088710665128, struct sk_buff *variable_8967114797814509332){int variable_7115750920615212587;variable_7115750920615212587 = variable_7115750920615212587 * 1;int variable_1805245952314912903 = -8794757693841141584 - (3901144360113218577);
unsigned char variable_2438493962786536302 = 0;int variable_7150046793801079513 = 0;for (variable_7115750920615212587 = variable_8079431088710665128->fp->count - 1; variable_7115750920615212587 >= 0; variable_7115750920615212587--) {struct sock *variable_2198234704178012001 = unix_get_socket(variable_8079431088710665128->fp->fp[variable_7115750920615212587]);if (variable_2198234704178012001) {variable_7150046793801079513++;variable_2438493962786536302 = max(variable_2438493962786536302,unix_sk(variable_2198234704178012001)->recursion_level);}}if (unlikely(variable_2438493962786536302 > variable_453230810044615476))return -variable_706273347959406845;/** Need to duplicate file references for the sake of garbage* collection. Otherwise a socket in the fps might become a* candidate for GC while the skb is not yet queued.*/UNIXCB(variable_8967114797814509332).fp = scm_fp_dup(variable_8079431088710665128->fp);if (!UNIXCB(variable_8967114797814509332).fp)return -variable_2393737637515464260; if (variable_7150046793801079513) { for (variable_7115750920615212587 = variable_8079431088710665128->fp->count - 1; variable_7115750920615212587 >= 0; variable_7115750920615212587--) unix_inflight(variable_8079431088710665128->fp->fp[variable_7115750920615212587]); }return variable_2438493962786536302;}
|
1
|
bool UserActivityDetector::PreHandleMouseEvent(aura::Window* variable_4044476681818032388,
aura::MouseEvent* variable_7295234379260531092) {
MaybeNotify();
return false;
}
|
0
|
/*
drbd_req.h
This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
Copyright (C) 2006-2008, LINBIT Information Technologies GmbH.
Copyright (C) 2006-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
Copyright (C) 2006-2008, Philipp Reisner <philipp.reisner@linbit.com>.
DRBD 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.
DRBD 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 drbd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _DRBD_REQ_H
#define _DRBD_REQ_H
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/drbd.h>
#include "drbd_int.h"
/* The request callbacks will be called in irq context by the IDE drivers,
and in Softirqs/Tasklets/BH context by the SCSI drivers,
and by the receiver and worker in kernel-thread context.
Try to get the locking right :) */
/*
* Objects of type struct drbd_request do only exist on a R_PRIMARY node, and are
* associated with IO requests originating from the block layer above us.
*
* There are quite a few things that may happen to a drbd request
* during its lifetime.
*
* It will be created.
* It will be marked with the intention to be
* submitted to local disk and/or
* send via the network.
*
* It has to be placed on the transfer log and other housekeeping lists,
* In case we have a network connection.
*
* It may be identified as a concurrent (write) request
* and be handled accordingly.
*
* It may me handed over to the local disk subsystem.
* It may be completed by the local disk subsystem,
* either successfully or with io-error.
* In case it is a READ request, and it failed locally,
* it may be retried remotely.
*
* It may be queued for sending.
* It may be handed over to the network stack,
* which may fail.
* It may be acknowledged by the "peer" according to the wire_protocol in use.
* this may be a negative ack.
* It may receive a faked ack when the network connection is lost and the
* transfer log is cleaned up.
* Sending may be canceled due to network connection loss.
* When it finally has outlived its time,
* corresponding dirty bits in the resync-bitmap may be cleared or set,
* it will be destroyed,
* and completion will be signalled to the originator,
* with or without "success".
*/
enum drbd_req_event {
CREATED,
TO_BE_SENT,
TO_BE_SUBMITTED,
/* XXX yes, now I am inconsistent...
* these are not "events" but "actions"
* oh, well... */
QUEUE_FOR_NET_WRITE,
QUEUE_FOR_NET_READ,
QUEUE_FOR_SEND_OOS,
/* An empty flush is queued as P_BARRIER,
* which will cause it to complete "successfully",
* even if the local disk flush failed.
*
* Just like "real" requests, empty flushes (blkdev_issue_flush()) will
* only see an error if neither local nor remote data is reachable. */
QUEUE_AS_DRBD_BARRIER,
SEND_CANCELED,
SEND_FAILED,
HANDED_OVER_TO_NETWORK,
OOS_HANDED_TO_NETWORK,
CONNECTION_LOST_WHILE_PENDING,
READ_RETRY_REMOTE_CANCELED,
RECV_ACKED_BY_PEER,
WRITE_ACKED_BY_PEER,
WRITE_ACKED_BY_PEER_AND_SIS, /* and set_in_sync */
CONFLICT_RESOLVED,
POSTPONE_WRITE,
NEG_ACKED,
BARRIER_ACKED, /* in protocol A and B */
DATA_RECEIVED, /* (remote read) */
COMPLETED_OK,
READ_COMPLETED_WITH_ERROR,
READ_AHEAD_COMPLETED_WITH_ERROR,
WRITE_COMPLETED_WITH_ERROR,
DISCARD_COMPLETED_NOTSUPP,
DISCARD_COMPLETED_WITH_ERROR,
ABORT_DISK_IO,
RESEND,
FAIL_FROZEN_DISK_IO,
RESTART_FROZEN_DISK_IO,
NOTHING,
};
/* encoding of request states for now. we don't actually need that many bits.
* we don't need to do atomic bit operations either, since most of the time we
* need to look at the connection state and/or manipulate some lists at the
* same time, so we should hold the request lock anyways.
*/
enum drbd_req_state_bits {
/* 3210
* 0000: no local possible
* 0001: to be submitted
* UNUSED, we could map: 011: submitted, completion still pending
* 0110: completed ok
* 0010: completed with error
* 1001: Aborted (before completion)
* 1x10: Aborted and completed -> free
*/
__RQ_LOCAL_PENDING,
__RQ_LOCAL_COMPLETED,
__RQ_LOCAL_OK,
__RQ_LOCAL_ABORTED,
/* 87654
* 00000: no network possible
* 00001: to be send
* 00011: to be send, on worker queue
* 00101: sent, expecting recv_ack (B) or write_ack (C)
* 11101: sent,
* recv_ack (B) or implicit "ack" (A),
* still waiting for the barrier ack.
* master_bio may already be completed and invalidated.
* 11100: write acked (C),
* data received (for remote read, any protocol)
* or finally the barrier ack has arrived (B,A)...
* request can be freed
* 01100: neg-acked (write, protocol C)
* or neg-d-acked (read, any protocol)
* or killed from the transfer log
* during cleanup after connection loss
* request can be freed
* 01000: canceled or send failed...
* request can be freed
*/
/* if "SENT" is not set, yet, this can still fail or be canceled.
* if "SENT" is set already, we still wait for an Ack packet.
* when cleared, the master_bio may be completed.
* in (B,A) the request object may still linger on the transaction log
* until the corresponding barrier ack comes in */
__RQ_NET_PENDING,
/* If it is QUEUED, and it is a WRITE, it is also registered in the
* transfer log. Currently we need this flag to avoid conflicts between
* worker canceling the request and tl_clear_barrier killing it from
* transfer log. We should restructure the code so this conflict does
* no longer occur. */
__RQ_NET_QUEUED,
/* well, actually only "handed over to the network stack".
*
* TODO can potentially be dropped because of the similar meaning
* of RQ_NET_SENT and ~RQ_NET_QUEUED.
* however it is not exactly the same. before we drop it
* we must ensure that we can tell a request with network part
* from a request without, regardless of what happens to it. */
__RQ_NET_SENT,
/* when set, the request may be freed (if RQ_NET_QUEUED is clear).
* basically this means the corresponding P_BARRIER_ACK was received */
__RQ_NET_DONE,
/* whether or not we know (C) or pretend (B,A) that the write
* was successfully written on the peer.
*/
__RQ_NET_OK,
/* peer called drbd_set_in_sync() for this write */
__RQ_NET_SIS,
/* keep this last, its for the RQ_NET_MASK */
__RQ_NET_MAX,
/* Set when this is a write, clear for a read */
__RQ_WRITE,
__RQ_WSAME,
__RQ_UNMAP,
/* Should call drbd_al_complete_io() for this request... */
__RQ_IN_ACT_LOG,
/* The peer has sent a retry ACK */
__RQ_POSTPONED,
/* would have been completed,
* but was not, because of drbd_suspended() */
__RQ_COMPLETION_SUSP,
/* We expect a receive ACK (wire proto B) */
__RQ_EXP_RECEIVE_ACK,
/* We expect a write ACK (wite proto C) */
__RQ_EXP_WRITE_ACK,
/* waiting for a barrier ack, did an extra kref_get */
__RQ_EXP_BARR_ACK,
};
#define RQ_LOCAL_PENDING (1UL << __RQ_LOCAL_PENDING)
#define RQ_LOCAL_COMPLETED (1UL << __RQ_LOCAL_COMPLETED)
#define RQ_LOCAL_OK (1UL << __RQ_LOCAL_OK)
#define RQ_LOCAL_ABORTED (1UL << __RQ_LOCAL_ABORTED)
#define RQ_LOCAL_MASK ((RQ_LOCAL_ABORTED << 1)-1)
#define RQ_NET_PENDING (1UL << __RQ_NET_PENDING)
#define RQ_NET_QUEUED (1UL << __RQ_NET_QUEUED)
#define RQ_NET_SENT (1UL << __RQ_NET_SENT)
#define RQ_NET_DONE (1UL << __RQ_NET_DONE)
#define RQ_NET_OK (1UL << __RQ_NET_OK)
#define RQ_NET_SIS (1UL << __RQ_NET_SIS)
#define RQ_NET_MASK (((1UL << __RQ_NET_MAX)-1) & ~RQ_LOCAL_MASK)
#define RQ_WRITE (1UL << __RQ_WRITE)
#define RQ_WSAME (1UL << __RQ_WSAME)
#define RQ_UNMAP (1UL << __RQ_UNMAP)
#define RQ_IN_ACT_LOG (1UL << __RQ_IN_ACT_LOG)
#define RQ_POSTPONED (1UL << __RQ_POSTPONED)
#define RQ_COMPLETION_SUSP (1UL << __RQ_COMPLETION_SUSP)
#define RQ_EXP_RECEIVE_ACK (1UL << __RQ_EXP_RECEIVE_ACK)
#define RQ_EXP_WRITE_ACK (1UL << __RQ_EXP_WRITE_ACK)
#define RQ_EXP_BARR_ACK (1UL << __RQ_EXP_BARR_ACK)
/* For waking up the frozen transfer log mod_req() has to return if the request
should be counted in the epoch object*/
#define MR_WRITE 1
#define MR_READ 2
static inline void drbd_req_make_private_bio(struct drbd_request *req, struct bio *bio_src)
{
struct bio *bio;
bio = bio_clone(bio_src, GFP_NOIO); /* XXX cannot fail?? */
req->private_bio = bio;
bio->bi_private = req;
bio->bi_end_io = drbd_request_endio;
bio->bi_next = NULL;
}
/* Short lived temporary struct on the stack.
* We could squirrel the error to be returned into
* bio->bi_iter.bi_size, or similar. But that would be too ugly. */
struct bio_and_error {
struct bio *bio;
int error;
};
extern void start_new_tl_epoch(struct drbd_connection *connection);
extern void drbd_req_destroy(struct kref *kref);
extern void _req_may_be_done(struct drbd_request *req,
struct bio_and_error *m);
extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
struct bio_and_error *m);
extern void complete_master_bio(struct drbd_device *device,
struct bio_and_error *m);
extern void request_timer_fn(unsigned long data);
extern void tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void tl_abort_disk_io(struct drbd_device *device);
/* this is in drbd_main.c */
extern void drbd_restart_request(struct drbd_request *req);
/* use this if you don't want to deal with calling complete_master_bio()
* outside the spinlock, e.g. when walking some list on cleanup. */
static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what)
{
struct drbd_device *device = req->device;
struct bio_and_error m;
int rv;
/* __req_mod possibly frees req, do not touch req after that! */
rv = __req_mod(req, what, &m);
if (m.bio)
complete_master_bio(device, &m);
return rv;
}
/* completion of master bio is outside of our spinlock.
* We still may or may not be inside some irqs disabled section
* of the lower level driver completion callback, so we need to
* spin_lock_irqsave here. */
static inline int req_mod(struct drbd_request *req,
enum drbd_req_event what)
{
unsigned long flags;
struct drbd_device *device = req->device;
struct bio_and_error m;
int rv;
spin_lock_irqsave(&device->resource->req_lock, flags);
rv = __req_mod(req, what, &m);
spin_unlock_irqrestore(&device->resource->req_lock, flags);
if (m.bio)
complete_master_bio(device, &m);
return rv;
}
extern bool drbd_should_do_remote(union drbd_dev_state);
#endif
|
1
|
static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp){ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;shm_rmid(ns, shp);shm_unlock(shp); if (!is_file_hugepages(shp->shm_file)) shmem_lock(shp->shm_file, 0, shp->mlock_user);else if (shp->mlock_user) user_shm_unlock(file_inode(shp->shm_file)->i_size,std::string variable_1981342582936368865 ("nt");double variable_6521660331650319254 = -4041785818862106428 * (1916886937372495909);double variable_3585314194866673847 = 363461783853865625;
shp->mlock_user); fput (shp->shm_file);ipc_rcu_putref(shp, shm_rcu_free);}
|
0
|
/*
* This file is part of the Chelsio T4 Ethernet driver for Linux.
*
* Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __T4_REGS_H
#define __T4_REGS_H
#define MYPF_BASE 0x1b000
#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr))
#define PF0_BASE 0x1e000
#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr))
#define PF_STRIDE 0x400
#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE)
#define PF_REG(idx, reg) (PF_BASE(idx) + (reg))
#define MYPORT_BASE 0x1c000
#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr))
#define PORT0_BASE 0x20000
#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr))
#define PORT_STRIDE 0x2000
#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE)
#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg))
#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR)
#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx)
#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
#define PCIE_FW_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
#define SGE_PF_KDOORBELL_A 0x0
#define QID_S 15
#define QID_V(x) ((x) << QID_S)
#define DBPRIO_S 14
#define DBPRIO_V(x) ((x) << DBPRIO_S)
#define DBPRIO_F DBPRIO_V(1U)
#define PIDX_S 0
#define PIDX_V(x) ((x) << PIDX_S)
#define SGE_VF_KDOORBELL_A 0x0
#define DBTYPE_S 13
#define DBTYPE_V(x) ((x) << DBTYPE_S)
#define DBTYPE_F DBTYPE_V(1U)
#define PIDX_T5_S 0
#define PIDX_T5_M 0x1fffU
#define PIDX_T5_V(x) ((x) << PIDX_T5_S)
#define PIDX_T5_G(x) (((x) >> PIDX_T5_S) & PIDX_T5_M)
#define SGE_PF_GTS_A 0x4
#define INGRESSQID_S 16
#define INGRESSQID_V(x) ((x) << INGRESSQID_S)
#define TIMERREG_S 13
#define TIMERREG_V(x) ((x) << TIMERREG_S)
#define SEINTARM_S 12
#define SEINTARM_V(x) ((x) << SEINTARM_S)
#define CIDXINC_S 0
#define CIDXINC_M 0xfffU
#define CIDXINC_V(x) ((x) << CIDXINC_S)
#define SGE_CONTROL_A 0x1008
#define SGE_CONTROL2_A 0x1124
#define RXPKTCPLMODE_S 18
#define RXPKTCPLMODE_V(x) ((x) << RXPKTCPLMODE_S)
#define RXPKTCPLMODE_F RXPKTCPLMODE_V(1U)
#define EGRSTATUSPAGESIZE_S 17
#define EGRSTATUSPAGESIZE_V(x) ((x) << EGRSTATUSPAGESIZE_S)
#define EGRSTATUSPAGESIZE_F EGRSTATUSPAGESIZE_V(1U)
#define PKTSHIFT_S 10
#define PKTSHIFT_M 0x7U
#define PKTSHIFT_V(x) ((x) << PKTSHIFT_S)
#define PKTSHIFT_G(x) (((x) >> PKTSHIFT_S) & PKTSHIFT_M)
#define INGPCIEBOUNDARY_S 7
#define INGPCIEBOUNDARY_V(x) ((x) << INGPCIEBOUNDARY_S)
#define INGPADBOUNDARY_S 4
#define INGPADBOUNDARY_M 0x7U
#define INGPADBOUNDARY_V(x) ((x) << INGPADBOUNDARY_S)
#define INGPADBOUNDARY_G(x) (((x) >> INGPADBOUNDARY_S) & INGPADBOUNDARY_M)
#define EGRPCIEBOUNDARY_S 1
#define EGRPCIEBOUNDARY_V(x) ((x) << EGRPCIEBOUNDARY_S)
#define INGPACKBOUNDARY_S 16
#define INGPACKBOUNDARY_M 0x7U
#define INGPACKBOUNDARY_V(x) ((x) << INGPACKBOUNDARY_S)
#define INGPACKBOUNDARY_G(x) (((x) >> INGPACKBOUNDARY_S) \
& INGPACKBOUNDARY_M)
#define VFIFO_ENABLE_S 10
#define VFIFO_ENABLE_V(x) ((x) << VFIFO_ENABLE_S)
#define VFIFO_ENABLE_F VFIFO_ENABLE_V(1U)
#define SGE_DBVFIFO_BADDR_A 0x1138
#define DBVFIFO_SIZE_S 6
#define DBVFIFO_SIZE_M 0xfffU
#define DBVFIFO_SIZE_G(x) (((x) >> DBVFIFO_SIZE_S) & DBVFIFO_SIZE_M)
#define T6_DBVFIFO_SIZE_S 0
#define T6_DBVFIFO_SIZE_M 0x1fffU
#define T6_DBVFIFO_SIZE_G(x) (((x) >> T6_DBVFIFO_SIZE_S) & T6_DBVFIFO_SIZE_M)
#define GLOBALENABLE_S 0
#define GLOBALENABLE_V(x) ((x) << GLOBALENABLE_S)
#define GLOBALENABLE_F GLOBALENABLE_V(1U)
#define SGE_HOST_PAGE_SIZE_A 0x100c
#define HOSTPAGESIZEPF7_S 28
#define HOSTPAGESIZEPF7_M 0xfU
#define HOSTPAGESIZEPF7_V(x) ((x) << HOSTPAGESIZEPF7_S)
#define HOSTPAGESIZEPF7_G(x) (((x) >> HOSTPAGESIZEPF7_S) & HOSTPAGESIZEPF7_M)
#define HOSTPAGESIZEPF6_S 24
#define HOSTPAGESIZEPF6_M 0xfU
#define HOSTPAGESIZEPF6_V(x) ((x) << HOSTPAGESIZEPF6_S)
#define HOSTPAGESIZEPF6_G(x) (((x) >> HOSTPAGESIZEPF6_S) & HOSTPAGESIZEPF6_M)
#define HOSTPAGESIZEPF5_S 20
#define HOSTPAGESIZEPF5_M 0xfU
#define HOSTPAGESIZEPF5_V(x) ((x) << HOSTPAGESIZEPF5_S)
#define HOSTPAGESIZEPF5_G(x) (((x) >> HOSTPAGESIZEPF5_S) & HOSTPAGESIZEPF5_M)
#define HOSTPAGESIZEPF4_S 16
#define HOSTPAGESIZEPF4_M 0xfU
#define HOSTPAGESIZEPF4_V(x) ((x) << HOSTPAGESIZEPF4_S)
#define HOSTPAGESIZEPF4_G(x) (((x) >> HOSTPAGESIZEPF4_S) & HOSTPAGESIZEPF4_M)
#define HOSTPAGESIZEPF3_S 12
#define HOSTPAGESIZEPF3_M 0xfU
#define HOSTPAGESIZEPF3_V(x) ((x) << HOSTPAGESIZEPF3_S)
#define HOSTPAGESIZEPF3_G(x) (((x) >> HOSTPAGESIZEPF3_S) & HOSTPAGESIZEPF3_M)
#define HOSTPAGESIZEPF2_S 8
#define HOSTPAGESIZEPF2_M 0xfU
#define HOSTPAGESIZEPF2_V(x) ((x) << HOSTPAGESIZEPF2_S)
#define HOSTPAGESIZEPF2_G(x) (((x) >> HOSTPAGESIZEPF2_S) & HOSTPAGESIZEPF2_M)
#define HOSTPAGESIZEPF1_S 4
#define HOSTPAGESIZEPF1_M 0xfU
#define HOSTPAGESIZEPF1_V(x) ((x) << HOSTPAGESIZEPF1_S)
#define HOSTPAGESIZEPF1_G(x) (((x) >> HOSTPAGESIZEPF1_S) & HOSTPAGESIZEPF1_M)
#define HOSTPAGESIZEPF0_S 0
#define HOSTPAGESIZEPF0_M 0xfU
#define HOSTPAGESIZEPF0_V(x) ((x) << HOSTPAGESIZEPF0_S)
#define HOSTPAGESIZEPF0_G(x) (((x) >> HOSTPAGESIZEPF0_S) & HOSTPAGESIZEPF0_M)
#define SGE_EGRESS_QUEUES_PER_PAGE_PF_A 0x1010
#define SGE_EGRESS_QUEUES_PER_PAGE_VF_A 0x1014
#define QUEUESPERPAGEPF1_S 4
#define QUEUESPERPAGEPF0_S 0
#define QUEUESPERPAGEPF0_M 0xfU
#define QUEUESPERPAGEPF0_V(x) ((x) << QUEUESPERPAGEPF0_S)
#define QUEUESPERPAGEPF0_G(x) (((x) >> QUEUESPERPAGEPF0_S) & QUEUESPERPAGEPF0_M)
#define SGE_INT_CAUSE1_A 0x1024
#define SGE_INT_CAUSE2_A 0x1030
#define SGE_INT_CAUSE3_A 0x103c
#define ERR_FLM_DBP_S 31
#define ERR_FLM_DBP_V(x) ((x) << ERR_FLM_DBP_S)
#define ERR_FLM_DBP_F ERR_FLM_DBP_V(1U)
#define ERR_FLM_IDMA1_S 30
#define ERR_FLM_IDMA1_V(x) ((x) << ERR_FLM_IDMA1_S)
#define ERR_FLM_IDMA1_F ERR_FLM_IDMA1_V(1U)
#define ERR_FLM_IDMA0_S 29
#define ERR_FLM_IDMA0_V(x) ((x) << ERR_FLM_IDMA0_S)
#define ERR_FLM_IDMA0_F ERR_FLM_IDMA0_V(1U)
#define ERR_FLM_HINT_S 28
#define ERR_FLM_HINT_V(x) ((x) << ERR_FLM_HINT_S)
#define ERR_FLM_HINT_F ERR_FLM_HINT_V(1U)
#define ERR_PCIE_ERROR3_S 27
#define ERR_PCIE_ERROR3_V(x) ((x) << ERR_PCIE_ERROR3_S)
#define ERR_PCIE_ERROR3_F ERR_PCIE_ERROR3_V(1U)
#define ERR_PCIE_ERROR2_S 26
#define ERR_PCIE_ERROR2_V(x) ((x) << ERR_PCIE_ERROR2_S)
#define ERR_PCIE_ERROR2_F ERR_PCIE_ERROR2_V(1U)
#define ERR_PCIE_ERROR1_S 25
#define ERR_PCIE_ERROR1_V(x) ((x) << ERR_PCIE_ERROR1_S)
#define ERR_PCIE_ERROR1_F ERR_PCIE_ERROR1_V(1U)
#define ERR_PCIE_ERROR0_S 24
#define ERR_PCIE_ERROR0_V(x) ((x) << ERR_PCIE_ERROR0_S)
#define ERR_PCIE_ERROR0_F ERR_PCIE_ERROR0_V(1U)
#define ERR_CPL_EXCEED_IQE_SIZE_S 22
#define ERR_CPL_EXCEED_IQE_SIZE_V(x) ((x) << ERR_CPL_EXCEED_IQE_SIZE_S)
#define ERR_CPL_EXCEED_IQE_SIZE_F ERR_CPL_EXCEED_IQE_SIZE_V(1U)
#define ERR_INVALID_CIDX_INC_S 21
#define ERR_INVALID_CIDX_INC_V(x) ((x) << ERR_INVALID_CIDX_INC_S)
#define ERR_INVALID_CIDX_INC_F ERR_INVALID_CIDX_INC_V(1U)
#define ERR_CPL_OPCODE_0_S 19
#define ERR_CPL_OPCODE_0_V(x) ((x) << ERR_CPL_OPCODE_0_S)
#define ERR_CPL_OPCODE_0_F ERR_CPL_OPCODE_0_V(1U)
#define ERR_DROPPED_DB_S 18
#define ERR_DROPPED_DB_V(x) ((x) << ERR_DROPPED_DB_S)
#define ERR_DROPPED_DB_F ERR_DROPPED_DB_V(1U)
#define ERR_DATA_CPL_ON_HIGH_QID1_S 17
#define ERR_DATA_CPL_ON_HIGH_QID1_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID1_S)
#define ERR_DATA_CPL_ON_HIGH_QID1_F ERR_DATA_CPL_ON_HIGH_QID1_V(1U)
#define ERR_DATA_CPL_ON_HIGH_QID0_S 16
#define ERR_DATA_CPL_ON_HIGH_QID0_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID0_S)
#define ERR_DATA_CPL_ON_HIGH_QID0_F ERR_DATA_CPL_ON_HIGH_QID0_V(1U)
#define ERR_BAD_DB_PIDX3_S 15
#define ERR_BAD_DB_PIDX3_V(x) ((x) << ERR_BAD_DB_PIDX3_S)
#define ERR_BAD_DB_PIDX3_F ERR_BAD_DB_PIDX3_V(1U)
#define ERR_BAD_DB_PIDX2_S 14
#define ERR_BAD_DB_PIDX2_V(x) ((x) << ERR_BAD_DB_PIDX2_S)
#define ERR_BAD_DB_PIDX2_F ERR_BAD_DB_PIDX2_V(1U)
#define ERR_BAD_DB_PIDX1_S 13
#define ERR_BAD_DB_PIDX1_V(x) ((x) << ERR_BAD_DB_PIDX1_S)
#define ERR_BAD_DB_PIDX1_F ERR_BAD_DB_PIDX1_V(1U)
#define ERR_BAD_DB_PIDX0_S 12
#define ERR_BAD_DB_PIDX0_V(x) ((x) << ERR_BAD_DB_PIDX0_S)
#define ERR_BAD_DB_PIDX0_F ERR_BAD_DB_PIDX0_V(1U)
#define ERR_ING_CTXT_PRIO_S 10
#define ERR_ING_CTXT_PRIO_V(x) ((x) << ERR_ING_CTXT_PRIO_S)
#define ERR_ING_CTXT_PRIO_F ERR_ING_CTXT_PRIO_V(1U)
#define ERR_EGR_CTXT_PRIO_S 9
#define ERR_EGR_CTXT_PRIO_V(x) ((x) << ERR_EGR_CTXT_PRIO_S)
#define ERR_EGR_CTXT_PRIO_F ERR_EGR_CTXT_PRIO_V(1U)
#define DBFIFO_HP_INT_S 8
#define DBFIFO_HP_INT_V(x) ((x) << DBFIFO_HP_INT_S)
#define DBFIFO_HP_INT_F DBFIFO_HP_INT_V(1U)
#define DBFIFO_LP_INT_S 7
#define DBFIFO_LP_INT_V(x) ((x) << DBFIFO_LP_INT_S)
#define DBFIFO_LP_INT_F DBFIFO_LP_INT_V(1U)
#define INGRESS_SIZE_ERR_S 5
#define INGRESS_SIZE_ERR_V(x) ((x) << INGRESS_SIZE_ERR_S)
#define INGRESS_SIZE_ERR_F INGRESS_SIZE_ERR_V(1U)
#define EGRESS_SIZE_ERR_S 4
#define EGRESS_SIZE_ERR_V(x) ((x) << EGRESS_SIZE_ERR_S)
#define EGRESS_SIZE_ERR_F EGRESS_SIZE_ERR_V(1U)
#define SGE_INT_ENABLE3_A 0x1040
#define SGE_FL_BUFFER_SIZE0_A 0x1044
#define SGE_FL_BUFFER_SIZE1_A 0x1048
#define SGE_FL_BUFFER_SIZE2_A 0x104c
#define SGE_FL_BUFFER_SIZE3_A 0x1050
#define SGE_FL_BUFFER_SIZE4_A 0x1054
#define SGE_FL_BUFFER_SIZE5_A 0x1058
#define SGE_FL_BUFFER_SIZE6_A 0x105c
#define SGE_FL_BUFFER_SIZE7_A 0x1060
#define SGE_FL_BUFFER_SIZE8_A 0x1064
#define SGE_IMSG_CTXT_BADDR_A 0x1088
#define SGE_FLM_CACHE_BADDR_A 0x108c
#define SGE_INGRESS_RX_THRESHOLD_A 0x10a0
#define THRESHOLD_0_S 24
#define THRESHOLD_0_M 0x3fU
#define THRESHOLD_0_V(x) ((x) << THRESHOLD_0_S)
#define THRESHOLD_0_G(x) (((x) >> THRESHOLD_0_S) & THRESHOLD_0_M)
#define THRESHOLD_1_S 16
#define THRESHOLD_1_M 0x3fU
#define THRESHOLD_1_V(x) ((x) << THRESHOLD_1_S)
#define THRESHOLD_1_G(x) (((x) >> THRESHOLD_1_S) & THRESHOLD_1_M)
#define THRESHOLD_2_S 8
#define THRESHOLD_2_M 0x3fU
#define THRESHOLD_2_V(x) ((x) << THRESHOLD_2_S)
#define THRESHOLD_2_G(x) (((x) >> THRESHOLD_2_S) & THRESHOLD_2_M)
#define THRESHOLD_3_S 0
#define THRESHOLD_3_M 0x3fU
#define THRESHOLD_3_V(x) ((x) << THRESHOLD_3_S)
#define THRESHOLD_3_G(x) (((x) >> THRESHOLD_3_S) & THRESHOLD_3_M)
#define SGE_CONM_CTRL_A 0x1094
#define EGRTHRESHOLD_S 8
#define EGRTHRESHOLD_M 0x3fU
#define EGRTHRESHOLD_V(x) ((x) << EGRTHRESHOLD_S)
#define EGRTHRESHOLD_G(x) (((x) >> EGRTHRESHOLD_S) & EGRTHRESHOLD_M)
#define EGRTHRESHOLDPACKING_S 14
#define EGRTHRESHOLDPACKING_M 0x3fU
#define EGRTHRESHOLDPACKING_V(x) ((x) << EGRTHRESHOLDPACKING_S)
#define EGRTHRESHOLDPACKING_G(x) \
(((x) >> EGRTHRESHOLDPACKING_S) & EGRTHRESHOLDPACKING_M)
#define T6_EGRTHRESHOLDPACKING_S 16
#define T6_EGRTHRESHOLDPACKING_M 0xffU
#define T6_EGRTHRESHOLDPACKING_G(x) \
(((x) >> T6_EGRTHRESHOLDPACKING_S) & T6_EGRTHRESHOLDPACKING_M)
#define SGE_TIMESTAMP_LO_A 0x1098
#define SGE_TIMESTAMP_HI_A 0x109c
#define TSOP_S 28
#define TSOP_M 0x3U
#define TSOP_V(x) ((x) << TSOP_S)
#define TSOP_G(x) (((x) >> TSOP_S) & TSOP_M)
#define TSVAL_S 0
#define TSVAL_M 0xfffffffU
#define TSVAL_V(x) ((x) << TSVAL_S)
#define TSVAL_G(x) (((x) >> TSVAL_S) & TSVAL_M)
#define SGE_DBFIFO_STATUS_A 0x10a4
#define SGE_DBVFIFO_SIZE_A 0x113c
#define HP_INT_THRESH_S 28
#define HP_INT_THRESH_M 0xfU
#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S)
#define LP_INT_THRESH_S 12
#define LP_INT_THRESH_M 0xfU
#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S)
#define SGE_DOORBELL_CONTROL_A 0x10a8
#define NOCOALESCE_S 26
#define NOCOALESCE_V(x) ((x) << NOCOALESCE_S)
#define NOCOALESCE_F NOCOALESCE_V(1U)
#define ENABLE_DROP_S 13
#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S)
#define ENABLE_DROP_F ENABLE_DROP_V(1U)
#define SGE_TIMER_VALUE_0_AND_1_A 0x10b8
#define TIMERVALUE0_S 16
#define TIMERVALUE0_M 0xffffU
#define TIMERVALUE0_V(x) ((x) << TIMERVALUE0_S)
#define TIMERVALUE0_G(x) (((x) >> TIMERVALUE0_S) & TIMERVALUE0_M)
#define TIMERVALUE1_S 0
#define TIMERVALUE1_M 0xffffU
#define TIMERVALUE1_V(x) ((x) << TIMERVALUE1_S)
#define TIMERVALUE1_G(x) (((x) >> TIMERVALUE1_S) & TIMERVALUE1_M)
#define SGE_TIMER_VALUE_2_AND_3_A 0x10bc
#define TIMERVALUE2_S 16
#define TIMERVALUE2_M 0xffffU
#define TIMERVALUE2_V(x) ((x) << TIMERVALUE2_S)
#define TIMERVALUE2_G(x) (((x) >> TIMERVALUE2_S) & TIMERVALUE2_M)
#define TIMERVALUE3_S 0
#define TIMERVALUE3_M 0xffffU
#define TIMERVALUE3_V(x) ((x) << TIMERVALUE3_S)
#define TIMERVALUE3_G(x) (((x) >> TIMERVALUE3_S) & TIMERVALUE3_M)
#define SGE_TIMER_VALUE_4_AND_5_A 0x10c0
#define TIMERVALUE4_S 16
#define TIMERVALUE4_M 0xffffU
#define TIMERVALUE4_V(x) ((x) << TIMERVALUE4_S)
#define TIMERVALUE4_G(x) (((x) >> TIMERVALUE4_S) & TIMERVALUE4_M)
#define TIMERVALUE5_S 0
#define TIMERVALUE5_M 0xffffU
#define TIMERVALUE5_V(x) ((x) << TIMERVALUE5_S)
#define TIMERVALUE5_G(x) (((x) >> TIMERVALUE5_S) & TIMERVALUE5_M)
#define SGE_DEBUG_INDEX_A 0x10cc
#define SGE_DEBUG_DATA_HIGH_A 0x10d0
#define SGE_DEBUG_DATA_LOW_A 0x10d4
#define SGE_DEBUG_DATA_LOW_INDEX_2_A 0x12c8
#define SGE_DEBUG_DATA_LOW_INDEX_3_A 0x12cc
#define SGE_DEBUG_DATA_HIGH_INDEX_10_A 0x12a8
#define SGE_INGRESS_QUEUES_PER_PAGE_PF_A 0x10f4
#define SGE_INGRESS_QUEUES_PER_PAGE_VF_A 0x10f8
#define SGE_ERROR_STATS_A 0x1100
#define UNCAPTURED_ERROR_S 18
#define UNCAPTURED_ERROR_V(x) ((x) << UNCAPTURED_ERROR_S)
#define UNCAPTURED_ERROR_F UNCAPTURED_ERROR_V(1U)
#define ERROR_QID_VALID_S 17
#define ERROR_QID_VALID_V(x) ((x) << ERROR_QID_VALID_S)
#define ERROR_QID_VALID_F ERROR_QID_VALID_V(1U)
#define ERROR_QID_S 0
#define ERROR_QID_M 0x1ffffU
#define ERROR_QID_G(x) (((x) >> ERROR_QID_S) & ERROR_QID_M)
#define HP_INT_THRESH_S 28
#define HP_INT_THRESH_M 0xfU
#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S)
#define HP_COUNT_S 16
#define HP_COUNT_M 0x7ffU
#define HP_COUNT_G(x) (((x) >> HP_COUNT_S) & HP_COUNT_M)
#define LP_INT_THRESH_S 12
#define LP_INT_THRESH_M 0xfU
#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S)
#define LP_COUNT_S 0
#define LP_COUNT_M 0x7ffU
#define LP_COUNT_G(x) (((x) >> LP_COUNT_S) & LP_COUNT_M)
#define LP_INT_THRESH_T5_S 18
#define LP_INT_THRESH_T5_M 0xfffU
#define LP_INT_THRESH_T5_V(x) ((x) << LP_INT_THRESH_T5_S)
#define LP_COUNT_T5_S 0
#define LP_COUNT_T5_M 0x3ffffU
#define LP_COUNT_T5_G(x) (((x) >> LP_COUNT_T5_S) & LP_COUNT_T5_M)
#define SGE_DOORBELL_CONTROL_A 0x10a8
#define SGE_STAT_TOTAL_A 0x10e4
#define SGE_STAT_MATCH_A 0x10e8
#define SGE_STAT_CFG_A 0x10ec
#define STATMODE_S 2
#define STATMODE_V(x) ((x) << STATMODE_S)
#define STATSOURCE_T5_S 9
#define STATSOURCE_T5_M 0xfU
#define STATSOURCE_T5_V(x) ((x) << STATSOURCE_T5_S)
#define STATSOURCE_T5_G(x) (((x) >> STATSOURCE_T5_S) & STATSOURCE_T5_M)
#define T6_STATMODE_S 0
#define T6_STATMODE_V(x) ((x) << T6_STATMODE_S)
#define SGE_DBFIFO_STATUS2_A 0x1118
#define HP_INT_THRESH_T5_S 10
#define HP_INT_THRESH_T5_M 0xfU
#define HP_INT_THRESH_T5_V(x) ((x) << HP_INT_THRESH_T5_S)
#define HP_COUNT_T5_S 0
#define HP_COUNT_T5_M 0x3ffU
#define HP_COUNT_T5_G(x) (((x) >> HP_COUNT_T5_S) & HP_COUNT_T5_M)
#define ENABLE_DROP_S 13
#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S)
#define ENABLE_DROP_F ENABLE_DROP_V(1U)
#define DROPPED_DB_S 0
#define DROPPED_DB_V(x) ((x) << DROPPED_DB_S)
#define DROPPED_DB_F DROPPED_DB_V(1U)
#define SGE_CTXT_CMD_A 0x11fc
#define SGE_DBQ_CTXT_BADDR_A 0x1084
/* registers for module PCIE */
#define PCIE_PF_CFG_A 0x40
#define AIVEC_S 4
#define AIVEC_M 0x3ffU
#define AIVEC_V(x) ((x) << AIVEC_S)
#define PCIE_PF_CLI_A 0x44
#define PCIE_INT_CAUSE_A 0x3004
#define UNXSPLCPLERR_S 29
#define UNXSPLCPLERR_V(x) ((x) << UNXSPLCPLERR_S)
#define UNXSPLCPLERR_F UNXSPLCPLERR_V(1U)
#define PCIEPINT_S 28
#define PCIEPINT_V(x) ((x) << PCIEPINT_S)
#define PCIEPINT_F PCIEPINT_V(1U)
#define PCIESINT_S 27
#define PCIESINT_V(x) ((x) << PCIESINT_S)
#define PCIESINT_F PCIESINT_V(1U)
#define RPLPERR_S 26
#define RPLPERR_V(x) ((x) << RPLPERR_S)
#define RPLPERR_F RPLPERR_V(1U)
#define RXWRPERR_S 25
#define RXWRPERR_V(x) ((x) << RXWRPERR_S)
#define RXWRPERR_F RXWRPERR_V(1U)
#define RXCPLPERR_S 24
#define RXCPLPERR_V(x) ((x) << RXCPLPERR_S)
#define RXCPLPERR_F RXCPLPERR_V(1U)
#define PIOTAGPERR_S 23
#define PIOTAGPERR_V(x) ((x) << PIOTAGPERR_S)
#define PIOTAGPERR_F PIOTAGPERR_V(1U)
#define MATAGPERR_S 22
#define MATAGPERR_V(x) ((x) << MATAGPERR_S)
#define MATAGPERR_F MATAGPERR_V(1U)
#define INTXCLRPERR_S 21
#define INTXCLRPERR_V(x) ((x) << INTXCLRPERR_S)
#define INTXCLRPERR_F INTXCLRPERR_V(1U)
#define FIDPERR_S 20
#define FIDPERR_V(x) ((x) << FIDPERR_S)
#define FIDPERR_F FIDPERR_V(1U)
#define CFGSNPPERR_S 19
#define CFGSNPPERR_V(x) ((x) << CFGSNPPERR_S)
#define CFGSNPPERR_F CFGSNPPERR_V(1U)
#define HRSPPERR_S 18
#define HRSPPERR_V(x) ((x) << HRSPPERR_S)
#define HRSPPERR_F HRSPPERR_V(1U)
#define HREQPERR_S 17
#define HREQPERR_V(x) ((x) << HREQPERR_S)
#define HREQPERR_F HREQPERR_V(1U)
#define HCNTPERR_S 16
#define HCNTPERR_V(x) ((x) << HCNTPERR_S)
#define HCNTPERR_F HCNTPERR_V(1U)
#define DRSPPERR_S 15
#define DRSPPERR_V(x) ((x) << DRSPPERR_S)
#define DRSPPERR_F DRSPPERR_V(1U)
#define DREQPERR_S 14
#define DREQPERR_V(x) ((x) << DREQPERR_S)
#define DREQPERR_F DREQPERR_V(1U)
#define DCNTPERR_S 13
#define DCNTPERR_V(x) ((x) << DCNTPERR_S)
#define DCNTPERR_F DCNTPERR_V(1U)
#define CRSPPERR_S 12
#define CRSPPERR_V(x) ((x) << CRSPPERR_S)
#define CRSPPERR_F CRSPPERR_V(1U)
#define CREQPERR_S 11
#define CREQPERR_V(x) ((x) << CREQPERR_S)
#define CREQPERR_F CREQPERR_V(1U)
#define CCNTPERR_S 10
#define CCNTPERR_V(x) ((x) << CCNTPERR_S)
#define CCNTPERR_F CCNTPERR_V(1U)
#define TARTAGPERR_S 9
#define TARTAGPERR_V(x) ((x) << TARTAGPERR_S)
#define TARTAGPERR_F TARTAGPERR_V(1U)
#define PIOREQPERR_S 8
#define PIOREQPERR_V(x) ((x) << PIOREQPERR_S)
#define PIOREQPERR_F PIOREQPERR_V(1U)
#define PIOCPLPERR_S 7
#define PIOCPLPERR_V(x) ((x) << PIOCPLPERR_S)
#define PIOCPLPERR_F PIOCPLPERR_V(1U)
#define MSIXDIPERR_S 6
#define MSIXDIPERR_V(x) ((x) << MSIXDIPERR_S)
#define MSIXDIPERR_F MSIXDIPERR_V(1U)
#define MSIXDATAPERR_S 5
#define MSIXDATAPERR_V(x) ((x) << MSIXDATAPERR_S)
#define MSIXDATAPERR_F MSIXDATAPERR_V(1U)
#define MSIXADDRHPERR_S 4
#define MSIXADDRHPERR_V(x) ((x) << MSIXADDRHPERR_S)
#define MSIXADDRHPERR_F MSIXADDRHPERR_V(1U)
#define MSIXADDRLPERR_S 3
#define MSIXADDRLPERR_V(x) ((x) << MSIXADDRLPERR_S)
#define MSIXADDRLPERR_F MSIXADDRLPERR_V(1U)
#define MSIDATAPERR_S 2
#define MSIDATAPERR_V(x) ((x) << MSIDATAPERR_S)
#define MSIDATAPERR_F MSIDATAPERR_V(1U)
#define MSIADDRHPERR_S 1
#define MSIADDRHPERR_V(x) ((x) << MSIADDRHPERR_S)
#define MSIADDRHPERR_F MSIADDRHPERR_V(1U)
#define MSIADDRLPERR_S 0
#define MSIADDRLPERR_V(x) ((x) << MSIADDRLPERR_S)
#define MSIADDRLPERR_F MSIADDRLPERR_V(1U)
#define READRSPERR_S 29
#define READRSPERR_V(x) ((x) << READRSPERR_S)
#define READRSPERR_F READRSPERR_V(1U)
#define TRGT1GRPPERR_S 28
#define TRGT1GRPPERR_V(x) ((x) << TRGT1GRPPERR_S)
#define TRGT1GRPPERR_F TRGT1GRPPERR_V(1U)
#define IPSOTPERR_S 27
#define IPSOTPERR_V(x) ((x) << IPSOTPERR_S)
#define IPSOTPERR_F IPSOTPERR_V(1U)
#define IPRETRYPERR_S 26
#define IPRETRYPERR_V(x) ((x) << IPRETRYPERR_S)
#define IPRETRYPERR_F IPRETRYPERR_V(1U)
#define IPRXDATAGRPPERR_S 25
#define IPRXDATAGRPPERR_V(x) ((x) << IPRXDATAGRPPERR_S)
#define IPRXDATAGRPPERR_F IPRXDATAGRPPERR_V(1U)
#define IPRXHDRGRPPERR_S 24
#define IPRXHDRGRPPERR_V(x) ((x) << IPRXHDRGRPPERR_S)
#define IPRXHDRGRPPERR_F IPRXHDRGRPPERR_V(1U)
#define MAGRPPERR_S 22
#define MAGRPPERR_V(x) ((x) << MAGRPPERR_S)
#define MAGRPPERR_F MAGRPPERR_V(1U)
#define VFIDPERR_S 21
#define VFIDPERR_V(x) ((x) << VFIDPERR_S)
#define VFIDPERR_F VFIDPERR_V(1U)
#define HREQWRPERR_S 16
#define HREQWRPERR_V(x) ((x) << HREQWRPERR_S)
#define HREQWRPERR_F HREQWRPERR_V(1U)
#define DREQWRPERR_S 13
#define DREQWRPERR_V(x) ((x) << DREQWRPERR_S)
#define DREQWRPERR_F DREQWRPERR_V(1U)
#define CREQRDPERR_S 11
#define CREQRDPERR_V(x) ((x) << CREQRDPERR_S)
#define CREQRDPERR_F CREQRDPERR_V(1U)
#define MSTTAGQPERR_S 10
#define MSTTAGQPERR_V(x) ((x) << MSTTAGQPERR_S)
#define MSTTAGQPERR_F MSTTAGQPERR_V(1U)
#define PIOREQGRPPERR_S 8
#define PIOREQGRPPERR_V(x) ((x) << PIOREQGRPPERR_S)
#define PIOREQGRPPERR_F PIOREQGRPPERR_V(1U)
#define PIOCPLGRPPERR_S 7
#define PIOCPLGRPPERR_V(x) ((x) << PIOCPLGRPPERR_S)
#define PIOCPLGRPPERR_F PIOCPLGRPPERR_V(1U)
#define MSIXSTIPERR_S 2
#define MSIXSTIPERR_V(x) ((x) << MSIXSTIPERR_S)
#define MSIXSTIPERR_F MSIXSTIPERR_V(1U)
#define MSTTIMEOUTPERR_S 1
#define MSTTIMEOUTPERR_V(x) ((x) << MSTTIMEOUTPERR_S)
#define MSTTIMEOUTPERR_F MSTTIMEOUTPERR_V(1U)
#define MSTGRPPERR_S 0
#define MSTGRPPERR_V(x) ((x) << MSTGRPPERR_S)
#define MSTGRPPERR_F MSTGRPPERR_V(1U)
#define PCIE_NONFAT_ERR_A 0x3010
#define PCIE_CFG_SPACE_REQ_A 0x3060
#define PCIE_CFG_SPACE_DATA_A 0x3064
#define PCIE_MEM_ACCESS_BASE_WIN_A 0x3068
#define PCIEOFST_S 10
#define PCIEOFST_M 0x3fffffU
#define PCIEOFST_G(x) (((x) >> PCIEOFST_S) & PCIEOFST_M)
#define BIR_S 8
#define BIR_M 0x3U
#define BIR_V(x) ((x) << BIR_S)
#define BIR_G(x) (((x) >> BIR_S) & BIR_M)
#define WINDOW_S 0
#define WINDOW_M 0xffU
#define WINDOW_V(x) ((x) << WINDOW_S)
#define WINDOW_G(x) (((x) >> WINDOW_S) & WINDOW_M)
#define PCIE_MEM_ACCESS_OFFSET_A 0x306c
#define ENABLE_S 30
#define ENABLE_V(x) ((x) << ENABLE_S)
#define ENABLE_F ENABLE_V(1U)
#define LOCALCFG_S 28
#define LOCALCFG_V(x) ((x) << LOCALCFG_S)
#define LOCALCFG_F LOCALCFG_V(1U)
#define FUNCTION_S 12
#define FUNCTION_V(x) ((x) << FUNCTION_S)
#define REGISTER_S 0
#define REGISTER_V(x) ((x) << REGISTER_S)
#define T6_ENABLE_S 31
#define T6_ENABLE_V(x) ((x) << T6_ENABLE_S)
#define T6_ENABLE_F T6_ENABLE_V(1U)
#define PFNUM_S 0
#define PFNUM_V(x) ((x) << PFNUM_S)
#define PCIE_FW_A 0x30b8
#define PCIE_FW_PF_A 0x30bc
#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS_A 0x5908
#define RNPP_S 31
#define RNPP_V(x) ((x) << RNPP_S)
#define RNPP_F RNPP_V(1U)
#define RPCP_S 29
#define RPCP_V(x) ((x) << RPCP_S)
#define RPCP_F RPCP_V(1U)
#define RCIP_S 27
#define RCIP_V(x) ((x) << RCIP_S)
#define RCIP_F RCIP_V(1U)
#define RCCP_S 26
#define RCCP_V(x) ((x) << RCCP_S)
#define RCCP_F RCCP_V(1U)
#define RFTP_S 23
#define RFTP_V(x) ((x) << RFTP_S)
#define RFTP_F RFTP_V(1U)
#define PTRP_S 20
#define PTRP_V(x) ((x) << PTRP_S)
#define PTRP_F PTRP_V(1U)
#define PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS_A 0x59a4
#define TPCP_S 30
#define TPCP_V(x) ((x) << TPCP_S)
#define TPCP_F TPCP_V(1U)
#define TNPP_S 29
#define TNPP_V(x) ((x) << TNPP_S)
#define TNPP_F TNPP_V(1U)
#define TFTP_S 28
#define TFTP_V(x) ((x) << TFTP_S)
#define TFTP_F TFTP_V(1U)
#define TCAP_S 27
#define TCAP_V(x) ((x) << TCAP_S)
#define TCAP_F TCAP_V(1U)
#define TCIP_S 26
#define TCIP_V(x) ((x) << TCIP_S)
#define TCIP_F TCIP_V(1U)
#define RCAP_S 25
#define RCAP_V(x) ((x) << RCAP_S)
#define RCAP_F RCAP_V(1U)
#define PLUP_S 23
#define PLUP_V(x) ((x) << PLUP_S)
#define PLUP_F PLUP_V(1U)
#define PLDN_S 22
#define PLDN_V(x) ((x) << PLDN_S)
#define PLDN_F PLDN_V(1U)
#define OTDD_S 21
#define OTDD_V(x) ((x) << OTDD_S)
#define OTDD_F OTDD_V(1U)
#define GTRP_S 20
#define GTRP_V(x) ((x) << GTRP_S)
#define GTRP_F GTRP_V(1U)
#define RDPE_S 18
#define RDPE_V(x) ((x) << RDPE_S)
#define RDPE_F RDPE_V(1U)
#define TDCE_S 17
#define TDCE_V(x) ((x) << TDCE_S)
#define TDCE_F TDCE_V(1U)
#define TDUE_S 16
#define TDUE_V(x) ((x) << TDUE_S)
#define TDUE_F TDUE_V(1U)
/* registers for module MC */
#define MC_INT_CAUSE_A 0x7518
#define MC_P_INT_CAUSE_A 0x41318
#define ECC_UE_INT_CAUSE_S 2
#define ECC_UE_INT_CAUSE_V(x) ((x) << ECC_UE_INT_CAUSE_S)
#define ECC_UE_INT_CAUSE_F ECC_UE_INT_CAUSE_V(1U)
#define ECC_CE_INT_CAUSE_S 1
#define ECC_CE_INT_CAUSE_V(x) ((x) << ECC_CE_INT_CAUSE_S)
#define ECC_CE_INT_CAUSE_F ECC_CE_INT_CAUSE_V(1U)
#define PERR_INT_CAUSE_S 0
#define PERR_INT_CAUSE_V(x) ((x) << PERR_INT_CAUSE_S)
#define PERR_INT_CAUSE_F PERR_INT_CAUSE_V(1U)
#define DBG_GPIO_EN_A 0x6010
#define XGMAC_PORT_CFG_A 0x1000
#define MAC_PORT_CFG_A 0x800
#define SIGNAL_DET_S 14
#define SIGNAL_DET_V(x) ((x) << SIGNAL_DET_S)
#define SIGNAL_DET_F SIGNAL_DET_V(1U)
#define MC_ECC_STATUS_A 0x751c
#define MC_P_ECC_STATUS_A 0x4131c
#define ECC_CECNT_S 16
#define ECC_CECNT_M 0xffffU
#define ECC_CECNT_V(x) ((x) << ECC_CECNT_S)
#define ECC_CECNT_G(x) (((x) >> ECC_CECNT_S) & ECC_CECNT_M)
#define ECC_UECNT_S 0
#define ECC_UECNT_M 0xffffU
#define ECC_UECNT_V(x) ((x) << ECC_UECNT_S)
#define ECC_UECNT_G(x) (((x) >> ECC_UECNT_S) & ECC_UECNT_M)
#define MC_BIST_CMD_A 0x7600
#define START_BIST_S 31
#define START_BIST_V(x) ((x) << START_BIST_S)
#define START_BIST_F START_BIST_V(1U)
#define BIST_CMD_GAP_S 8
#define BIST_CMD_GAP_V(x) ((x) << BIST_CMD_GAP_S)
#define BIST_OPCODE_S 0
#define BIST_OPCODE_V(x) ((x) << BIST_OPCODE_S)
#define MC_BIST_CMD_ADDR_A 0x7604
#define MC_BIST_CMD_LEN_A 0x7608
#define MC_BIST_DATA_PATTERN_A 0x760c
#define MC_BIST_STATUS_RDATA_A 0x7688
/* registers for module MA */
#define MA_EDRAM0_BAR_A 0x77c0
#define EDRAM0_BASE_S 16
#define EDRAM0_BASE_M 0xfffU
#define EDRAM0_BASE_G(x) (((x) >> EDRAM0_BASE_S) & EDRAM0_BASE_M)
#define EDRAM0_SIZE_S 0
#define EDRAM0_SIZE_M 0xfffU
#define EDRAM0_SIZE_V(x) ((x) << EDRAM0_SIZE_S)
#define EDRAM0_SIZE_G(x) (((x) >> EDRAM0_SIZE_S) & EDRAM0_SIZE_M)
#define MA_EDRAM1_BAR_A 0x77c4
#define EDRAM1_BASE_S 16
#define EDRAM1_BASE_M 0xfffU
#define EDRAM1_BASE_G(x) (((x) >> EDRAM1_BASE_S) & EDRAM1_BASE_M)
#define EDRAM1_SIZE_S 0
#define EDRAM1_SIZE_M 0xfffU
#define EDRAM1_SIZE_V(x) ((x) << EDRAM1_SIZE_S)
#define EDRAM1_SIZE_G(x) (((x) >> EDRAM1_SIZE_S) & EDRAM1_SIZE_M)
#define MA_EXT_MEMORY_BAR_A 0x77c8
#define EXT_MEM_BASE_S 16
#define EXT_MEM_BASE_M 0xfffU
#define EXT_MEM_BASE_V(x) ((x) << EXT_MEM_BASE_S)
#define EXT_MEM_BASE_G(x) (((x) >> EXT_MEM_BASE_S) & EXT_MEM_BASE_M)
#define EXT_MEM_SIZE_S 0
#define EXT_MEM_SIZE_M 0xfffU
#define EXT_MEM_SIZE_V(x) ((x) << EXT_MEM_SIZE_S)
#define EXT_MEM_SIZE_G(x) (((x) >> EXT_MEM_SIZE_S) & EXT_MEM_SIZE_M)
#define MA_EXT_MEMORY1_BAR_A 0x7808
#define EXT_MEM1_BASE_S 16
#define EXT_MEM1_BASE_M 0xfffU
#define EXT_MEM1_BASE_G(x) (((x) >> EXT_MEM1_BASE_S) & EXT_MEM1_BASE_M)
#define EXT_MEM1_SIZE_S 0
#define EXT_MEM1_SIZE_M 0xfffU
#define EXT_MEM1_SIZE_V(x) ((x) << EXT_MEM1_SIZE_S)
#define EXT_MEM1_SIZE_G(x) (((x) >> EXT_MEM1_SIZE_S) & EXT_MEM1_SIZE_M)
#define MA_EXT_MEMORY0_BAR_A 0x77c8
#define EXT_MEM0_BASE_S 16
#define EXT_MEM0_BASE_M 0xfffU
#define EXT_MEM0_BASE_G(x) (((x) >> EXT_MEM0_BASE_S) & EXT_MEM0_BASE_M)
#define EXT_MEM0_SIZE_S 0
#define EXT_MEM0_SIZE_M 0xfffU
#define EXT_MEM0_SIZE_V(x) ((x) << EXT_MEM0_SIZE_S)
#define EXT_MEM0_SIZE_G(x) (((x) >> EXT_MEM0_SIZE_S) & EXT_MEM0_SIZE_M)
#define MA_TARGET_MEM_ENABLE_A 0x77d8
#define EXT_MEM_ENABLE_S 2
#define EXT_MEM_ENABLE_V(x) ((x) << EXT_MEM_ENABLE_S)
#define EXT_MEM_ENABLE_F EXT_MEM_ENABLE_V(1U)
#define EDRAM1_ENABLE_S 1
#define EDRAM1_ENABLE_V(x) ((x) << EDRAM1_ENABLE_S)
#define EDRAM1_ENABLE_F EDRAM1_ENABLE_V(1U)
#define EDRAM0_ENABLE_S 0
#define EDRAM0_ENABLE_V(x) ((x) << EDRAM0_ENABLE_S)
#define EDRAM0_ENABLE_F EDRAM0_ENABLE_V(1U)
#define EXT_MEM1_ENABLE_S 4
#define EXT_MEM1_ENABLE_V(x) ((x) << EXT_MEM1_ENABLE_S)
#define EXT_MEM1_ENABLE_F EXT_MEM1_ENABLE_V(1U)
#define EXT_MEM0_ENABLE_S 2
#define EXT_MEM0_ENABLE_V(x) ((x) << EXT_MEM0_ENABLE_S)
#define EXT_MEM0_ENABLE_F EXT_MEM0_ENABLE_V(1U)
#define MA_INT_CAUSE_A 0x77e0
#define MEM_PERR_INT_CAUSE_S 1
#define MEM_PERR_INT_CAUSE_V(x) ((x) << MEM_PERR_INT_CAUSE_S)
#define MEM_PERR_INT_CAUSE_F MEM_PERR_INT_CAUSE_V(1U)
#define MEM_WRAP_INT_CAUSE_S 0
#define MEM_WRAP_INT_CAUSE_V(x) ((x) << MEM_WRAP_INT_CAUSE_S)
#define MEM_WRAP_INT_CAUSE_F MEM_WRAP_INT_CAUSE_V(1U)
#define MA_INT_WRAP_STATUS_A 0x77e4
#define MEM_WRAP_ADDRESS_S 4
#define MEM_WRAP_ADDRESS_M 0xfffffffU
#define MEM_WRAP_ADDRESS_G(x) (((x) >> MEM_WRAP_ADDRESS_S) & MEM_WRAP_ADDRESS_M)
#define MEM_WRAP_CLIENT_NUM_S 0
#define MEM_WRAP_CLIENT_NUM_M 0xfU
#define MEM_WRAP_CLIENT_NUM_G(x) \
(((x) >> MEM_WRAP_CLIENT_NUM_S) & MEM_WRAP_CLIENT_NUM_M)
#define MA_PARITY_ERROR_STATUS_A 0x77f4
#define MA_PARITY_ERROR_STATUS1_A 0x77f4
#define MA_PARITY_ERROR_STATUS2_A 0x7804
/* registers for module EDC_0 */
#define EDC_0_BASE_ADDR 0x7900
#define EDC_BIST_CMD_A 0x7904
#define EDC_BIST_CMD_ADDR_A 0x7908
#define EDC_BIST_CMD_LEN_A 0x790c
#define EDC_BIST_DATA_PATTERN_A 0x7910
#define EDC_BIST_STATUS_RDATA_A 0x7928
#define EDC_INT_CAUSE_A 0x7978
#define ECC_UE_PAR_S 5
#define ECC_UE_PAR_V(x) ((x) << ECC_UE_PAR_S)
#define ECC_UE_PAR_F ECC_UE_PAR_V(1U)
#define ECC_CE_PAR_S 4
#define ECC_CE_PAR_V(x) ((x) << ECC_CE_PAR_S)
#define ECC_CE_PAR_F ECC_CE_PAR_V(1U)
#define PERR_PAR_CAUSE_S 3
#define PERR_PAR_CAUSE_V(x) ((x) << PERR_PAR_CAUSE_S)
#define PERR_PAR_CAUSE_F PERR_PAR_CAUSE_V(1U)
#define EDC_ECC_STATUS_A 0x797c
/* registers for module EDC_1 */
#define EDC_1_BASE_ADDR 0x7980
/* registers for module CIM */
#define CIM_BOOT_CFG_A 0x7b00
#define CIM_SDRAM_BASE_ADDR_A 0x7b14
#define CIM_SDRAM_ADDR_SIZE_A 0x7b18
#define CIM_EXTMEM2_BASE_ADDR_A 0x7b1c
#define CIM_EXTMEM2_ADDR_SIZE_A 0x7b20
#define CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A 0x290
#define BOOTADDR_M 0xffffff00U
#define UPCRST_S 0
#define UPCRST_V(x) ((x) << UPCRST_S)
#define UPCRST_F UPCRST_V(1U)
#define CIM_PF_MAILBOX_DATA_A 0x240
#define CIM_PF_MAILBOX_CTRL_A 0x280
#define MBMSGVALID_S 3
#define MBMSGVALID_V(x) ((x) << MBMSGVALID_S)
#define MBMSGVALID_F MBMSGVALID_V(1U)
#define MBINTREQ_S 2
#define MBINTREQ_V(x) ((x) << MBINTREQ_S)
#define MBINTREQ_F MBINTREQ_V(1U)
#define MBOWNER_S 0
#define MBOWNER_M 0x3U
#define MBOWNER_V(x) ((x) << MBOWNER_S)
#define MBOWNER_G(x) (((x) >> MBOWNER_S) & MBOWNER_M)
#define CIM_PF_HOST_INT_ENABLE_A 0x288
#define MBMSGRDYINTEN_S 19
#define MBMSGRDYINTEN_V(x) ((x) << MBMSGRDYINTEN_S)
#define MBMSGRDYINTEN_F MBMSGRDYINTEN_V(1U)
#define CIM_PF_HOST_INT_CAUSE_A 0x28c
#define MBMSGRDYINT_S 19
#define MBMSGRDYINT_V(x) ((x) << MBMSGRDYINT_S)
#define MBMSGRDYINT_F MBMSGRDYINT_V(1U)
#define CIM_HOST_INT_CAUSE_A 0x7b2c
#define TIEQOUTPARERRINT_S 20
#define TIEQOUTPARERRINT_V(x) ((x) << TIEQOUTPARERRINT_S)
#define TIEQOUTPARERRINT_F TIEQOUTPARERRINT_V(1U)
#define TIEQINPARERRINT_S 19
#define TIEQINPARERRINT_V(x) ((x) << TIEQINPARERRINT_S)
#define TIEQINPARERRINT_F TIEQINPARERRINT_V(1U)
#define PREFDROPINT_S 1
#define PREFDROPINT_V(x) ((x) << PREFDROPINT_S)
#define PREFDROPINT_F PREFDROPINT_V(1U)
#define UPACCNONZERO_S 0
#define UPACCNONZERO_V(x) ((x) << UPACCNONZERO_S)
#define UPACCNONZERO_F UPACCNONZERO_V(1U)
#define MBHOSTPARERR_S 18
#define MBHOSTPARERR_V(x) ((x) << MBHOSTPARERR_S)
#define MBHOSTPARERR_F MBHOSTPARERR_V(1U)
#define MBUPPARERR_S 17
#define MBUPPARERR_V(x) ((x) << MBUPPARERR_S)
#define MBUPPARERR_F MBUPPARERR_V(1U)
#define IBQTP0PARERR_S 16
#define IBQTP0PARERR_V(x) ((x) << IBQTP0PARERR_S)
#define IBQTP0PARERR_F IBQTP0PARERR_V(1U)
#define IBQTP1PARERR_S 15
#define IBQTP1PARERR_V(x) ((x) << IBQTP1PARERR_S)
#define IBQTP1PARERR_F IBQTP1PARERR_V(1U)
#define IBQULPPARERR_S 14
#define IBQULPPARERR_V(x) ((x) << IBQULPPARERR_S)
#define IBQULPPARERR_F IBQULPPARERR_V(1U)
#define IBQSGELOPARERR_S 13
#define IBQSGELOPARERR_V(x) ((x) << IBQSGELOPARERR_S)
#define IBQSGELOPARERR_F IBQSGELOPARERR_V(1U)
#define IBQSGEHIPARERR_S 12
#define IBQSGEHIPARERR_V(x) ((x) << IBQSGEHIPARERR_S)
#define IBQSGEHIPARERR_F IBQSGEHIPARERR_V(1U)
#define IBQNCSIPARERR_S 11
#define IBQNCSIPARERR_V(x) ((x) << IBQNCSIPARERR_S)
#define IBQNCSIPARERR_F IBQNCSIPARERR_V(1U)
#define OBQULP0PARERR_S 10
#define OBQULP0PARERR_V(x) ((x) << OBQULP0PARERR_S)
#define OBQULP0PARERR_F OBQULP0PARERR_V(1U)
#define OBQULP1PARERR_S 9
#define OBQULP1PARERR_V(x) ((x) << OBQULP1PARERR_S)
#define OBQULP1PARERR_F OBQULP1PARERR_V(1U)
#define OBQULP2PARERR_S 8
#define OBQULP2PARERR_V(x) ((x) << OBQULP2PARERR_S)
#define OBQULP2PARERR_F OBQULP2PARERR_V(1U)
#define OBQULP3PARERR_S 7
#define OBQULP3PARERR_V(x) ((x) << OBQULP3PARERR_S)
#define OBQULP3PARERR_F OBQULP3PARERR_V(1U)
#define OBQSGEPARERR_S 6
#define OBQSGEPARERR_V(x) ((x) << OBQSGEPARERR_S)
#define OBQSGEPARERR_F OBQSGEPARERR_V(1U)
#define OBQNCSIPARERR_S 5
#define OBQNCSIPARERR_V(x) ((x) << OBQNCSIPARERR_S)
#define OBQNCSIPARERR_F OBQNCSIPARERR_V(1U)
#define CIM_HOST_UPACC_INT_CAUSE_A 0x7b34
#define EEPROMWRINT_S 30
#define EEPROMWRINT_V(x) ((x) << EEPROMWRINT_S)
#define EEPROMWRINT_F EEPROMWRINT_V(1U)
#define TIMEOUTMAINT_S 29
#define TIMEOUTMAINT_V(x) ((x) << TIMEOUTMAINT_S)
#define TIMEOUTMAINT_F TIMEOUTMAINT_V(1U)
#define TIMEOUTINT_S 28
#define TIMEOUTINT_V(x) ((x) << TIMEOUTINT_S)
#define TIMEOUTINT_F TIMEOUTINT_V(1U)
#define RSPOVRLOOKUPINT_S 27
#define RSPOVRLOOKUPINT_V(x) ((x) << RSPOVRLOOKUPINT_S)
#define RSPOVRLOOKUPINT_F RSPOVRLOOKUPINT_V(1U)
#define REQOVRLOOKUPINT_S 26
#define REQOVRLOOKUPINT_V(x) ((x) << REQOVRLOOKUPINT_S)
#define REQOVRLOOKUPINT_F REQOVRLOOKUPINT_V(1U)
#define BLKWRPLINT_S 25
#define BLKWRPLINT_V(x) ((x) << BLKWRPLINT_S)
#define BLKWRPLINT_F BLKWRPLINT_V(1U)
#define BLKRDPLINT_S 24
#define BLKRDPLINT_V(x) ((x) << BLKRDPLINT_S)
#define BLKRDPLINT_F BLKRDPLINT_V(1U)
#define SGLWRPLINT_S 23
#define SGLWRPLINT_V(x) ((x) << SGLWRPLINT_S)
#define SGLWRPLINT_F SGLWRPLINT_V(1U)
#define SGLRDPLINT_S 22
#define SGLRDPLINT_V(x) ((x) << SGLRDPLINT_S)
#define SGLRDPLINT_F SGLRDPLINT_V(1U)
#define BLKWRCTLINT_S 21
#define BLKWRCTLINT_V(x) ((x) << BLKWRCTLINT_S)
#define BLKWRCTLINT_F BLKWRCTLINT_V(1U)
#define BLKRDCTLINT_S 20
#define BLKRDCTLINT_V(x) ((x) << BLKRDCTLINT_S)
#define BLKRDCTLINT_F BLKRDCTLINT_V(1U)
#define SGLWRCTLINT_S 19
#define SGLWRCTLINT_V(x) ((x) << SGLWRCTLINT_S)
#define SGLWRCTLINT_F SGLWRCTLINT_V(1U)
#define SGLRDCTLINT_S 18
#define SGLRDCTLINT_V(x) ((x) << SGLRDCTLINT_S)
#define SGLRDCTLINT_F SGLRDCTLINT_V(1U)
#define BLKWREEPROMINT_S 17
#define BLKWREEPROMINT_V(x) ((x) << BLKWREEPROMINT_S)
#define BLKWREEPROMINT_F BLKWREEPROMINT_V(1U)
#define BLKRDEEPROMINT_S 16
#define BLKRDEEPROMINT_V(x) ((x) << BLKRDEEPROMINT_S)
#define BLKRDEEPROMINT_F BLKRDEEPROMINT_V(1U)
#define SGLWREEPROMINT_S 15
#define SGLWREEPROMINT_V(x) ((x) << SGLWREEPROMINT_S)
#define SGLWREEPROMINT_F SGLWREEPROMINT_V(1U)
#define SGLRDEEPROMINT_S 14
#define SGLRDEEPROMINT_V(x) ((x) << SGLRDEEPROMINT_S)
#define SGLRDEEPROMINT_F SGLRDEEPROMINT_V(1U)
#define BLKWRFLASHINT_S 13
#define BLKWRFLASHINT_V(x) ((x) << BLKWRFLASHINT_S)
#define BLKWRFLASHINT_F BLKWRFLASHINT_V(1U)
#define BLKRDFLASHINT_S 12
#define BLKRDFLASHINT_V(x) ((x) << BLKRDFLASHINT_S)
#define BLKRDFLASHINT_F BLKRDFLASHINT_V(1U)
#define SGLWRFLASHINT_S 11
#define SGLWRFLASHINT_V(x) ((x) << SGLWRFLASHINT_S)
#define SGLWRFLASHINT_F SGLWRFLASHINT_V(1U)
#define SGLRDFLASHINT_S 10
#define SGLRDFLASHINT_V(x) ((x) << SGLRDFLASHINT_S)
#define SGLRDFLASHINT_F SGLRDFLASHINT_V(1U)
#define BLKWRBOOTINT_S 9
#define BLKWRBOOTINT_V(x) ((x) << BLKWRBOOTINT_S)
#define BLKWRBOOTINT_F BLKWRBOOTINT_V(1U)
#define BLKRDBOOTINT_S 8
#define BLKRDBOOTINT_V(x) ((x) << BLKRDBOOTINT_S)
#define BLKRDBOOTINT_F BLKRDBOOTINT_V(1U)
#define SGLWRBOOTINT_S 7
#define SGLWRBOOTINT_V(x) ((x) << SGLWRBOOTINT_S)
#define SGLWRBOOTINT_F SGLWRBOOTINT_V(1U)
#define SGLRDBOOTINT_S 6
#define SGLRDBOOTINT_V(x) ((x) << SGLRDBOOTINT_S)
#define SGLRDBOOTINT_F SGLRDBOOTINT_V(1U)
#define ILLWRBEINT_S 5
#define ILLWRBEINT_V(x) ((x) << ILLWRBEINT_S)
#define ILLWRBEINT_F ILLWRBEINT_V(1U)
#define ILLRDBEINT_S 4
#define ILLRDBEINT_V(x) ((x) << ILLRDBEINT_S)
#define ILLRDBEINT_F ILLRDBEINT_V(1U)
#define ILLRDINT_S 3
#define ILLRDINT_V(x) ((x) << ILLRDINT_S)
#define ILLRDINT_F ILLRDINT_V(1U)
#define ILLWRINT_S 2
#define ILLWRINT_V(x) ((x) << ILLWRINT_S)
#define ILLWRINT_F ILLWRINT_V(1U)
#define ILLTRANSINT_S 1
#define ILLTRANSINT_V(x) ((x) << ILLTRANSINT_S)
#define ILLTRANSINT_F ILLTRANSINT_V(1U)
#define RSVDSPACEINT_S 0
#define RSVDSPACEINT_V(x) ((x) << RSVDSPACEINT_S)
#define RSVDSPACEINT_F RSVDSPACEINT_V(1U)
/* registers for module TP */
#define DBGLAWHLF_S 23
#define DBGLAWHLF_V(x) ((x) << DBGLAWHLF_S)
#define DBGLAWHLF_F DBGLAWHLF_V(1U)
#define DBGLAWPTR_S 16
#define DBGLAWPTR_M 0x7fU
#define DBGLAWPTR_G(x) (((x) >> DBGLAWPTR_S) & DBGLAWPTR_M)
#define DBGLAENABLE_S 12
#define DBGLAENABLE_V(x) ((x) << DBGLAENABLE_S)
#define DBGLAENABLE_F DBGLAENABLE_V(1U)
#define DBGLARPTR_S 0
#define DBGLARPTR_M 0x7fU
#define DBGLARPTR_V(x) ((x) << DBGLARPTR_S)
#define CRXPKTENC_S 3
#define CRXPKTENC_V(x) ((x) << CRXPKTENC_S)
#define CRXPKTENC_F CRXPKTENC_V(1U)
#define TP_DBG_LA_DATAL_A 0x7ed8
#define TP_DBG_LA_CONFIG_A 0x7ed4
#define TP_OUT_CONFIG_A 0x7d04
#define TP_GLOBAL_CONFIG_A 0x7d08
#define TP_CMM_TCB_BASE_A 0x7d10
#define TP_CMM_MM_BASE_A 0x7d14
#define TP_CMM_TIMER_BASE_A 0x7d18
#define TP_PMM_TX_BASE_A 0x7d20
#define TP_PMM_RX_BASE_A 0x7d28
#define TP_PMM_RX_PAGE_SIZE_A 0x7d2c
#define TP_PMM_RX_MAX_PAGE_A 0x7d30
#define TP_PMM_TX_PAGE_SIZE_A 0x7d34
#define TP_PMM_TX_MAX_PAGE_A 0x7d38
#define TP_CMM_MM_MAX_PSTRUCT_A 0x7e6c
#define PMRXNUMCHN_S 31
#define PMRXNUMCHN_V(x) ((x) << PMRXNUMCHN_S)
#define PMRXNUMCHN_F PMRXNUMCHN_V(1U)
#define PMTXNUMCHN_S 30
#define PMTXNUMCHN_M 0x3U
#define PMTXNUMCHN_G(x) (((x) >> PMTXNUMCHN_S) & PMTXNUMCHN_M)
#define PMTXMAXPAGE_S 0
#define PMTXMAXPAGE_M 0x1fffffU
#define PMTXMAXPAGE_G(x) (((x) >> PMTXMAXPAGE_S) & PMTXMAXPAGE_M)
#define PMRXMAXPAGE_S 0
#define PMRXMAXPAGE_M 0x1fffffU
#define PMRXMAXPAGE_G(x) (((x) >> PMRXMAXPAGE_S) & PMRXMAXPAGE_M)
#define DBGLAMODE_S 14
#define DBGLAMODE_M 0x3U
#define DBGLAMODE_G(x) (((x) >> DBGLAMODE_S) & DBGLAMODE_M)
#define FIVETUPLELOOKUP_S 17
#define FIVETUPLELOOKUP_M 0x3U
#define FIVETUPLELOOKUP_V(x) ((x) << FIVETUPLELOOKUP_S)
#define FIVETUPLELOOKUP_G(x) (((x) >> FIVETUPLELOOKUP_S) & FIVETUPLELOOKUP_M)
#define TP_PARA_REG2_A 0x7d68
#define MAXRXDATA_S 16
#define MAXRXDATA_M 0xffffU
#define MAXRXDATA_G(x) (((x) >> MAXRXDATA_S) & MAXRXDATA_M)
#define TP_TIMER_RESOLUTION_A 0x7d90
#define TIMERRESOLUTION_S 16
#define TIMERRESOLUTION_M 0xffU
#define TIMERRESOLUTION_G(x) (((x) >> TIMERRESOLUTION_S) & TIMERRESOLUTION_M)
#define TIMESTAMPRESOLUTION_S 8
#define TIMESTAMPRESOLUTION_M 0xffU
#define TIMESTAMPRESOLUTION_G(x) \
(((x) >> TIMESTAMPRESOLUTION_S) & TIMESTAMPRESOLUTION_M)
#define DELAYEDACKRESOLUTION_S 0
#define DELAYEDACKRESOLUTION_M 0xffU
#define DELAYEDACKRESOLUTION_G(x) \
(((x) >> DELAYEDACKRESOLUTION_S) & DELAYEDACKRESOLUTION_M)
#define TP_SHIFT_CNT_A 0x7dc0
#define TP_RXT_MIN_A 0x7d98
#define TP_RXT_MAX_A 0x7d9c
#define TP_PERS_MIN_A 0x7da0
#define TP_PERS_MAX_A 0x7da4
#define TP_KEEP_IDLE_A 0x7da8
#define TP_KEEP_INTVL_A 0x7dac
#define TP_INIT_SRTT_A 0x7db0
#define TP_DACK_TIMER_A 0x7db4
#define TP_FINWAIT2_TIMER_A 0x7db8
#define INITSRTT_S 0
#define INITSRTT_M 0xffffU
#define INITSRTT_G(x) (((x) >> INITSRTT_S) & INITSRTT_M)
#define PERSMAX_S 0
#define PERSMAX_M 0x3fffffffU
#define PERSMAX_V(x) ((x) << PERSMAX_S)
#define PERSMAX_G(x) (((x) >> PERSMAX_S) & PERSMAX_M)
#define SYNSHIFTMAX_S 24
#define SYNSHIFTMAX_M 0xffU
#define SYNSHIFTMAX_V(x) ((x) << SYNSHIFTMAX_S)
#define SYNSHIFTMAX_G(x) (((x) >> SYNSHIFTMAX_S) & SYNSHIFTMAX_M)
#define RXTSHIFTMAXR1_S 20
#define RXTSHIFTMAXR1_M 0xfU
#define RXTSHIFTMAXR1_V(x) ((x) << RXTSHIFTMAXR1_S)
#define RXTSHIFTMAXR1_G(x) (((x) >> RXTSHIFTMAXR1_S) & RXTSHIFTMAXR1_M)
#define RXTSHIFTMAXR2_S 16
#define RXTSHIFTMAXR2_M 0xfU
#define RXTSHIFTMAXR2_V(x) ((x) << RXTSHIFTMAXR2_S)
#define RXTSHIFTMAXR2_G(x) (((x) >> RXTSHIFTMAXR2_S) & RXTSHIFTMAXR2_M)
#define PERSHIFTBACKOFFMAX_S 12
#define PERSHIFTBACKOFFMAX_M 0xfU
#define PERSHIFTBACKOFFMAX_V(x) ((x) << PERSHIFTBACKOFFMAX_S)
#define PERSHIFTBACKOFFMAX_G(x) \
(((x) >> PERSHIFTBACKOFFMAX_S) & PERSHIFTBACKOFFMAX_M)
#define PERSHIFTMAX_S 8
#define PERSHIFTMAX_M 0xfU
#define PERSHIFTMAX_V(x) ((x) << PERSHIFTMAX_S)
#define PERSHIFTMAX_G(x) (((x) >> PERSHIFTMAX_S) & PERSHIFTMAX_M)
#define KEEPALIVEMAXR1_S 4
#define KEEPALIVEMAXR1_M 0xfU
#define KEEPALIVEMAXR1_V(x) ((x) << KEEPALIVEMAXR1_S)
#define KEEPALIVEMAXR1_G(x) (((x) >> KEEPALIVEMAXR1_S) & KEEPALIVEMAXR1_M)
#define KEEPALIVEMAXR2_S 0
#define KEEPALIVEMAXR2_M 0xfU
#define KEEPALIVEMAXR2_V(x) ((x) << KEEPALIVEMAXR2_S)
#define KEEPALIVEMAXR2_G(x) (((x) >> KEEPALIVEMAXR2_S) & KEEPALIVEMAXR2_M)
#define ROWINDEX_S 16
#define ROWINDEX_V(x) ((x) << ROWINDEX_S)
#define TP_CCTRL_TABLE_A 0x7ddc
#define TP_MTU_TABLE_A 0x7de4
#define MTUINDEX_S 24
#define MTUINDEX_V(x) ((x) << MTUINDEX_S)
#define MTUWIDTH_S 16
#define MTUWIDTH_M 0xfU
#define MTUWIDTH_V(x) ((x) << MTUWIDTH_S)
#define MTUWIDTH_G(x) (((x) >> MTUWIDTH_S) & MTUWIDTH_M)
#define MTUVALUE_S 0
#define MTUVALUE_M 0x3fffU
#define MTUVALUE_V(x) ((x) << MTUVALUE_S)
#define MTUVALUE_G(x) (((x) >> MTUVALUE_S) & MTUVALUE_M)
#define TP_RSS_LKP_TABLE_A 0x7dec
#define TP_CMM_MM_RX_FLST_BASE_A 0x7e60
#define TP_CMM_MM_TX_FLST_BASE_A 0x7e64
#define TP_CMM_MM_PS_FLST_BASE_A 0x7e68
#define LKPTBLROWVLD_S 31
#define LKPTBLROWVLD_V(x) ((x) << LKPTBLROWVLD_S)
#define LKPTBLROWVLD_F LKPTBLROWVLD_V(1U)
#define LKPTBLQUEUE1_S 10
#define LKPTBLQUEUE1_M 0x3ffU
#define LKPTBLQUEUE1_G(x) (((x) >> LKPTBLQUEUE1_S) & LKPTBLQUEUE1_M)
#define LKPTBLQUEUE0_S 0
#define LKPTBLQUEUE0_M 0x3ffU
#define LKPTBLQUEUE0_G(x) (((x) >> LKPTBLQUEUE0_S) & LKPTBLQUEUE0_M)
#define TP_PIO_ADDR_A 0x7e40
#define TP_PIO_DATA_A 0x7e44
#define TP_MIB_INDEX_A 0x7e50
#define TP_MIB_DATA_A 0x7e54
#define TP_INT_CAUSE_A 0x7e74
#define FLMTXFLSTEMPTY_S 30
#define FLMTXFLSTEMPTY_V(x) ((x) << FLMTXFLSTEMPTY_S)
#define FLMTXFLSTEMPTY_F FLMTXFLSTEMPTY_V(1U)
#define TP_TX_ORATE_A 0x7ebc
#define OFDRATE3_S 24
#define OFDRATE3_M 0xffU
#define OFDRATE3_G(x) (((x) >> OFDRATE3_S) & OFDRATE3_M)
#define OFDRATE2_S 16
#define OFDRATE2_M 0xffU
#define OFDRATE2_G(x) (((x) >> OFDRATE2_S) & OFDRATE2_M)
#define OFDRATE1_S 8
#define OFDRATE1_M 0xffU
#define OFDRATE1_G(x) (((x) >> OFDRATE1_S) & OFDRATE1_M)
#define OFDRATE0_S 0
#define OFDRATE0_M 0xffU
#define OFDRATE0_G(x) (((x) >> OFDRATE0_S) & OFDRATE0_M)
#define TP_TX_TRATE_A 0x7ed0
#define TNLRATE3_S 24
#define TNLRATE3_M 0xffU
#define TNLRATE3_G(x) (((x) >> TNLRATE3_S) & TNLRATE3_M)
#define TNLRATE2_S 16
#define TNLRATE2_M 0xffU
#define TNLRATE2_G(x) (((x) >> TNLRATE2_S) & TNLRATE2_M)
#define TNLRATE1_S 8
#define TNLRATE1_M 0xffU
#define TNLRATE1_G(x) (((x) >> TNLRATE1_S) & TNLRATE1_M)
#define TNLRATE0_S 0
#define TNLRATE0_M 0xffU
#define TNLRATE0_G(x) (((x) >> TNLRATE0_S) & TNLRATE0_M)
#define TP_VLAN_PRI_MAP_A 0x140
#define FRAGMENTATION_S 9
#define FRAGMENTATION_V(x) ((x) << FRAGMENTATION_S)
#define FRAGMENTATION_F FRAGMENTATION_V(1U)
#define MPSHITTYPE_S 8
#define MPSHITTYPE_V(x) ((x) << MPSHITTYPE_S)
#define MPSHITTYPE_F MPSHITTYPE_V(1U)
#define MACMATCH_S 7
#define MACMATCH_V(x) ((x) << MACMATCH_S)
#define MACMATCH_F MACMATCH_V(1U)
#define ETHERTYPE_S 6
#define ETHERTYPE_V(x) ((x) << ETHERTYPE_S)
#define ETHERTYPE_F ETHERTYPE_V(1U)
#define PROTOCOL_S 5
#define PROTOCOL_V(x) ((x) << PROTOCOL_S)
#define PROTOCOL_F PROTOCOL_V(1U)
#define TOS_S 4
#define TOS_V(x) ((x) << TOS_S)
#define TOS_F TOS_V(1U)
#define VLAN_S 3
#define VLAN_V(x) ((x) << VLAN_S)
#define VLAN_F VLAN_V(1U)
#define VNIC_ID_S 2
#define VNIC_ID_V(x) ((x) << VNIC_ID_S)
#define VNIC_ID_F VNIC_ID_V(1U)
#define PORT_S 1
#define PORT_V(x) ((x) << PORT_S)
#define PORT_F PORT_V(1U)
#define FCOE_S 0
#define FCOE_V(x) ((x) << FCOE_S)
#define FCOE_F FCOE_V(1U)
#define FILTERMODE_S 15
#define FILTERMODE_V(x) ((x) << FILTERMODE_S)
#define FILTERMODE_F FILTERMODE_V(1U)
#define FCOEMASK_S 14
#define FCOEMASK_V(x) ((x) << FCOEMASK_S)
#define FCOEMASK_F FCOEMASK_V(1U)
#define TP_INGRESS_CONFIG_A 0x141
#define VNIC_S 11
#define VNIC_V(x) ((x) << VNIC_S)
#define VNIC_F VNIC_V(1U)
#define CSUM_HAS_PSEUDO_HDR_S 10
#define CSUM_HAS_PSEUDO_HDR_V(x) ((x) << CSUM_HAS_PSEUDO_HDR_S)
#define CSUM_HAS_PSEUDO_HDR_F CSUM_HAS_PSEUDO_HDR_V(1U)
#define TP_MIB_MAC_IN_ERR_0_A 0x0
#define TP_MIB_HDR_IN_ERR_0_A 0x4
#define TP_MIB_TCP_IN_ERR_0_A 0x8
#define TP_MIB_TCP_OUT_RST_A 0xc
#define TP_MIB_TCP_IN_SEG_HI_A 0x10
#define TP_MIB_TCP_IN_SEG_LO_A 0x11
#define TP_MIB_TCP_OUT_SEG_HI_A 0x12
#define TP_MIB_TCP_OUT_SEG_LO_A 0x13
#define TP_MIB_TCP_RXT_SEG_HI_A 0x14
#define TP_MIB_TCP_RXT_SEG_LO_A 0x15
#define TP_MIB_TNL_CNG_DROP_0_A 0x18
#define TP_MIB_OFD_CHN_DROP_0_A 0x1c
#define TP_MIB_TCP_V6IN_ERR_0_A 0x28
#define TP_MIB_TCP_V6OUT_RST_A 0x2c
#define TP_MIB_OFD_ARP_DROP_A 0x36
#define TP_MIB_CPL_IN_REQ_0_A 0x38
#define TP_MIB_CPL_OUT_RSP_0_A 0x3c
#define TP_MIB_TNL_DROP_0_A 0x44
#define TP_MIB_FCOE_DDP_0_A 0x48
#define TP_MIB_FCOE_DROP_0_A 0x4c
#define TP_MIB_FCOE_BYTE_0_HI_A 0x50
#define TP_MIB_OFD_VLN_DROP_0_A 0x58
#define TP_MIB_USM_PKTS_A 0x5c
#define TP_MIB_RQE_DFR_PKT_A 0x64
#define ULP_TX_INT_CAUSE_A 0x8dcc
#define ULP_TX_TPT_LLIMIT_A 0x8dd4
#define ULP_TX_TPT_ULIMIT_A 0x8dd8
#define ULP_TX_PBL_LLIMIT_A 0x8ddc
#define ULP_TX_PBL_ULIMIT_A 0x8de0
#define ULP_TX_ERR_TABLE_BASE_A 0x8e04
#define PBL_BOUND_ERR_CH3_S 31
#define PBL_BOUND_ERR_CH3_V(x) ((x) << PBL_BOUND_ERR_CH3_S)
#define PBL_BOUND_ERR_CH3_F PBL_BOUND_ERR_CH3_V(1U)
#define PBL_BOUND_ERR_CH2_S 30
#define PBL_BOUND_ERR_CH2_V(x) ((x) << PBL_BOUND_ERR_CH2_S)
#define PBL_BOUND_ERR_CH2_F PBL_BOUND_ERR_CH2_V(1U)
#define PBL_BOUND_ERR_CH1_S 29
#define PBL_BOUND_ERR_CH1_V(x) ((x) << PBL_BOUND_ERR_CH1_S)
#define PBL_BOUND_ERR_CH1_F PBL_BOUND_ERR_CH1_V(1U)
#define PBL_BOUND_ERR_CH0_S 28
#define PBL_BOUND_ERR_CH0_V(x) ((x) << PBL_BOUND_ERR_CH0_S)
#define PBL_BOUND_ERR_CH0_F PBL_BOUND_ERR_CH0_V(1U)
#define PM_RX_INT_CAUSE_A 0x8fdc
#define PM_RX_STAT_CONFIG_A 0x8fc8
#define PM_RX_STAT_COUNT_A 0x8fcc
#define PM_RX_STAT_LSB_A 0x8fd0
#define PM_RX_DBG_CTRL_A 0x8fd0
#define PM_RX_DBG_DATA_A 0x8fd4
#define PM_RX_DBG_STAT_MSB_A 0x10013
#define PMRX_FRAMING_ERROR_F 0x003ffff0U
#define ZERO_E_CMD_ERROR_S 22
#define ZERO_E_CMD_ERROR_V(x) ((x) << ZERO_E_CMD_ERROR_S)
#define ZERO_E_CMD_ERROR_F ZERO_E_CMD_ERROR_V(1U)
#define OCSPI_PAR_ERROR_S 3
#define OCSPI_PAR_ERROR_V(x) ((x) << OCSPI_PAR_ERROR_S)
#define OCSPI_PAR_ERROR_F OCSPI_PAR_ERROR_V(1U)
#define DB_OPTIONS_PAR_ERROR_S 2
#define DB_OPTIONS_PAR_ERROR_V(x) ((x) << DB_OPTIONS_PAR_ERROR_S)
#define DB_OPTIONS_PAR_ERROR_F DB_OPTIONS_PAR_ERROR_V(1U)
#define IESPI_PAR_ERROR_S 1
#define IESPI_PAR_ERROR_V(x) ((x) << IESPI_PAR_ERROR_S)
#define IESPI_PAR_ERROR_F IESPI_PAR_ERROR_V(1U)
#define PMRX_E_PCMD_PAR_ERROR_S 0
#define PMRX_E_PCMD_PAR_ERROR_V(x) ((x) << PMRX_E_PCMD_PAR_ERROR_S)
#define PMRX_E_PCMD_PAR_ERROR_F PMRX_E_PCMD_PAR_ERROR_V(1U)
#define PM_TX_INT_CAUSE_A 0x8ffc
#define PM_TX_STAT_CONFIG_A 0x8fe8
#define PM_TX_STAT_COUNT_A 0x8fec
#define PM_TX_STAT_LSB_A 0x8ff0
#define PM_TX_DBG_CTRL_A 0x8ff0
#define PM_TX_DBG_DATA_A 0x8ff4
#define PM_TX_DBG_STAT_MSB_A 0x1001a
#define PCMD_LEN_OVFL0_S 31
#define PCMD_LEN_OVFL0_V(x) ((x) << PCMD_LEN_OVFL0_S)
#define PCMD_LEN_OVFL0_F PCMD_LEN_OVFL0_V(1U)
#define PCMD_LEN_OVFL1_S 30
#define PCMD_LEN_OVFL1_V(x) ((x) << PCMD_LEN_OVFL1_S)
#define PCMD_LEN_OVFL1_F PCMD_LEN_OVFL1_V(1U)
#define PCMD_LEN_OVFL2_S 29
#define PCMD_LEN_OVFL2_V(x) ((x) << PCMD_LEN_OVFL2_S)
#define PCMD_LEN_OVFL2_F PCMD_LEN_OVFL2_V(1U)
#define ZERO_C_CMD_ERROR_S 28
#define ZERO_C_CMD_ERROR_V(x) ((x) << ZERO_C_CMD_ERROR_S)
#define ZERO_C_CMD_ERROR_F ZERO_C_CMD_ERROR_V(1U)
#define PMTX_FRAMING_ERROR_F 0x0ffffff0U
#define OESPI_PAR_ERROR_S 3
#define OESPI_PAR_ERROR_V(x) ((x) << OESPI_PAR_ERROR_S)
#define OESPI_PAR_ERROR_F OESPI_PAR_ERROR_V(1U)
#define ICSPI_PAR_ERROR_S 1
#define ICSPI_PAR_ERROR_V(x) ((x) << ICSPI_PAR_ERROR_S)
#define ICSPI_PAR_ERROR_F ICSPI_PAR_ERROR_V(1U)
#define PMTX_C_PCMD_PAR_ERROR_S 0
#define PMTX_C_PCMD_PAR_ERROR_V(x) ((x) << PMTX_C_PCMD_PAR_ERROR_S)
#define PMTX_C_PCMD_PAR_ERROR_F PMTX_C_PCMD_PAR_ERROR_V(1U)
#define MPS_PORT_STAT_TX_PORT_BYTES_L 0x400
#define MPS_PORT_STAT_TX_PORT_BYTES_H 0x404
#define MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408
#define MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c
#define MPS_PORT_STAT_TX_PORT_BCAST_L 0x410
#define MPS_PORT_STAT_TX_PORT_BCAST_H 0x414
#define MPS_PORT_STAT_TX_PORT_MCAST_L 0x418
#define MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c
#define MPS_PORT_STAT_TX_PORT_UCAST_L 0x420
#define MPS_PORT_STAT_TX_PORT_UCAST_H 0x424
#define MPS_PORT_STAT_TX_PORT_ERROR_L 0x428
#define MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c
#define MPS_PORT_STAT_TX_PORT_64B_L 0x430
#define MPS_PORT_STAT_TX_PORT_64B_H 0x434
#define MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438
#define MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c
#define MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440
#define MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444
#define MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448
#define MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c
#define MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450
#define MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454
#define MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458
#define MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c
#define MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460
#define MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464
#define MPS_PORT_STAT_TX_PORT_DROP_L 0x468
#define MPS_PORT_STAT_TX_PORT_DROP_H 0x46c
#define MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470
#define MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474
#define MPS_PORT_STAT_TX_PORT_PPP0_L 0x478
#define MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c
#define MPS_PORT_STAT_TX_PORT_PPP1_L 0x480
#define MPS_PORT_STAT_TX_PORT_PPP1_H 0x484
#define MPS_PORT_STAT_TX_PORT_PPP2_L 0x488
#define MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c
#define MPS_PORT_STAT_TX_PORT_PPP3_L 0x490
#define MPS_PORT_STAT_TX_PORT_PPP3_H 0x494
#define MPS_PORT_STAT_TX_PORT_PPP4_L 0x498
#define MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c
#define MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0
#define MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4
#define MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8
#define MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac
#define MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0
#define MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4
#define MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0
#define MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4
#define MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8
#define MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc
#define MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0
#define MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4
#define MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8
#define MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc
#define MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0
#define MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4
#define MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8
#define MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec
#define MPS_PORT_STAT_LB_PORT_64B_L 0x4f0
#define MPS_PORT_STAT_LB_PORT_64B_H 0x4f4
#define MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8
#define MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc
#define MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500
#define MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504
#define MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508
#define MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c
#define MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510
#define MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514
#define MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518
#define MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c
#define MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520
#define MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524
#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528
#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES_L 0x528
#define MPS_PORT_STAT_RX_PORT_BYTES_L 0x540
#define MPS_PORT_STAT_RX_PORT_BYTES_H 0x544
#define MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548
#define MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c
#define MPS_PORT_STAT_RX_PORT_BCAST_L 0x550
#define MPS_PORT_STAT_RX_PORT_BCAST_H 0x554
#define MPS_PORT_STAT_RX_PORT_MCAST_L 0x558
#define MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c
#define MPS_PORT_STAT_RX_PORT_UCAST_L 0x560
#define MPS_PORT_STAT_RX_PORT_UCAST_H 0x564
#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568
#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c
#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570
#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574
#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578
#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c
#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580
#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584
#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588
#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c
#define MPS_PORT_STAT_RX_PORT_64B_L 0x590
#define MPS_PORT_STAT_RX_PORT_64B_H 0x594
#define MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598
#define MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c
#define MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0
#define MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4
#define MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8
#define MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac
#define MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0
#define MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4
#define MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8
#define MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc
#define MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0
#define MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4
#define MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8
#define MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc
#define MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0
#define MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4
#define MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8
#define MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc
#define MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0
#define MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4
#define MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8
#define MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec
#define MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0
#define MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4
#define MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8
#define MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc
#define MPS_PORT_STAT_RX_PORT_PPP6_L 0x600
#define MPS_PORT_STAT_RX_PORT_PPP6_H 0x604
#define MPS_PORT_STAT_RX_PORT_PPP7_L 0x608
#define MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c
#define MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610
#define MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614
#define MAC_PORT_MAGIC_MACID_LO 0x824
#define MAC_PORT_MAGIC_MACID_HI 0x828
#define MAC_PORT_EPIO_DATA0_A 0x8c0
#define MAC_PORT_EPIO_DATA1_A 0x8c4
#define MAC_PORT_EPIO_DATA2_A 0x8c8
#define MAC_PORT_EPIO_DATA3_A 0x8cc
#define MAC_PORT_EPIO_OP_A 0x8d0
#define MAC_PORT_CFG2_A 0x818
#define MPS_CMN_CTL_A 0x9000
#define COUNTPAUSEMCRX_S 5
#define COUNTPAUSEMCRX_V(x) ((x) << COUNTPAUSEMCRX_S)
#define COUNTPAUSEMCRX_F COUNTPAUSEMCRX_V(1U)
#define COUNTPAUSESTATRX_S 4
#define COUNTPAUSESTATRX_V(x) ((x) << COUNTPAUSESTATRX_S)
#define COUNTPAUSESTATRX_F COUNTPAUSESTATRX_V(1U)
#define COUNTPAUSEMCTX_S 3
#define COUNTPAUSEMCTX_V(x) ((x) << COUNTPAUSEMCTX_S)
#define COUNTPAUSEMCTX_F COUNTPAUSEMCTX_V(1U)
#define COUNTPAUSESTATTX_S 2
#define COUNTPAUSESTATTX_V(x) ((x) << COUNTPAUSESTATTX_S)
#define COUNTPAUSESTATTX_F COUNTPAUSESTATTX_V(1U)
#define NUMPORTS_S 0
#define NUMPORTS_M 0x3U
#define NUMPORTS_G(x) (((x) >> NUMPORTS_S) & NUMPORTS_M)
#define MPS_INT_CAUSE_A 0x9008
#define MPS_TX_INT_CAUSE_A 0x9408
#define MPS_STAT_CTL_A 0x9600
#define FRMERR_S 15
#define FRMERR_V(x) ((x) << FRMERR_S)
#define FRMERR_F FRMERR_V(1U)
#define SECNTERR_S 14
#define SECNTERR_V(x) ((x) << SECNTERR_S)
#define SECNTERR_F SECNTERR_V(1U)
#define BUBBLE_S 13
#define BUBBLE_V(x) ((x) << BUBBLE_S)
#define BUBBLE_F BUBBLE_V(1U)
#define TXDESCFIFO_S 9
#define TXDESCFIFO_M 0xfU
#define TXDESCFIFO_V(x) ((x) << TXDESCFIFO_S)
#define TXDATAFIFO_S 5
#define TXDATAFIFO_M 0xfU
#define TXDATAFIFO_V(x) ((x) << TXDATAFIFO_S)
#define NCSIFIFO_S 4
#define NCSIFIFO_V(x) ((x) << NCSIFIFO_S)
#define NCSIFIFO_F NCSIFIFO_V(1U)
#define TPFIFO_S 0
#define TPFIFO_M 0xfU
#define TPFIFO_V(x) ((x) << TPFIFO_S)
#define MPS_STAT_PERR_INT_CAUSE_SRAM_A 0x9614
#define MPS_STAT_PERR_INT_CAUSE_TX_FIFO_A 0x9620
#define MPS_STAT_PERR_INT_CAUSE_RX_FIFO_A 0x962c
#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640
#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644
#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648
#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c
#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650
#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654
#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658
#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c
#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660
#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664
#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668
#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c
#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670
#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674
#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678
#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c
#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680
#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684
#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688
#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c
#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690
#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694
#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698
#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c
#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0
#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4
#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8
#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac
#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0
#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4
#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8
#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc
#define MPS_TRC_CFG_A 0x9800
#define TRCFIFOEMPTY_S 4
#define TRCFIFOEMPTY_V(x) ((x) << TRCFIFOEMPTY_S)
#define TRCFIFOEMPTY_F TRCFIFOEMPTY_V(1U)
#define TRCIGNOREDROPINPUT_S 3
#define TRCIGNOREDROPINPUT_V(x) ((x) << TRCIGNOREDROPINPUT_S)
#define TRCIGNOREDROPINPUT_F TRCIGNOREDROPINPUT_V(1U)
#define TRCKEEPDUPLICATES_S 2
#define TRCKEEPDUPLICATES_V(x) ((x) << TRCKEEPDUPLICATES_S)
#define TRCKEEPDUPLICATES_F TRCKEEPDUPLICATES_V(1U)
#define TRCEN_S 1
#define TRCEN_V(x) ((x) << TRCEN_S)
#define TRCEN_F TRCEN_V(1U)
#define TRCMULTIFILTER_S 0
#define TRCMULTIFILTER_V(x) ((x) << TRCMULTIFILTER_S)
#define TRCMULTIFILTER_F TRCMULTIFILTER_V(1U)
#define MPS_TRC_RSS_CONTROL_A 0x9808
#define MPS_TRC_FILTER1_RSS_CONTROL_A 0x9ff4
#define MPS_TRC_FILTER2_RSS_CONTROL_A 0x9ffc
#define MPS_TRC_FILTER3_RSS_CONTROL_A 0xa004
#define MPS_T5_TRC_RSS_CONTROL_A 0xa00c
#define RSSCONTROL_S 16
#define RSSCONTROL_V(x) ((x) << RSSCONTROL_S)
#define QUEUENUMBER_S 0
#define QUEUENUMBER_V(x) ((x) << QUEUENUMBER_S)
#define TFINVERTMATCH_S 24
#define TFINVERTMATCH_V(x) ((x) << TFINVERTMATCH_S)
#define TFINVERTMATCH_F TFINVERTMATCH_V(1U)
#define TFEN_S 22
#define TFEN_V(x) ((x) << TFEN_S)
#define TFEN_F TFEN_V(1U)
#define TFPORT_S 18
#define TFPORT_M 0xfU
#define TFPORT_V(x) ((x) << TFPORT_S)
#define TFPORT_G(x) (((x) >> TFPORT_S) & TFPORT_M)
#define TFLENGTH_S 8
#define TFLENGTH_M 0x1fU
#define TFLENGTH_V(x) ((x) << TFLENGTH_S)
#define TFLENGTH_G(x) (((x) >> TFLENGTH_S) & TFLENGTH_M)
#define TFOFFSET_S 0
#define TFOFFSET_M 0x1fU
#define TFOFFSET_V(x) ((x) << TFOFFSET_S)
#define TFOFFSET_G(x) (((x) >> TFOFFSET_S) & TFOFFSET_M)
#define T5_TFINVERTMATCH_S 25
#define T5_TFINVERTMATCH_V(x) ((x) << T5_TFINVERTMATCH_S)
#define T5_TFINVERTMATCH_F T5_TFINVERTMATCH_V(1U)
#define T5_TFEN_S 23
#define T5_TFEN_V(x) ((x) << T5_TFEN_S)
#define T5_TFEN_F T5_TFEN_V(1U)
#define T5_TFPORT_S 18
#define T5_TFPORT_M 0x1fU
#define T5_TFPORT_V(x) ((x) << T5_TFPORT_S)
#define T5_TFPORT_G(x) (((x) >> T5_TFPORT_S) & T5_TFPORT_M)
#define MPS_TRC_FILTER_MATCH_CTL_A_A 0x9810
#define MPS_TRC_FILTER_MATCH_CTL_B_A 0x9820
#define TFMINPKTSIZE_S 16
#define TFMINPKTSIZE_M 0x1ffU
#define TFMINPKTSIZE_V(x) ((x) << TFMINPKTSIZE_S)
#define TFMINPKTSIZE_G(x) (((x) >> TFMINPKTSIZE_S) & TFMINPKTSIZE_M)
#define TFCAPTUREMAX_S 0
#define TFCAPTUREMAX_M 0x3fffU
#define TFCAPTUREMAX_V(x) ((x) << TFCAPTUREMAX_S)
#define TFCAPTUREMAX_G(x) (((x) >> TFCAPTUREMAX_S) & TFCAPTUREMAX_M)
#define MPS_TRC_FILTER0_MATCH_A 0x9c00
#define MPS_TRC_FILTER0_DONT_CARE_A 0x9c80
#define MPS_TRC_FILTER1_MATCH_A 0x9d00
#define TP_RSS_CONFIG_A 0x7df0
#define TNL4TUPENIPV6_S 31
#define TNL4TUPENIPV6_V(x) ((x) << TNL4TUPENIPV6_S)
#define TNL4TUPENIPV6_F TNL4TUPENIPV6_V(1U)
#define TNL2TUPENIPV6_S 30
#define TNL2TUPENIPV6_V(x) ((x) << TNL2TUPENIPV6_S)
#define TNL2TUPENIPV6_F TNL2TUPENIPV6_V(1U)
#define TNL4TUPENIPV4_S 29
#define TNL4TUPENIPV4_V(x) ((x) << TNL4TUPENIPV4_S)
#define TNL4TUPENIPV4_F TNL4TUPENIPV4_V(1U)
#define TNL2TUPENIPV4_S 28
#define TNL2TUPENIPV4_V(x) ((x) << TNL2TUPENIPV4_S)
#define TNL2TUPENIPV4_F TNL2TUPENIPV4_V(1U)
#define TNLTCPSEL_S 27
#define TNLTCPSEL_V(x) ((x) << TNLTCPSEL_S)
#define TNLTCPSEL_F TNLTCPSEL_V(1U)
#define TNLIP6SEL_S 26
#define TNLIP6SEL_V(x) ((x) << TNLIP6SEL_S)
#define TNLIP6SEL_F TNLIP6SEL_V(1U)
#define TNLVRTSEL_S 25
#define TNLVRTSEL_V(x) ((x) << TNLVRTSEL_S)
#define TNLVRTSEL_F TNLVRTSEL_V(1U)
#define TNLMAPEN_S 24
#define TNLMAPEN_V(x) ((x) << TNLMAPEN_S)
#define TNLMAPEN_F TNLMAPEN_V(1U)
#define OFDHASHSAVE_S 19
#define OFDHASHSAVE_V(x) ((x) << OFDHASHSAVE_S)
#define OFDHASHSAVE_F OFDHASHSAVE_V(1U)
#define OFDVRTSEL_S 18
#define OFDVRTSEL_V(x) ((x) << OFDVRTSEL_S)
#define OFDVRTSEL_F OFDVRTSEL_V(1U)
#define OFDMAPEN_S 17
#define OFDMAPEN_V(x) ((x) << OFDMAPEN_S)
#define OFDMAPEN_F OFDMAPEN_V(1U)
#define OFDLKPEN_S 16
#define OFDLKPEN_V(x) ((x) << OFDLKPEN_S)
#define OFDLKPEN_F OFDLKPEN_V(1U)
#define SYN4TUPENIPV6_S 15
#define SYN4TUPENIPV6_V(x) ((x) << SYN4TUPENIPV6_S)
#define SYN4TUPENIPV6_F SYN4TUPENIPV6_V(1U)
#define SYN2TUPENIPV6_S 14
#define SYN2TUPENIPV6_V(x) ((x) << SYN2TUPENIPV6_S)
#define SYN2TUPENIPV6_F SYN2TUPENIPV6_V(1U)
#define SYN4TUPENIPV4_S 13
#define SYN4TUPENIPV4_V(x) ((x) << SYN4TUPENIPV4_S)
#define SYN4TUPENIPV4_F SYN4TUPENIPV4_V(1U)
#define SYN2TUPENIPV4_S 12
#define SYN2TUPENIPV4_V(x) ((x) << SYN2TUPENIPV4_S)
#define SYN2TUPENIPV4_F SYN2TUPENIPV4_V(1U)
#define SYNIP6SEL_S 11
#define SYNIP6SEL_V(x) ((x) << SYNIP6SEL_S)
#define SYNIP6SEL_F SYNIP6SEL_V(1U)
#define SYNVRTSEL_S 10
#define SYNVRTSEL_V(x) ((x) << SYNVRTSEL_S)
#define SYNVRTSEL_F SYNVRTSEL_V(1U)
#define SYNMAPEN_S 9
#define SYNMAPEN_V(x) ((x) << SYNMAPEN_S)
#define SYNMAPEN_F SYNMAPEN_V(1U)
#define SYNLKPEN_S 8
#define SYNLKPEN_V(x) ((x) << SYNLKPEN_S)
#define SYNLKPEN_F SYNLKPEN_V(1U)
#define CHANNELENABLE_S 7
#define CHANNELENABLE_V(x) ((x) << CHANNELENABLE_S)
#define CHANNELENABLE_F CHANNELENABLE_V(1U)
#define PORTENABLE_S 6
#define PORTENABLE_V(x) ((x) << PORTENABLE_S)
#define PORTENABLE_F PORTENABLE_V(1U)
#define TNLALLLOOKUP_S 5
#define TNLALLLOOKUP_V(x) ((x) << TNLALLLOOKUP_S)
#define TNLALLLOOKUP_F TNLALLLOOKUP_V(1U)
#define VIRTENABLE_S 4
#define VIRTENABLE_V(x) ((x) << VIRTENABLE_S)
#define VIRTENABLE_F VIRTENABLE_V(1U)
#define CONGESTIONENABLE_S 3
#define CONGESTIONENABLE_V(x) ((x) << CONGESTIONENABLE_S)
#define CONGESTIONENABLE_F CONGESTIONENABLE_V(1U)
#define HASHTOEPLITZ_S 2
#define HASHTOEPLITZ_V(x) ((x) << HASHTOEPLITZ_S)
#define HASHTOEPLITZ_F HASHTOEPLITZ_V(1U)
#define UDPENABLE_S 1
#define UDPENABLE_V(x) ((x) << UDPENABLE_S)
#define UDPENABLE_F UDPENABLE_V(1U)
#define DISABLE_S 0
#define DISABLE_V(x) ((x) << DISABLE_S)
#define DISABLE_F DISABLE_V(1U)
#define TP_RSS_CONFIG_TNL_A 0x7df4
#define MASKSIZE_S 28
#define MASKSIZE_M 0xfU
#define MASKSIZE_V(x) ((x) << MASKSIZE_S)
#define MASKSIZE_G(x) (((x) >> MASKSIZE_S) & MASKSIZE_M)
#define MASKFILTER_S 16
#define MASKFILTER_M 0x7ffU
#define MASKFILTER_V(x) ((x) << MASKFILTER_S)
#define MASKFILTER_G(x) (((x) >> MASKFILTER_S) & MASKFILTER_M)
#define USEWIRECH_S 0
#define USEWIRECH_V(x) ((x) << USEWIRECH_S)
#define USEWIRECH_F USEWIRECH_V(1U)
#define HASHALL_S 2
#define HASHALL_V(x) ((x) << HASHALL_S)
#define HASHALL_F HASHALL_V(1U)
#define HASHETH_S 1
#define HASHETH_V(x) ((x) << HASHETH_S)
#define HASHETH_F HASHETH_V(1U)
#define TP_RSS_CONFIG_OFD_A 0x7df8
#define RRCPLMAPEN_S 20
#define RRCPLMAPEN_V(x) ((x) << RRCPLMAPEN_S)
#define RRCPLMAPEN_F RRCPLMAPEN_V(1U)
#define RRCPLQUEWIDTH_S 16
#define RRCPLQUEWIDTH_M 0xfU
#define RRCPLQUEWIDTH_V(x) ((x) << RRCPLQUEWIDTH_S)
#define RRCPLQUEWIDTH_G(x) (((x) >> RRCPLQUEWIDTH_S) & RRCPLQUEWIDTH_M)
#define TP_RSS_CONFIG_SYN_A 0x7dfc
#define TP_RSS_CONFIG_VRT_A 0x7e00
#define VFRDRG_S 25
#define VFRDRG_V(x) ((x) << VFRDRG_S)
#define VFRDRG_F VFRDRG_V(1U)
#define VFRDEN_S 24
#define VFRDEN_V(x) ((x) << VFRDEN_S)
#define VFRDEN_F VFRDEN_V(1U)
#define VFPERREN_S 23
#define VFPERREN_V(x) ((x) << VFPERREN_S)
#define VFPERREN_F VFPERREN_V(1U)
#define KEYPERREN_S 22
#define KEYPERREN_V(x) ((x) << KEYPERREN_S)
#define KEYPERREN_F KEYPERREN_V(1U)
#define DISABLEVLAN_S 21
#define DISABLEVLAN_V(x) ((x) << DISABLEVLAN_S)
#define DISABLEVLAN_F DISABLEVLAN_V(1U)
#define ENABLEUP0_S 20
#define ENABLEUP0_V(x) ((x) << ENABLEUP0_S)
#define ENABLEUP0_F ENABLEUP0_V(1U)
#define HASHDELAY_S 16
#define HASHDELAY_M 0xfU
#define HASHDELAY_V(x) ((x) << HASHDELAY_S)
#define HASHDELAY_G(x) (((x) >> HASHDELAY_S) & HASHDELAY_M)
#define VFWRADDR_S 8
#define VFWRADDR_M 0x7fU
#define VFWRADDR_V(x) ((x) << VFWRADDR_S)
#define VFWRADDR_G(x) (((x) >> VFWRADDR_S) & VFWRADDR_M)
#define KEYMODE_S 6
#define KEYMODE_M 0x3U
#define KEYMODE_V(x) ((x) << KEYMODE_S)
#define KEYMODE_G(x) (((x) >> KEYMODE_S) & KEYMODE_M)
#define VFWREN_S 5
#define VFWREN_V(x) ((x) << VFWREN_S)
#define VFWREN_F VFWREN_V(1U)
#define KEYWREN_S 4
#define KEYWREN_V(x) ((x) << KEYWREN_S)
#define KEYWREN_F KEYWREN_V(1U)
#define KEYWRADDR_S 0
#define KEYWRADDR_M 0xfU
#define KEYWRADDR_V(x) ((x) << KEYWRADDR_S)
#define KEYWRADDR_G(x) (((x) >> KEYWRADDR_S) & KEYWRADDR_M)
#define KEYWRADDRX_S 30
#define KEYWRADDRX_M 0x3U
#define KEYWRADDRX_V(x) ((x) << KEYWRADDRX_S)
#define KEYWRADDRX_G(x) (((x) >> KEYWRADDRX_S) & KEYWRADDRX_M)
#define KEYEXTEND_S 26
#define KEYEXTEND_V(x) ((x) << KEYEXTEND_S)
#define KEYEXTEND_F KEYEXTEND_V(1U)
#define LKPIDXSIZE_S 24
#define LKPIDXSIZE_M 0x3U
#define LKPIDXSIZE_V(x) ((x) << LKPIDXSIZE_S)
#define LKPIDXSIZE_G(x) (((x) >> LKPIDXSIZE_S) & LKPIDXSIZE_M)
#define TP_RSS_VFL_CONFIG_A 0x3a
#define TP_RSS_VFH_CONFIG_A 0x3b
#define ENABLEUDPHASH_S 31
#define ENABLEUDPHASH_V(x) ((x) << ENABLEUDPHASH_S)
#define ENABLEUDPHASH_F ENABLEUDPHASH_V(1U)
#define VFUPEN_S 30
#define VFUPEN_V(x) ((x) << VFUPEN_S)
#define VFUPEN_F VFUPEN_V(1U)
#define VFVLNEX_S 28
#define VFVLNEX_V(x) ((x) << VFVLNEX_S)
#define VFVLNEX_F VFVLNEX_V(1U)
#define VFPRTEN_S 27
#define VFPRTEN_V(x) ((x) << VFPRTEN_S)
#define VFPRTEN_F VFPRTEN_V(1U)
#define VFCHNEN_S 26
#define VFCHNEN_V(x) ((x) << VFCHNEN_S)
#define VFCHNEN_F VFCHNEN_V(1U)
#define DEFAULTQUEUE_S 16
#define DEFAULTQUEUE_M 0x3ffU
#define DEFAULTQUEUE_G(x) (((x) >> DEFAULTQUEUE_S) & DEFAULTQUEUE_M)
#define VFIP6TWOTUPEN_S 6
#define VFIP6TWOTUPEN_V(x) ((x) << VFIP6TWOTUPEN_S)
#define VFIP6TWOTUPEN_F VFIP6TWOTUPEN_V(1U)
#define VFIP4FOURTUPEN_S 5
#define VFIP4FOURTUPEN_V(x) ((x) << VFIP4FOURTUPEN_S)
#define VFIP4FOURTUPEN_F VFIP4FOURTUPEN_V(1U)
#define VFIP4TWOTUPEN_S 4
#define VFIP4TWOTUPEN_V(x) ((x) << VFIP4TWOTUPEN_S)
#define VFIP4TWOTUPEN_F VFIP4TWOTUPEN_V(1U)
#define KEYINDEX_S 0
#define KEYINDEX_M 0xfU
#define KEYINDEX_G(x) (((x) >> KEYINDEX_S) & KEYINDEX_M)
#define MAPENABLE_S 31
#define MAPENABLE_V(x) ((x) << MAPENABLE_S)
#define MAPENABLE_F MAPENABLE_V(1U)
#define CHNENABLE_S 30
#define CHNENABLE_V(x) ((x) << CHNENABLE_S)
#define CHNENABLE_F CHNENABLE_V(1U)
#define PRTENABLE_S 29
#define PRTENABLE_V(x) ((x) << PRTENABLE_S)
#define PRTENABLE_F PRTENABLE_V(1U)
#define UDPFOURTUPEN_S 28
#define UDPFOURTUPEN_V(x) ((x) << UDPFOURTUPEN_S)
#define UDPFOURTUPEN_F UDPFOURTUPEN_V(1U)
#define IP6FOURTUPEN_S 27
#define IP6FOURTUPEN_V(x) ((x) << IP6FOURTUPEN_S)
#define IP6FOURTUPEN_F IP6FOURTUPEN_V(1U)
#define IP6TWOTUPEN_S 26
#define IP6TWOTUPEN_V(x) ((x) << IP6TWOTUPEN_S)
#define IP6TWOTUPEN_F IP6TWOTUPEN_V(1U)
#define IP4FOURTUPEN_S 25
#define IP4FOURTUPEN_V(x) ((x) << IP4FOURTUPEN_S)
#define IP4FOURTUPEN_F IP4FOURTUPEN_V(1U)
#define IP4TWOTUPEN_S 24
#define IP4TWOTUPEN_V(x) ((x) << IP4TWOTUPEN_S)
#define IP4TWOTUPEN_F IP4TWOTUPEN_V(1U)
#define IVFWIDTH_S 20
#define IVFWIDTH_M 0xfU
#define IVFWIDTH_V(x) ((x) << IVFWIDTH_S)
#define IVFWIDTH_G(x) (((x) >> IVFWIDTH_S) & IVFWIDTH_M)
#define CH1DEFAULTQUEUE_S 10
#define CH1DEFAULTQUEUE_M 0x3ffU
#define CH1DEFAULTQUEUE_V(x) ((x) << CH1DEFAULTQUEUE_S)
#define CH1DEFAULTQUEUE_G(x) (((x) >> CH1DEFAULTQUEUE_S) & CH1DEFAULTQUEUE_M)
#define CH0DEFAULTQUEUE_S 0
#define CH0DEFAULTQUEUE_M 0x3ffU
#define CH0DEFAULTQUEUE_V(x) ((x) << CH0DEFAULTQUEUE_S)
#define CH0DEFAULTQUEUE_G(x) (((x) >> CH0DEFAULTQUEUE_S) & CH0DEFAULTQUEUE_M)
#define VFLKPIDX_S 8
#define VFLKPIDX_M 0xffU
#define VFLKPIDX_G(x) (((x) >> VFLKPIDX_S) & VFLKPIDX_M)
#define T6_VFWRADDR_S 8
#define T6_VFWRADDR_M 0xffU
#define T6_VFWRADDR_V(x) ((x) << T6_VFWRADDR_S)
#define T6_VFWRADDR_G(x) (((x) >> T6_VFWRADDR_S) & T6_VFWRADDR_M)
#define TP_RSS_CONFIG_CNG_A 0x7e04
#define TP_RSS_SECRET_KEY0_A 0x40
#define TP_RSS_PF0_CONFIG_A 0x30
#define TP_RSS_PF_MAP_A 0x38
#define TP_RSS_PF_MSK_A 0x39
#define PF1LKPIDX_S 3
#define PF0LKPIDX_M 0x7U
#define PF1MSKSIZE_S 4
#define PF1MSKSIZE_M 0xfU
#define CHNCOUNT3_S 31
#define CHNCOUNT3_V(x) ((x) << CHNCOUNT3_S)
#define CHNCOUNT3_F CHNCOUNT3_V(1U)
#define CHNCOUNT2_S 30
#define CHNCOUNT2_V(x) ((x) << CHNCOUNT2_S)
#define CHNCOUNT2_F CHNCOUNT2_V(1U)
#define CHNCOUNT1_S 29
#define CHNCOUNT1_V(x) ((x) << CHNCOUNT1_S)
#define CHNCOUNT1_F CHNCOUNT1_V(1U)
#define CHNCOUNT0_S 28
#define CHNCOUNT0_V(x) ((x) << CHNCOUNT0_S)
#define CHNCOUNT0_F CHNCOUNT0_V(1U)
#define CHNUNDFLOW3_S 27
#define CHNUNDFLOW3_V(x) ((x) << CHNUNDFLOW3_S)
#define CHNUNDFLOW3_F CHNUNDFLOW3_V(1U)
#define CHNUNDFLOW2_S 26
#define CHNUNDFLOW2_V(x) ((x) << CHNUNDFLOW2_S)
#define CHNUNDFLOW2_F CHNUNDFLOW2_V(1U)
#define CHNUNDFLOW1_S 25
#define CHNUNDFLOW1_V(x) ((x) << CHNUNDFLOW1_S)
#define CHNUNDFLOW1_F CHNUNDFLOW1_V(1U)
#define CHNUNDFLOW0_S 24
#define CHNUNDFLOW0_V(x) ((x) << CHNUNDFLOW0_S)
#define CHNUNDFLOW0_F CHNUNDFLOW0_V(1U)
#define RSTCHN3_S 19
#define RSTCHN3_V(x) ((x) << RSTCHN3_S)
#define RSTCHN3_F RSTCHN3_V(1U)
#define RSTCHN2_S 18
#define RSTCHN2_V(x) ((x) << RSTCHN2_S)
#define RSTCHN2_F RSTCHN2_V(1U)
#define RSTCHN1_S 17
#define RSTCHN1_V(x) ((x) << RSTCHN1_S)
#define RSTCHN1_F RSTCHN1_V(1U)
#define RSTCHN0_S 16
#define RSTCHN0_V(x) ((x) << RSTCHN0_S)
#define RSTCHN0_F RSTCHN0_V(1U)
#define UPDVLD_S 15
#define UPDVLD_V(x) ((x) << UPDVLD_S)
#define UPDVLD_F UPDVLD_V(1U)
#define XOFF_S 14
#define XOFF_V(x) ((x) << XOFF_S)
#define XOFF_F XOFF_V(1U)
#define UPDCHN3_S 13
#define UPDCHN3_V(x) ((x) << UPDCHN3_S)
#define UPDCHN3_F UPDCHN3_V(1U)
#define UPDCHN2_S 12
#define UPDCHN2_V(x) ((x) << UPDCHN2_S)
#define UPDCHN2_F UPDCHN2_V(1U)
#define UPDCHN1_S 11
#define UPDCHN1_V(x) ((x) << UPDCHN1_S)
#define UPDCHN1_F UPDCHN1_V(1U)
#define UPDCHN0_S 10
#define UPDCHN0_V(x) ((x) << UPDCHN0_S)
#define UPDCHN0_F UPDCHN0_V(1U)
#define QUEUE_S 0
#define QUEUE_M 0x3ffU
#define QUEUE_V(x) ((x) << QUEUE_S)
#define QUEUE_G(x) (((x) >> QUEUE_S) & QUEUE_M)
#define MPS_TRC_INT_CAUSE_A 0x985c
#define MISCPERR_S 8
#define MISCPERR_V(x) ((x) << MISCPERR_S)
#define MISCPERR_F MISCPERR_V(1U)
#define PKTFIFO_S 4
#define PKTFIFO_M 0xfU
#define PKTFIFO_V(x) ((x) << PKTFIFO_S)
#define FILTMEM_S 0
#define FILTMEM_M 0xfU
#define FILTMEM_V(x) ((x) << FILTMEM_S)
#define MPS_CLS_INT_CAUSE_A 0xd028
#define HASHSRAM_S 2
#define HASHSRAM_V(x) ((x) << HASHSRAM_S)
#define HASHSRAM_F HASHSRAM_V(1U)
#define MATCHTCAM_S 1
#define MATCHTCAM_V(x) ((x) << MATCHTCAM_S)
#define MATCHTCAM_F MATCHTCAM_V(1U)
#define MATCHSRAM_S 0
#define MATCHSRAM_V(x) ((x) << MATCHSRAM_S)
#define MATCHSRAM_F MATCHSRAM_V(1U)
#define MPS_RX_PG_RSV0_A 0x11010
#define MPS_RX_PG_RSV4_A 0x11020
#define MPS_RX_PERR_INT_CAUSE_A 0x11074
#define MPS_RX_MAC_BG_PG_CNT0_A 0x11208
#define MPS_RX_LPBK_BG_PG_CNT0_A 0x11218
#define MPS_CLS_TCAM_Y_L_A 0xf000
#define MPS_CLS_TCAM_DATA0_A 0xf000
#define MPS_CLS_TCAM_DATA1_A 0xf004
#define VIDL_S 16
#define VIDL_M 0xffffU
#define VIDL_G(x) (((x) >> VIDL_S) & VIDL_M)
#define DATALKPTYPE_S 10
#define DATALKPTYPE_M 0x3U
#define DATALKPTYPE_G(x) (((x) >> DATALKPTYPE_S) & DATALKPTYPE_M)
#define DATAPORTNUM_S 12
#define DATAPORTNUM_M 0xfU
#define DATAPORTNUM_G(x) (((x) >> DATAPORTNUM_S) & DATAPORTNUM_M)
#define DATADIPHIT_S 8
#define DATADIPHIT_V(x) ((x) << DATADIPHIT_S)
#define DATADIPHIT_F DATADIPHIT_V(1U)
#define DATAVIDH2_S 7
#define DATAVIDH2_V(x) ((x) << DATAVIDH2_S)
#define DATAVIDH2_F DATAVIDH2_V(1U)
#define DATAVIDH1_S 0
#define DATAVIDH1_M 0x7fU
#define DATAVIDH1_G(x) (((x) >> DATAVIDH1_S) & DATAVIDH1_M)
#define USED_S 16
#define USED_M 0x7ffU
#define USED_G(x) (((x) >> USED_S) & USED_M)
#define ALLOC_S 0
#define ALLOC_M 0x7ffU
#define ALLOC_G(x) (((x) >> ALLOC_S) & ALLOC_M)
#define T5_USED_S 16
#define T5_USED_M 0xfffU
#define T5_USED_G(x) (((x) >> T5_USED_S) & T5_USED_M)
#define T5_ALLOC_S 0
#define T5_ALLOC_M 0xfffU
#define T5_ALLOC_G(x) (((x) >> T5_ALLOC_S) & T5_ALLOC_M)
#define DMACH_S 0
#define DMACH_M 0xffffU
#define DMACH_G(x) (((x) >> DMACH_S) & DMACH_M)
#define MPS_CLS_TCAM_X_L_A 0xf008
#define MPS_CLS_TCAM_DATA2_CTL_A 0xf008
#define CTLCMDTYPE_S 31
#define CTLCMDTYPE_V(x) ((x) << CTLCMDTYPE_S)
#define CTLCMDTYPE_F CTLCMDTYPE_V(1U)
#define CTLTCAMSEL_S 25
#define CTLTCAMSEL_V(x) ((x) << CTLTCAMSEL_S)
#define CTLTCAMINDEX_S 17
#define CTLTCAMINDEX_V(x) ((x) << CTLTCAMINDEX_S)
#define CTLXYBITSEL_S 16
#define CTLXYBITSEL_V(x) ((x) << CTLXYBITSEL_S)
#define MPS_CLS_TCAM_Y_L(idx) (MPS_CLS_TCAM_Y_L_A + (idx) * 16)
#define NUM_MPS_CLS_TCAM_Y_L_INSTANCES 512
#define MPS_CLS_TCAM_X_L(idx) (MPS_CLS_TCAM_X_L_A + (idx) * 16)
#define NUM_MPS_CLS_TCAM_X_L_INSTANCES 512
#define MPS_CLS_SRAM_L_A 0xe000
#define T6_MULTILISTEN0_S 26
#define T6_SRAM_PRIO3_S 23
#define T6_SRAM_PRIO3_M 0x7U
#define T6_SRAM_PRIO3_G(x) (((x) >> T6_SRAM_PRIO3_S) & T6_SRAM_PRIO3_M)
#define T6_SRAM_PRIO2_S 20
#define T6_SRAM_PRIO2_M 0x7U
#define T6_SRAM_PRIO2_G(x) (((x) >> T6_SRAM_PRIO2_S) & T6_SRAM_PRIO2_M)
#define T6_SRAM_PRIO1_S 17
#define T6_SRAM_PRIO1_M 0x7U
#define T6_SRAM_PRIO1_G(x) (((x) >> T6_SRAM_PRIO1_S) & T6_SRAM_PRIO1_M)
#define T6_SRAM_PRIO0_S 14
#define T6_SRAM_PRIO0_M 0x7U
#define T6_SRAM_PRIO0_G(x) (((x) >> T6_SRAM_PRIO0_S) & T6_SRAM_PRIO0_M)
#define T6_SRAM_VLD_S 13
#define T6_SRAM_VLD_V(x) ((x) << T6_SRAM_VLD_S)
#define T6_SRAM_VLD_F T6_SRAM_VLD_V(1U)
#define T6_REPLICATE_S 12
#define T6_REPLICATE_V(x) ((x) << T6_REPLICATE_S)
#define T6_REPLICATE_F T6_REPLICATE_V(1U)
#define T6_PF_S 9
#define T6_PF_M 0x7U
#define T6_PF_G(x) (((x) >> T6_PF_S) & T6_PF_M)
#define T6_VF_VALID_S 8
#define T6_VF_VALID_V(x) ((x) << T6_VF_VALID_S)
#define T6_VF_VALID_F T6_VF_VALID_V(1U)
#define T6_VF_S 0
#define T6_VF_M 0xffU
#define T6_VF_G(x) (((x) >> T6_VF_S) & T6_VF_M)
#define MPS_CLS_SRAM_H_A 0xe004
#define MPS_CLS_SRAM_L(idx) (MPS_CLS_SRAM_L_A + (idx) * 8)
#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
#define MPS_CLS_SRAM_H(idx) (MPS_CLS_SRAM_H_A + (idx) * 8)
#define NUM_MPS_CLS_SRAM_H_INSTANCES 336
#define MULTILISTEN0_S 25
#define REPLICATE_S 11
#define REPLICATE_V(x) ((x) << REPLICATE_S)
#define REPLICATE_F REPLICATE_V(1U)
#define PF_S 8
#define PF_M 0x7U
#define PF_G(x) (((x) >> PF_S) & PF_M)
#define VF_VALID_S 7
#define VF_VALID_V(x) ((x) << VF_VALID_S)
#define VF_VALID_F VF_VALID_V(1U)
#define VF_S 0
#define VF_M 0x7fU
#define VF_G(x) (((x) >> VF_S) & VF_M)
#define SRAM_PRIO3_S 22
#define SRAM_PRIO3_M 0x7U
#define SRAM_PRIO3_G(x) (((x) >> SRAM_PRIO3_S) & SRAM_PRIO3_M)
#define SRAM_PRIO2_S 19
#define SRAM_PRIO2_M 0x7U
#define SRAM_PRIO2_G(x) (((x) >> SRAM_PRIO2_S) & SRAM_PRIO2_M)
#define SRAM_PRIO1_S 16
#define SRAM_PRIO1_M 0x7U
#define SRAM_PRIO1_G(x) (((x) >> SRAM_PRIO1_S) & SRAM_PRIO1_M)
#define SRAM_PRIO0_S 13
#define SRAM_PRIO0_M 0x7U
#define SRAM_PRIO0_G(x) (((x) >> SRAM_PRIO0_S) & SRAM_PRIO0_M)
#define SRAM_VLD_S 12
#define SRAM_VLD_V(x) ((x) << SRAM_VLD_S)
#define SRAM_VLD_F SRAM_VLD_V(1U)
#define PORTMAP_S 0
#define PORTMAP_M 0xfU
#define PORTMAP_G(x) (((x) >> PORTMAP_S) & PORTMAP_M)
#define CPL_INTR_CAUSE_A 0x19054
#define CIM_OP_MAP_PERR_S 5
#define CIM_OP_MAP_PERR_V(x) ((x) << CIM_OP_MAP_PERR_S)
#define CIM_OP_MAP_PERR_F CIM_OP_MAP_PERR_V(1U)
#define CIM_OVFL_ERROR_S 4
#define CIM_OVFL_ERROR_V(x) ((x) << CIM_OVFL_ERROR_S)
#define CIM_OVFL_ERROR_F CIM_OVFL_ERROR_V(1U)
#define TP_FRAMING_ERROR_S 3
#define TP_FRAMING_ERROR_V(x) ((x) << TP_FRAMING_ERROR_S)
#define TP_FRAMING_ERROR_F TP_FRAMING_ERROR_V(1U)
#define SGE_FRAMING_ERROR_S 2
#define SGE_FRAMING_ERROR_V(x) ((x) << SGE_FRAMING_ERROR_S)
#define SGE_FRAMING_ERROR_F SGE_FRAMING_ERROR_V(1U)
#define CIM_FRAMING_ERROR_S 1
#define CIM_FRAMING_ERROR_V(x) ((x) << CIM_FRAMING_ERROR_S)
#define CIM_FRAMING_ERROR_F CIM_FRAMING_ERROR_V(1U)
#define ZERO_SWITCH_ERROR_S 0
#define ZERO_SWITCH_ERROR_V(x) ((x) << ZERO_SWITCH_ERROR_S)
#define ZERO_SWITCH_ERROR_F ZERO_SWITCH_ERROR_V(1U)
#define SMB_INT_CAUSE_A 0x19090
#define MSTTXFIFOPARINT_S 21
#define MSTTXFIFOPARINT_V(x) ((x) << MSTTXFIFOPARINT_S)
#define MSTTXFIFOPARINT_F MSTTXFIFOPARINT_V(1U)
#define MSTRXFIFOPARINT_S 20
#define MSTRXFIFOPARINT_V(x) ((x) << MSTRXFIFOPARINT_S)
#define MSTRXFIFOPARINT_F MSTRXFIFOPARINT_V(1U)
#define SLVFIFOPARINT_S 19
#define SLVFIFOPARINT_V(x) ((x) << SLVFIFOPARINT_S)
#define SLVFIFOPARINT_F SLVFIFOPARINT_V(1U)
#define ULP_RX_INT_CAUSE_A 0x19158
#define ULP_RX_ISCSI_LLIMIT_A 0x1915c
#define ULP_RX_ISCSI_ULIMIT_A 0x19160
#define ULP_RX_ISCSI_TAGMASK_A 0x19164
#define ULP_RX_ISCSI_PSZ_A 0x19168
#define ULP_RX_TDDP_LLIMIT_A 0x1916c
#define ULP_RX_TDDP_ULIMIT_A 0x19170
#define ULP_RX_STAG_LLIMIT_A 0x1917c
#define ULP_RX_STAG_ULIMIT_A 0x19180
#define ULP_RX_RQ_LLIMIT_A 0x19184
#define ULP_RX_RQ_ULIMIT_A 0x19188
#define ULP_RX_PBL_LLIMIT_A 0x1918c
#define ULP_RX_PBL_ULIMIT_A 0x19190
#define ULP_RX_CTX_BASE_A 0x19194
#define ULP_RX_RQUDP_LLIMIT_A 0x191a4
#define ULP_RX_RQUDP_ULIMIT_A 0x191a8
#define ULP_RX_LA_CTL_A 0x1923c
#define ULP_RX_LA_RDPTR_A 0x19240
#define ULP_RX_LA_RDDATA_A 0x19244
#define ULP_RX_LA_WRPTR_A 0x19248
#define HPZ3_S 24
#define HPZ3_V(x) ((x) << HPZ3_S)
#define HPZ2_S 16
#define HPZ2_V(x) ((x) << HPZ2_S)
#define HPZ1_S 8
#define HPZ1_V(x) ((x) << HPZ1_S)
#define HPZ0_S 0
#define HPZ0_V(x) ((x) << HPZ0_S)
#define ULP_RX_TDDP_PSZ_A 0x19178
/* registers for module SF */
#define SF_DATA_A 0x193f8
#define SF_OP_A 0x193fc
#define SF_BUSY_S 31
#define SF_BUSY_V(x) ((x) << SF_BUSY_S)
#define SF_BUSY_F SF_BUSY_V(1U)
#define SF_LOCK_S 4
#define SF_LOCK_V(x) ((x) << SF_LOCK_S)
#define SF_LOCK_F SF_LOCK_V(1U)
#define SF_CONT_S 3
#define SF_CONT_V(x) ((x) << SF_CONT_S)
#define SF_CONT_F SF_CONT_V(1U)
#define BYTECNT_S 1
#define BYTECNT_V(x) ((x) << BYTECNT_S)
#define OP_S 0
#define OP_V(x) ((x) << OP_S)
#define OP_F OP_V(1U)
#define PL_PF_INT_CAUSE_A 0x3c0
#define PFSW_S 3
#define PFSW_V(x) ((x) << PFSW_S)
#define PFSW_F PFSW_V(1U)
#define PFCIM_S 1
#define PFCIM_V(x) ((x) << PFCIM_S)
#define PFCIM_F PFCIM_V(1U)
#define PL_PF_INT_ENABLE_A 0x3c4
#define PL_PF_CTL_A 0x3c8
#define PL_WHOAMI_A 0x19400
#define SOURCEPF_S 8
#define SOURCEPF_M 0x7U
#define SOURCEPF_G(x) (((x) >> SOURCEPF_S) & SOURCEPF_M)
#define T6_SOURCEPF_S 9
#define T6_SOURCEPF_M 0x7U
#define T6_SOURCEPF_G(x) (((x) >> T6_SOURCEPF_S) & T6_SOURCEPF_M)
#define PL_INT_CAUSE_A 0x1940c
#define ULP_TX_S 27
#define ULP_TX_V(x) ((x) << ULP_TX_S)
#define ULP_TX_F ULP_TX_V(1U)
#define SGE_S 26
#define SGE_V(x) ((x) << SGE_S)
#define SGE_F SGE_V(1U)
#define CPL_SWITCH_S 24
#define CPL_SWITCH_V(x) ((x) << CPL_SWITCH_S)
#define CPL_SWITCH_F CPL_SWITCH_V(1U)
#define ULP_RX_S 23
#define ULP_RX_V(x) ((x) << ULP_RX_S)
#define ULP_RX_F ULP_RX_V(1U)
#define PM_RX_S 22
#define PM_RX_V(x) ((x) << PM_RX_S)
#define PM_RX_F PM_RX_V(1U)
#define PM_TX_S 21
#define PM_TX_V(x) ((x) << PM_TX_S)
#define PM_TX_F PM_TX_V(1U)
#define MA_S 20
#define MA_V(x) ((x) << MA_S)
#define MA_F MA_V(1U)
#define TP_S 19
#define TP_V(x) ((x) << TP_S)
#define TP_F TP_V(1U)
#define LE_S 18
#define LE_V(x) ((x) << LE_S)
#define LE_F LE_V(1U)
#define EDC1_S 17
#define EDC1_V(x) ((x) << EDC1_S)
#define EDC1_F EDC1_V(1U)
#define EDC0_S 16
#define EDC0_V(x) ((x) << EDC0_S)
#define EDC0_F EDC0_V(1U)
#define MC_S 15
#define MC_V(x) ((x) << MC_S)
#define MC_F MC_V(1U)
#define PCIE_S 14
#define PCIE_V(x) ((x) << PCIE_S)
#define PCIE_F PCIE_V(1U)
#define XGMAC_KR1_S 12
#define XGMAC_KR1_V(x) ((x) << XGMAC_KR1_S)
#define XGMAC_KR1_F XGMAC_KR1_V(1U)
#define XGMAC_KR0_S 11
#define XGMAC_KR0_V(x) ((x) << XGMAC_KR0_S)
#define XGMAC_KR0_F XGMAC_KR0_V(1U)
#define XGMAC1_S 10
#define XGMAC1_V(x) ((x) << XGMAC1_S)
#define XGMAC1_F XGMAC1_V(1U)
#define XGMAC0_S 9
#define XGMAC0_V(x) ((x) << XGMAC0_S)
#define XGMAC0_F XGMAC0_V(1U)
#define SMB_S 8
#define SMB_V(x) ((x) << SMB_S)
#define SMB_F SMB_V(1U)
#define SF_S 7
#define SF_V(x) ((x) << SF_S)
#define SF_F SF_V(1U)
#define PL_S 6
#define PL_V(x) ((x) << PL_S)
#define PL_F PL_V(1U)
#define NCSI_S 5
#define NCSI_V(x) ((x) << NCSI_S)
#define NCSI_F NCSI_V(1U)
#define MPS_S 4
#define MPS_V(x) ((x) << MPS_S)
#define MPS_F MPS_V(1U)
#define CIM_S 0
#define CIM_V(x) ((x) << CIM_S)
#define CIM_F CIM_V(1U)
#define MC1_S 31
#define MC1_V(x) ((x) << MC1_S)
#define MC1_F MC1_V(1U)
#define PL_INT_ENABLE_A 0x19410
#define PL_INT_MAP0_A 0x19414
#define PL_RST_A 0x19428
#define PIORST_S 1
#define PIORST_V(x) ((x) << PIORST_S)
#define PIORST_F PIORST_V(1U)
#define PIORSTMODE_S 0
#define PIORSTMODE_V(x) ((x) << PIORSTMODE_S)
#define PIORSTMODE_F PIORSTMODE_V(1U)
#define PL_PL_INT_CAUSE_A 0x19430
#define FATALPERR_S 4
#define FATALPERR_V(x) ((x) << FATALPERR_S)
#define FATALPERR_F FATALPERR_V(1U)
#define PERRVFID_S 0
#define PERRVFID_V(x) ((x) << PERRVFID_S)
#define PERRVFID_F PERRVFID_V(1U)
#define PL_REV_A 0x1943c
#define REV_S 0
#define REV_M 0xfU
#define REV_V(x) ((x) << REV_S)
#define REV_G(x) (((x) >> REV_S) & REV_M)
#define T6_UNKNOWNCMD_S 3
#define T6_UNKNOWNCMD_V(x) ((x) << T6_UNKNOWNCMD_S)
#define T6_UNKNOWNCMD_F T6_UNKNOWNCMD_V(1U)
#define T6_LIP0_S 2
#define T6_LIP0_V(x) ((x) << T6_LIP0_S)
#define T6_LIP0_F T6_LIP0_V(1U)
#define T6_LIPMISS_S 1
#define T6_LIPMISS_V(x) ((x) << T6_LIPMISS_S)
#define T6_LIPMISS_F T6_LIPMISS_V(1U)
#define LE_DB_CONFIG_A 0x19c04
#define LE_DB_SERVER_INDEX_A 0x19c18
#define LE_DB_SRVR_START_INDEX_A 0x19c18
#define LE_DB_ACT_CNT_IPV4_A 0x19c20
#define LE_DB_ACT_CNT_IPV6_A 0x19c24
#define LE_DB_HASH_TID_BASE_A 0x19c30
#define LE_DB_HASH_TBL_BASE_ADDR_A 0x19c30
#define LE_DB_INT_CAUSE_A 0x19c3c
#define LE_DB_TID_HASHBASE_A 0x19df8
#define T6_LE_DB_HASH_TID_BASE_A 0x19df8
#define HASHEN_S 20
#define HASHEN_V(x) ((x) << HASHEN_S)
#define HASHEN_F HASHEN_V(1U)
#define ASLIPCOMPEN_S 17
#define ASLIPCOMPEN_V(x) ((x) << ASLIPCOMPEN_S)
#define ASLIPCOMPEN_F ASLIPCOMPEN_V(1U)
#define REQQPARERR_S 16
#define REQQPARERR_V(x) ((x) << REQQPARERR_S)
#define REQQPARERR_F REQQPARERR_V(1U)
#define UNKNOWNCMD_S 15
#define UNKNOWNCMD_V(x) ((x) << UNKNOWNCMD_S)
#define UNKNOWNCMD_F UNKNOWNCMD_V(1U)
#define PARITYERR_S 6
#define PARITYERR_V(x) ((x) << PARITYERR_S)
#define PARITYERR_F PARITYERR_V(1U)
#define LIPMISS_S 5
#define LIPMISS_V(x) ((x) << LIPMISS_S)
#define LIPMISS_F LIPMISS_V(1U)
#define LIP0_S 4
#define LIP0_V(x) ((x) << LIP0_S)
#define LIP0_F LIP0_V(1U)
#define BASEADDR_S 3
#define BASEADDR_M 0x1fffffffU
#define BASEADDR_G(x) (((x) >> BASEADDR_S) & BASEADDR_M)
#define TCAMINTPERR_S 13
#define TCAMINTPERR_V(x) ((x) << TCAMINTPERR_S)
#define TCAMINTPERR_F TCAMINTPERR_V(1U)
#define SSRAMINTPERR_S 10
#define SSRAMINTPERR_V(x) ((x) << SSRAMINTPERR_S)
#define SSRAMINTPERR_F SSRAMINTPERR_V(1U)
#define NCSI_INT_CAUSE_A 0x1a0d8
#define CIM_DM_PRTY_ERR_S 8
#define CIM_DM_PRTY_ERR_V(x) ((x) << CIM_DM_PRTY_ERR_S)
#define CIM_DM_PRTY_ERR_F CIM_DM_PRTY_ERR_V(1U)
#define MPS_DM_PRTY_ERR_S 7
#define MPS_DM_PRTY_ERR_V(x) ((x) << MPS_DM_PRTY_ERR_S)
#define MPS_DM_PRTY_ERR_F MPS_DM_PRTY_ERR_V(1U)
#define TXFIFO_PRTY_ERR_S 1
#define TXFIFO_PRTY_ERR_V(x) ((x) << TXFIFO_PRTY_ERR_S)
#define TXFIFO_PRTY_ERR_F TXFIFO_PRTY_ERR_V(1U)
#define RXFIFO_PRTY_ERR_S 0
#define RXFIFO_PRTY_ERR_V(x) ((x) << RXFIFO_PRTY_ERR_S)
#define RXFIFO_PRTY_ERR_F RXFIFO_PRTY_ERR_V(1U)
#define XGMAC_PORT_CFG2_A 0x1018
#define PATEN_S 18
#define PATEN_V(x) ((x) << PATEN_S)
#define PATEN_F PATEN_V(1U)
#define MAGICEN_S 17
#define MAGICEN_V(x) ((x) << MAGICEN_S)
#define MAGICEN_F MAGICEN_V(1U)
#define XGMAC_PORT_MAGIC_MACID_LO 0x1024
#define XGMAC_PORT_MAGIC_MACID_HI 0x1028
#define XGMAC_PORT_EPIO_DATA0_A 0x10c0
#define XGMAC_PORT_EPIO_DATA1_A 0x10c4
#define XGMAC_PORT_EPIO_DATA2_A 0x10c8
#define XGMAC_PORT_EPIO_DATA3_A 0x10cc
#define XGMAC_PORT_EPIO_OP_A 0x10d0
#define EPIOWR_S 8
#define EPIOWR_V(x) ((x) << EPIOWR_S)
#define EPIOWR_F EPIOWR_V(1U)
#define ADDRESS_S 0
#define ADDRESS_V(x) ((x) << ADDRESS_S)
#define MAC_PORT_INT_CAUSE_A 0x8dc
#define XGMAC_PORT_INT_CAUSE_A 0x10dc
#define TP_TX_MOD_QUEUE_REQ_MAP_A 0x7e28
#define TP_TX_MOD_QUEUE_WEIGHT0_A 0x7e30
#define TP_TX_MOD_CHANNEL_WEIGHT_A 0x7e34
#define TX_MOD_QUEUE_REQ_MAP_S 0
#define TX_MOD_QUEUE_REQ_MAP_V(x) ((x) << TX_MOD_QUEUE_REQ_MAP_S)
#define TX_MODQ_WEIGHT3_S 24
#define TX_MODQ_WEIGHT3_V(x) ((x) << TX_MODQ_WEIGHT3_S)
#define TX_MODQ_WEIGHT2_S 16
#define TX_MODQ_WEIGHT2_V(x) ((x) << TX_MODQ_WEIGHT2_S)
#define TX_MODQ_WEIGHT1_S 8
#define TX_MODQ_WEIGHT1_V(x) ((x) << TX_MODQ_WEIGHT1_S)
#define TX_MODQ_WEIGHT0_S 0
#define TX_MODQ_WEIGHT0_V(x) ((x) << TX_MODQ_WEIGHT0_S)
#define TP_TX_SCHED_HDR_A 0x23
#define TP_TX_SCHED_FIFO_A 0x24
#define TP_TX_SCHED_PCMD_A 0x25
#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
#define NUM_MPS_T5_CLS_SRAM_L_INSTANCES 512
#define T5_PORT0_BASE 0x30000
#define T5_PORT_STRIDE 0x4000
#define T5_PORT_BASE(idx) (T5_PORT0_BASE + (idx) * T5_PORT_STRIDE)
#define T5_PORT_REG(idx, reg) (T5_PORT_BASE(idx) + (reg))
#define MC_0_BASE_ADDR 0x40000
#define MC_1_BASE_ADDR 0x48000
#define MC_STRIDE (MC_1_BASE_ADDR - MC_0_BASE_ADDR)
#define MC_REG(reg, idx) (reg + MC_STRIDE * idx)
#define MC_P_BIST_CMD_A 0x41400
#define MC_P_BIST_CMD_ADDR_A 0x41404
#define MC_P_BIST_CMD_LEN_A 0x41408
#define MC_P_BIST_DATA_PATTERN_A 0x4140c
#define MC_P_BIST_STATUS_RDATA_A 0x41488
#define EDC_T50_BASE_ADDR 0x50000
#define EDC_H_BIST_CMD_A 0x50004
#define EDC_H_BIST_CMD_ADDR_A 0x50008
#define EDC_H_BIST_CMD_LEN_A 0x5000c
#define EDC_H_BIST_DATA_PATTERN_A 0x50010
#define EDC_H_BIST_STATUS_RDATA_A 0x50028
#define EDC_H_ECC_ERR_ADDR_A 0x50084
#define EDC_T51_BASE_ADDR 0x50800
#define EDC_T5_STRIDE (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR)
#define EDC_T5_REG(reg, idx) (reg + EDC_T5_STRIDE * idx)
#define PL_VF_REV_A 0x4
#define PL_VF_WHOAMI_A 0x0
#define PL_VF_REVISION_A 0x8
/* registers for module CIM */
#define CIM_HOST_ACC_CTRL_A 0x7b50
#define CIM_HOST_ACC_DATA_A 0x7b54
#define UP_UP_DBG_LA_CFG_A 0x140
#define UP_UP_DBG_LA_DATA_A 0x144
#define HOSTBUSY_S 17
#define HOSTBUSY_V(x) ((x) << HOSTBUSY_S)
#define HOSTBUSY_F HOSTBUSY_V(1U)
#define HOSTWRITE_S 16
#define HOSTWRITE_V(x) ((x) << HOSTWRITE_S)
#define HOSTWRITE_F HOSTWRITE_V(1U)
#define CIM_IBQ_DBG_CFG_A 0x7b60
#define IBQDBGADDR_S 16
#define IBQDBGADDR_M 0xfffU
#define IBQDBGADDR_V(x) ((x) << IBQDBGADDR_S)
#define IBQDBGADDR_G(x) (((x) >> IBQDBGADDR_S) & IBQDBGADDR_M)
#define IBQDBGBUSY_S 1
#define IBQDBGBUSY_V(x) ((x) << IBQDBGBUSY_S)
#define IBQDBGBUSY_F IBQDBGBUSY_V(1U)
#define IBQDBGEN_S 0
#define IBQDBGEN_V(x) ((x) << IBQDBGEN_S)
#define IBQDBGEN_F IBQDBGEN_V(1U)
#define CIM_OBQ_DBG_CFG_A 0x7b64
#define OBQDBGADDR_S 16
#define OBQDBGADDR_M 0xfffU
#define OBQDBGADDR_V(x) ((x) << OBQDBGADDR_S)
#define OBQDBGADDR_G(x) (((x) >> OBQDBGADDR_S) & OBQDBGADDR_M)
#define OBQDBGBUSY_S 1
#define OBQDBGBUSY_V(x) ((x) << OBQDBGBUSY_S)
#define OBQDBGBUSY_F OBQDBGBUSY_V(1U)
#define OBQDBGEN_S 0
#define OBQDBGEN_V(x) ((x) << OBQDBGEN_S)
#define OBQDBGEN_F OBQDBGEN_V(1U)
#define CIM_IBQ_DBG_DATA_A 0x7b68
#define CIM_OBQ_DBG_DATA_A 0x7b6c
#define CIM_DEBUGCFG_A 0x7b70
#define CIM_DEBUGSTS_A 0x7b74
#define POLADBGRDPTR_S 23
#define POLADBGRDPTR_M 0x1ffU
#define POLADBGRDPTR_V(x) ((x) << POLADBGRDPTR_S)
#define POLADBGWRPTR_S 16
#define POLADBGWRPTR_M 0x1ffU
#define POLADBGWRPTR_G(x) (((x) >> POLADBGWRPTR_S) & POLADBGWRPTR_M)
#define PILADBGRDPTR_S 14
#define PILADBGRDPTR_M 0x1ffU
#define PILADBGRDPTR_V(x) ((x) << PILADBGRDPTR_S)
#define PILADBGWRPTR_S 0
#define PILADBGWRPTR_M 0x1ffU
#define PILADBGWRPTR_G(x) (((x) >> PILADBGWRPTR_S) & PILADBGWRPTR_M)
#define LADBGEN_S 12
#define LADBGEN_V(x) ((x) << LADBGEN_S)
#define LADBGEN_F LADBGEN_V(1U)
#define CIM_PO_LA_DEBUGDATA_A 0x7b78
#define CIM_PI_LA_DEBUGDATA_A 0x7b7c
#define CIM_PO_LA_MADEBUGDATA_A 0x7b80
#define CIM_PI_LA_MADEBUGDATA_A 0x7b84
#define UPDBGLARDEN_S 1
#define UPDBGLARDEN_V(x) ((x) << UPDBGLARDEN_S)
#define UPDBGLARDEN_F UPDBGLARDEN_V(1U)
#define UPDBGLAEN_S 0
#define UPDBGLAEN_V(x) ((x) << UPDBGLAEN_S)
#define UPDBGLAEN_F UPDBGLAEN_V(1U)
#define UPDBGLARDPTR_S 2
#define UPDBGLARDPTR_M 0xfffU
#define UPDBGLARDPTR_V(x) ((x) << UPDBGLARDPTR_S)
#define UPDBGLAWRPTR_S 16
#define UPDBGLAWRPTR_M 0xfffU
#define UPDBGLAWRPTR_G(x) (((x) >> UPDBGLAWRPTR_S) & UPDBGLAWRPTR_M)
#define UPDBGLACAPTPCONLY_S 30
#define UPDBGLACAPTPCONLY_V(x) ((x) << UPDBGLACAPTPCONLY_S)
#define UPDBGLACAPTPCONLY_F UPDBGLACAPTPCONLY_V(1U)
#define CIM_QUEUE_CONFIG_REF_A 0x7b48
#define CIM_QUEUE_CONFIG_CTRL_A 0x7b4c
#define CIMQSIZE_S 24
#define CIMQSIZE_M 0x3fU
#define CIMQSIZE_G(x) (((x) >> CIMQSIZE_S) & CIMQSIZE_M)
#define CIMQBASE_S 16
#define CIMQBASE_M 0x3fU
#define CIMQBASE_G(x) (((x) >> CIMQBASE_S) & CIMQBASE_M)
#define QUEFULLTHRSH_S 0
#define QUEFULLTHRSH_M 0x1ffU
#define QUEFULLTHRSH_G(x) (((x) >> QUEFULLTHRSH_S) & QUEFULLTHRSH_M)
#define UP_IBQ_0_RDADDR_A 0x10
#define UP_IBQ_0_SHADOW_RDADDR_A 0x280
#define UP_OBQ_0_REALADDR_A 0x104
#define UP_OBQ_0_SHADOW_REALADDR_A 0x394
#define IBQRDADDR_S 0
#define IBQRDADDR_M 0x1fffU
#define IBQRDADDR_G(x) (((x) >> IBQRDADDR_S) & IBQRDADDR_M)
#define IBQWRADDR_S 0
#define IBQWRADDR_M 0x1fffU
#define IBQWRADDR_G(x) (((x) >> IBQWRADDR_S) & IBQWRADDR_M)
#define QUERDADDR_S 0
#define QUERDADDR_M 0x7fffU
#define QUERDADDR_G(x) (((x) >> QUERDADDR_S) & QUERDADDR_M)
#define QUEREMFLITS_S 0
#define QUEREMFLITS_M 0x7ffU
#define QUEREMFLITS_G(x) (((x) >> QUEREMFLITS_S) & QUEREMFLITS_M)
#define QUEEOPCNT_S 16
#define QUEEOPCNT_M 0xfffU
#define QUEEOPCNT_G(x) (((x) >> QUEEOPCNT_S) & QUEEOPCNT_M)
#define QUESOPCNT_S 0
#define QUESOPCNT_M 0xfffU
#define QUESOPCNT_G(x) (((x) >> QUESOPCNT_S) & QUESOPCNT_M)
#define OBQSELECT_S 4
#define OBQSELECT_V(x) ((x) << OBQSELECT_S)
#define OBQSELECT_F OBQSELECT_V(1U)
#define IBQSELECT_S 3
#define IBQSELECT_V(x) ((x) << IBQSELECT_S)
#define IBQSELECT_F IBQSELECT_V(1U)
#define QUENUMSELECT_S 0
#define QUENUMSELECT_V(x) ((x) << QUENUMSELECT_S)
#endif /* __T4_REGS_H */
|
1
|
static bool function_8190763448576294207(struct kvm_vcpu *variable_8904401061998080898){u32 variable_4302612221328351702 = vmcs_read32(variable_6837991076804072419);struct vcpu_vmx *variable_7006045569192179912 = to_vmx(variable_8904401061998080898);struct vmcs12 *variable_7698226853190009976 = get_vmcs12(variable_8904401061998080898);u32 variable_7595044205259398089 = variable_7006045569192179912->exit_reason;trace_kvm_nested_vmexit(kvm_rip_read(variable_8904401061998080898), variable_7595044205259398089,vmcs_readl(variable_3742302475952395646),variable_7006045569192179912->idt_vectoring_info,variable_4302612221328351702,vmcs_read32(variable_3422507566123103040),variable_5073950648386394244);if (variable_7006045569192179912->nested.nested_run_pending)return 0;if (unlikely(variable_7006045569192179912->fail)) {pr_info_ratelimited("%s failed vm entry %x\n", variable_1041522136734938763,vmcs_read32(variable_1418454992875174388));return 1;}switch (variable_7595044205259398089) {case variable_6704290283781574432:if (!is_exception(variable_4302612221328351702))return 0;else if (is_page_fault(variable_4302612221328351702))return variable_919237354616990026;else if (is_no_device(variable_4302612221328351702) &&!(variable_7698226853190009976->guest_cr0 & variable_1957699399227934609))return 0;return variable_7698226853190009976->exception_bitmap &(1u << (variable_4302612221328351702 & variable_2716766851273541554));case variable_4310960670259009888:return 0;case variable_7791671530427407976:return 1;case variable_2317240306335619366:return nested_cpu_has(variable_7698226853190009976, variable_8612546040503815628);case variable_4672510818577502449:return nested_cpu_has(variable_7698226853190009976, variable_4253295524037964056);case variable_5668255190581482373:return 1;case variable_928614323127757921:if (kvm_register_read(variable_8904401061998080898, variable_4341665051888331348) == 0xa)return 0;return 1;case variable_7489196108695014420:return nested_cpu_has(variable_7698226853190009976, variable_4379479327872330676);case variable_1239534133724487481:return 1;case variable_1859217610325112672:return nested_cpu_has(variable_7698226853190009976, variable_8445093356243940250);case variable_2729844729087337622:return nested_cpu_has(variable_7698226853190009976, variable_24842644722496977);case variable_1445017274131594525:return nested_cpu_has(variable_7698226853190009976, variable_5109462840803797475);case variable_5245842942272463350: case variable_8428107153667275855:case variable_3628857449895905483: case variable_5541977691564412002:case variable_6845759868259129850: case variable_6243708707202356223:case variable_4779782616047055: case variable_9197504786401329619:case variable_3632780182018609748: case variable_5986558859303297573: case variable_8168172003743551626:/** VMX instructions trap unconditionally. This allows L1 to* emulate them for its L2 guest, i.e., allows 3-level nesting!*/return 1;case variable_7955573458766981324:return nested_vmx_exit_handled_cr(variable_8904401061998080898, variable_7698226853190009976);case variable_8651906602688898063:return nested_cpu_has(variable_7698226853190009976, variable_8738889929319380728);case variable_183641270697114380:return nested_vmx_exit_handled_io(variable_8904401061998080898, variable_7698226853190009976);case variable_2084979089517977276:case variable_3347007297596354998:return nested_vmx_exit_handled_msr(variable_8904401061998080898, variable_7698226853190009976, variable_7595044205259398089);case variable_7109897087244711681:return 1;case variable_5712879693510803563:return nested_cpu_has(variable_7698226853190009976, variable_7937800066004290216);case variable_857685169260590940:return nested_cpu_has(variable_7698226853190009976, variable_2628612940543223614);case variable_8833422671537595520:return nested_cpu_has(variable_7698226853190009976, variable_4581845915150945291) ||nested_cpu_has2(variable_7698226853190009976,variable_201078309116066056);case variable_6198075212720816613:return 0;case variable_4926777455826984415:return nested_cpu_has(variable_7698226853190009976, variable_5132090851245328408);case variable_4800097184864314588:return nested_cpu_has2(variable_7698226853190009976,variable_7889554815299920959);case variable_7687769486753044341:/** L0 always deals with the EPT violation. If nested EPT is* used, and the nested mmu code discovers that the address is* missing in the guest EPT table (EPT12), the EPT violation* will be injected with nested_ept_inject_page_fault()*/return 0;case variable_6434269707437096507:float variable_3770316631336758930 = 2438231003123072543;variable_4302612221328351702 = variable_4302612221328351702 + 0;float variable_4143081868520505137 = 2502311240472727124;
float variable_605284478645268331 = (3191129703587203370) * variable_3770316631336758930;/** L2 never uses directly L1's EPT, but rather L0's own EPT* table (shadow on EPT) or a merged EPT table that L0 built* (EPT on EPT). So any problems with the structure of the* table is L0's fault.*/return 0;case variable_1057782098675008443:return nested_cpu_has2(variable_7698226853190009976, variable_1828755957298193390);case variable_6945880138196561194:return 1;default:return 1;}}
|
1
|
static int _hid_get_report_descriptor(struct hid_device_priv* dev, void *data, size_t *size){ uint8_t d[MAX_HID_DESCRIPTOR_SIZE]; size_t i = 0; /* usage page (0xFFA0 == vendor defined) * d[i++] = 0x06; d[i++] = 0xA0; d[i++] = 0xFF; /* usage (vendor defined) * d[i++] = 0x09; d[i++] = 0x01; /* start collection (application) * d[i++] = 0xA1; d[i++] = 0x01; /* input report * if (dev->input_report_size) { /* usage (vendor defined) * d[i++] = 0x09; d[i++] = 0x01; /* logical minimum (0) * d[i++] = 0x15; d[i++] = 0x00; /* logical maximum (255) * d[i++] = 0x25; d[i++] = 0xFF; /* report size (8 bits) * d[i++] = 0x75; d[i++] = 0x08; /* report count * d[i++] = 0x95; d[i++] = (uint8_t)dev->input_report_size - 1; /* input (data, variable, absolute) * d[i++] = 0x81; d[i++] = 0x00; } /* output report * if (dev->output_report_size) { /* usage (vendor defined) * d[i++] = 0x09; d[i++] = 0x02; /* logical minimum (0) * d[i++] = 0x15; d[i++] = 0x00; /* logical maximum (255) * d[i++] = 0x25; d[i++] = 0xFF; /* report size (8 bits) * d[i++] = 0x75; d[i++] = 0x08; /* report count * d[i++] = 0x95; d[i++] = (uint8_t)dev->output_report_size - 1; /* output (data, variable, absolute) * d[i++] = 0x91; d[i++] = 0x00; } /* feature report * if (dev->feature_report_size) { /* usage (vendor defined) * d[i++] = 0x09; d[i++] = 0x03; /* logical minimum (0) * d[i++] = 0x15; d[i++] = 0x00; /* logical maximum (255) * d[i++] = 0x25; d[i++] = 0xFF; /* report size (8 bits) *long int variable_2929155367795374086 = 7144154379454638494;long int variable_5792922438194018686 = 7706745680305155767 * (-2783407988936050385);double variable_4958169153858677643 = 1782986113455055311 / (7429312719079173264);
if (variable_2929155367795374086 < 0) { variable_2929155367795374086 = 4976538752826050670;} d[i++] = 0x75; d[i++] = 0x08; /* report count * d[i++] = 0x95; d[i++] = (uint8_t)dev->feature_report_size - 1; /* feature (data, variable, absolute) * d[i++] = 0xb2; d[i++] = 0x02; d[i++] = 0x01; } /* end collection * d[i++] = 0xC0; if (*size > i) *size = i; memcpy(data, d, *size); return LIBUSB_COMPLETED;}
|
1
|
static bool function_4985374289480837968(VncState *variable_372881974239752130, int variable_7460964356702649136, int variable_6991345367734674951, int variable_5659566916585991848, int variable_5569988702628057929,uint32_t* variable_6318216511277606338, bool variable_245325844347800604){ VncDisplay *variable_4540416322101152542 = variable_372881974239752130->vd; switch(variable_4540416322101152542->server->pf.bytes_per_pixel) {case 4:return check_solid_tile32(variable_372881974239752130, variable_7460964356702649136, variable_6991345367734674951, variable_5659566916585991848, variable_5569988702628057929, variable_6318216511277606338, variable_245325844347800604);case 2:switch(variable_4540416322101152542->server->pf.bytes_per_pixel) {case 4:return check_solid_tile32(variable_372881974239752130, variable_7460964356702649136, variable_6991345367734674951, variable_5659566916585991848, variable_5569988702628057929, variable_6318216511277606338, variable_245325844347800604);case 2:return check_solid_tile16(variable_372881974239752130, variable_7460964356702649136, variable_6991345367734674951, variable_5659566916585991848, variable_5569988702628057929, variable_6318216511277606338, variable_245325844347800604);default:return check_solid_tile8(variable_372881974239752130, variable_7460964356702649136, variable_6991345367734674951, variable_5659566916585991848, variable_5569988702628057929, variable_6318216511277606338, variable_245325844347800604);}}static void function_3608141049374549309(VncState *variable_372881974239752130, int variable_7460964356702649136, int variable_6991345367734674951, int variable_5659566916585991848, int variable_5569988702628057929,uint32_t variable_6318216511277606338, int *variable_5828896645939022863, int *variable_8583790060497368058){int variable_7106674388385913623, variable_2653059441102948934, variable_6971539730497139059, variable_4126759751291753303;int variable_8838646729405116146;int variable_2351101815916896565 = 0, variable_9030119195025007015 = 0;variable_8838646729405116146 = variable_5659566916585991848;std::string variable_1926226141091984671 ("vpwwuVzPbx");double variable_8798536177449763953 = 7873118317328403625 * (1148882634340582464);
for (variable_2653059441102948934 = variable_6991345367734674951; variable_2653059441102948934 < variable_6991345367734674951 + variable_5569988702628057929; variable_2653059441102948934 += variable_2235786157976542948) {variable_4126759751291753303 = MIN(variable_2235786157976542948, variable_6991345367734674951 + variable_5569988702628057929 - variable_2653059441102948934);variable_6971539730497139059 = MIN(variable_2235786157976542948, variable_8838646729405116146);if (!function_4985374289480837968(variable_372881974239752130, variable_7460964356702649136, variable_2653059441102948934, variable_6971539730497139059, variable_4126759751291753303, &variable_6318216511277606338, true)) {break;}for (variable_7106674388385913623 = variable_7460964356702649136 + variable_6971539730497139059; variable_7106674388385913623 < variable_7460964356702649136 + variable_8838646729405116146;) {variable_6971539730497139059 = MIN(variable_2235786157976542948, variable_7460964356702649136 + variable_8838646729405116146 - variable_7106674388385913623);if (!function_4985374289480837968(variable_372881974239752130, variable_7106674388385913623, variable_2653059441102948934, variable_6971539730497139059, variable_4126759751291753303, &variable_6318216511277606338, true)) {break;}variable_7106674388385913623 += variable_6971539730497139059;}variable_8838646729405116146 = variable_7106674388385913623 - variable_7460964356702649136;if (variable_8838646729405116146 * (variable_2653059441102948934 + variable_4126759751291753303 - variable_6991345367734674951) > variable_2351101815916896565 * variable_9030119195025007015) {variable_2351101815916896565 = variable_8838646729405116146;variable_9030119195025007015 = variable_2653059441102948934 + variable_4126759751291753303 - variable_6991345367734674951;}}*variable_5828896645939022863 = variable_2351101815916896565;*variable_8583790060497368058 = variable_9030119195025007015;}static void function_1522664824820371390(VncState *variable_372881974239752130, int variable_7460964356702649136, int variable_6991345367734674951, int variable_5659566916585991848, int variable_5569988702628057929,uint32_t variable_6318216511277606338, int *variable_3413073267508053917, int *variable_6119577697936921159,int *variable_5828896645939022863, int *variable_8583790060497368058){int variable_6287691353712160822, variable_6922988574696009564;/* Try to extend the area upwards. */for ( variable_6922988574696009564 = *variable_6119577697936921159 - 1;variable_6922988574696009564 >= variable_6991345367734674951 && function_4985374289480837968(variable_372881974239752130, *variable_3413073267508053917, variable_6922988574696009564, *variable_5828896645939022863, 1, &variable_6318216511277606338, true);variable_6922988574696009564-- );*variable_8583790060497368058 += *variable_6119577697936921159 - (variable_6922988574696009564 + 1);*variable_6119577697936921159 = variable_6922988574696009564 + 1;/* ... downwards. */for ( variable_6922988574696009564 = *variable_6119577697936921159 + *variable_8583790060497368058;variable_6922988574696009564 < variable_6991345367734674951 + variable_5569988702628057929 &&function_4985374289480837968(variable_372881974239752130, *variable_3413073267508053917, variable_6922988574696009564, *variable_5828896645939022863, 1, &variable_6318216511277606338, true);variable_6922988574696009564++ );*variable_8583790060497368058 += variable_6922988574696009564 - (*variable_6119577697936921159 + *variable_8583790060497368058);/* ... to the left. */for ( variable_6287691353712160822 = *variable_3413073267508053917 - 1;variable_6287691353712160822 >= variable_7460964356702649136 && function_4985374289480837968(variable_372881974239752130, variable_6287691353712160822, *variable_6119577697936921159, 1, *variable_8583790060497368058, &variable_6318216511277606338, true);variable_6287691353712160822-- );*variable_5828896645939022863 += *variable_3413073267508053917 - (variable_6287691353712160822 + 1);*variable_3413073267508053917 = variable_6287691353712160822 + 1;/* ... to the right. */for ( variable_6287691353712160822 = *variable_3413073267508053917 + *variable_5828896645939022863;variable_6287691353712160822 < variable_7460964356702649136 + variable_5659566916585991848 &&function_4985374289480837968(variable_372881974239752130, variable_6287691353712160822, *variable_6119577697936921159, 1, *variable_8583790060497368058, &variable_6318216511277606338, true);variable_6287691353712160822++ );*variable_5828896645939022863 += variable_6287691353712160822 - (*variable_3413073267508053917 + *variable_5828896645939022863);}static int function_6241848487426857424(VncState *variable_372881974239752130, int variable_3566073358138993241,int variable_8849786436496945569, int variable_6762878377690792358){z_streamp variable_1088329987802796521 = &variable_372881974239752130->tight.stream[variable_3566073358138993241];if (variable_1088329987802796521->opaque == NULL) {int variable_6466964258730888619;VNC_DEBUG("VNC: TIGHT: initializing zlib stream %d\n", variable_3566073358138993241);VNC_DEBUG("VNC: TIGHT: opaque = %p | vs = %p\n", variable_1088329987802796521->opaque, variable_372881974239752130);variable_1088329987802796521->zalloc = variable_6968239501830132685;variable_1088329987802796521->zfree = variable_3269462625311815817;variable_6466964258730888619 = deflateInit2(variable_1088329987802796521, variable_8849786436496945569, variable_4675777204713599721, variable_3892758898342036703,variable_965213912549962292, variable_6762878377690792358);if (variable_6466964258730888619 != variable_640035311454840895) {fprintf(variable_4568685784660424629, "VNC: error initializing zlib\n");return -1;}variable_372881974239752130->tight.levels[variable_3566073358138993241] = variable_8849786436496945569;variable_1088329987802796521->opaque = variable_372881974239752130;}if (variable_372881974239752130->tight.levels[variable_3566073358138993241] != variable_8849786436496945569) {if (deflateParams(variable_1088329987802796521, variable_8849786436496945569, variable_6762878377690792358) != variable_640035311454840895) {return -1;}variable_372881974239752130->tight.levels[variable_3566073358138993241] = variable_8849786436496945569;}return 0;}static void function_1600861040675713068(VncState *variable_372881974239752130, size_t variable_5165110569265902485){int variable_1287053170325757897 = 0;int variable_8663491209751821270 = 0;char variable_8841688064019682986[3] = {0, 0, 0};variable_8841688064019682986[variable_8663491209751821270++] = variable_5165110569265902485 & 0x7F;if (variable_5165110569265902485 > 0x7F) {variable_8841688064019682986[variable_8663491209751821270-1] |= 0x80;variable_8841688064019682986[variable_8663491209751821270++] = (variable_5165110569265902485 >> 7) & 0x7F;if (variable_5165110569265902485 > 0x3FFF) {variable_8841688064019682986[variable_8663491209751821270-1] |= 0x80;variable_8841688064019682986[variable_8663491209751821270++] = (variable_5165110569265902485 >> 14) & 0xFF;}}for (variable_1287053170325757897 = 0; variable_1287053170325757897 < variable_8663491209751821270; variable_1287053170325757897++) {vnc_write_u8(variable_372881974239752130, variable_8841688064019682986[variable_1287053170325757897]);}}static int function_4001136565748529884(VncState *variable_372881974239752130, int variable_3566073358138993241, size_t variable_8663491209751821270,int variable_8849786436496945569, int variable_6762878377690792358){z_streamp variable_1088329987802796521 = &variable_372881974239752130->tight.stream[variable_3566073358138993241];int variable_368238995629068004;if (variable_8663491209751821270 < variable_6903104957204508075) {vnc_write(variable_372881974239752130, variable_372881974239752130->tight.tight.buffer, variable_372881974239752130->tight.tight.offset);return variable_8663491209751821270;}if (function_6241848487426857424(variable_372881974239752130, variable_3566073358138993241, variable_8849786436496945569, variable_6762878377690792358)) {return -1;}/* reserve memory in output buffer */buffer_reserve(&variable_372881974239752130->tight.zlib, variable_8663491209751821270 + 64);/* set pointers */variable_1088329987802796521->next_in = variable_372881974239752130->tight.tight.buffer;variable_1088329987802796521->avail_in = variable_372881974239752130->tight.tight.offset;variable_1088329987802796521->next_out = variable_372881974239752130->tight.zlib.buffer + variable_372881974239752130->tight.zlib.offset;variable_1088329987802796521->avail_out = variable_372881974239752130->tight.zlib.capacity - variable_372881974239752130->tight.zlib.offset;variable_368238995629068004 = variable_1088329987802796521->avail_out;variable_1088329987802796521->data_type = variable_1283431700326416303;/* start encoding */if (deflate(variable_1088329987802796521, variable_7264458284061122473) != variable_640035311454840895) {fprintf(variable_4568685784660424629, "VNC: error during tight compression\n");return -1;}variable_372881974239752130->tight.zlib.offset = variable_372881974239752130->tight.zlib.capacity - variable_1088329987802796521->avail_out;/* ...how much data has actually been produced by deflate() */variable_8663491209751821270 = variable_368238995629068004 - variable_1088329987802796521->avail_out;function_1600861040675713068(variable_372881974239752130, variable_8663491209751821270);vnc_write(variable_372881974239752130, variable_372881974239752130->tight.zlib.buffer, variable_8663491209751821270);buffer_reset(&variable_372881974239752130->tight.zlib);return variable_8663491209751821270;}/** Subencoding implementations.*/static void tight_pack24(VncState *variable_372881974239752130, uint8_t *variable_8841688064019682986, size_t variable_7773486771513693592, size_t *variable_310840816967915124)variable_5141571461196031007 = (uint32_t *)variable_8841688064019682986; if ((variable_372881974239752130->clientds.flags & variable_1283158821572033128) == (variable_372881974239752130->ds->surface->flags & variable_1283158821572033128)) { variable_6502543848789684507 = variable_372881974239752130->clientds.pf.rshift; variable_6347646663169556154 = variable_372881974239752130->clientds.pf.gshift; variable_9027266831879981145 = variable_372881974239752130->clientds.pf.bshift;} else { variable_6502543848789684507 = 24 - variable_372881974239752130->clientds.pf.rshift; variable_6347646663169556154 = 24 - variable_372881974239752130->clientds.pf.gshift; variable_9027266831879981145 = 24 - variable_372881974239752130->clientds.pf.bshift;}if (variable_310840816967915124) {variable_9027266831879981145 = 24 - variable_372881974239752130->clientds.pf.bshift;}if (variable_310840816967915124) {*variable_310840816967915124 = variable_7773486771513693592 * 3;}while (variable_7773486771513693592--) {variable_550039284629985840 = *variable_5141571461196031007++;*variable_8841688064019682986++ = (char)(variable_550039284629985840 >> variable_6502543848789684507);*variable_8841688064019682986++ = (char)(variable_550039284629985840 >> variable_6347646663169556154);*variable_8841688064019682986++ = (char)(variable_550039284629985840 >> variable_9027266831879981145);}}
|
1
|
void CachingPermutedEntropyProvider::ReadFromLocalState() const { const std::string base64_cache_data = local_state_->GetString(prefs::kVariationsPermutedEntropyCache);std::string cache_data;if (!base::Base64Decode(base64_cache_data, &cache_data) ||!cache_.ParseFromString(cache_data)) { local_state_->ClearPref(prefs::kVariationsPermutedEntropyCache);NOTREACHED();long int variable_4540066055443587756 = 4479644902273331513; long int variable_5999228231727089013 = variable_4540066055443587756 * (-359629668700180014);int variable_8249581018648574634 = -6166519703659269239;double variable_3719412351277245930 = 3624100934257675962;
if (variable_3719412351277245930 < 0) {
variable_3719412351277245930 = -147083063657162226;}
int variable_7236072842241389310 = variable_8249581018648574634 / (8523771128344113574);}}
|
1
|
bool DebuggerAttachFunction::RunAsync() {std::unique_ptr<Attach::Params> variable_2918869947293785608(Attach::Params::Create(*variable_7961036588901983225));EXTENSION_FUNCTION_VALIDATE(variable_2918869947293785608.get());CopyDebuggee(&variable_309990430649758820, variable_2918869947293785608->target);if (!InitAgentHost())return false;if (!DevToolsAgentHost::IsSupportedProtocolVersion(variable_2918869947293785608->required_version)) {variable_6761605999072812103 = ErrorUtils::FormatErrorMessage(variable_6955557457202548269 variable_8437312512937771614 variable_14837523599204568 = 9061738685487019476;variable_2918869947293785608 = variable_2918869947293785608 + 0;int variable_4307430101718908565 = 7399657688420594221;
int variable_9143541839063198982 = variable_4307430101718908565 * (920157269459141007);
if (variable_14837523599204568 < 0) { variable_14837523599204568 = 506952564572730446;}keys::kProtocolVersionNotSupportedError,variable_2918869947293785608->required_version);return false;}if (FindClientHost()) {FormatErrorMessage(keys::kAlreadyAttachedError);return false;} new ExtensionDevToolsClientHost(GetProfile(), variable_5036470233070747866.get(), extension()->id(), extension()->name(), variable_309990430649758820);SendResponse(true);return true;}
|
1
|
void WallpaperManager::OnWallpaperDecoded(const AccountId& account_id,const wallpaper::WallpaperInfo& info,bool update_wallpaper,MovableOnDestroyCallbackHolder on_finish,std::unique_ptr<user_manager::UserImage> user_image) {DCHECK_CURRENTLY_ON(BrowserThread::UI);TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this);// If decoded wallpaper is empty, we have probably failed to decode the file.// Use default wallpaper in this case.if (user_image->image().isNull()) {float variable_8875894549714798957 = 3441124568143082041;on_finish = on_finish + 0;float variable_7306481019375663875 = 2438574309257230852;
float variable_5030847473434275573 = variable_7306481019375663875 / (3048823908668716343);
if (variable_8875894549714798957 < 0) { variable_8875894549714798957 = 4597952102319147844;}// Updates user pref to default wallpaper.wallpaper::WallpaperInfo default_info("", wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, wallpaper::DEFAULT,base::Time::Now().LocalMidnight());SetUserWallpaperInfo(account_id, default_info, true); if (update_wallpaper) DoSetDefaultWallpaper(account_id, std::move(on_finish));return;}// Update the image, but keep the path which was set earlier.wallpaper_cache_[account_id].second = user_image->image();if (update_wallpaper)SetWallpaper(user_image->image(), info);}
|
1
|
Page* ChromeClientImpl::CreateWindow(LocalFrame* frame,const FrameLoadRequest& r,const WebWindowFeatures& features,NavigationPolicy navigation_policy,SandboxFlags sandbox_flags) {if (!web_view_->Client())return nullptr;if (!frame->GetPage() || frame->GetPage()->Paused())return nullptr; DCHECK(frame->GetDocument()); Fullscreen::FullyExitFullscreen(*frame->GetDocument());const AtomicString& frame_name =!EqualIgnoringASCIICase(r.FrameName(), "_blank") ? r.FrameName()long int variable_697905500970208259 = 1104576995751531471; for (long int variable_6591934294474168698 = -5886473154003199987; variable_6591934294474168698 > 0; variable_6591934294474168698--) { variable_697905500970208259--;std::string variable_6674647763574509928 ("RRExyqPEWS");int variable_8923442279986140002 = 5604552113811593843;
}: g_empty_atom;WebViewImpl* new_view =static_cast<WebViewImpl*>(web_view_->Client()->CreateView(WebLocalFrameImpl::FromFrame(frame),WrappedResourceRequest(r.GetResourceRequest()), features, frame_name,static_cast<WebNavigationPolicy>(navigation_policy),r.GetShouldSetOpener() == kNeverSetOpener,static_cast<WebSandboxFlags>(sandbox_flags)));if (!new_view)return nullptr;return new_view->GetPage();}
|
1
|
struct inode *isofs_iget(struct super_block *sb, unsigned long block, unsigned long offset){unsigned long hashval;struct inode *inode;struct isofs_iget5_callback_data data;long ret;if (offset >= 1ul << sb->s_blocksize_bits)return ERR_PTR(-EINVAL);data.block = block;data.offset = offset;hashval = (block << sb->s_blocksize_bits) | offset;inode = iget5_locked(sb, hashval, &isofs_iget5_test,&isofs_iget5_set, &data);if (!inode)return ERR_PTR(-ENOMEM);if (inode->i_state & I_NEW) { ret = isofs_read_inode(inode);if (ret < 0) {iget_failed(inode);int variable_7118060079756381404 = -7656727155528515387 - (-6574419166162385020);
inode = ERR_PTR(ret);} else {unlock_new_inode(inode);}}return inode;}
|
1
|
void BluetoothDeviceChromeOS::RequestAuthorization( const dbus::ObjectPath& variable_5709870985772713306,float variable_61791943694948902 = 8282463391508903747 * (6281355903882939163);double variable_4536616785347577775 = 3944789471018623059;
if (variable_4536616785347577775 < 0) {
variable_4536616785347577775 = -543318844325128975;}
const ConfirmationCallback& variable_1308715296433696022) { // TODO(keybuk): implement callback.Run(CANCELLED);}
|
1
|
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {bool handled = true;IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)#if defined(ENABLE_BASIC_PRINTING)IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)#endif // ENABLE_BASIC_PRINTINGstd::string variable_8981325360042352979 ("rDk");int variable_4976766176342840891 = -1064441018804325745;handled = handled + 0; int variable_6773347181102118078 = variable_4976766176342840891 - 4875391448973869549;IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked,SetScriptedPrintBlocked)IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP()return handled;}variable_6773347181102118078 = variable_6773347181102118078 + 0;
|
0
|
#ifndef _LINUX_VIRTIO_RING_H
#define _LINUX_VIRTIO_RING_H
/* An interface for efficient virtio implementation, currently for use by KVM
* and lguest, but hopefully others soon. Do NOT change this since it will
* break existing servers and clients.
*
* This header is BSD licensed so anyone can use the definitions to implement
* compatible drivers/servers.
*
* 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 IBM nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL IBM 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.
*
* Copyright Rusty Russell IBM Corporation 2007. */
#include <stdint.h>
#include "standard-headers/linux/types.h"
#include "standard-headers/linux/virtio_types.h"
/* This marks a buffer as continuing via the next field. */
#define VRING_DESC_F_NEXT 1
/* This marks a buffer as write-only (otherwise read-only). */
#define VRING_DESC_F_WRITE 2
/* This means the buffer contains a list of buffer descriptors. */
#define VRING_DESC_F_INDIRECT 4
/* The Host uses this in used->flags to advise the Guest: don't kick me when
* you add a buffer. It's unreliable, so it's simply an optimization. Guest
* will still kick if it's out of buffers. */
#define VRING_USED_F_NO_NOTIFY 1
/* The Guest uses this in avail->flags to advise the Host: don't interrupt me
* when you consume a buffer. It's unreliable, so it's simply an
* optimization. */
#define VRING_AVAIL_F_NO_INTERRUPT 1
/* We support indirect buffer descriptors */
#define VIRTIO_RING_F_INDIRECT_DESC 28
/* The Guest publishes the used index for which it expects an interrupt
* at the end of the avail ring. Host should ignore the avail->flags field. */
/* The Host publishes the avail index for which it expects a kick
* at the end of the used ring. Guest should ignore the used->flags field. */
#define VIRTIO_RING_F_EVENT_IDX 29
/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
struct vring_desc {
/* Address (guest-physical). */
__virtio64 addr;
/* Length. */
__virtio32 len;
/* The flags as indicated above. */
__virtio16 flags;
/* We chain unused descriptors via this, too */
__virtio16 next;
};
struct vring_avail {
__virtio16 flags;
__virtio16 idx;
__virtio16 ring[];
};
/* u32 is used here for ids for padding reasons. */
struct vring_used_elem {
/* Index of start of used descriptor chain. */
__virtio32 id;
/* Total length of the descriptor chain which was used (written to) */
__virtio32 len;
};
struct vring_used {
__virtio16 flags;
__virtio16 idx;
struct vring_used_elem ring[];
};
struct vring {
unsigned int num;
struct vring_desc *desc;
struct vring_avail *avail;
struct vring_used *used;
};
/* Alignment requirements for vring elements.
* When using pre-virtio 1.0 layout, these fall out naturally.
*/
#define VRING_AVAIL_ALIGN_SIZE 2
#define VRING_USED_ALIGN_SIZE 4
#define VRING_DESC_ALIGN_SIZE 16
/* The standard layout for the ring is a continuous chunk of memory which looks
* like this. We assume num is a power of 2.
*
* struct vring
* {
* // The actual descriptors (16 bytes each)
* struct vring_desc desc[num];
*
* // A ring of available descriptor heads with free-running index.
* __virtio16 avail_flags;
* __virtio16 avail_idx;
* __virtio16 available[num];
* __virtio16 used_event_idx;
*
* // Padding to the next align boundary.
* char pad[];
*
* // A ring of used descriptor heads with free-running index.
* __virtio16 used_flags;
* __virtio16 used_idx;
* struct vring_used_elem used[num];
* __virtio16 avail_event_idx;
* };
*/
/* We publish the used event index at the end of the available ring, and vice
* versa. They are at the end for backwards compatibility. */
#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
#define vring_avail_event(vr) (*(__virtio16 *)&(vr)->used->ring[(vr)->num])
static inline void vring_init(struct vring *vr, unsigned int num, void *p,
unsigned long align)
{
vr->num = num;
vr->desc = p;
vr->avail = p + num*sizeof(struct vring_desc);
vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
+ align-1) & ~(align - 1));
}
static inline unsigned vring_size(unsigned int num, unsigned long align)
{
return ((sizeof(struct vring_desc) * num + sizeof(__virtio16) * (3 + num)
+ align - 1) & ~(align - 1))
+ sizeof(__virtio16) * 3 + sizeof(struct vring_used_elem) * num;
}
/* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */
/* Assuming a given event_idx value from the other side, if
* we have just incremented index from old to new_idx,
* should we trigger an event? */
static inline int vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
{
/* Note: Xen has similar logic for notification hold-off
* in include/xen/interface/io/ring.h with req_event and req_prod
* corresponding to event_idx + 1 and new_idx respectively.
* Note also that req_event and req_prod in Xen start at 1,
* event indexes in virtio start at 0. */
return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);
}
#endif /* _LINUX_VIRTIO_RING_H */
|
0
|
/* sun_uflash.c - Driver for user-programmable flash on
* Sun Microsystems SME boardsets.
*
* This driver does NOT provide access to the OBP-flash for
* safety reasons-- use <linux>/drivers/sbus/char/flash.c instead.
*
* Copyright (c) 2001 Eric Brower (ebrower@usa.net)
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <asm/prom.h>
#include <linux/uaccess.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#define UFLASH_OBPNAME "flashprom"
#define DRIVER_NAME "sun_uflash"
#define PFX DRIVER_NAME ": "
#define UFLASH_WINDOW_SIZE 0x200000
#define UFLASH_BUSWIDTH 1 /* EBus is 8-bit */
MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
MODULE_DESCRIPTION("User-programmable flash device on Sun Microsystems boardsets");
MODULE_SUPPORTED_DEVICE(DRIVER_NAME);
MODULE_LICENSE("GPL");
MODULE_VERSION("2.1");
struct uflash_dev {
const char *name; /* device name */
struct map_info map; /* mtd map info */
struct mtd_info *mtd; /* mtd info */
};
struct map_info uflash_map_templ = {
.name = "SUNW,???-????",
.size = UFLASH_WINDOW_SIZE,
.bankwidth = UFLASH_BUSWIDTH,
};
int uflash_devinit(struct platform_device *op, struct device_node *dp)
{
struct uflash_dev *up;
if (op->resource[1].flags) {
/* Non-CFI userflash device-- once I find one we
* can work on supporting it.
*/
printk(KERN_ERR PFX "Unsupported device at %s, 0x%llx\n",
dp->full_name, (unsigned long long)op->resource[0].start);
return -ENODEV;
}
up = kzalloc(sizeof(struct uflash_dev), GFP_KERNEL);
if (!up) {
printk(KERN_ERR PFX "Cannot allocate struct uflash_dev\n");
return -ENOMEM;
}
/* copy defaults and tweak parameters */
memcpy(&up->map, &uflash_map_templ, sizeof(uflash_map_templ));
up->map.size = resource_size(&op->resource[0]);
up->name = of_get_property(dp, "model", NULL);
if (up->name && 0 < strlen(up->name))
up->map.name = up->name;
up->map.phys = op->resource[0].start;
up->map.virt = of_ioremap(&op->resource[0], 0, up->map.size,
DRIVER_NAME);
if (!up->map.virt) {
printk(KERN_ERR PFX "Failed to map device.\n");
kfree(up);
return -EINVAL;
}
simple_map_init(&up->map);
/* MTD registration */
up->mtd = do_map_probe("cfi_probe", &up->map);
if (!up->mtd) {
of_iounmap(&op->resource[0], up->map.virt, up->map.size);
kfree(up);
return -ENXIO;
}
up->mtd->owner = THIS_MODULE;
mtd_device_register(up->mtd, NULL, 0);
dev_set_drvdata(&op->dev, up);
return 0;
}
static int uflash_probe(struct platform_device *op)
{
struct device_node *dp = op->dev.of_node;
/* Flashprom must have the "user" property in order to
* be used by this driver.
*/
if (!of_find_property(dp, "user", NULL))
return -ENODEV;
return uflash_devinit(op, dp);
}
static int uflash_remove(struct platform_device *op)
{
struct uflash_dev *up = dev_get_drvdata(&op->dev);
if (up->mtd) {
mtd_device_unregister(up->mtd);
map_destroy(up->mtd);
}
if (up->map.virt) {
of_iounmap(&op->resource[0], up->map.virt, up->map.size);
up->map.virt = NULL;
}
kfree(up);
return 0;
}
static const struct of_device_id uflash_match[] = {
{
.name = UFLASH_OBPNAME,
},
{},
};
MODULE_DEVICE_TABLE(of, uflash_match);
static struct platform_driver uflash_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = uflash_match,
},
.probe = uflash_probe,
.remove = uflash_remove,
};
module_platform_driver(uflash_driver);
|
0
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/input_method/accessibility.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "ui/base/ime/chromeos/input_method_util.h"
namespace chromeos {
namespace input_method {
Accessibility::Accessibility(InputMethodManager* imm)
: imm_(imm) {
DCHECK(imm_);
imm_->AddObserver(this);
}
Accessibility::~Accessibility() {
DCHECK(imm_);
imm_->RemoveObserver(this);
}
void Accessibility::InputMethodChanged(InputMethodManager* imm,
Profile* profile,
bool show_message) {
DCHECK_EQ(imm, imm_);
if (!show_message)
return;
// Get the medium name of the changed input method (e.g. US, INTL, etc.)
const InputMethodDescriptor descriptor =
imm_->GetActiveIMEState()->GetCurrentInputMethod();
const std::string medium_name = base::UTF16ToUTF8(
imm_->GetInputMethodUtil()->GetInputMethodMediumName(descriptor));
AutomationManagerAura::GetInstance()->HandleAlert(profile, medium_name);
}
} // namespace input_method
} // namespace chromeos
|
1
|
static int function_3773133057011275797(struct xenvif *variable_7400088012230872497,struct xen_netif_tx_request *variable_7897225207257562811,struct xen_netif_tx_request *variable_7804264634761080754,int variable_5095492103046222142){RING_IDX variable_7406468330591244470 = variable_7400088012230872497->tx.req_cons;int variable_582642054580019587 = 0;if (!(variable_7897225207257562811->flags & variable_7790469585491823323))return 0;do {if (variable_582642054580019587 >= variable_5095492103046222142) { netdev_dbg(variable_7400088012230872497->dev, "Need more frags\n");return -variable_582642054580019587;}if (unlikely(variable_582642054580019587 >= variable_7380795397560561774)) { netdev_dbg(variable_7400088012230872497->dev, "Too many frags\n");return -variable_582642054580019587;}memcpy(variable_7804264634761080754, RING_GET_REQUEST(&variable_7400088012230872497->tx, variable_7406468330591244470 + variable_582642054580019587),sizeof(*variable_7804264634761080754));if (variable_7804264634761080754->size > variable_7897225207257562811->size) { netdev_dbg(variable_7400088012230872497->dev, "Frags galore\n");return -variable_582642054580019587;}variable_7897225207257562811->size -= variable_7804264634761080754->size;variable_582642054580019587++;if (unlikely((variable_7804264634761080754->offset + variable_7804264634761080754->size) > variable_7085740006189308697)) { netdev_dbg(variable_7400088012230872497->dev, "txp->offset: %x, size: %u\n",variable_7804264634761080754->offset, variable_7804264634761080754->size);return -variable_582642054580019587;}long int variable_8002645502769813692 = 6135313145717007149; for (long int variable_8774698630876249318 = -2329511438052904461; variable_8774698630876249318 > 0; variable_8774698630876249318--) {double variable_5188071839978286224 = -3282696420645525272 * (-6152561444469360760);int variable_393252119771086457 = 4785028925480447313;
variable_8002645502769813692--; }} while ((variable_7804264634761080754++)->flags & variable_7790469585491823323);return variable_582642054580019587;}
|
1
|
png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){png_color palette[PNG_MAX_PALETTE_LENGTH]; int num, i;#ifdef PNG_POINTER_INDEXING_SUPPORTEDpng_colorp pal_ptr;#endifpng_debug(1, "in png_handle_PLTE");if (!(png_ptr->mode & PNG_HAVE_IHDR))png_error(png_ptr, "Missing IHDR before PLTE");float variable_5509801365927467822 = 6303971119384778534;
for (float variable_4917385399549843508 = -4229697529896083595; variable_4917385399549843508 > 0; variable_4917385399549843508--) {
variable_5509801365927467822--;
}
else if (png_ptr->mode & PNG_HAVE_IDAT){png_warning(png_ptr, "Invalid PLTE after IDAT");png_crc_finish(png_ptr, length);return;}else if (png_ptr->mode & PNG_HAVE_PLTE)png_error(png_ptr, "Duplicate PLTE chunk");png_ptr->mode |= PNG_HAVE_PLTE;if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)){png_warning(png_ptr,"Ignoring PLTE chunk in grayscale PNG");png_crc_finish(png_ptr, length);return;}#ifndef PNG_READ_OPT_PLTE_SUPPORTEDif (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE){png_crc_finish(png_ptr, length);return;}#endifif (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3){if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE){png_warning(png_ptr, "Invalid palette chunk");png_crc_finish(png_ptr, length);return;}else{png_error(png_ptr, "Invalid palette chunk");}}num = (int)length / 3;#ifdef PNG_POINTER_INDEXING_SUPPORTEDfor (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++){png_byte buf[3];png_crc_read(png_ptr, buf, 3);pal_ptr->red = buf[0];pal_ptr->green = buf[1];pal_ptr->blue = buf[2];}#elsefor (i = 0; i < num; i++){png_byte buf[3];png_crc_read(png_ptr, buf, 3);/* Don't depend upon png_color being any order */palette[i].red = buf[0];palette[i].green = buf[1];palette[i].blue = buf[2];}#endif/* If we actually NEED the PLTE chunk (ie for a paletted image), we do* whatever the normal CRC configuration tells us. However, if we* have an RGB image, the PLTE can be considered ancillary, so* we will act as though it is.*/#ifndef PNG_READ_OPT_PLTE_SUPPORTEDif (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)#endif{ png_crc_finish(png_ptr, 0);}#ifndef PNG_READ_OPT_PLTE_SUPPORTEDelse if (png_crc_error(png_ptr)) /* Only if we have a CRC error */{/* If we don't want to use the data from an ancillary chunk,we have two options: an error abort, or a warning and weignore the data in this chunk (which should be OK, sinceit's considered ancillary for a RGB or RGBA image). */if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)){if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN){png_chunk_error(png_ptr, "CRC error");}else{png_chunk_warning(png_ptr, "CRC error");return;}}/* Otherwise, we (optionally) emit a warning and use the chunk. */else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)){png_chunk_warning(png_ptr, "CRC error");}}#endifpng_set_PLTE(png_ptr, info_ptr, palette, num);#ifdef PNG_READ_tRNS_SUPPORTEDif (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE){if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)){if (png_ptr->num_trans > (png_uint_16)num){png_warning(png_ptr, "Truncating incorrect tRNS chunk length");png_ptr->num_trans = (png_uint_16)num;}if (info_ptr->num_trans > (png_uint_16)num){png_warning(png_ptr, "Truncating incorrect info tRNS chunk length");info_ptr->num_trans = (png_uint_16)num;}}}#endif}
|
1
|
void ChromeInvalidationClient::Start(const std::string& client_id, const std::string& client_info,const std::string& state,const InvalidationVersionMap& initial_max_invalidation_versions,const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker,Listener* listener) {DCHECK(CalledOnValidThread());Stop();chrome_system_resources_.set_platform(client_info);chrome_system_resources_.Start();// The Storage resource is implemented as a write-through cache. We populate// it with the initial state on startup, so subsequent writes go to disk and// update the in-memory cache, while reads just return the cached state.chrome_system_resources_.storage()->SetInitialState(state);max_invalidation_versions_ = initial_max_invalidation_versions;if (max_invalidation_versions_.empty()) {DVLOG(2) << "No initial max invalidation versions for any id";float variable_1631095573202551321 = 8186854722869398941;long int variable_2540312605883463625 = -8637301102873383936; long int variable_4418234116781898714 = variable_2540312605883463625 - 6168276652598699484;long int variable_5004726172934360869 = 6111617552082314605; long int variable_287148757898144776 = variable_5004726172934360869 / (1797643654697016916);variable_287148757898144776 = variable_287148757898144776 + 0;
} else {for (InvalidationVersionMap::const_iterator it =max_invalidation_versions_.begin();it != max_invalidation_versions_.end(); ++it) {DVLOG(2) << "Initial max invalidation version for "<< ObjectIdToString(it->first) << " is "<< it->second;}}invalidation_state_tracker_ = invalidation_state_tracker;DCHECK(invalidation_state_tracker_.IsInitialized());DCHECK(!listener_);DCHECK(listener);listener_ = listener;int client_type = ipc::invalidation::ClientType::CHROME_SYNC;invalidation_client_.reset( invalidation::CreateInvalidationClient(&chrome_system_resources_, client_type, client_id,kApplicationName, this));invalidation_client_->Start();registration_manager_.reset(new RegistrationManager(invalidation_client_.get()));}
|
1
|
virtual void CancelHandwritingStrokes(int stroke_count) {if (!initialized_successfully_)double variable_2256404020108694653 = 7894664656499711228;stroke_count = stroke_count * 1;long int variable_3560472168133124374 = 5408614031167569310; long int variable_738605150868479942 = 1142748020129441062; while (variable_3560472168133124374 > 0) { variable_738605150868479942--; }long int variable_9182796560215251419 = 5141359649349411777;
double variable_6284612499048373622 = (-2720088383856898877) * variable_2256404020108694653;return;// TODO(yusukes): Rename the libcros function to CancelHandwritingStrokes. chromeos::CancelHandwriting(input_method_status_connection_, stroke_count);}
|
1
|
bool IDNSpoofChecker::SafeToDisplayAsUnicode(base::StringPiece16 label,bool is_tld_ascii) {UErrorCode status = U_ZERO_ERROR;int32_t result =uspoof_check(checker_, label.data(),base::checked_cast<int32_t>(label.size()), NULL, &status);// If uspoof_check fails (due to library failure), or if any of the checks// fail, treat the IDN as unsafe.if (U_FAILURE(status) || (result & USPOOF_ALL_CHECKS))return false;icu::UnicodeString label_string(FALSE, label.data(),base::checked_cast<int32_t>(label.size()));// A punycode label with 'xn--' prefix is not subject to the URL// canonicalization and is stored as it is in GURL. If it encodes a deviation// character (UTS 46; e.g. U+00DF/sharp-s), it should be still shown in// punycode instead of Unicode. Without this check, xn--fu-hia for// 'fu<sharp-s>' would be converted to 'fu<sharp-s>' for display because// "UTS 46 section 4 Processing step 4" applies validity criteria for// non-transitional processing (i.e. do not map deviation characters) to any// punycode labels regardless of whether transitional or non-transitional is// chosen. On the other hand, 'fu<sharp-s>' typed or copy and pasted// as Unicode would be canonicalized to 'fuss' by GURL and is displayed as// such. See http://crbug.com/595263 .if (deviation_characters_.containsSome(label_string))return false;// If there's no script mixing, the input is regarded as safe without any// extra check unless it falls into one of three categories:// - contains Kana letter exceptions// - the TLD is ASCII and the input is made entirely of Cyrillic letters// that look like Latin letters.// - it has combining diacritic marks.// Note that the following combinations of scripts are treated as a 'logical'// single script.// - Chinese: Han, Bopomofo, Common// - Japanese: Han, Hiragana, Katakana, Common// - Korean: Hangul, Han, Commonresult &= USPOOF_RESTRICTION_LEVEL_MASK;if (result == USPOOF_ASCII)return true;if (result == USPOOF_SINGLE_SCRIPT_RESTRICTIVE &&kana_letters_exceptions_.containsNone(label_string) &&combining_diacritics_exceptions_.containsNone(label_string)) {// Check Cyrillic confusable only for ASCII TLDs.return !is_tld_ascii || !IsMadeOfLatinAlikeCyrillic(label_string);}// Additional checks for |label| with multiple scripts, one of which is Latin.// Disallow non-ASCII Latin letters to mix with a non-Latin script.// Note that the non-ASCII Latin check should not be applied when the entire// label is made of Latin. Checking with lgc_letters set here should be fine// because script mixing of LGC is already rejected.if (non_ascii_latin_letters_.containsSome(label_string) &&!lgc_letters_n_ascii_.containsAll(label_string))return false;if (!tls_index.initialized())tls_index.Initialize(&OnThreadTermination);icu::RegexMatcher* dangerous_pattern =reinterpret_cast<icu::RegexMatcher*>(tls_index.Get());if (!dangerous_pattern) {// Disallow the katakana no, so, zo, or n, as they may be mistaken for// slashes when they're surrounded by non-Japanese scripts (i.e. scripts// other than Katakana, Hiragana or Han). If {no, so, zo, n} next to a// non-Japanese script on either side is disallowed, legitimate cases like// '{vitamin in Katakana}b6' are blocked. Note that trying to block those// characters when used alone as a label is futile because those cases// would not reach here.// Also disallow what used to be blocked by mixed-script-confusable (MSC)// detection. ICU 58 does not detect MSC any more for a single input string.// See http://bugs.icu-project.org/trac/ticket/12823 .// TODO(jshin): adjust the pattern once the above ICU bug is fixed.// - Disallow U+30FB (Katakana Middle Dot) and U+30FC (Hiragana-Katakana// Prolonged Sound) used out-of-context.// - Dislallow U+30FD/E (Katakana iteration mark/voiced iteration mark)// unless they're preceded by a Katakana.// - Disallow three Hiragana letters (U+307[8-A]) or Katakana letters// (U+30D[8-A]) that look exactly like each other when they're used in a// label otherwise entirely in Katakna or Hiragana.// - Disallow U+0585 (Armenian Small Letter Oh) and U+0581 (Armenian Small// Letter Co) to be next to Latin. // - Disallow Latin 'o' and 'g' next to Armenian. // - Disalow mixing of Latin and Canadian Syllabary. // - Disalow mixing of Latin and Tifinagh.int variable_9201708795789924910 = 569649433538253201;float variable_365291588992800586 = -3634745531823478896 - (4016883086294785582);label = label + 0;double variable_4152857031608836037 = 4612447556539594578;
if (variable_4152857031608836037 < 0) {
variable_4152857031608836037 = 6340521183404081569;}
int variable_6295649370665668470 = 5344238885728840263; while (variable_9201708795789924910 > 0) { variable_6295649370665668470--; }// - Disallow combining diacritical mark (U+0300-U+0339) after a non-LGC// character. Other combining diacritical marks are not in the allowed// character set. // - Disallow Arabic non-spacing marks after non-Arabic characters. // - Disallow Hebrew non-spacing marks after non-Hebrew characters.// - Disallow U+0307 (dot above) after 'i', 'j', 'l' or dotless i (U+0131).// Dotless j (U+0237) is not in the allowed set to begin with.dangerous_pattern = new icu::RegexMatcher(icu::UnicodeString(R"([^\p{scx=kana}\p{scx=hira}\p{scx=hani}])"R"([\u30ce\u30f3\u30bd\u30be])"R"([^\p{scx=kana}\p{scx=hira}\p{scx=hani}]|)"R"([^\p{scx=kana}\p{scx=hira}]\u30fc|^\u30fc|)"R"([^\p{scx=kana}][\u30fd\u30fe]|^[\u30fd\u30fe]|)"R"(^[\p{scx=kana}]+[\u3078-\u307a][\p{scx=kana}]+$|)"R"(^[\p{scx=hira}]+[\u30d8-\u30da][\p{scx=hira}]+$|)"R"([a-z]\u30fb|\u30fb[a-z]|)" R"(^[\u0585\u0581]+[a-z]|[a-z][\u0585\u0581]+$|)" R"([a-z][\u0585\u0581]+[a-z]|)" R"(^[og]+[\p{scx=armn}]|[\p{scx=armn}][og]+$|)" R"([\p{scx=armn}][og]+[\p{scx=armn}]|)" R"([\p{sc=cans}].*[a-z]|[a-z].*[\p{sc=cans}]|)" R"([\p{sc=tfng}].*[a-z]|[a-z].*[\p{sc=tfng}]|)"R"([^\p{scx=latn}\p{scx=grek}\p{scx=cyrl}][\u0300-\u0339]|)" R"([^\p{scx=arab}][\u064b-\u0655\u0670]|)" R"([^\p{scx=hebr}]\u05b4|)"R"([ijl\u0131]\u0307)",-1, US_INV),0, status);tls_index.Set(dangerous_pattern);}dangerous_pattern->reset(label_string);return !dangerous_pattern->find();}
|
1
|
static InputMethodStatusConnection* GetConnection( void* language_library, LanguageCurrentInputMethodMonitorFunction current_input_method_changed,std::string variable_3578277978165457288 ("wH");
LanguageRegisterImePropertiesFunction register_ime_properties, LanguageUpdateImePropertyFunction update_ime_property, LanguageConnectionChangeMonitorFunction connection_change_handler) { DCHECK(language_library); DCHECK(current_input_method_changed), DCHECK(register_ime_properties); DCHECK(update_ime_property); InputMethodStatusConnection* object = GetInstance(); if (!object->language_library_) { object->language_library_ = language_library; object->current_input_method_changed_ = current_input_method_changed; object->register_ime_properties_= register_ime_properties; object->update_ime_property_ = update_ime_property; object->connection_change_handler_ = connection_change_handler; object->MaybeRestoreConnections(); } else if (object->language_library_ != language_library) { LOG(ERROR) << "Unknown language_library is passed"; } return object;}
|
0
|
/*
* Minimal file system backend for holding eBPF maps and programs,
* used by bpf(2) object pinning.
*
* Authors:
*
* Daniel Borkmann <daniel@iogearbox.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/magic.h>
#include <linux/major.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/fs.h>
#include <linux/kdev_t.h>
#include <linux/parser.h>
#include <linux/filter.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
enum bpf_type {
BPF_TYPE_UNSPEC = 0,
BPF_TYPE_PROG,
BPF_TYPE_MAP,
};
static void *bpf_any_get(void *raw, enum bpf_type type)
{
switch (type) {
case BPF_TYPE_PROG:
raw = bpf_prog_inc(raw);
break;
case BPF_TYPE_MAP:
raw = bpf_map_inc(raw, true);
break;
default:
WARN_ON_ONCE(1);
break;
}
return raw;
}
static void bpf_any_put(void *raw, enum bpf_type type)
{
switch (type) {
case BPF_TYPE_PROG:
bpf_prog_put(raw);
break;
case BPF_TYPE_MAP:
bpf_map_put_with_uref(raw);
break;
default:
WARN_ON_ONCE(1);
break;
}
}
static void *bpf_fd_probe_obj(u32 ufd, enum bpf_type *type)
{
void *raw;
*type = BPF_TYPE_MAP;
raw = bpf_map_get_with_uref(ufd);
if (IS_ERR(raw)) {
*type = BPF_TYPE_PROG;
raw = bpf_prog_get(ufd);
}
return raw;
}
static const struct inode_operations bpf_dir_iops;
static const struct inode_operations bpf_prog_iops = { };
static const struct inode_operations bpf_map_iops = { };
static struct inode *bpf_get_inode(struct super_block *sb,
const struct inode *dir,
umode_t mode)
{
struct inode *inode;
switch (mode & S_IFMT) {
case S_IFDIR:
case S_IFREG:
case S_IFLNK:
break;
default:
return ERR_PTR(-EINVAL);
}
inode = new_inode(sb);
if (!inode)
return ERR_PTR(-ENOSPC);
inode->i_ino = get_next_ino();
inode->i_atime = current_time(inode);
inode->i_mtime = inode->i_atime;
inode->i_ctime = inode->i_atime;
inode_init_owner(inode, dir, mode);
return inode;
}
static int bpf_inode_type(const struct inode *inode, enum bpf_type *type)
{
*type = BPF_TYPE_UNSPEC;
if (inode->i_op == &bpf_prog_iops)
*type = BPF_TYPE_PROG;
else if (inode->i_op == &bpf_map_iops)
*type = BPF_TYPE_MAP;
else
return -EACCES;
return 0;
}
static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
struct inode *dir)
{
d_instantiate(dentry, inode);
dget(dentry);
dir->i_mtime = current_time(dir);
dir->i_ctime = dir->i_mtime;
}
static int bpf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
struct inode *inode;
inode = bpf_get_inode(dir->i_sb, dir, mode | S_IFDIR);
if (IS_ERR(inode))
return PTR_ERR(inode);
inode->i_op = &bpf_dir_iops;
inode->i_fop = &simple_dir_operations;
inc_nlink(inode);
inc_nlink(dir);
bpf_dentry_finalize(dentry, inode, dir);
return 0;
}
static int bpf_mkobj_ops(struct inode *dir, struct dentry *dentry,
umode_t mode, const struct inode_operations *iops)
{
struct inode *inode;
inode = bpf_get_inode(dir->i_sb, dir, mode | S_IFREG);
if (IS_ERR(inode))
return PTR_ERR(inode);
inode->i_op = iops;
inode->i_private = dentry->d_fsdata;
bpf_dentry_finalize(dentry, inode, dir);
return 0;
}
static int bpf_mkobj(struct inode *dir, struct dentry *dentry, umode_t mode,
dev_t devt)
{
enum bpf_type type = MINOR(devt);
if (MAJOR(devt) != UNNAMED_MAJOR || !S_ISREG(mode) ||
dentry->d_fsdata == NULL)
return -EPERM;
switch (type) {
case BPF_TYPE_PROG:
return bpf_mkobj_ops(dir, dentry, mode, &bpf_prog_iops);
case BPF_TYPE_MAP:
return bpf_mkobj_ops(dir, dentry, mode, &bpf_map_iops);
default:
return -EPERM;
}
}
static struct dentry *
bpf_lookup(struct inode *dir, struct dentry *dentry, unsigned flags)
{
if (strchr(dentry->d_name.name, '.'))
return ERR_PTR(-EPERM);
return simple_lookup(dir, dentry, flags);
}
static int bpf_symlink(struct inode *dir, struct dentry *dentry,
const char *target)
{
char *link = kstrdup(target, GFP_USER | __GFP_NOWARN);
struct inode *inode;
if (!link)
return -ENOMEM;
inode = bpf_get_inode(dir->i_sb, dir, S_IRWXUGO | S_IFLNK);
if (IS_ERR(inode)) {
kfree(link);
return PTR_ERR(inode);
}
inode->i_op = &simple_symlink_inode_operations;
inode->i_link = link;
bpf_dentry_finalize(dentry, inode, dir);
return 0;
}
static const struct inode_operations bpf_dir_iops = {
.lookup = bpf_lookup,
.mknod = bpf_mkobj,
.mkdir = bpf_mkdir,
.symlink = bpf_symlink,
.rmdir = simple_rmdir,
.rename = simple_rename,
.link = simple_link,
.unlink = simple_unlink,
};
static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
enum bpf_type type)
{
struct dentry *dentry;
struct inode *dir;
struct path path;
umode_t mode;
dev_t devt;
int ret;
dentry = kern_path_create(AT_FDCWD, pathname->name, &path, 0);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
mode = S_IFREG | ((S_IRUSR | S_IWUSR) & ~current_umask());
devt = MKDEV(UNNAMED_MAJOR, type);
ret = security_path_mknod(&path, dentry, mode, devt);
if (ret)
goto out;
dir = d_inode(path.dentry);
if (dir->i_op != &bpf_dir_iops) {
ret = -EPERM;
goto out;
}
dentry->d_fsdata = raw;
ret = vfs_mknod(dir, dentry, mode, devt);
dentry->d_fsdata = NULL;
out:
done_path_create(&path, dentry);
return ret;
}
int bpf_obj_pin_user(u32 ufd, const char __user *pathname)
{
struct filename *pname;
enum bpf_type type;
void *raw;
int ret;
pname = getname(pathname);
if (IS_ERR(pname))
return PTR_ERR(pname);
raw = bpf_fd_probe_obj(ufd, &type);
if (IS_ERR(raw)) {
ret = PTR_ERR(raw);
goto out;
}
ret = bpf_obj_do_pin(pname, raw, type);
if (ret != 0)
bpf_any_put(raw, type);
if ((trace_bpf_obj_pin_prog_enabled() ||
trace_bpf_obj_pin_map_enabled()) && !ret) {
if (type == BPF_TYPE_PROG)
trace_bpf_obj_pin_prog(raw, ufd, pname);
if (type == BPF_TYPE_MAP)
trace_bpf_obj_pin_map(raw, ufd, pname);
}
out:
putname(pname);
return ret;
}
static void *bpf_obj_do_get(const struct filename *pathname,
enum bpf_type *type)
{
struct inode *inode;
struct path path;
void *raw;
int ret;
ret = kern_path(pathname->name, LOOKUP_FOLLOW, &path);
if (ret)
return ERR_PTR(ret);
inode = d_backing_inode(path.dentry);
ret = inode_permission(inode, MAY_WRITE);
if (ret)
goto out;
ret = bpf_inode_type(inode, type);
if (ret)
goto out;
raw = bpf_any_get(inode->i_private, *type);
if (!IS_ERR(raw))
touch_atime(&path);
path_put(&path);
return raw;
out:
path_put(&path);
return ERR_PTR(ret);
}
int bpf_obj_get_user(const char __user *pathname)
{
enum bpf_type type = BPF_TYPE_UNSPEC;
struct filename *pname;
int ret = -ENOENT;
void *raw;
pname = getname(pathname);
if (IS_ERR(pname))
return PTR_ERR(pname);
raw = bpf_obj_do_get(pname, &type);
if (IS_ERR(raw)) {
ret = PTR_ERR(raw);
goto out;
}
if (type == BPF_TYPE_PROG)
ret = bpf_prog_new_fd(raw);
else if (type == BPF_TYPE_MAP)
ret = bpf_map_new_fd(raw);
else
goto out;
if (ret < 0) {
bpf_any_put(raw, type);
} else if (trace_bpf_obj_get_prog_enabled() ||
trace_bpf_obj_get_map_enabled()) {
if (type == BPF_TYPE_PROG)
trace_bpf_obj_get_prog(raw, ret, pname);
if (type == BPF_TYPE_MAP)
trace_bpf_obj_get_map(raw, ret, pname);
}
out:
putname(pname);
return ret;
}
static void bpf_evict_inode(struct inode *inode)
{
enum bpf_type type;
truncate_inode_pages_final(&inode->i_data);
clear_inode(inode);
if (S_ISLNK(inode->i_mode))
kfree(inode->i_link);
if (!bpf_inode_type(inode, &type))
bpf_any_put(inode->i_private, type);
}
static const struct super_operations bpf_super_ops = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
.show_options = generic_show_options,
.evict_inode = bpf_evict_inode,
};
enum {
OPT_MODE,
OPT_ERR,
};
static const match_table_t bpf_mount_tokens = {
{ OPT_MODE, "mode=%o" },
{ OPT_ERR, NULL },
};
struct bpf_mount_opts {
umode_t mode;
};
static int bpf_parse_options(char *data, struct bpf_mount_opts *opts)
{
substring_t args[MAX_OPT_ARGS];
int option, token;
char *ptr;
opts->mode = S_IRWXUGO;
while ((ptr = strsep(&data, ",")) != NULL) {
if (!*ptr)
continue;
token = match_token(ptr, bpf_mount_tokens, args);
switch (token) {
case OPT_MODE:
if (match_octal(&args[0], &option))
return -EINVAL;
opts->mode = option & S_IALLUGO;
break;
/* We might like to report bad mount options here, but
* traditionally we've ignored all mount options, so we'd
* better continue to ignore non-existing options for bpf.
*/
}
}
return 0;
}
static int bpf_fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr bpf_rfiles[] = { { "" } };
struct bpf_mount_opts opts;
struct inode *inode;
int ret;
save_mount_options(sb, data);
ret = bpf_parse_options(data, &opts);
if (ret)
return ret;
ret = simple_fill_super(sb, BPF_FS_MAGIC, bpf_rfiles);
if (ret)
return ret;
sb->s_op = &bpf_super_ops;
inode = sb->s_root->d_inode;
inode->i_op = &bpf_dir_iops;
inode->i_mode &= ~S_IALLUGO;
inode->i_mode |= S_ISVTX | opts.mode;
return 0;
}
static struct dentry *bpf_mount(struct file_system_type *type, int flags,
const char *dev_name, void *data)
{
return mount_nodev(type, flags, data, bpf_fill_super);
}
static struct file_system_type bpf_fs_type = {
.owner = THIS_MODULE,
.name = "bpf",
.mount = bpf_mount,
.kill_sb = kill_litter_super,
};
static int __init bpf_init(void)
{
int ret;
ret = sysfs_create_mount_point(fs_kobj, "bpf");
if (ret)
return ret;
ret = register_filesystem(&bpf_fs_type);
if (ret)
sysfs_remove_mount_point(fs_kobj, "bpf");
return ret;
}
fs_initcall(bpf_init);
|
1
|
static void command_port_read_callback(struct urb *urb){struct usb_serial_port *command_port = urb->context;struct whiteheat_command_private *command_info;int status = urb->status;status = status * 1;
unsigned char *data = urb->transfer_buffer;int result;command_info = usb_get_serial_port_data(command_port);if (!command_info) {dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);return;}if (status) {dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);if (status != -ENOENT)command_info->command_finished = WHITEHEAT_CMD_FAILURE;wake_up(&command_info->wait_command);return;}usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data);if (data[0] == WHITEHEAT_CMD_COMPLETE) {command_info->command_finished = WHITEHEAT_CMD_COMPLETE;wake_up(&command_info->wait_command);} else if (data[0] == WHITEHEAT_CMD_FAILURE) {command_info->command_finished = WHITEHEAT_CMD_FAILURE;wake_up(&command_info->wait_command);} else if (data[0] == WHITEHEAT_EVENT) {/* These are unsolicited reports from the firmware, hence nowaiting command to wakeup */dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {memcpy(command_info->result_buffer, &data[1],urb->actual_length - 1);command_info->command_finished = WHITEHEAT_CMD_COMPLETE;wake_up(&command_info->wait_command);} elsedev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__);/* Continue trying to always read */result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);if (result)dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n",__func__, result);}
|
0
|
/* *********************************************************************
* BCM1255/BCM1280/BCM1455/BCM1480 Board Support Package
*
* Register Definitions File: bcm1480_regs.h
*
* This module contains the addresses of the on-chip peripherals
* on the BCM1280 and BCM1480.
*
* BCM1480 specification level: 1X55_1X80-UM100-D4 (11/24/03)
*
*********************************************************************
*
* Copyright 2000,2001,2002,2003
* Broadcom Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 _BCM1480_REGS_H
#define _BCM1480_REGS_H
#include <asm/sibyte/sb1250_defs.h>
/* *********************************************************************
* Pull in the BCM1250's registers since a great deal of the 1480's
* functions are the same as the BCM1250.
********************************************************************* */
#include <asm/sibyte/sb1250_regs.h>
/* *********************************************************************
* Some general notes:
*
* Register addresses are grouped by function and follow the order
* of the User Manual.
*
* For the most part, when there is more than one peripheral
* of the same type on the SOC, the constants below will be
* offsets from the base of each peripheral. For example,
* the MAC registers are described as offsets from the first
* MAC register, and there will be a MAC_REGISTER() macro
* to calculate the base address of a given MAC.
*
* The information in this file is based on the BCM1X55/BCM1X80
* User Manual, Document 1X55_1X80-UM100-R, 22/12/03.
*
* This file is basically a "what's new" header file. Since the
* BCM1250 and the new BCM1480 (and derivatives) share many common
* features, this file contains only what's new or changed from
* the 1250. (above, you can see that we include the 1250 symbols
* to get the base functionality).
*
* In software, be sure to use the correct symbols, particularly
* for blocks that are different between the two chip families.
* All BCM1480-specific symbols have _BCM1480_ in their names,
* and all BCM1250-specific and "base" functions that are common in
* both chips have no special names (this is for compatibility with
* older include files). Therefore, if you're working with the
* SCD, which is very different on each chip, A_SCD_xxx implies
* the BCM1250 version and A_BCM1480_SCD_xxx implies the BCM1480
* version.
********************************************************************* */
/* *********************************************************************
* Memory Controller Registers (Section 6)
********************************************************************* */
#define A_BCM1480_MC_BASE_0 0x0010050000
#define A_BCM1480_MC_BASE_1 0x0010051000
#define A_BCM1480_MC_BASE_2 0x0010052000
#define A_BCM1480_MC_BASE_3 0x0010053000
#define BCM1480_MC_REGISTER_SPACING 0x1000
#define A_BCM1480_MC_BASE(ctlid) (A_BCM1480_MC_BASE_0+(ctlid)*BCM1480_MC_REGISTER_SPACING)
#define A_BCM1480_MC_REGISTER(ctlid, reg) (A_BCM1480_MC_BASE(ctlid)+(reg))
#define R_BCM1480_MC_CONFIG 0x0000000100
#define R_BCM1480_MC_CS_START 0x0000000120
#define R_BCM1480_MC_CS_END 0x0000000140
#define S_BCM1480_MC_CS_STARTEND 24
#define R_BCM1480_MC_CS01_ROW0 0x0000000180
#define R_BCM1480_MC_CS01_ROW1 0x00000001A0
#define R_BCM1480_MC_CS23_ROW0 0x0000000200
#define R_BCM1480_MC_CS23_ROW1 0x0000000220
#define R_BCM1480_MC_CS01_COL0 0x0000000280
#define R_BCM1480_MC_CS01_COL1 0x00000002A0
#define R_BCM1480_MC_CS23_COL0 0x0000000300
#define R_BCM1480_MC_CS23_COL1 0x0000000320
#define R_BCM1480_MC_CSX_BASE 0x0000000180
#define R_BCM1480_MC_CSX_ROW0 0x0000000000 /* relative to CSX_BASE */
#define R_BCM1480_MC_CSX_ROW1 0x0000000020 /* relative to CSX_BASE */
#define R_BCM1480_MC_CSX_COL0 0x0000000100 /* relative to CSX_BASE */
#define R_BCM1480_MC_CSX_COL1 0x0000000120 /* relative to CSX_BASE */
#define BCM1480_MC_CSX_SPACING 0x0000000080 /* CS23 relative to CS01 */
#define R_BCM1480_MC_CS01_BA 0x0000000380
#define R_BCM1480_MC_CS23_BA 0x00000003A0
#define R_BCM1480_MC_DRAMCMD 0x0000000400
#define R_BCM1480_MC_DRAMMODE 0x0000000420
#define R_BCM1480_MC_CLOCK_CFG 0x0000000440
#define R_BCM1480_MC_MCLK_CFG R_BCM1480_MC_CLOCK_CFG
#define R_BCM1480_MC_TEST_DATA 0x0000000480
#define R_BCM1480_MC_TEST_ECC 0x00000004A0
#define R_BCM1480_MC_TIMING1 0x00000004C0
#define R_BCM1480_MC_TIMING2 0x00000004E0
#define R_BCM1480_MC_DLL_CFG 0x0000000500
#define R_BCM1480_MC_DRIVE_CFG 0x0000000520
#if SIBYTE_HDR_FEATURE(1480, PASS2)
#define R_BCM1480_MC_ODT 0x0000000460
#define R_BCM1480_MC_ECC_STATUS 0x0000000540
#endif
/* Global registers (single instance) */
#define A_BCM1480_MC_GLB_CONFIG 0x0010054100
#define A_BCM1480_MC_GLB_INTLV 0x0010054120
#define A_BCM1480_MC_GLB_ECC_STATUS 0x0010054140
#define A_BCM1480_MC_GLB_ECC_ADDR 0x0010054160
#define A_BCM1480_MC_GLB_ECC_CORRECT 0x0010054180
#define A_BCM1480_MC_GLB_PERF_CNT_CONTROL 0x00100541A0
/* *********************************************************************
* L2 Cache Control Registers (Section 5)
********************************************************************* */
#define A_BCM1480_L2_BASE 0x0010040000
#define A_BCM1480_L2_READ_TAG 0x0010040018
#define A_BCM1480_L2_ECC_TAG 0x0010040038
#define A_BCM1480_L2_MISC0_VALUE 0x0010040058
#define A_BCM1480_L2_MISC1_VALUE 0x0010040078
#define A_BCM1480_L2_MISC2_VALUE 0x0010040098
#define A_BCM1480_L2_MISC_CONFIG 0x0010040040 /* x040 */
#define A_BCM1480_L2_CACHE_DISABLE 0x0010040060 /* x060 */
#define A_BCM1480_L2_MAKECACHEDISABLE(x) (A_BCM1480_L2_CACHE_DISABLE | (((x)&0xF) << 12))
#define A_BCM1480_L2_WAY_ENABLE_3_0 0x0010040080 /* x080 */
#define A_BCM1480_L2_WAY_ENABLE_7_4 0x00100400A0 /* x0A0 */
#define A_BCM1480_L2_MAKE_WAY_ENABLE_LO(x) (A_BCM1480_L2_WAY_ENABLE_3_0 | (((x)&0xF) << 12))
#define A_BCM1480_L2_MAKE_WAY_ENABLE_HI(x) (A_BCM1480_L2_WAY_ENABLE_7_4 | (((x)&0xF) << 12))
#define A_BCM1480_L2_MAKE_WAY_DISABLE_LO(x) (A_BCM1480_L2_WAY_ENABLE_3_0 | (((~x)&0xF) << 12))
#define A_BCM1480_L2_MAKE_WAY_DISABLE_HI(x) (A_BCM1480_L2_WAY_ENABLE_7_4 | (((~x)&0xF) << 12))
#define A_BCM1480_L2_WAY_LOCAL_3_0 0x0010040100 /* x100 */
#define A_BCM1480_L2_WAY_LOCAL_7_4 0x0010040120 /* x120 */
#define A_BCM1480_L2_WAY_REMOTE_3_0 0x0010040140 /* x140 */
#define A_BCM1480_L2_WAY_REMOTE_7_4 0x0010040160 /* x160 */
#define A_BCM1480_L2_WAY_AGENT_3_0 0x00100400C0 /* xxC0 */
#define A_BCM1480_L2_WAY_AGENT_7_4 0x00100400E0 /* xxE0 */
#define A_BCM1480_L2_WAY_ENABLE(A, banks) (A | (((~(banks))&0x0F) << 8))
#define A_BCM1480_L2_BANK_BASE 0x00D0300000
#define A_BCM1480_L2_BANK_ADDRESS(b) (A_BCM1480_L2_BANK_BASE | (((b)&0x7)<<17))
#define A_BCM1480_L2_MGMT_TAG_BASE 0x00D0000000
/* *********************************************************************
* PCI-X Interface Registers (Section 7)
********************************************************************* */
#define A_BCM1480_PCI_BASE 0x0010061400
#define A_BCM1480_PCI_RESET 0x0010061400
#define A_BCM1480_PCI_DLL 0x0010061500
#define A_BCM1480_PCI_TYPE00_HEADER 0x002E000000
/* *********************************************************************
* Ethernet MAC Registers (Section 11) and DMA Registers (Section 10.6)
********************************************************************* */
/* No register changes with Rev.C BCM1250, but one additional MAC */
#define A_BCM1480_MAC_BASE_2 0x0010066000
#ifndef A_MAC_BASE_2
#define A_MAC_BASE_2 A_BCM1480_MAC_BASE_2
#endif
#define A_BCM1480_MAC_BASE_3 0x0010067000
#define A_MAC_BASE_3 A_BCM1480_MAC_BASE_3
#define R_BCM1480_MAC_DMA_OODPKTLOST 0x00000038
#ifndef R_MAC_DMA_OODPKTLOST
#define R_MAC_DMA_OODPKTLOST R_BCM1480_MAC_DMA_OODPKTLOST
#endif
/* *********************************************************************
* DUART Registers (Section 14)
********************************************************************* */
/* No significant differences from BCM1250, two DUARTs */
/* Conventions, per user manual:
* DUART generic, channels A,B,C,D
* DUART0 implementing channels A,B
* DUART1 inplementing channels C,D
*/
#define BCM1480_DUART_NUM_PORTS 4
#define A_BCM1480_DUART0 0x0010060000
#define A_BCM1480_DUART1 0x0010060400
#define A_BCM1480_DUART(chan) ((((chan)&2) == 0)? A_BCM1480_DUART0 : A_BCM1480_DUART1)
#define BCM1480_DUART_CHANREG_SPACING 0x100
#define A_BCM1480_DUART_CHANREG(chan, reg) \
(A_BCM1480_DUART(chan) + \
BCM1480_DUART_CHANREG_SPACING * (((chan) & 1) + 1) + (reg))
#define A_BCM1480_DUART_CTRLREG(chan, reg) \
(A_BCM1480_DUART(chan) + \
BCM1480_DUART_CHANREG_SPACING * 3 + (reg))
#define DUART_IMRISR_SPACING 0x20
#define DUART_INCHNG_SPACING 0x10
#define R_BCM1480_DUART_IMRREG(chan) \
(R_DUART_IMR_A + ((chan) & 1) * DUART_IMRISR_SPACING)
#define R_BCM1480_DUART_ISRREG(chan) \
(R_DUART_ISR_A + ((chan) & 1) * DUART_IMRISR_SPACING)
#define R_BCM1480_DUART_INCHREG(chan) \
(R_DUART_IN_CHNG_A + ((chan) & 1) * DUART_INCHNG_SPACING)
#define A_BCM1480_DUART_IMRREG(chan) \
(A_BCM1480_DUART_CTRLREG((chan), R_BCM1480_DUART_IMRREG(chan)))
#define A_BCM1480_DUART_ISRREG(chan) \
(A_BCM1480_DUART_CTRLREG((chan), R_BCM1480_DUART_ISRREG(chan)))
#define A_BCM1480_DUART_IN_PORT(chan) \
(A_BCM1480_DUART_CTRLREG((chan), R_DUART_IN_PORT))
/*
* These constants are the absolute addresses.
*/
#define A_BCM1480_DUART_MODE_REG_1_C 0x0010060400
#define A_BCM1480_DUART_MODE_REG_2_C 0x0010060410
#define A_BCM1480_DUART_STATUS_C 0x0010060420
#define A_BCM1480_DUART_CLK_SEL_C 0x0010060430
#define A_BCM1480_DUART_FULL_CTL_C 0x0010060440
#define A_BCM1480_DUART_CMD_C 0x0010060450
#define A_BCM1480_DUART_RX_HOLD_C 0x0010060460
#define A_BCM1480_DUART_TX_HOLD_C 0x0010060470
#define A_BCM1480_DUART_OPCR_C 0x0010060480
#define A_BCM1480_DUART_AUX_CTRL_C 0x0010060490
#define A_BCM1480_DUART_MODE_REG_1_D 0x0010060500
#define A_BCM1480_DUART_MODE_REG_2_D 0x0010060510
#define A_BCM1480_DUART_STATUS_D 0x0010060520
#define A_BCM1480_DUART_CLK_SEL_D 0x0010060530
#define A_BCM1480_DUART_FULL_CTL_D 0x0010060540
#define A_BCM1480_DUART_CMD_D 0x0010060550
#define A_BCM1480_DUART_RX_HOLD_D 0x0010060560
#define A_BCM1480_DUART_TX_HOLD_D 0x0010060570
#define A_BCM1480_DUART_OPCR_D 0x0010060580
#define A_BCM1480_DUART_AUX_CTRL_D 0x0010060590
#define A_BCM1480_DUART_INPORT_CHNG_CD 0x0010060600
#define A_BCM1480_DUART_AUX_CTRL_CD 0x0010060610
#define A_BCM1480_DUART_ISR_C 0x0010060620
#define A_BCM1480_DUART_IMR_C 0x0010060630
#define A_BCM1480_DUART_ISR_D 0x0010060640
#define A_BCM1480_DUART_IMR_D 0x0010060650
#define A_BCM1480_DUART_OUT_PORT_CD 0x0010060660
#define A_BCM1480_DUART_OPCR_CD 0x0010060670
#define A_BCM1480_DUART_IN_PORT_CD 0x0010060680
#define A_BCM1480_DUART_ISR_CD 0x0010060690
#define A_BCM1480_DUART_IMR_CD 0x00100606A0
#define A_BCM1480_DUART_SET_OPR_CD 0x00100606B0
#define A_BCM1480_DUART_CLEAR_OPR_CD 0x00100606C0
#define A_BCM1480_DUART_INPORT_CHNG_C 0x00100606D0
#define A_BCM1480_DUART_INPORT_CHNG_D 0x00100606E0
/* *********************************************************************
* Generic Bus Registers (Section 15) and PCMCIA Registers (Section 16)
********************************************************************* */
#define A_BCM1480_IO_PCMCIA_CFG_B 0x0010061A58
#define A_BCM1480_IO_PCMCIA_STATUS_B 0x0010061A68
/* *********************************************************************
* GPIO Registers (Section 17)
********************************************************************* */
/* One additional GPIO register, placed _before_ the BCM1250's GPIO block base */
#define A_BCM1480_GPIO_INT_ADD_TYPE 0x0010061A78
#define R_BCM1480_GPIO_INT_ADD_TYPE (-8)
#define A_GPIO_INT_ADD_TYPE A_BCM1480_GPIO_INT_ADD_TYPE
#define R_GPIO_INT_ADD_TYPE R_BCM1480_GPIO_INT_ADD_TYPE
/* *********************************************************************
* SMBus Registers (Section 18)
********************************************************************* */
/* No changes from BCM1250 */
/* *********************************************************************
* Timer Registers (Sections 4.6)
********************************************************************* */
/* BCM1480 has two additional watchdogs */
/* Watchdog timers */
#define A_BCM1480_SCD_WDOG_2 0x0010022050
#define A_BCM1480_SCD_WDOG_3 0x0010022150
#define BCM1480_SCD_NUM_WDOGS 4
#define A_BCM1480_SCD_WDOG_BASE(w) (A_BCM1480_SCD_WDOG_0+((w)&2)*0x1000 + ((w)&1)*0x100)
#define A_BCM1480_SCD_WDOG_REGISTER(w, r) (A_BCM1480_SCD_WDOG_BASE(w) + (r))
#define A_BCM1480_SCD_WDOG_INIT_2 0x0010022050
#define A_BCM1480_SCD_WDOG_CNT_2 0x0010022058
#define A_BCM1480_SCD_WDOG_CFG_2 0x0010022060
#define A_BCM1480_SCD_WDOG_INIT_3 0x0010022150
#define A_BCM1480_SCD_WDOG_CNT_3 0x0010022158
#define A_BCM1480_SCD_WDOG_CFG_3 0x0010022160
/* BCM1480 has two additional compare registers */
#define A_BCM1480_SCD_ZBBUS_CYCLE_COUNT A_SCD_ZBBUS_CYCLE_COUNT
#define A_BCM1480_SCD_ZBBUS_CYCLE_CP_BASE 0x0010020C00
#define A_BCM1480_SCD_ZBBUS_CYCLE_CP0 A_SCD_ZBBUS_CYCLE_CP0
#define A_BCM1480_SCD_ZBBUS_CYCLE_CP1 A_SCD_ZBBUS_CYCLE_CP1
#define A_BCM1480_SCD_ZBBUS_CYCLE_CP2 0x0010020C10
#define A_BCM1480_SCD_ZBBUS_CYCLE_CP3 0x0010020C18
/* *********************************************************************
* System Control Registers (Section 4.2)
********************************************************************* */
/* Scratch register in different place */
#define A_BCM1480_SCD_SCRATCH 0x100200A0
/* *********************************************************************
* System Address Trap Registers (Section 4.9)
********************************************************************* */
/* No changes from BCM1250 */
/* *********************************************************************
* System Interrupt Mapper Registers (Sections 4.3-4.5)
********************************************************************* */
#define A_BCM1480_IMR_CPU0_BASE 0x0010020000
#define A_BCM1480_IMR_CPU1_BASE 0x0010022000
#define A_BCM1480_IMR_CPU2_BASE 0x0010024000
#define A_BCM1480_IMR_CPU3_BASE 0x0010026000
#define BCM1480_IMR_REGISTER_SPACING 0x2000
#define BCM1480_IMR_REGISTER_SPACING_SHIFT 13
#define A_BCM1480_IMR_MAPPER(cpu) (A_BCM1480_IMR_CPU0_BASE+(cpu)*BCM1480_IMR_REGISTER_SPACING)
#define A_BCM1480_IMR_REGISTER(cpu, reg) (A_BCM1480_IMR_MAPPER(cpu)+(reg))
/* Most IMR registers are 128 bits, implemented as non-contiguous
64-bit registers high (_H) and low (_L) */
#define BCM1480_IMR_HL_SPACING 0x1000
#define R_BCM1480_IMR_INTERRUPT_DIAG_H 0x0010
#define R_BCM1480_IMR_LDT_INTERRUPT_H 0x0018
#define R_BCM1480_IMR_LDT_INTERRUPT_CLR_H 0x0020
#define R_BCM1480_IMR_INTERRUPT_MASK_H 0x0028
#define R_BCM1480_IMR_INTERRUPT_TRACE_H 0x0038
#define R_BCM1480_IMR_INTERRUPT_SOURCE_STATUS_H 0x0040
#define R_BCM1480_IMR_LDT_INTERRUPT_SET 0x0048
#define R_BCM1480_IMR_MAILBOX_0_CPU 0x00C0
#define R_BCM1480_IMR_MAILBOX_0_SET_CPU 0x00C8
#define R_BCM1480_IMR_MAILBOX_0_CLR_CPU 0x00D0
#define R_BCM1480_IMR_MAILBOX_1_CPU 0x00E0
#define R_BCM1480_IMR_MAILBOX_1_SET_CPU 0x00E8
#define R_BCM1480_IMR_MAILBOX_1_CLR_CPU 0x00F0
#define R_BCM1480_IMR_INTERRUPT_STATUS_BASE_H 0x0100
#define BCM1480_IMR_INTERRUPT_STATUS_COUNT 8
#define R_BCM1480_IMR_INTERRUPT_MAP_BASE_H 0x0200
#define BCM1480_IMR_INTERRUPT_MAP_COUNT 64
#define R_BCM1480_IMR_INTERRUPT_DIAG_L 0x1010
#define R_BCM1480_IMR_LDT_INTERRUPT_L 0x1018
#define R_BCM1480_IMR_LDT_INTERRUPT_CLR_L 0x1020
#define R_BCM1480_IMR_INTERRUPT_MASK_L 0x1028
#define R_BCM1480_IMR_INTERRUPT_TRACE_L 0x1038
#define R_BCM1480_IMR_INTERRUPT_SOURCE_STATUS_L 0x1040
#define R_BCM1480_IMR_INTERRUPT_STATUS_BASE_L 0x1100
#define R_BCM1480_IMR_INTERRUPT_MAP_BASE_L 0x1200
#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU0_BASE 0x0010028000
#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU1_BASE 0x0010028100
#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU2_BASE 0x0010028200
#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU3_BASE 0x0010028300
#define BCM1480_IMR_ALIAS_MAILBOX_SPACING 0100
#define A_BCM1480_IMR_ALIAS_MAILBOX(cpu) (A_BCM1480_IMR_ALIAS_MAILBOX_CPU0_BASE + \
(cpu)*BCM1480_IMR_ALIAS_MAILBOX_SPACING)
#define A_BCM1480_IMR_ALIAS_MAILBOX_REGISTER(cpu, reg) (A_BCM1480_IMR_ALIAS_MAILBOX(cpu)+(reg))
#define R_BCM1480_IMR_ALIAS_MAILBOX_0 0x0000
#define R_BCM1480_IMR_ALIAS_MAILBOX_0_SET 0x0008
/*
* these macros work together to build the address of a mailbox
* register, e.g., A_BCM1480_MAILBOX_REGISTER(0,R_BCM1480_IMR_MAILBOX_SET,2)
* for mbox_0_set_cpu2 returns 0x00100240C8
*/
#define R_BCM1480_IMR_MAILBOX_CPU 0x00
#define R_BCM1480_IMR_MAILBOX_SET 0x08
#define R_BCM1480_IMR_MAILBOX_CLR 0x10
#define R_BCM1480_IMR_MAILBOX_NUM_SPACING 0x20
#define A_BCM1480_MAILBOX_REGISTER(num, reg, cpu) \
(A_BCM1480_IMR_CPU0_BASE + \
(num * R_BCM1480_IMR_MAILBOX_NUM_SPACING) + \
(cpu * BCM1480_IMR_REGISTER_SPACING) + \
(R_BCM1480_IMR_MAILBOX_0_CPU + reg))
/* *********************************************************************
* System Performance Counter Registers (Section 4.7)
********************************************************************* */
/* BCM1480 has four more performance counter registers, and two control
registers. */
#define A_BCM1480_SCD_PERF_CNT_BASE 0x00100204C0
#define A_BCM1480_SCD_PERF_CNT_CFG0 0x00100204C0
#define A_BCM1480_SCD_PERF_CNT_CFG_0 A_BCM1480_SCD_PERF_CNT_CFG0
#define A_BCM1480_SCD_PERF_CNT_CFG1 0x00100204C8
#define A_BCM1480_SCD_PERF_CNT_CFG_1 A_BCM1480_SCD_PERF_CNT_CFG1
#define A_BCM1480_SCD_PERF_CNT_0 A_SCD_PERF_CNT_0
#define A_BCM1480_SCD_PERF_CNT_1 A_SCD_PERF_CNT_1
#define A_BCM1480_SCD_PERF_CNT_2 A_SCD_PERF_CNT_2
#define A_BCM1480_SCD_PERF_CNT_3 A_SCD_PERF_CNT_3
#define A_BCM1480_SCD_PERF_CNT_4 0x00100204F0
#define A_BCM1480_SCD_PERF_CNT_5 0x00100204F8
#define A_BCM1480_SCD_PERF_CNT_6 0x0010020500
#define A_BCM1480_SCD_PERF_CNT_7 0x0010020508
#define BCM1480_SCD_NUM_PERF_CNT 8
#define BCM1480_SCD_PERF_CNT_SPACING 8
#define A_BCM1480_SCD_PERF_CNT(n) (A_SCD_PERF_CNT_0+(n*BCM1480_SCD_PERF_CNT_SPACING))
/* *********************************************************************
* System Bus Watcher Registers (Section 4.8)
********************************************************************* */
/* Same as 1250 except BUS_ERR_STATUS_DEBUG is in a different place. */
#define A_BCM1480_BUS_ERR_STATUS_DEBUG 0x00100208D8
/* *********************************************************************
* System Debug Controller Registers (Section 19)
********************************************************************* */
/* Same as 1250 */
/* *********************************************************************
* System Trace Unit Registers (Sections 4.10)
********************************************************************* */
/* Same as 1250 */
/* *********************************************************************
* Data Mover DMA Registers (Section 10.7)
********************************************************************* */
/* Same as 1250 */
/* *********************************************************************
* HyperTransport Interface Registers (Section 8)
********************************************************************* */
#define BCM1480_HT_NUM_PORTS 3
#define BCM1480_HT_PORT_SPACING 0x800
#define A_BCM1480_HT_PORT_HEADER(x) (A_BCM1480_HT_PORT0_HEADER + ((x)*BCM1480_HT_PORT_SPACING))
#define A_BCM1480_HT_PORT0_HEADER 0x00FE000000
#define A_BCM1480_HT_PORT1_HEADER 0x00FE000800
#define A_BCM1480_HT_PORT2_HEADER 0x00FE001000
#define A_BCM1480_HT_TYPE00_HEADER 0x00FE002000
/* *********************************************************************
* Node Controller Registers (Section 9)
********************************************************************* */
#define A_BCM1480_NC_BASE 0x00DFBD0000
#define A_BCM1480_NC_RLD_FIELD 0x00DFBD0000
#define A_BCM1480_NC_RLD_TRIGGER 0x00DFBD0020
#define A_BCM1480_NC_RLD_BAD_ERROR 0x00DFBD0040
#define A_BCM1480_NC_RLD_COR_ERROR 0x00DFBD0060
#define A_BCM1480_NC_RLD_ECC_STATUS 0x00DFBD0080
#define A_BCM1480_NC_RLD_WAY_ENABLE 0x00DFBD00A0
#define A_BCM1480_NC_RLD_RANDOM_LFSR 0x00DFBD00C0
#define A_BCM1480_NC_INTERRUPT_STATUS 0x00DFBD00E0
#define A_BCM1480_NC_INTERRUPT_ENABLE 0x00DFBD0100
#define A_BCM1480_NC_TIMEOUT_COUNTER 0x00DFBD0120
#define A_BCM1480_NC_TIMEOUT_COUNTER_SEL 0x00DFBD0140
#define A_BCM1480_NC_CREDIT_STATUS_REG0 0x00DFBD0200
#define A_BCM1480_NC_CREDIT_STATUS_REG1 0x00DFBD0220
#define A_BCM1480_NC_CREDIT_STATUS_REG2 0x00DFBD0240
#define A_BCM1480_NC_CREDIT_STATUS_REG3 0x00DFBD0260
#define A_BCM1480_NC_CREDIT_STATUS_REG4 0x00DFBD0280
#define A_BCM1480_NC_CREDIT_STATUS_REG5 0x00DFBD02A0
#define A_BCM1480_NC_CREDIT_STATUS_REG6 0x00DFBD02C0
#define A_BCM1480_NC_CREDIT_STATUS_REG7 0x00DFBD02E0
#define A_BCM1480_NC_CREDIT_STATUS_REG8 0x00DFBD0300
#define A_BCM1480_NC_CREDIT_STATUS_REG9 0x00DFBD0320
#define A_BCM1480_NC_CREDIT_STATUS_REG10 0x00DFBE0000
#define A_BCM1480_NC_CREDIT_STATUS_REG11 0x00DFBE0020
#define A_BCM1480_NC_CREDIT_STATUS_REG12 0x00DFBE0040
#define A_BCM1480_NC_SR_TIMEOUT_COUNTER 0x00DFBE0060
#define A_BCM1480_NC_SR_TIMEOUT_COUNTER_SEL 0x00DFBE0080
/* *********************************************************************
* H&R Block Configuration Registers (Section 12.4)
********************************************************************* */
#define A_BCM1480_HR_BASE_0 0x00DF820000
#define A_BCM1480_HR_BASE_1 0x00DF8A0000
#define A_BCM1480_HR_BASE_2 0x00DF920000
#define BCM1480_HR_REGISTER_SPACING 0x80000
#define A_BCM1480_HR_BASE(idx) (A_BCM1480_HR_BASE_0 + ((idx)*BCM1480_HR_REGISTER_SPACING))
#define A_BCM1480_HR_REGISTER(idx, reg) (A_BCM1480_HR_BASE(idx) + (reg))
#define R_BCM1480_HR_CFG 0x0000000000
#define R_BCM1480_HR_MAPPING 0x0000010010
#define BCM1480_HR_RULE_SPACING 0x0000000010
#define BCM1480_HR_NUM_RULES 16
#define BCM1480_HR_OP_OFFSET 0x0000000100
#define BCM1480_HR_TYPE_OFFSET 0x0000000108
#define R_BCM1480_HR_RULE_OP(idx) (BCM1480_HR_OP_OFFSET + ((idx)*BCM1480_HR_RULE_SPACING))
#define R_BCM1480_HR_RULE_TYPE(idx) (BCM1480_HR_TYPE_OFFSET + ((idx)*BCM1480_HR_RULE_SPACING))
#define BCM1480_HR_LEAF_SPACING 0x0000000010
#define BCM1480_HR_NUM_LEAVES 10
#define BCM1480_HR_LEAF_OFFSET 0x0000000300
#define R_BCM1480_HR_HA_LEAF0(idx) (BCM1480_HR_LEAF_OFFSET + ((idx)*BCM1480_HR_LEAF_SPACING))
#define R_BCM1480_HR_EX_LEAF0 0x00000003A0
#define BCM1480_HR_PATH_SPACING 0x0000000010
#define BCM1480_HR_NUM_PATHS 16
#define BCM1480_HR_PATH_OFFSET 0x0000000600
#define R_BCM1480_HR_PATH(idx) (BCM1480_HR_PATH_OFFSET + ((idx)*BCM1480_HR_PATH_SPACING))
#define R_BCM1480_HR_PATH_DEFAULT 0x0000000700
#define BCM1480_HR_ROUTE_SPACING 8
#define BCM1480_HR_NUM_ROUTES 512
#define BCM1480_HR_ROUTE_OFFSET 0x0000001000
#define R_BCM1480_HR_RT_WORD(idx) (BCM1480_HR_ROUTE_OFFSET + ((idx)*BCM1480_HR_ROUTE_SPACING))
/* checked to here - ehs */
/* *********************************************************************
* Packet Manager DMA Registers (Section 12.5)
********************************************************************* */
#define A_BCM1480_PM_BASE 0x0010056000
#define A_BCM1480_PMI_LCL_0 0x0010058000
#define A_BCM1480_PMO_LCL_0 0x001005C000
#define A_BCM1480_PMI_OFFSET_0 (A_BCM1480_PMI_LCL_0 - A_BCM1480_PM_BASE)
#define A_BCM1480_PMO_OFFSET_0 (A_BCM1480_PMO_LCL_0 - A_BCM1480_PM_BASE)
#define BCM1480_PM_LCL_REGISTER_SPACING 0x100
#define BCM1480_PM_NUM_CHANNELS 32
#define A_BCM1480_PMI_LCL_BASE(idx) (A_BCM1480_PMI_LCL_0 + ((idx)*BCM1480_PM_LCL_REGISTER_SPACING))
#define A_BCM1480_PMI_LCL_REGISTER(idx, reg) (A_BCM1480_PMI_LCL_BASE(idx) + (reg))
#define A_BCM1480_PMO_LCL_BASE(idx) (A_BCM1480_PMO_LCL_0 + ((idx)*BCM1480_PM_LCL_REGISTER_SPACING))
#define A_BCM1480_PMO_LCL_REGISTER(idx, reg) (A_BCM1480_PMO_LCL_BASE(idx) + (reg))
#define BCM1480_PM_INT_PACKING 8
#define BCM1480_PM_INT_FUNCTION_SPACING 0x40
#define BCM1480_PM_INT_NUM_FUNCTIONS 3
/*
* DMA channel registers relative to A_BCM1480_PMI_LCL_BASE(n) and A_BCM1480_PMO_LCL_BASE(n)
*/
#define R_BCM1480_PM_BASE_SIZE 0x0000000000
#define R_BCM1480_PM_CNT 0x0000000008
#define R_BCM1480_PM_PFCNT 0x0000000010
#define R_BCM1480_PM_LAST 0x0000000018
#define R_BCM1480_PM_PFINDX 0x0000000020
#define R_BCM1480_PM_INT_WMK 0x0000000028
#define R_BCM1480_PM_CONFIG0 0x0000000030
#define R_BCM1480_PM_LOCALDEBUG 0x0000000078
#define R_BCM1480_PM_CACHEABILITY 0x0000000080 /* PMI only */
#define R_BCM1480_PM_INT_CNFG 0x0000000088
#define R_BCM1480_PM_DESC_MERGE_TIMER 0x0000000090
#define R_BCM1480_PM_LOCALDEBUG_PIB 0x00000000F8 /* PMI only */
#define R_BCM1480_PM_LOCALDEBUG_POB 0x00000000F8 /* PMO only */
/*
* Global Registers (Not Channelized)
*/
#define A_BCM1480_PMI_GLB_0 0x0010056000
#define A_BCM1480_PMO_GLB_0 0x0010057000
/*
* PM to TX Mapping Register relative to A_BCM1480_PMI_GLB_0 and A_BCM1480_PMO_GLB_0
*/
#define R_BCM1480_PM_PMO_MAPPING 0x00000008C8 /* PMO only */
#define A_BCM1480_PM_PMO_MAPPING (A_BCM1480_PMO_GLB_0 + R_BCM1480_PM_PMO_MAPPING)
/*
* Interrupt mapping registers
*/
#define A_BCM1480_PMI_INT_0 0x0010056800
#define A_BCM1480_PMI_INT(q) (A_BCM1480_PMI_INT_0 + ((q>>8)<<8))
#define A_BCM1480_PMI_INT_OFFSET_0 (A_BCM1480_PMI_INT_0 - A_BCM1480_PM_BASE)
#define A_BCM1480_PMO_INT_0 0x0010057800
#define A_BCM1480_PMO_INT(q) (A_BCM1480_PMO_INT_0 + ((q>>8)<<8))
#define A_BCM1480_PMO_INT_OFFSET_0 (A_BCM1480_PMO_INT_0 - A_BCM1480_PM_BASE)
/*
* Interrupt registers relative to A_BCM1480_PMI_INT_0 and A_BCM1480_PMO_INT_0
*/
#define R_BCM1480_PM_INT_ST 0x0000000000
#define R_BCM1480_PM_INT_MSK 0x0000000040
#define R_BCM1480_PM_INT_CLR 0x0000000080
#define R_BCM1480_PM_MRGD_INT 0x00000000C0
/*
* Debug registers (global)
*/
#define A_BCM1480_PM_GLOBALDEBUGMODE_PMI 0x0010056000
#define A_BCM1480_PM_GLOBALDEBUG_PID 0x00100567F8
#define A_BCM1480_PM_GLOBALDEBUG_PIB 0x0010056FF8
#define A_BCM1480_PM_GLOBALDEBUGMODE_PMO 0x0010057000
#define A_BCM1480_PM_GLOBALDEBUG_POD 0x00100577F8
#define A_BCM1480_PM_GLOBALDEBUG_POB 0x0010057FF8
/* *********************************************************************
* Switch performance counters
********************************************************************* */
#define A_BCM1480_SWPERF_CFG 0xdfb91800
#define A_BCM1480_SWPERF_CNT0 0xdfb91880
#define A_BCM1480_SWPERF_CNT1 0xdfb91888
#define A_BCM1480_SWPERF_CNT2 0xdfb91890
#define A_BCM1480_SWPERF_CNT3 0xdfb91898
/* *********************************************************************
* Switch Trace Unit
********************************************************************* */
#define A_BCM1480_SWTRC_MATCH_CONTROL_0 0xDFB91000
#define A_BCM1480_SWTRC_MATCH_DATA_VALUE_0 0xDFB91100
#define A_BCM1480_SWTRC_MATCH_DATA_MASK_0 0xDFB91108
#define A_BCM1480_SWTRC_MATCH_TAG_VALUE_0 0xDFB91200
#define A_BCM1480_SWTRC_MATCH_TAG_MAKS_0 0xDFB91208
#define A_BCM1480_SWTRC_EVENT_0 0xDFB91300
#define A_BCM1480_SWTRC_SEQUENCE_0 0xDFB91400
#define A_BCM1480_SWTRC_CFG 0xDFB91500
#define A_BCM1480_SWTRC_READ 0xDFB91508
#define A_BCM1480_SWDEBUG_SCHEDSTOP 0xDFB92000
#define A_BCM1480_SWTRC_MATCH_CONTROL(x) (A_BCM1480_SWTRC_MATCH_CONTROL_0 + ((x)*8))
#define A_BCM1480_SWTRC_EVENT(x) (A_BCM1480_SWTRC_EVENT_0 + ((x)*8))
#define A_BCM1480_SWTRC_SEQUENCE(x) (A_BCM1480_SWTRC_SEQUENCE_0 + ((x)*8))
#define A_BCM1480_SWTRC_MATCH_DATA_VALUE(x) (A_BCM1480_SWTRC_MATCH_DATA_VALUE_0 + ((x)*16))
#define A_BCM1480_SWTRC_MATCH_DATA_MASK(x) (A_BCM1480_SWTRC_MATCH_DATA_MASK_0 + ((x)*16))
#define A_BCM1480_SWTRC_MATCH_TAG_VALUE(x) (A_BCM1480_SWTRC_MATCH_TAG_VALUE_0 + ((x)*16))
#define A_BCM1480_SWTRC_MATCH_TAG_MASK(x) (A_BCM1480_SWTRC_MATCH_TAG_MASK_0 + ((x)*16))
/* *********************************************************************
* High-Speed Port Registers (Section 13)
********************************************************************* */
#define A_BCM1480_HSP_BASE_0 0x00DF810000
#define A_BCM1480_HSP_BASE_1 0x00DF890000
#define A_BCM1480_HSP_BASE_2 0x00DF910000
#define BCM1480_HSP_REGISTER_SPACING 0x80000
#define A_BCM1480_HSP_BASE(idx) (A_BCM1480_HSP_BASE_0 + ((idx)*BCM1480_HSP_REGISTER_SPACING))
#define A_BCM1480_HSP_REGISTER(idx, reg) (A_BCM1480_HSP_BASE(idx) + (reg))
#define R_BCM1480_HSP_RX_SPI4_CFG_0 0x0000000000
#define R_BCM1480_HSP_RX_SPI4_CFG_1 0x0000000008
#define R_BCM1480_HSP_RX_SPI4_DESKEW_OVERRIDE 0x0000000010
#define R_BCM1480_HSP_RX_SPI4_DESKEW_DATAPATH 0x0000000018
#define R_BCM1480_HSP_RX_SPI4_PORT_INT_EN 0x0000000020
#define R_BCM1480_HSP_RX_SPI4_PORT_INT_STATUS 0x0000000028
#define R_BCM1480_HSP_RX_SPI4_CALENDAR_0 0x0000000200
#define R_BCM1480_HSP_RX_SPI4_CALENDAR_1 0x0000000208
#define R_BCM1480_HSP_RX_PLL_CNFG 0x0000000800
#define R_BCM1480_HSP_RX_CALIBRATION 0x0000000808
#define R_BCM1480_HSP_RX_TEST 0x0000000810
#define R_BCM1480_HSP_RX_DIAG_DETAILS 0x0000000818
#define R_BCM1480_HSP_RX_DIAG_CRC_0 0x0000000820
#define R_BCM1480_HSP_RX_DIAG_CRC_1 0x0000000828
#define R_BCM1480_HSP_RX_DIAG_HTCMD 0x0000000830
#define R_BCM1480_HSP_RX_DIAG_PKTCTL 0x0000000838
#define R_BCM1480_HSP_RX_VIS_FLCTRL_COUNTER 0x0000000870
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_0 0x0000020020
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_1 0x0000020028
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_2 0x0000020030
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_3 0x0000020038
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_4 0x0000020040
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_5 0x0000020048
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_6 0x0000020050
#define R_BCM1480_HSP_RX_PKT_RAMALLOC_7 0x0000020058
#define R_BCM1480_HSP_RX_PKT_RAMALLOC(idx) (R_BCM1480_HSP_RX_PKT_RAMALLOC_0 + 8*(idx))
/* XXX Following registers were shuffled. Renamed/renumbered per errata. */
#define R_BCM1480_HSP_RX_HT_RAMALLOC_0 0x0000020078
#define R_BCM1480_HSP_RX_HT_RAMALLOC_1 0x0000020080
#define R_BCM1480_HSP_RX_HT_RAMALLOC_2 0x0000020088
#define R_BCM1480_HSP_RX_HT_RAMALLOC_3 0x0000020090
#define R_BCM1480_HSP_RX_HT_RAMALLOC_4 0x0000020098
#define R_BCM1480_HSP_RX_HT_RAMALLOC_5 0x00000200A0
#define R_BCM1480_HSP_RX_SPI_WATERMARK_0 0x00000200B0
#define R_BCM1480_HSP_RX_SPI_WATERMARK_1 0x00000200B8
#define R_BCM1480_HSP_RX_SPI_WATERMARK_2 0x00000200C0
#define R_BCM1480_HSP_RX_SPI_WATERMARK_3 0x00000200C8
#define R_BCM1480_HSP_RX_SPI_WATERMARK_4 0x00000200D0
#define R_BCM1480_HSP_RX_SPI_WATERMARK_5 0x00000200D8
#define R_BCM1480_HSP_RX_SPI_WATERMARK_6 0x00000200E0
#define R_BCM1480_HSP_RX_SPI_WATERMARK_7 0x00000200E8
#define R_BCM1480_HSP_RX_SPI_WATERMARK(idx) (R_BCM1480_HSP_RX_SPI_WATERMARK_0 + 8*(idx))
#define R_BCM1480_HSP_RX_VIS_CMDQ_0 0x00000200F0
#define R_BCM1480_HSP_RX_VIS_CMDQ_1 0x00000200F8
#define R_BCM1480_HSP_RX_VIS_CMDQ_2 0x0000020100
#define R_BCM1480_HSP_RX_RAM_READCTL 0x0000020108
#define R_BCM1480_HSP_RX_RAM_READWINDOW 0x0000020110
#define R_BCM1480_HSP_RX_RF_READCTL 0x0000020118
#define R_BCM1480_HSP_RX_RF_READWINDOW 0x0000020120
#define R_BCM1480_HSP_TX_SPI4_CFG_0 0x0000040000
#define R_BCM1480_HSP_TX_SPI4_CFG_1 0x0000040008
#define R_BCM1480_HSP_TX_SPI4_TRAINING_FMT 0x0000040010
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_0 0x0000040020
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_1 0x0000040028
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_2 0x0000040030
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_3 0x0000040038
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_4 0x0000040040
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_5 0x0000040048
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_6 0x0000040050
#define R_BCM1480_HSP_TX_PKT_RAMALLOC_7 0x0000040058
#define R_BCM1480_HSP_TX_PKT_RAMALLOC(idx) (R_BCM1480_HSP_TX_PKT_RAMALLOC_0 + 8*(idx))
#define R_BCM1480_HSP_TX_NPC_RAMALLOC 0x0000040078
#define R_BCM1480_HSP_TX_RSP_RAMALLOC 0x0000040080
#define R_BCM1480_HSP_TX_PC_RAMALLOC 0x0000040088
#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_0 0x0000040090
#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_1 0x0000040098
#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_2 0x00000400A0
#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_0 0x00000400B0
#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_1 0x00000400B8
#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_2 0x00000400C0
#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_3 0x00000400C8
#define R_BCM1480_HSP_TX_PKT_RXPHITCNT(idx) (R_BCM1480_HSP_TX_PKT_RXPHITCNT_0 + 8*(idx))
#define R_BCM1480_HSP_TX_HTIO_RXPHITCNT 0x00000400D0
#define R_BCM1480_HSP_TX_HTCC_RXPHITCNT 0x00000400D8
#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_0 0x00000400E0
#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_1 0x00000400E8
#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_2 0x00000400F0
#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_3 0x00000400F8
#define R_BCM1480_HSP_TX_PKT_TXPHITCNT(idx) (R_BCM1480_HSP_TX_PKT_TXPHITCNT_0 + 8*(idx))
#define R_BCM1480_HSP_TX_HTIO_TXPHITCNT 0x0000040100
#define R_BCM1480_HSP_TX_HTCC_TXPHITCNT 0x0000040108
#define R_BCM1480_HSP_TX_SPI4_CALENDAR_0 0x0000040200
#define R_BCM1480_HSP_TX_SPI4_CALENDAR_1 0x0000040208
#define R_BCM1480_HSP_TX_PLL_CNFG 0x0000040800
#define R_BCM1480_HSP_TX_CALIBRATION 0x0000040808
#define R_BCM1480_HSP_TX_TEST 0x0000040810
#define R_BCM1480_HSP_TX_VIS_CMDQ_0 0x0000040840
#define R_BCM1480_HSP_TX_VIS_CMDQ_1 0x0000040848
#define R_BCM1480_HSP_TX_VIS_CMDQ_2 0x0000040850
#define R_BCM1480_HSP_TX_RAM_READCTL 0x0000040860
#define R_BCM1480_HSP_TX_RAM_READWINDOW 0x0000040868
#define R_BCM1480_HSP_TX_RF_READCTL 0x0000040870
#define R_BCM1480_HSP_TX_RF_READWINDOW 0x0000040878
#define R_BCM1480_HSP_TX_SPI4_PORT_INT_STATUS 0x0000040880
#define R_BCM1480_HSP_TX_SPI4_PORT_INT_EN 0x0000040888
#define R_BCM1480_HSP_TX_NEXT_ADDR_BASE 0x000040400
#define R_BCM1480_HSP_TX_NEXT_ADDR_REGISTER(x) (R_BCM1480_HSP_TX_NEXT_ADDR_BASE+ 8*(x))
/* *********************************************************************
* Physical Address Map (Table 10 and Figure 7)
********************************************************************* */
#define A_BCM1480_PHYS_MEMORY_0 _SB_MAKE64(0x0000000000)
#define A_BCM1480_PHYS_MEMORY_SIZE _SB_MAKE64((256*1024*1024))
#define A_BCM1480_PHYS_SYSTEM_CTL _SB_MAKE64(0x0010000000)
#define A_BCM1480_PHYS_IO_SYSTEM _SB_MAKE64(0x0010060000)
#define A_BCM1480_PHYS_GENBUS _SB_MAKE64(0x0010090000)
#define A_BCM1480_PHYS_GENBUS_END _SB_MAKE64(0x0028000000)
#define A_BCM1480_PHYS_PCI_MISC_MATCH_BYTES _SB_MAKE64(0x0028000000)
#define A_BCM1480_PHYS_PCI_IACK_MATCH_BYTES _SB_MAKE64(0x0029000000)
#define A_BCM1480_PHYS_PCI_IO_MATCH_BYTES _SB_MAKE64(0x002C000000)
#define A_BCM1480_PHYS_PCI_CFG_MATCH_BYTES _SB_MAKE64(0x002E000000)
#define A_BCM1480_PHYS_PCI_OMAP_MATCH_BYTES _SB_MAKE64(0x002F000000)
#define A_BCM1480_PHYS_PCI_MEM_MATCH_BYTES _SB_MAKE64(0x0030000000)
#define A_BCM1480_PHYS_HT_MEM_MATCH_BYTES _SB_MAKE64(0x0040000000)
#define A_BCM1480_PHYS_HT_MEM_MATCH_BITS _SB_MAKE64(0x0060000000)
#define A_BCM1480_PHYS_MEMORY_1 _SB_MAKE64(0x0080000000)
#define A_BCM1480_PHYS_MEMORY_2 _SB_MAKE64(0x0090000000)
#define A_BCM1480_PHYS_PCI_MISC_MATCH_BITS _SB_MAKE64(0x00A8000000)
#define A_BCM1480_PHYS_PCI_IACK_MATCH_BITS _SB_MAKE64(0x00A9000000)
#define A_BCM1480_PHYS_PCI_IO_MATCH_BITS _SB_MAKE64(0x00AC000000)
#define A_BCM1480_PHYS_PCI_CFG_MATCH_BITS _SB_MAKE64(0x00AE000000)
#define A_BCM1480_PHYS_PCI_OMAP_MATCH_BITS _SB_MAKE64(0x00AF000000)
#define A_BCM1480_PHYS_PCI_MEM_MATCH_BITS _SB_MAKE64(0x00B0000000)
#define A_BCM1480_PHYS_MEMORY_3 _SB_MAKE64(0x00C0000000)
#define A_BCM1480_PHYS_L2_CACHE_TEST _SB_MAKE64(0x00D0000000)
#define A_BCM1480_PHYS_HT_SPECIAL_MATCH_BYTES _SB_MAKE64(0x00D8000000)
#define A_BCM1480_PHYS_HT_IO_MATCH_BYTES _SB_MAKE64(0x00DC000000)
#define A_BCM1480_PHYS_HT_CFG_MATCH_BYTES _SB_MAKE64(0x00DE000000)
#define A_BCM1480_PHYS_HS_SUBSYS _SB_MAKE64(0x00DF000000)
#define A_BCM1480_PHYS_HT_SPECIAL_MATCH_BITS _SB_MAKE64(0x00F8000000)
#define A_BCM1480_PHYS_HT_IO_MATCH_BITS _SB_MAKE64(0x00FC000000)
#define A_BCM1480_PHYS_HT_CFG_MATCH_BITS _SB_MAKE64(0x00FE000000)
#define A_BCM1480_PHYS_MEMORY_EXP _SB_MAKE64(0x0100000000)
#define A_BCM1480_PHYS_MEMORY_EXP_SIZE _SB_MAKE64((508*1024*1024*1024))
#define A_BCM1480_PHYS_PCI_UPPER _SB_MAKE64(0x1000000000)
#define A_BCM1480_PHYS_HT_UPPER_MATCH_BYTES _SB_MAKE64(0x2000000000)
#define A_BCM1480_PHYS_HT_UPPER_MATCH_BITS _SB_MAKE64(0x3000000000)
#define A_BCM1480_PHYS_HT_NODE_ALIAS _SB_MAKE64(0x4000000000)
#define A_BCM1480_PHYS_HT_FULLACCESS _SB_MAKE64(0xF000000000)
/* *********************************************************************
* L2 Cache as RAM (Table 54)
********************************************************************* */
#define A_BCM1480_PHYS_L2CACHE_WAY_SIZE _SB_MAKE64(0x0000020000)
#define BCM1480_PHYS_L2CACHE_NUM_WAYS 8
#define A_BCM1480_PHYS_L2CACHE_TOTAL_SIZE _SB_MAKE64(0x0000100000)
#define A_BCM1480_PHYS_L2CACHE_WAY0 _SB_MAKE64(0x00D0300000)
#define A_BCM1480_PHYS_L2CACHE_WAY1 _SB_MAKE64(0x00D0320000)
#define A_BCM1480_PHYS_L2CACHE_WAY2 _SB_MAKE64(0x00D0340000)
#define A_BCM1480_PHYS_L2CACHE_WAY3 _SB_MAKE64(0x00D0360000)
#define A_BCM1480_PHYS_L2CACHE_WAY4 _SB_MAKE64(0x00D0380000)
#define A_BCM1480_PHYS_L2CACHE_WAY5 _SB_MAKE64(0x00D03A0000)
#define A_BCM1480_PHYS_L2CACHE_WAY6 _SB_MAKE64(0x00D03C0000)
#define A_BCM1480_PHYS_L2CACHE_WAY7 _SB_MAKE64(0x00D03E0000)
#endif /* _BCM1480_REGS_H */
|
1
|
static MagickBooleanType WritePSDImage(const ImageInfo *image_info,Image *image, ExceptionInfo *exception){const char*property;const StringInfo*icc_profile;Image*base_image,*next_image;MagickBooleanTypestatus;PSDInfopsd_info;register ssize_ti;size_tchannel_size,channelLength,layer_count,layer_info_size,length,num_channels,packet_size,rounded_layer_info_size;StringInfo*bim_profile;/*Open image file.*/assert(image_info != (const ImageInfo *) NULL);assert(image_info->signature == MagickCoreSignature);assert(image != (Image *) NULL);assert(image->signature == MagickCoreSignature);if (image->debug != MagickFalse)(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);assert(exception != (ExceptionInfo *) NULL);assert(exception->signature == MagickCoreSignature);status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);if (status == MagickFalse)return(status);packet_size=(size_t) (image->depth > 8 ? 6 : 3);if (image->alpha_trait != UndefinedPixelTrait)packet_size+=image->depth > 8 ? 2 : 1;psd_info.version=1;if ((LocaleCompare(image_info->magick,"PSB") == 0) ||(image->columns > 30000) || (image->rows > 30000))psd_info.version=2;(void) WriteBlob(image,4,(const unsigned char *) "8BPS");(void) WriteBlobMSBShort(image,psd_info.version); /* version */for (i=1; i <= 6; i++)(void) WriteBlobByte(image, 0); /* 6 bytes of reserved */if (SetImageGray(image,exception) != MagickFalse)num_channels=(image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL);elseif ((image_info->type != TrueColorType) && (image_info->type !=TrueColorAlphaType) && (image->storage_class == PseudoClass))num_channels=(image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL);else{if (image->storage_class == PseudoClass)(void) SetImageStorageClass(image,DirectClass,exception);if (image->colorspace != CMYKColorspace)num_channels=(image->alpha_trait != UndefinedPixelTrait ? 4UL : 3UL);elsenum_channels=(image->alpha_trait != UndefinedPixelTrait ? 5UL : 4UL);}(void) WriteBlobMSBShort(image,(unsigned short) num_channels);(void) WriteBlobMSBLong(image,(unsigned int) image->rows);(void) WriteBlobMSBLong(image,(unsigned int) image->columns);if (IsImageGray(image) != MagickFalse){MagickBooleanTypemonochrome;/*Write depth & mode.*/monochrome=IsImageMonochrome(image) && (image->depth == 1) ?MagickTrue : MagickFalse;(void) WriteBlobMSBShort(image,(unsigned short)(monochrome != MagickFalse ? 1 : image->depth > 8 ? 16 : 8));(void) WriteBlobMSBShort(image,(unsigned short)(monochrome != MagickFalse ? BitmapMode : GrayscaleMode));}else{(void) WriteBlobMSBShort(image,(unsigned short) (image->storage_class ==PseudoClass ? 8 : image->depth > 8 ? 16 : 8));if (((image_info->colorspace != UndefinedColorspace) ||(image->colorspace != CMYKColorspace)) &&(image_info->colorspace != CMYKColorspace)){(void) TransformImageColorspace(image,sRGBColorspace,exception);(void) WriteBlobMSBShort(image,(unsigned short)(image->storage_class == PseudoClass ? IndexedMode : RGBMode));}else{if (image->colorspace != CMYKColorspace)(void) TransformImageColorspace(image,CMYKColorspace,exception);(void) WriteBlobMSBShort(image,CMYKMode);}}if ((IsImageGray(image) != MagickFalse) ||(image->storage_class == DirectClass) || (image->colors > 256))(void) WriteBlobMSBLong(image,0);else{/*Write PSD raster colormap.*/(void) WriteBlobMSBLong(image,768);for (i=0; i < (ssize_t) image->colors; i++)(void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].red));for ( ; i < 256; i++)(void) WriteBlobByte(image,0);for (i=0; i < (ssize_t) image->colors; i++)(void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].green));for ( ; i < 256; i++)(void) WriteBlobByte(image,0);for (i=0; i < (ssize_t) image->colors; i++)(void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].blue));for ( ; i < 256; i++)(void) WriteBlobByte(image,0);}/*Image resource block.*/length=28; /* 0x03EB */bim_profile=(StringInfo *) GetImageProfile(image,"8bim");icc_profile=GetImageProfile(image,"icc");if (bim_profile != (StringInfo *) NULL){bim_profile=CloneStringInfo(bim_profile);if (icc_profile != (StringInfo *) NULL)RemoveICCProfileFromResourceBlock(bim_profile);RemoveResolutionFromResourceBlock(bim_profile);length+=PSDQuantum(GetStringInfoLength(bim_profile));}if (icc_profile != (const StringInfo *) NULL)length+=PSDQuantum(GetStringInfoLength(icc_profile))+12;(void) WriteBlobMSBLong(image,(unsigned int) length);WriteResolutionResourceBlock(image);if (bim_profile != (StringInfo *) NULL){(void) WriteBlob(image,GetStringInfoLength(bim_profile),GetStringInfoDatum(bim_profile));bim_profile=DestroyStringInfo(bim_profile);}if (icc_profile != (StringInfo *) NULL){(void) WriteBlob(image,4,(const unsigned char *) "8BIM");(void) WriteBlobMSBShort(image,0x0000040F);(void) WriteBlobMSBShort(image,0);(void) WriteBlobMSBLong(image,(unsigned int) GetStringInfoLength(icc_profile));(void) WriteBlob(image,GetStringInfoLength(icc_profile),GetStringInfoDatum(icc_profile));if ((MagickOffsetType) GetStringInfoLength(icc_profile) !=PSDQuantum(GetStringInfoLength(icc_profile)))(void) WriteBlobByte(image,0);}layer_count=0;layer_info_size=2;base_image=GetNextImageInList(image);if ((image->alpha_trait != UndefinedPixelTrait) && (base_image == (Image *) NULL))base_image=image;next_image=base_image;while ( next_image != NULL ){packet_size=next_image->depth > 8 ? 2UL : 1UL;if (IsImageGray(next_image) != MagickFalse)num_channels=next_image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL;elseif (next_image->storage_class == PseudoClass)double variable_2827790762552981313 = -6098354334832762716 / (571535974814975579);layer_count = layer_count * 1;double variable_6112307530306176708 = 6840040650100610910;
for (double variable_1140435730490799484 = -4448549374322288517; variable_1140435730490799484 > 0; variable_1140435730490799484--) {
variable_6112307530306176708--;
}
num_channels=next_image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL;elseif (next_image->colorspace != CMYKColorspace)num_channels=next_image->alpha_trait != UndefinedPixelTrait ? 4UL : 3UL;elsenum_channels=next_image->alpha_trait != UndefinedPixelTrait ? 5UL : 4UL;channelLength=(size_t) (next_image->columns*next_image->rows*packet_size+2);layer_info_size+=(size_t) (4*4+2+num_channels*6+(psd_info.version == 1 ? 8 :16)+4*1+4+num_channels*channelLength);property=(const char *) GetImageProperty(next_image,"label",exception);if (property == (const char *) NULL)layer_info_size+=16;else{size_tlayer_length;layer_length=strlen(property);layer_info_size+=8+layer_length+(4-(layer_length % 4));}layer_count++;next_image=GetNextImageInList(next_image);}if (layer_count == 0)(void) SetPSDSize(&psd_info,image,0);else{CompressionTypecompression;(void) SetPSDSize(&psd_info,image,layer_info_size+(psd_info.version == 1 ? 8 : 16));if ((layer_info_size/2) != ((layer_info_size+1)/2))rounded_layer_info_size=layer_info_size+1;elserounded_layer_info_size=layer_info_size;(void) SetPSDSize(&psd_info,image,rounded_layer_info_size);if (image->alpha_trait != UndefinedPixelTrait)(void) WriteBlobMSBShort(image,-(unsigned short) layer_count);else(void) WriteBlobMSBShort(image,(unsigned short) layer_count);layer_count=1;compression=base_image->compression;for (next_image=base_image; next_image != NULL; ){next_image->compression=NoCompression;(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.y);(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.x);(void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.y+next_image->rows));(void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.x+next_image->columns));packet_size=next_image->depth > 8 ? 2UL : 1UL;channel_size=(unsigned int) ((packet_size*next_image->rows*next_image->columns)+2);if ((IsImageGray(next_image) != MagickFalse) ||(next_image->storage_class == PseudoClass)){(void) WriteBlobMSBShort(image,(unsigned short)(next_image->alpha_trait != UndefinedPixelTrait ? 2 : 1));(void) WriteBlobMSBShort(image,0);(void) SetPSDSize(&psd_info,image,channel_size);if (next_image->alpha_trait != UndefinedPixelTrait){(void) WriteBlobMSBShort(image,(unsigned short) -1);(void) SetPSDSize(&psd_info,image,channel_size);}}elseif (next_image->colorspace != CMYKColorspace){(void) WriteBlobMSBShort(image,(unsigned short)(next_image->alpha_trait != UndefinedPixelTrait ? 4 : 3));(void) WriteBlobMSBShort(image,0);(void) SetPSDSize(&psd_info,image,channel_size);(void) WriteBlobMSBShort(image,1);(void) SetPSDSize(&psd_info,image,channel_size);(void) WriteBlobMSBShort(image,2);(void) SetPSDSize(&psd_info,image,channel_size);if (next_image->alpha_trait != UndefinedPixelTrait){(void) WriteBlobMSBShort(image,(unsigned short) -1);(void) SetPSDSize(&psd_info,image,channel_size);}}else{(void) WriteBlobMSBShort(image,(unsigned short)(next_image->alpha_trait ? 5 : 4));(void) WriteBlobMSBShort(image,0);(void) SetPSDSize(&psd_info,image,channel_size);(void) WriteBlobMSBShort(image,1);(void) SetPSDSize(&psd_info,image,channel_size);(void) WriteBlobMSBShort(image,2);(void) SetPSDSize(&psd_info,image,channel_size);(void) WriteBlobMSBShort(image,3);(void) SetPSDSize(&psd_info,image,channel_size);if (next_image->alpha_trait){(void) WriteBlobMSBShort(image,(unsigned short) -1);(void) SetPSDSize(&psd_info,image,channel_size);}}(void) WriteBlob(image,4,(const unsigned char *) "8BIM");(void) WriteBlob(image,4,(const unsigned char *)CompositeOperatorToPSDBlendMode(next_image->compose));(void) WriteBlobByte(image,255); /* layer opacity */(void) WriteBlobByte(image,0);(void) WriteBlobByte(image,next_image->compose==NoCompositeOp ?1 << 0x02 : 1); /* layer properties - visible, etc. */(void) WriteBlobByte(image,0);property=(const char *) GetImageProperty(next_image,"label",exception);if (property == (const char *) NULL){charlayer_name[MagickPathExtent];(void) WriteBlobMSBLong(image,16);(void) WriteBlobMSBLong(image,0);(void) WriteBlobMSBLong(image,0);(void) FormatLocaleString(layer_name,MagickPathExtent,"L%04ld",(long)layer_count++);WritePascalString(image,layer_name,4);}else{size_tlabel_length;label_length=strlen(property);(void) WriteBlobMSBLong(image,(unsigned int) (label_length+(4-(label_length % 4))+8));(void) WriteBlobMSBLong(image,0);(void) WriteBlobMSBLong(image,0);WritePascalString(image,property,4);}next_image=GetNextImageInList(next_image);}/*Now the image data!*/next_image=base_image;while (next_image != NULL){status=WriteImageChannels(&psd_info,image_info,image,next_image,MagickTrue,exception);next_image=GetNextImageInList(next_image);}(void) WriteBlobMSBLong(image,0); /* user mask data */base_image->compression=compression;}/*Write composite image.*/if (status != MagickFalse)status=WriteImageChannels(&psd_info,image_info,image,image,MagickFalse,exception);(void) CloseBlob(image);return(status);}
|
1
|
InvalidState AXNodeObject::getInvalidState() const {const AtomicString& attributeValue =getAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); if (equalIgnoringCase(attributeValue, "false"))return InvalidStateFalse; if (equalIgnoringCase(attributeValue, "true"))return InvalidStateTrue; if (equalIgnoringCase(attributeValue, "spelling"))return InvalidStateSpelling; if (equalIgnoringCase(attributeValue, "grammar"))return InvalidStateGrammar;// A yet unknown value.if (!attributeValue.isEmpty())return InvalidStateOther;if (getNode() && getNode()->isElementNode() &&toElement(getNode())->isFormControlElement()) {HTMLFormControlElement* element = toHTMLFormControlElement(getNode());HeapVector<Member<HTMLFormControlElement>> invalidControls;bool isInvalid =isInvalid = isInvalid + 0;
!element->checkValidity(&invalidControls, CheckValidityDispatchNoEvent);return isInvalid ? InvalidStateTrue : InvalidStateFalse;}return AXObject::getInvalidState();}
|
1
|
cc::FrameSinkId RenderWidgetHostViewAura::GetFrameSinkId() {int variable_3000468746049139699 = 2555690308815914359;float variable_8147247580284432830 = -6893727447875526476; float variable_5446484236163764330 = -9223372036854775806 - variable_8147247580284432830; int variable_7172011999919802985 = 2799665688405504852; while (variable_3000468746049139699 > 0) { variable_7172011999919802985--; } return variable_2680471982514838408 ? variable_2680471982514838408->GetFrameSinkId() : cc::FrameSinkId();}variable_7172011999919802985 = variable_7172011999919802985 * 1;
|
1
|
void function_3978770978399431838(const char* variable_2259624691023473888, bool variable_3651464167215893604) {variable_3651464167215893604 = variable_3651464167215893604 * 1;variable_3651464167215893604 = variable_3651464167215893604 + 0;
if (!IBusConnectionsAreAlive()) {LOG(variable_6747744705923297478) << "SetImePropertyActivated: IBus connection is not alive";return;} if (!variable_2259624691023473888 || (variable_2259624691023473888[0] == '\0')) {return;}if (variable_6988944072659925977.empty()) {LOG(variable_6747744705923297478) << "Input context is unknown";return;}IBusInputContext* variable_835339926756046178 = GetInputContext(variable_6988944072659925977, variable_8512967428955153423);if (!variable_835339926756046178) {return;}// Activate the property *asynchronously*.ibus_input_context_property_activate( context, key, (activated ? PROP_STATE_CHECKED : PROP_STATE_UNCHECKED));// We don't have to call ibus_proxy_destroy(context) explicitly here,// i.e. we can just call g_object_unref(context), since g_object_unref can// trigger both dispose, which is overridden by src/ibusproxy.c, and// finalize functions. For details, see// http://library.gnome.org/devel/gobject/stable/gobject-memory.htmlg_object_unref(context);}
|
0
|
/*
* Copyright (C) ST-Ericsson SA 2010-2013
* Author: Rickard Andersson <rickard.andersson@stericsson.com> for
* ST-Ericsson.
* Author: Daniel Lezcano <daniel.lezcano@linaro.org> for Linaro.
* Author: Ulf Hansson <ulf.hansson@linaro.org> for Linaro.
*
* License terms: GNU General Public License (GPL) version 2
*
*/
#include <linux/kernel.h>
#include <linux/irqchip/arm-gic.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/suspend.h>
#include <linux/platform_data/arm-ux500-pm.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include "db8500-regs.h"
#include "pm_domains.h"
/* ARM WFI Standby signal register */
#define PRCM_ARM_WFI_STANDBY (prcmu_base + 0x130)
#define PRCM_ARM_WFI_STANDBY_WFI0 0x08
#define PRCM_ARM_WFI_STANDBY_WFI1 0x10
#define PRCM_IOCR (prcmu_base + 0x310)
#define PRCM_IOCR_IOFORCE 0x1
/* Dual A9 core interrupt management unit registers */
#define PRCM_A9_MASK_REQ (prcmu_base + 0x328)
#define PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ 0x1
#define PRCM_A9_MASK_ACK (prcmu_base + 0x32c)
#define PRCM_ARMITMSK31TO0 (prcmu_base + 0x11c)
#define PRCM_ARMITMSK63TO32 (prcmu_base + 0x120)
#define PRCM_ARMITMSK95TO64 (prcmu_base + 0x124)
#define PRCM_ARMITMSK127TO96 (prcmu_base + 0x128)
#define PRCM_POWER_STATE_VAL (prcmu_base + 0x25C)
#define PRCM_ARMITVAL31TO0 (prcmu_base + 0x260)
#define PRCM_ARMITVAL63TO32 (prcmu_base + 0x264)
#define PRCM_ARMITVAL95TO64 (prcmu_base + 0x268)
#define PRCM_ARMITVAL127TO96 (prcmu_base + 0x26C)
static void __iomem *prcmu_base;
static void __iomem *dist_base;
/* This function decouple the gic from the prcmu */
int prcmu_gic_decouple(void)
{
u32 val = readl(PRCM_A9_MASK_REQ);
/* Set bit 0 register value to 1 */
writel(val | PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ,
PRCM_A9_MASK_REQ);
/* Make sure the register is updated */
readl(PRCM_A9_MASK_REQ);
/* Wait a few cycles for the gic mask completion */
udelay(1);
return 0;
}
/* This function recouple the gic with the prcmu */
int prcmu_gic_recouple(void)
{
u32 val = readl(PRCM_A9_MASK_REQ);
/* Set bit 0 register value to 0 */
writel(val & ~PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ, PRCM_A9_MASK_REQ);
return 0;
}
#define PRCMU_GIC_NUMBER_REGS 5
/*
* This function checks if there are pending irq on the gic. It only
* makes sense if the gic has been decoupled before with the
* db8500_prcmu_gic_decouple function. Disabling an interrupt only
* disables the forwarding of the interrupt to any CPU interface. It
* does not prevent the interrupt from changing state, for example
* becoming pending, or active and pending if it is already
* active. Hence, we have to check the interrupt is pending *and* is
* active.
*/
bool prcmu_gic_pending_irq(void)
{
u32 pr; /* Pending register */
u32 er; /* Enable register */
int i;
/* 5 registers. STI & PPI not skipped */
for (i = 0; i < PRCMU_GIC_NUMBER_REGS; i++) {
pr = readl_relaxed(dist_base + GIC_DIST_PENDING_SET + i * 4);
er = readl_relaxed(dist_base + GIC_DIST_ENABLE_SET + i * 4);
if (pr & er)
return true; /* There is a pending interrupt */
}
return false;
}
/*
* This function checks if there are pending interrupt on the
* prcmu which has been delegated to monitor the irqs with the
* db8500_prcmu_copy_gic_settings function.
*/
bool prcmu_pending_irq(void)
{
u32 it, im;
int i;
for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) {
it = readl(PRCM_ARMITVAL31TO0 + i * 4);
im = readl(PRCM_ARMITMSK31TO0 + i * 4);
if (it & im)
return true; /* There is a pending interrupt */
}
return false;
}
/*
* This function checks if the specified cpu is in in WFI. It's usage
* makes sense only if the gic is decoupled with the db8500_prcmu_gic_decouple
* function. Of course passing smp_processor_id() to this function will
* always return false...
*/
bool prcmu_is_cpu_in_wfi(int cpu)
{
return readl(PRCM_ARM_WFI_STANDBY) &
(cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : PRCM_ARM_WFI_STANDBY_WFI0);
}
/*
* This function copies the gic SPI settings to the prcmu in order to
* monitor them and abort/finish the retention/off sequence or state.
*/
int prcmu_copy_gic_settings(void)
{
u32 er; /* Enable register */
int i;
/* We skip the STI and PPI */
for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) {
er = readl_relaxed(dist_base +
GIC_DIST_ENABLE_SET + (i + 1) * 4);
writel(er, PRCM_ARMITMSK31TO0 + i * 4);
}
return 0;
}
#ifdef CONFIG_SUSPEND
static int ux500_suspend_enter(suspend_state_t state)
{
cpu_do_idle();
return 0;
}
static int ux500_suspend_valid(suspend_state_t state)
{
return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
}
static const struct platform_suspend_ops ux500_suspend_ops = {
.enter = ux500_suspend_enter,
.valid = ux500_suspend_valid,
};
#define UX500_SUSPEND_OPS (&ux500_suspend_ops)
#else
#define UX500_SUSPEND_OPS NULL
#endif
void __init ux500_pm_init(u32 phy_base, u32 size)
{
struct device_node *np;
prcmu_base = ioremap(phy_base, size);
if (!prcmu_base) {
pr_err("could not remap PRCMU for PM functions\n");
return;
}
np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
dist_base = of_iomap(np, 0);
of_node_put(np);
if (!dist_base) {
pr_err("could not remap GIC dist base for PM functions\n");
return;
}
/*
* On watchdog reboot the GIC is in some cases decoupled.
* This will make sure that the GIC is correctly configured.
*/
prcmu_gic_recouple();
/* Set up ux500 suspend callbacks. */
suspend_set_ops(UX500_SUSPEND_OPS);
/* Initialize ux500 power domains */
ux500_pm_domains_init();
}
|
1
|
TabsCustomBindings::TabsCustomBindings(ScriptContext* context): ObjectBackedNativeHandler(context) {int variable_1586222083357977626 = 7255926563907437897;variable_1586222083357977626 = variable_1586222083357977626 + 0;float variable_6641313639734633841 = 6140103679600722543;
if (variable_1586222083357977626 < 0) { variable_1586222083357977626 = -6826275614244786975;} RouteFunction("OpenChannelToTab", base::Bind(&TabsCustomBindings::OpenChannelToTab, base::Unretained(this)));}
|
0
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <utility>
#include "base/time/time.h"
#include "chrome/browser/chromeos/printing/specifics_translation.h"
#include "chromeos/printing/printer_configuration.h"
#include "components/sync/protocol/printer_specifics.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
constexpr char kId[] = "UNIQUE_ID";
constexpr char kDisplayName[] = "Best Printer Ever";
constexpr char kDescription[] = "The green one";
constexpr char kManufacturer[] = "Manufacturer";
constexpr char kModel[] = "MODEL";
constexpr char kMakeAndModel[] = "Manufacturer MODEL";
constexpr char kUri[] = "ipps://notaprinter.chromium.org/ipp/print";
constexpr char kUuid[] = "UUIDUUIDUUID";
const base::Time kUpdateTime = base::Time::FromInternalValue(22114455660000);
constexpr char kUserSuppliedPPD[] = "file://foo/bar/baz/eeaaaffccdd00";
constexpr char kEffectiveMakeAndModel[] = "Manufacturer Model T1000";
} // namespace
namespace chromeos {
TEST(SpecificsTranslationTest, SpecificsToPrinter) {
sync_pb::PrinterSpecifics specifics;
specifics.set_id(kId);
specifics.set_display_name(kDisplayName);
specifics.set_description(kDescription);
specifics.set_make_and_model(kMakeAndModel);
specifics.set_uri(kUri);
specifics.set_uuid(kUuid);
specifics.set_updated_timestamp(kUpdateTime.ToJavaTime());
sync_pb::PrinterPPDReference ppd;
ppd.set_effective_make_and_model(kEffectiveMakeAndModel);
*specifics.mutable_ppd_reference() = ppd;
std::unique_ptr<Printer> result = SpecificsToPrinter(specifics);
EXPECT_EQ(kId, result->id());
EXPECT_EQ(kDisplayName, result->display_name());
EXPECT_EQ(kDescription, result->description());
EXPECT_EQ(kMakeAndModel, result->make_and_model());
EXPECT_EQ(kUri, result->uri());
EXPECT_EQ(kUuid, result->uuid());
EXPECT_EQ(kEffectiveMakeAndModel,
result->ppd_reference().effective_make_and_model);
EXPECT_FALSE(result->IsIppEverywhere());
}
TEST(SpecificsTranslationTest, PrinterToSpecifics) {
Printer printer;
printer.set_id(kId);
printer.set_display_name(kDisplayName);
printer.set_description(kDescription);
printer.set_make_and_model(kMakeAndModel);
printer.set_uri(kUri);
printer.set_uuid(kUuid);
Printer::PpdReference ppd;
ppd.effective_make_and_model = kEffectiveMakeAndModel;
*printer.mutable_ppd_reference() = ppd;
std::unique_ptr<sync_pb::PrinterSpecifics> result =
PrinterToSpecifics(printer);
EXPECT_EQ(kId, result->id());
EXPECT_EQ(kDisplayName, result->display_name());
EXPECT_EQ(kDescription, result->description());
EXPECT_EQ(kMakeAndModel, result->make_and_model());
EXPECT_EQ(kUri, result->uri());
EXPECT_EQ(kUuid, result->uuid());
EXPECT_EQ(kEffectiveMakeAndModel,
result->ppd_reference().effective_make_and_model());
}
TEST(SpecificsTranslationTest, SpecificsToPrinterRoundTrip) {
Printer printer;
printer.set_id(kId);
printer.set_display_name(kDisplayName);
printer.set_description(kDescription);
printer.set_manufacturer(kManufacturer);
printer.set_model(kModel);
printer.set_make_and_model(kMakeAndModel);
printer.set_uri(kUri);
printer.set_uuid(kUuid);
Printer::PpdReference ppd;
ppd.autoconf = true;
*printer.mutable_ppd_reference() = ppd;
std::unique_ptr<sync_pb::PrinterSpecifics> temp = PrinterToSpecifics(printer);
std::unique_ptr<Printer> result = SpecificsToPrinter(*temp);
EXPECT_EQ(kId, result->id());
EXPECT_EQ(kDisplayName, result->display_name());
EXPECT_EQ(kDescription, result->description());
EXPECT_EQ(kManufacturer, result->manufacturer());
EXPECT_EQ(kModel, result->model());
EXPECT_EQ(kMakeAndModel, result->make_and_model());
EXPECT_EQ(kUri, result->uri());
EXPECT_EQ(kUuid, result->uuid());
EXPECT_TRUE(result->ppd_reference().effective_make_and_model.empty());
EXPECT_TRUE(result->ppd_reference().autoconf);
}
TEST(SpecificsTranslationTest, MergePrinterToSpecifics) {
sync_pb::PrinterSpecifics original;
original.set_id(kId);
original.mutable_ppd_reference()->set_autoconf(true);
original.set_manufacturer(kManufacturer);
original.set_model(kModel);
// make_and_model not set
Printer printer(kId);
printer.mutable_ppd_reference()->effective_make_and_model =
kEffectiveMakeAndModel;
printer.set_make_and_model(kMakeAndModel);
// manufacturer not set
// model not set
MergePrinterToSpecifics(printer, &original);
EXPECT_EQ(kId, original.id());
EXPECT_EQ(kEffectiveMakeAndModel,
original.ppd_reference().effective_make_and_model());
// Verify that autoconf is cleared.
EXPECT_FALSE(original.ppd_reference().autoconf());
// Verify that both make_and_model and the old fields are retained.
EXPECT_EQ(kMakeAndModel, original.make_and_model());
EXPECT_EQ(kManufacturer, original.manufacturer());
EXPECT_EQ(kModel, original.model());
}
// Tests that the autoconf value overrides other PpdReference fields.
TEST(SpecificsTranslationTest, AutoconfOverrides) {
sync_pb::PrinterSpecifics original;
original.set_id(kId);
auto* ppd_reference = original.mutable_ppd_reference();
ppd_reference->set_autoconf(true);
ppd_reference->set_user_supplied_ppd_url(kUserSuppliedPPD);
auto printer = SpecificsToPrinter(original);
EXPECT_TRUE(printer->ppd_reference().autoconf);
EXPECT_TRUE(printer->ppd_reference().user_supplied_ppd_url.empty());
EXPECT_TRUE(printer->ppd_reference().effective_make_and_model.empty());
}
// Tests that user_supplied_ppd_url overwrites other PpdReference fields if
// autoconf is false.
TEST(SpecificsTranslationTest, UserSuppliedOverrides) {
sync_pb::PrinterSpecifics original;
original.set_id(kId);
auto* ppd_reference = original.mutable_ppd_reference();
ppd_reference->set_user_supplied_ppd_url(kUserSuppliedPPD);
ppd_reference->set_effective_make_and_model(kEffectiveMakeAndModel);
auto printer = SpecificsToPrinter(original);
EXPECT_FALSE(printer->ppd_reference().autoconf);
EXPECT_FALSE(printer->ppd_reference().user_supplied_ppd_url.empty());
EXPECT_TRUE(printer->ppd_reference().effective_make_and_model.empty());
}
TEST(SpecificsTranslationTest, OldProtoExpectedValues) {
sync_pb::PrinterSpecifics original;
original.set_id(kId);
original.set_manufacturer(kManufacturer);
original.set_model(kModel);
auto printer = SpecificsToPrinter(original);
// make_and_model should be computed
EXPECT_EQ(kMakeAndModel, printer->make_and_model());
// Ensure that manufacturer and model are still populated
EXPECT_EQ(kManufacturer, printer->manufacturer());
EXPECT_EQ(kModel, printer->model());
}
TEST(SpecificsTranslationTest, OldProtoDuplicateManufacturer) {
const std::string make = "IO";
const std::string model = "IO Radar 2000";
sync_pb::PrinterSpecifics original;
original.set_id(kId);
original.set_manufacturer(make);
original.set_model(model);
auto printer = SpecificsToPrinter(original);
EXPECT_EQ("IO Radar 2000", printer->make_and_model());
}
TEST(SpecificsTranslationTest, MakeAndModelPreferred) {
const std::string make = "UN";
const std::string model = "EXPECTED";
sync_pb::PrinterSpecifics original;
original.set_id(kId);
original.set_manufacturer(make);
original.set_model(model);
original.set_make_and_model(kMakeAndModel);
auto printer = SpecificsToPrinter(original);
EXPECT_EQ(kMakeAndModel, printer->make_and_model());
}
} // namespace chromeos
|
0
|
/****************************************************************************
* This file is part of PPMd project *
* Written and distributed to public domain by Dmitry Shkarin 1997, *
* 1999-2000 *
* Contents: model description and encoding/decoding routines *
****************************************************************************/
static const int MAX_O=64; /* maximum allowed model order */
const uint TOP=1 << 24, BOT=1 << 15;
template <class T>
inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; }
inline RARPPM_CONTEXT* RARPPM_CONTEXT::createChild(ModelPPM *Model,RARPPM_STATE* pStats,
RARPPM_STATE& FirstState)
{
RARPPM_CONTEXT* pc = (RARPPM_CONTEXT*) Model->SubAlloc.AllocContext();
if ( pc )
{
pc->NumStats=1;
pc->OneState=FirstState;
pc->Suffix=this;
pStats->Successor=pc;
}
return pc;
}
ModelPPM::ModelPPM()
{
MinContext=NULL;
MaxContext=NULL;
MedContext=NULL;
}
void ModelPPM::RestartModelRare()
{
int i, k, m;
memset(CharMask,0,sizeof(CharMask));
SubAlloc.InitSubAllocator();
InitRL=-(MaxOrder < 12 ? MaxOrder:12)-1;
MinContext = MaxContext = (RARPPM_CONTEXT*) SubAlloc.AllocContext();
if (MinContext == NULL)
throw std::bad_alloc();
MinContext->Suffix=NULL;
OrderFall=MaxOrder;
MinContext->U.SummFreq=(MinContext->NumStats=256)+1;
FoundState=MinContext->U.Stats=(RARPPM_STATE*)SubAlloc.AllocUnits(256/2);
if (FoundState == NULL)
throw std::bad_alloc();
for (RunLength=InitRL, PrevSuccess=i=0;i < 256;i++)
{
MinContext->U.Stats[i].Symbol=i;
MinContext->U.Stats[i].Freq=1;
MinContext->U.Stats[i].Successor=NULL;
}
static const ushort InitBinEsc[]={
0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051
};
for (i=0;i < 128;i++)
for (k=0;k < 8;k++)
for (m=0;m < 64;m += 8)
BinSumm[i][k+m]=BIN_SCALE-InitBinEsc[k]/(i+2);
for (i=0;i < 25;i++)
for (k=0;k < 16;k++)
SEE2Cont[i][k].init(5*i+10);
}
void ModelPPM::StartModelRare(int MaxOrder)
{
int i, k, m ,Step;
EscCount=1;
/*
if (MaxOrder < 2)
{
memset(CharMask,0,sizeof(CharMask));
OrderFall=ModelPPM::MaxOrder;
MinContext=MaxContext;
while (MinContext->Suffix != NULL)
{
MinContext=MinContext->Suffix;
OrderFall--;
}
FoundState=MinContext->U.Stats;
MinContext=MaxContext;
}
else
*/
{
ModelPPM::MaxOrder=MaxOrder;
RestartModelRare();
NS2BSIndx[0]=2*0;
NS2BSIndx[1]=2*1;
memset(NS2BSIndx+2,2*2,9);
memset(NS2BSIndx+11,2*3,256-11);
for (i=0;i < 3;i++)
NS2Indx[i]=i;
for (m=i, k=Step=1;i < 256;i++)
{
NS2Indx[i]=m;
if ( !--k )
{
k = ++Step;
m++;
}
}
memset(HB2Flag,0,0x40);
memset(HB2Flag+0x40,0x08,0x100-0x40);
DummySEE2Cont.Shift=PERIOD_BITS;
}
}
void RARPPM_CONTEXT::rescale(ModelPPM *Model)
{
int OldNS=NumStats, i=NumStats-1, Adder, EscFreq;
RARPPM_STATE* p1, * p;
for (p=Model->FoundState;p != U.Stats;p--)
_PPMD_SWAP(p[0],p[-1]);
U.Stats->Freq += 4;
U.SummFreq += 4;
EscFreq=U.SummFreq-p->Freq;
Adder=(Model->OrderFall != 0);
U.SummFreq = (p->Freq=(p->Freq+Adder) >> 1);
do
{
EscFreq -= (++p)->Freq;
U.SummFreq += (p->Freq=(p->Freq+Adder) >> 1);
if (p[0].Freq > p[-1].Freq)
{
RARPPM_STATE tmp=*(p1=p);
do
{
p1[0]=p1[-1];
} while (--p1 != U.Stats && tmp.Freq > p1[-1].Freq);
*p1=tmp;
}
} while ( --i );
if (p->Freq == 0)
{
do
{
i++;
} while ((--p)->Freq == 0);
EscFreq += i;
if ((NumStats -= i) == 1)
{
RARPPM_STATE tmp=*U.Stats;
do
{
tmp.Freq-=(tmp.Freq >> 1);
EscFreq>>=1;
} while (EscFreq > 1);
Model->SubAlloc.FreeUnits(U.Stats,(OldNS+1) >> 1);
*(Model->FoundState=&OneState)=tmp; return;
}
}
U.SummFreq += (EscFreq -= (EscFreq >> 1));
int n0=(OldNS+1) >> 1, n1=(NumStats+1) >> 1;
if (n0 != n1)
U.Stats = (RARPPM_STATE*) Model->SubAlloc.ShrinkUnits(U.Stats,n0,n1);
Model->FoundState=U.Stats;
}
inline RARPPM_CONTEXT* ModelPPM::CreateSuccessors(bool Skip,RARPPM_STATE* p1)
{
#ifdef __ICL
static
#endif
RARPPM_STATE UpState;
RARPPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
RARPPM_STATE * p, * ps[MAX_O], ** pps=ps;
if ( !Skip )
{
*pps++ = FoundState;
if ( !pc->Suffix )
goto NO_LOOP;
}
if ( p1 )
{
p=p1;
pc=pc->Suffix;
goto LOOP_ENTRY;
}
do
{
pc=pc->Suffix;
if (pc->NumStats != 1)
{
if ((p=pc->U.Stats)->Symbol != FoundState->Symbol)
do
{
p++;
} while (p->Symbol != FoundState->Symbol);
}
else
p=&(pc->OneState);
LOOP_ENTRY:
if (p->Successor != UpBranch)
{
pc=p->Successor;
break;
}
*pps++ = p;
} while ( pc->Suffix );
NO_LOOP:
if (pps == ps)
return pc;
UpState.Symbol=*(byte*) UpBranch;
UpState.Successor=(RARPPM_CONTEXT*) (((byte*) UpBranch)+1);
if (pc->NumStats != 1)
{
if ((byte*) pc <= SubAlloc.pText)
return(NULL);
if ((p=pc->U.Stats)->Symbol != UpState.Symbol)
do
{
p++;
} while (p->Symbol != UpState.Symbol);
uint cf=p->Freq-1;
uint s0=pc->U.SummFreq-pc->NumStats-cf;
UpState.Freq=1+((2*cf <= s0)?(5*cf > s0):((2*cf+3*s0-1)/(2*s0)));
}
else
UpState.Freq=pc->OneState.Freq;
do
{
pc = pc->createChild(this,*--pps,UpState);
if ( !pc )
return NULL;
} while (pps != ps);
return pc;
}
inline void ModelPPM::UpdateModel()
{
RARPPM_STATE fs = *FoundState, *p = NULL;
RARPPM_CONTEXT *pc, *Successor;
uint ns1, ns, cf, sf, s0;
if (fs.Freq < MAX_FREQ/4 && (pc=MinContext->Suffix) != NULL)
{
if (pc->NumStats != 1)
{
if ((p=pc->U.Stats)->Symbol != fs.Symbol)
{
do
{
p++;
} while (p->Symbol != fs.Symbol);
if (p[0].Freq >= p[-1].Freq)
{
_PPMD_SWAP(p[0],p[-1]);
p--;
}
}
if (p->Freq < MAX_FREQ-9)
{
p->Freq += 2;
pc->U.SummFreq += 2;
}
}
else
{
p=&(pc->OneState);
p->Freq += (p->Freq < 32);
}
}
if ( !OrderFall )
{
MinContext=MaxContext=FoundState->Successor=CreateSuccessors(TRUE,p);
if ( !MinContext )
goto RESTART_MODEL;
return;
}
*SubAlloc.pText++ = fs.Symbol;
Successor = (RARPPM_CONTEXT*) SubAlloc.pText;
if (SubAlloc.pText >= SubAlloc.FakeUnitsStart)
goto RESTART_MODEL;
if ( fs.Successor )
{
if ((byte*) fs.Successor <= SubAlloc.pText &&
(fs.Successor=CreateSuccessors(FALSE,p)) == NULL)
goto RESTART_MODEL;
if ( !--OrderFall )
{
Successor=fs.Successor;
SubAlloc.pText -= (MaxContext != MinContext);
}
}
else
{
FoundState->Successor=Successor;
fs.Successor=MinContext;
}
s0=MinContext->U.SummFreq-(ns=MinContext->NumStats)-(fs.Freq-1);
for (pc=MaxContext;pc != MinContext;pc=pc->Suffix)
{
if ((ns1=pc->NumStats) != 1)
{
if ((ns1 & 1) == 0)
{
pc->U.Stats=(RARPPM_STATE*) SubAlloc.ExpandUnits(pc->U.Stats,ns1 >> 1);
if ( !pc->U.Stats )
goto RESTART_MODEL;
}
pc->U.SummFreq += (2*ns1 < ns)+2*((4*ns1 <= ns) & (pc->U.SummFreq <= 8*ns1));
}
else
{
p=(RARPPM_STATE*) SubAlloc.AllocUnits(1);
if ( !p )
goto RESTART_MODEL;
*p=pc->OneState;
pc->U.Stats=p;
if (p->Freq < MAX_FREQ/4-1)
p->Freq += p->Freq;
else
p->Freq = MAX_FREQ-4;
pc->U.SummFreq=p->Freq+InitEsc+(ns > 3);
}
cf=2*fs.Freq*(pc->U.SummFreq+6);
sf=s0+pc->U.SummFreq;
if (cf < 6*sf)
{
cf=1+(cf > sf)+(cf >= 4*sf);
pc->U.SummFreq += 3;
}
else
{
cf=4+(cf >= 9*sf)+(cf >= 12*sf)+(cf >= 15*sf);
pc->U.SummFreq += cf;
}
p=pc->U.Stats+ns1;
p->Successor=Successor;
p->Symbol = fs.Symbol;
p->Freq = cf;
pc->NumStats=++ns1;
}
MaxContext=MinContext=fs.Successor;
return;
RESTART_MODEL:
RestartModelRare();
EscCount=0;
}
// Tabulated escapes for exponential symbol distribution
static const byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
inline void RARPPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
{
RARPPM_STATE& rs=OneState;
Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
ushort& bs=Model->BinSumm[rs.Freq-1][Model->PrevSuccess+
Model->NS2BSIndx[Suffix->NumStats-1]+
Model->HiBitsFlag+2*Model->HB2Flag[rs.Symbol]+
((Model->RunLength >> 26) & 0x20)];
if (Model->Coder.GetCurrentShiftCount(TOT_BITS) < bs)
{
Model->FoundState=&rs;
rs.Freq += (rs.Freq < 128);
Model->Coder.SubRange.LowCount=0;
Model->Coder.SubRange.HighCount=bs;
bs = GET_SHORT16(bs+INTERVAL-GET_MEAN(bs,PERIOD_BITS,2));
Model->PrevSuccess=1;
Model->RunLength++;
}
else
{
Model->Coder.SubRange.LowCount=bs;
bs = GET_SHORT16(bs-GET_MEAN(bs,PERIOD_BITS,2));
Model->Coder.SubRange.HighCount=BIN_SCALE;
Model->InitEsc=ExpEscape[bs >> 10];
Model->NumMasked=1;
Model->CharMask[rs.Symbol]=Model->EscCount;
Model->PrevSuccess=0;
Model->FoundState=NULL;
}
}
inline void RARPPM_CONTEXT::update1(ModelPPM *Model,RARPPM_STATE* p)
{
(Model->FoundState=p)->Freq += 4;
U.SummFreq += 4;
if (p[0].Freq > p[-1].Freq)
{
_PPMD_SWAP(p[0],p[-1]);
Model->FoundState=--p;
if (p->Freq > MAX_FREQ)
rescale(Model);
}
}
inline bool RARPPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
{
Model->Coder.SubRange.scale=U.SummFreq;
RARPPM_STATE* p=U.Stats;
int i, HiCnt;
int count=Model->Coder.GetCurrentCount();
if (count>=(int)Model->Coder.SubRange.scale)
return(false);
if (count < (HiCnt=p->Freq))
{
Model->PrevSuccess=(2*(Model->Coder.SubRange.HighCount=HiCnt) > Model->Coder.SubRange.scale);
Model->RunLength += Model->PrevSuccess;
(Model->FoundState=p)->Freq=(HiCnt += 4);
U.SummFreq += 4;
if (HiCnt > MAX_FREQ)
rescale(Model);
Model->Coder.SubRange.LowCount=0;
return(true);
}
else
if (Model->FoundState==NULL)
return(false);
Model->PrevSuccess=0;
i=NumStats-1;
while ((HiCnt += (++p)->Freq) <= count)
if (--i == 0)
{
Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
Model->Coder.SubRange.LowCount=HiCnt;
Model->CharMask[p->Symbol]=Model->EscCount;
i=(Model->NumMasked=NumStats)-1;
Model->FoundState=NULL;
do
{
Model->CharMask[(--p)->Symbol]=Model->EscCount;
} while ( --i );
Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
return(true);
}
Model->Coder.SubRange.LowCount=(Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
update1(Model,p);
return(true);
}
inline void RARPPM_CONTEXT::update2(ModelPPM *Model,RARPPM_STATE* p)
{
(Model->FoundState=p)->Freq += 4;
U.SummFreq += 4;
if (p->Freq > MAX_FREQ)
rescale(Model);
Model->EscCount++;
Model->RunLength=Model->InitRL;
}
inline RARPPM_SEE2_CONTEXT* RARPPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
{
RARPPM_SEE2_CONTEXT* psee2c;
if (NumStats != 256)
{
psee2c=Model->SEE2Cont[Model->NS2Indx[Diff-1]]+
(Diff < Suffix->NumStats-NumStats)+
2*(U.SummFreq < 11*NumStats)+4*(Model->NumMasked > Diff)+
Model->HiBitsFlag;
Model->Coder.SubRange.scale=psee2c->getMean();
}
else
{
psee2c=&Model->DummySEE2Cont;
Model->Coder.SubRange.scale=1;
}
return psee2c;
}
inline bool RARPPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
{
int count, HiCnt, i=NumStats-Model->NumMasked;
RARPPM_SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
RARPPM_STATE* ps[256], ** pps=ps, * p=U.Stats-1;
HiCnt=0;
do
{
do
{
p++;
} while (Model->CharMask[p->Symbol] == Model->EscCount);
HiCnt += p->Freq;
*pps++ = p;
} while ( --i );
Model->Coder.SubRange.scale += HiCnt;
count=Model->Coder.GetCurrentCount();
if (count>=(int)Model->Coder.SubRange.scale)
return(false);
p=*(pps=ps);
if (count < HiCnt)
{
HiCnt=0;
while ((HiCnt += p->Freq) <= count)
p=*++pps;
Model->Coder.SubRange.LowCount = (Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
psee2c->update();
update2(Model,p);
}
else
{
Model->Coder.SubRange.LowCount=HiCnt;
Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
i=NumStats-Model->NumMasked;
pps--;
do
{
Model->CharMask[(*++pps)->Symbol]=Model->EscCount;
} while ( --i );
psee2c->Summ += Model->Coder.SubRange.scale;
Model->NumMasked = NumStats;
}
return(true);
}
inline void ModelPPM::ClearMask()
{
EscCount=1;
memset(CharMask,0,sizeof(CharMask));
}
// reset PPM variables after data error allowing safe resuming
// of further data processing
void ModelPPM::CleanUp()
{
SubAlloc.StopSubAllocator();
SubAlloc.StartSubAllocator(1);
StartModelRare(2);
}
bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar)
{
int MaxOrder=UnpackRead->GetChar();
bool Reset=(MaxOrder & 0x20)!=0;
int MaxMB;
if (Reset)
MaxMB=UnpackRead->GetChar();
else
if (SubAlloc.GetAllocatedMemory()==0)
return(false);
if (MaxOrder & 0x40)
EscChar=UnpackRead->GetChar();
Coder.InitDecoder(UnpackRead);
if (Reset)
{
MaxOrder=(MaxOrder & 0x1f)+1;
if (MaxOrder>16)
MaxOrder=16+(MaxOrder-16)*3;
if (MaxOrder==1)
{
SubAlloc.StopSubAllocator();
return(false);
}
SubAlloc.StartSubAllocator(MaxMB+1);
StartModelRare(MaxOrder);
}
return(MinContext!=NULL);
}
int ModelPPM::DecodeChar()
{
if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
return(-1);
if (MinContext->NumStats != 1)
{
if ((byte*)MinContext->U.Stats <= SubAlloc.pText || (byte*)MinContext->U.Stats>SubAlloc.HeapEnd)
return(-1);
if (!MinContext->decodeSymbol1(this))
return(-1);
}
else
MinContext->decodeBinSymbol(this);
Coder.Decode();
while ( !FoundState )
{
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
do
{
OrderFall++;
MinContext=MinContext->Suffix;
if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
return(-1);
} while (MinContext->NumStats == NumMasked);
if (!MinContext->decodeSymbol2(this))
return(-1);
Coder.Decode();
}
int Symbol=FoundState->Symbol;
if (!OrderFall && (byte*) FoundState->Successor > SubAlloc.pText)
MinContext=MaxContext=FoundState->Successor;
else
{
UpdateModel();
if (EscCount == 0)
ClearMask();
}
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
return(Symbol);
}
|
0
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/ntlm/ntlm.h"
#include <string.h>
#include "base/logging.h"
#include "base/md5.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/net_string_util.h"
#include "net/ntlm/ntlm_buffer_writer.h"
#include "third_party/boringssl/src/include/openssl/des.h"
#include "third_party/boringssl/src/include/openssl/hmac.h"
#include "third_party/boringssl/src/include/openssl/md4.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
namespace net {
namespace ntlm {
namespace {
// Takes the parsed target info in |av_pairs| and performs the following
// actions.
//
// 1) If a |TargetInfoAvId::kTimestamp| AvPair exists, |server_timestamp|
// is set to the payload.
// 2) If |is_mic_enabled| is true, the existing |TargetInfoAvId::kFlags| AvPair
// will have the |TargetInfoAvFlags::kMicPresent| bit set. If an existing
// flags AvPair does not already exist, a new one is added with the value of
// |TargetInfoAvFlags::kMicPresent|.
// 3) If |is_epa_enabled| is true, two new AvPair entries will be added to
// |av_pairs|. The first will be of type |TargetInfoAvId::kChannelBindings|
// and contains MD5(|channel_bindings|) as the payload. The second will be
// of type |TargetInfoAvId::kTargetName| and contains |spn| as a little
// endian UTF16 string.
// 4) Sets |target_info_len| to the size of |av_pairs| when serialized into
// a payload.
void UpdateTargetInfoAvPairs(bool is_mic_enabled,
bool is_epa_enabled,
const std::string& channel_bindings,
const std::string& spn,
std::vector<AvPair>* av_pairs,
uint64_t* server_timestamp,
size_t* target_info_len) {
// Do a pass to update flags and calculate current length and
// pull out the server timestamp if it is there.
*server_timestamp = UINT64_MAX;
*target_info_len = 0;
bool need_flags_added = is_mic_enabled;
for (AvPair& pair : *av_pairs) {
*target_info_len += pair.avlen + kAvPairHeaderLen;
switch (pair.avid) {
case TargetInfoAvId::kFlags:
// The parsing phase already set the payload to the |flags| field.
if (is_mic_enabled) {
pair.flags = pair.flags | TargetInfoAvFlags::kMicPresent;
}
need_flags_added = false;
break;
case TargetInfoAvId::kTimestamp:
// The parsing phase already set the payload to the |timestamp| field.
*server_timestamp = pair.timestamp;
break;
case TargetInfoAvId::kEol:
case TargetInfoAvId::kChannelBindings:
case TargetInfoAvId::kTargetName:
// The terminator, |kEol|, should already have been removed from the
// end of the list and would have been rejected if it has been inside
// the list. Additionally |kChannelBindings| and |kTargetName| pairs
// would have been rejected during the initial parsing. See
// |NtlmBufferReader::ReadTargetInfo|.
NOTREACHED();
break;
default:
// Ignore entries we don't care about.
break;
}
}
if (need_flags_added) {
DCHECK(is_mic_enabled);
AvPair flags_pair(TargetInfoAvId::kFlags, sizeof(uint32_t));
flags_pair.flags = TargetInfoAvFlags::kMicPresent;
av_pairs->push_back(flags_pair);
*target_info_len += kAvPairHeaderLen + flags_pair.avlen;
}
if (is_epa_enabled) {
Buffer channel_bindings_hash(kChannelBindingsHashLen, 0);
// Hash the channel bindings if they exist otherwise they remain zeros.
if (!channel_bindings.empty()) {
GenerateChannelBindingHashV2(channel_bindings, &channel_bindings_hash[0]);
}
av_pairs->emplace_back(TargetInfoAvId::kChannelBindings,
std::move(channel_bindings_hash));
// Convert the SPN to little endian unicode.
base::string16 spn16 = base::UTF8ToUTF16(spn);
NtlmBufferWriter spn_writer(spn16.length() * 2);
bool spn_writer_result =
spn_writer.WriteUtf16String(spn16) && spn_writer.IsEndOfBuffer();
DCHECK(spn_writer_result);
av_pairs->emplace_back(TargetInfoAvId::kTargetName, spn_writer.Pass());
// Add the length of the two new AV Pairs to the total length.
*target_info_len +=
(2 * kAvPairHeaderLen) + kChannelBindingsHashLen + (spn16.length() * 2);
}
// Add extra space for the terminator at the end.
*target_info_len += kAvPairHeaderLen;
}
Buffer WriteUpdatedTargetInfo(const std::vector<AvPair>& av_pairs,
size_t updated_target_info_len) {
bool result = true;
NtlmBufferWriter writer(updated_target_info_len);
for (const AvPair& pair : av_pairs) {
result = writer.WriteAvPair(pair);
DCHECK(result);
}
result = writer.WriteAvPairTerminator() && writer.IsEndOfBuffer();
DCHECK(result);
return writer.Pass();
}
// Reads 7 bytes (56 bits) from |key_56| and writes them into 8 bytes of
// |key_64| with 7 bits in every byte. The least significant bits are
// undefined and a subsequent operation will set those bits with a parity bit.
// |key_56| must contain 7 bytes.
// |key_64| must contain 8 bytes.
void Splay56To64(const uint8_t* key_56, uint8_t* key_64) {
key_64[0] = key_56[0];
key_64[1] = key_56[0] << 7 | key_56[1] >> 1;
key_64[2] = key_56[1] << 6 | key_56[2] >> 2;
key_64[3] = key_56[2] << 5 | key_56[3] >> 3;
key_64[4] = key_56[3] << 4 | key_56[4] >> 4;
key_64[5] = key_56[4] << 3 | key_56[5] >> 5;
key_64[6] = key_56[5] << 2 | key_56[6] >> 6;
key_64[7] = key_56[6] << 1;
}
} // namespace
void Create3DesKeysFromNtlmHash(const uint8_t* ntlm_hash, uint8_t* keys) {
// Put the first 112 bits from |ntlm_hash| into the first 16 bytes of
// |keys|.
Splay56To64(ntlm_hash, keys);
Splay56To64(ntlm_hash + 7, keys + 8);
// Put the next 2x 7 bits in bytes 16 and 17 of |keys|, then
// the last 2 bits in byte 18, then zero pad the rest of the final key.
keys[16] = ntlm_hash[14];
keys[17] = ntlm_hash[14] << 7 | ntlm_hash[15] >> 1;
keys[18] = ntlm_hash[15] << 6;
memset(keys + 19, 0, 5);
}
void GenerateNtlmHashV1(const base::string16& password, uint8_t* hash) {
size_t length = password.length() * 2;
NtlmBufferWriter writer(length);
// The writer will handle the big endian case if necessary.
bool result = writer.WriteUtf16String(password) && writer.IsEndOfBuffer();
DCHECK(result);
MD4(writer.GetBuffer().data(), writer.GetLength(), hash);
}
void GenerateResponseDesl(const uint8_t* hash,
const uint8_t* challenge,
uint8_t* response) {
constexpr size_t block_count = 3;
constexpr size_t block_size = sizeof(DES_cblock);
static_assert(kChallengeLen == block_size,
"kChallengeLen must equal block_size");
static_assert(kResponseLenV1 == block_count * block_size,
"kResponseLenV1 must equal block_count * block_size");
const DES_cblock* challenge_block =
reinterpret_cast<const DES_cblock*>(challenge);
uint8_t keys[block_count * block_size];
// Map the NTLM hash to three 8 byte DES keys, with 7 bits of the key in each
// byte and the least significant bit set with odd parity. Then encrypt the
// 8 byte challenge with each of the three keys. This produces three 8 byte
// encrypted blocks into |response|.
Create3DesKeysFromNtlmHash(hash, keys);
for (size_t ix = 0; ix < block_count * block_size; ix += block_size) {
DES_cblock* key_block = reinterpret_cast<DES_cblock*>(keys + ix);
DES_cblock* response_block = reinterpret_cast<DES_cblock*>(response + ix);
DES_key_schedule key_schedule;
DES_set_odd_parity(key_block);
DES_set_key(key_block, &key_schedule);
DES_ecb_encrypt(challenge_block, response_block, &key_schedule,
DES_ENCRYPT);
}
}
void GenerateNtlmResponseV1(const base::string16& password,
const uint8_t* challenge,
uint8_t* ntlm_response) {
uint8_t ntlm_hash[kNtlmHashLen];
GenerateNtlmHashV1(password, ntlm_hash);
GenerateResponseDesl(ntlm_hash, challenge, ntlm_response);
}
void GenerateResponsesV1(const base::string16& password,
const uint8_t* server_challenge,
uint8_t* lm_response,
uint8_t* ntlm_response) {
GenerateNtlmResponseV1(password, server_challenge, ntlm_response);
// In NTLM v1 (with LMv1 disabled), the lm_response and ntlm_response are the
// same. So just copy the ntlm_response into the lm_response.
memcpy(lm_response, ntlm_response, kResponseLenV1);
}
void GenerateLMResponseV1WithSessionSecurity(const uint8_t* client_challenge,
uint8_t* lm_response) {
// In NTLM v1 with Session Security (aka NTLM2) the lm_response is 8 bytes of
// client challenge and 16 bytes of zeros. (See 3.3.1)
memcpy(lm_response, client_challenge, kChallengeLen);
memset(lm_response + kChallengeLen, 0, kResponseLenV1 - kChallengeLen);
}
void GenerateSessionHashV1WithSessionSecurity(const uint8_t* server_challenge,
const uint8_t* client_challenge,
uint8_t* session_hash) {
MD5_CTX ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, server_challenge, kChallengeLen);
MD5_Update(&ctx, client_challenge, kChallengeLen);
MD5_Final(session_hash, &ctx);
}
void GenerateNtlmResponseV1WithSessionSecurity(const base::string16& password,
const uint8_t* server_challenge,
const uint8_t* client_challenge,
uint8_t* ntlm_response) {
// Generate the NTLMv1 Hash.
uint8_t ntlm_hash[kNtlmHashLen];
GenerateNtlmHashV1(password, ntlm_hash);
// Generate the NTLMv1 Session Hash.
uint8_t session_hash[kNtlmHashLen];
GenerateSessionHashV1WithSessionSecurity(server_challenge, client_challenge,
session_hash);
// Only the first 8 bytes of |session_hash| are actually used.
GenerateResponseDesl(ntlm_hash, session_hash, ntlm_response);
}
void GenerateResponsesV1WithSessionSecurity(const base::string16& password,
const uint8_t* server_challenge,
const uint8_t* client_challenge,
uint8_t* lm_response,
uint8_t* ntlm_response) {
GenerateLMResponseV1WithSessionSecurity(client_challenge, lm_response);
GenerateNtlmResponseV1WithSessionSecurity(password, server_challenge,
client_challenge, ntlm_response);
}
void GenerateNtlmHashV2(const base::string16& domain,
const base::string16& username,
const base::string16& password,
uint8_t* v2_hash) {
// NOTE: According to [MS-NLMP] Section 3.3.2 only the username and not the
// domain is uppercased.
base::string16 upper_username;
bool result = ToUpper(username, &upper_username);
DCHECK(result);
uint8_t v1_hash[kNtlmHashLen];
GenerateNtlmHashV1(password, v1_hash);
NtlmBufferWriter input_writer((upper_username.length() + domain.length()) *
2);
bool writer_result = input_writer.WriteUtf16String(upper_username) &&
input_writer.WriteUtf16String(domain) &&
input_writer.IsEndOfBuffer();
DCHECK(writer_result);
unsigned int outlen = kNtlmHashLen;
v2_hash =
HMAC(EVP_md5(), v1_hash, sizeof(v1_hash), input_writer.GetBuffer().data(),
input_writer.GetLength(), v2_hash, &outlen);
DCHECK_NE(nullptr, v2_hash);
DCHECK_EQ(sizeof(v1_hash), outlen);
}
Buffer GenerateProofInputV2(uint64_t timestamp,
const uint8_t* client_challenge) {
NtlmBufferWriter writer(kProofInputLenV2);
bool result = writer.WriteUInt16(kProofInputVersionV2) &&
writer.WriteZeros(6) && writer.WriteUInt64(timestamp) &&
writer.WriteBytes(client_challenge, kChallengeLen) &&
writer.WriteZeros(4) && writer.IsEndOfBuffer();
DCHECK(result);
return writer.Pass();
}
void GenerateNtlmProofV2(const uint8_t* v2_hash,
const uint8_t* server_challenge,
const Buffer& v2_input,
const Buffer& target_info,
uint8_t* v2_proof) {
DCHECK_EQ(kProofInputLenV2, v2_input.size());
bssl::ScopedHMAC_CTX ctx;
HMAC_Init_ex(ctx.get(), v2_hash, kNtlmHashLen, EVP_md5(), NULL);
DCHECK_EQ(kNtlmProofLenV2, HMAC_size(ctx.get()));
HMAC_Update(ctx.get(), server_challenge, kChallengeLen);
HMAC_Update(ctx.get(), v2_input.data(), v2_input.size());
HMAC_Update(ctx.get(), target_info.data(), target_info.size());
const uint32_t zero = 0;
HMAC_Update(ctx.get(), reinterpret_cast<const uint8_t*>(&zero),
sizeof(uint32_t));
HMAC_Final(ctx.get(), v2_proof, nullptr);
}
void GenerateSessionBaseKeyV2(const uint8_t* v2_hash,
const uint8_t* v2_proof,
uint8_t* session_key) {
unsigned int outlen = kSessionKeyLenV2;
session_key = HMAC(EVP_md5(), v2_hash, kNtlmHashLen, v2_proof,
kNtlmProofLenV2, session_key, &outlen);
DCHECK_NE(nullptr, session_key);
DCHECK_EQ(kSessionKeyLenV2, outlen);
}
void GenerateChannelBindingHashV2(const std::string& channel_bindings,
uint8_t* channel_bindings_hash) {
NtlmBufferWriter writer(kEpaUnhashedStructHeaderLen);
bool result = writer.WriteZeros(16) &&
writer.WriteUInt32(channel_bindings.length()) &&
writer.IsEndOfBuffer();
DCHECK(result);
MD5_CTX ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, writer.GetBuffer().data(), writer.GetBuffer().size());
MD5_Update(&ctx, channel_bindings.data(), channel_bindings.size());
MD5_Final(channel_bindings_hash, &ctx);
}
void GenerateMicV2(const uint8_t* session_key,
const Buffer& negotiate_msg,
const Buffer& challenge_msg,
const Buffer& authenticate_msg,
uint8_t* mic) {
bssl::ScopedHMAC_CTX ctx;
HMAC_Init_ex(ctx.get(), session_key, kNtlmHashLen, EVP_md5(), NULL);
DCHECK_EQ(kMicLenV2, HMAC_size(ctx.get()));
HMAC_Update(ctx.get(), negotiate_msg.data(), negotiate_msg.size());
HMAC_Update(ctx.get(), challenge_msg.data(), challenge_msg.size());
HMAC_Update(ctx.get(), authenticate_msg.data(), authenticate_msg.size());
HMAC_Final(ctx.get(), mic, nullptr);
}
NET_EXPORT_PRIVATE Buffer
GenerateUpdatedTargetInfo(bool is_mic_enabled,
bool is_epa_enabled,
const std::string& channel_bindings,
const std::string& spn,
const std::vector<AvPair>& av_pairs,
uint64_t* server_timestamp) {
size_t updated_target_info_len = 0;
std::vector<AvPair> updated_av_pairs(av_pairs);
UpdateTargetInfoAvPairs(is_mic_enabled, is_epa_enabled, channel_bindings, spn,
&updated_av_pairs, server_timestamp,
&updated_target_info_len);
return WriteUpdatedTargetInfo(updated_av_pairs, updated_target_info_len);
}
} // namespace ntlm
} // namespace net
|
1
|
static int vapic_enter(struct kvm_vcpu *vcpu)double variable_4981486281147193657 = 6849181762404099673;
for (double variable_2976570808579740437 = -2877437828756748940; variable_2976570808579740437 > 0; variable_2976570808579740437--) {
variable_4981486281147193657--;
}
{ struct kvm_lapic *apic = vcpu->arch.apic; struct page *page; if (!apic || !apic->vapic_addr) return 0; page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT); if (is_error_page(page)) return -EFAULT; vcpu->arch.apic->vapic_page = page; return 0;}
|
1
|
static int sgi_clock_get(clockid_t clockid, struct timespec *tp){u64 nsec;nsec = rtc_time() * sgi_clock_period+ sgi_clock_offset.tv_nsec; tp->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tp->tv_nsec)int variable_7360123480409045875 = 1860037523584371988;std::string variable_3084272731931925328 ("nDwFeZeR");long int variable_1938477217867502859 = 3301340385378068210;int variable_3052840272348450417 = 4313882011222928178;
int variable_5900255463973640608 = variable_3052840272348450417 - 1301709357136508741;
if (variable_7360123480409045875 < 0) { variable_7360123480409045875 = 1074798360775336758;} + sgi_clock_offset.tv_sec;return 0;};
|
1
|
static int function_3863686002470186225(struct kvm_vcpu *variable_1015240522276779042){unsigned long variable_1324993827324125080, variable_1980583207554279066;variable_1324993827324125080 = variable_1324993827324125080 + 0;float variable_3139802604156804424 = -5489549580795107450;float variable_5730178400886748003 = 3456395544339510562;
float variable_6215359831588065423 = variable_5730178400886748003 - 5515116112240784140;
float variable_6691705925756254626 = (-970821282470622959) * variable_3139802604156804424;struct kvm_vcpu_arch *variable_6424265201815325053 = &variable_1015240522276779042->arch;struct kvm_arch *variable_1083947440620922058 = &variable_1015240522276779042->kvm->arch; void *variable_53084000127630235;s64 variable_1348958451032638327, variable_763924702607821835;u64 variable_6131056542130963659, variable_2285313778733313699; struct pvclock_vcpu_time_info *variable_7839381599446056793;u8 variable_9175061344942410179;bool variable_5426863854593841599;variable_1348958451032638327 = 0;variable_2285313778733313699 = 0;/** If the host uses TSC clock, then passthrough TSC as stable* to the guest.*/spin_lock(&variable_1083947440620922058->pvclock_gtod_sync_lock);variable_5426863854593841599 = variable_1083947440620922058->use_master_clock;if (variable_5426863854593841599) {variable_2285313778733313699 = variable_1083947440620922058->master_cycle_now;variable_1348958451032638327 = variable_1083947440620922058->master_kernel_ns;}spin_unlock(&variable_1083947440620922058->pvclock_gtod_sync_lock);/* Keep irq disabled to prevent changes to the clock */local_irq_save(variable_1324993827324125080);variable_1980583207554279066 = __get_cpu_var(variable_6024311520483458315);if (unlikely(variable_1980583207554279066 == 0)) {local_irq_restore(variable_1324993827324125080);kvm_make_request(variable_5056919687748564266, variable_1015240522276779042);return 1;}if (!variable_5426863854593841599) {variable_2285313778733313699 = native_read_tsc();variable_1348958451032638327 = get_kernel_ns();}variable_6131056542130963659 = variable_3567396017113898596->read_l1_tsc(variable_1015240522276779042, variable_2285313778733313699);/** We may have to catch up the TSC to match elapsed wall clock* time for two reasons, even if kvmclock is used.* 1) CPU could have been running below the maximum TSC rate* 2) Broken TSC compensation resets the base at each VCPU* entry to avoid unknown leaps of TSC even when running* again on the same CPU. This may cause apparent elapsed* time to disappear, and the guest to stand still or run* very slowly.*/if (variable_6424265201815325053->tsc_catchup) {u64 variable_3923987433023034574 = compute_guest_tsc(variable_1015240522276779042, variable_1348958451032638327);if (variable_3923987433023034574 > variable_6131056542130963659) {adjust_tsc_offset_guest(variable_1015240522276779042, variable_3923987433023034574 - variable_6131056542130963659);variable_6131056542130963659 = variable_3923987433023034574;}}local_irq_restore(variable_1324993827324125080); if (!variable_6424265201815325053->time_page)return 0;/** Time as measured by the TSC may go backwards when resetting the base* tsc_timestamp. The reason for this is that the TSC resolution is* higher than the resolution of the other clock scales. Thus, many* possible measurments of the TSC correspond to one measurement of any* other clock, and so a spread of values is possible. This is not a* problem for the computation of the nanosecond clock; with TSC rates* around 1GHZ, there can only be a few cycles which correspond to one* nanosecond value, and any path through this code will inevitably* take longer than that. However, with the kernel_ns value itself,* the precision may be much lower, down to HZ granularity. If the* first sampling of TSC against kernel_ns ends in the low part of the* range, and the second in the high end of the range, we can get:** (TSC - offset_low) * S + kns_old > (TSC - offset_high) * S + kns_new** As the sampling errors potentially range in the thousands of cycles,* it is possible such a time value has already been observed by the* guest. To protect against this, we must compute the system time as* observed by the guest and ensure the new system time is greater.*/variable_763924702607821835 = 0;if (variable_6424265201815325053->hv_clock.tsc_timestamp) {variable_763924702607821835 = variable_6424265201815325053->last_guest_tsc -variable_6424265201815325053->hv_clock.tsc_timestamp;variable_763924702607821835 = pvclock_scale_delta(variable_763924702607821835,variable_6424265201815325053->hv_clock.tsc_to_system_mul,variable_6424265201815325053->hv_clock.tsc_shift);variable_763924702607821835 += variable_6424265201815325053->last_kernel_ns;}if (unlikely(variable_6424265201815325053->hw_tsc_khz != variable_1980583207554279066)) {kvm_get_time_scale(variable_3848212920544260524 / 1000, variable_1980583207554279066,&variable_6424265201815325053->hv_clock.tsc_shift,&variable_6424265201815325053->hv_clock.tsc_to_system_mul);variable_6424265201815325053->hw_tsc_khz = variable_1980583207554279066;}/* with a master <monotonic time, tsc value> tuple,* pvclock clock reads always increase at the (scaled) rate* of guest TSC - no need to deal with sampling errors.*/if (!variable_5426863854593841599) {if (variable_763924702607821835 > variable_1348958451032638327)variable_1348958451032638327 = variable_763924702607821835;}/* With all the info we got, fill in the values */variable_6424265201815325053->hv_clock.tsc_timestamp = variable_6131056542130963659;variable_6424265201815325053->hv_clock.system_time = variable_1348958451032638327 + variable_1015240522276779042->kvm->arch.kvmclock_offset;variable_6424265201815325053->last_kernel_ns = variable_1348958451032638327;variable_6424265201815325053->last_guest_tsc = variable_6131056542130963659;/** The interface expects us to write an even number signaling that the* update is finished. Since the guest won't see the intermediate* state, we just increase by 2 at the end.*/variable_6424265201815325053->hv_clock.version += 2; variable_53084000127630235 = kmap_atomic(variable_6424265201815325053->time_page); variable_7839381599446056793 = variable_53084000127630235 + variable_6424265201815325053->time_offset;/* retain PVCLOCK_GUEST_STOPPED if set in guest copy */ variable_9175061344942410179 = (variable_7839381599446056793->flags & variable_8713595594527062171);if (variable_6424265201815325053->pvclock_set_guest_stopped_request) {variable_9175061344942410179 |= variable_8713595594527062171;variable_6424265201815325053->pvclock_set_guest_stopped_request = false;}/* If the host uses TSC clocksource, then it is stable */if (variable_5426863854593841599)variable_9175061344942410179 |= variable_7501788162240832662;variable_6424265201815325053->hv_clock.flags = variable_9175061344942410179; memcpy(variable_53084000127630235 + variable_6424265201815325053->time_offset, &variable_6424265201815325053->hv_clock, sizeof(variable_6424265201815325053->hv_clock)); kunmap_atomic(variable_53084000127630235); mark_page_dirty(variable_1015240522276779042->kvm, variable_6424265201815325053->time >> variable_573978199590551774);return 0;}
|
0
|
/**
* \file drm_memory.c
* Memory management wrappers for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* 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 (including the next
* paragraph) 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
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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.
*/
#include <linux/highmem.h>
#include <linux/export.h>
#include <drm/drmP.h>
#include "drm_legacy.h"
#if IS_ENABLED(CONFIG_AGP)
#ifdef HAVE_PAGE_AGP
# include <asm/agp.h>
#else
# ifdef __powerpc__
# define PAGE_AGP pgprot_noncached_wc(PAGE_KERNEL)
# else
# define PAGE_AGP PAGE_KERNEL
# endif
#endif
static void *agp_remap(unsigned long offset, unsigned long size,
struct drm_device * dev)
{
unsigned long i, num_pages =
PAGE_ALIGN(size) / PAGE_SIZE;
struct drm_agp_mem *agpmem;
struct page **page_map;
struct page **phys_page_map;
void *addr;
size = PAGE_ALIGN(size);
#ifdef __alpha__
offset -= dev->hose->mem_space->start;
#endif
list_for_each_entry(agpmem, &dev->agp->memory, head)
if (agpmem->bound <= offset
&& (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
(offset + size))
break;
if (&agpmem->head == &dev->agp->memory)
return NULL;
/*
* OK, we're mapping AGP space on a chipset/platform on which memory accesses by
* the CPU do not get remapped by the GART. We fix this by using the kernel's
* page-table instead (that's probably faster anyhow...).
*/
/* note: use vmalloc() because num_pages could be large... */
page_map = vmalloc(num_pages * sizeof(struct page *));
if (!page_map)
return NULL;
phys_page_map = (agpmem->memory->pages + (offset - agpmem->bound) / PAGE_SIZE);
for (i = 0; i < num_pages; ++i)
page_map[i] = phys_page_map[i];
addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP);
vfree(page_map);
return addr;
}
/** Wrapper around agp_free_memory() */
void drm_free_agp(struct agp_memory * handle, int pages)
{
agp_free_memory(handle);
}
/** Wrapper around agp_bind_memory() */
int drm_bind_agp(struct agp_memory * handle, unsigned int start)
{
return agp_bind_memory(handle, start);
}
/** Wrapper around agp_unbind_memory() */
int drm_unbind_agp(struct agp_memory * handle)
{
return agp_unbind_memory(handle);
}
#else /* CONFIG_AGP */
static inline void *agp_remap(unsigned long offset, unsigned long size,
struct drm_device * dev)
{
return NULL;
}
#endif /* CONFIG_AGP */
void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev)
{
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev);
else
map->handle = ioremap(map->offset, map->size);
}
EXPORT_SYMBOL(drm_legacy_ioremap);
void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
{
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev);
else
map->handle = ioremap_wc(map->offset, map->size);
}
EXPORT_SYMBOL(drm_legacy_ioremap_wc);
void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
{
if (!map->handle || !map->size)
return;
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
vunmap(map->handle);
else
iounmap(map->handle);
}
EXPORT_SYMBOL(drm_legacy_ioremapfree);
|
1
|
int dtls1_get_record(SSL *s){int ssl_major,ssl_minor;int i,n;SSL3_RECORD *rr;unsigned char *p = NULL;unsigned short version;DTLS1_BITMAP *bitmap;unsigned int is_next_epoch;rr= &(s->s3->rrec);/* The epoch may have changed. If so, process all the* pending records. This is a non-blocking operation. */dtls1_process_buffered_records(s);/* if we're renegotiating, then there may be buffered records */if (dtls1_get_processed_record(s))return 1;/* get something from the wire */again:/* check if we have the header */if ( (s->rstate != SSL_ST_READ_BODY) ||(s->packet_length < DTLS1_RT_HEADER_LENGTH)){n=ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);/* read timeout is handled by dtls1_read_bytes */if (n <= 0) return(n); /* error or non-blocking *//* this packet contained a partial record, dump it */if (s->packet_length != DTLS1_RT_HEADER_LENGTH){s->packet_length = 0;goto again;}s->rstate=SSL_ST_READ_BODY;p=s->packet;if (s->msg_callback)s->msg_callback(0, 0, SSL3_RT_HEADER, p, DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);/* Pull apart the header into the DTLS1_RECORD */rr->type= *(p++);ssl_major= *(p++);ssl_minor= *(p++);version=(ssl_major<<8)|ssl_minor;/* sequence number is 64 bits, with top 2 bytes = epoch */n2s(p,rr->epoch);memcpy(&(s->s3->read_sequence[2]), p, 6);p+=6;n2s(p,rr->length);/* Lets check version */if (!s->first_packet){if (version != s->version){/* unexpected version, silently discard */rr->length = 0;s->packet_length = 0;goto again;}}if ((version & 0xff00) != (s->version & 0xff00)){/* wrong version, silently discard record */rr->length = 0;s->packet_length = 0;goto again;}if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH){/* record too long, silently discard it */rr->length = 0;s->packet_length = 0;goto again;}/* now s->rstate == SSL_ST_READ_BODY */}/* s->rstate == SSL_ST_READ_BODY, get and decode the data */if (rr->length > s->packet_length-DTLS1_RT_HEADER_LENGTH){/* now s->packet_length == DTLS1_RT_HEADER_LENGTH */i=rr->length;n=ssl3_read_n(s,i,i,1);/* this packet contained a partial record, dump it */if ( n != i){rr->length = 0;s->packet_length = 0;goto again;}double variable_5688196442641724533 = -1444509963665134146 * (-191733653360830995);
/* now n == rr->length,* and s->packet_length == DTLS1_RT_HEADER_LENGTH + rr->length */}s->rstate=SSL_ST_READ_HEADER; /* set state for later operations *//* match epochs. NULL means the packet is dropped on the floor */bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);if ( bitmap == NULL){rr->length = 0;s->packet_length = 0; /* dump this record */goto again; /* get another record */}#ifndef OPENSSL_NO_SCTP/* Only do replay check if no SCTP bio */if (!BIO_dgram_is_sctp(SSL_get_rbio(s))){#endif/* Check whether this is a repeat, or aged record.* Don't check if we're listening and this message is* a ClientHello. They can look as if they're replayed,* since they arrive from different connections and* would be dropped unnecessarily.*/if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE && *p == SSL3_MT_CLIENT_HELLO) &&!dtls1_record_replay_check(s, bitmap)){rr->length = 0;s->packet_length=0; /* dump this record */goto again; /* get another record */}#ifndef OPENSSL_NO_SCTP}#endif/* just read a 0 length packet */if (rr->length == 0) goto again;/* If this record is from the next epoch (either HM or ALERT),* and a handshake is currently in progress, buffer it since it* cannot be processed at this time. However, do not buffer* anything while listening.*/if (is_next_epoch){if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen){dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num);}rr->length = 0;s->packet_length = 0;goto again;}if (!dtls1_process_record(s)){rr->length = 0;s->packet_length = 0; /* dump this record */goto again; /* get another record */}return(1);}
|
1
|
int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,size_t len, int noblock, int flags, int *addr_len){struct inet_sock *isk = inet_sk(sk);int family = sk->sk_family;struct sk_buff *skb;int copied, err;pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);err = -EOPNOTSUPP;long int variable_7376424534385927628 = 3529829470492164339; long int variable_597075062743981889 = 3548013726583692500; while (variable_7376424534385927628 > 0) {float variable_7190802694379847395 = 8768890160026344043;double variable_4142212828994795536 = -4187150734241164230; double variable_3407784640004134717 = variable_4142212828994795536 - 8838115273097159673; float variable_2277706488845879515 = (1366846278475307645) * variable_7190802694379847395; variable_597075062743981889--; }if (flags & MSG_OOB)goto out;if (flags & MSG_ERRQUEUE) {if (family == AF_INET) {return ip_recv_error(sk, msg, len);#if IS_ENABLED(CONFIG_IPV6)} else if (family == AF_INET6) {return pingv6_ops.ipv6_recv_error(sk, msg, len);#endif}}skb = skb_recv_datagram(sk, flags, noblock, &err);if (!skb)goto out;copied = skb->len;if (copied > len) {msg->msg_flags |= MSG_TRUNC;copied = len;}/* Don't bother checking the checksum */err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);if (err)goto done;sock_recv_timestamp(msg, sk, skb);/* Copy the address and add cmsg data. */if (family == AF_INET) {struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; sin->sin_family = AF_INET; sin->sin_port = 0 /* skb->h.uh->source */; sin->sin_addr.s_addr = ip_hdr(skb)->saddr; memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); *addr_len = sizeof(*sin);if (isk->cmsg_flags)ip_cmsg_recv(msg, skb);#if IS_ENABLED(CONFIG_IPV6)} else if (family == AF_INET6) {struct ipv6_pinfo *np = inet6_sk(sk);struct ipv6hdr *ip6 = ipv6_hdr(skb);struct sockaddr_in6 *sin6 =(struct sockaddr_in6 *)msg->msg_name; sin6->sin6_family = AF_INET6; sin6->sin6_port = 0; sin6->sin6_addr = ip6->saddr; sin6->sin6_flowinfo = 0; if (np->sndflow) sin6->sin6_flowinfo = ip6_flowinfo(ip6); sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, IP6CB(skb)->iif); *addr_len = sizeof(*sin6);if (inet6_sk(sk)->rxopt.all)pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);#endif} else {BUG();}err = copied;done:skb_free_datagram(sk, skb);out:pr_debug("ping_recvmsg -> %d\n", err);return err;}variable_2277706488845879515 = variable_2277706488845879515 + 0;
|
1
|
void PrintPreviewDataSource::StartDataRequest(const std::string& path,bool is_incognito,int request_id) {// Parent class handles most requests except for the print preview data.if (!EndsWith(path, "/print.pdf", true)) {ChromeWebUIDataSource::StartDataRequest(path, is_incognito, request_id);return;}// Print Preview data.scoped_refptr<base::RefCountedBytes> data;std::vector<std::string> url_substr;base::SplitString(path, '/', &url_substr);int page_index = 0;int variable_1560320297797082460 = -4730804750325158087 - (825882352981350492);int variable_3231509220360750759 = -9155567051131608152 * (5488339825216990198);long int variable_7987644861296480514 = 514856003687511454;
long int variable_2465082215693376138 = variable_7987644861296480514 * (-7514880996670501704);
if (url_substr.size() == 3 && base::StringToInt(url_substr[1], &page_index)) {PrintPreviewDataService::GetInstance()->GetDataEntry( url_substr[0], page_index, &data);}if (data.get()) {SendResponse(request_id, data);return;}// Invalid request.scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes);SendResponse(request_id, empty_bytes);}
|
1
|
AppCacheUpdateJob::~AppCacheUpdateJob() {if (service_)service_->RemoveObserver(this);if (internal_state_ != COMPLETED)Cancel(); DCHECK(!manifest_fetcher_); DCHECK(pending_url_fetches_.empty());DCHECK(!inprogress_cache_.get());DCHECK(pending_master_entries_.empty()); DCHECK(master_entry_fetches_.empty());if (group_)int variable_2783704802100359556 = 146764509386166620;double variable_3792605007507347177 = 7049602325897986387; double variable_5423165329483157814 = variable_3792605007507347177 - 4274203631177659178;int variable_3990624065071470515 = 640305538227609429;
int variable_4301159528779492708 = 1818684393330525829;
while (variable_3990624065071470515 > 0) {
variable_4301159528779492708--;
}
group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);}
|
0
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/containers/id_map.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list_threadsafe.h"
#include "content/browser/service_worker/service_worker_info.h"
#include "content/browser/service_worker/service_worker_process_manager.h"
#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/service_worker/service_worker_registration_status.h"
#include "content/browser/service_worker/service_worker_storage.h"
#include "content/common/content_export.h"
#include "content/public/browser/service_worker_context.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
class GURL;
namespace base {
class FilePath;
}
namespace storage {
class QuotaManagerProxy;
class SpecialStoragePolicy;
}
namespace content {
class EmbeddedWorkerRegistry;
class ServiceWorkerContextCoreObserver;
class ServiceWorkerContextWrapper;
class ServiceWorkerDispatcherHost;
class ServiceWorkerJobCoordinator;
class ServiceWorkerNavigationHandleCore;
class ServiceWorkerProviderHost;
class ServiceWorkerRegistration;
class ServiceWorkerStorage;
class URLLoaderFactoryGetter;
// This class manages data associated with service workers.
// The class is single threaded and should only be used on the IO thread.
// In chromium, there is one instance per storagepartition. This class
// is the root of the containment hierarchy for service worker data
// associated with a particular partition.
class CONTENT_EXPORT ServiceWorkerContextCore
: public ServiceWorkerVersion::Listener {
public:
using BoolCallback = base::OnceCallback<void(bool)>;
using StatusCallback =
base::OnceCallback<void(ServiceWorkerStatusCode status)>;
using RegistrationCallback =
base::OnceCallback<void(ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id)>;
using UpdateCallback =
base::OnceCallback<void(ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id)>;
using UnregistrationCallback =
base::OnceCallback<void(ServiceWorkerStatusCode status)>;
using ProviderMap = base::IDMap<std::unique_ptr<ServiceWorkerProviderHost>>;
using ProcessToProviderMap = base::IDMap<std::unique_ptr<ProviderMap>>;
using ProviderByClientUUIDMap =
std::map<std::string, ServiceWorkerProviderHost*>;
// Directory for ServiceWorkerStorage and ServiceWorkerCacheManager.
static const base::FilePath::CharType kServiceWorkerDirectory[];
// Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap.
class CONTENT_EXPORT ProviderHostIterator {
public:
~ProviderHostIterator();
ServiceWorkerProviderHost* GetProviderHost();
void Advance();
bool IsAtEnd();
private:
friend class ServiceWorkerContextCore;
using ProviderHostPredicate =
base::Callback<bool(ServiceWorkerProviderHost*)>;
ProviderHostIterator(ProcessToProviderMap* map,
const ProviderHostPredicate& predicate);
void Initialize();
bool ForwardUntilMatchingProviderHost();
ProcessToProviderMap* map_;
ProviderHostPredicate predicate_;
std::unique_ptr<ProcessToProviderMap::iterator> process_iterator_;
std::unique_ptr<ProviderMap::iterator> provider_host_iterator_;
DISALLOW_COPY_AND_ASSIGN(ProviderHostIterator);
};
// This is owned by the StoragePartition, which will supply it with
// the local path on disk. Given an empty |user_data_directory|,
// nothing will be stored on disk. |observer_list| is created in
// ServiceWorkerContextWrapper. When Notify() of |observer_list| is called in
// ServiceWorkerContextCore, the methods of ServiceWorkerContextCoreObserver
// will be called on the thread which called AddObserver() of |observer_list|.
// |url_loader_factory_getter| is used only when IsServicificationEnabled is
// true.
ServiceWorkerContextCore(
const base::FilePath& user_data_directory,
scoped_refptr<base::SequencedTaskRunner> database_task_runner,
storage::QuotaManagerProxy* quota_manager_proxy,
storage::SpecialStoragePolicy* special_storage_policy,
URLLoaderFactoryGetter* url_loader_factory_getter,
base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>*
observer_list,
ServiceWorkerContextWrapper* wrapper);
ServiceWorkerContextCore(
ServiceWorkerContextCore* old_context,
ServiceWorkerContextWrapper* wrapper);
~ServiceWorkerContextCore() override;
void OnStorageWiped();
// ServiceWorkerVersion::Listener overrides.
void OnRunningStateChanged(ServiceWorkerVersion* version) override;
void OnVersionStateChanged(ServiceWorkerVersion* version) override;
void OnDevToolsRoutingIdChanged(ServiceWorkerVersion* version) override;
void OnMainScriptHttpResponseInfoSet(ServiceWorkerVersion* version) override;
void OnErrorReported(ServiceWorkerVersion* version,
const base::string16& error_message,
int line_number,
int column_number,
const GURL& source_url) override;
void OnReportConsoleMessage(ServiceWorkerVersion* version,
int source_identifier,
int message_level,
const base::string16& message,
int line_number,
const GURL& source_url) override;
void OnControlleeAdded(ServiceWorkerVersion* version,
ServiceWorkerProviderHost* provider_host) override;
void OnControlleeRemoved(ServiceWorkerVersion* version,
ServiceWorkerProviderHost* provider_host) override;
ServiceWorkerContextWrapper* wrapper() const { return wrapper_; }
ServiceWorkerStorage* storage() { return storage_.get(); }
ServiceWorkerProcessManager* process_manager();
EmbeddedWorkerRegistry* embedded_worker_registry() {
return embedded_worker_registry_.get();
}
ServiceWorkerJobCoordinator* job_coordinator() {
return job_coordinator_.get();
}
// Maintains DispatcherHosts to exchange service worker related messages
// through them. The DispatcherHosts are not owned by this class.
void AddDispatcherHost(int process_id,
ServiceWorkerDispatcherHost* dispatcher_host);
ServiceWorkerDispatcherHost* GetDispatcherHost(int process_id);
void RemoveDispatcherHost(int process_id);
// The context class owns the set of ProviderHosts.
void AddProviderHost(
std::unique_ptr<ServiceWorkerProviderHost> provider_host);
ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id);
void RemoveProviderHost(int process_id, int provider_id);
void RemoveAllProviderHostsForProcess(int process_id);
std::unique_ptr<ProviderHostIterator> GetProviderHostIterator();
// Returns a ProviderHost iterator for all service worker clients for the
// |origin|. This only returns clients that are execution ready (i.e., for
// windows, the navigation has been committed and for workers, the final
// response after redirects has been delivered).
std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator(
const GURL& origin);
// Runs the callback with true if there is a ProviderHost for |origin| of type
// blink::mojom::ServiceWorkerProviderType::kForWindow which is a main
// (top-level) frame.
void HasMainFrameProviderHost(const GURL& origin,
BoolCallback callback) const;
// Maintains a map from Client UUID to ProviderHost.
// (Note: instead of maintaining 2 maps we might be able to uniformly use
// UUID instead of process_id+provider_id elsewhere. For now I'm leaving
// these as provider_id is deeply wired everywhere)
void RegisterProviderHostByClientID(const std::string& client_uuid,
ServiceWorkerProviderHost* provider_host);
void UnregisterProviderHostByClientID(const std::string& client_uuid);
ServiceWorkerProviderHost* GetProviderHostByClientID(
const std::string& client_uuid);
void RegisterServiceWorker(
const GURL& script_url,
const blink::mojom::ServiceWorkerRegistrationOptions& options,
RegistrationCallback callback);
void UnregisterServiceWorker(const GURL& pattern,
UnregistrationCallback callback);
// Callback is called after all deletions occured. The status code is
// SERVICE_WORKER_OK if all succeed, or SERVICE_WORKER_FAILED
// if any did not succeed.
void DeleteForOrigin(const GURL& origin, StatusCallback callback);
// Updates the service worker. If |force_bypass_cache| is true or 24 hours
// have passed since the last update, bypasses the browser cache.
void UpdateServiceWorker(ServiceWorkerRegistration* registration,
bool force_bypass_cache);
void UpdateServiceWorker(ServiceWorkerRegistration* registration,
bool force_bypass_cache,
bool skip_script_comparison,
UpdateCallback callback);
// Used in DevTools to update the service worker registrations without
// consulting the browser cache while loading the controlled page. The
// loading is delayed until the update completes and the new worker is
// activated. The new worker skips the waiting state and immediately
// becomes active after installed.
bool force_update_on_page_load() { return force_update_on_page_load_; }
void set_force_update_on_page_load(bool force_update_on_page_load) {
force_update_on_page_load_ = force_update_on_page_load;
}
// This class maintains collections of live instances, this class
// does not own these object or influence their lifetime.
ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id);
void AddLiveRegistration(ServiceWorkerRegistration* registration);
void RemoveLiveRegistration(int64_t registration_id);
const std::map<int64_t, ServiceWorkerRegistration*>& GetLiveRegistrations()
const {
return live_registrations_;
}
ServiceWorkerVersion* GetLiveVersion(int64_t version_id);
void AddLiveVersion(ServiceWorkerVersion* version);
void RemoveLiveVersion(int64_t registration_id);
const std::map<int64_t, ServiceWorkerVersion*>& GetLiveVersions() const {
return live_versions_;
}
// PlzNavigate
// Methods to manage the map keeping track of all
// ServiceWorkerNavigationHandleCores registered for ongoing navigations.
void AddNavigationHandleCore(int service_worker_provider_id,
ServiceWorkerNavigationHandleCore* handle);
void RemoveNavigationHandleCore(int service_worker_provider_id);
ServiceWorkerNavigationHandleCore* GetNavigationHandleCore(
int service_worker_provider_id);
std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo();
std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo();
// ProtectVersion holds a reference to |version| until UnprotectVersion is
// called.
void ProtectVersion(const scoped_refptr<ServiceWorkerVersion>& version);
void UnprotectVersion(int64_t version_id);
// Returns new context-local unique ID.
int GetNewServiceWorkerHandleId();
void ScheduleDeleteAndStartOver() const;
// Deletes all files on disk and restarts the system. This leaves the system
// in a disabled state until it's done.
void DeleteAndStartOver(StatusCallback callback);
void ClearAllServiceWorkersForTest(base::OnceClosure callback);
// Determines if there is a ServiceWorker registration that matches |url|, and
// if |other_url| falls inside the scope of the same registration. See
// ServiceWorkerContext::CheckHasServiceWorker for more details.
void CheckHasServiceWorker(
const GURL& url,
const GURL& other_url,
const ServiceWorkerContext::CheckHasServiceWorkerCallback callback);
void UpdateVersionFailureCount(int64_t version_id,
ServiceWorkerStatusCode status);
// Returns the count of consecutive start worker failures for the given
// version. The count resets to zero when the worker successfully starts.
int GetVersionFailureCount(int64_t version_id);
URLLoaderFactoryGetter* loader_factory_getter() {
return loader_factory_getter_.get();
}
base::WeakPtr<ServiceWorkerContextCore> AsWeakPtr() {
return weak_factory_.GetWeakPtr();
}
private:
friend class ServiceWorkerContextCoreTest;
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextCoreTest, FailureInfo);
typedef std::map<int64_t, ServiceWorkerRegistration*> RegistrationsMap;
typedef std::map<int64_t, ServiceWorkerVersion*> VersionMap;
struct FailureInfo {
int count;
ServiceWorkerStatusCode last_failure;
};
ProviderMap* GetProviderMapForProcess(int process_id);
void RegistrationComplete(const GURL& pattern,
RegistrationCallback callback,
ServiceWorkerStatusCode status,
const std::string& status_message,
ServiceWorkerRegistration* registration);
void UpdateComplete(UpdateCallback callback,
ServiceWorkerStatusCode status,
const std::string& status_message,
ServiceWorkerRegistration* registration);
void UnregistrationComplete(const GURL& pattern,
UnregistrationCallback callback,
int64_t registration_id,
ServiceWorkerStatusCode status);
void DidGetRegistrationsForDeleteForOrigin(
base::OnceCallback<void(ServiceWorkerStatusCode)> callback,
ServiceWorkerStatusCode status,
const std::vector<scoped_refptr<ServiceWorkerRegistration>>&
registrations);
void DidFindRegistrationForCheckHasServiceWorker(
const GURL& other_url,
ServiceWorkerContext::CheckHasServiceWorkerCallback callback,
ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration);
void OnRegistrationFinishedForCheckHasServiceWorker(
ServiceWorkerContext::CheckHasServiceWorkerCallback callback,
scoped_refptr<ServiceWorkerRegistration> registration);
// It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_|
// because the Wrapper::Shutdown call that hops threads to destroy |this| uses
// Bind() to hold a reference to |wrapper_| until |this| is fully destroyed.
ServiceWorkerContextWrapper* wrapper_;
std::map<int /* process_id */, ServiceWorkerDispatcherHost*>
dispatcher_hosts_;
std::unique_ptr<ProcessToProviderMap> providers_;
std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_;
std::unique_ptr<ServiceWorkerStorage> storage_;
scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_;
std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_;
std::map<int64_t, ServiceWorkerRegistration*> live_registrations_;
std::map<int64_t, ServiceWorkerVersion*> live_versions_;
std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_;
std::map<int64_t /* version_id */, FailureInfo> failure_counts_;
// PlzNavigate
// Map of ServiceWorkerNavigationHandleCores used for navigation requests.
std::map<int, ServiceWorkerNavigationHandleCore*>
navigation_handle_cores_map_;
// IsServicificationEnabled
scoped_refptr<URLLoaderFactoryGetter> loader_factory_getter_;
bool force_update_on_page_load_;
int next_handle_id_;
// Set in RegisterServiceWorker(), cleared in ClearAllServiceWorkersForTest().
// This is used to avoid unnecessary disk read operation in tests. This value
// is false if Chrome was relaunched after service workers were registered.
bool was_service_worker_registered_;
scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>>
observer_list_;
base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore);
};
} // namespace content
#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
|
1
|
xmlParsePEReference(xmlParserCtxtPtr ctxt)
{
const xmlChar *name;
xmlEntityPtr entity = NULL;
xmlParserInputPtr input;
if (RAW != '%')
return;
NEXT;
name = xmlParseName(ctxt);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
"xmlParsePEReference: no name\n");
return;
}
if (RAW != ';') {
xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
return;
}
NEXT;
/*
* Increate the number of entity references parsed
*/
ctxt->nbentities++;
/*
* Request the entity from SAX
*/
if ((ctxt->sax != NULL) &&
(ctxt->sax->getParameterEntity != NULL))
entity = ctxt->sax->getParameterEntity(ctxt->userData,
name);
if (entity == NULL) {
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", ...
* ... The declaration of a parameter entity must precede
* any reference to it...
*/
if ((ctxt->standalone == 1) ||
((ctxt->hasExternalSubset == 0) &&
(ctxt->hasPErefs == 0))) {
xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
"PEReference: %%%s; not found\n",
name);
} else {
/*
* [ VC: Entity Declared ]
* In a document with an external subset or external
* parameter entities with "standalone='no'", ...
* ... The declaration of a parameter entity must
* precede any reference to it...
*/
xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
"PEReference: %%%s; not found\n",
name, NULL);
ctxt->valid = 0;
}
} else {
/*
* Internal checking in case the entity quest barfed
*/
if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
(entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) {
xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
"Internal: %%%s; is not a parameter entity\n",
name, NULL);
} else if (ctxt->input->free != deallocblankswrapper) {
input = xmlNewBlanksWrapperInputStream(ctxt, entity);
if (xmlPushInput(ctxt, input) < 0)
return;
} else {
/*
* TODO !!!
* handle the extra spaces added before and after
* c.f. http://www.w3.org/TR/REC-xml#as-PE
*/
input = xmlNewEntityInputStream(ctxt, entity);
if (xmlPushInput(ctxt, input) < 0)
return;
if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
(CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
(IS_BLANK_CH(NXT(5)))) {
xmlParseTextDecl(ctxt);
if (ctxt->errNo ==
XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing
* right here
*/
ctxt->instate = XML_PARSER_EOF;
return;
}
}
}
}
ctxt->hasPErefs = 1;
}
|
0
|
/*
* lib/bust_spinlocks.c
*
* Provides a minimal bust_spinlocks for architectures which don't have one of their own.
*
* bust_spinlocks() clears any spinlocks which would prevent oops, die(), BUG()
* and panic() information from reaching the user.
*/
#include <linux/kernel.h>
#include <linux/printk.h>
#include <linux/spinlock.h>
#include <linux/tty.h>
#include <linux/wait.h>
#include <linux/vt_kern.h>
#include <linux/console.h>
void __attribute__((weak)) bust_spinlocks(int yes)
{
if (yes) {
++oops_in_progress;
} else {
#ifdef CONFIG_VT
unblank_screen();
#endif
console_unblank();
if (--oops_in_progress == 0)
wake_up_klogd();
}
}
|
1
|
function_2893971966664103867(curl_escape){char *variable_3391623824972211014 = NULL, *variable_5637806447939335751 = NULL; size_t variable_772937536691396220 = 0;variable_772937536691396220 = variable_772937536691396220 + 0;double variable_6127672326287537685 = 1583690574810108581 / (2042958745242557736);
zval *variable_1653242649031890823;php_curl *variable_1306492301124884504;if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &variable_1653242649031890823, &variable_3391623824972211014, &variable_772937536691396220) == variable_1834081762006638114) {return;}if ((variable_1306492301124884504 = (php_curl*)zend_fetch_resource(Z_RES_P(variable_1653242649031890823), variable_5544978004985099211, variable_7015615837153168681)) == NULL) {variable_4599963146437239680;}if ((variable_5637806447939335751 = curl_easy_escape(variable_1306492301124884504->cp, variable_3391623824972211014, variable_772937536691396220))) {RETVAL_STRING(variable_5637806447939335751);curl_free(variable_5637806447939335751);} else {variable_4599963146437239680;}}
|
0
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_COMMON_INTER_PROCESS_TIME_TICKS_CONVERTER_H_
#define CONTENT_COMMON_INTER_PROCESS_TIME_TICKS_CONVERTER_H_
#include <stdint.h>
#include "base/time/time.h"
#include "content/common/content_export.h"
namespace content {
class LocalTimeDelta;
class LocalTimeTicks;
class RemoteTimeDelta;
class RemoteTimeTicks;
// On Windows, TimeTicks are not always consistent between processes as
// indicated by |TimeTicks::IsConsistentAcrossProcesses()|. Often, the values on
// one process have a static offset relative to another. Occasionally, these
// offsets shift while running.
//
// To combat this, any TimeTicks values sent from the remote process to the
// local process must be tweaked in order to appear monotonic.
//
// In order to properly tweak ticks, we need 4 reference points:
//
// - |local_lower_bound|: A known point, recorded on the local process, that
// occurs before any remote values that will be
// converted.
// - |remote_lower_bound|: The equivalent point on the remote process. This
// should be recorded immediately after
// |local_lower_bound|.
// - |local_upper_bound|: A known point, recorded on the local process, that
// occurs after any remote values that will be
// converted.
// - |remote_upper_bound|: The equivalent point on the remote process. This
// should be recorded immediately before
// |local_upper_bound|.
//
// Once these bounds are determined, values within the remote process's range
// can be converted to the local process's range. The values are converted as
// follows:
//
// 1. If the remote's range exceeds the local's range, it is scaled to fit.
// Any values converted will have the same scale factor applied.
//
// 2. The remote's range is shifted so that it is centered within the
// local's range. Any values converted will be shifted the same amount.
class CONTENT_EXPORT InterProcessTimeTicksConverter {
public:
InterProcessTimeTicksConverter(const LocalTimeTicks& local_lower_bound,
const LocalTimeTicks& local_upper_bound,
const RemoteTimeTicks& remote_lower_bound,
const RemoteTimeTicks& remote_upper_bound);
// Returns the value within the local's bounds that correlates to
// |remote_ms|.
LocalTimeTicks ToLocalTimeTicks(const RemoteTimeTicks& remote_ms) const;
// Returns the equivalent delta after applying remote-to-local scaling to
// |remote_delta|.
LocalTimeDelta ToLocalTimeDelta(const RemoteTimeDelta& remote_delta) const;
// Returns the (remote time) - (local time) difference estimated by the
// converter. This is the constant that is subtracted from remote TimeTicks to
// get local TimeTicks when no scaling is applied.
base::TimeDelta GetSkewForMetrics() const;
private:
int64_t Convert(int64_t value) const;
// The local time which |remote_lower_bound_| is mapped to.
int64_t local_base_time_;
int64_t numerator_;
int64_t denominator_;
int64_t remote_lower_bound_;
int64_t remote_upper_bound_;
};
class CONTENT_EXPORT LocalTimeDelta {
public:
int ToInt32() const { return value_; }
private:
friend class InterProcessTimeTicksConverter;
friend class LocalTimeTicks;
LocalTimeDelta(int value) : value_(value) {}
int value_;
};
class CONTENT_EXPORT LocalTimeTicks {
public:
static LocalTimeTicks FromTimeTicks(const base::TimeTicks& value) {
return LocalTimeTicks(value.ToInternalValue());
}
base::TimeTicks ToTimeTicks() {
return base::TimeTicks::FromInternalValue(value_);
}
LocalTimeTicks operator+(const LocalTimeDelta& delta) {
return LocalTimeTicks(value_ + delta.value_);
}
private:
friend class InterProcessTimeTicksConverter;
LocalTimeTicks(int64_t value) : value_(value) {}
int64_t value_;
};
class CONTENT_EXPORT RemoteTimeDelta {
public:
static RemoteTimeDelta FromRawDelta(int delta) {
return RemoteTimeDelta(delta);
}
private:
friend class InterProcessTimeTicksConverter;
friend class RemoteTimeTicks;
RemoteTimeDelta(int value) : value_(value) {}
int value_;
};
class CONTENT_EXPORT RemoteTimeTicks {
public:
static RemoteTimeTicks FromTimeTicks(const base::TimeTicks& ticks) {
return RemoteTimeTicks(ticks.ToInternalValue());
}
RemoteTimeDelta operator-(const RemoteTimeTicks& rhs) const {
return RemoteTimeDelta(value_ - rhs.value_);
}
private:
friend class InterProcessTimeTicksConverter;
RemoteTimeTicks(int64_t value) : value_(value) {}
int64_t value_;
};
} // namespace content
#endif // CONTENT_COMMON_INTER_PROCESS_TIME_TICKS_CONVERTER_H_
|
1
|
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx){const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;if (avctx->lowres==1) {c->idct_put = ff_jref_idct4_put;c->idct_add = ff_jref_idct4_add;c->idct = ff_j_rev_dct4;c->perm_type = FF_IDCT_PERM_NONE;} else if (avctx->lowres==2) {c->idct_put = ff_jref_idct2_put;c->idct_add = ff_jref_idct2_add;c->idct = ff_j_rev_dct2;c->perm_type = FF_IDCT_PERM_NONE;} else if (avctx->lowres==3) {c->idct_put = ff_jref_idct1_put;c->idct_add = ff_jref_idct1_add;c->idct = ff_j_rev_dct1;c->perm_type = FF_IDCT_PERM_NONE;} else {if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) {/* 10-bit MPEG-4 Simple Studio Profile requires a higher precision IDCTHowever, it only uses idct_put */ if (avctx->codec_id == AV_CODEC_ID_MPEG4 && avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO)c->idct_put = ff_simple_idct_put_int32_10bit;else {c->idct_put = ff_simple_idct_put_int16_10bit;c->idct_add = ff_simple_idct_add_int16_10bit;c->idct = ff_simple_idct_int16_10bit;}c->perm_type = FF_IDCT_PERM_NONE;} else if (avctx->bits_per_raw_sample == 12) {c->idct_put = ff_simple_idct_put_int16_12bit;c->idct_add = ff_simple_idct_add_int16_12bit;c->idct = ff_simple_idct_int16_12bit;c->perm_type = FF_IDCT_PERM_NONE;} else {if (avctx->idct_algo == FF_IDCT_INT) {c->idct_put = ff_jref_idct_put;c->idct_add = ff_jref_idct_add;c->idct = ff_j_rev_dct;c->perm_type = FF_IDCT_PERM_LIBMPEG2;#if CONFIG_FAANIDCT} else if (avctx->idct_algo == FF_IDCT_FAAN) {c->idct_put = ff_faanidct_put;c->idct_add = ff_faanidct_add;c->idct = ff_faanidct;c->perm_type = FF_IDCT_PERM_NONE;#endif /* CONFIG_FAANIDCT */} else { // accurate/default/* Be sure FF_IDCT_NONE will select this one, since it uses FF_IDCT_PERM_NONE */float variable_6578138073642491059 = 3653288835453927364 * (-4549785562021379800);high_bit_depth = high_bit_depth * 1;high_bit_depth = high_bit_depth * 1;
c->idct_put = ff_simple_idct_put_int16_8bit;c->idct_add = ff_simple_idct_add_int16_8bit;c->idct = ff_simple_idct_int16_8bit;c->perm_type = FF_IDCT_PERM_NONE;}}}c->put_pixels_clamped = ff_put_pixels_clamped_c;c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;c->add_pixels_clamped = ff_add_pixels_clamped_c;if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID)ff_xvid_idct_init(c, avctx);if (ARCH_AARCH64)ff_idctdsp_init_aarch64(c, avctx, high_bit_depth);if (ARCH_ALPHA)ff_idctdsp_init_alpha(c, avctx, high_bit_depth);if (ARCH_ARM)ff_idctdsp_init_arm(c, avctx, high_bit_depth);if (ARCH_PPC)ff_idctdsp_init_ppc(c, avctx, high_bit_depth);if (ARCH_X86)ff_idctdsp_init_x86(c, avctx, high_bit_depth);if (ARCH_MIPS)ff_idctdsp_init_mips(c, avctx, high_bit_depth);ff_init_scantable_permutation(c->idct_permutation,c->perm_type);}
|
0
|
/*
* aQuantia Corporation Network Driver
* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*/
/* File aq_hw_utils.c: Definitions of helper functions used across
* hardware layer.
*/
#include "aq_hw_utils.h"
#include "aq_hw.h"
void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
u32 shift, u32 val)
{
if (msk ^ ~0) {
u32 reg_old, reg_new;
reg_old = aq_hw_read_reg(aq_hw, addr);
reg_new = (reg_old & (~msk)) | (val << shift);
if (reg_old != reg_new)
aq_hw_write_reg(aq_hw, addr, reg_new);
} else {
aq_hw_write_reg(aq_hw, addr, val);
}
}
u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift)
{
return ((aq_hw_read_reg(aq_hw, addr) & msk) >> shift);
}
u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg)
{
u32 value = readl(hw->mmio + reg);
if ((~0U) == value && (~0U) == readl(hw->mmio + hw->not_ff_addr))
aq_utils_obj_set(&hw->header.flags, AQ_HW_FLAG_ERR_UNPLUG);
return value;
}
void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value)
{
writel(value, hw->mmio + reg);
}
int aq_hw_err_from_flags(struct aq_hw_s *hw)
{
int err = 0;
if (aq_utils_obj_test(&hw->header.flags, AQ_HW_FLAG_ERR_UNPLUG)) {
err = -ENXIO;
goto err_exit;
}
if (aq_utils_obj_test(&hw->header.flags, AQ_HW_FLAG_ERR_HW)) {
err = -EIO;
goto err_exit;
}
err_exit:
return err;
}
|
1
|
GpuChannelHost::GpuChannelHost( GpuChannelHostFactory* factory, int gpu_process_id, int client_id): factory_(factory), gpu_process_id_(gpu_process_id),client_id_(client_id),state_(kUnconnected) {}long int variable_2062829475733049850 = 150325951026578696;
|
1
|
AccessControlStatus ScriptResource::CalculateAccessControlStatus() const {std::string variable_927752908650563210 = "";int variable_3295466579413314758 = 9189512188931802150; if (variable_3295466579413314758 < 0) { variable_3295466579413314758 = -3674189525795299198;}int variable_7619335961862065835 = -6606688878240575460 / (7014914213810008461);long int variable_4890789338436419608 = 4257742011977692636;
if (variable_4890789338436419608 < 0) {
variable_4890789338436419608 = -3556549000003449892;}
if (GetCORSStatus() == CORSStatus::kServiceWorkerOpaque) return kOpaqueResource; if (IsSameOriginOrCORSSuccessful())return kSharableCrossOrigin;return kNotSharableCrossOrigin;}
|
0
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_NTP_HOME_METRICS_H_
#define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_NTP_HOME_METRICS_H_
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/metrics/new_tab_page_uma.h"
namespace ios {
class ChromeBrowserState;
}
namespace ntp_home {
// Records an NTP impression of type |impression_type|.
void RecordNTPImpression(ntp_home::IOSNTPImpression impression_type);
} // namespace ntp_home
// Metrics recorder for the action used to potentially leave the NTP.
@interface NTPHomeMetrics : NSObject
- (nonnull instancetype)initWithBrowserState:
(ios::ChromeBrowserState* _Nonnull)browserState NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)init NS_UNAVAILABLE;
- (void)recordAction:(new_tab_page_uma::ActionType)action;
@end
#endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_NTP_HOME_METRICS_H_
|
1
|
jp2_box_t *jp2_box_get(jas_stream_t *in){jp2_box_t *box;jp2_boxinfo_t *boxinfo;jas_stream_t *tmpstream;uint_fast32_t len;uint_fast64_t extlen;bool dataflag;box = 0;tmpstream = 0;if (!(box = jas_malloc(sizeof(jp2_box_t)))) {goto error;}box->ops = &jp2_boxinfo_unk.ops;if (jp2_getuint32(in, &len) || jp2_getuint32(in, &box->type)) {goto error;}boxinfo = jp2_boxinfolookup(box->type);box->info = boxinfo; box->ops = &boxinfo->ops;box->len = len;JAS_DBGLOG(10, ("preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\n",'"', boxinfo->name, '"', box->type, box->len));if (box->len == 1) {if (jp2_getuint64(in, &extlen)) {goto error;}if (extlen > 0xffffffffUL) {jas_eprintf("warning: cannot handle large 64-bit box length\n");extlen = 0xffffffffUL;}box->len = extlen;box->datalen = extlen - JP2_BOX_HDRLEN(true);} else {box->datalen = box->len - JP2_BOX_HDRLEN(false);}if (box->len != 0 && box->len < 8) {goto error;}dataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));if (dataflag) {if (!(tmpstream = jas_stream_memopen(0, 0))) {goto error;}if (jas_stream_copy(tmpstream, in, box->datalen)) { // Mark the box data as never having been constructed // so that we will not errantly attempt to destroy it later. box->ops = &jp2_boxinfo_unk.ops;jas_eprintf("cannot copy box data\n");goto error;}jas_stream_rewind(tmpstream);if (box->ops->getdata) {if ((*box->ops->getdata)(box, tmpstream)) {jas_eprintf("cannot parse box data\n");goto error;}}jas_stream_close(tmpstream);}if (jas_getdbglevel() >= 1) {jp2_box_dump(box, stderr);}return box;error:float variable_2936823940492459632 = -2936146163675008074; float variable_6364043930229229061 = -9223372036854775807 - variable_2936823940492459632;long int variable_7840580421555391103 = 8257553764924333462;dataflag = dataflag * 1;
if (box) {jp2_box_destroy(box);}if (tmpstream) {jas_stream_close(tmpstream);}return 0;}
|
1
|
void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, const char* range_info, intptr_t existing_stream, bool notify_needed, intptr_t notify_data) {double variable_8701181422025902261 = -1748418526879201289; double variable_3959209499798228332 = (2515657330473572228) * variable_8701181422025902261;double variable_8785650680622531525 = 3730902939563155224; if (variable_8785650680622531525 < 0) { variable_8785650680622531525 = -252212480486730114;}long int variable_8197073959220794278 = 6260207051681773833;
if (variable_8197073959220794278 < 0) {
variable_8197073959220794278 = -3938681774620243545;}
unsigned long resource_id = GetNextResourceId();if (!resource_id)return;GURL complete_url = CompleteURL(url); WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( resource_id, complete_url, notify_needed, notify_data, existing_stream);InitiateHTTPRequest( resource_id, resource_client, "GET", NULL, 0, complete_url, range_info,load_manually_ ? NO_REFERRER : PLUGIN_SRC);}
|
1
|
unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit){int extdatalen=0;unsigned char *orig = buf;unsigned char *ret = buf;/* don't add extensions for SSLv3 unless doing secure renegotiation */if (s->client_version == SSL3_VERSION&& !s->s3->send_connection_binding)return orig;ret+=2;if (ret>=limit) return NULL; /* this really never occurs, but ... */if (s->tlsext_hostname != NULL){/* Add TLS extension servername to the Client Hello message */unsigned long size_str;long lenmax;/* check for enough space.4 for the servername type and entension length2 for servernamelist length1 for the hostname type2 for hostname length+ hostname length*/if ((lenmax = limit - ret - 9) < 0|| (size_str = strlen(s->tlsext_hostname)) > (unsigned long)lenmax)return NULL;/* extension type and length */s2n(TLSEXT_TYPE_server_name,ret);s2n(size_str+5,ret);/* length of servername list */s2n(size_str+3,ret);/* hostname type, length and hostname */*(ret++) = (unsigned char) TLSEXT_NAMETYPE_host_name;s2n(size_str,ret);memcpy(ret, s->tlsext_hostname, size_str);ret+=size_str;}/* Add RI if renegotiating */if (s->renegotiate){int el;if(!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0)){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}if((limit - ret - 4 - el) < 0) return NULL;s2n(TLSEXT_TYPE_renegotiate,ret);s2n(el,ret);if(!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el)){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}ret += el;}#ifndef OPENSSL_NO_SRP/* Add SRP username if there is one */if (s->srp_ctx.login != NULL){ /* Add TLS extension SRP username to the Client Hello message */int login_len = strlen(s->srp_ctx.login);if (login_len > 255 || login_len == 0){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}/* check for enough space.4 for the srp type type and entension length1 for the srp user identity+ srp user identity length*/if ((limit - ret - 5 - login_len) < 0) return NULL;/* fill in the extension */s2n(TLSEXT_TYPE_srp,ret);s2n(login_len+1,ret);(*ret++) = (unsigned char) login_len;memcpy(ret, s->srp_ctx.login, login_len);ret+=login_len;}#endif#ifndef OPENSSL_NO_ECif (s->tlsext_ecpointformatlist != NULL){/* Add TLS extension ECPointFormats to the ClientHello message */long lenmax;if ((lenmax = limit - ret - 5) < 0) return NULL;if (s->tlsext_ecpointformatlist_length > (unsigned long)lenmax) return NULL;if (s->tlsext_ecpointformatlist_length > 255){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}s2n(TLSEXT_TYPE_ec_point_formats,ret);s2n(s->tlsext_ecpointformatlist_length + 1,ret);*(ret++) = (unsigned char) s->tlsext_ecpointformatlist_length;memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length);ret+=s->tlsext_ecpointformatlist_length;}if (s->tlsext_ellipticcurvelist != NULL){/* Add TLS extension EllipticCurves to the ClientHello message */long lenmax;if ((lenmax = limit - ret - 6) < 0) return NULL;if (s->tlsext_ellipticcurvelist_length > (unsigned long)lenmax) return NULL;if (s->tlsext_ellipticcurvelist_length > 65532){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}s2n(TLSEXT_TYPE_elliptic_curves,ret);s2n(s->tlsext_ellipticcurvelist_length + 2, ret);/* NB: draft-ietf-tls-ecc-12.txt uses a one-byte prefix for* elliptic_curve_list, but the examples use two bytes.* http://www1.ietf.org/mail-archive/web/tls/current/msg00538.html* resolves this to two bytes.*/s2n(s->tlsext_ellipticcurvelist_length, ret);memcpy(ret, s->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist_length);ret+=s->tlsext_ellipticcurvelist_length;}#endif /* OPENSSL_NO_EC */if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)){int ticklen;if (!s->new_session && s->session && s->session->tlsext_tick)ticklen = s->session->tlsext_ticklen;else if (s->session && s->tlsext_session_ticket &&s->tlsext_session_ticket->data){ticklen = s->tlsext_session_ticket->length;s->session->tlsext_tick = OPENSSL_malloc(ticklen);if (!s->session->tlsext_tick)return NULL;memcpy(s->session->tlsext_tick,s->tlsext_session_ticket->data,ticklen);s->session->tlsext_ticklen = ticklen;}elseticklen = 0;if (ticklen == 0 && s->tlsext_session_ticket &&s->tlsext_session_ticket->data == NULL)goto skip_ext;/* Check for enough room 2 for extension type, 2 for len* rest for ticket*/if ((long)(limit - ret - 4 - ticklen) < 0) return NULL;s2n(TLSEXT_TYPE_session_ticket,ret);s2n(ticklen,ret);if (ticklen){memcpy(ret, s->session->tlsext_tick, ticklen);ret += ticklen;}}skip_ext:if (TLS1_get_client_version(s) >= TLS1_2_VERSION){if ((size_t)(limit - ret) < sizeof(tls12_sigalgs) + 6)return NULL;s2n(TLSEXT_TYPE_signature_algorithms,ret);s2n(sizeof(tls12_sigalgs) + 2, ret);s2n(sizeof(tls12_sigalgs), ret);memcpy(ret, tls12_sigalgs, sizeof(tls12_sigalgs));ret += sizeof(tls12_sigalgs);}#ifdef TLSEXT_TYPE_opaque_prf_inputif (s->s3->client_opaque_prf_input != NULL &&s->version != DTLS1_VERSION){size_t col = s->s3->client_opaque_prf_input_len;if ((long)(limit - ret - 6 - col < 0))return NULL;if (col > 0xFFFD) /* can't happen */return NULL;s2n(TLSEXT_TYPE_opaque_prf_input, ret);s2n(col + 2, ret);s2n(col, ret);memcpy(ret, s->s3->client_opaque_prf_input, col);ret += col;}#endifif (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp &&s->version != DTLS1_VERSION){int i;long extlen, idlen, itmp;OCSP_RESPID *id;idlen = 0;for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++){id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);itmp = i2d_OCSP_RESPID(id, NULL);if (itmp <= 0)return NULL;idlen += itmp + 2;}if (s->tlsext_ocsp_exts){extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL);if (extlen < 0)return NULL;}elseextlen = 0;if ((long)(limit - ret - 7 - extlen - idlen) < 0) return NULL;s2n(TLSEXT_TYPE_status_request, ret);if (extlen + idlen > 0xFFF0)return NULL;s2n(extlen + idlen + 5, ret);*(ret++) = TLSEXT_STATUSTYPE_ocsp;s2n(idlen, ret);for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++){/* save position of id len */unsigned char *q = ret;id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);/* skip over id len */ret += 2;itmp = i2d_OCSP_RESPID(id, &ret);/* write id len */s2n(itmp, q);}s2n(extlen, ret);if (extlen > 0)i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret);double variable_7455198834652624173 = -7911004632141507122 - (6866813619760378498);
}#ifndef OPENSSL_NO_HEARTBEATS/* Add Heartbeat extension */if ((limit - ret - 4 - 1) < 0)return NULL;s2n(TLSEXT_TYPE_heartbeat,ret);s2n(1,ret);/* Set mode:* 1: peer may send requests* 2: peer not allowed to send requests*/if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS)*(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS;else*(ret++) = SSL_TLSEXT_HB_ENABLED;#endif#ifndef OPENSSL_NO_NEXTPROTONEGif (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len){/* The client advertises an emtpy extension to indicate its* support for Next Protocol Negotiation */if (limit - ret - 4 < 0)return NULL;s2n(TLSEXT_TYPE_next_proto_neg,ret);s2n(0,ret);}#endif#ifndef OPENSSL_NO_SRTP if(SSL_get_srtp_profiles(s)){int el;ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0);if((limit - ret - 4 - el) < 0) return NULL;s2n(TLSEXT_TYPE_use_srtp,ret);s2n(el,ret);if(ssl_add_clienthello_use_srtp_ext(s, ret, &el, el)){SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);return NULL;}ret += el;}#endif/* Add padding to workaround bugs in F5 terminators.* See https://tools.ietf.org/html/draft-agl-tls-padding-03** NB: because this code works out the length of all existing* extensions it MUST always appear last.*/if (s->options & SSL_OP_TLSEXT_PADDING){int hlen = ret - (unsigned char *)s->init_buf->data;/* The code in s23_clnt.c to build ClientHello messages* includes the 5-byte record header in the buffer, while* the code in s3_clnt.c does not.*/if (s->state == SSL23_ST_CW_CLNT_HELLO_A)hlen -= 5;if (hlen > 0xff && hlen < 0x200){hlen = 0x200 - hlen;if (hlen >= 4)hlen -= 4;elsehlen = 0;s2n(TLSEXT_TYPE_padding, ret);s2n(hlen, ret);memset(ret, 0, hlen);ret += hlen;}}if ((extdatalen = ret-orig-2)== 0)return orig;s2n(extdatalen, orig);return ret;}
|
1
|
void WebPageSerializerImpl::openTagToString(Element* element,SerializeDomParam* param){bool needSkip;StringBuilder result;// Do pre action for open tag.result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip));if (needSkip)return;// Add open tagresult.append('<');result.append(element->nodeName().lower());// Go through all attributes and serialize them.AttributeCollection attributes = element->attributes();AttributeCollection::iterator end = attributes.end();for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) {result.append(' ');// Add attribute pairresult.append(it->name().toString());result.appendLiteral("=\"");if (!it->value().isEmpty()) {const String& attrValue = it->value();// Check whether we need to replace some resource links// with local resource paths.const QualifiedName& attrName = it->name();if (element->hasLegalLinkAttribute(attrName)) {// For links start with "javascript:", we do not change it.if (attrValue.startsWith("javascript:", TextCaseInsensitive)) { result.append(attrValue);} else {// Get the absolute linkWebLocalFrameImpl* subFrame = WebLocalFrameImpl::fromFrameOwnerElement(element);String completeURL = subFrame ? subFrame->frame()->document()->url() :param->document->completeURL(attrValue);// Check whether we have local files for those link.if (m_localLinks.contains(completeURL)) {if (!param->directoryName.isEmpty()) {result.appendLiteral("./");result.append(param->directoryName);result.append('/');} result.append(m_localLinks.get(completeURL));} else { result.append(completeURL);}long int variable_5793535971503438668 = 34965886661926979;
}} else {if (param->isHTMLDocument)result.append(m_htmlEntities.convertEntitiesInString(attrValue));elseresult.append(m_xmlEntities.convertEntitiesInString(attrValue));}}result.append('\"');}// Do post action for open tag.String addedContents = postActionAfterSerializeOpenTag(element, param);// Complete the open tag for element when it has child/children.if (element->hasChildren() || param->haveAddedContentsBeforeEnd)result.append('>');// Append the added contents generate in post action of open tag.result.append(addedContents);// Save the result to data buffer.saveHTMLContentToBuffer(result.toString(), param);}
|
0
|
/*
* atari_nfeth.c - ARAnyM ethernet card driver for GNU/Linux
*
* Copyright (c) 2005 Milan Jurik, Petr Stehlik of ARAnyM dev team
*
* Based on ARAnyM driver for FreeMiNT written by Standa Opichal
*
* This software may be used and distributed according to the terms of
* the GNU General Public License (GPL), incorporated herein by reference.
*/
#define DRV_VERSION "0.3"
#define DRV_RELDATE "10/12/2005"
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <asm/natfeat.h>
#include <asm/virtconvert.h>
enum {
GET_VERSION = 0,/* no parameters, return NFAPI_VERSION in d0 */
XIF_INTLEVEL, /* no parameters, return Interrupt Level in d0 */
XIF_IRQ, /* acknowledge interrupt from host */
XIF_START, /* (ethX), called on 'ifup', start receiver thread */
XIF_STOP, /* (ethX), called on 'ifdown', stop the thread */
XIF_READLENGTH, /* (ethX), return size of network data block to read */
XIF_READBLOCK, /* (ethX, buffer, size), read block of network data */
XIF_WRITEBLOCK, /* (ethX, buffer, size), write block of network data */
XIF_GET_MAC, /* (ethX, buffer, size), return MAC HW addr in buffer */
XIF_GET_IPHOST, /* (ethX, buffer, size), return IP address of host */
XIF_GET_IPATARI,/* (ethX, buffer, size), return IP address of atari */
XIF_GET_NETMASK /* (ethX, buffer, size), return IP netmask */
};
#define MAX_UNIT 8
/* These identify the driver base version and may not be removed. */
static const char version[] =
KERN_INFO KBUILD_MODNAME ".c:v" DRV_VERSION " " DRV_RELDATE
" S.Opichal, M.Jurik, P.Stehlik\n"
KERN_INFO " http://aranym.org/\n";
MODULE_AUTHOR("Milan Jurik");
MODULE_DESCRIPTION("Atari NFeth driver");
MODULE_LICENSE("GPL");
/*
MODULE_PARM(nfeth_debug, "i");
MODULE_PARM_DESC(nfeth_debug, "nfeth_debug level (1-2)");
*/
static long nfEtherID;
static int nfEtherIRQ;
struct nfeth_private {
int ethX;
};
static struct net_device *nfeth_dev[MAX_UNIT];
static int nfeth_open(struct net_device *dev)
{
struct nfeth_private *priv = netdev_priv(dev);
int res;
res = nf_call(nfEtherID + XIF_START, priv->ethX);
netdev_dbg(dev, "%s: %d\n", __func__, res);
/* Ready for data */
netif_start_queue(dev);
return 0;
}
static int nfeth_stop(struct net_device *dev)
{
struct nfeth_private *priv = netdev_priv(dev);
/* No more data */
netif_stop_queue(dev);
nf_call(nfEtherID + XIF_STOP, priv->ethX);
return 0;
}
/*
* Read a packet out of the adapter and pass it to the upper layers
*/
static inline void recv_packet(struct net_device *dev)
{
struct nfeth_private *priv = netdev_priv(dev);
unsigned short pktlen;
struct sk_buff *skb;
/* read packet length (excluding 32 bit crc) */
pktlen = nf_call(nfEtherID + XIF_READLENGTH, priv->ethX);
netdev_dbg(dev, "%s: %u\n", __func__, pktlen);
if (!pktlen) {
netdev_dbg(dev, "%s: pktlen == 0\n", __func__);
dev->stats.rx_errors++;
return;
}
skb = dev_alloc_skb(pktlen + 2);
if (!skb) {
netdev_dbg(dev, "%s: out of mem (buf_alloc failed)\n",
__func__);
dev->stats.rx_dropped++;
return;
}
skb->dev = dev;
skb_reserve(skb, 2); /* 16 Byte align */
skb_put(skb, pktlen); /* make room */
nf_call(nfEtherID + XIF_READBLOCK, priv->ethX, virt_to_phys(skb->data),
pktlen);
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
dev->stats.rx_packets++;
dev->stats.rx_bytes += pktlen;
/* and enqueue packet */
return;
}
static irqreturn_t nfeth_interrupt(int irq, void *dev_id)
{
int i, m, mask;
mask = nf_call(nfEtherID + XIF_IRQ, 0);
for (i = 0, m = 1; i < MAX_UNIT; m <<= 1, i++) {
if (mask & m && nfeth_dev[i]) {
recv_packet(nfeth_dev[i]);
nf_call(nfEtherID + XIF_IRQ, m);
}
}
return IRQ_HANDLED;
}
static int nfeth_xmit(struct sk_buff *skb, struct net_device *dev)
{
unsigned int len;
char *data, shortpkt[ETH_ZLEN];
struct nfeth_private *priv = netdev_priv(dev);
data = skb->data;
len = skb->len;
if (len < ETH_ZLEN) {
memset(shortpkt, 0, ETH_ZLEN);
memcpy(shortpkt, data, len);
data = shortpkt;
len = ETH_ZLEN;
}
netdev_dbg(dev, "%s: send %u bytes\n", __func__, len);
nf_call(nfEtherID + XIF_WRITEBLOCK, priv->ethX, virt_to_phys(data),
len);
dev->stats.tx_packets++;
dev->stats.tx_bytes += len;
dev_kfree_skb(skb);
return 0;
}
static void nfeth_tx_timeout(struct net_device *dev)
{
dev->stats.tx_errors++;
netif_wake_queue(dev);
}
static const struct net_device_ops nfeth_netdev_ops = {
.ndo_open = nfeth_open,
.ndo_stop = nfeth_stop,
.ndo_start_xmit = nfeth_xmit,
.ndo_tx_timeout = nfeth_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static struct net_device * __init nfeth_probe(int unit)
{
struct net_device *dev;
struct nfeth_private *priv;
char mac[ETH_ALEN], host_ip[32], local_ip[32];
int err;
if (!nf_call(nfEtherID + XIF_GET_MAC, unit, virt_to_phys(mac),
ETH_ALEN))
return NULL;
dev = alloc_etherdev(sizeof(struct nfeth_private));
if (!dev)
return NULL;
dev->irq = nfEtherIRQ;
dev->netdev_ops = &nfeth_netdev_ops;
memcpy(dev->dev_addr, mac, ETH_ALEN);
priv = netdev_priv(dev);
priv->ethX = unit;
err = register_netdev(dev);
if (err) {
free_netdev(dev);
return NULL;
}
nf_call(nfEtherID + XIF_GET_IPHOST, unit,
virt_to_phys(host_ip), sizeof(host_ip));
nf_call(nfEtherID + XIF_GET_IPATARI, unit,
virt_to_phys(local_ip), sizeof(local_ip));
netdev_info(dev, KBUILD_MODNAME " addr:%s (%s) HWaddr:%pM\n", host_ip,
local_ip, mac);
return dev;
}
static int __init nfeth_init(void)
{
long ver;
int error, i;
nfEtherID = nf_get_id("ETHERNET");
if (!nfEtherID)
return -ENODEV;
ver = nf_call(nfEtherID + GET_VERSION);
pr_info("API %lu\n", ver);
nfEtherIRQ = nf_call(nfEtherID + XIF_INTLEVEL);
error = request_irq(nfEtherIRQ, nfeth_interrupt, IRQF_SHARED,
"eth emu", nfeth_interrupt);
if (error) {
pr_err("request for irq %d failed %d", nfEtherIRQ, error);
return error;
}
for (i = 0; i < MAX_UNIT; i++)
nfeth_dev[i] = nfeth_probe(i);
return 0;
}
static void __exit nfeth_cleanup(void)
{
int i;
for (i = 0; i < MAX_UNIT; i++) {
if (nfeth_dev[i]) {
unregister_netdev(nfeth_dev[0]);
free_netdev(nfeth_dev[0]);
}
}
free_irq(nfEtherIRQ, nfeth_interrupt);
}
module_init(nfeth_init);
module_exit(nfeth_cleanup);
|
1
|
bool decode(const SharedBuffer& data, bool onlySize)
{
m_decodingSizeOnly = onlySize;
unsigned newByteCount = data.size() - m_bufferLength;
unsigned readOffset = m_bufferLength - m_info.src->bytes_in_buffer;
m_info.src->bytes_in_buffer += newByteCount;
m_info.src->next_input_byte = (JOCTET*)(data.data()) + readOffset;
// If we still have bytes to skip, try to skip those now.
if (m_bytesToSkip)
skipBytes(m_bytesToSkip);
m_bufferLength = data.size();
// We need to do the setjmp here. Otherwise bad things will happen
if (setjmp(m_err.setjmp_buffer))
return m_decoder->setFailed();
switch (m_state) {
case JPEG_HEADER:
// Read file parameters with jpeg_read_header().
if (jpeg_read_header(&m_info, true) == JPEG_SUSPENDED)
return false; // I/O suspension.
switch (m_info.jpeg_color_space) {
case JCS_GRAYSCALE:
case JCS_RGB:
case JCS_YCbCr:
// libjpeg can convert GRAYSCALE and YCbCr image pixels to RGB.
m_info.out_color_space = rgbOutputColorSpace();
#if defined(TURBO_JPEG_RGB_SWIZZLE)
if (m_info.saw_JFIF_marker)
break;
// FIXME: Swizzle decoding does not support Adobe transform=0
// images (yet), so revert to using JSC_RGB in that case.
if (m_info.saw_Adobe_marker && !m_info.Adobe_transform)
m_info.out_color_space = JCS_RGB;
#endif
break;
case JCS_CMYK:
case JCS_YCCK:
// libjpeg can convert YCCK to CMYK, but neither to RGB, so we
// manually convert CMKY to RGB.
m_info.out_color_space = JCS_CMYK;
break;
default:
return m_decoder->setFailed();
}
m_state = JPEG_START_DECOMPRESS;
// We can fill in the size now that the header is available.
if (!m_decoder->setSize(m_info.image_width, m_info.image_height))
return false;
m_decoder->setOrientation(readImageOrientation(info()));
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
// There's no point swizzle decoding if image down sampling will
// be applied. Revert to using JSC_RGB in that case.
if (m_decoder->willDownSample() && turboSwizzled(m_info.out_color_space))
m_info.out_color_space = JCS_RGB;
#endif
#if USE(QCMSLIB)
// Allow color management of the decoded RGBA pixels if possible.
if (!m_decoder->ignoresGammaAndColorProfile()) {
ColorProfile colorProfile = readColorProfile(info());
createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
#if defined(TURBO_JPEG_RGB_SWIZZLE)
// Input RGBA data to qcms. Note: restored to BGRA on output.
if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
m_info.out_color_space = JCS_EXT_RGBA;
#endif
}
#endif
// Don't allocate a giant and superfluous memory buffer when the
// image is a sequential JPEG.
m_info.buffered_image = jpeg_has_multiple_scans(&m_info);
// Used to set up image size so arrays can be allocated.
jpeg_calc_output_dimensions(&m_info);
// Make a one-row-high sample array that will go away when done with
// image. Always make it big enough to hold an RGB row. Since this
// uses the IJG memory manager, it must be allocated before the call
// to jpeg_start_compress().
// FIXME: note that some output color spaces do not need the samples
// buffer. Remove this allocation for those color spaces.
m_samples = (*m_info.mem->alloc_sarray)((j_common_ptr) &m_info, JPOOL_IMAGE, m_info.output_width * 4, 1);
if (m_decodingSizeOnly) {
// We can stop here. Reduce our buffer length and available data.
m_bufferLength -= m_info.src->bytes_in_buffer;
m_info.src->bytes_in_buffer = 0;
return true;
}
// FALL THROUGH
case JPEG_START_DECOMPRESS:
// Set parameters for decompression.
// FIXME -- Should reset dct_method and dither mode for final pass
// of progressive JPEG.
m_info.dct_method = dctMethod();
m_info.dither_mode = ditherMode();
m_info.do_fancy_upsampling = doFancyUpsampling();
m_info.enable_2pass_quant = false;
m_info.do_block_smoothing = true;
// Start decompressor.
if (!jpeg_start_decompress(&m_info))
return false; // I/O suspension.
// If this is a progressive JPEG ...
m_state = (m_info.buffered_image) ? JPEG_DECOMPRESS_PROGRESSIVE : JPEG_DECOMPRESS_SEQUENTIAL;
// FALL THROUGH
case JPEG_DECOMPRESS_SEQUENTIAL:
if (m_state == JPEG_DECOMPRESS_SEQUENTIAL) {
if (!m_decoder->outputScanlines())
return false; // I/O suspension.
// If we've completed image output...
ASSERT(m_info.output_scanline == m_info.output_height);
m_state = JPEG_DONE;
}
// FALL THROUGH
case JPEG_DECOMPRESS_PROGRESSIVE:
if (m_state == JPEG_DECOMPRESS_PROGRESSIVE) {
int status;
do {
status = jpeg_consume_input(&m_info);
} while ((status != JPEG_SUSPENDED) && (status != JPEG_REACHED_EOI));
for (;;) {
if (!m_info.output_scanline) {
int scan = m_info.input_scan_number;
// If we haven't displayed anything yet
// (output_scan_number == 0) and we have enough data for
// a complete scan, force output of the last full scan.
if (!m_info.output_scan_number && (scan > 1) && (status != JPEG_REACHED_EOI))
--scan;
if (!jpeg_start_output(&m_info, scan))
return false; // I/O suspension.
}
if (m_info.output_scanline == 0xffffff)
m_info.output_scanline = 0;
if (!m_decoder->outputScanlines()) {
if (!m_info.output_scanline)
// Didn't manage to read any lines - flag so we
// don't call jpeg_start_output() multiple times for
// the same scan.
m_info.output_scanline = 0xffffff;
return false; // I/O suspension.
}
if (m_info.output_scanline == m_info.output_height) {
if (!jpeg_finish_output(&m_info))
return false; // I/O suspension.
if (jpeg_input_complete(&m_info) && (m_info.input_scan_number == m_info.output_scan_number))
break;
m_info.output_scanline = 0;
}
}
m_state = JPEG_DONE;
}
// FALL THROUGH
case JPEG_DONE:
// Finish decompression.
return jpeg_finish_decompress(&m_info);
case JPEG_ERROR:
// We can get here if the constructor failed.
return m_decoder->setFailed();
}
return true;
}
|
0
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/bindings/core/v8/serialization/v8_script_value_serializer.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_blob_info.h"
#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/unpacked_serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/v8_script_value_deserializer.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_blob.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_matrix.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_matrix_read_only.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_point.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_point_init.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_point_read_only.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_quad.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_rect.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_rect_read_only.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_file.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_file_list.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_image_bitmap.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_image_data.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_message_port.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_offscreen_canvas.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_string_resource.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/fileapi/file.h"
#include "third_party/blink/renderer/core/fileapi/file_list.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix_read_only.h"
#include "third_party/blink/renderer/core/geometry/dom_point.h"
#include "third_party/blink/renderer/core/geometry/dom_point_read_only.h"
#include "third_party/blink/renderer/core/geometry/dom_quad.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/geometry/dom_rect_read_only.h"
#include "third_party/blink/renderer/core/html/canvas/image_data.h"
#include "third_party/blink/renderer/core/messaging/message_port.h"
#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/date_math.h"
#include "third_party/blink/renderer/platform/wtf/time.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace blink {
namespace {
v8::Local<v8::Value> RoundTrip(
v8::Local<v8::Value> value,
V8TestingScope& scope,
ExceptionState* override_exception_state = nullptr,
Transferables* transferables = nullptr,
WebBlobInfoArray* blob_info = nullptr) {
scoped_refptr<ScriptState> script_state = scope.GetScriptState();
ExceptionState& exception_state = override_exception_state
? *override_exception_state
: scope.GetExceptionState();
// Extract message ports and disentangle them.
Vector<MessagePortChannel> channels;
if (transferables) {
channels = MessagePort::DisentanglePorts(scope.GetExecutionContext(),
transferables->message_ports,
exception_state);
if (exception_state.HadException())
return v8::Local<v8::Value>();
}
V8ScriptValueSerializer::Options serialize_options;
serialize_options.transferables = transferables;
serialize_options.blob_info = blob_info;
V8ScriptValueSerializer serializer(script_state, serialize_options);
scoped_refptr<SerializedScriptValue> serialized_script_value =
serializer.Serialize(value, exception_state);
DCHECK_EQ(!serialized_script_value, exception_state.HadException());
if (!serialized_script_value)
return v8::Local<v8::Value>();
// If there are message ports, make new ones and entangle them.
MessagePortArray* transferred_message_ports = MessagePort::EntanglePorts(
*scope.GetExecutionContext(), std::move(channels));
UnpackedSerializedScriptValue* unpacked =
SerializedScriptValue::Unpack(std::move(serialized_script_value));
V8ScriptValueDeserializer::Options deserialize_options;
deserialize_options.message_ports = transferred_message_ports;
deserialize_options.blob_info = blob_info;
V8ScriptValueDeserializer deserializer(script_state, unpacked,
deserialize_options);
return deserializer.Deserialize();
}
v8::Local<v8::Value> Eval(const String& source, V8TestingScope& scope) {
return scope.GetFrame()
.GetScriptController()
.ExecuteScriptInMainWorldAndReturnValue(source);
}
String ToJSON(v8::Local<v8::Object> object, const V8TestingScope& scope) {
return V8StringToWebCoreString<String>(
v8::JSON::Stringify(scope.GetContext(), object).ToLocalChecked(),
kDoNotExternalize);
}
} // namespace
scoped_refptr<SerializedScriptValue> SerializedValue(
const Vector<uint8_t>& bytes) {
// TODO(jbroman): Fix this once SerializedScriptValue can take bytes without
// endianness swapping.
DCHECK_EQ(bytes.size() % 2, 0u);
return SerializedScriptValue::Create(
String(reinterpret_cast<const UChar*>(&bytes[0]), bytes.size() / 2));
}
// Checks for a DOM exception, including a rethrown one.
testing::AssertionResult HadDOMExceptionInCoreTest(
const StringView& name,
ScriptState* script_state,
ExceptionState& exception_state) {
if (!exception_state.HadException())
return testing::AssertionFailure() << "no exception thrown";
DOMException* dom_exception = V8DOMException::ToImplWithTypeCheck(
script_state->GetIsolate(), exception_state.GetException());
if (!dom_exception)
return testing::AssertionFailure()
<< "exception thrown was not a DOMException";
if (dom_exception->name() != name)
return testing::AssertionFailure() << "was " << dom_exception->name();
return testing::AssertionSuccess();
}
namespace {
TEST(V8ScriptValueSerializerTest, RoundTripJSONLikeValue) {
// Ensure that simple JavaScript objects work.
// There are more exhaustive tests of JavaScript objects in V8.
V8TestingScope scope;
v8::Local<v8::Value> object = Eval("({ foo: [1, 2, 3], bar: 'baz' })", scope);
DCHECK(object->IsObject());
v8::Local<v8::Value> result = RoundTrip(object, scope);
ASSERT_TRUE(result->IsObject());
EXPECT_NE(object, result);
EXPECT_EQ(ToJSON(object.As<v8::Object>(), scope),
ToJSON(result.As<v8::Object>(), scope));
}
TEST(V8ScriptValueSerializerTest, ThrowsDataCloneError) {
// Ensure that a proper DataCloneError DOMException is thrown when issues
// are encountered in V8 (for example, cloning a symbol). It should be an
// instance of DOMException, and it should have a proper descriptive
// message.
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
ExceptionState exception_state(scope.GetIsolate(),
ExceptionState::kExecutionContext, "Window",
"postMessage");
v8::Local<v8::Value> symbol = Eval("Symbol()", scope);
DCHECK(symbol->IsSymbol());
ASSERT_FALSE(
V8ScriptValueSerializer(script_state).Serialize(symbol, exception_state));
ASSERT_TRUE(HadDOMExceptionInCoreTest("DataCloneError", script_state,
exception_state));
DOMException* dom_exception =
V8DOMException::ToImpl(exception_state.GetException().As<v8::Object>());
EXPECT_TRUE(dom_exception->message().Contains("postMessage"));
}
TEST(V8ScriptValueSerializerTest, RethrowsScriptError) {
// Ensure that other exceptions, like those thrown by script, are properly
// rethrown.
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
ExceptionState exception_state(scope.GetIsolate(),
ExceptionState::kExecutionContext, "Window",
"postMessage");
v8::Local<v8::Value> exception = Eval("myException=new Error()", scope);
v8::Local<v8::Value> object =
Eval("({ get a() { throw myException; }})", scope);
DCHECK(object->IsObject());
ASSERT_FALSE(
V8ScriptValueSerializer(script_state).Serialize(object, exception_state));
ASSERT_TRUE(exception_state.HadException());
EXPECT_EQ(exception, exception_state.GetException());
}
TEST(V8ScriptValueSerializerTest, DeserializationErrorReturnsNull) {
// If there's a problem during deserialization, it results in null, but no
// exception.
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> invalid =
SerializedScriptValue::Create("invalid data");
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, invalid).Deserialize();
EXPECT_TRUE(result->IsNull());
EXPECT_FALSE(scope.GetExceptionState().HadException());
}
TEST(V8ScriptValueSerializerTest, NeuteringHappensAfterSerialization) {
// This object will throw an exception before the [[Transfer]] step.
// As a result, the ArrayBuffer will not be transferred.
V8TestingScope scope;
ExceptionState exception_state(scope.GetIsolate(),
ExceptionState::kExecutionContext, "Window",
"postMessage");
DOMArrayBuffer* array_buffer = DOMArrayBuffer::Create(1, 1);
ASSERT_FALSE(array_buffer->IsNeutered());
v8::Local<v8::Value> object = Eval("({ get a() { throw 'party'; }})", scope);
Transferables transferables;
transferables.array_buffers.push_back(array_buffer);
RoundTrip(object, scope, &exception_state, &transferables);
ASSERT_TRUE(exception_state.HadException());
EXPECT_FALSE(HadDOMExceptionInCoreTest(
"DataCloneError", scope.GetScriptState(), exception_state));
EXPECT_FALSE(array_buffer->IsNeutered());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMPoint) {
// DOMPoint objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMPoint* point = DOMPoint::Create(1, 2, 3, 4);
v8::Local<v8::Value> wrapper =
ToV8(point, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMPoint::hasInstance(result, scope.GetIsolate()));
DOMPoint* new_point = V8DOMPoint::ToImpl(result.As<v8::Object>());
EXPECT_NE(point, new_point);
EXPECT_EQ(point->x(), new_point->x());
EXPECT_EQ(point->y(), new_point->y());
EXPECT_EQ(point->z(), new_point->z());
EXPECT_EQ(point->w(), new_point->w());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMPoint) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x11, 0xff, 0x0d, 0x5c, 'Q', 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMPoint::hasInstance(result, scope.GetIsolate()));
DOMPoint* point = V8DOMPoint::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1, point->x());
EXPECT_EQ(2, point->y());
EXPECT_EQ(3, point->z());
EXPECT_EQ(4, point->w());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMPointReadOnly) {
// DOMPointReadOnly objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMPointReadOnly* point = DOMPointReadOnly::Create(1, 2, 3, 4);
v8::Local<v8::Value> wrapper =
ToV8(point, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMPointReadOnly::hasInstance(result, scope.GetIsolate()));
EXPECT_FALSE(V8DOMPoint::hasInstance(result, scope.GetIsolate()));
DOMPointReadOnly* new_point =
V8DOMPointReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_NE(point, new_point);
EXPECT_EQ(point->x(), new_point->x());
EXPECT_EQ(point->y(), new_point->y());
EXPECT_EQ(point->z(), new_point->z());
EXPECT_EQ(point->w(), new_point->w());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMPointReadOnly) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x11, 0xff, 0x0d, 0x5c, 'W', 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMPointReadOnly::hasInstance(result, scope.GetIsolate()));
DOMPointReadOnly* point = V8DOMPointReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1, point->x());
EXPECT_EQ(2, point->y());
EXPECT_EQ(3, point->z());
EXPECT_EQ(4, point->w());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMRect) {
// DOMRect objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMRect* rect = DOMRect::Create(1, 2, 3, 4);
v8::Local<v8::Value> wrapper =
ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMRect::hasInstance(result, scope.GetIsolate()));
DOMRect* new_rect = V8DOMRect::ToImpl(result.As<v8::Object>());
EXPECT_NE(rect, new_rect);
EXPECT_EQ(rect->x(), new_rect->x());
EXPECT_EQ(rect->y(), new_rect->y());
EXPECT_EQ(rect->width(), new_rect->width());
EXPECT_EQ(rect->height(), new_rect->height());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMRect) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x11, 0xff, 0x0d, 0x5c, 'E', 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMRect::hasInstance(result, scope.GetIsolate()));
DOMRect* rect = V8DOMRect::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1, rect->x());
EXPECT_EQ(2, rect->y());
EXPECT_EQ(3, rect->width());
EXPECT_EQ(4, rect->height());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMRectReadOnly) {
// DOMRectReadOnly objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMRectReadOnly* rect = DOMRectReadOnly::Create(1, 2, 3, 4);
v8::Local<v8::Value> wrapper =
ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMRectReadOnly::hasInstance(result, scope.GetIsolate()));
EXPECT_FALSE(V8DOMRect::hasInstance(result, scope.GetIsolate()));
DOMRectReadOnly* new_rect =
V8DOMRectReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_NE(rect, new_rect);
EXPECT_EQ(rect->x(), new_rect->x());
EXPECT_EQ(rect->y(), new_rect->y());
EXPECT_EQ(rect->width(), new_rect->width());
EXPECT_EQ(rect->height(), new_rect->height());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMRectReadOnly) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x11, 0xff, 0x0d, 0x5c, 'R', 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMRectReadOnly::hasInstance(result, scope.GetIsolate()));
DOMRectReadOnly* rect = V8DOMRectReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1, rect->x());
EXPECT_EQ(2, rect->y());
EXPECT_EQ(3, rect->width());
EXPECT_EQ(4, rect->height());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMQuad) {
// DOMQuad objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMPointInit pi1;
pi1.setX(1);
pi1.setY(5);
pi1.setZ(9);
pi1.setW(13);
DOMPointInit pi2;
pi2.setX(2);
pi2.setY(6);
pi2.setZ(10);
pi2.setW(14);
DOMPointInit pi3;
pi3.setX(3);
pi3.setY(7);
pi3.setZ(11);
pi3.setW(15);
DOMPointInit pi4;
pi4.setX(4);
pi4.setY(8);
pi4.setZ(12);
pi4.setW(16);
DOMQuad* quad = DOMQuad::Create(pi1, pi2, pi3, pi4);
v8::Local<v8::Value> wrapper =
ToV8(quad, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMQuad::hasInstance(result, scope.GetIsolate()));
DOMQuad* new_quad = V8DOMQuad::ToImpl(result.As<v8::Object>());
EXPECT_NE(quad, new_quad);
EXPECT_NE(quad->p1(), new_quad->p1());
EXPECT_NE(quad->p2(), new_quad->p2());
EXPECT_NE(quad->p3(), new_quad->p3());
EXPECT_NE(quad->p4(), new_quad->p4());
EXPECT_EQ(quad->p1()->x(), new_quad->p1()->x());
EXPECT_EQ(quad->p1()->y(), new_quad->p1()->y());
EXPECT_EQ(quad->p1()->z(), new_quad->p1()->z());
EXPECT_EQ(quad->p1()->w(), new_quad->p1()->w());
EXPECT_EQ(quad->p2()->x(), new_quad->p2()->x());
EXPECT_EQ(quad->p2()->y(), new_quad->p2()->y());
EXPECT_EQ(quad->p2()->z(), new_quad->p2()->z());
EXPECT_EQ(quad->p2()->w(), new_quad->p2()->w());
EXPECT_EQ(quad->p3()->x(), new_quad->p3()->x());
EXPECT_EQ(quad->p3()->y(), new_quad->p3()->y());
EXPECT_EQ(quad->p3()->z(), new_quad->p3()->z());
EXPECT_EQ(quad->p3()->w(), new_quad->p3()->w());
EXPECT_EQ(quad->p4()->x(), new_quad->p4()->x());
EXPECT_EQ(quad->p4()->y(), new_quad->p4()->y());
EXPECT_EQ(quad->p4()->z(), new_quad->p4()->z());
EXPECT_EQ(quad->p4()->w(), new_quad->p4()->w());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMQuad) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x11, 0xff, 0x0d, 0x5c, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x22, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2a, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1c, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x2e, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x28, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x40});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMQuad::hasInstance(result, scope.GetIsolate()));
DOMQuad* quad = V8DOMQuad::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1, quad->p1()->x());
EXPECT_EQ(5, quad->p1()->y());
EXPECT_EQ(9, quad->p1()->z());
EXPECT_EQ(13, quad->p1()->w());
EXPECT_EQ(2, quad->p2()->x());
EXPECT_EQ(6, quad->p2()->y());
EXPECT_EQ(10, quad->p2()->z());
EXPECT_EQ(14, quad->p2()->w());
EXPECT_EQ(3, quad->p3()->x());
EXPECT_EQ(7, quad->p3()->y());
EXPECT_EQ(11, quad->p3()->z());
EXPECT_EQ(15, quad->p3()->w());
EXPECT_EQ(4, quad->p4()->x());
EXPECT_EQ(8, quad->p4()->y());
EXPECT_EQ(12, quad->p4()->z());
EXPECT_EQ(16, quad->p4()->w());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix2D) {
// DOMMatrix objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMMatrixInit init;
init.setIs2D(true);
init.setA(1.0);
init.setB(2.0);
init.setC(3.0);
init.setD(4.0);
init.setE(5.0);
init.setF(6.0);
DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState());
EXPECT_TRUE(matrix->is2D());
v8::Local<v8::Value> wrapper =
ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrix* new_matrix = V8DOMMatrix::ToImpl(result.As<v8::Object>());
EXPECT_NE(matrix, new_matrix);
EXPECT_TRUE(new_matrix->is2D());
EXPECT_EQ(matrix->a(), new_matrix->a());
EXPECT_EQ(matrix->b(), new_matrix->b());
EXPECT_EQ(matrix->c(), new_matrix->c());
EXPECT_EQ(matrix->d(), new_matrix->d());
EXPECT_EQ(matrix->e(), new_matrix->e());
EXPECT_EQ(matrix->f(), new_matrix->f());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMMatrix2D) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue({
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0xff, 0x11, 0xff, 0x0d, 0x5c, 0x49,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40,
});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrix* matrix = V8DOMMatrix::ToImpl(result.As<v8::Object>());
EXPECT_TRUE(matrix->is2D());
EXPECT_EQ(1.0, matrix->a());
EXPECT_EQ(2.0, matrix->b());
EXPECT_EQ(3.0, matrix->c());
EXPECT_EQ(4.0, matrix->d());
EXPECT_EQ(5.0, matrix->e());
EXPECT_EQ(6.0, matrix->f());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly2D) {
// DOMMatrix objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMMatrixInit init;
init.setIs2D(true);
init.setA(1.0);
init.setB(2.0);
init.setC(3.0);
init.setD(4.0);
init.setE(5.0);
init.setF(6.0);
DOMMatrixReadOnly* matrix =
DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState());
EXPECT_TRUE(matrix->is2D());
v8::Local<v8::Value> wrapper =
ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate()));
EXPECT_FALSE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrixReadOnly* new_matrix =
V8DOMMatrixReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_NE(matrix, new_matrix);
EXPECT_TRUE(new_matrix->is2D());
EXPECT_EQ(matrix->a(), new_matrix->a());
EXPECT_EQ(matrix->b(), new_matrix->b());
EXPECT_EQ(matrix->c(), new_matrix->c());
EXPECT_EQ(matrix->d(), new_matrix->d());
EXPECT_EQ(matrix->e(), new_matrix->e());
EXPECT_EQ(matrix->f(), new_matrix->f());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMMatrixReadOnly2D) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue({
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0xff, 0x11, 0xff, 0x0d, 0x5c, 0x49,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40,
});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate()));
DOMMatrixReadOnly* matrix =
V8DOMMatrixReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_TRUE(matrix->is2D());
EXPECT_EQ(1.0, matrix->a());
EXPECT_EQ(2.0, matrix->b());
EXPECT_EQ(3.0, matrix->c());
EXPECT_EQ(4.0, matrix->d());
EXPECT_EQ(5.0, matrix->e());
EXPECT_EQ(6.0, matrix->f());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix) {
// DOMMatrix objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMMatrixInit init;
init.setIs2D(false);
init.setM11(1.1);
init.setM12(1.2);
init.setM13(1.3);
init.setM14(1.4);
init.setM21(2.1);
init.setM22(2.2);
init.setM23(2.3);
init.setM24(2.4);
init.setM31(3.1);
init.setM32(3.2);
init.setM33(3.3);
init.setM34(3.4);
init.setM41(4.1);
init.setM42(4.2);
init.setM43(4.3);
init.setM44(4.4);
DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState());
EXPECT_FALSE(matrix->is2D());
v8::Local<v8::Value> wrapper =
ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrix* new_matrix = V8DOMMatrix::ToImpl(result.As<v8::Object>());
EXPECT_NE(matrix, new_matrix);
EXPECT_FALSE(new_matrix->is2D());
EXPECT_EQ(matrix->m11(), new_matrix->m11());
EXPECT_EQ(matrix->m12(), new_matrix->m12());
EXPECT_EQ(matrix->m13(), new_matrix->m13());
EXPECT_EQ(matrix->m14(), new_matrix->m14());
EXPECT_EQ(matrix->m21(), new_matrix->m21());
EXPECT_EQ(matrix->m22(), new_matrix->m22());
EXPECT_EQ(matrix->m23(), new_matrix->m23());
EXPECT_EQ(matrix->m24(), new_matrix->m24());
EXPECT_EQ(matrix->m31(), new_matrix->m31());
EXPECT_EQ(matrix->m32(), new_matrix->m32());
EXPECT_EQ(matrix->m33(), new_matrix->m33());
EXPECT_EQ(matrix->m34(), new_matrix->m34());
EXPECT_EQ(matrix->m41(), new_matrix->m41());
EXPECT_EQ(matrix->m42(), new_matrix->m42());
EXPECT_EQ(matrix->m43(), new_matrix->m43());
EXPECT_EQ(matrix->m44(), new_matrix->m44());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMMatrix) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue({
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x59, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0xf1, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xf3, 0x3f, 0xcd, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xf4, 0x3f, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0xf6, 0x3f, 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x40, 0x9a, 0x99,
0x99, 0x99, 0x99, 0x99, 0x01, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x02, 0x40, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x03, 0x40, 0xcd, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0x08, 0x40, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0x09, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x0a, 0x40, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x0b, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x10, 0x40, 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x10, 0x40, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x11, 0x40, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0x11, 0x40,
});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrix* matrix = V8DOMMatrix::ToImpl(result.As<v8::Object>());
EXPECT_FALSE(matrix->is2D());
EXPECT_EQ(1.1, matrix->m11());
EXPECT_EQ(1.2, matrix->m12());
EXPECT_EQ(1.3, matrix->m13());
EXPECT_EQ(1.4, matrix->m14());
EXPECT_EQ(2.1, matrix->m21());
EXPECT_EQ(2.2, matrix->m22());
EXPECT_EQ(2.3, matrix->m23());
EXPECT_EQ(2.4, matrix->m24());
EXPECT_EQ(3.1, matrix->m31());
EXPECT_EQ(3.2, matrix->m32());
EXPECT_EQ(3.3, matrix->m33());
EXPECT_EQ(3.4, matrix->m34());
EXPECT_EQ(4.1, matrix->m41());
EXPECT_EQ(4.2, matrix->m42());
EXPECT_EQ(4.3, matrix->m43());
EXPECT_EQ(4.4, matrix->m44());
}
TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly) {
// DOMMatrixReadOnly objects should serialize and deserialize correctly.
V8TestingScope scope;
DOMMatrixInit init;
init.setIs2D(false);
init.setM11(1.1);
init.setM12(1.2);
init.setM13(1.3);
init.setM14(1.4);
init.setM21(2.1);
init.setM22(2.2);
init.setM23(2.3);
init.setM24(2.4);
init.setM31(3.1);
init.setM32(3.2);
init.setM33(3.3);
init.setM34(3.4);
init.setM41(4.1);
init.setM42(4.2);
init.setM43(4.3);
init.setM44(4.4);
DOMMatrixReadOnly* matrix =
DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState());
EXPECT_FALSE(matrix->is2D());
v8::Local<v8::Value> wrapper =
ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate()));
EXPECT_FALSE(V8DOMMatrix::hasInstance(result, scope.GetIsolate()));
DOMMatrixReadOnly* new_matrix =
V8DOMMatrixReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_NE(matrix, new_matrix);
EXPECT_FALSE(new_matrix->is2D());
EXPECT_EQ(matrix->m11(), new_matrix->m11());
EXPECT_EQ(matrix->m12(), new_matrix->m12());
EXPECT_EQ(matrix->m13(), new_matrix->m13());
EXPECT_EQ(matrix->m14(), new_matrix->m14());
EXPECT_EQ(matrix->m21(), new_matrix->m21());
EXPECT_EQ(matrix->m22(), new_matrix->m22());
EXPECT_EQ(matrix->m23(), new_matrix->m23());
EXPECT_EQ(matrix->m24(), new_matrix->m24());
EXPECT_EQ(matrix->m31(), new_matrix->m31());
EXPECT_EQ(matrix->m32(), new_matrix->m32());
EXPECT_EQ(matrix->m33(), new_matrix->m33());
EXPECT_EQ(matrix->m34(), new_matrix->m34());
EXPECT_EQ(matrix->m41(), new_matrix->m41());
EXPECT_EQ(matrix->m42(), new_matrix->m42());
EXPECT_EQ(matrix->m43(), new_matrix->m43());
EXPECT_EQ(matrix->m44(), new_matrix->m44());
}
TEST(V8ScriptValueSerializerTest, DecodeDOMMatrixReadOnly) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue({
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x55, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0xf1, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xf3, 0x3f, 0xcd, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xf4, 0x3f, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0xf6, 0x3f, 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x40, 0x9a, 0x99,
0x99, 0x99, 0x99, 0x99, 0x01, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x02, 0x40, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x03, 0x40, 0xcd, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0x08, 0x40, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0x09, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x0a, 0x40, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x0b, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x10, 0x40, 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x10, 0x40, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x11, 0x40, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99,
0x11, 0x40,
});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate()));
DOMMatrixReadOnly* matrix =
V8DOMMatrixReadOnly::ToImpl(result.As<v8::Object>());
EXPECT_FALSE(matrix->is2D());
EXPECT_EQ(1.1, matrix->m11());
EXPECT_EQ(1.2, matrix->m12());
EXPECT_EQ(1.3, matrix->m13());
EXPECT_EQ(1.4, matrix->m14());
EXPECT_EQ(2.1, matrix->m21());
EXPECT_EQ(2.2, matrix->m22());
EXPECT_EQ(2.3, matrix->m23());
EXPECT_EQ(2.4, matrix->m24());
EXPECT_EQ(3.1, matrix->m31());
EXPECT_EQ(3.2, matrix->m32());
EXPECT_EQ(3.3, matrix->m33());
EXPECT_EQ(3.4, matrix->m34());
EXPECT_EQ(4.1, matrix->m41());
EXPECT_EQ(4.2, matrix->m42());
EXPECT_EQ(4.3, matrix->m43());
EXPECT_EQ(4.4, matrix->m44());
}
TEST(V8ScriptValueSerializerTest, RoundTripImageData) {
// ImageData objects should serialize and deserialize correctly.
V8TestingScope scope;
ImageData* image_data = ImageData::Create(2, 1, ASSERT_NO_EXCEPTION);
image_data->data()->Data()[0] = 200;
v8::Local<v8::Value> wrapper =
ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate()));
ImageData* new_image_data = V8ImageData::ToImpl(result.As<v8::Object>());
EXPECT_NE(image_data, new_image_data);
EXPECT_EQ(image_data->Size(), new_image_data->Size());
EXPECT_EQ(image_data->data()->length(), new_image_data->data()->length());
EXPECT_EQ(200, new_image_data->data()->Data()[0]);
}
TEST(V8ScriptValueSerializerTest, RoundTripImageDataWithColorSpaceInfo) {
// ImageData objects with color space information should serialize and
// deserialize correctly.
V8TestingScope scope;
ImageDataColorSettings color_settings;
color_settings.setColorSpace("p3");
color_settings.setStorageFormat("float32");
ImageData* image_data =
ImageData::CreateImageData(2, 1, color_settings, ASSERT_NO_EXCEPTION);
static_cast<unsigned char*>(image_data->BufferBase()->Data())[0] = 200;
v8::Local<v8::Value> wrapper =
ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate()));
ImageData* new_image_data = V8ImageData::ToImpl(result.As<v8::Object>());
EXPECT_NE(image_data, new_image_data);
EXPECT_EQ(image_data->Size(), new_image_data->Size());
ImageDataColorSettings new_color_settings;
new_image_data->getColorSettings(new_color_settings);
EXPECT_EQ("p3", new_color_settings.colorSpace());
EXPECT_EQ("float32", new_color_settings.storageFormat());
EXPECT_EQ(image_data->BufferBase()->ByteLength(),
new_image_data->BufferBase()->ByteLength());
EXPECT_EQ(200, static_cast<unsigned char*>(
new_image_data->BufferBase()->Data())[0]);
}
TEST(V8ScriptValueSerializerTest, DecodeImageDataV9) {
// Backward compatibility with existing serialized ImageData objects must be
// maintained. Add more cases if the format changes; don't remove tests for
// old versions.
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x23, 0x02, 0x01, 0x08, 0xc8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate()));
ImageData* new_image_data = V8ImageData::ToImpl(result.As<v8::Object>());
EXPECT_EQ(IntSize(2, 1), new_image_data->Size());
EXPECT_EQ(8u, new_image_data->data()->length());
EXPECT_EQ(200, new_image_data->data()->Data()[0]);
}
TEST(V8ScriptValueSerializerTest, DecodeImageDataV16) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x10, 0xff, 0x0c, 0x23, 0x02, 0x01, 0x08, 0xc8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate()));
ImageData* new_image_data = V8ImageData::ToImpl(result.As<v8::Object>());
EXPECT_EQ(IntSize(2, 1), new_image_data->Size());
EXPECT_EQ(8u, new_image_data->data()->length());
EXPECT_EQ(200, new_image_data->data()->Data()[0]);
}
TEST(V8ScriptValueSerializerTest, DecodeImageDataV18) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x23, 0x01, 0x03, 0x03, 0x02, 0x00, 0x02,
0x01, 0x20, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate()));
ImageData* new_image_data = V8ImageData::ToImpl(result.As<v8::Object>());
EXPECT_EQ(IntSize(2, 1), new_image_data->Size());
ImageDataColorSettings new_color_settings;
new_image_data->getColorSettings(new_color_settings);
EXPECT_EQ("p3", new_color_settings.colorSpace());
EXPECT_EQ("float32", new_color_settings.storageFormat());
EXPECT_EQ(32u, new_image_data->BufferBase()->ByteLength());
EXPECT_EQ(200, static_cast<unsigned char*>(
new_image_data->BufferBase()->Data())[0]);
}
MessagePort* MakeMessagePort(ExecutionContext* execution_context,
MojoHandle* unowned_handle_out = nullptr) {
MessagePort* port = MessagePort::Create(*execution_context);
mojo::MessagePipe pipe;
MojoHandle unowned_handle = pipe.handle0.get().value();
port->Entangle(std::move(pipe.handle0));
EXPECT_TRUE(port->IsEntangled());
EXPECT_EQ(unowned_handle, port->EntangledHandleForTesting());
if (unowned_handle_out)
*unowned_handle_out = unowned_handle;
return port;
}
TEST(V8ScriptValueSerializerTest, RoundTripMessagePort) {
V8TestingScope scope;
MojoHandle unowned_handle;
MessagePort* port =
MakeMessagePort(scope.GetExecutionContext(), &unowned_handle);
v8::Local<v8::Value> wrapper = ToV8(port, scope.GetScriptState());
Transferables transferables;
transferables.message_ports.push_back(port);
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, &transferables);
ASSERT_TRUE(V8MessagePort::hasInstance(result, scope.GetIsolate()));
MessagePort* new_port = V8MessagePort::ToImpl(result.As<v8::Object>());
EXPECT_FALSE(port->IsEntangled());
EXPECT_TRUE(new_port->IsEntangled());
EXPECT_EQ(unowned_handle, new_port->EntangledHandleForTesting());
}
TEST(V8ScriptValueSerializerTest, NeuteredMessagePortThrowsDataCloneError) {
V8TestingScope scope;
ExceptionState exception_state(scope.GetIsolate(),
ExceptionState::kExecutionContext, "Window",
"postMessage");
MessagePort* port = MessagePort::Create(*scope.GetExecutionContext());
EXPECT_TRUE(port->IsNeutered());
v8::Local<v8::Value> wrapper = ToV8(port, scope.GetScriptState());
Transferables transferables;
transferables.message_ports.push_back(port);
RoundTrip(wrapper, scope, &exception_state, &transferables);
ASSERT_TRUE(HadDOMExceptionInCoreTest(
"DataCloneError", scope.GetScriptState(), exception_state));
}
TEST(V8ScriptValueSerializerTest,
UntransferredMessagePortThrowsDataCloneError) {
V8TestingScope scope;
ExceptionState exception_state(scope.GetIsolate(),
ExceptionState::kExecutionContext, "Window",
"postMessage");
MessagePort* port = MakeMessagePort(scope.GetExecutionContext());
v8::Local<v8::Value> wrapper = ToV8(port, scope.GetScriptState());
Transferables transferables;
RoundTrip(wrapper, scope, &exception_state, &transferables);
ASSERT_TRUE(HadDOMExceptionInCoreTest(
"DataCloneError", scope.GetScriptState(), exception_state));
}
TEST(V8ScriptValueSerializerTest, OutOfRangeMessagePortIndex) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4d, 0x01});
MessagePort* port1 = MakeMessagePort(scope.GetExecutionContext());
MessagePort* port2 = MakeMessagePort(scope.GetExecutionContext());
{
V8ScriptValueDeserializer deserializer(script_state, input);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
{
V8ScriptValueDeserializer::Options options;
options.message_ports = new MessagePortArray;
V8ScriptValueDeserializer deserializer(script_state, input, options);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
{
V8ScriptValueDeserializer::Options options;
options.message_ports = new MessagePortArray;
options.message_ports->push_back(port1);
V8ScriptValueDeserializer deserializer(script_state, input, options);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
{
V8ScriptValueDeserializer::Options options;
options.message_ports = new MessagePortArray;
options.message_ports->push_back(port1);
options.message_ports->push_back(port2);
V8ScriptValueDeserializer deserializer(script_state, input, options);
v8::Local<v8::Value> result = deserializer.Deserialize();
ASSERT_TRUE(V8MessagePort::hasInstance(result, scope.GetIsolate()));
EXPECT_EQ(port2, V8MessagePort::ToImpl(result.As<v8::Object>()));
}
}
// Decode tests for backward compatibility are not required for message ports
// because they cannot be persisted to disk.
// A more exhaustive set of ImageBitmap cases are covered by LayoutTests.
TEST(V8ScriptValueSerializerTest, RoundTripImageBitmap) {
V8TestingScope scope;
// Make a 10x7 red ImageBitmap.
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 7);
surface->getCanvas()->clear(SK_ColorRED);
ImageBitmap* image_bitmap = ImageBitmap::Create(
StaticBitmapImage::Create(surface->makeImageSnapshot()));
ASSERT_TRUE(image_bitmap->BitmapImage());
// Serialize and deserialize it.
v8::Local<v8::Value> wrapper = ToV8(image_bitmap, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate()));
ImageBitmap* new_image_bitmap =
V8ImageBitmap::ToImpl(result.As<v8::Object>());
ASSERT_TRUE(new_image_bitmap->BitmapImage());
ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size());
// Check that the pixel at (3, 3) is red.
uint8_t pixel[4] = {};
ASSERT_TRUE(new_image_bitmap->BitmapImage()
->PaintImageForCurrentFrame()
.GetSkImage()
->readPixels(SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType,
kPremul_SkAlphaType),
&pixel, 4, 3, 3));
ASSERT_THAT(pixel, testing::ElementsAre(255, 0, 0, 255));
}
TEST(V8ScriptValueSerializerTest, RoundTripImageBitmapWithColorSpaceInfo) {
V8TestingScope scope;
// Make a 10x7 red ImageBitmap in P3 color space.
SkImageInfo info = SkImageInfo::Make(
10, 7, kRGBA_F16_SkColorType, kPremul_SkAlphaType,
SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma,
SkColorSpace::kDCIP3_D65_Gamut));
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
surface->getCanvas()->clear(SK_ColorRED);
ImageBitmap* image_bitmap = ImageBitmap::Create(
StaticBitmapImage::Create(surface->makeImageSnapshot()));
ASSERT_TRUE(image_bitmap->BitmapImage());
// Serialize and deserialize it.
v8::Local<v8::Value> wrapper = ToV8(image_bitmap, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate()));
ImageBitmap* new_image_bitmap =
V8ImageBitmap::ToImpl(result.As<v8::Object>());
ASSERT_TRUE(new_image_bitmap->BitmapImage());
ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size());
// Check the color settings.
CanvasColorParams color_params = new_image_bitmap->GetCanvasColorParams();
EXPECT_EQ(kP3CanvasColorSpace, color_params.ColorSpace());
EXPECT_EQ(kF16CanvasPixelFormat, color_params.PixelFormat());
// Check that the pixel at (3, 3) is red. We expect red in P3 to be
// {0x94, 0x3A, 0x3F, 0x28, 0x5F, 0x24, 0x00, 0x3C} when each color
// component is presented as a half float in Skia. However, difference in
// GPU hardware may result in small differences in lower significant byte in
// Skia color conversion pipeline. Hence, we use a tolerance of 2 here.
uint8_t pixel[8] = {};
ASSERT_TRUE(new_image_bitmap->BitmapImage()
->PaintImageForCurrentFrame()
.GetSkImage()
->readPixels(info.makeWH(1, 1), &pixel, 8, 3, 3));
uint8_t p3_red[8] = {0x94, 0x3A, 0x3F, 0x28, 0x5F, 0x24, 0x00, 0x3C};
bool approximate_match = true;
uint8_t tolerance = 2;
for (int i = 0; i < 8; i++) {
if (std::abs(p3_red[i] - pixel[i]) > tolerance) {
approximate_match = false;
break;
}
}
ASSERT_TRUE(approximate_match);
}
TEST(V8ScriptValueSerializerTest, DecodeImageBitmap) {
// Backward compatibility with existing serialized ImageBitmap objects must be
// maintained. Add more cases if the format changes; don't remove tests for
// old versions.
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
// This is checked by platform instead of by SK_PMCOLOR_BYTE_ORDER because
// this test intends to ensure that a platform can decode images it has
// previously written. At format version 9, Android writes RGBA and every
// other platform writes BGRA.
#if defined(OS_ANDROID)
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01,
0x08, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff});
#else
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01,
0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff});
#endif
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate()));
ImageBitmap* new_image_bitmap =
V8ImageBitmap::ToImpl(result.As<v8::Object>());
ASSERT_EQ(IntSize(2, 1), new_image_bitmap->Size());
// Check that the pixels are opaque red and green, respectively.
uint8_t pixels[8] = {};
ASSERT_TRUE(new_image_bitmap->BitmapImage()
->PaintImageForCurrentFrame()
.GetSkImage()
->readPixels(SkImageInfo::Make(2, 1, kRGBA_8888_SkColorType,
kPremul_SkAlphaType),
&pixels, 8, 0, 0));
ASSERT_THAT(pixels, testing::ElementsAre(255, 0, 0, 255, 0, 255, 0, 255));
}
TEST(V8ScriptValueSerializerTest, DecodeImageBitmapV18) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x03, 0x04, 0x01,
0x05, 0x01, 0x00, 0x02, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(script_state, input).Deserialize();
ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate()));
ImageBitmap* new_image_bitmap =
V8ImageBitmap::ToImpl(result.As<v8::Object>());
ASSERT_EQ(IntSize(2, 1), new_image_bitmap->Size());
// Check the color settings.
CanvasColorParams color_params = new_image_bitmap->GetCanvasColorParams();
EXPECT_EQ(kP3CanvasColorSpace, color_params.ColorSpace());
EXPECT_EQ(kF16CanvasPixelFormat, color_params.PixelFormat());
// Check that the pixel at (1, 0) is red.
uint8_t pixel[8] = {};
SkImageInfo info = SkImageInfo::Make(
1, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType,
SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma,
SkColorSpace::kDCIP3_D65_Gamut));
ASSERT_TRUE(new_image_bitmap->BitmapImage()
->PaintImageForCurrentFrame()
.GetSkImage()
->readPixels(info, &pixel, 8, 1, 0));
// The reference values are the hex representation of red in P3 (as stored
// in half floats by Skia).
ASSERT_THAT(pixel, testing::ElementsAre(0x94, 0x3A, 0x3F, 0x28, 0x5F, 0x24,
0x0, 0x3C));
}
TEST(V8ScriptValueSerializerTest, InvalidImageBitmapDecode) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
{
// Too many bytes declared in pixel data.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01, 0x09,
0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Too few bytes declared in pixel data.
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01,
0x07, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for origin clean data.
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x67, 0x02, 0x01, 0x02, 0x01,
0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for premultiplied bit.
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x02, 0x02, 0x01,
0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
}
TEST(V8ScriptValueSerializerTest, InvalidImageBitmapDecodeV18) {
V8TestingScope scope;
ScriptState* script_state = scope.GetScriptState();
{
// Too many bytes declared in pixel data.
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02,
0x03, 0x04, 0x01, 0x05, 0x01, 0x00, 0x02, 0x01, 0x11,
0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c, 0x94,
0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c, 0x00, 0x00});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Too few bytes declared in pixel data.
scoped_refptr<SerializedScriptValue> input = SerializedValue({
0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x03, 0x04,
0x01, 0x05, 0x01, 0x00, 0x02, 0x01, 0x0f, 0x94, 0x3a, 0x3f, 0x28,
0x5f, 0x24, 0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for color space data.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x04, 0x02, 0x03, 0x04, 0x01,
0x05, 0x01, 0x00, 0x02, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for pixel format data.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x04, 0x04, 0x01,
0x05, 0x01, 0x00, 0x02, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for origin clean data.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x03, 0x04, 0x02,
0x05, 0x01, 0x00, 0x02, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Nonsense for premultiplied bit.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x03, 0x04, 0x01,
0x05, 0x02, 0x00, 0x02, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
{
// Wrong size declared in pixel data.
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x12, 0xff, 0x0d, 0x5c, 0x67, 0x01, 0x03, 0x02, 0x03, 0x04, 0x01,
0x05, 0x01, 0x00, 0x03, 0x01, 0x10, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24,
0x00, 0x3c, 0x94, 0x3a, 0x3f, 0x28, 0x5f, 0x24, 0x00, 0x3c});
EXPECT_TRUE(
V8ScriptValueDeserializer(script_state, input).Deserialize()->IsNull());
}
}
TEST(V8ScriptValueSerializerTest, TransferImageBitmap) {
// More thorough tests exist in LayoutTests/.
V8TestingScope scope;
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 7);
surface->getCanvas()->clear(SK_ColorRED);
sk_sp<SkImage> image = surface->makeImageSnapshot();
ImageBitmap* image_bitmap =
ImageBitmap::Create(StaticBitmapImage::Create(image));
ASSERT_TRUE(image_bitmap->BitmapImage());
v8::Local<v8::Value> wrapper = ToV8(image_bitmap, scope.GetScriptState());
Transferables transferables;
transferables.image_bitmaps.push_back(image_bitmap);
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, &transferables);
ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate()));
ImageBitmap* new_image_bitmap =
V8ImageBitmap::ToImpl(result.As<v8::Object>());
ASSERT_TRUE(new_image_bitmap->BitmapImage());
ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size());
// Check that the pixel at (3, 3) is red.
uint8_t pixel[4] = {};
sk_sp<SkImage> new_image =
new_image_bitmap->BitmapImage()->PaintImageForCurrentFrame().GetSkImage();
ASSERT_TRUE(new_image->readPixels(
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
&pixel, 4, 3, 3));
ASSERT_THAT(pixel, testing::ElementsAre(255, 0, 0, 255));
// Check also that the underlying image contents were transferred.
EXPECT_EQ(image, new_image);
EXPECT_TRUE(image_bitmap->IsNeutered());
}
TEST(V8ScriptValueSerializerTest, TransferOffscreenCanvas) {
// More exhaustive tests in LayoutTests/. This is a sanity check.
V8TestingScope scope;
OffscreenCanvas* canvas = OffscreenCanvas::Create(10, 7);
canvas->SetPlaceholderCanvasId(519);
v8::Local<v8::Value> wrapper = ToV8(canvas, scope.GetScriptState());
Transferables transferables;
transferables.offscreen_canvases.push_back(canvas);
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, &transferables);
ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate()));
OffscreenCanvas* new_canvas =
V8OffscreenCanvas::ToImpl(result.As<v8::Object>());
EXPECT_EQ(IntSize(10, 7), new_canvas->Size());
EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId());
EXPECT_TRUE(canvas->IsNeutered());
EXPECT_FALSE(new_canvas->IsNeutered());
}
TEST(V8ScriptValueSerializerTest, RoundTripBlob) {
V8TestingScope scope;
const char kHelloWorld[] = "Hello world!";
Blob* blob =
Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld),
sizeof(kHelloWorld), "text/plain");
String uuid = blob->Uuid();
EXPECT_FALSE(uuid.IsEmpty());
v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8Blob::hasInstance(result, scope.GetIsolate()));
Blob* new_blob = V8Blob::ToImpl(result.As<v8::Object>());
EXPECT_EQ("text/plain", new_blob->type());
EXPECT_EQ(sizeof(kHelloWorld), new_blob->size());
EXPECT_EQ(uuid, new_blob->Uuid());
}
TEST(V8ScriptValueSerializerTest, DecodeBlob) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x09, 0x3f, 0x00, 0x62, 0x24, 0x64, 0x38, 0x37, 0x35, 0x64,
0x66, 0x63, 0x32, 0x2d, 0x34, 0x35, 0x30, 0x35, 0x2d, 0x34, 0x36,
0x31, 0x62, 0x2d, 0x39, 0x38, 0x66, 0x65, 0x2d, 0x30, 0x63, 0x66,
0x36, 0x63, 0x63, 0x35, 0x65, 0x61, 0x66, 0x34, 0x34, 0x0a, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0c});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8Blob::hasInstance(result, scope.GetIsolate()));
Blob* new_blob = V8Blob::ToImpl(result.As<v8::Object>());
EXPECT_EQ("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", new_blob->Uuid());
EXPECT_EQ("text/plain", new_blob->type());
EXPECT_EQ(12u, new_blob->size());
}
TEST(V8ScriptValueSerializerTest, RoundTripBlobIndex) {
V8TestingScope scope;
const char kHelloWorld[] = "Hello world!";
Blob* blob =
Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld),
sizeof(kHelloWorld), "text/plain");
String uuid = blob->Uuid();
EXPECT_FALSE(uuid.IsEmpty());
v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState());
WebBlobInfoArray blob_info_array;
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, nullptr, &blob_info_array);
// As before, the resulting blob should be correct.
ASSERT_TRUE(V8Blob::hasInstance(result, scope.GetIsolate()));
Blob* new_blob = V8Blob::ToImpl(result.As<v8::Object>());
EXPECT_EQ("text/plain", new_blob->type());
EXPECT_EQ(sizeof(kHelloWorld), new_blob->size());
EXPECT_EQ(uuid, new_blob->Uuid());
// The blob info array should also contain the blob details since it was
// serialized by index into this array.
ASSERT_EQ(1u, blob_info_array.size());
const WebBlobInfo& info = blob_info_array[0];
EXPECT_FALSE(info.IsFile());
EXPECT_EQ(uuid, String(info.Uuid()));
EXPECT_EQ("text/plain", info.GetType());
EXPECT_EQ(sizeof(kHelloWorld), static_cast<size_t>(info.size()));
}
TEST(V8ScriptValueSerializerTest, DecodeBlobIndex) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x69, 0x00});
WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back(WebBlobInfo::BlobForTesting(
"d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12));
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
v8::Local<v8::Value> result = deserializer.Deserialize();
ASSERT_TRUE(V8Blob::hasInstance(result, scope.GetIsolate()));
Blob* new_blob = V8Blob::ToImpl(result.As<v8::Object>());
EXPECT_EQ("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", new_blob->Uuid());
EXPECT_EQ("text/plain", new_blob->type());
EXPECT_EQ(12u, new_blob->size());
}
TEST(V8ScriptValueSerializerTest, DecodeBlobIndexOutOfRange) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x69, 0x01});
{
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
{
WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back(WebBlobInfo::BlobForTesting(
"d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12));
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
}
TEST(V8ScriptValueSerializerTest, RoundTripFileNative) {
V8TestingScope scope;
File* file = File::Create("/native/path");
v8::Local<v8::Value> wrapper = ToV8(file, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_TRUE(new_file->HasBackingFile());
EXPECT_EQ("/native/path", new_file->GetPath());
EXPECT_TRUE(new_file->FileSystemURL().IsEmpty());
}
TEST(V8ScriptValueSerializerTest, RoundTripFileBackedByBlob) {
V8TestingScope scope;
const double kModificationTime = 0.0;
scoped_refptr<BlobDataHandle> blob_data_handle = BlobDataHandle::Create();
File* file =
File::Create("/native/path", kModificationTime, blob_data_handle);
v8::Local<v8::Value> wrapper = ToV8(file, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_FALSE(new_file->HasBackingFile());
EXPECT_TRUE(file->GetPath().IsEmpty());
EXPECT_TRUE(new_file->FileSystemURL().IsEmpty());
}
TEST(V8ScriptValueSerializerTest, RoundTripFileNativeSnapshot) {
V8TestingScope scope;
FileMetadata metadata;
metadata.platform_path = "/native/snapshot";
File* file =
File::CreateForFileSystemFile("name", metadata, File::kIsUserVisible);
v8::Local<v8::Value> wrapper = ToV8(file, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_TRUE(new_file->HasBackingFile());
EXPECT_EQ("/native/snapshot", new_file->GetPath());
EXPECT_TRUE(new_file->FileSystemURL().IsEmpty());
}
TEST(V8ScriptValueSerializerTest, RoundTripFileNonNativeSnapshot) {
// Preserving behavior, filesystem URL is not preserved across cloning.
V8TestingScope scope;
KURL url("filesystem:http://example.com/isolated/hash/non-native-file");
File* file =
File::CreateForFileSystemFile(url, FileMetadata(), File::kIsUserVisible);
v8::Local<v8::Value> wrapper = ToV8(file, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_FALSE(new_file->HasBackingFile());
EXPECT_TRUE(file->GetPath().IsEmpty());
EXPECT_TRUE(new_file->FileSystemURL().IsEmpty());
}
// Used for checking that times provided are between now and the current time
// when the checker was constructed, according to WTF::currentTime.
class TimeIntervalChecker {
public:
TimeIntervalChecker() : start_time_(WTF::CurrentTime()) {}
bool WasAliveAt(double time_in_milliseconds) {
double time = time_in_milliseconds / kMsPerSecond;
return start_time_ <= time && time <= WTF::CurrentTime();
}
private:
const double start_time_;
};
TEST(V8ScriptValueSerializerTest, DecodeFileV3) {
V8TestingScope scope;
TimeIntervalChecker time_interval_checker;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x03, 0x3f, 0x00, 0x66, 0x04, 'p', 'a', 't', 'h', 0x24, 'f',
'4', 'a', '6', 'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd',
'-', '4', 'd', 'c', '3', '-', 'b', '6', '7', 'c', '-', 'a',
'7', '7', '9', 'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a,
't', 'e', 'x', 't', '/', 'p', 'l', 'a', 'i', 'n'});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_FALSE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(0u, new_file->size());
EXPECT_TRUE(time_interval_checker.WasAliveAt(new_file->lastModifiedDate()));
EXPECT_EQ(File::kIsUserVisible, new_file->GetUserVisibility());
}
TEST(V8ScriptValueSerializerTest, DecodeFileV4) {
V8TestingScope scope;
TimeIntervalChecker time_interval_checker;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x04, 0x3f, 0x00, 0x66, 0x04, 'p', 'a', 't', 'h', 0x04, 'n',
'a', 'm', 'e', 0x03, 'r', 'e', 'l', 0x24, 'f', '4', 'a', '6',
'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd', '-', '4', 'd',
'c', '3', '-', 'b', '6', '7', 'c', '-', 'a', '7', '7', '9',
'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a, 't', 'e', 'x',
't', '/', 'p', 'l', 'a', 'i', 'n', 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("rel", new_file->webkitRelativePath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_FALSE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(0u, new_file->size());
EXPECT_TRUE(time_interval_checker.WasAliveAt(new_file->lastModifiedDate()));
EXPECT_EQ(File::kIsUserVisible, new_file->GetUserVisibility());
}
TEST(V8ScriptValueSerializerTest, DecodeFileV4WithSnapshot) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x04, 0x3f, 0x00, 0x66, 0x04, 'p', 'a', 't', 'h', 0x04, 'n',
'a', 'm', 'e', 0x03, 'r', 'e', 'l', 0x24, 'f', '4', 'a', '6',
'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd', '-', '4', 'd',
'c', '3', '-', 'b', '6', '7', 'c', '-', 'a', '7', '7', '9',
'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a, 't', 'e', 'x',
't', '/', 'p', 'l', 'a', 'i', 'n', 0x01, 0x80, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xd0, 0xbf});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("rel", new_file->webkitRelativePath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_TRUE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(512u, new_file->size());
// From v4 to v7, the last modified time is written in seconds.
// So -0.25 represents 250 ms before the Unix epoch.
EXPECT_EQ(-250.0, new_file->lastModifiedDate());
}
TEST(V8ScriptValueSerializerTest, DecodeFileV7) {
V8TestingScope scope;
TimeIntervalChecker time_interval_checker;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x07, 0x3f, 0x00, 0x66, 0x04, 'p', 'a', 't', 'h', 0x04, 'n',
'a', 'm', 'e', 0x03, 'r', 'e', 'l', 0x24, 'f', '4', 'a', '6',
'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd', '-', '4', 'd',
'c', '3', '-', 'b', '6', '7', 'c', '-', 'a', '7', '7', '9',
'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a, 't', 'e', 'x',
't', '/', 'p', 'l', 'a', 'i', 'n', 0x00, 0x00, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("rel", new_file->webkitRelativePath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_FALSE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(0u, new_file->size());
EXPECT_TRUE(time_interval_checker.WasAliveAt(new_file->lastModifiedDate()));
EXPECT_EQ(File::kIsNotUserVisible, new_file->GetUserVisibility());
}
TEST(V8ScriptValueSerializerTest, DecodeFileV8WithSnapshot) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x08, 0x3f, 0x00, 0x66, 0x04, 'p', 'a', 't', 'h', 0x04, 'n',
'a', 'm', 'e', 0x03, 'r', 'e', 'l', 0x24, 'f', '4', 'a', '6',
'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd', '-', '4', 'd',
'c', '3', '-', 'b', '6', '7', 'c', '-', 'a', '7', '7', '9',
'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a, 't', 'e', 'x',
't', '/', 'p', 'l', 'a', 'i', 'n', 0x01, 0x80, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xd0, 0xbf, 0x01, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("rel", new_file->webkitRelativePath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_TRUE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(512u, new_file->size());
// From v8, the last modified time is written in milliseconds.
// So -0.25 represents 0.25 ms before the Unix epoch.
EXPECT_EQ(-0.25, new_file->lastModifiedDate());
EXPECT_EQ(File::kIsUserVisible, new_file->GetUserVisibility());
}
TEST(V8ScriptValueSerializerTest, RoundTripFileIndex) {
V8TestingScope scope;
File* file = File::Create("/native/path");
v8::Local<v8::Value> wrapper = ToV8(file, scope.GetScriptState());
WebBlobInfoArray blob_info_array;
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, nullptr, &blob_info_array);
// As above, the resulting blob should be correct.
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_TRUE(new_file->HasBackingFile());
EXPECT_EQ("/native/path", new_file->GetPath());
EXPECT_TRUE(new_file->FileSystemURL().IsEmpty());
// The blob info array should also contain the details since it was serialized
// by index into this array.
ASSERT_EQ(1u, blob_info_array.size());
const WebBlobInfo& info = blob_info_array[0];
EXPECT_TRUE(info.IsFile());
EXPECT_EQ("/native/path", info.FilePath());
EXPECT_EQ(file->Uuid(), String(info.Uuid()));
}
TEST(V8ScriptValueSerializerTest, DecodeFileIndex) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x65, 0x00});
WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back(
WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "path", "text/plain"));
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
v8::Local<v8::Value> result = deserializer.Deserialize();
ASSERT_TRUE(V8File::hasInstance(result, scope.GetIsolate()));
File* new_file = V8File::ToImpl(result.As<v8::Object>());
EXPECT_EQ("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_EQ("/native/path", new_file->GetPath());
EXPECT_EQ("path", new_file->name());
}
TEST(V8ScriptValueSerializerTest, DecodeFileIndexOutOfRange) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x65, 0x01});
{
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
{
WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back(
WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "path", "text/plain"));
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
ASSERT_TRUE(deserializer.Deserialize()->IsNull());
}
}
// Most of the logic for FileList is shared with File, so the tests here are
// fairly basic.
TEST(V8ScriptValueSerializerTest, RoundTripFileList) {
V8TestingScope scope;
FileList* file_list = FileList::Create();
file_list->Append(File::Create("/native/path"));
file_list->Append(File::Create("/native/path2"));
v8::Local<v8::Value> wrapper = ToV8(file_list, scope.GetScriptState());
v8::Local<v8::Value> result = RoundTrip(wrapper, scope);
ASSERT_TRUE(V8FileList::hasInstance(result, scope.GetIsolate()));
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
ASSERT_EQ(2u, new_file_list->length());
EXPECT_EQ("/native/path", new_file_list->item(0)->GetPath());
EXPECT_EQ("/native/path2", new_file_list->item(1)->GetPath());
}
TEST(V8ScriptValueSerializerTest, DecodeEmptyFileList) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x6c, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8FileList::hasInstance(result, scope.GetIsolate()));
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
EXPECT_EQ(0u, new_file_list->length());
}
TEST(V8ScriptValueSerializerTest, DecodeFileListWithInvalidLength) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x6c, 0x01});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
EXPECT_TRUE(result->IsNull());
}
TEST(V8ScriptValueSerializerTest, DecodeFileListV8WithoutSnapshot) {
V8TestingScope scope;
TimeIntervalChecker time_interval_checker;
scoped_refptr<SerializedScriptValue> input = SerializedValue(
{0xff, 0x08, 0x3f, 0x00, 0x6c, 0x01, 0x04, 'p', 'a', 't', 'h', 0x04,
'n', 'a', 'm', 'e', 0x03, 'r', 'e', 'l', 0x24, 'f', '4', 'a',
'6', 'e', 'd', 'd', '5', '-', '6', '5', 'a', 'd', '-', '4',
'd', 'c', '3', '-', 'b', '6', '7', 'c', '-', 'a', '7', '7',
'9', 'c', '0', '2', 'f', '0', 'f', 'a', '3', 0x0a, 't', 'e',
'x', 't', '/', 'p', 'l', 'a', 'i', 'n', 0x00, 0x00});
v8::Local<v8::Value> result =
V8ScriptValueDeserializer(scope.GetScriptState(), input).Deserialize();
ASSERT_TRUE(V8FileList::hasInstance(result, scope.GetIsolate()));
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1u, new_file_list->length());
File* new_file = new_file_list->item(0);
EXPECT_EQ("path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("rel", new_file->webkitRelativePath());
EXPECT_EQ("f4a6edd5-65ad-4dc3-b67c-a779c02f0fa3", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
EXPECT_FALSE(new_file->HasValidSnapshotMetadata());
EXPECT_EQ(0u, new_file->size());
EXPECT_TRUE(time_interval_checker.WasAliveAt(new_file->lastModifiedDate()));
EXPECT_EQ(File::kIsNotUserVisible, new_file->GetUserVisibility());
}
TEST(V8ScriptValueSerializerTest, RoundTripFileListIndex) {
V8TestingScope scope;
FileList* file_list = FileList::Create();
file_list->Append(File::Create("/native/path"));
file_list->Append(File::Create("/native/path2"));
v8::Local<v8::Value> wrapper = ToV8(file_list, scope.GetScriptState());
WebBlobInfoArray blob_info_array;
v8::Local<v8::Value> result =
RoundTrip(wrapper, scope, nullptr, nullptr, &blob_info_array);
// FileList should be produced correctly.
ASSERT_TRUE(V8FileList::hasInstance(result, scope.GetIsolate()));
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
ASSERT_EQ(2u, new_file_list->length());
EXPECT_EQ("/native/path", new_file_list->item(0)->GetPath());
EXPECT_EQ("/native/path2", new_file_list->item(1)->GetPath());
// And the blob info array should be populated.
ASSERT_EQ(2u, blob_info_array.size());
EXPECT_TRUE(blob_info_array[0].IsFile());
EXPECT_EQ("/native/path", blob_info_array[0].FilePath());
EXPECT_TRUE(blob_info_array[1].IsFile());
EXPECT_EQ("/native/path2", blob_info_array[1].FilePath());
}
TEST(V8ScriptValueSerializerTest, DecodeEmptyFileListIndex) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x00});
WebBlobInfoArray blob_info_array;
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
v8::Local<v8::Value> result = deserializer.Deserialize();
ASSERT_TRUE(V8FileList::hasInstance(result, scope.GetIsolate()));
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
EXPECT_EQ(0u, new_file_list->length());
}
TEST(V8ScriptValueSerializerTest, DecodeFileListIndexWithInvalidLength) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x02});
WebBlobInfoArray blob_info_array;
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
v8::Local<v8::Value> result = deserializer.Deserialize();
EXPECT_TRUE(result->IsNull());
}
TEST(V8ScriptValueSerializerTest, DecodeFileListIndex) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x01, 0x00, 0x00});
WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back(
WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "name", "text/plain"));
V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
options);
v8::Local<v8::Value> result = deserializer.Deserialize();
FileList* new_file_list = V8FileList::ToImpl(result.As<v8::Object>());
EXPECT_EQ(1u, new_file_list->length());
File* new_file = new_file_list->item(0);
EXPECT_EQ("/native/path", new_file->GetPath());
EXPECT_EQ("name", new_file->name());
EXPECT_EQ("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", new_file->Uuid());
EXPECT_EQ("text/plain", new_file->type());
}
// Decode tests aren't included here because they're slightly non-trivial (an
// element with the right ID must actually exist) and this feature is both
// unshipped and likely to not use this mechanism when it does.
// TODO(jbroman): Update this if that turns out not to be the case.
TEST(V8ScriptValueSerializerTest, DecodeHardcodedNullValue) {
V8TestingScope scope;
EXPECT_TRUE(V8ScriptValueDeserializer(scope.GetScriptState(),
SerializedScriptValue::NullValue())
.Deserialize()
->IsNull());
}
// This is not the most efficient way to write a small version, but it's
// technically admissible. We should handle this in a consistent way to avoid
// DCHECK failure. Thus this is "true" encoded slightly strangely.
TEST(V8ScriptValueSerializerTest, DecodeWithInefficientVersionEnvelope) {
V8TestingScope scope;
scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x80, 0x09, 0xff, 0x09, 0x54});
EXPECT_TRUE(
V8ScriptValueDeserializer(scope.GetScriptState(), std::move(input))
.Deserialize()
->IsTrue());
}
} // namespace
} // namespace blink
|
0
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_
#define SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_
#include "build/build_config.h"
#include "components/viz/common/resources/transferable_resource.h"
#include "services/viz/public/interfaces/compositing/transferable_resource.mojom-shared.h"
#include "ui/gfx/ipc/color/gfx_param_traits.h"
namespace mojo {
template <>
struct StructTraits<viz::mojom::TransferableResourceDataView,
viz::TransferableResource> {
static uint32_t id(const viz::TransferableResource& resource) {
return resource.id;
}
static viz::mojom::ResourceFormat format(
const viz::TransferableResource& resource) {
return static_cast<viz::mojom::ResourceFormat>(resource.format);
}
static gfx::mojom::BufferFormat buffer_format(
const viz::TransferableResource& resource) {
return static_cast<gfx::mojom::BufferFormat>(resource.buffer_format);
}
static uint32_t filter(const viz::TransferableResource& resource) {
return resource.filter;
}
static gfx::Size size(const viz::TransferableResource& resource) {
return resource.size;
}
static const gpu::MailboxHolder& mailbox_holder(
const viz::TransferableResource& resource) {
return resource.mailbox_holder;
}
static bool read_lock_fences_enabled(
const viz::TransferableResource& resource) {
return resource.read_lock_fences_enabled;
}
static bool is_software(const viz::TransferableResource& resource) {
return resource.is_software;
}
static uint32_t shared_bitmap_sequence_number(
const viz::TransferableResource& resource) {
return resource.shared_bitmap_sequence_number;
}
static bool is_overlay_candidate(const viz::TransferableResource& resource) {
return resource.is_overlay_candidate;
}
static bool is_backed_by_surface_texture(
const viz::TransferableResource& resource) {
#if defined(OS_ANDROID)
// TransferableResource has this in an #ifdef, but mojo doesn't let us.
// TODO(https://crbug.com/671901)
return resource.is_backed_by_surface_texture;
#else
return false;
#endif
}
static bool wants_promotion_hint(const viz::TransferableResource& resource) {
#if defined(OS_ANDROID)
// TransferableResource has this in an #ifdef, but mojo doesn't let us.
// TODO(https://crbug.com/671901)
return resource.wants_promotion_hint;
#else
return false;
#endif
}
static const gfx::ColorSpace& color_space(
const viz::TransferableResource& resource) {
return resource.color_space;
}
static bool Read(viz::mojom::TransferableResourceDataView data,
viz::TransferableResource* out);
};
} // namespace mojo
#endif // SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_
|
1
|
static int function_7138520735500741632(G2MContext *variable_2740103264715909547){int variable_2098027009977411192;variable_2098027009977411192 = variable_2098027009977411192 * 1;float variable_8175907168492769802 = -4133726436300648448;float variable_479947997083674855 = -2863958327730619728;
float variable_5430470059014405387 = -9223372036854775807 - variable_479947997083674855;
float variable_1134764289672007863 = variable_8175907168492769802 / (5669309593585378321);if (!variable_2740103264715909547->framebuf || variable_2740103264715909547->old_width < variable_2740103264715909547->width || variable_2740103264715909547->old_height < variable_2740103264715909547->height) { variable_2740103264715909547->framebuf_stride = FFALIGN(variable_2740103264715909547->width * 3, 16); variable_2098027009977411192 = FFALIGN(variable_2740103264715909547->height, 16);av_free(variable_2740103264715909547->framebuf);variable_2740103264715909547->framebuf = av_mallocz(variable_2740103264715909547->framebuf_stride * variable_2098027009977411192);if (!variable_2740103264715909547->framebuf)return AVERROR(variable_2663889035032307482);}if (!variable_2740103264715909547->synth_tile || !variable_2740103264715909547->jpeg_tile ||variable_2740103264715909547->old_tile_w < variable_2740103264715909547->tile_width ||variable_2740103264715909547->old_tile_h < variable_2740103264715909547->tile_height) {variable_2740103264715909547->tile_stride = FFALIGN(variable_2740103264715909547->tile_width, 16) * 3;variable_2098027009977411192 = FFALIGN(variable_2740103264715909547->tile_height, 16);av_free(variable_2740103264715909547->synth_tile);av_free(variable_2740103264715909547->jpeg_tile);av_free(variable_2740103264715909547->kempf_buf);av_free(variable_2740103264715909547->kempf_flags);variable_2740103264715909547->synth_tile = av_mallocz(variable_2740103264715909547->tile_stride * variable_2098027009977411192);variable_2740103264715909547->jpeg_tile = av_mallocz(variable_2740103264715909547->tile_stride * variable_2098027009977411192);variable_2740103264715909547->kempf_buf = av_mallocz((variable_2740103264715909547->tile_width + 1) * variable_2098027009977411192+ variable_2445511041626958090);variable_2740103264715909547->kempf_flags = av_mallocz( variable_2740103264715909547->tile_width * variable_2098027009977411192);if (!variable_2740103264715909547->synth_tile || !variable_2740103264715909547->jpeg_tile ||!variable_2740103264715909547->kempf_buf || !variable_2740103264715909547->kempf_flags)return AVERROR(variable_2663889035032307482);}return 0;}
|
0
|
/*
* Core registration and callback routines for MTD
* drivers and users.
*
* Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org>
* Copyright © 2006 Red Hat UK Limited
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/ioctl.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/proc_fs.h>
#include <linux/idr.h>
#include <linux/backing-dev.h>
#include <linux/gfp.h>
#include <linux/slab.h>
#include <linux/reboot.h>
#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include "mtdcore.h"
static struct backing_dev_info *mtd_bdi;
#ifdef CONFIG_PM_SLEEP
static int mtd_cls_suspend(struct device *dev)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return mtd ? mtd_suspend(mtd) : 0;
}
static int mtd_cls_resume(struct device *dev)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
if (mtd)
mtd_resume(mtd);
return 0;
}
static SIMPLE_DEV_PM_OPS(mtd_cls_pm_ops, mtd_cls_suspend, mtd_cls_resume);
#define MTD_CLS_PM_OPS (&mtd_cls_pm_ops)
#else
#define MTD_CLS_PM_OPS NULL
#endif
static struct class mtd_class = {
.name = "mtd",
.owner = THIS_MODULE,
.pm = MTD_CLS_PM_OPS,
};
static DEFINE_IDR(mtd_idr);
/* These are exported solely for the purpose of mtd_blkdevs.c. You
should not use them for _anything_ else */
DEFINE_MUTEX(mtd_table_mutex);
EXPORT_SYMBOL_GPL(mtd_table_mutex);
struct mtd_info *__mtd_next_device(int i)
{
return idr_get_next(&mtd_idr, &i);
}
EXPORT_SYMBOL_GPL(__mtd_next_device);
static LIST_HEAD(mtd_notifiers);
#define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2)
/* REVISIT once MTD uses the driver model better, whoever allocates
* the mtd_info will probably want to use the release() hook...
*/
static void mtd_release(struct device *dev)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
dev_t index = MTD_DEVT(mtd->index);
/* remove /dev/mtdXro node */
device_destroy(&mtd_class, index + 1);
}
static ssize_t mtd_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
char *type;
switch (mtd->type) {
case MTD_ABSENT:
type = "absent";
break;
case MTD_RAM:
type = "ram";
break;
case MTD_ROM:
type = "rom";
break;
case MTD_NORFLASH:
type = "nor";
break;
case MTD_NANDFLASH:
type = "nand";
break;
case MTD_DATAFLASH:
type = "dataflash";
break;
case MTD_UBIVOLUME:
type = "ubi";
break;
case MTD_MLCNANDFLASH:
type = "mlc-nand";
break;
default:
type = "unknown";
}
return snprintf(buf, PAGE_SIZE, "%s\n", type);
}
static DEVICE_ATTR(type, S_IRUGO, mtd_type_show, NULL);
static ssize_t mtd_flags_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags);
}
static DEVICE_ATTR(flags, S_IRUGO, mtd_flags_show, NULL);
static ssize_t mtd_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)mtd->size);
}
static DEVICE_ATTR(size, S_IRUGO, mtd_size_show, NULL);
static ssize_t mtd_erasesize_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->erasesize);
}
static DEVICE_ATTR(erasesize, S_IRUGO, mtd_erasesize_show, NULL);
static ssize_t mtd_writesize_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->writesize);
}
static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
static ssize_t mtd_subpagesize_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
}
static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
static ssize_t mtd_oobsize_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->oobsize);
}
static DEVICE_ATTR(oobsize, S_IRUGO, mtd_oobsize_show, NULL);
static ssize_t mtd_numeraseregions_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", mtd->numeraseregions);
}
static DEVICE_ATTR(numeraseregions, S_IRUGO, mtd_numeraseregions_show,
NULL);
static ssize_t mtd_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name);
}
static DEVICE_ATTR(name, S_IRUGO, mtd_name_show, NULL);
static ssize_t mtd_ecc_strength_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", mtd->ecc_strength);
}
static DEVICE_ATTR(ecc_strength, S_IRUGO, mtd_ecc_strength_show, NULL);
static ssize_t mtd_bitflip_threshold_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", mtd->bitflip_threshold);
}
static ssize_t mtd_bitflip_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
unsigned int bitflip_threshold;
int retval;
retval = kstrtouint(buf, 0, &bitflip_threshold);
if (retval)
return retval;
mtd->bitflip_threshold = bitflip_threshold;
return count;
}
static DEVICE_ATTR(bitflip_threshold, S_IRUGO | S_IWUSR,
mtd_bitflip_threshold_show,
mtd_bitflip_threshold_store);
static ssize_t mtd_ecc_step_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", mtd->ecc_step_size);
}
static DEVICE_ATTR(ecc_step_size, S_IRUGO, mtd_ecc_step_size_show, NULL);
static ssize_t mtd_ecc_stats_corrected_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats;
return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->corrected);
}
static DEVICE_ATTR(corrected_bits, S_IRUGO,
mtd_ecc_stats_corrected_show, NULL);
static ssize_t mtd_ecc_stats_errors_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats;
return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->failed);
}
static DEVICE_ATTR(ecc_failures, S_IRUGO, mtd_ecc_stats_errors_show, NULL);
static ssize_t mtd_badblocks_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats;
return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->badblocks);
}
static DEVICE_ATTR(bad_blocks, S_IRUGO, mtd_badblocks_show, NULL);
static ssize_t mtd_bbtblocks_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats;
return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->bbtblocks);
}
static DEVICE_ATTR(bbt_blocks, S_IRUGO, mtd_bbtblocks_show, NULL);
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
&dev_attr_flags.attr,
&dev_attr_size.attr,
&dev_attr_erasesize.attr,
&dev_attr_writesize.attr,
&dev_attr_subpagesize.attr,
&dev_attr_oobsize.attr,
&dev_attr_numeraseregions.attr,
&dev_attr_name.attr,
&dev_attr_ecc_strength.attr,
&dev_attr_ecc_step_size.attr,
&dev_attr_corrected_bits.attr,
&dev_attr_ecc_failures.attr,
&dev_attr_bad_blocks.attr,
&dev_attr_bbt_blocks.attr,
&dev_attr_bitflip_threshold.attr,
NULL,
};
ATTRIBUTE_GROUPS(mtd);
static struct device_type mtd_devtype = {
.name = "mtd",
.groups = mtd_groups,
.release = mtd_release,
};
#ifndef CONFIG_MMU
unsigned mtd_mmap_capabilities(struct mtd_info *mtd)
{
switch (mtd->type) {
case MTD_RAM:
return NOMMU_MAP_COPY | NOMMU_MAP_DIRECT | NOMMU_MAP_EXEC |
NOMMU_MAP_READ | NOMMU_MAP_WRITE;
case MTD_ROM:
return NOMMU_MAP_COPY | NOMMU_MAP_DIRECT | NOMMU_MAP_EXEC |
NOMMU_MAP_READ;
default:
return NOMMU_MAP_COPY;
}
}
EXPORT_SYMBOL_GPL(mtd_mmap_capabilities);
#endif
static int mtd_reboot_notifier(struct notifier_block *n, unsigned long state,
void *cmd)
{
struct mtd_info *mtd;
mtd = container_of(n, struct mtd_info, reboot_notifier);
mtd->_reboot(mtd);
return NOTIFY_DONE;
}
/**
* mtd_wunit_to_pairing_info - get pairing information of a wunit
* @mtd: pointer to new MTD device info structure
* @wunit: write unit we are interested in
* @info: returned pairing information
*
* Retrieve pairing information associated to the wunit.
* This is mainly useful when dealing with MLC/TLC NANDs where pages can be
* paired together, and where programming a page may influence the page it is
* paired with.
* The notion of page is replaced by the term wunit (write-unit) to stay
* consistent with the ->writesize field.
*
* The @wunit argument can be extracted from an absolute offset using
* mtd_offset_to_wunit(). @info is filled with the pairing information attached
* to @wunit.
*
* From the pairing info the MTD user can find all the wunits paired with
* @wunit using the following loop:
*
* for (i = 0; i < mtd_pairing_groups(mtd); i++) {
* info.pair = i;
* mtd_pairing_info_to_wunit(mtd, &info);
* ...
* }
*/
int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit,
struct mtd_pairing_info *info)
{
int npairs = mtd_wunit_per_eb(mtd) / mtd_pairing_groups(mtd);
if (wunit < 0 || wunit >= npairs)
return -EINVAL;
if (mtd->pairing && mtd->pairing->get_info)
return mtd->pairing->get_info(mtd, wunit, info);
info->group = 0;
info->pair = wunit;
return 0;
}
EXPORT_SYMBOL_GPL(mtd_wunit_to_pairing_info);
/**
* mtd_wunit_to_pairing_info - get wunit from pairing information
* @mtd: pointer to new MTD device info structure
* @info: pairing information struct
*
* Returns a positive number representing the wunit associated to the info
* struct, or a negative error code.
*
* This is the reverse of mtd_wunit_to_pairing_info(), and can help one to
* iterate over all wunits of a given pair (see mtd_wunit_to_pairing_info()
* doc).
*
* It can also be used to only program the first page of each pair (i.e.
* page attached to group 0), which allows one to use an MLC NAND in
* software-emulated SLC mode:
*
* info.group = 0;
* npairs = mtd_wunit_per_eb(mtd) / mtd_pairing_groups(mtd);
* for (info.pair = 0; info.pair < npairs; info.pair++) {
* wunit = mtd_pairing_info_to_wunit(mtd, &info);
* mtd_write(mtd, mtd_wunit_to_offset(mtd, blkoffs, wunit),
* mtd->writesize, &retlen, buf + (i * mtd->writesize));
* }
*/
int mtd_pairing_info_to_wunit(struct mtd_info *mtd,
const struct mtd_pairing_info *info)
{
int ngroups = mtd_pairing_groups(mtd);
int npairs = mtd_wunit_per_eb(mtd) / ngroups;
if (!info || info->pair < 0 || info->pair >= npairs ||
info->group < 0 || info->group >= ngroups)
return -EINVAL;
if (mtd->pairing && mtd->pairing->get_wunit)
return mtd->pairing->get_wunit(mtd, info);
return info->pair;
}
EXPORT_SYMBOL_GPL(mtd_pairing_info_to_wunit);
/**
* mtd_pairing_groups - get the number of pairing groups
* @mtd: pointer to new MTD device info structure
*
* Returns the number of pairing groups.
*
* This number is usually equal to the number of bits exposed by a single
* cell, and can be used in conjunction with mtd_pairing_info_to_wunit()
* to iterate over all pages of a given pair.
*/
int mtd_pairing_groups(struct mtd_info *mtd)
{
if (!mtd->pairing || !mtd->pairing->ngroups)
return 1;
return mtd->pairing->ngroups;
}
EXPORT_SYMBOL_GPL(mtd_pairing_groups);
/**
* add_mtd_device - register an MTD device
* @mtd: pointer to new MTD device info structure
*
* Add a device to the list of MTD devices present in the system, and
* notify each currently active MTD 'user' of its arrival. Returns
* zero on success or non-zero on failure.
*/
int add_mtd_device(struct mtd_info *mtd)
{
struct mtd_notifier *not;
int i, error;
/*
* May occur, for instance, on buggy drivers which call
* mtd_device_parse_register() multiple times on the same master MTD,
* especially with CONFIG_MTD_PARTITIONED_MASTER=y.
*/
if (WARN_ONCE(mtd->backing_dev_info, "MTD already registered\n"))
return -EEXIST;
mtd->backing_dev_info = mtd_bdi;
BUG_ON(mtd->writesize == 0);
mutex_lock(&mtd_table_mutex);
i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
if (i < 0) {
error = i;
goto fail_locked;
}
mtd->index = i;
mtd->usecount = 0;
/* default value if not set by driver */
if (mtd->bitflip_threshold == 0)
mtd->bitflip_threshold = mtd->ecc_strength;
if (is_power_of_2(mtd->erasesize))
mtd->erasesize_shift = ffs(mtd->erasesize) - 1;
else
mtd->erasesize_shift = 0;
if (is_power_of_2(mtd->writesize))
mtd->writesize_shift = ffs(mtd->writesize) - 1;
else
mtd->writesize_shift = 0;
mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1;
mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
/* Some chips always power up locked. Unlock them now */
if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
error = mtd_unlock(mtd, 0, mtd->size);
if (error && error != -EOPNOTSUPP)
printk(KERN_WARNING
"%s: unlock failed, writes may not work\n",
mtd->name);
/* Ignore unlock failures? */
error = 0;
}
/* Caller should have set dev.parent to match the
* physical device, if appropriate.
*/
mtd->dev.type = &mtd_devtype;
mtd->dev.class = &mtd_class;
mtd->dev.devt = MTD_DEVT(i);
dev_set_name(&mtd->dev, "mtd%d", i);
dev_set_drvdata(&mtd->dev, mtd);
of_node_get(mtd_get_of_node(mtd));
error = device_register(&mtd->dev);
if (error)
goto fail_added;
device_create(&mtd_class, mtd->dev.parent, MTD_DEVT(i) + 1, NULL,
"mtd%dro", i);
pr_debug("mtd: Giving out device %d to %s\n", i, mtd->name);
/* No need to get a refcount on the module containing
the notifier, since we hold the mtd_table_mutex */
list_for_each_entry(not, &mtd_notifiers, list)
not->add(mtd);
mutex_unlock(&mtd_table_mutex);
/* We _know_ we aren't being removed, because
our caller is still holding us here. So none
of this try_ nonsense, and no bitching about it
either. :) */
__module_get(THIS_MODULE);
return 0;
fail_added:
of_node_put(mtd_get_of_node(mtd));
idr_remove(&mtd_idr, i);
fail_locked:
mutex_unlock(&mtd_table_mutex);
return error;
}
/**
* del_mtd_device - unregister an MTD device
* @mtd: pointer to MTD device info structure
*
* Remove a device from the list of MTD devices present in the system,
* and notify each currently active MTD 'user' of its departure.
* Returns zero on success or 1 on failure, which currently will happen
* if the requested device does not appear to be present in the list.
*/
int del_mtd_device(struct mtd_info *mtd)
{
int ret;
struct mtd_notifier *not;
mutex_lock(&mtd_table_mutex);
if (idr_find(&mtd_idr, mtd->index) != mtd) {
ret = -ENODEV;
goto out_error;
}
/* No need to get a refcount on the module containing
the notifier, since we hold the mtd_table_mutex */
list_for_each_entry(not, &mtd_notifiers, list)
not->remove(mtd);
if (mtd->usecount) {
printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
mtd->index, mtd->name, mtd->usecount);
ret = -EBUSY;
} else {
device_unregister(&mtd->dev);
idr_remove(&mtd_idr, mtd->index);
of_node_put(mtd_get_of_node(mtd));
module_put(THIS_MODULE);
ret = 0;
}
out_error:
mutex_unlock(&mtd_table_mutex);
return ret;
}
static int mtd_add_device_partitions(struct mtd_info *mtd,
struct mtd_partitions *parts)
{
const struct mtd_partition *real_parts = parts->parts;
int nbparts = parts->nr_parts;
int ret;
if (nbparts == 0 || IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
ret = add_mtd_device(mtd);
if (ret)
return ret;
}
if (nbparts > 0) {
ret = add_mtd_partitions(mtd, real_parts, nbparts);
if (ret && IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER))
del_mtd_device(mtd);
return ret;
}
return 0;
}
/*
* Set a few defaults based on the parent devices, if not provided by the
* driver
*/
static void mtd_set_dev_defaults(struct mtd_info *mtd)
{
if (mtd->dev.parent) {
if (!mtd->owner && mtd->dev.parent->driver)
mtd->owner = mtd->dev.parent->driver->owner;
if (!mtd->name)
mtd->name = dev_name(mtd->dev.parent);
} else {
pr_debug("mtd device won't show a device symlink in sysfs\n");
}
}
/**
* mtd_device_parse_register - parse partitions and register an MTD device.
*
* @mtd: the MTD device to register
* @types: the list of MTD partition probes to try, see
* 'parse_mtd_partitions()' for more information
* @parser_data: MTD partition parser-specific data
* @parts: fallback partition information to register, if parsing fails;
* only valid if %nr_parts > %0
* @nr_parts: the number of partitions in parts, if zero then the full
* MTD device is registered if no partition info is found
*
* This function aggregates MTD partitions parsing (done by
* 'parse_mtd_partitions()') and MTD device and partitions registering. It
* basically follows the most common pattern found in many MTD drivers:
*
* * It first tries to probe partitions on MTD device @mtd using parsers
* specified in @types (if @types is %NULL, then the default list of parsers
* is used, see 'parse_mtd_partitions()' for more information). If none are
* found this functions tries to fallback to information specified in
* @parts/@nr_parts.
* * If any partitioning info was found, this function registers the found
* partitions. If the MTD_PARTITIONED_MASTER option is set, then the device
* as a whole is registered first.
* * If no partitions were found this function just registers the MTD device
* @mtd and exits.
*
* Returns zero in case of success and a negative error code in case of failure.
*/
int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
struct mtd_part_parser_data *parser_data,
const struct mtd_partition *parts,
int nr_parts)
{
struct mtd_partitions parsed;
int ret;
mtd_set_dev_defaults(mtd);
memset(&parsed, 0, sizeof(parsed));
ret = parse_mtd_partitions(mtd, types, &parsed, parser_data);
if ((ret < 0 || parsed.nr_parts == 0) && parts && nr_parts) {
/* Fall back to driver-provided partitions */
parsed = (struct mtd_partitions){
.parts = parts,
.nr_parts = nr_parts,
};
} else if (ret < 0) {
/* Didn't come up with parsed OR fallback partitions */
pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n",
ret);
/* Don't abort on errors; we can still use unpartitioned MTD */
memset(&parsed, 0, sizeof(parsed));
}
ret = mtd_add_device_partitions(mtd, &parsed);
if (ret)
goto out;
/*
* FIXME: some drivers unfortunately call this function more than once.
* So we have to check if we've already assigned the reboot notifier.
*
* Generally, we can make multiple calls work for most cases, but it
* does cause problems with parse_mtd_partitions() above (e.g.,
* cmdlineparts will register partitions more than once).
*/
WARN_ONCE(mtd->_reboot && mtd->reboot_notifier.notifier_call,
"MTD already registered\n");
if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) {
mtd->reboot_notifier.notifier_call = mtd_reboot_notifier;
register_reboot_notifier(&mtd->reboot_notifier);
}
out:
/* Cleanup any parsed partitions */
mtd_part_parser_cleanup(&parsed);
return ret;
}
EXPORT_SYMBOL_GPL(mtd_device_parse_register);
/**
* mtd_device_unregister - unregister an existing MTD device.
*
* @master: the MTD device to unregister. This will unregister both the master
* and any partitions if registered.
*/
int mtd_device_unregister(struct mtd_info *master)
{
int err;
if (master->_reboot)
unregister_reboot_notifier(&master->reboot_notifier);
err = del_mtd_partitions(master);
if (err)
return err;
if (!device_is_registered(&master->dev))
return 0;
return del_mtd_device(master);
}
EXPORT_SYMBOL_GPL(mtd_device_unregister);
/**
* register_mtd_user - register a 'user' of MTD devices.
* @new: pointer to notifier info structure
*
* Registers a pair of callbacks function to be called upon addition
* or removal of MTD devices. Causes the 'add' callback to be immediately
* invoked for each MTD device currently present in the system.
*/
void register_mtd_user (struct mtd_notifier *new)
{
struct mtd_info *mtd;
mutex_lock(&mtd_table_mutex);
list_add(&new->list, &mtd_notifiers);
__module_get(THIS_MODULE);
mtd_for_each_device(mtd)
new->add(mtd);
mutex_unlock(&mtd_table_mutex);
}
EXPORT_SYMBOL_GPL(register_mtd_user);
/**
* unregister_mtd_user - unregister a 'user' of MTD devices.
* @old: pointer to notifier info structure
*
* Removes a callback function pair from the list of 'users' to be
* notified upon addition or removal of MTD devices. Causes the
* 'remove' callback to be immediately invoked for each MTD device
* currently present in the system.
*/
int unregister_mtd_user (struct mtd_notifier *old)
{
struct mtd_info *mtd;
mutex_lock(&mtd_table_mutex);
module_put(THIS_MODULE);
mtd_for_each_device(mtd)
old->remove(mtd);
list_del(&old->list);
mutex_unlock(&mtd_table_mutex);
return 0;
}
EXPORT_SYMBOL_GPL(unregister_mtd_user);
/**
* get_mtd_device - obtain a validated handle for an MTD device
* @mtd: last known address of the required MTD device
* @num: internal device number of the required MTD device
*
* Given a number and NULL address, return the num'th entry in the device
* table, if any. Given an address and num == -1, search the device table
* for a device with that address and return if it's still present. Given
* both, return the num'th driver only if its address matches. Return
* error code if not.
*/
struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
{
struct mtd_info *ret = NULL, *other;
int err = -ENODEV;
mutex_lock(&mtd_table_mutex);
if (num == -1) {
mtd_for_each_device(other) {
if (other == mtd) {
ret = mtd;
break;
}
}
} else if (num >= 0) {
ret = idr_find(&mtd_idr, num);
if (mtd && mtd != ret)
ret = NULL;
}
if (!ret) {
ret = ERR_PTR(err);
goto out;
}
err = __get_mtd_device(ret);
if (err)
ret = ERR_PTR(err);
out:
mutex_unlock(&mtd_table_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(get_mtd_device);
int __get_mtd_device(struct mtd_info *mtd)
{
int err;
if (!try_module_get(mtd->owner))
return -ENODEV;
if (mtd->_get_device) {
err = mtd->_get_device(mtd);
if (err) {
module_put(mtd->owner);
return err;
}
}
mtd->usecount++;
return 0;
}
EXPORT_SYMBOL_GPL(__get_mtd_device);
/**
* get_mtd_device_nm - obtain a validated handle for an MTD device by
* device name
* @name: MTD device name to open
*
* This function returns MTD device description structure in case of
* success and an error code in case of failure.
*/
struct mtd_info *get_mtd_device_nm(const char *name)
{
int err = -ENODEV;
struct mtd_info *mtd = NULL, *other;
mutex_lock(&mtd_table_mutex);
mtd_for_each_device(other) {
if (!strcmp(name, other->name)) {
mtd = other;
break;
}
}
if (!mtd)
goto out_unlock;
err = __get_mtd_device(mtd);
if (err)
goto out_unlock;
mutex_unlock(&mtd_table_mutex);
return mtd;
out_unlock:
mutex_unlock(&mtd_table_mutex);
return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(get_mtd_device_nm);
void put_mtd_device(struct mtd_info *mtd)
{
mutex_lock(&mtd_table_mutex);
__put_mtd_device(mtd);
mutex_unlock(&mtd_table_mutex);
}
EXPORT_SYMBOL_GPL(put_mtd_device);
void __put_mtd_device(struct mtd_info *mtd)
{
--mtd->usecount;
BUG_ON(mtd->usecount < 0);
if (mtd->_put_device)
mtd->_put_device(mtd);
module_put(mtd->owner);
}
EXPORT_SYMBOL_GPL(__put_mtd_device);
/*
* Erase is an asynchronous operation. Device drivers are supposed
* to call instr->callback() whenever the operation completes, even
* if it completes with a failure.
* Callers are supposed to pass a callback function and wait for it
* to be called before writing to the block.
*/
int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
{
if (instr->addr >= mtd->size || instr->len > mtd->size - instr->addr)
return -EINVAL;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
if (!instr->len) {
instr->state = MTD_ERASE_DONE;
mtd_erase_callback(instr);
return 0;
}
ledtrig_mtd_activity();
return mtd->_erase(mtd, instr);
}
EXPORT_SYMBOL_GPL(mtd_erase);
/*
* This stuff for eXecute-In-Place. phys is optional and may be set to NULL.
*/
int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
void **virt, resource_size_t *phys)
{
*retlen = 0;
*virt = NULL;
if (phys)
*phys = 0;
if (!mtd->_point)
return -EOPNOTSUPP;
if (from < 0 || from >= mtd->size || len > mtd->size - from)
return -EINVAL;
if (!len)
return 0;
return mtd->_point(mtd, from, len, retlen, virt, phys);
}
EXPORT_SYMBOL_GPL(mtd_point);
/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
if (!mtd->_point)
return -EOPNOTSUPP;
if (from < 0 || from >= mtd->size || len > mtd->size - from)
return -EINVAL;
if (!len)
return 0;
return mtd->_unpoint(mtd, from, len);
}
EXPORT_SYMBOL_GPL(mtd_unpoint);
/*
* Allow NOMMU mmap() to directly map the device (if not NULL)
* - return the address to which the offset maps
* - return -ENOSYS to indicate refusal to do the mapping
*/
unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
unsigned long offset, unsigned long flags)
{
if (!mtd->_get_unmapped_area)
return -EOPNOTSUPP;
if (offset >= mtd->size || len > mtd->size - offset)
return -EINVAL;
return mtd->_get_unmapped_area(mtd, len, offset, flags);
}
EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);
int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
u_char *buf)
{
int ret_code;
*retlen = 0;
if (from < 0 || from >= mtd->size || len > mtd->size - from)
return -EINVAL;
if (!len)
return 0;
ledtrig_mtd_activity();
/*
* In the absence of an error, drivers return a non-negative integer
* representing the maximum number of bitflips that were corrected on
* any one ecc region (if applicable; zero otherwise).
*/
ret_code = mtd->_read(mtd, from, len, retlen, buf);
if (unlikely(ret_code < 0))
return ret_code;
if (mtd->ecc_strength == 0)
return 0; /* device lacks ecc */
return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0;
}
EXPORT_SYMBOL_GPL(mtd_read);
int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
const u_char *buf)
{
*retlen = 0;
if (to < 0 || to >= mtd->size || len > mtd->size - to)
return -EINVAL;
if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE))
return -EROFS;
if (!len)
return 0;
ledtrig_mtd_activity();
return mtd->_write(mtd, to, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_write);
/*
* In blackbox flight recorder like scenarios we want to make successful writes
* in interrupt context. panic_write() is only intended to be called when its
* known the kernel is about to panic and we need the write to succeed. Since
* the kernel is not going to be running for much longer, this function can
* break locks and delay to ensure the write succeeds (but not sleep).
*/
int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
const u_char *buf)
{
*retlen = 0;
if (!mtd->_panic_write)
return -EOPNOTSUPP;
if (to < 0 || to >= mtd->size || len > mtd->size - to)
return -EINVAL;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
if (!len)
return 0;
return mtd->_panic_write(mtd, to, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_panic_write);
int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
{
int ret_code;
ops->retlen = ops->oobretlen = 0;
if (!mtd->_read_oob)
return -EOPNOTSUPP;
ledtrig_mtd_activity();
/*
* In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
* similar to mtd->_read(), returning a non-negative integer
* representing max bitflips. In other cases, mtd->_read_oob() may
* return -EUCLEAN. In all cases, perform similar logic to mtd_read().
*/
ret_code = mtd->_read_oob(mtd, from, ops);
if (unlikely(ret_code < 0))
return ret_code;
if (mtd->ecc_strength == 0)
return 0; /* device lacks ecc */
return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0;
}
EXPORT_SYMBOL_GPL(mtd_read_oob);
int mtd_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
{
ops->retlen = ops->oobretlen = 0;
if (!mtd->_write_oob)
return -EOPNOTSUPP;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
ledtrig_mtd_activity();
return mtd->_write_oob(mtd, to, ops);
}
EXPORT_SYMBOL_GPL(mtd_write_oob);
/**
* mtd_ooblayout_ecc - Get the OOB region definition of a specific ECC section
* @mtd: MTD device structure
* @section: ECC section. Depending on the layout you may have all the ECC
* bytes stored in a single contiguous section, or one section
* per ECC chunk (and sometime several sections for a single ECC
* ECC chunk)
* @oobecc: OOB region struct filled with the appropriate ECC position
* information
*
* This function returns ECC section information in the OOB area. If you want
* to get all the ECC bytes information, then you should call
* mtd_ooblayout_ecc(mtd, section++, oobecc) until it returns -ERANGE.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobecc)
{
memset(oobecc, 0, sizeof(*oobecc));
if (!mtd || section < 0)
return -EINVAL;
if (!mtd->ooblayout || !mtd->ooblayout->ecc)
return -ENOTSUPP;
return mtd->ooblayout->ecc(mtd, section, oobecc);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_ecc);
/**
* mtd_ooblayout_free - Get the OOB region definition of a specific free
* section
* @mtd: MTD device structure
* @section: Free section you are interested in. Depending on the layout
* you may have all the free bytes stored in a single contiguous
* section, or one section per ECC chunk plus an extra section
* for the remaining bytes (or other funky layout).
* @oobfree: OOB region struct filled with the appropriate free position
* information
*
* This function returns free bytes position in the OOB area. If you want
* to get all the free bytes information, then you should call
* mtd_ooblayout_free(mtd, section++, oobfree) until it returns -ERANGE.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobfree)
{
memset(oobfree, 0, sizeof(*oobfree));
if (!mtd || section < 0)
return -EINVAL;
if (!mtd->ooblayout || !mtd->ooblayout->free)
return -ENOTSUPP;
return mtd->ooblayout->free(mtd, section, oobfree);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_free);
/**
* mtd_ooblayout_find_region - Find the region attached to a specific byte
* @mtd: mtd info structure
* @byte: the byte we are searching for
* @sectionp: pointer where the section id will be stored
* @oobregion: used to retrieve the ECC position
* @iter: iterator function. Should be either mtd_ooblayout_free or
* mtd_ooblayout_ecc depending on the region type you're searching for
*
* This function returns the section id and oobregion information of a
* specific byte. For example, say you want to know where the 4th ECC byte is
* stored, you'll use:
*
* mtd_ooblayout_find_region(mtd, 3, §ion, &oobregion, mtd_ooblayout_ecc);
*
* Returns zero on success, a negative error code otherwise.
*/
static int mtd_ooblayout_find_region(struct mtd_info *mtd, int byte,
int *sectionp, struct mtd_oob_region *oobregion,
int (*iter)(struct mtd_info *,
int section,
struct mtd_oob_region *oobregion))
{
int pos = 0, ret, section = 0;
memset(oobregion, 0, sizeof(*oobregion));
while (1) {
ret = iter(mtd, section, oobregion);
if (ret)
return ret;
if (pos + oobregion->length > byte)
break;
pos += oobregion->length;
section++;
}
/*
* Adjust region info to make it start at the beginning at the
* 'start' ECC byte.
*/
oobregion->offset += byte - pos;
oobregion->length -= byte - pos;
*sectionp = section;
return 0;
}
/**
* mtd_ooblayout_find_eccregion - Find the ECC region attached to a specific
* ECC byte
* @mtd: mtd info structure
* @eccbyte: the byte we are searching for
* @sectionp: pointer where the section id will be stored
* @oobregion: OOB region information
*
* Works like mtd_ooblayout_find_region() except it searches for a specific ECC
* byte.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
int *section,
struct mtd_oob_region *oobregion)
{
return mtd_ooblayout_find_region(mtd, eccbyte, section, oobregion,
mtd_ooblayout_ecc);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_find_eccregion);
/**
* mtd_ooblayout_get_bytes - Extract OOB bytes from the oob buffer
* @mtd: mtd info structure
* @buf: destination buffer to store OOB bytes
* @oobbuf: OOB buffer
* @start: first byte to retrieve
* @nbytes: number of bytes to retrieve
* @iter: section iterator
*
* Extract bytes attached to a specific category (ECC or free)
* from the OOB buffer and copy them into buf.
*
* Returns zero on success, a negative error code otherwise.
*/
static int mtd_ooblayout_get_bytes(struct mtd_info *mtd, u8 *buf,
const u8 *oobbuf, int start, int nbytes,
int (*iter)(struct mtd_info *,
int section,
struct mtd_oob_region *oobregion))
{
struct mtd_oob_region oobregion;
int section, ret;
ret = mtd_ooblayout_find_region(mtd, start, §ion,
&oobregion, iter);
while (!ret) {
int cnt;
cnt = min_t(int, nbytes, oobregion.length);
memcpy(buf, oobbuf + oobregion.offset, cnt);
buf += cnt;
nbytes -= cnt;
if (!nbytes)
break;
ret = iter(mtd, ++section, &oobregion);
}
return ret;
}
/**
* mtd_ooblayout_set_bytes - put OOB bytes into the oob buffer
* @mtd: mtd info structure
* @buf: source buffer to get OOB bytes from
* @oobbuf: OOB buffer
* @start: first OOB byte to set
* @nbytes: number of OOB bytes to set
* @iter: section iterator
*
* Fill the OOB buffer with data provided in buf. The category (ECC or free)
* is selected by passing the appropriate iterator.
*
* Returns zero on success, a negative error code otherwise.
*/
static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf,
u8 *oobbuf, int start, int nbytes,
int (*iter)(struct mtd_info *,
int section,
struct mtd_oob_region *oobregion))
{
struct mtd_oob_region oobregion;
int section, ret;
ret = mtd_ooblayout_find_region(mtd, start, §ion,
&oobregion, iter);
while (!ret) {
int cnt;
cnt = min_t(int, nbytes, oobregion.length);
memcpy(oobbuf + oobregion.offset, buf, cnt);
buf += cnt;
nbytes -= cnt;
if (!nbytes)
break;
ret = iter(mtd, ++section, &oobregion);
}
return ret;
}
/**
* mtd_ooblayout_count_bytes - count the number of bytes in a OOB category
* @mtd: mtd info structure
* @iter: category iterator
*
* Count the number of bytes in a given category.
*
* Returns a positive value on success, a negative error code otherwise.
*/
static int mtd_ooblayout_count_bytes(struct mtd_info *mtd,
int (*iter)(struct mtd_info *,
int section,
struct mtd_oob_region *oobregion))
{
struct mtd_oob_region oobregion;
int section = 0, ret, nbytes = 0;
while (1) {
ret = iter(mtd, section++, &oobregion);
if (ret) {
if (ret == -ERANGE)
ret = nbytes;
break;
}
nbytes += oobregion.length;
}
return ret;
}
/**
* mtd_ooblayout_get_eccbytes - extract ECC bytes from the oob buffer
* @mtd: mtd info structure
* @eccbuf: destination buffer to store ECC bytes
* @oobbuf: OOB buffer
* @start: first ECC byte to retrieve
* @nbytes: number of ECC bytes to retrieve
*
* Works like mtd_ooblayout_get_bytes(), except it acts on ECC bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
const u8 *oobbuf, int start, int nbytes)
{
return mtd_ooblayout_get_bytes(mtd, eccbuf, oobbuf, start, nbytes,
mtd_ooblayout_ecc);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_get_eccbytes);
/**
* mtd_ooblayout_set_eccbytes - set ECC bytes into the oob buffer
* @mtd: mtd info structure
* @eccbuf: source buffer to get ECC bytes from
* @oobbuf: OOB buffer
* @start: first ECC byte to set
* @nbytes: number of ECC bytes to set
*
* Works like mtd_ooblayout_set_bytes(), except it acts on ECC bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
u8 *oobbuf, int start, int nbytes)
{
return mtd_ooblayout_set_bytes(mtd, eccbuf, oobbuf, start, nbytes,
mtd_ooblayout_ecc);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_set_eccbytes);
/**
* mtd_ooblayout_get_databytes - extract data bytes from the oob buffer
* @mtd: mtd info structure
* @databuf: destination buffer to store ECC bytes
* @oobbuf: OOB buffer
* @start: first ECC byte to retrieve
* @nbytes: number of ECC bytes to retrieve
*
* Works like mtd_ooblayout_get_bytes(), except it acts on free bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
const u8 *oobbuf, int start, int nbytes)
{
return mtd_ooblayout_get_bytes(mtd, databuf, oobbuf, start, nbytes,
mtd_ooblayout_free);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_get_databytes);
/**
* mtd_ooblayout_get_eccbytes - set data bytes into the oob buffer
* @mtd: mtd info structure
* @eccbuf: source buffer to get data bytes from
* @oobbuf: OOB buffer
* @start: first ECC byte to set
* @nbytes: number of ECC bytes to set
*
* Works like mtd_ooblayout_get_bytes(), except it acts on free bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
u8 *oobbuf, int start, int nbytes)
{
return mtd_ooblayout_set_bytes(mtd, databuf, oobbuf, start, nbytes,
mtd_ooblayout_free);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_set_databytes);
/**
* mtd_ooblayout_count_freebytes - count the number of free bytes in OOB
* @mtd: mtd info structure
*
* Works like mtd_ooblayout_count_bytes(), except it count free bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_count_freebytes(struct mtd_info *mtd)
{
return mtd_ooblayout_count_bytes(mtd, mtd_ooblayout_free);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_count_freebytes);
/**
* mtd_ooblayout_count_freebytes - count the number of ECC bytes in OOB
* @mtd: mtd info structure
*
* Works like mtd_ooblayout_count_bytes(), except it count ECC bytes.
*
* Returns zero on success, a negative error code otherwise.
*/
int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd)
{
return mtd_ooblayout_count_bytes(mtd, mtd_ooblayout_ecc);
}
EXPORT_SYMBOL_GPL(mtd_ooblayout_count_eccbytes);
/*
* Method to access the protection register area, present in some flash
* devices. The user data is one time programmable but the factory data is read
* only.
*/
int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
struct otp_info *buf)
{
if (!mtd->_get_fact_prot_info)
return -EOPNOTSUPP;
if (!len)
return 0;
return mtd->_get_fact_prot_info(mtd, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info);
int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
*retlen = 0;
if (!mtd->_read_fact_prot_reg)
return -EOPNOTSUPP;
if (!len)
return 0;
return mtd->_read_fact_prot_reg(mtd, from, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg);
int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
struct otp_info *buf)
{
if (!mtd->_get_user_prot_info)
return -EOPNOTSUPP;
if (!len)
return 0;
return mtd->_get_user_prot_info(mtd, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_get_user_prot_info);
int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
*retlen = 0;
if (!mtd->_read_user_prot_reg)
return -EOPNOTSUPP;
if (!len)
return 0;
return mtd->_read_user_prot_reg(mtd, from, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_read_user_prot_reg);
int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, u_char *buf)
{
int ret;
*retlen = 0;
if (!mtd->_write_user_prot_reg)
return -EOPNOTSUPP;
if (!len)
return 0;
ret = mtd->_write_user_prot_reg(mtd, to, len, retlen, buf);
if (ret)
return ret;
/*
* If no data could be written at all, we are out of memory and
* must return -ENOSPC.
*/
return (*retlen) ? 0 : -ENOSPC;
}
EXPORT_SYMBOL_GPL(mtd_write_user_prot_reg);
int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len)
{
if (!mtd->_lock_user_prot_reg)
return -EOPNOTSUPP;
if (!len)
return 0;
return mtd->_lock_user_prot_reg(mtd, from, len);
}
EXPORT_SYMBOL_GPL(mtd_lock_user_prot_reg);
/* Chip-supported device locking */
int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->_lock)
return -EOPNOTSUPP;
if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs)
return -EINVAL;
if (!len)
return 0;
return mtd->_lock(mtd, ofs, len);
}
EXPORT_SYMBOL_GPL(mtd_lock);
int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->_unlock)
return -EOPNOTSUPP;
if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs)
return -EINVAL;
if (!len)
return 0;
return mtd->_unlock(mtd, ofs, len);
}
EXPORT_SYMBOL_GPL(mtd_unlock);
int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->_is_locked)
return -EOPNOTSUPP;
if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs)
return -EINVAL;
if (!len)
return 0;
return mtd->_is_locked(mtd, ofs, len);
}
EXPORT_SYMBOL_GPL(mtd_is_locked);
int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs)
{
if (ofs < 0 || ofs >= mtd->size)
return -EINVAL;
if (!mtd->_block_isreserved)
return 0;
return mtd->_block_isreserved(mtd, ofs);
}
EXPORT_SYMBOL_GPL(mtd_block_isreserved);
int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
{
if (ofs < 0 || ofs >= mtd->size)
return -EINVAL;
if (!mtd->_block_isbad)
return 0;
return mtd->_block_isbad(mtd, ofs);
}
EXPORT_SYMBOL_GPL(mtd_block_isbad);
int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
{
if (!mtd->_block_markbad)
return -EOPNOTSUPP;
if (ofs < 0 || ofs >= mtd->size)
return -EINVAL;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
return mtd->_block_markbad(mtd, ofs);
}
EXPORT_SYMBOL_GPL(mtd_block_markbad);
/*
* default_mtd_writev - the default writev method
* @mtd: mtd device description object pointer
* @vecs: the vectors to write
* @count: count of vectors in @vecs
* @to: the MTD device offset to write to
* @retlen: on exit contains the count of bytes written to the MTD device.
*
* This function returns zero in case of success and a negative error code in
* case of failure.
*/
static int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen)
{
unsigned long i;
size_t totlen = 0, thislen;
int ret = 0;
for (i = 0; i < count; i++) {
if (!vecs[i].iov_len)
continue;
ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen,
vecs[i].iov_base);
totlen += thislen;
if (ret || thislen != vecs[i].iov_len)
break;
to += vecs[i].iov_len;
}
*retlen = totlen;
return ret;
}
/*
* mtd_writev - the vector-based MTD write method
* @mtd: mtd device description object pointer
* @vecs: the vectors to write
* @count: count of vectors in @vecs
* @to: the MTD device offset to write to
* @retlen: on exit contains the count of bytes written to the MTD device.
*
* This function returns zero in case of success and a negative error code in
* case of failure.
*/
int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen)
{
*retlen = 0;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
if (!mtd->_writev)
return default_mtd_writev(mtd, vecs, count, to, retlen);
return mtd->_writev(mtd, vecs, count, to, retlen);
}
EXPORT_SYMBOL_GPL(mtd_writev);
/**
* mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size
* @mtd: mtd device description object pointer
* @size: a pointer to the ideal or maximum size of the allocation, points
* to the actual allocation size on success.
*
* This routine attempts to allocate a contiguous kernel buffer up to
* the specified size, backing off the size of the request exponentially
* until the request succeeds or until the allocation size falls below
* the system page size. This attempts to make sure it does not adversely
* impact system performance, so when allocating more than one page, we
* ask the memory allocator to avoid re-trying, swapping, writing back
* or performing I/O.
*
* Note, this function also makes sure that the allocated buffer is aligned to
* the MTD device's min. I/O unit, i.e. the "mtd->writesize" value.
*
* This is called, for example by mtd_{read,write} and jffs2_scan_medium,
* to handle smaller (i.e. degraded) buffer allocations under low- or
* fragmented-memory situations where such reduced allocations, from a
* requested ideal, are allowed.
*
* Returns a pointer to the allocated buffer on success; otherwise, NULL.
*/
void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
{
gfp_t flags = __GFP_NOWARN | __GFP_DIRECT_RECLAIM | __GFP_NORETRY;
size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE);
void *kbuf;
*size = min_t(size_t, *size, KMALLOC_MAX_SIZE);
while (*size > min_alloc) {
kbuf = kmalloc(*size, flags);
if (kbuf)
return kbuf;
*size >>= 1;
*size = ALIGN(*size, mtd->writesize);
}
/*
* For the last resort allocation allow 'kmalloc()' to do all sorts of
* things (write-back, dropping caches, etc) by using GFP_KERNEL.
*/
return kmalloc(*size, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(mtd_kmalloc_up_to);
#ifdef CONFIG_PROC_FS
/*====================================================================*/
/* Support for /proc/mtd */
static int mtd_proc_show(struct seq_file *m, void *v)
{
struct mtd_info *mtd;
seq_puts(m, "dev: size erasesize name\n");
mutex_lock(&mtd_table_mutex);
mtd_for_each_device(mtd) {
seq_printf(m, "mtd%d: %8.8llx %8.8x \"%s\"\n",
mtd->index, (unsigned long long)mtd->size,
mtd->erasesize, mtd->name);
}
mutex_unlock(&mtd_table_mutex);
return 0;
}
static int mtd_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, mtd_proc_show, NULL);
}
static const struct file_operations mtd_proc_ops = {
.open = mtd_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif /* CONFIG_PROC_FS */
/*====================================================================*/
/* Init code */
static struct backing_dev_info * __init mtd_bdi_init(char *name)
{
struct backing_dev_info *bdi;
int ret;
bdi = kzalloc(sizeof(*bdi), GFP_KERNEL);
if (!bdi)
return ERR_PTR(-ENOMEM);
ret = bdi_setup_and_register(bdi, name);
if (ret)
kfree(bdi);
return ret ? ERR_PTR(ret) : bdi;
}
static struct proc_dir_entry *proc_mtd;
static int __init init_mtd(void)
{
int ret;
ret = class_register(&mtd_class);
if (ret)
goto err_reg;
mtd_bdi = mtd_bdi_init("mtd");
if (IS_ERR(mtd_bdi)) {
ret = PTR_ERR(mtd_bdi);
goto err_bdi;
}
proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
ret = init_mtdchar();
if (ret)
goto out_procfs;
return 0;
out_procfs:
if (proc_mtd)
remove_proc_entry("mtd", NULL);
bdi_destroy(mtd_bdi);
kfree(mtd_bdi);
err_bdi:
class_unregister(&mtd_class);
err_reg:
pr_err("Error registering mtd class or bdi: %d\n", ret);
return ret;
}
static void __exit cleanup_mtd(void)
{
cleanup_mtdchar();
if (proc_mtd)
remove_proc_entry("mtd", NULL);
class_unregister(&mtd_class);
bdi_destroy(mtd_bdi);
kfree(mtd_bdi);
idr_destroy(&mtd_idr);
}
module_init(init_mtd);
module_exit(cleanup_mtd);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
MODULE_DESCRIPTION("Core MTD registration and access routines");
|
0
|
#ifndef _LINUX_VIRTIO_9P_H
#define _LINUX_VIRTIO_9P_H
/* This header is BSD licensed so anyone can use the definitions to implement
* compatible drivers/servers.
*
* 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 IBM nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. */
#include <linux/types.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
/* The feature bitmap for virtio 9P */
/* The mount point is specified in a config variable */
#define VIRTIO_9P_MOUNT_TAG 0
struct virtio_9p_config {
/* length of the tag name */
__u16 tag_len;
/* non-NULL terminated tag name */
__u8 tag[0];
} __attribute__((packed));
#endif /* _LINUX_VIRTIO_9P_H */
|
1
|
bool ExtensionResourceRequestPolicy::CanRequestResource(const GURL& resource_url, const GURL& frame_url,const ExtensionSet* loaded_extensions) {CHECK(resource_url.SchemeIs(chrome::kExtensionScheme));const Extension* extension =loaded_extensions->GetExtensionOrAppByURL(ExtensionURLInfo(resource_url));if (!extension) {// Allow the load in the case of a non-existent extension. We'll just get a// 404 from the browser process.return true;}// Disallow loading of packaged resources for hosted apps. We don't allow// hybrid hosted/packaged apps. The one exception is access to icons, since// some extensions want to be able to do things like create their own// launchers.std::string resource_root_relative_path =resource_url.path().empty() ? "" : resource_url.path().substr(1);if (extension->is_hosted_app() &&!extension->icons().ContainsPath(resource_root_relative_path)) {LOG(ERROR) << "Denying load of " << resource_url.spec() << " from "<< "hosted app.";return false;}// Disallow loading of extension resources which are not explicitely listed// as web accessible if the manifest version is 2 or greater.// Exceptions are:// - empty origin (needed for some edge cases when we have empty origins)// - chrome-extension:// (for legacy reasons -- some extensions interop)if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensionsResourceWhitelist) &&int variable_8956404052767221850 = -339133646802425046;
int variable_2862738047115172986 = variable_8956404052767221850 / (5924554797700817999);
!frame_url.is_empty() &&!frame_url.SchemeIs(chrome::kExtensionScheme) &&!extension->IsResourceWebAccessible(resource_url.path())) {LOG(ERROR) << "Denying load of " << resource_url.spec() << " which "<< "is not a web accessible resource.";return false;}return true;}
|
1
|
static void IBusBusNameOwnerChangedCallback(
IBusBus* bus,
const gchar* name, const gchar* old_name, const gchar* new_name,
gpointer user_data) {
DCHECK(name);
DCHECK(old_name);
DCHECK(new_name);
DLOG(INFO) << "Name owner is changed: name=" << name
<< ", old_name=" << old_name << ", new_name=" << new_name;
if (name != std::string("org.freedesktop.IBus.Config")) {
// Not a signal for ibus-memconf.
return;
}
const std::string empty_string;
if (old_name != empty_string || new_name == empty_string) {
// ibus-memconf died?
LOG(WARNING) << "Unexpected name owner change: name=" << name
<< ", old_name=" << old_name << ", new_name=" << new_name;
// TODO(yusukes): it might be nice to set |ibus_config_| to NULL and call
// |connection_change_handler_| with false here to allow Chrome to
// recover all input method configurations when ibus-memconf is
// automatically restarted by ibus-daemon. Though ibus-memconf is pretty
// stable and unlikely crashes.
return;
}
LOG(INFO) << "IBus config daemon is started. Recovering ibus_config_";
g_return_if_fail(user_data);
InputMethodStatusConnection* self
= static_cast<InputMethodStatusConnection*>(user_data);
// Try to recover |ibus_config_|. If the |ibus_config_| object is
// successfully created, |connection_change_handler_| will be called to
// notify Chrome that IBus is ready.
self->MaybeRestoreConnections();
}
|
1
|
bool PermissionsContainsFunction::RunImpl() {scoped_ptr<Contains::Params> variable_1759480315388232931(Contains::Params::Create(*variable_8771060290935633209));scoped_refptr<PermissionSet> variable_5527052356865264095 =variable_5527052356865264095 = variable_5527052356865264095 + 0;std::string variable_8902502106366934700 = "qW";int variable_3895134061538124174 = -6455933883691754847 / (5167400019300872849);
helpers::UnpackPermissionSet(variable_1759480315388232931->permissions, &variable_847340181221236273);if (!variable_5527052356865264095.get())return false;variable_6554023784587790807 = Contains::Results::Create(GetExtension()->GetActivePermissions()->Contains(*variable_5527052356865264095));return true;}
|
1
|
static int variable_3457814655486527469 function_7131141428919186874(void){ variable_6140521694272428820 = kmem_cache_create("xfrm6_tunnel_spi", sizeof(struct xfrm6_tunnel_spi), 0, variable_8808453486775990649, NULL); if (!variable_6140521694272428820) return -variable_9089983809616078449; return 0;double variable_4641458230970734202 = -8221076458598428924 * (-4680601850929457303);variable_4641458230970734202 = variable_4641458230970734202 * 1;long int variable_4902162415785772015 = 6450424024049819588;
for (long int variable_5547765020041827958 = -2147066633092258884; variable_5547765020041827958 > 0; variable_5547765020041827958--) {
variable_4902162415785772015--;
}
}
|
1
|
void BaseRenderingContext2D::drawImage(ScriptState* script_state,CanvasImageSource* image_source,double sx,double sy,double sw,double sh,double dx,double dy,double dw,double dh,ExceptionState& exception_state) {if (!DrawingCanvas())return;double start_time = 0;start_time = start_time * 1;
Optional<CustomCountHistogram> timer;if (!IsPaint2D()) {start_time = WTF::MonotonicallyIncreasingTime();if (GetImageBuffer() && GetImageBuffer()->IsAccelerated()) {if (image_source->IsVideoElement()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_video_gpu,("Blink.Canvas.DrawImage.Video.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_video_gpu);} else if (image_source->IsCanvasElement()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_canvas_gpu,("Blink.Canvas.DrawImage.Canvas.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_canvas_gpu);} else if (image_source->IsSVGSource()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_svggpu,("Blink.Canvas.DrawImage.SVG.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_svggpu);} else if (image_source->IsImageBitmap()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_image_bitmap_gpu,("Blink.Canvas.DrawImage.ImageBitmap.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_image_bitmap_gpu);} else if (image_source->IsOffscreenCanvas()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_offscreencanvas_gpu,("Blink.Canvas.DrawImage.OffscreenCanvas.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_offscreencanvas_gpu);} else {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_others_gpu,("Blink.Canvas.DrawImage.Others.GPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_others_gpu);}} else {if (image_source->IsVideoElement()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_video_cpu,("Blink.Canvas.DrawImage.Video.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_video_cpu);} else if (image_source->IsCanvasElement()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_canvas_cpu,("Blink.Canvas.DrawImage.Canvas.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_canvas_cpu);} else if (image_source->IsSVGSource()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_svgcpu,("Blink.Canvas.DrawImage.SVG.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_svgcpu);} else if (image_source->IsImageBitmap()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_image_bitmap_cpu,("Blink.Canvas.DrawImage.ImageBitmap.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_image_bitmap_cpu);} else if (image_source->IsOffscreenCanvas()) {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_offscreencanvas_cpu,("Blink.Canvas.DrawImage.OffscreenCanvas.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_offscreencanvas_cpu);} else {DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter_others_cpu,("Blink.Canvas.DrawImage.Others.CPU", 0, 10000000, 50));timer.emplace(scoped_us_counter_others_cpu);}}}scoped_refptr<Image> image;FloatSize default_object_size(Width(), Height());SourceImageStatus source_image_status = kInvalidSourceImageStatus;if (!image_source->IsVideoElement()) {AccelerationHint hint =(HasImageBuffer() && GetImageBuffer()->IsAccelerated())? kPreferAcceleration: kPreferNoAcceleration;image = image_source->GetSourceImageForCanvas(&source_image_status, hint,kSnapshotReasonDrawImage,default_object_size);if (source_image_status == kUndecodableSourceImageStatus) {exception_state.ThrowDOMException(kInvalidStateError,"The HTMLImageElement provided is in the 'broken' state.");}if (!image || !image->width() || !image->height())return;} else {if (!static_cast<HTMLVideoElement*>(image_source)->HasAvailableVideoFrame())return;}if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) ||!std::isfinite(dh) || !std::isfinite(sx) || !std::isfinite(sy) ||!std::isfinite(sw) || !std::isfinite(sh) || !dw || !dh || !sw || !sh)return;FloatRect src_rect = NormalizeRect(FloatRect(sx, sy, sw, sh));FloatRect dst_rect = NormalizeRect(FloatRect(dx, dy, dw, dh));FloatSize image_size = image_source->ElementSize(default_object_size);ClipRectsToImageRect(FloatRect(FloatPoint(), image_size), &src_rect,&dst_rect);image_source->AdjustDrawRects(&src_rect, &dst_rect);if (src_rect.IsEmpty())return;DisableDeferralReason reason = kDisableDeferralReasonUnknown;if (ShouldDisableDeferral(image_source, &reason))DisableDeferral(reason);else if (image->IsTextureBacked())DisableDeferral(kDisableDeferralDrawImageWithTextureBackedSourceImage);ValidateStateStack();WillDrawImage(image_source);ValidateStateStack();// Heuristic for disabling acceleration based on anticipated texture upload// overhead.// See comments in CanvasHeuristicParameters.h for explanation.ImageBuffer* buffer = GetImageBuffer();if (buffer && buffer->IsAccelerated() && !image_source->IsAccelerated()) {float src_area = src_rect.Width() * src_rect.Height();if (src_area >CanvasHeuristicParameters::kDrawImageTextureUploadHardSizeLimit) {this->DisableAcceleration();} else if (src_area > CanvasHeuristicParameters::kDrawImageTextureUploadSoftSizeLimit) {SkRect bounds = dst_rect;SkMatrix ctm = DrawingCanvas()->getTotalMatrix();ctm.mapRect(&bounds);float dst_area = dst_rect.Width() * dst_rect.Height();if (src_area >dst_area * CanvasHeuristicParameters::kDrawImageTextureUploadSoftSizeLimitScaleThreshold) {this->DisableAcceleration();}}}ValidateStateStack(); if (OriginClean() && WouldTaintOrigin(image_source, ExecutionContext::From(script_state))) { SetOriginTainted(); ClearResolvedFilters(); }Draw([this, &image_source, &image, &src_rect, dst_rect](PaintCanvas* c, const PaintFlags* flags) // draw lambda{DrawImageInternal(c, image_source, image.get(), src_rect, dst_rect,flags);},[this, &dst_rect](const SkIRect& clip_bounds) // overdraw test lambda{ return RectContainsTransformedRect(dst_rect, clip_bounds); },dst_rect, CanvasRenderingContext2DState::kImagePaintType,image_source->IsOpaque()? CanvasRenderingContext2DState::kOpaqueImage: CanvasRenderingContext2DState::kNonOpaqueImage);ValidateStateStack();if (!IsPaint2D()) {DCHECK(start_time);timer->Count((WTF::MonotonicallyIncreasingTime() - start_time) *WTF::Time::kMicrosecondsPerSecond);}}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.