answer
stringlengths
15
1.25M
<?php /** * @file * Stub file for "bootstrap_dropdown" theme hook [pre]process functions. */ /** * Pre-processes variables for the "bootstrap_dropdown" theme hook. * * See theme function for list of available variables. * * @see <API key>() * * @ingroup theme_preprocess */ function <API key>(&$variables) { $element = &$variables['element']; // Provide defaults. $element += array( '#wrapper_attributes' => NULL, '#attributes' => NULL, '#alignment' => NULL, '#toggle' => NULL, '#items' => NULL, ); // Dropdown vertical alignment. $element['#wrapper_attributes']['class'][] = 'dropdown'; if ($element[' $element['#wrapper_attributes']['class'][] = 'dropup'; } if (isset($element['#toggle'])) { if (is_string($element['#toggle'])) { $element['#toggle'] = array( '#theme' => '<API key>', '#text' => filter_xss_admin($element['#toggle']), '#path' => '#', '#options' => array( 'attributes' => array(), 'html' => TRUE, 'external' => TRUE, ), ); } if (isset($element['#toggle']['#options']['attributes'])) { $element['#toggle']['#options']['attributes']['class'][] = 'dropdown-toggle'; $element['#toggle']['#options']['attributes']['data-toggle'] = 'dropdown'; } else { $element['#toggle']['#attributes']['class'][] = 'dropdown-toggle'; $element['#toggle']['#attributes']['data-toggle'] = 'dropdown'; } } // Menu items. $element['#attributes']['role'] = 'menu'; $element['#attributes']['class'][] = 'dropdown-menu'; if ($element[' $element['#attributes']['class'][] = 'dropdown-menu-right'; } } /** * Processes variables for the "bootstrap_dropdown" theme hook. * * See theme function for list of available variables. * * @see <API key>() * * @ingroup theme_process */ function <API key>(&$variables) { $element = &$variables['element']; $items = array(); foreach ($element['#items'] as $data) { $item_classes = array(); // Dividers. if (empty($data)) { $data = ''; $item_classes[] = 'divider'; } // Headers (must be a string). elseif (is_array($data) && (!empty($data['header']) || !empty($data['#header']))) { $item_classes[] = 'dropdown-header'; } // Disabled. elseif (is_array($data) && (!empty($data['disabled']) || !empty($data['#disabled']))) { $item_classes[] = 'disabled'; } // Active. elseif (is_array($data) && (!empty($data['active']) || !empty($data['#active']))) { $item_classes[] = 'active'; } // Construct item_list item. $item = array( 'data' => render($data), 'role' => 'presentation', ); if (!empty($item_classes)) { $item['class'] = $item_classes; } $items[] = $item; } // Create the dropdown. $variables['dropdown'] = array( '#theme_wrappers' => array('container'), '#attributes' => $element['#wrapper_attributes'], 'toggle' => $element['#toggle'], 'items' => array( '#theme' => '<API key>', '#items' => $items, '#attributes' => $element['#attributes'], ), ); }
a { text-decoration:none; } td { font-family: Arial, Helvetica, sans-serif; } div.tiny { width:1px; height:1px; font-size:1px; } .currentview { border: 2px solid blue; cursor: default; } #printview, #dayview, #weekview, #monthview { cursor: pointer; cursor: hand; } #functions { width: 13.5%; /* can't make this 25% for some reason */ min-width: 105px; float: left; padding: 0px 5px 0px 5px; margin-right: 0%; /* added because of the width issue above */ } #topToolbarRight { background-color:#BBCCFF; float: right; width: 100%; border-bottom:1px solid black; border-TOP:1px solid black; } #dateNAV { float: left; font-family: Arial, Helvetica, sans-serif; font-size: 14pt; } #dateDisplay { float: left; padding-left: 10px; font-family: Arial, Helvetica, sans-serif; } #viewPicker { float: right; margin-right: 10px; } #bigCalHeader { width:70%; float: right; text-align:center; font-family: Arial, Helvetica, sans-serif; font-size: 14pt; } #providerPicker { font-family: Arial, Helvetica, sans-serif; width: 100%; } #providerPicker #pc_facility { width: 100%; } #providerPicker #pc_username { width: 100%; } #facilityColor { font-family: Arial, Helvetica, sans-serif; width: 100%; float: left; } #facilityColor table{ width:100%; border-collapse: collapse; } #bottom{ float:left; position: relative; width:100%; } #bigCal { overflow: hidden; background-color: #FFF3D1; border-left:1px solid black; } #bigCal table { border-collapse: collapse; border: none; vertical-align:middle; width: 100%; } #bigCal td { padding: 1px; margin: 0px; } #bottomLeft { width: 15%; min-width:140px; float: left; clear: left; } /* these are for the small datepicker DIV */ #datePicker { width: 100%; } #datePicker table { width:96%; border-collapse: collapse; margin-left: 3px; } #datePicker td { width: 19.5px; font-family: Arial, Helvetica, sans-serif; font-size: 0.7em; text-align: center; /* font-size: 9pt; */ } #datePicker .tdMonthName-small { text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; background-color: #FFF2E8; cursor: pointer; } #datePicker .tdDOW-small { font-family: Arial, Helvetica, sans-serif; font-size: 10px; vertical-align: top; text-align: center; border: none; padding: 2px 3px 2px 3px; background-color: #FFF2E8; } #datePicker .tdDatePicker { cursor: pointer; cursor: hand; } #datePicker .tdWeekend-small { font-family: Arial, Helvetica, sans-serif; font-size: 10px; vertical-align: top; border: none; padding: 2px 3px 2px 3px; background-color: #ffffff; color: #999999; } #datePicker .<API key> { font-family: Arial, Helvetica, sans-serif; font-size: 10px; vertical-align: top; border: none; padding: 2px 3px 2px 3px; background-color: #ffffff; color: #999999; } #datePicker .tdMonthDay-small { font-family: Arial, Helvetica, sans-serif; font-size: 10px; vertical-align: top; border: none; padding: 2px 3px 2px 3px; background-color: #ffffff; } #datePicker .currentWeek { background-color: #DBD5FF; } #datePicker .currentDate { background-color: #A79BE7; color: #E8FAFF; } #datePicker .<API key> { background-color: #A79BE7; color: #E8FAFF; } /* the DIV of times */ #times { border-right: 1px solid #999; width: 2em; background-color: #FFF3D1; padding: 0px; } #times table { border-collapse: collapse; width: 100%; margin: 0px; padding: 0px; background-color: #E7D294; background-color: #FFF3D1; } #times table td { border-bottom: 1px solid #999; margin: 0px; padding: 0px; font-size: 0.8em; } .timeslot { /* height value is tied to two PHP variables in the ajax_*.html files * if you change this value then be sure to change the matching value * in those files */ height: 20px; margin: 0px; padding: 0px; } .schedule { background-color: #FFF3D1; background-color: #FFF; vertical-align: top; padding: 0px; margin: 0px; border: 1px solid #999999; } /* for the header row with provider names */ .providerheader { text-align: center; background-color: #EDEAFF; width: 100%; overflow:hidden; border-bottom: 1px solid lightgrey; white-space: nowrap; } /* for the DIV inside each TD, this DIV contains any events for a single day */ .calendar_day { position: relative; height: 100%; width: 100%; } /* classes specific to the WEEK view */ .week_dateheader { border-left: 1px solid #999; border-right: 1px solid #999; font-size: 0.7em; font-weight: bold; } .week_currday { background-color: #DBD5FF; } /* classes specific to the MONTH view */ .month_daylink { width:95%; font-size: 0.8em; text-align:right; background-color: #FFF; padding:1px 2px 1px 2px; } .month_dateheader { font-size: 0.7em; width:13%; } .month_event { font-size: 0.8em; width: 100%; } /* types of events */ .event { position: absolute; font-size: 0.8em; width: 100%; } .event img { vertical-align:middle; } .event_in { background-color: white; z-index:1; } .event_appointment { background-color: white; z-index:2; overflow: hidden; border: 1px solid #ccc; } .event_noshow { background-color: pink; z-index:2; overflow: hidden; border: 1px solid #fcc; } .event_reserved { background-color: pink; z-index:2; overflow: hidden; border: 1px solid #cfc; } .event_highlight { font-weight: bold; border-top: 1px solid #999; border-left: 1px solid #999; border-right: 2px solid #666; border-bottom: 2px solid #666; margin: -3px; background-color: black; } .event_time { cursor: pointer; } .event_time:hover { color: red; } .view1 { font-size:10px; } .view2 { background-color:#94D6E7; font-size:10px; } .in_start { background: transparent; z-index:2; } .event_out.event_highlight, .in_start.event_highlight { font-weight: bold; border-top: 1px solid #999; border-left: 1px solid #999; border-right: 2px solid #666; border-bottom: 2px solid #666; margin: 0px; background-color: yellow; opacity: 1; z-index: 2; cursor: pointer; } .event_out{ z-index: 3; background-color:#ff7533; }
#ifndef <API key> #define <API key> #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/<API key>.h" namespace base { class FilePath; class ScopedClosureRunner; class SequencedTaskRunner; } // namespace base namespace drive { namespace internal { class FileCache; class FileWriteWatcher; class ResourceMetadata; } // namespace internal class EventLogger; class JobScheduler; class ResourceEntry; namespace file_system { class CreateFileOperation; class DownloadOperation; class OperationDelegate; // Implements GetFileForSaving() operation that prepares a local cache for // a Drive file whose next modification is monitored and notified to the // OperationDelegate. // TODO(kinaba): crbug.com/269424: we might want to monitor all the changes // to the cache directory, not just the one immediately after the save dialog. class <API key> { public: <API key>(EventLogger* logger, base::SequencedTaskRunner* <API key>, OperationDelegate* delegate, JobScheduler* scheduler, internal::ResourceMetadata* metadata, internal::FileCache* cache, const base::FilePath& <API key>); ~<API key>(); // Makes sure that |file_path| in the file system is available in the local // cache, and marks it as dirty. The next modification to the cache file is // watched and is automatically notified to the delegate. If the entry is not // present in the file system, it is created. void GetFileForSaving(const base::FilePath& file_path, const GetFileCallback& callback); internal::FileWriteWatcher* <API key>() { return file_write_watcher_.get(); } private: void <API key>(const base::FilePath& file_path, const GetFileCallback& callback, FileError error); void <API key>(const GetFileCallback& callback, FileError error, const base::FilePath& cache_path, scoped_ptr<ResourceEntry> entry); void <API key>( const GetFileCallback& callback, const base::FilePath& cache_path, scoped_ptr<ResourceEntry> entry, scoped_ptr<base::ScopedClosureRunner>* file_closer, FileError error); void <API key>(const GetFileCallback& callback, const base::FilePath& cache_path, scoped_ptr<ResourceEntry> entry, bool success); // Called when the cache file for |local_id| is written. void OnWriteEvent(const std::string& local_id, scoped_ptr<base::ScopedClosureRunner> file_closer); EventLogger* logger_; scoped_ptr<CreateFileOperation> <API key>; scoped_ptr<DownloadOperation> download_operation_; scoped_ptr<internal::FileWriteWatcher> file_write_watcher_; scoped_refptr<base::SequencedTaskRunner> <API key>; OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; internal::FileCache* cache_; // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<<API key>> weak_ptr_factory_; <API key>(<API key>); }; } // namespace file_system } // namespace drive #endif // <API key>
// Boost.Bimap \file property_map/<API key>.hpp \brief Support for the property map concept. #ifndef <API key> #define <API key> #if defined(_MSC_VER) && (_MSC_VER>=1200) #pragma once #endif #include <boost/config.hpp> #include <boost/property_map/property_map.hpp> #include <boost/bimap/unordered_set_of.hpp> #include <boost/bimap/support/data_type_by.hpp> #include <boost/bimap/support/key_type_by.hpp> #ifndef <API key> namespace boost { template< class Tag, class Bimap > struct property_traits< ::boost::bimaps::views::unordered_map_view<Tag,Bimap> > { typedef <API key> ::boost::bimaps::support::data_type_by<Tag,Bimap>::type value_type; typedef <API key> ::boost::bimaps::support:: key_type_by<Tag,Bimap>::type key_type; typedef <API key> category; }; template< class Tag, class Bimap > const <API key> ::boost::bimaps::support::data_type_by<Tag,Bimap>::type & get(const ::boost::bimaps::views::unordered_map_view<Tag,Bimap> & m, const <API key> ::boost::bimaps::support::key_type_by<Tag,Bimap>::type & key) { return m.at(key); } } // namespace boost #endif // <API key> #endif // <API key>
#include <linux/module.h> #include <linux/interrupt.h> #include <linux/gpio/driver.h> #include <linux/log2.h> #include <linux/platform_device.h> #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinmux.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinconf-generic.h> #include "../core.h" #include "pinctrl-intel.h" /* Offset from regs */ #define REVID 0x000 #define REVID_SHIFT 16 #define REVID_MASK GENMASK(31, 16) #define PADBAR 0x00c #define GPI_IS 0x100 #define GPI_GPE_STS 0x140 #define GPI_GPE_EN 0x160 #define PADOWN_BITS 4 #define PADOWN_SHIFT(p) ((p) % 8 * PADOWN_BITS) #define PADOWN_MASK(p) (0xf << PADOWN_SHIFT(p)) #define PADOWN_GPP(p) ((p) / 8) /* Offset from pad_regs */ #define PADCFG0 0x000 #define <API key> 25 #define <API key> (3 << <API key>) #define <API key> 0 #define <API key> 1 #define <API key> 2 #define <API key> 3 #define PADCFG0_PREGFRXSEL BIT(24) #define PADCFG0_RXINV BIT(23) #define <API key> BIT(20) #define PADCFG0_GPIROUTSCI BIT(19) #define PADCFG0_GPIROUTSMI BIT(18) #define PADCFG0_GPIROUTNMI BIT(17) #define PADCFG0_PMODE_SHIFT 10 #define PADCFG0_PMODE_MASK (0xf << PADCFG0_PMODE_SHIFT) #define PADCFG0_GPIORXDIS BIT(9) #define PADCFG0_GPIOTXDIS BIT(8) #define PADCFG0_GPIORXSTATE BIT(1) #define PADCFG0_GPIOTXSTATE BIT(0) #define PADCFG1 0x004 #define PADCFG1_TERM_UP BIT(13) #define PADCFG1_TERM_SHIFT 10 #define PADCFG1_TERM_MASK (7 << PADCFG1_TERM_SHIFT) #define PADCFG1_TERM_20K 4 #define PADCFG1_TERM_2K 3 #define PADCFG1_TERM_5K 2 #define PADCFG1_TERM_1K 1 #define PADCFG2 0x008 #define PADCFG2_DEBEN BIT(0) #define <API key> 1 #define <API key> GENMASK(4, 1) #define DEBOUNCE_PERIOD 31250 struct intel_pad_context { u32 padcfg0; u32 padcfg1; u32 padcfg2; }; struct <API key> { u32 *intmask; }; struct <API key> { struct intel_pad_context *pads; struct <API key> *communities; }; /** * struct intel_pinctrl - Intel pinctrl private structure * @dev: Pointer to the device structure * @lock: Lock to serialize register access * @pctldesc: Pin controller description * @pctldev: Pointer to the pin controller device * @chip: GPIO chip in this pin controller * @soc: SoC/PCH specific pin configuration data * @communities: All communities in this pin controller * @ncommunities: Number of communities in this pin controller * @context: Configuration saved over system sleep * @irq: pinctrl/GPIO chip irq number */ struct intel_pinctrl { struct device *dev; raw_spinlock_t lock; struct pinctrl_desc pctldesc; struct pinctrl_dev *pctldev; struct gpio_chip chip; const struct <API key> *soc; struct intel_community *communities; size_t ncommunities; struct <API key> context; int irq; }; #define pin_to_padno(c, p) ((p) - (c)->pin_base) static struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned pin) { struct intel_community *community; int i; for (i = 0; i < pctrl->ncommunities; i++) { community = &pctrl->communities[i]; if (pin >= community->pin_base && pin < community->pin_base + community->npins) return community; } dev_warn(pctrl->dev, "failed to find community for pin %u\n", pin); return NULL; } static void __iomem *intel_get_padcfg(struct intel_pinctrl *pctrl, unsigned pin, unsigned reg) { const struct intel_community *community; unsigned padno; size_t nregs; community = intel_get_community(pctrl, pin); if (!community) return NULL; padno = pin_to_padno(community, pin); nregs = (community->features & <API key>) ? 4 : 2; if (reg == PADCFG2 && !(community->features & <API key>)) return NULL; return community->pad_regs + reg + padno * nregs * 4; } static bool <API key>(struct intel_pinctrl *pctrl, unsigned pin) { const struct intel_community *community; unsigned padno, gpp, offset, group; void __iomem *padown; community = intel_get_community(pctrl, pin); if (!community) return false; if (!community->padown_offset) return true; padno = pin_to_padno(community, pin); group = padno / community->gpp_size; gpp = PADOWN_GPP(padno % community->gpp_size); offset = community->padown_offset + 0x10 * group + gpp * 4; padown = community->regs + offset; return !(readl(padown) & PADOWN_MASK(padno)); } static bool intel_pad_acpi_mode(struct intel_pinctrl *pctrl, unsigned pin) { const struct intel_community *community; unsigned padno, gpp, offset; void __iomem *hostown; community = intel_get_community(pctrl, pin); if (!community) return true; if (!community->hostown_offset) return false; padno = pin_to_padno(community, pin); gpp = padno / community->gpp_size; offset = community->hostown_offset + gpp * 4; hostown = community->regs + offset; return !(readl(hostown) & BIT(padno % community->gpp_size)); } static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned pin) { struct intel_community *community; unsigned padno, gpp, offset; u32 value; community = intel_get_community(pctrl, pin); if (!community) return true; if (!community->padcfglock_offset) return false; padno = pin_to_padno(community, pin); gpp = padno / community->gpp_size; /* * If PADCFGLOCK and PADCFGLOCKTX bits are both clear for this pad, * the pad is considered unlocked. Any other case means that it is * either fully or partially locked and we don't touch it. */ offset = community->padcfglock_offset + gpp * 8; value = readl(community->regs + offset); if (value & BIT(pin % community->gpp_size)) return true; offset = community->padcfglock_offset + 4 + gpp * 8; value = readl(community->regs + offset); if (value & BIT(pin % community->gpp_size)) return true; return false; } static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned pin) { return <API key>(pctrl, pin) && !intel_pad_locked(pctrl, pin); } static int <API key>(struct pinctrl_dev *pctldev) { struct intel_pinctrl *pctrl = <API key>(pctldev); return pctrl->soc->ngroups; } static const char *<API key>(struct pinctrl_dev *pctldev, unsigned group) { struct intel_pinctrl *pctrl = <API key>(pctldev); return pctrl->soc->groups[group].name; } static int <API key>(struct pinctrl_dev *pctldev, unsigned group, const unsigned **pins, unsigned *npins) { struct intel_pinctrl *pctrl = <API key>(pctldev); *pins = pctrl->soc->groups[group].pins; *npins = pctrl->soc->groups[group].npins; return 0; } static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned pin) { struct intel_pinctrl *pctrl = <API key>(pctldev); void __iomem *padcfg; u32 cfg0, cfg1, mode; bool locked, acpi; if (!<API key>(pctrl, pin)) { seq_puts(s, "not available"); return; } cfg0 = readl(intel_get_padcfg(pctrl, pin, PADCFG0)); cfg1 = readl(intel_get_padcfg(pctrl, pin, PADCFG1)); mode = (cfg0 & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT; if (!mode) seq_puts(s, "GPIO "); else seq_printf(s, "mode %d ", mode); seq_printf(s, "0x%08x 0x%08x", cfg0, cfg1); /* Dump the additional PADCFG registers if available */ padcfg = intel_get_padcfg(pctrl, pin, PADCFG2); if (padcfg) seq_printf(s, " 0x%08x", readl(padcfg)); locked = intel_pad_locked(pctrl, pin); acpi = intel_pad_acpi_mode(pctrl, pin); if (locked || acpi) { seq_puts(s, " ["); if (locked) { seq_puts(s, "LOCKED"); if (acpi) seq_puts(s, ", "); } if (acpi) seq_puts(s, "ACPI"); seq_puts(s, "]"); } } static const struct pinctrl_ops intel_pinctrl_ops = { .get_groups_count = <API key>, .get_group_name = <API key>, .get_group_pins = <API key>, .pin_dbg_show = intel_pin_dbg_show, }; static int <API key>(struct pinctrl_dev *pctldev) { struct intel_pinctrl *pctrl = <API key>(pctldev); return pctrl->soc->nfunctions; } static const char *<API key>(struct pinctrl_dev *pctldev, unsigned function) { struct intel_pinctrl *pctrl = <API key>(pctldev); return pctrl->soc->functions[function].name; } static int <API key>(struct pinctrl_dev *pctldev, unsigned function, const char * const **groups, unsigned * const ngroups) { struct intel_pinctrl *pctrl = <API key>(pctldev); *groups = pctrl->soc->functions[function].groups; *ngroups = pctrl->soc->functions[function].ngroups; return 0; } static int <API key>(struct pinctrl_dev *pctldev, unsigned function, unsigned group) { struct intel_pinctrl *pctrl = <API key>(pctldev); const struct intel_pingroup *grp = &pctrl->soc->groups[group]; unsigned long flags; int i; <API key>(&pctrl->lock, flags); /* * All pins in the groups needs to be accessible and writable * before we can enable the mux for this group. */ for (i = 0; i < grp->npins; i++) { if (!intel_pad_usable(pctrl, grp->pins[i])) { <API key>(&pctrl->lock, flags); return -EBUSY; } } /* Now enable the mux setting for each pin in the group */ for (i = 0; i < grp->npins; i++) { void __iomem *padcfg0; u32 value; padcfg0 = intel_get_padcfg(pctrl, grp->pins[i], PADCFG0); value = readl(padcfg0); value &= ~PADCFG0_PMODE_MASK; value |= grp->mode << PADCFG0_PMODE_SHIFT; writel(value, padcfg0); } <API key>(&pctrl->lock, flags); return 0; } static void <API key>(void __iomem *padcfg0, bool input) { u32 value; value = readl(padcfg0); if (input) { value &= ~PADCFG0_GPIORXDIS; value |= PADCFG0_GPIOTXDIS; } else { value &= ~PADCFG0_GPIOTXDIS; value |= PADCFG0_GPIORXDIS; } writel(value, padcfg0); } static int <API key>(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned pin) { struct intel_pinctrl *pctrl = <API key>(pctldev); void __iomem *padcfg0; unsigned long flags; u32 value; <API key>(&pctrl->lock, flags); if (!intel_pad_usable(pctrl, pin)) { <API key>(&pctrl->lock, flags); return -EBUSY; } padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); /* Put the pad into GPIO mode */ value = readl(padcfg0) & ~PADCFG0_PMODE_MASK; /* Disable SCI/SMI/NMI generation */ value &= ~(<API key> | PADCFG0_GPIROUTSCI); value &= ~(PADCFG0_GPIROUTSMI | PADCFG0_GPIROUTNMI); writel(value, padcfg0); /* Disable TX buffer and enable RX (this will be input) */ <API key>(padcfg0, true); <API key>(&pctrl->lock, flags); return 0; } static int <API key>(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned pin, bool input) { struct intel_pinctrl *pctrl = <API key>(pctldev); void __iomem *padcfg0; unsigned long flags; <API key>(&pctrl->lock, flags); padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); <API key>(padcfg0, input); <API key>(&pctrl->lock, flags); return 0; } static const struct pinmux_ops intel_pinmux_ops = { .get_functions_count = <API key>, .get_function_name = <API key>, .get_function_groups = <API key>, .set_mux = <API key>, .gpio_request_enable = <API key>, .gpio_set_direction = <API key>, }; static int intel_config_get(struct pinctrl_dev *pctldev, unsigned pin, unsigned long *config) { struct intel_pinctrl *pctrl = <API key>(pctldev); enum pin_config_param param = <API key>(*config); const struct intel_community *community; u32 value, term; u32 arg = 0; if (!<API key>(pctrl, pin)) return -ENOTSUPP; community = intel_get_community(pctrl, pin); value = readl(intel_get_padcfg(pctrl, pin, PADCFG1)); term = (value & PADCFG1_TERM_MASK) >> PADCFG1_TERM_SHIFT; switch (param) { case <API key>: if (term) return -EINVAL; break; case <API key>: if (!term || !(value & PADCFG1_TERM_UP)) return -EINVAL; switch (term) { case PADCFG1_TERM_1K: arg = 1000; break; case PADCFG1_TERM_2K: arg = 2000; break; case PADCFG1_TERM_5K: arg = 5000; break; case PADCFG1_TERM_20K: arg = 20000; break; } break; case <API key>: if (!term || value & PADCFG1_TERM_UP) return -EINVAL; switch (term) { case PADCFG1_TERM_1K: if (!(community->features & <API key>)) return -EINVAL; arg = 1000; break; case PADCFG1_TERM_5K: arg = 5000; break; case PADCFG1_TERM_20K: arg = 20000; break; } break; case <API key>: { void __iomem *padcfg2; u32 v; padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2); if (!padcfg2) return -ENOTSUPP; v = readl(padcfg2); if (!(v & PADCFG2_DEBEN)) return -EINVAL; v = (v & <API key>) >> <API key>; arg = BIT(v) * DEBOUNCE_PERIOD / 1000; break; } default: return -ENOTSUPP; } *config = <API key>(param, arg); return 0; } static int <API key>(struct intel_pinctrl *pctrl, unsigned pin, unsigned long config) { unsigned param = <API key>(config); unsigned arg = <API key>(config); const struct intel_community *community; void __iomem *padcfg1; unsigned long flags; int ret = 0; u32 value; <API key>(&pctrl->lock, flags); community = intel_get_community(pctrl, pin); padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1); value = readl(padcfg1); switch (param) { case <API key>: value &= ~(PADCFG1_TERM_MASK | PADCFG1_TERM_UP); break; case <API key>: value &= ~PADCFG1_TERM_MASK; value |= PADCFG1_TERM_UP; switch (arg) { case 20000: value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; break; case 5000: value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; break; case 2000: value |= PADCFG1_TERM_2K << PADCFG1_TERM_SHIFT; break; case 1000: value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT; break; default: ret = -EINVAL; } break; case <API key>: value &= ~(PADCFG1_TERM_UP | PADCFG1_TERM_MASK); switch (arg) { case 20000: value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; break; case 5000: value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; break; case 1000: if (!(community->features & <API key>)) { ret = -EINVAL; break; } value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT; break; default: ret = -EINVAL; } break; } if (!ret) writel(value, padcfg1); <API key>(&pctrl->lock, flags); return ret; } static int <API key>(struct intel_pinctrl *pctrl, unsigned pin, unsigned debounce) { void __iomem *padcfg0, *padcfg2; unsigned long flags; u32 value0, value2; int ret = 0; padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2); if (!padcfg2) return -ENOTSUPP; padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); <API key>(&pctrl->lock, flags); value0 = readl(padcfg0); value2 = readl(padcfg2); /* Disable glitch filter and debouncer */ value0 &= ~PADCFG0_PREGFRXSEL; value2 &= ~(PADCFG2_DEBEN | <API key>); if (debounce) { unsigned long v; v = order_base_2(debounce * 1000 / DEBOUNCE_PERIOD); if (v < 3 || v > 15) { ret = -EINVAL; goto exit_unlock; } else { /* Enable glitch filter and debouncer */ value0 |= PADCFG0_PREGFRXSEL; value2 |= v << <API key>; value2 |= PADCFG2_DEBEN; } } writel(value0, padcfg0); writel(value2, padcfg2); exit_unlock: <API key>(&pctrl->lock, flags); return ret; } static int intel_config_set(struct pinctrl_dev *pctldev, unsigned pin, unsigned long *configs, unsigned nconfigs) { struct intel_pinctrl *pctrl = <API key>(pctldev); int i, ret; if (!intel_pad_usable(pctrl, pin)) return -ENOTSUPP; for (i = 0; i < nconfigs; i++) { switch (<API key>(configs[i])) { case <API key>: case <API key>: case <API key>: ret = <API key>(pctrl, pin, configs[i]); if (ret) return ret; break; case <API key>: ret = <API key>(pctrl, pin, <API key>(configs[i])); if (ret) return ret; break; default: return -ENOTSUPP; } } return 0; } static const struct pinconf_ops intel_pinconf_ops = { .is_generic = true, .pin_config_get = intel_config_get, .pin_config_set = intel_config_set, }; static const struct pinctrl_desc intel_pinctrl_desc = { .pctlops = &intel_pinctrl_ops, .pmxops = &intel_pinmux_ops, .confops = &intel_pinconf_ops, .owner = THIS_MODULE, }; static int intel_gpio_get(struct gpio_chip *chip, unsigned offset) { struct intel_pinctrl *pctrl = gpiochip_get_data(chip); void __iomem *reg; reg = intel_get_padcfg(pctrl, offset, PADCFG0); if (!reg) return -EINVAL; return !!(readl(reg) & PADCFG0_GPIORXSTATE); } static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct intel_pinctrl *pctrl = gpiochip_get_data(chip); void __iomem *reg; reg = intel_get_padcfg(pctrl, offset, PADCFG0); if (reg) { unsigned long flags; u32 padcfg0; <API key>(&pctrl->lock, flags); padcfg0 = readl(reg); if (value) padcfg0 |= PADCFG0_GPIOTXSTATE; else padcfg0 &= ~PADCFG0_GPIOTXSTATE; writel(padcfg0, reg); <API key>(&pctrl->lock, flags); } } static int <API key>(struct gpio_chip *chip, unsigned offset) { return <API key>(chip->base + offset); } static int <API key>(struct gpio_chip *chip, unsigned offset, int value) { intel_gpio_set(chip, offset, value); return <API key>(chip->base + offset); } static const struct gpio_chip intel_gpio_chip = { .owner = THIS_MODULE, .request = <API key>, .free = <API key>, .direction_input = <API key>, .direction_output = <API key>, .get = intel_gpio_get, .set = intel_gpio_set, .set_config = <API key>, }; static void intel_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = <API key>(d); struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); raw_spin_lock(&pctrl->lock); community = intel_get_community(pctrl, pin); if (community) { unsigned padno = pin_to_padno(community, pin); unsigned gpp_offset = padno % community->gpp_size; unsigned gpp = padno / community->gpp_size; writel(BIT(gpp_offset), community->regs + GPI_IS + gpp * 4); } raw_spin_unlock(&pctrl->lock); } static void <API key>(struct irq_data *d) { struct gpio_chip *gc = <API key>(d); struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); unsigned long flags; <API key>(&pctrl->lock, flags); community = intel_get_community(pctrl, pin); if (community) { unsigned padno = pin_to_padno(community, pin); unsigned gpp_size = community->gpp_size; unsigned gpp_offset = padno % gpp_size; unsigned gpp = padno / gpp_size; u32 value; /* Clear interrupt status first to avoid unexpected interrupt */ writel(BIT(gpp_offset), community->regs + GPI_IS + gpp * 4); value = readl(community->regs + community->ie_offset + gpp * 4); value |= BIT(gpp_offset); writel(value, community->regs + community->ie_offset + gpp * 4); } <API key>(&pctrl->lock, flags); } static void <API key>(struct irq_data *d, bool mask) { struct gpio_chip *gc = <API key>(d); struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); unsigned long flags; <API key>(&pctrl->lock, flags); community = intel_get_community(pctrl, pin); if (community) { unsigned padno = pin_to_padno(community, pin); unsigned gpp_offset = padno % community->gpp_size; unsigned gpp = padno / community->gpp_size; void __iomem *reg; u32 value; reg = community->regs + community->ie_offset + gpp * 4; value = readl(reg); if (mask) value &= ~BIT(gpp_offset); else value |= BIT(gpp_offset); writel(value, reg); } <API key>(&pctrl->lock, flags); } static void intel_gpio_irq_mask(struct irq_data *d) { <API key>(d, true); } static void <API key>(struct irq_data *d) { <API key>(d, false); } static int intel_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = <API key>(d); struct intel_pinctrl *pctrl = gpiochip_get_data(gc); unsigned pin = irqd_to_hwirq(d); unsigned long flags; void __iomem *reg; u32 value; reg = intel_get_padcfg(pctrl, pin, PADCFG0); if (!reg) return -EINVAL; /* * If the pin is in ACPI mode it is still usable as a GPIO but it * cannot be used as IRQ because GPI_IS status bit will not be * updated by the host controller hardware. */ if (intel_pad_acpi_mode(pctrl, pin)) { dev_warn(pctrl->dev, "pin %u cannot be used as IRQ\n", pin); return -EPERM; } <API key>(&pctrl->lock, flags); value = readl(reg); value &= ~(<API key> | PADCFG0_RXINV); if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { value |= <API key> << <API key>; } else if (type & <API key>) { value |= <API key> << <API key>; value |= PADCFG0_RXINV; } else if (type & <API key>) { value |= <API key> << <API key>; } else if (type & IRQ_TYPE_LEVEL_MASK) { if (type & IRQ_TYPE_LEVEL_LOW) value |= PADCFG0_RXINV; } else { value |= <API key> << <API key>; } writel(value, reg); if (type & IRQ_TYPE_EDGE_BOTH) <API key>(d, handle_edge_irq); else if (type & IRQ_TYPE_LEVEL_MASK) <API key>(d, handle_level_irq); <API key>(&pctrl->lock, flags); return 0; } static int intel_gpio_irq_wake(struct irq_data *d, unsigned int on) { struct gpio_chip *gc = <API key>(d); struct intel_pinctrl *pctrl = gpiochip_get_data(gc); unsigned pin = irqd_to_hwirq(d); if (on) enable_irq_wake(pctrl->irq); else disable_irq_wake(pctrl->irq); dev_dbg(pctrl->dev, "%sable wake for pin %u\n", on ? "en" : "dis", pin); return 0; } static irqreturn_t <API key>(struct intel_pinctrl *pctrl, const struct intel_community *community) { struct gpio_chip *gc = &pctrl->chip; irqreturn_t ret = IRQ_NONE; int gpp; for (gpp = 0; gpp < community->ngpps; gpp++) { unsigned long pending, enabled, gpp_offset; pending = readl(community->regs + GPI_IS + gpp * 4); enabled = readl(community->regs + community->ie_offset + gpp * 4); /* Only interrupts that are enabled */ pending &= enabled; for_each_set_bit(gpp_offset, &pending, community->gpp_size) { unsigned padno, irq; /* * The last group in community can have less pins * than NPADS_IN_GPP. */ padno = gpp_offset + gpp * community->gpp_size; if (padno >= community->npins) break; irq = irq_find_mapping(gc->irqdomain, community->pin_base + padno); generic_handle_irq(irq); ret |= IRQ_HANDLED; } } return ret; } static irqreturn_t intel_gpio_irq(int irq, void *data) { const struct intel_community *community; struct intel_pinctrl *pctrl = data; irqreturn_t ret = IRQ_NONE; int i; /* Need to check all communities for pending interrupts */ for (i = 0; i < pctrl->ncommunities; i++) { community = &pctrl->communities[i]; ret |= <API key>(pctrl, community); } return ret; } static struct irq_chip intel_gpio_irqchip = { .name = "intel-gpio", .irq_enable = <API key>, .irq_ack = intel_gpio_irq_ack, .irq_mask = intel_gpio_irq_mask, .irq_unmask = <API key>, .irq_set_type = intel_gpio_irq_type, .irq_set_wake = intel_gpio_irq_wake, }; static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq) { int ret; pctrl->chip = intel_gpio_chip; pctrl->chip.ngpio = pctrl->soc->npins; pctrl->chip.label = dev_name(pctrl->dev); pctrl->chip.parent = pctrl->dev; pctrl->chip.base = -1; pctrl->irq = irq; ret = <API key>(pctrl->dev, &pctrl->chip, pctrl); if (ret) { dev_err(pctrl->dev, "failed to register gpiochip\n"); return ret; } ret = <API key>(&pctrl->chip, dev_name(pctrl->dev), 0, 0, pctrl->soc->npins); if (ret) { dev_err(pctrl->dev, "failed to add GPIO pin range\n"); return ret; } /* * We need to request the interrupt here (instead of providing chip * to the irq directly) because on some platforms several GPIO * controllers share the same interrupt line. */ ret = devm_request_irq(pctrl->dev, irq, intel_gpio_irq, IRQF_SHARED | IRQF_NO_THREAD, dev_name(pctrl->dev), pctrl); if (ret) { dev_err(pctrl->dev, "failed to request interrupt\n"); return ret; } ret = <API key>(&pctrl->chip, &intel_gpio_irqchip, 0, handle_bad_irq, IRQ_TYPE_NONE); if (ret) { dev_err(pctrl->dev, "failed to add irqchip\n"); return ret; } <API key>(&pctrl->chip, &intel_gpio_irqchip, irq, NULL); return 0; } static int <API key>(struct intel_pinctrl *pctrl) { #ifdef CONFIG_PM_SLEEP const struct <API key> *soc = pctrl->soc; struct <API key> *communities; struct intel_pad_context *pads; int i; pads = devm_kcalloc(pctrl->dev, soc->npins, sizeof(*pads), GFP_KERNEL); if (!pads) return -ENOMEM; communities = devm_kcalloc(pctrl->dev, pctrl->ncommunities, sizeof(*communities), GFP_KERNEL); if (!communities) return -ENOMEM; for (i = 0; i < pctrl->ncommunities; i++) { struct intel_community *community = &pctrl->communities[i]; u32 *intmask; intmask = devm_kcalloc(pctrl->dev, community->ngpps, sizeof(*intmask), GFP_KERNEL); if (!intmask) return -ENOMEM; communities[i].intmask = intmask; } pctrl->context.pads = pads; pctrl->context.communities = communities; #endif return 0; } int intel_pinctrl_probe(struct platform_device *pdev, const struct <API key> *soc_data) { struct intel_pinctrl *pctrl; int i, ret, irq; if (!soc_data) return -EINVAL; pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); if (!pctrl) return -ENOMEM; pctrl->dev = &pdev->dev; pctrl->soc = soc_data; raw_spin_lock_init(&pctrl->lock); /* * Make a copy of the communities which we can use to hold pointers * to the registers. */ pctrl->ncommunities = pctrl->soc->ncommunities; pctrl->communities = devm_kcalloc(&pdev->dev, pctrl->ncommunities, sizeof(*pctrl->communities), GFP_KERNEL); if (!pctrl->communities) return -ENOMEM; for (i = 0; i < pctrl->ncommunities; i++) { struct intel_community *community = &pctrl->communities[i]; struct resource *res; void __iomem *regs; u32 padbar; *community = pctrl->soc->communities[i]; res = <API key>(pdev, IORESOURCE_MEM, community->barno); regs = <API key>(&pdev->dev, res); if (IS_ERR(regs)) return PTR_ERR(regs); /* * Determine community features based on the revision if * not specified already. */ if (!community->features) { u32 rev; rev = (readl(regs + REVID) & REVID_MASK) >> REVID_SHIFT; if (rev >= 0x94) { community->features |= <API key>; community->features |= <API key>; } } /* Read offset of the pad configuration registers */ padbar = readl(regs + PADBAR); community->regs = regs; community->pad_regs = regs + padbar; community->ngpps = DIV_ROUND_UP(community->npins, community->gpp_size); } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get interrupt number\n"); return irq; } ret = <API key>(pctrl); if (ret) return ret; pctrl->pctldesc = intel_pinctrl_desc; pctrl->pctldesc.name = dev_name(&pdev->dev); pctrl->pctldesc.pins = pctrl->soc->pins; pctrl->pctldesc.npins = pctrl->soc->npins; pctrl->pctldev = <API key>(&pdev->dev, &pctrl->pctldesc, pctrl); if (IS_ERR(pctrl->pctldev)) { dev_err(&pdev->dev, "failed to register pinctrl driver\n"); return PTR_ERR(pctrl->pctldev); } ret = intel_gpio_probe(pctrl, irq); if (ret) return ret; <API key>(pdev, pctrl); return 0; } EXPORT_SYMBOL_GPL(intel_pinctrl_probe); #ifdef CONFIG_PM_SLEEP static bool <API key>(struct intel_pinctrl *pctrl, unsigned pin) { const struct pin_desc *pd = pin_desc_get(pctrl->pctldev, pin); if (!pd || !intel_pad_usable(pctrl, pin)) return false; /* * Only restore the pin if it is actually in use by the kernel (or * by userspace). It is possible that some pins are used by the * BIOS during resume and those are not always locked down so leave * them alone. */ if (pd->mux_owner || pd->gpio_owner || <API key>(&pctrl->chip, pin)) return true; return false; } int <API key>(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct intel_pinctrl *pctrl = <API key>(pdev); struct <API key> *communities; struct intel_pad_context *pads; int i; pads = pctrl->context.pads; for (i = 0; i < pctrl->soc->npins; i++) { const struct pinctrl_pin_desc *desc = &pctrl->soc->pins[i]; void __iomem *padcfg; u32 val; if (!<API key>(pctrl, desc->number)) continue; val = readl(intel_get_padcfg(pctrl, desc->number, PADCFG0)); pads[i].padcfg0 = val & ~PADCFG0_GPIORXSTATE; val = readl(intel_get_padcfg(pctrl, desc->number, PADCFG1)); pads[i].padcfg1 = val; padcfg = intel_get_padcfg(pctrl, desc->number, PADCFG2); if (padcfg) pads[i].padcfg2 = readl(padcfg); } communities = pctrl->context.communities; for (i = 0; i < pctrl->ncommunities; i++) { struct intel_community *community = &pctrl->communities[i]; void __iomem *base; unsigned gpp; base = community->regs + community->ie_offset; for (gpp = 0; gpp < community->ngpps; gpp++) communities[i].intmask[gpp] = readl(base + gpp * 4); } return 0; } EXPORT_SYMBOL_GPL(<API key>); static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) { size_t i; for (i = 0; i < pctrl->ncommunities; i++) { const struct intel_community *community; void __iomem *base; unsigned gpp; community = &pctrl->communities[i]; base = community->regs; for (gpp = 0; gpp < community->ngpps; gpp++) { /* Mask and clear all interrupts */ writel(0, base + community->ie_offset + gpp * 4); writel(0xffff, base + GPI_IS + gpp * 4); } } } int <API key>(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct intel_pinctrl *pctrl = <API key>(pdev); const struct <API key> *communities; const struct intel_pad_context *pads; int i; /* Mask all interrupts */ intel_gpio_irq_init(pctrl); pads = pctrl->context.pads; for (i = 0; i < pctrl->soc->npins; i++) { const struct pinctrl_pin_desc *desc = &pctrl->soc->pins[i]; void __iomem *padcfg; u32 val; if (!<API key>(pctrl, desc->number)) continue; padcfg = intel_get_padcfg(pctrl, desc->number, PADCFG0); val = readl(padcfg) & ~PADCFG0_GPIORXSTATE; if (val != pads[i].padcfg0) { writel(pads[i].padcfg0, padcfg); dev_dbg(dev, "restored pin %u padcfg0 %#08x\n", desc->number, readl(padcfg)); } padcfg = intel_get_padcfg(pctrl, desc->number, PADCFG1); val = readl(padcfg); if (val != pads[i].padcfg1) { writel(pads[i].padcfg1, padcfg); dev_dbg(dev, "restored pin %u padcfg1 %#08x\n", desc->number, readl(padcfg)); } padcfg = intel_get_padcfg(pctrl, desc->number, PADCFG2); if (padcfg) { val = readl(padcfg); if (val != pads[i].padcfg2) { writel(pads[i].padcfg2, padcfg); dev_dbg(dev, "restored pin %u padcfg2 %#08x\n", desc->number, readl(padcfg)); } } } communities = pctrl->context.communities; for (i = 0; i < pctrl->ncommunities; i++) { struct intel_community *community = &pctrl->communities[i]; void __iomem *base; unsigned gpp; base = community->regs + community->ie_offset; for (gpp = 0; gpp < community->ngpps; gpp++) { writel(communities[i].intmask[gpp], base + gpp * 4); dev_dbg(dev, "restored mask %d/%u %#08x\n", i, gpp, readl(base + gpp * 4)); } } return 0; } EXPORT_SYMBOL_GPL(<API key>); #endif MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>"); MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); MODULE_DESCRIPTION("Intel pinctrl/GPIO core driver"); MODULE_LICENSE("GPL v2");
layout: "influxdb" page_title: "InfluxDB: <API key>" sidebar_current: "<API key>" description: |- The <API key> resource allows an InfluxDB continuous query to be managed. # influxdb\_continuous\_query The continuous_query resource allows a continuous query to be created on an InfluxDB server. ## Example Usage hcl resource "influxdb_database" "test" { name = "terraform-test" } resource "<API key>" "minnie" { name = "minnie" database = "${influxdb_database.test.name}" query = "SELECT min(mouse) INTO min_mouse FROM zoo GROUP BY time(30m)" } ## Argument Reference The following arguments are supported: * `name` - (Required) The name for the continuous_query. This must be unique on the InfluxDB server. * `database` - (Required) The database for the continuous_query. This must be an existing influxdb database. * `query` - (Required) The query for the continuous_query. ## Attributes Reference This resource exports no further attributes.
@echo off REM Please adjust the paths JFLEX_HOME and JAVA_HOME to suit your needs REM (please do not add a trailing backslash) set JFLEX_HOME=C:\JFLEX REM only needed for JDK 1.1.x: set JAVA_HOME=C:\JAVA REM set CLPATH=%JAVA_HOME%\lib\classes.zip;%JFLEX_HOME%\lib\JFlex.jar REM for JDK 1.1.x %JAVA_HOME%\bin\java -classpath %CLPATH% JFlex.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 REM for JDK 1.2 rem java -Xmx128m -jar %JFLEX_HOME%\lib\JFlex.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
<head> <style> div::selection { color: red; background-color: blue; } div { width: 1px; overflow: visible; } </style> </head> <div>M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;M&shy;</div> <script> document.execCommand('SelectAll') </script>
#include <net/mac80211.h> #include <net/rtnetlink.h> #include "ieee80211_i.h" #include "mesh.h" #include "driver-ops.h" #include "led.h" static void <API key>(struct ieee80211_local *local) { if (<API key>(local)) return; <API key>(local->hw.wiphy); } int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) { struct ieee80211_local *local = hw_to_local(hw); struct <API key> *sdata; struct sta_info *sta; if (!local->open_count) goto suspend; <API key>(local); <API key>(local); ieee80211_roc_purge(local, NULL); <API key>(local); if (ieee80211_hw_check(hw, AMPDU_AGGREGATION) && !(wowlan && wowlan->any)) { mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { set_sta_flag(sta, WLAN_STA_BLOCK_BA); <API key>( sta, <API key>); } mutex_unlock(&local->sta_mtx); } /* keep sched_scan only in case of 'any' trigger */ if (!(wowlan && wowlan->any)) <API key>(local); <API key>(hw, <API key>, <API key>, false); /* flush out all packets */ synchronize_net(); <API key>(local, NULL, true); local->quiescing = true; /* make quiescing visible to timers everywhere */ mb(); flush_workqueue(local->workqueue); /* Don't try to run timers while suspended. */ del_timer_sync(&local->sta_cleanup); /* * Note that this particular timer doesn't need to be * restarted at resume. */ cancel_work_sync(&local-><API key>); del_timer_sync(&local->dynamic_ps_timer); local->wowlan = wowlan; if (local->wowlan) { int err; /* Drivers don't expect to suspend while some operations like * authenticating or associating are in progress. It doesn't * make sense anyway to accept that, since the authentication * or association would never finish since the driver can't do * that on its own. * Thus, clean up in-progress auth/assoc first. */ list_for_each_entry(sdata, &local->interfaces, list) { if (!<API key>(sdata)) continue; if (sdata->vif.type != <API key>) continue; <API key>(sdata); /* If suspended during TX in progress, and wowlan * is enabled (connection will be active) there * can be a race where the driver is put out * of power-save due to TX and during suspend * dynamic_ps_timer is cancelled and TX packet * is flushed, leaving the driver in ACTIVE even * after resuming until dynamic_ps_timer puts * driver back in DOZE. */ if (sdata->u.mgd.associated && sdata->u.mgd.powersave && !(local->hw.conf.flags & IEEE80211_CONF_PS)) { local->hw.conf.flags |= IEEE80211_CONF_PS; ieee80211_hw_config(local, <API key>); } } err = drv_suspend(local, wowlan); if (err < 0) { local->quiescing = false; local->wowlan = false; if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) { mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { clear_sta_flag(sta, WLAN_STA_BLOCK_BA); } mutex_unlock(&local->sta_mtx); } <API key>(hw, <API key>, <API key>, false); return err; } else if (err > 0) { WARN_ON(err != 1); /* cfg80211 will call back into mac80211 to disconnect * all interfaces, allow that to proceed properly */ <API key>(hw, <API key>, <API key>, false); return err; } else { goto suspend; } } /* remove all interfaces that were created in the driver */ list_for_each_entry(sdata, &local->interfaces, list) { if (!<API key>(sdata)) continue; switch (sdata->vif.type) { case <API key>: case <API key>: continue; case <API key>: <API key>(sdata); break; case NL80211_IFTYPE_WDS: /* tear down aggregation sessions and remove STAs */ mutex_lock(&local->sta_mtx); sta = sdata->u.wds.sta; if (sta && sta->uploaded) { enum ieee80211_sta_state state; state = sta->sta_state; for (; state > <API key>; state WARN_ON(drv_sta_state(local, sta->sdata, sta, state, state - 1)); } mutex_unlock(&local->sta_mtx); break; default: break; } <API key>(local, sdata); } /* * We disconnected on all interfaces before suspend, all channel * contexts should be released. */ WARN_ON(!list_empty(&local->chanctx_list)); /* stop hardware - this must stop RX */ if (local->open_count) <API key>(local); suspend: local->suspended = true; /* need suspended to be visible before quiescing is false */ barrier(); local->quiescing = false; return 0; } /* * __ieee80211_resume() is a static inline which just calls * ieee80211_reconfig(), which is also needed for hardware * hang/firmware failure/etc. recovery. */ void <API key>(struct ieee80211_vif *vif, struct <API key> *wakeup, gfp_t gfp) { struct <API key> *sdata = vif_to_sdata(vif); <API key>(&sdata->wdev, wakeup, gfp); } EXPORT_SYMBOL(<API key>);
# coding=utf-8 from Handler import Handler import logging try: import gmetric except ImportError: gmetric = None class GmetricHandler(Handler): """ Implements the abstract Handler class, sending data the same way that gmetric does. """ def __init__(self, config=None): """ Create a new instance of the GmetricHandler class """ # Initialize Handler Handler.__init__(self, config) if gmetric is None: logging.error("Failed to load gmetric module") return # Initialize Data self.socket = None # Initialize Options self.host = self.config['host'] self.port = int(self.config['port']) self.protocol = self.config['protocol'] if not self.protocol: self.protocol = 'udp' # Initialize self.gmetric = gmetric.Gmetric(self.host, self.port, self.protocol) def <API key>(self): """ Returns the help text for the configuration options for this handler """ config = super(GmetricHandler, self).<API key>() config.update({ 'host': 'Hostname', 'port': 'Port', 'protocol': 'udp or tcp', }) return config def get_default_config(self): """ Return the default config for the handler """ config = super(GmetricHandler, self).get_default_config() config.update({ 'host': 'localhost', 'port': 8651, 'protocol': 'udp', }) return config def __del__(self): """ Destroy instance of the GmetricHandler class """ self._close() def process(self, metric): """ Process a metric by sending it to a gmond instance """ # Just send the data as a string self._send(metric) def _send(self, metric): """ Send data to gmond. """ metric_name = self.get_name_from_path(metric.path) tmax = "60" dmax = "0" slope = "both" # FIXME: Badness, shouldn't *assume* double type metric_type = "double" units = "" group = "" self.gmetric.send(metric_name, metric.value, metric_type, units, slope, tmax, dmax, group) def _close(self): """ Close the connection """ self.gmetric = None
#include <linux/kernel.h> #include <linux/io.h> #include <linux/clk.h> #include <linux/timer.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/irqreturn.h> #include <linux/interrupt.h> #include <linux/if_ether.h> #include <linux/etherdevice.h> #include <linux/netdevice.h> #include <linux/net_tstamp.h> #include <linux/phy.h> #include <linux/workqueue.h> #include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/of.h> #include <linux/of_net.h> #include <linux/of_device.h> #include <linux/if_vlan.h> #include <linux/pinctrl/consumer.h> #include "cpsw.h" #include "cpsw_ale.h" #include "cpts.h" #include "davinci_cpdma.h" #define CPSW_DEBUG (NETIF_MSG_HW | NETIF_MSG_WOL | \ NETIF_MSG_DRV | NETIF_MSG_LINK | \ NETIF_MSG_IFUP | NETIF_MSG_INTR | \ NETIF_MSG_PROBE | NETIF_MSG_TIMER | \ NETIF_MSG_IFDOWN | NETIF_MSG_RX_ERR | \ NETIF_MSG_TX_ERR | NETIF_MSG_TX_DONE | \ NETIF_MSG_PKTDATA | NETIF_MSG_TX_QUEUED | \ NETIF_MSG_RX_STATUS) #define cpsw_info(priv, type, format, ...) \ do { \ if (netif_msg_##type(priv) && net_ratelimit()) \ dev_info(priv->dev, format, ## __VA_ARGS__); \ } while (0) #define cpsw_err(priv, type, format, ...) \ do { \ if (netif_msg_##type(priv) && net_ratelimit()) \ dev_err(priv->dev, format, ## __VA_ARGS__); \ } while (0) #define cpsw_dbg(priv, type, format, ...) \ do { \ if (netif_msg_##type(priv) && net_ratelimit()) \ dev_dbg(priv->dev, format, ## __VA_ARGS__); \ } while (0) #define cpsw_notice(priv, type, format, ...) \ do { \ if (netif_msg_##type(priv) && net_ratelimit()) \ dev_notice(priv->dev, format, ## __VA_ARGS__); \ } while (0) #define ALE_ALL_PORTS 0x7 #define CPSW_MAJOR_VERSION(reg) (reg >> 8 & 0x7) #define CPSW_MINOR_VERSION(reg) (reg & 0xff) #define CPSW_RTL_VERSION(reg) ((reg >> 11) & 0x1f) #define CPSW_VERSION_1 0x19010a #define CPSW_VERSION_2 0x19010c #define CPSW_VERSION_3 0x19010f #define CPSW_VERSION_4 0x190112 #define HOST_PORT_NUM 0 #define SLIVER_SIZE 0x40 #define <API key> 0x028 #define CPSW1_SLAVE_OFFSET 0x050 #define CPSW1_SLAVE_SIZE 0x040 #define CPSW1_CPDMA_OFFSET 0x100 #define <API key> 0x200 #define CPSW1_HW_STATS 0x400 #define CPSW1_CPTS_OFFSET 0x500 #define CPSW1_ALE_OFFSET 0x600 #define CPSW1_SLIVER_OFFSET 0x700 #define <API key> 0x108 #define CPSW2_SLAVE_OFFSET 0x200 #define CPSW2_SLAVE_SIZE 0x100 #define CPSW2_CPDMA_OFFSET 0x800 #define CPSW2_HW_STATS 0x900 #define <API key> 0xa00 #define CPSW2_CPTS_OFFSET 0xc00 #define CPSW2_ALE_OFFSET 0xd00 #define CPSW2_SLIVER_OFFSET 0xd80 #define CPSW2_BD_OFFSET 0x2000 #define CPDMA_RXTHRESH 0x0c0 #define CPDMA_RXFREE 0x0e0 #define CPDMA_TXHDP 0x00 #define CPDMA_RXHDP 0x20 #define CPDMA_TXCP 0x40 #define CPDMA_RXCP 0x60 #define CPSW_POLL_WEIGHT 64 #define <API key> 60 #define <API key> (1500 + 14 + 4 + 4) #define RX_PRIORITY_MAPPING 0x76543210 #define TX_PRIORITY_MAPPING 0x33221100 #define <API key> 0x76543210 #define CPSW_VLAN_AWARE BIT(1) #define CPSW_ALE_VLAN_AWARE 1 #define <API key> (0 << 15) #define <API key> (1 << 15) #define <API key> (2 << 15) #define CPSW_INTPACEEN (0x3f << 16) #define <API key> (0x7FF << 0) #define CPSW_CMINTMAX_CNT 63 #define CPSW_CMINTMIN_CNT 2 #define CPSW_CMINTMAX_INTVL (1000 / CPSW_CMINTMIN_CNT) #define CPSW_CMINTMIN_INTVL ((1000 / CPSW_CMINTMAX_CNT) + 1) #define cpsw_enable_irq(priv) \ do { \ u32 i; \ for (i = 0; i < priv->num_irqs; i++) \ enable_irq(priv->irqs_table[i]); \ } while (0); #define cpsw_disable_irq(priv) \ do { \ u32 i; \ for (i = 0; i < priv->num_irqs; i++) \ disable_irq_nosync(priv->irqs_table[i]); \ } while (0); #define cpsw_slave_index(priv) \ ((priv->data.dual_emac) ? priv->emac_port : \ priv->data.active_slave) static int debug_level; module_param(debug_level, int, 0); MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)"); static int ale_ageout = 10; module_param(ale_ageout, int, 0); MODULE_PARM_DESC(ale_ageout, "cpsw ale ageout interval (seconds)"); static int rx_packet_max = <API key>; module_param(rx_packet_max, int, 0); MODULE_PARM_DESC(rx_packet_max, "maximum receive packet size (bytes)"); struct cpsw_wr_regs { u32 id_ver; u32 soft_reset; u32 control; u32 int_control; u32 rx_thresh_en; u32 rx_en; u32 tx_en; u32 misc_en; u32 mem_allign1[8]; u32 rx_thresh_stat; u32 rx_stat; u32 tx_stat; u32 misc_stat; u32 mem_allign2[8]; u32 rx_imax; u32 tx_imax; }; struct cpsw_ss_regs { u32 id_ver; u32 control; u32 soft_reset; u32 stat_port_en; u32 ptype; u32 soft_idle; u32 thru_rate; u32 gap_thresh; u32 tx_start_wds; u32 flow_control; u32 vlan_ltype; u32 ts_ltype; u32 dlr_ltype; }; /* CPSW_PORT_V1 */ #define CPSW1_MAX_BLKS 0x00 /* Maximum FIFO Blocks */ #define CPSW1_BLK_CNT 0x04 /* FIFO Block Usage Count (Read Only) */ #define CPSW1_TX_IN_CTL 0x08 /* Transmit FIFO Control */ #define CPSW1_PORT_VLAN 0x0c /* VLAN Register */ #define CPSW1_TX_PRI_MAP 0x10 /* Tx Header Priority to Switch Pri Mapping */ #define CPSW1_TS_CTL 0x14 /* Time Sync Control */ #define CPSW1_TS_SEQ_LTYPE 0x18 /* Time Sync Sequence ID Offset and Msg Type */ #define CPSW1_TS_VLAN 0x1c /* Time Sync VLAN1 and VLAN2 */ /* CPSW_PORT_V2 */ #define CPSW2_CONTROL 0x00 /* Control Register */ #define CPSW2_MAX_BLKS 0x08 /* Maximum FIFO Blocks */ #define CPSW2_BLK_CNT 0x0c /* FIFO Block Usage Count (Read Only) */ #define CPSW2_TX_IN_CTL 0x10 /* Transmit FIFO Control */ #define CPSW2_PORT_VLAN 0x14 /* VLAN Register */ #define CPSW2_TX_PRI_MAP 0x18 /* Tx Header Priority to Switch Pri Mapping */ #define CPSW2_TS_SEQ_MTYPE 0x1c /* Time Sync Sequence ID Offset and Msg Type */ /* CPSW_PORT_V1 and V2 */ #define SA_LO 0x20 /* CPGMAC_SL Source Address Low */ #define SA_HI 0x24 /* CPGMAC_SL Source Address High */ #define SEND_PERCENT 0x28 /* Transmit Queue Send Percentages */ /* CPSW_PORT_V2 only */ #define RX_DSCP_PRI_MAP0 0x30 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP1 0x34 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP2 0x38 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP3 0x3c /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP4 0x40 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP5 0x44 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP6 0x48 /* Rx DSCP Priority to Rx Packet Mapping */ #define RX_DSCP_PRI_MAP7 0x4c /* Rx DSCP Priority to Rx Packet Mapping */ /* Bit definitions for the CPSW2_CONTROL register */ #define PASS_PRI_TAGGED (1<<24) /* Pass Priority Tagged */ #define VLAN_LTYPE2_EN (1<<21) /* VLAN LTYPE 2 enable */ #define VLAN_LTYPE1_EN (1<<20) /* VLAN LTYPE 1 enable */ #define DSCP_PRI_EN (1<<16) /* DSCP Priority Enable */ #define TS_320 (1<<14) /* Time Sync Dest Port 320 enable */ #define TS_319 (1<<13) /* Time Sync Dest Port 319 enable */ #define TS_132 (1<<12) /* Time Sync Dest IP Addr 132 enable */ #define TS_131 (1<<11) /* Time Sync Dest IP Addr 131 enable */ #define TS_130 (1<<10) /* Time Sync Dest IP Addr 130 enable */ #define TS_129 (1<<9) /* Time Sync Dest IP Addr 129 enable */ #define TS_BIT8 (1<<8) /* ts_ttl_nonzero? */ #define TS_ANNEX_D_EN (1<<4) /* Time Sync Annex D enable */ #define TS_LTYPE2_EN (1<<3) /* Time Sync LTYPE 2 enable */ #define TS_LTYPE1_EN (1<<2) /* Time Sync LTYPE 1 enable */ #define TS_TX_EN (1<<1) /* Time Sync Transmit Enable */ #define TS_RX_EN (1<<0) /* Time Sync Receive Enable */ #define CTRL_TS_BITS \ (TS_320 | TS_319 | TS_132 | TS_131 | TS_130 | TS_129 | TS_BIT8 | \ TS_ANNEX_D_EN | TS_LTYPE1_EN) #define CTRL_ALL_TS_MASK (CTRL_TS_BITS | TS_TX_EN | TS_RX_EN) #define CTRL_TX_TS_BITS (CTRL_TS_BITS | TS_TX_EN) #define CTRL_RX_TS_BITS (CTRL_TS_BITS | TS_RX_EN) /* Bit definitions for the CPSW2_TS_SEQ_MTYPE register */ #define <API key> (16) /* Time Sync Sequence ID Offset */ #define <API key> (0x3f) #define <API key> (0) /* Time Sync Message Type Enable */ #define TS_MSG_TYPE_EN_MASK (0xffff) /* The PTP event messages - Sync, Delay_Req, Pdelay_Req, and Pdelay_Resp. */ #define EVENT_MSG_BITS ((1<<0) | (1<<1) | (1<<2) | (1<<3)) /* Bit definitions for the CPSW1_TS_CTL register */ #define CPSW_V1_TS_RX_EN BIT(0) #define CPSW_V1_TS_TX_EN BIT(4) #define <API key> 16 /* Bit definitions for the CPSW1_TS_SEQ_LTYPE register */ #define <API key> 16 struct cpsw_host_regs { u32 max_blks; u32 blk_cnt; u32 tx_in_ctl; u32 port_vlan; u32 tx_pri_map; u32 cpdma_tx_pri_map; u32 cpdma_rx_chan_map; }; struct cpsw_sliver_regs { u32 id_ver; u32 mac_control; u32 mac_status; u32 soft_reset; u32 rx_maxlen; u32 __reserved_0; u32 rx_pause; u32 tx_pause; u32 __reserved_1; u32 rx_pri_map; }; struct cpsw_hw_stats { u32 rxgoodframes; u32 rxbroadcastframes; u32 rxmulticastframes; u32 rxpauseframes; u32 rxcrcerrors; u32 rxaligncodeerrors; u32 rxoversizedframes; u32 rxjabberframes; u32 rxundersizedframes; u32 rxfragments; u32 __pad_0[2]; u32 rxoctets; u32 txgoodframes; u32 txbroadcastframes; u32 txmulticastframes; u32 txpauseframes; u32 txdeferredframes; u32 txcollisionframes; u32 txsinglecollframes; u32 txmultcollframes; u32 <API key>; u32 txlatecollisions; u32 txunderrun; u32 <API key>; u32 txoctets; u32 octetframes64; u32 octetframes65t127; u32 octetframes128t255; u32 octetframes256t511; u32 octetframes512t1023; u32 octetframes1024tup; u32 netoctets; u32 rxsofoverruns; u32 rxmofoverruns; u32 rxdmaoverruns; }; struct cpsw_slave { void __iomem *regs; struct cpsw_sliver_regs __iomem *sliver; int slave_num; u32 mac_control; struct cpsw_slave_data *data; struct phy_device *phy; struct net_device *ndev; u32 port_vlan; u32 open_stat; }; static inline u32 slave_read(struct cpsw_slave *slave, u32 offset) { return __raw_readl(slave->regs + offset); } static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset) { __raw_writel(val, slave->regs + offset); } struct cpsw_priv { spinlock_t lock; struct platform_device *pdev; struct net_device *ndev; struct napi_struct napi; struct device *dev; struct cpsw_platform_data data; struct cpsw_ss_regs __iomem *regs; struct cpsw_wr_regs __iomem *wr_regs; u8 __iomem *hw_stats; struct cpsw_host_regs __iomem *host_port_regs; u32 msg_enable; u32 version; u32 coal_intvl; u32 bus_freq_mhz; struct net_device_stats stats; int rx_packet_max; int host_port; struct clk *clk; u8 mac_addr[ETH_ALEN]; struct cpsw_slave *slaves; struct cpdma_ctlr *dma; struct cpdma_chan *txch, *rxch; struct cpsw_ale *ale; /* snapshot of IRQ numbers */ u32 irqs_table[4]; u32 num_irqs; bool irq_enabled; struct cpts *cpts; u32 emac_port; }; struct cpsw_stats { char stat_string[ETH_GSTRING_LEN]; int type; int sizeof_stat; int stat_offset; }; enum { CPSW_STATS, CPDMA_RX_STATS, CPDMA_TX_STATS, }; #define CPSW_STAT(m) CPSW_STATS, \ sizeof(((struct cpsw_hw_stats *)0)->m), \ offsetof(struct cpsw_hw_stats, m) #define CPDMA_RX_STAT(m) CPDMA_RX_STATS, \ sizeof(((struct cpdma_chan_stats *)0)->m), \ offsetof(struct cpdma_chan_stats, m) #define CPDMA_TX_STAT(m) CPDMA_TX_STATS, \ sizeof(((struct cpdma_chan_stats *)0)->m), \ offsetof(struct cpdma_chan_stats, m) static const struct cpsw_stats cpsw_gstrings_stats[] = { { "Good Rx Frames", CPSW_STAT(rxgoodframes) }, { "Broadcast Rx Frames", CPSW_STAT(rxbroadcastframes) }, { "Multicast Rx Frames", CPSW_STAT(rxmulticastframes) }, { "Pause Rx Frames", CPSW_STAT(rxpauseframes) }, { "Rx CRC Errors", CPSW_STAT(rxcrcerrors) }, { "Rx Align/Code Errors", CPSW_STAT(rxaligncodeerrors) }, { "Oversize Rx Frames", CPSW_STAT(rxoversizedframes) }, { "Rx Jabbers", CPSW_STAT(rxjabberframes) }, { "Undersize (Short) Rx Frames", CPSW_STAT(rxundersizedframes) }, { "Rx Fragments", CPSW_STAT(rxfragments) }, { "Rx Octets", CPSW_STAT(rxoctets) }, { "Good Tx Frames", CPSW_STAT(txgoodframes) }, { "Broadcast Tx Frames", CPSW_STAT(txbroadcastframes) }, { "Multicast Tx Frames", CPSW_STAT(txmulticastframes) }, { "Pause Tx Frames", CPSW_STAT(txpauseframes) }, { "Deferred Tx Frames", CPSW_STAT(txdeferredframes) }, { "Collisions", CPSW_STAT(txcollisionframes) }, { "Single Collision Tx Frames", CPSW_STAT(txsinglecollframes) }, { "Multiple Collision Tx Frames", CPSW_STAT(txmultcollframes) }, { "Excessive Collisions", CPSW_STAT(<API key>) }, { "Late Collisions", CPSW_STAT(txlatecollisions) }, { "Tx Underrun", CPSW_STAT(txunderrun) }, { "Carrier Sense Errors", CPSW_STAT(<API key>) }, { "Tx Octets", CPSW_STAT(txoctets) }, { "Rx + Tx 64 Octet Frames", CPSW_STAT(octetframes64) }, { "Rx + Tx 65-127 Octet Frames", CPSW_STAT(octetframes65t127) }, { "Rx + Tx 128-255 Octet Frames", CPSW_STAT(octetframes128t255) }, { "Rx + Tx 256-511 Octet Frames", CPSW_STAT(octetframes256t511) }, { "Rx + Tx 512-1023 Octet Frames", CPSW_STAT(octetframes512t1023) }, { "Rx + Tx 1024-Up Octet Frames", CPSW_STAT(octetframes1024tup) }, { "Net Octets", CPSW_STAT(netoctets) }, { "Rx Start of Frame Overruns", CPSW_STAT(rxsofoverruns) }, { "Rx Middle of Frame Overruns", CPSW_STAT(rxmofoverruns) }, { "Rx DMA Overruns", CPSW_STAT(rxdmaoverruns) }, { "Rx DMA chan: head_enqueue", CPDMA_RX_STAT(head_enqueue) }, { "Rx DMA chan: tail_enqueue", CPDMA_RX_STAT(tail_enqueue) }, { "Rx DMA chan: pad_enqueue", CPDMA_RX_STAT(pad_enqueue) }, { "Rx DMA chan: misqueued", CPDMA_RX_STAT(misqueued) }, { "Rx DMA chan: desc_alloc_fail", CPDMA_RX_STAT(desc_alloc_fail) }, { "Rx DMA chan: pad_alloc_fail", CPDMA_RX_STAT(pad_alloc_fail) }, { "Rx DMA chan: runt_receive_buf", CPDMA_RX_STAT(runt_receive_buff) }, { "Rx DMA chan: runt_transmit_buf", CPDMA_RX_STAT(runt_transmit_buff) }, { "Rx DMA chan: empty_dequeue", CPDMA_RX_STAT(empty_dequeue) }, { "Rx DMA chan: busy_dequeue", CPDMA_RX_STAT(busy_dequeue) }, { "Rx DMA chan: good_dequeue", CPDMA_RX_STAT(good_dequeue) }, { "Rx DMA chan: requeue", CPDMA_RX_STAT(requeue) }, { "Rx DMA chan: teardown_dequeue", CPDMA_RX_STAT(teardown_dequeue) }, { "Tx DMA chan: head_enqueue", CPDMA_TX_STAT(head_enqueue) }, { "Tx DMA chan: tail_enqueue", CPDMA_TX_STAT(tail_enqueue) }, { "Tx DMA chan: pad_enqueue", CPDMA_TX_STAT(pad_enqueue) }, { "Tx DMA chan: misqueued", CPDMA_TX_STAT(misqueued) }, { "Tx DMA chan: desc_alloc_fail", CPDMA_TX_STAT(desc_alloc_fail) }, { "Tx DMA chan: pad_alloc_fail", CPDMA_TX_STAT(pad_alloc_fail) }, { "Tx DMA chan: runt_receive_buf", CPDMA_TX_STAT(runt_receive_buff) }, { "Tx DMA chan: runt_transmit_buf", CPDMA_TX_STAT(runt_transmit_buff) }, { "Tx DMA chan: empty_dequeue", CPDMA_TX_STAT(empty_dequeue) }, { "Tx DMA chan: busy_dequeue", CPDMA_TX_STAT(busy_dequeue) }, { "Tx DMA chan: good_dequeue", CPDMA_TX_STAT(good_dequeue) }, { "Tx DMA chan: requeue", CPDMA_TX_STAT(requeue) }, { "Tx DMA chan: teardown_dequeue", CPDMA_TX_STAT(teardown_dequeue) }, }; #define CPSW_STATS_LEN ARRAY_SIZE(cpsw_gstrings_stats) #define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi) #define for_each_slave(priv, func, arg...) \ do { \ struct cpsw_slave *slave; \ int n; \ if (priv->data.dual_emac) \ (func)((priv)->slaves + priv->emac_port, ##arg);\ else \ for (n = (priv)->data.slaves, \ slave = (priv)->slaves; \ n; n (func)(slave++, ##arg); \ } while (0) #define cpsw_get_slave_ndev(priv, __slave_no__) \ (priv->slaves[__slave_no__].ndev) #define cpsw_get_slave_priv(priv, __slave_no__) \ ((priv->slaves[__slave_no__].ndev) ? \ netdev_priv(priv->slaves[__slave_no__].ndev) : NULL) \ #define <API key>(status, priv, ndev, skb) \ do { \ if (!priv->data.dual_emac) \ break; \ if (<API key>(status) == 1) { \ ndev = cpsw_get_slave_ndev(priv, 0); \ priv = netdev_priv(ndev); \ skb->dev = ndev; \ } else if (<API key>(status) == 2) { \ ndev = cpsw_get_slave_ndev(priv, 1); \ priv = netdev_priv(ndev); \ skb->dev = ndev; \ } \ } while (0) #define cpsw_add_mcast(priv, addr) \ do { \ if (priv->data.dual_emac) { \ struct cpsw_slave *slave = priv->slaves + \ priv->emac_port; \ int slave_port = cpsw_get_slave_port(priv, \ slave->slave_num); \ cpsw_ale_add_mcast(priv->ale, addr, \ 1 << slave_port | 1 << priv->host_port, \ ALE_VLAN, slave->port_vlan, 0); \ } else { \ cpsw_ale_add_mcast(priv->ale, addr, \ ALE_ALL_PORTS << priv->host_port, \ 0, 0, 0); \ } \ } while (0) static inline int cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num) { if (priv->host_port == 0) return slave_num + 1; else return slave_num; } static void <API key>(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); if (ndev->flags & IFF_PROMISC) { /* Enable promiscuous mode */ dev_err(priv->dev, "Ignoring Promiscuous mode\n"); return; } /* Clear all mcast from ALE */ <API key>(priv->ale, ALE_ALL_PORTS << priv->host_port); if (!netdev_mc_empty(ndev)) { struct netdev_hw_addr *ha; /* program multicast address list into ALE register */ <API key>(ha, ndev) { cpsw_add_mcast(priv, (u8 *)ha->addr); } } } static void cpsw_intr_enable(struct cpsw_priv *priv) { __raw_writel(0xFF, &priv->wr_regs->tx_en); __raw_writel(0xFF, &priv->wr_regs->rx_en); cpdma_ctlr_int_ctrl(priv->dma, true); return; } static void cpsw_intr_disable(struct cpsw_priv *priv) { __raw_writel(0, &priv->wr_regs->tx_en); __raw_writel(0, &priv->wr_regs->rx_en); cpdma_ctlr_int_ctrl(priv->dma, false); return; } void cpsw_tx_handler(void *token, int len, int status) { struct sk_buff *skb = token; struct net_device *ndev = skb->dev; struct cpsw_priv *priv = netdev_priv(ndev); /* Check whether the queue is stopped due to stalled tx dma, if the * queue is stopped then start the queue as we have free desc for tx */ if (unlikely(netif_queue_stopped(ndev))) netif_wake_queue(ndev); cpts_tx_timestamp(priv->cpts, skb); priv->stats.tx_packets++; priv->stats.tx_bytes += len; dev_kfree_skb_any(skb); } void cpsw_rx_handler(void *token, int len, int status) { struct sk_buff *skb = token; struct sk_buff *new_skb; struct net_device *ndev = skb->dev; struct cpsw_priv *priv = netdev_priv(ndev); int ret = 0; <API key>(status, priv, ndev, skb); if (unlikely(status < 0)) { /* the interface is going down, skbs are purged */ dev_kfree_skb_any(skb); return; } new_skb = <API key>(ndev, priv->rx_packet_max); if (new_skb) { skb_put(skb, len); cpts_rx_timestamp(priv->cpts, skb); skb->protocol = eth_type_trans(skb, ndev); netif_receive_skb(skb); priv->stats.rx_bytes += len; priv->stats.rx_packets++; } else { priv->stats.rx_dropped++; new_skb = skb; } ret = cpdma_chan_submit(priv->rxch, new_skb, new_skb->data, skb_tailroom(new_skb), 0); if (WARN_ON(ret < 0)) dev_kfree_skb_any(new_skb); } static irqreturn_t cpsw_interrupt(int irq, void *dev_id) { struct cpsw_priv *priv = dev_id; cpsw_intr_disable(priv); if (priv->irq_enabled == true) { cpsw_disable_irq(priv); priv->irq_enabled = false; } if (netif_running(priv->ndev)) { napi_schedule(&priv->napi); return IRQ_HANDLED; } priv = cpsw_get_slave_priv(priv, 1); if (!priv) return IRQ_NONE; if (netif_running(priv->ndev)) { napi_schedule(&priv->napi); return IRQ_HANDLED; } return IRQ_NONE; } static int cpsw_poll(struct napi_struct *napi, int budget) { struct cpsw_priv *priv = napi_to_priv(napi); int num_tx, num_rx; num_tx = cpdma_chan_process(priv->txch, 128); if (num_tx) cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX); num_rx = cpdma_chan_process(priv->rxch, budget); if (num_rx < budget) { struct cpsw_priv *prim_cpsw; napi_complete(napi); cpsw_intr_enable(priv); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX); prim_cpsw = cpsw_get_slave_priv(priv, 0); if (prim_cpsw->irq_enabled == false) { prim_cpsw->irq_enabled = true; cpsw_enable_irq(priv); } } if (num_rx || num_tx) cpsw_dbg(priv, intr, "poll %d rx, %d tx pkts\n", num_rx, num_tx); return num_rx; } static inline void soft_reset(const char *module, void __iomem *reg) { unsigned long timeout = jiffies + HZ; __raw_writel(1, reg); do { cpu_relax(); } while ((__raw_readl(reg) & 1) && time_after(timeout, jiffies)); WARN(__raw_readl(reg) & 1, "failed to soft-reset %s\n", module); } #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \ ((mac)[2] << 16) | ((mac)[3] << 24)) #define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8)) static void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv) { slave_write(slave, mac_hi(priv->mac_addr), SA_HI); slave_write(slave, mac_lo(priv->mac_addr), SA_LO); } static void _cpsw_adjust_link(struct cpsw_slave *slave, struct cpsw_priv *priv, bool *link) { struct phy_device *phy = slave->phy; u32 mac_control = 0; u32 slave_port; if (!phy) return; slave_port = cpsw_get_slave_port(priv, slave->slave_num); if (phy->link) { mac_control = priv->data.mac_control; /* enable forwarding */ <API key>(priv->ale, slave_port, ALE_PORT_STATE, <API key>); if (phy->speed == 1000) mac_control |= BIT(7); /* GIGABITEN */ if (phy->duplex) mac_control |= BIT(0); /* FULLDUPLEXEN */ /* set speed_in input in case RMII mode is used in 100Mbps */ if (phy->speed == 100) mac_control |= BIT(15); else if (phy->speed == 10) mac_control |= BIT(18); /* In Band mode */ *link = true; } else { mac_control = 0; /* disable forwarding */ <API key>(priv->ale, slave_port, ALE_PORT_STATE, <API key>); } if (mac_control != slave->mac_control) { phy_print_status(phy); __raw_writel(mac_control, &slave->sliver->mac_control); } slave->mac_control = mac_control; } static void cpsw_adjust_link(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); bool link = false; for_each_slave(priv, _cpsw_adjust_link, priv, &link); if (link) { netif_carrier_on(ndev); if (netif_running(ndev)) netif_wake_queue(ndev); } else { netif_carrier_off(ndev); netif_stop_queue(ndev); } } static int cpsw_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal) { struct cpsw_priv *priv = netdev_priv(ndev); coal->rx_coalesce_usecs = priv->coal_intvl; return 0; } static int cpsw_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal) { struct cpsw_priv *priv = netdev_priv(ndev); u32 int_ctrl; u32 num_interrupts = 0; u32 prescale = 0; u32 addnl_dvdr = 1; u32 coal_intvl = 0; if (!coal->rx_coalesce_usecs) return -EINVAL; coal_intvl = coal->rx_coalesce_usecs; int_ctrl = readl(&priv->wr_regs->int_control); prescale = priv->bus_freq_mhz * 4; if (coal_intvl < CPSW_CMINTMIN_INTVL) coal_intvl = CPSW_CMINTMIN_INTVL; if (coal_intvl > CPSW_CMINTMAX_INTVL) { /* Interrupt pacer works with 4us Pulse, we can * throttle further by dilating the 4us pulse. */ addnl_dvdr = <API key> / prescale; if (addnl_dvdr > 1) { prescale *= addnl_dvdr; if (coal_intvl > (CPSW_CMINTMAX_INTVL * addnl_dvdr)) coal_intvl = (CPSW_CMINTMAX_INTVL * addnl_dvdr); } else { addnl_dvdr = 1; coal_intvl = CPSW_CMINTMAX_INTVL; } } num_interrupts = (1000 * addnl_dvdr) / coal_intvl; writel(num_interrupts, &priv->wr_regs->rx_imax); writel(num_interrupts, &priv->wr_regs->tx_imax); int_ctrl |= CPSW_INTPACEEN; int_ctrl &= (~<API key>); int_ctrl |= (prescale & <API key>); writel(int_ctrl, &priv->wr_regs->int_control); cpsw_notice(priv, timer, "Set coalesce to %d usecs.\n", coal_intvl); if (priv->data.dual_emac) { int i; for (i = 0; i < priv->data.slaves; i++) { priv = netdev_priv(priv->slaves[i].ndev); priv->coal_intvl = coal_intvl; } } else { priv->coal_intvl = coal_intvl; } return 0; } static int cpsw_get_sset_count(struct net_device *ndev, int sset) { switch (sset) { case ETH_SS_STATS: return CPSW_STATS_LEN; default: return -EOPNOTSUPP; } } static void cpsw_get_strings(struct net_device *ndev, u32 stringset, u8 *data) { u8 *p = data; int i; switch (stringset) { case ETH_SS_STATS: for (i = 0; i < CPSW_STATS_LEN; i++) { memcpy(p, cpsw_gstrings_stats[i].stat_string, ETH_GSTRING_LEN); p += ETH_GSTRING_LEN; } break; } } static void <API key>(struct net_device *ndev, struct ethtool_stats *stats, u64 *data) { struct cpsw_priv *priv = netdev_priv(ndev); struct cpdma_chan_stats rx_stats; struct cpdma_chan_stats tx_stats; u32 val; u8 *p; int i; /* Collect Davinci CPDMA stats for Rx and Tx Channel */ <API key>(priv->rxch, &rx_stats); <API key>(priv->txch, &tx_stats); for (i = 0; i < CPSW_STATS_LEN; i++) { switch (cpsw_gstrings_stats[i].type) { case CPSW_STATS: val = readl(priv->hw_stats + cpsw_gstrings_stats[i].stat_offset); data[i] = val; break; case CPDMA_RX_STATS: p = (u8 *)&rx_stats + cpsw_gstrings_stats[i].stat_offset; data[i] = *(u32 *)p; break; case CPDMA_TX_STATS: p = (u8 *)&tx_stats + cpsw_gstrings_stats[i].stat_offset; data[i] = *(u32 *)p; break; } } } static inline int __show_stat(char *buf, int maxlen, const char *name, u32 val) { static char *leader = "........................................"; if (!val) return 0; else return snprintf(buf, maxlen, "%s %s %10d\n", name, leader + strlen(name), val); } static int <API key>(struct cpsw_priv *priv) { u32 i; u32 usage_count = 0; if (!priv->data.dual_emac) return 0; for (i = 0; i < priv->data.slaves; i++) if (priv->slaves[i].open_stat) usage_count++; return usage_count; } static inline int <API key>(struct net_device *ndev, struct cpsw_priv *priv, struct sk_buff *skb) { if (!priv->data.dual_emac) return cpdma_chan_submit(priv->txch, skb, skb->data, skb->len, 0); if (ndev == cpsw_get_slave_ndev(priv, 0)) return cpdma_chan_submit(priv->txch, skb, skb->data, skb->len, 1); else return cpdma_chan_submit(priv->txch, skb, skb->data, skb->len, 2); } static inline void <API key>( struct cpsw_priv *priv, struct cpsw_slave *slave, u32 slave_port) { u32 port_mask = 1 << slave_port | 1 << priv->host_port; if (priv->version == CPSW_VERSION_1) slave_write(slave, slave->port_vlan, CPSW1_PORT_VLAN); else slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN); cpsw_ale_add_vlan(priv->ale, slave->port_vlan, port_mask, port_mask, port_mask, 0); cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, port_mask, ALE_VLAN, slave->port_vlan, 0); cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, ALE_VLAN, slave->port_vlan); } static void soft_reset_slave(struct cpsw_slave *slave) { char name[32]; snprintf(name, sizeof(name), "slave-%d", slave->slave_num); soft_reset(name, &slave->sliver->soft_reset); } static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) { u32 slave_port; soft_reset_slave(slave); /* setup priority mapping */ __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); switch (priv->version) { case CPSW_VERSION_1: slave_write(slave, TX_PRIORITY_MAPPING, CPSW1_TX_PRI_MAP); break; case CPSW_VERSION_2: case CPSW_VERSION_3: case CPSW_VERSION_4: slave_write(slave, TX_PRIORITY_MAPPING, CPSW2_TX_PRI_MAP); break; } /* setup max packet size, and mac address */ __raw_writel(priv->rx_packet_max, &slave->sliver->rx_maxlen); cpsw_set_slave_mac(slave, priv); slave->mac_control = 0; /* no link yet */ slave_port = cpsw_get_slave_port(priv, slave->slave_num); if (priv->data.dual_emac) <API key>(priv, slave, slave_port); else cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); slave->phy = phy_connect(priv->ndev, slave->data->phy_id, &cpsw_adjust_link, slave->data->phy_if); if (IS_ERR(slave->phy)) { dev_err(priv->dev, "phy %s not found on slave %d\n", slave->data->phy_id, slave->slave_num); slave->phy = NULL; } else { dev_info(priv->dev, "phy found : id is : 0x%x\n", slave->phy->phy_id); phy_start(slave->phy); /* Configure GMII_SEL register */ cpsw_phy_sel(&priv->pdev->dev, slave->phy->interface, slave->slave_num); } } static inline void <API key>(struct cpsw_priv *priv) { const int vlan = priv->data.default_vlan; const int port = priv->host_port; u32 reg; int i; reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : CPSW2_PORT_VLAN; writel(vlan, &priv->host_port_regs->port_vlan); for (i = 0; i < priv->data.slaves; i++) slave_write(priv->slaves + i, vlan, reg); cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port, ALE_ALL_PORTS << port, ALE_ALL_PORTS << port, (ALE_PORT_1 | ALE_PORT_2) << port); } static void cpsw_init_host_port(struct cpsw_priv *priv) { u32 control_reg; u32 fifo_mode; /* soft reset the controller and initialize ale */ soft_reset("cpsw", &priv->regs->soft_reset); cpsw_ale_start(priv->ale); /* switch to vlan unaware mode */ <API key>(priv->ale, priv->host_port, ALE_VLAN_AWARE, CPSW_ALE_VLAN_AWARE); control_reg = readl(&priv->regs->control); control_reg |= CPSW_VLAN_AWARE; writel(control_reg, &priv->regs->control); fifo_mode = (priv->data.dual_emac) ? <API key> : <API key>; writel(fifo_mode, &priv->host_port_regs->tx_in_ctl); /* setup host port priority mapping */ __raw_writel(<API key>, &priv->host_port_regs->cpdma_tx_pri_map); __raw_writel(0, &priv->host_port_regs->cpdma_rx_chan_map); <API key>(priv->ale, priv->host_port, ALE_PORT_STATE, <API key>); if (!priv->data.dual_emac) { cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, 0, 0); cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1 << priv->host_port, 0, 0, ALE_MCAST_FWD_2); } } static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv) { if (!slave->phy) return; phy_stop(slave->phy); phy_disconnect(slave->phy); slave->phy = NULL; } static int cpsw_ndo_open(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_priv *prim_cpsw; int i, ret; u32 reg; if (!<API key>(priv)) cpsw_intr_disable(priv); netif_carrier_off(ndev); pm_runtime_get_sync(&priv->pdev->dev); reg = priv->version; dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n", CPSW_MAJOR_VERSION(reg), CPSW_MINOR_VERSION(reg), CPSW_RTL_VERSION(reg)); /* initialize host and slave ports */ if (!<API key>(priv)) cpsw_init_host_port(priv); for_each_slave(priv, cpsw_slave_open, priv); /* Add default VLAN */ if (!priv->data.dual_emac) <API key>(priv); if (!<API key>(priv)) { /* setup tx dma to fixed prio and zero offset */ cpdma_control_set(priv->dma, CPDMA_TX_PRIO_FIXED, 1); cpdma_control_set(priv->dma, <API key>, 0); /* disable priority elevation */ __raw_writel(0, &priv->regs->ptype); /* enable statistics collection only on all ports */ __raw_writel(0x7, &priv->regs->stat_port_en); if (WARN_ON(!priv->data.rx_descs)) priv->data.rx_descs = 128; for (i = 0; i < priv->data.rx_descs; i++) { struct sk_buff *skb; ret = -ENOMEM; skb = <API key>(priv->ndev, priv->rx_packet_max, GFP_KERNEL); if (!skb) goto err_cleanup; ret = cpdma_chan_submit(priv->rxch, skb, skb->data, skb_tailroom(skb), 0); if (ret < 0) { kfree_skb(skb); goto err_cleanup; } } /* continue even if we didn't manage to submit all * receive descs */ cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); if (cpts_register(&priv->pdev->dev, priv->cpts, priv->data.cpts_clock_mult, priv->data.cpts_clock_shift)) dev_err(priv->dev, "error registering cpts device\n"); } /* Enable Interrupt pacing if configured */ if (priv->coal_intvl != 0) { struct ethtool_coalesce coal; coal.rx_coalesce_usecs = (priv->coal_intvl << 4); cpsw_set_coalesce(ndev, &coal); } prim_cpsw = cpsw_get_slave_priv(priv, 0); if (prim_cpsw->irq_enabled == false) { if ((priv == prim_cpsw) || !netif_running(prim_cpsw->ndev)) { prim_cpsw->irq_enabled = true; cpsw_enable_irq(prim_cpsw); } } napi_enable(&priv->napi); cpdma_ctlr_start(priv->dma); cpsw_intr_enable(priv); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX); if (priv->data.dual_emac) priv->slaves[priv->emac_port].open_stat = true; return 0; err_cleanup: cpdma_ctlr_stop(priv->dma); for_each_slave(priv, cpsw_slave_stop, priv); pm_runtime_put_sync(&priv->pdev->dev); netif_carrier_off(priv->ndev); return ret; } static int cpsw_ndo_stop(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); cpsw_info(priv, ifdown, "shutting down cpsw device\n"); netif_stop_queue(priv->ndev); napi_disable(&priv->napi); netif_carrier_off(priv->ndev); if (<API key>(priv) <= 1) { cpts_unregister(priv->cpts); cpsw_intr_disable(priv); cpdma_ctlr_int_ctrl(priv->dma, false); cpdma_ctlr_stop(priv->dma); cpsw_ale_stop(priv->ale); } for_each_slave(priv, cpsw_slave_stop, priv); pm_runtime_put_sync(&priv->pdev->dev); if (priv->data.dual_emac) priv->slaves[priv->emac_port].open_stat = false; return 0; } static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); int ret; ndev->trans_start = jiffies; if (skb_padto(skb, <API key>)) { cpsw_err(priv, tx_err, "packet pad failed\n"); priv->stats.tx_dropped++; return NETDEV_TX_OK; } if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && priv->cpts->tx_enable) skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; skb_tx_timestamp(skb); ret = <API key>(ndev, priv, skb); if (unlikely(ret != 0)) { cpsw_err(priv, tx_err, "desc submit failed\n"); goto fail; } /* If there is no more tx desc left free then we need to * tell the kernel to stop sending us tx frames. */ if (unlikely(!<API key>(priv->txch))) netif_stop_queue(ndev); return NETDEV_TX_OK; fail: priv->stats.tx_dropped++; netif_stop_queue(ndev); return NETDEV_TX_BUSY; } static void <API key>(struct net_device *ndev, int flags) { /* * The switch cannot operate in promiscuous mode without substantial * headache. For promiscuous mode to work, we would need to put the * ALE in bypass mode and route all traffic to the host port. * Subsequently, the host will need to operate as a "bridge", learn, * and flood as needed. For now, we simply complain here and * do nothing about it :-) */ if ((flags & IFF_PROMISC) && (ndev->flags & IFF_PROMISC)) dev_err(&ndev->dev, "promiscuity ignored!\n"); /* * The switch cannot filter multicast traffic unless it is configured * in "VLAN Aware" mode. Unfortunately, VLAN awareness requires a * whole bunch of additional logic that this driver does not implement * at present. */ if ((flags & IFF_ALLMULTI) && !(ndev->flags & IFF_ALLMULTI)) dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n"); } #ifdef CONFIG_TI_CPTS static void cpsw_hwtstamp_v1(struct cpsw_priv *priv) { struct cpsw_slave *slave = &priv->slaves[priv->data.active_slave]; u32 ts_en, seq_id; if (!priv->cpts->tx_enable && !priv->cpts->rx_enable) { slave_write(slave, 0, CPSW1_TS_CTL); return; } seq_id = (30 << <API key>) | ETH_P_1588; ts_en = EVENT_MSG_BITS << <API key>; if (priv->cpts->tx_enable) ts_en |= CPSW_V1_TS_TX_EN; if (priv->cpts->rx_enable) ts_en |= CPSW_V1_TS_RX_EN; slave_write(slave, ts_en, CPSW1_TS_CTL); slave_write(slave, seq_id, CPSW1_TS_SEQ_LTYPE); } static void cpsw_hwtstamp_v2(struct cpsw_priv *priv) { struct cpsw_slave *slave; u32 ctrl, mtype; if (priv->data.dual_emac) slave = &priv->slaves[priv->emac_port]; else slave = &priv->slaves[priv->data.active_slave]; ctrl = slave_read(slave, CPSW2_CONTROL); ctrl &= ~CTRL_ALL_TS_MASK; if (priv->cpts->tx_enable) ctrl |= CTRL_TX_TS_BITS; if (priv->cpts->rx_enable) ctrl |= CTRL_RX_TS_BITS; mtype = (30 << <API key>) | EVENT_MSG_BITS; slave_write(slave, mtype, CPSW2_TS_SEQ_MTYPE); slave_write(slave, ctrl, CPSW2_CONTROL); __raw_writel(ETH_P_1588, &priv->regs->ts_ltype); } static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) { struct cpsw_priv *priv = netdev_priv(dev); struct cpts *cpts = priv->cpts; struct hwtstamp_config cfg; if (priv->version != CPSW_VERSION_1 && priv->version != CPSW_VERSION_2) return -EOPNOTSUPP; if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) return -EFAULT; /* reserved for future extensions */ if (cfg.flags) return -EINVAL; if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON) return -ERANGE; switch (cfg.rx_filter) { case <API key>: cpts->rx_enable = 0; break; case HWTSTAMP_FILTER_ALL: case <API key>: case <API key>: case <API key>: return -ERANGE; case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: cpts->rx_enable = 1; cfg.rx_filter = <API key>; break; default: return -ERANGE; } cpts->tx_enable = cfg.tx_type == HWTSTAMP_TX_ON; switch (priv->version) { case CPSW_VERSION_1: cpsw_hwtstamp_v1(priv); break; case CPSW_VERSION_2: cpsw_hwtstamp_v2(priv); break; default: WARN_ON(1); } return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; } #endif /*CONFIG_TI_CPTS*/ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) { struct cpsw_priv *priv = netdev_priv(dev); struct mii_ioctl_data *data = if_mii(req); int slave_no = cpsw_slave_index(priv); if (!netif_running(dev)) return -EINVAL; switch (cmd) { #ifdef CONFIG_TI_CPTS case SIOCSHWTSTAMP: return cpsw_hwtstamp_ioctl(dev, req); #endif case SIOCGMIIPHY: data->phy_id = priv->slaves[slave_no].phy->addr; break; default: return -ENOTSUPP; } return 0; } static void cpsw_ndo_tx_timeout(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); cpsw_err(priv, tx_err, "transmit timeout, restarting dma\n"); priv->stats.tx_errors++; cpsw_intr_disable(priv); cpdma_ctlr_int_ctrl(priv->dma, false); cpdma_chan_stop(priv->txch); cpdma_chan_start(priv->txch); cpdma_ctlr_int_ctrl(priv->dma, true); cpsw_intr_enable(priv); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX); } static int <API key>(struct net_device *ndev, void *p) { struct cpsw_priv *priv = netdev_priv(ndev); struct sockaddr *addr = (struct sockaddr *)p; int flags = 0; u16 vid = 0; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; if (priv->data.dual_emac) { vid = priv->slaves[priv->emac_port].port_vlan; flags = ALE_VLAN; } cpsw_ale_del_ucast(priv->ale, priv->mac_addr, priv->host_port, flags, vid); cpsw_ale_add_ucast(priv->ale, addr->sa_data, priv->host_port, flags, vid); memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); for_each_slave(priv, cpsw_set_slave_mac, priv); return 0; } static struct net_device_stats *cpsw_ndo_get_stats(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); return &priv->stats; } #ifdef <API key> static void <API key>(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); cpsw_intr_disable(priv); cpdma_ctlr_int_ctrl(priv->dma, false); cpsw_interrupt(ndev->irq, priv); cpdma_ctlr_int_ctrl(priv->dma, true); cpsw_intr_enable(priv); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX); cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX); } #endif static inline int <API key>(struct cpsw_priv *priv, unsigned short vid) { int ret; ret = cpsw_ale_add_vlan(priv->ale, vid, ALE_ALL_PORTS << priv->host_port, 0, ALE_ALL_PORTS << priv->host_port, (ALE_PORT_1 | ALE_PORT_2) << priv->host_port); if (ret != 0) return ret; ret = cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, ALE_VLAN, vid); if (ret != 0) goto clean_vid; ret = cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, ALE_ALL_PORTS << priv->host_port, ALE_VLAN, vid, 0); if (ret != 0) goto clean_vlan_ucast; return 0; clean_vlan_ucast: cpsw_ale_del_ucast(priv->ale, priv->mac_addr, priv->host_port, ALE_VLAN, vid); clean_vid: cpsw_ale_del_vlan(priv->ale, vid, 0); return ret; } static int <API key>(struct net_device *ndev, __be16 proto, u16 vid) { struct cpsw_priv *priv = netdev_priv(ndev); if (vid == priv->data.default_vlan) return 0; dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid); return <API key>(priv, vid); } static int <API key>(struct net_device *ndev, __be16 proto, u16 vid) { struct cpsw_priv *priv = netdev_priv(ndev); int ret; if (vid == priv->data.default_vlan) return 0; dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid); ret = cpsw_ale_del_vlan(priv->ale, vid, 0); if (ret != 0) return ret; ret = cpsw_ale_del_ucast(priv->ale, priv->mac_addr, priv->host_port, ALE_VLAN, vid); if (ret != 0) return ret; return cpsw_ale_del_mcast(priv->ale, priv->ndev->broadcast, 0, ALE_VLAN, vid); } static const struct net_device_ops cpsw_netdev_ops = { .ndo_open = cpsw_ndo_open, .ndo_stop = cpsw_ndo_stop, .ndo_start_xmit = cpsw_ndo_start_xmit, .ndo_change_rx_flags = <API key>, .ndo_set_mac_address = <API key>, .ndo_do_ioctl = cpsw_ndo_ioctl, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu, .ndo_tx_timeout = cpsw_ndo_tx_timeout, .ndo_get_stats = cpsw_ndo_get_stats, .ndo_set_rx_mode = <API key>, #ifdef <API key> .ndo_poll_controller = <API key>, #endif .ndo_vlan_rx_add_vid = <API key>, .<API key> = <API key>, }; static void cpsw_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { struct cpsw_priv *priv = netdev_priv(ndev); strlcpy(info->driver, "TI CPSW Driver v1.0", sizeof(info->driver)); strlcpy(info->version, "1.0", sizeof(info->version)); strlcpy(info->bus_info, priv->pdev->name, sizeof(info->bus_info)); } static u32 cpsw_get_msglevel(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); return priv->msg_enable; } static void cpsw_set_msglevel(struct net_device *ndev, u32 value) { struct cpsw_priv *priv = netdev_priv(ndev); priv->msg_enable = value; } static int cpsw_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info) { #ifdef CONFIG_TI_CPTS struct cpsw_priv *priv = netdev_priv(ndev); info->so_timestamping = <API key> | <API key> | <API key> | <API key> | <API key> | <API key>; info->phc_index = priv->cpts->phc_index; info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); info->rx_filters = (1 << <API key>) | (1 << <API key>); #else info->so_timestamping = <API key> | <API key> | <API key>; info->phc_index = -1; info->tx_types = 0; info->rx_filters = 0; #endif return 0; } static int cpsw_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct cpsw_priv *priv = netdev_priv(ndev); int slave_no = cpsw_slave_index(priv); if (priv->slaves[slave_no].phy) return phy_ethtool_gset(priv->slaves[slave_no].phy, ecmd); else return -EOPNOTSUPP; } static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct cpsw_priv *priv = netdev_priv(ndev); int slave_no = cpsw_slave_index(priv); if (priv->slaves[slave_no].phy) return phy_ethtool_sset(priv->slaves[slave_no].phy, ecmd); else return -EOPNOTSUPP; } static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) { struct cpsw_priv *priv = netdev_priv(ndev); int slave_no = cpsw_slave_index(priv); wol->supported = 0; wol->wolopts = 0; if (priv->slaves[slave_no].phy) phy_ethtool_get_wol(priv->slaves[slave_no].phy, wol); } static int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) { struct cpsw_priv *priv = netdev_priv(ndev); int slave_no = cpsw_slave_index(priv); if (priv->slaves[slave_no].phy) return phy_ethtool_set_wol(priv->slaves[slave_no].phy, wol); else return -EOPNOTSUPP; } static const struct ethtool_ops cpsw_ethtool_ops = { .get_drvinfo = cpsw_get_drvinfo, .get_msglevel = cpsw_get_msglevel, .set_msglevel = cpsw_set_msglevel, .get_link = ethtool_op_get_link, .get_ts_info = cpsw_get_ts_info, .get_settings = cpsw_get_settings, .set_settings = cpsw_set_settings, .get_coalesce = cpsw_get_coalesce, .set_coalesce = cpsw_set_coalesce, .get_sset_count = cpsw_get_sset_count, .get_strings = cpsw_get_strings, .get_ethtool_stats = <API key>, .get_wol = cpsw_get_wol, .set_wol = cpsw_set_wol, }; static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, u32 slave_reg_ofs, u32 sliver_reg_ofs) { void __iomem *regs = priv->regs; int slave_num = slave->slave_num; struct cpsw_slave_data *data = priv->data.slave_data + slave_num; slave->data = data; slave->regs = regs + slave_reg_ofs; slave->sliver = regs + sliver_reg_ofs; slave->port_vlan = data->dual_emac_res_vlan; } static int cpsw_probe_dt(struct cpsw_platform_data *data, struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct device_node *slave_node; int i = 0, ret; u32 prop; if (!node) return -EINVAL; if (<API key>(node, "slaves", &prop)) { pr_err("Missing slaves property in the DT.\n"); return -EINVAL; } data->slaves = prop; if (<API key>(node, "active_slave", &prop)) { pr_err("Missing active_slave property in the DT.\n"); return -EINVAL; } data->active_slave = prop; if (<API key>(node, "cpts_clock_mult", &prop)) { pr_err("Missing cpts_clock_mult property in the DT.\n"); return -EINVAL; } data->cpts_clock_mult = prop; if (<API key>(node, "cpts_clock_shift", &prop)) { pr_err("Missing cpts_clock_shift property in the DT.\n"); return -EINVAL; } data->cpts_clock_shift = prop; data->slave_data = devm_kzalloc(&pdev->dev, data->slaves * sizeof(struct cpsw_slave_data), GFP_KERNEL); if (!data->slave_data) return -ENOMEM; if (<API key>(node, "cpdma_channels", &prop)) { pr_err("Missing cpdma_channels property in the DT.\n"); return -EINVAL; } data->channels = prop; if (<API key>(node, "ale_entries", &prop)) { pr_err("Missing ale_entries property in the DT.\n"); return -EINVAL; } data->ale_entries = prop; if (<API key>(node, "bd_ram_size", &prop)) { pr_err("Missing bd_ram_size property in the DT.\n"); return -EINVAL; } data->bd_ram_size = prop; if (<API key>(node, "rx_descs", &prop)) { pr_err("Missing rx_descs property in the DT.\n"); return -EINVAL; } data->rx_descs = prop; if (<API key>(node, "mac_control", &prop)) { pr_err("Missing mac_control property in the DT.\n"); return -EINVAL; } data->mac_control = prop; if (<API key>(node, "dual_emac")) data->dual_emac = 1; /* * Populate all the child nodes here... */ ret = <API key>(node, NULL, NULL, &pdev->dev); /* We do not want to force this, as in some cases may not have child */ if (ret) pr_warn("Doesn't have any child node\n"); <API key>(node, slave_node) { struct cpsw_slave_data *slave_data = data->slave_data + i; const void *mac_addr = NULL; u32 phyid; int lenp; const __be32 *parp; struct device_node *mdio_node; struct platform_device *mdio; /* This is no slave child node, continue */ if (strcmp(slave_node->name, "slave")) continue; parp = of_get_property(slave_node, "phy_id", &lenp); if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { pr_err("Missing slave[%d] phy_id property\n", i); return -EINVAL; } mdio_node = <API key>(be32_to_cpup(parp)); phyid = be32_to_cpup(parp+1); mdio = <API key>(mdio_node); snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), PHY_ID_FMT, mdio->name, phyid); mac_addr = of_get_mac_address(slave_node); if (mac_addr) memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); slave_data->phy_if = of_get_phy_mode(slave_node); if (data->dual_emac) { if (<API key>(slave_node, "dual_emac_res_vlan", &prop)) { pr_err("Missing dual_emac_res_vlan in DT.\n"); slave_data->dual_emac_res_vlan = i+1; pr_err("Using %d as Reserved VLAN for %d slave\n", slave_data->dual_emac_res_vlan, i); } else { slave_data->dual_emac_res_vlan = prop; } } i++; if (i == data->slaves) break; } return 0; } static int <API key>(struct platform_device *pdev, struct cpsw_priv *priv) { struct cpsw_platform_data *data = &priv->data; struct net_device *ndev; struct cpsw_priv *priv_sl2; int ret = 0, i; ndev = alloc_etherdev(sizeof(struct cpsw_priv)); if (!ndev) { pr_err("cpsw: error allocating net_device\n"); return -ENOMEM; } priv_sl2 = netdev_priv(ndev); spin_lock_init(&priv_sl2->lock); priv_sl2->data = *data; priv_sl2->pdev = pdev; priv_sl2->ndev = ndev; priv_sl2->dev = &ndev->dev; priv_sl2->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); priv_sl2->rx_packet_max = max(rx_packet_max, 128); if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, ETH_ALEN); pr_info("cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr); } else { random_ether_addr(priv_sl2->mac_addr); pr_info("cpsw: Random MACID = %pM\n", priv_sl2->mac_addr); } memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); priv_sl2->slaves = priv->slaves; priv_sl2->clk = priv->clk; priv_sl2->coal_intvl = 0; priv_sl2->bus_freq_mhz = priv->bus_freq_mhz; priv_sl2->regs = priv->regs; priv_sl2->host_port = priv->host_port; priv_sl2->host_port_regs = priv->host_port_regs; priv_sl2->wr_regs = priv->wr_regs; priv_sl2->hw_stats = priv->hw_stats; priv_sl2->dma = priv->dma; priv_sl2->txch = priv->txch; priv_sl2->rxch = priv->rxch; priv_sl2->ale = priv->ale; priv_sl2->emac_port = 1; priv->slaves[1].ndev = ndev; priv_sl2->cpts = priv->cpts; priv_sl2->version = priv->version; for (i = 0; i < priv->num_irqs; i++) { priv_sl2->irqs_table[i] = priv->irqs_table[i]; priv_sl2->num_irqs = priv->num_irqs; } ndev->features |= <API key>; ndev->netdev_ops = &cpsw_netdev_ops; SET_ETHTOOL_OPS(ndev, &cpsw_ethtool_ops); netif_napi_add(ndev, &priv_sl2->napi, cpsw_poll, CPSW_POLL_WEIGHT); /* register the network device */ SET_NETDEV_DEV(ndev, &pdev->dev); ret = register_netdev(ndev); if (ret) { pr_err("cpsw: error registering net device\n"); free_netdev(ndev); ret = -ENODEV; } return ret; } static int cpsw_probe(struct platform_device *pdev) { struct cpsw_platform_data *data; struct net_device *ndev; struct cpsw_priv *priv; struct cpdma_params dma_params; struct cpsw_ale_params ale_params; void __iomem *ss_regs; struct resource *res, *ss_res; u32 slave_offset, sliver_offset, slave_size; int ret = 0, i, k = 0; ndev = alloc_etherdev(sizeof(struct cpsw_priv)); if (!ndev) { pr_err("error allocating net_device\n"); return -ENOMEM; } <API key>(pdev, ndev); priv = netdev_priv(ndev); spin_lock_init(&priv->lock); priv->pdev = pdev; priv->ndev = ndev; priv->dev = &ndev->dev; priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); priv->rx_packet_max = max(rx_packet_max, 128); priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL); priv->irq_enabled = true; if (!priv->cpts) { pr_err("error allocating cpts\n"); goto clean_ndev_ret; } /* * This may be required here for child devices. */ pm_runtime_enable(&pdev->dev); /* Select default pin state */ <API key>(&pdev->dev); if (cpsw_probe_dt(&priv->data, pdev)) { pr_err("cpsw: platform data missing\n"); ret = -ENODEV; goto <API key>; } data = &priv->data; if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN); pr_info("Detected MACID = %pM\n", priv->mac_addr); } else { eth_random_addr(priv->mac_addr); pr_info("Random MACID = %pM\n", priv->mac_addr); } memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); priv->slaves = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_slave) * data->slaves, GFP_KERNEL); if (!priv->slaves) { ret = -ENOMEM; goto <API key>; } for (i = 0; i < data->slaves; i++) priv->slaves[i].slave_num = i; priv->slaves[0].ndev = ndev; priv->emac_port = 0; priv->clk = devm_clk_get(&pdev->dev, "fck"); if (IS_ERR(priv->clk)) { dev_err(priv->dev, "fck is not found\n"); ret = -ENODEV; goto <API key>; } priv->coal_intvl = 0; priv->bus_freq_mhz = clk_get_rate(priv->clk) / 1000000; ss_res = <API key>(pdev, IORESOURCE_MEM, 0); ss_regs = <API key>(&pdev->dev, ss_res); if (IS_ERR(ss_regs)) { ret = PTR_ERR(ss_regs); goto <API key>; } priv->regs = ss_regs; priv->host_port = HOST_PORT_NUM; /* Need to enable clocks with runtime PM api to access module * registers */ pm_runtime_get_sync(&pdev->dev); priv->version = readl(&priv->regs->id_ver); pm_runtime_put_sync(&pdev->dev); res = <API key>(pdev, IORESOURCE_MEM, 1); priv->wr_regs = <API key>(&pdev->dev, res); if (IS_ERR(priv->wr_regs)) { ret = PTR_ERR(priv->wr_regs); goto <API key>; } memset(&dma_params, 0, sizeof(dma_params)); memset(&ale_params, 0, sizeof(ale_params)); switch (priv->version) { case CPSW_VERSION_1: priv->host_port_regs = ss_regs + <API key>; priv->cpts->reg = ss_regs + CPSW1_CPTS_OFFSET; priv->hw_stats = ss_regs + CPSW1_HW_STATS; dma_params.dmaregs = ss_regs + CPSW1_CPDMA_OFFSET; dma_params.txhdp = ss_regs + <API key>; ale_params.ale_regs = ss_regs + CPSW1_ALE_OFFSET; slave_offset = CPSW1_SLAVE_OFFSET; slave_size = CPSW1_SLAVE_SIZE; sliver_offset = CPSW1_SLIVER_OFFSET; dma_params.desc_mem_phys = 0; break; case CPSW_VERSION_2: case CPSW_VERSION_3: case CPSW_VERSION_4: priv->host_port_regs = ss_regs + <API key>; priv->cpts->reg = ss_regs + CPSW2_CPTS_OFFSET; priv->hw_stats = ss_regs + CPSW2_HW_STATS; dma_params.dmaregs = ss_regs + CPSW2_CPDMA_OFFSET; dma_params.txhdp = ss_regs + <API key>; ale_params.ale_regs = ss_regs + CPSW2_ALE_OFFSET; slave_offset = CPSW2_SLAVE_OFFSET; slave_size = CPSW2_SLAVE_SIZE; sliver_offset = CPSW2_SLIVER_OFFSET; dma_params.desc_mem_phys = (u32 __force) ss_res->start + CPSW2_BD_OFFSET; break; default: dev_err(priv->dev, "unknown version 0x%08x\n", priv->version); ret = -ENODEV; goto <API key>; } for (i = 0; i < priv->data.slaves; i++) { struct cpsw_slave *slave = &priv->slaves[i]; cpsw_slave_init(slave, priv, slave_offset, sliver_offset); slave_offset += slave_size; sliver_offset += SLIVER_SIZE; } dma_params.dev = &pdev->dev; dma_params.rxthresh = dma_params.dmaregs + CPDMA_RXTHRESH; dma_params.rxfree = dma_params.dmaregs + CPDMA_RXFREE; dma_params.rxhdp = dma_params.txhdp + CPDMA_RXHDP; dma_params.txcp = dma_params.txhdp + CPDMA_TXCP; dma_params.rxcp = dma_params.txhdp + CPDMA_RXCP; dma_params.num_chan = data->channels; dma_params.has_soft_reset = true; dma_params.min_packet_size = <API key>; dma_params.desc_mem_size = data->bd_ram_size; dma_params.desc_align = 16; dma_params.has_ext_regs = true; dma_params.desc_hw_addr = dma_params.desc_mem_phys; priv->dma = cpdma_ctlr_create(&dma_params); if (!priv->dma) { dev_err(priv->dev, "error initializing dma\n"); ret = -ENOMEM; goto <API key>; } priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0), cpsw_tx_handler); priv->rxch = cpdma_chan_create(priv->dma, rx_chan_num(0), cpsw_rx_handler); if (WARN_ON(!priv->txch || !priv->rxch)) { dev_err(priv->dev, "error initializing dma channels\n"); ret = -ENOMEM; goto clean_dma_ret; } ale_params.dev = &ndev->dev; ale_params.ale_ageout = ale_ageout; ale_params.ale_entries = data->ale_entries; ale_params.ale_ports = data->slaves; priv->ale = cpsw_ale_create(&ale_params); if (!priv->ale) { dev_err(priv->dev, "error initializing ale engine\n"); ret = -ENODEV; goto clean_dma_ret; } ndev->irq = platform_get_irq(pdev, 0); if (ndev->irq < 0) { dev_err(priv->dev, "error getting irq resource\n"); ret = -ENOENT; goto clean_ale_ret; } while ((res = <API key>(priv->pdev, IORESOURCE_IRQ, k))) { for (i = res->start; i <= res->end; i++) { if (devm_request_irq(&pdev->dev, i, cpsw_interrupt, 0, dev_name(&pdev->dev), priv)) { dev_err(priv->dev, "error attaching irq\n"); goto clean_ale_ret; } priv->irqs_table[k] = i; priv->num_irqs = k + 1; } k++; } ndev->features |= <API key>; ndev->netdev_ops = &cpsw_netdev_ops; SET_ETHTOOL_OPS(ndev, &cpsw_ethtool_ops); netif_napi_add(ndev, &priv->napi, cpsw_poll, CPSW_POLL_WEIGHT); /* register the network device */ SET_NETDEV_DEV(ndev, &pdev->dev); ret = register_netdev(ndev); if (ret) { dev_err(priv->dev, "error registering net device\n"); ret = -ENODEV; goto clean_ale_ret; } if (cpts_register(&pdev->dev, priv->cpts, data->cpts_clock_mult, data->cpts_clock_shift)) dev_err(priv->dev, "error registering cpts device\n"); cpsw_notice(priv, probe, "initialized device (regs %x, irq %d)\n", ss_res->start, ndev->irq); if (priv->data.dual_emac) { ret = <API key>(pdev, priv); if (ret) { cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); goto clean_ale_ret; } } return 0; clean_ale_ret: cpsw_ale_destroy(priv->ale); clean_dma_ret: cpdma_chan_destroy(priv->txch); cpdma_chan_destroy(priv->rxch); cpdma_ctlr_destroy(priv->dma); <API key>: pm_runtime_disable(&pdev->dev); clean_ndev_ret: free_netdev(priv->ndev); return ret; } static int cpsw_remove(struct platform_device *pdev) { struct net_device *ndev = <API key>(pdev); struct cpsw_priv *priv = netdev_priv(ndev); if (priv->data.dual_emac) unregister_netdev(cpsw_get_slave_ndev(priv, 1)); unregister_netdev(ndev); cpsw_ale_destroy(priv->ale); cpdma_chan_destroy(priv->txch); cpdma_chan_destroy(priv->rxch); cpdma_ctlr_destroy(priv->dma); pm_runtime_disable(&pdev->dev); if (priv->data.dual_emac) free_netdev(cpsw_get_slave_ndev(priv, 1)); free_netdev(ndev); return 0; } static int cpsw_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct net_device *ndev = <API key>(pdev); struct cpsw_priv *priv = netdev_priv(ndev); if (netif_running(ndev)) cpsw_ndo_stop(ndev); for_each_slave(priv, soft_reset_slave); pm_runtime_put_sync(&pdev->dev); /* Select sleep pin state */ <API key>(&pdev->dev); return 0; } static int cpsw_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct net_device *ndev = <API key>(pdev); pm_runtime_get_sync(&pdev->dev); /* Select default pin state */ <API key>(&pdev->dev); if (netif_running(ndev)) cpsw_ndo_open(ndev); return 0; } static const struct dev_pm_ops cpsw_pm_ops = { .suspend = cpsw_suspend, .resume = cpsw_resume, }; static const struct of_device_id cpsw_of_mtable[] = { { .compatible = "ti,cpsw", }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, cpsw_of_mtable); static struct platform_driver cpsw_driver = { .driver = { .name = "cpsw", .owner = THIS_MODULE, .pm = &cpsw_pm_ops, .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, .remove = cpsw_remove, }; static int __init cpsw_init(void) { return <API key>(&cpsw_driver); } late_initcall(cpsw_init); static void __exit cpsw_exit(void) { <API key>(&cpsw_driver); } module_exit(cpsw_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Cyril Chemparathy <cyril@ti.com>"); MODULE_AUTHOR("Mugunthan V N <mugunthanvnm@ti.com>"); MODULE_DESCRIPTION("TI CPSW Ethernet driver");
#!/bin/bash THREAD_FACTOR=2 . $(dirname $0)/config/common_run.sh fw_depends $DBTYPE rvm jruby-9.1 rvm use jruby-$JRUBY_VERSION . $(dirname $0)/config/bundle_install.sh bundle exec torquebox run --io-threads $(( MAX_CONCURRENCY / 2 )) --worker-threads $MAX_CONCURRENCY -b 0.0.0.0 -p 8080 -e production &
import type { ITrail } from "../../Interfaces/Particles/ITrail"; import type { RecursivePartial } from "../../../Types/RecursivePartial"; import { OptionsColor } from "../OptionsColor"; export declare class Trail implements ITrail { enable: boolean; length: number; fillColor: OptionsColor; constructor(); load(data?: RecursivePartial<ITrail>): void; }
#include <linux/kernel.h> #include <linux/module.h> #include <linux/bcd.h> #include <linux/delay.h> #include <linux/mfd/core.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/pdata.h> #include <linux/mfd/wm831x/irq.h> #include <linux/mfd/wm831x/auxadc.h> #include <linux/mfd/wm831x/otp.h> #include <linux/mfd/wm831x/pmu.h> #include <linux/mfd/wm831x/regulator.h> /* Current settings - values are 2*2^(reg_val/4) microamps. These are * exported since they are used by multiple drivers. */ int <API key>[<API key> + 1] = { 2, 2, 3, 3, 4, 5, 6, 7, 8, 10, 11, 13, 16, 19, 23, 27, 32, 38, 45, 54, 64, 76, 91, 108, 128, 152, 181, 215, 256, 304, 362, 431, 512, 609, 724, 861, 1024, 1218, 1448, 1722, 2048, 2435, 2896, 3444, 4096, 4871, 5793, 6889, 8192, 9742, 11585, 13777, 16384, 19484, 23170, 27554, }; EXPORT_SYMBOL_GPL(<API key>); static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg) { if (!wm831x->locked) return 0; switch (reg) { case WM831X_WATCHDOG: case WM831X_DC4_CONTROL: case <API key>: case <API key>: case <API key>: case <API key>: return 1; default: return 0; } } /** * wm831x_reg_unlock: Unlock user keyed registers * * The WM831x has a user key preventing writes to particularly * critical registers. This function locks those registers, * allowing writes to them. */ void wm831x_reg_lock(struct wm831x *wm831x) { int ret; ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0); if (ret == 0) { dev_vdbg(wm831x->dev, "Registers locked\n"); mutex_lock(&wm831x->io_lock); WARN_ON(wm831x->locked); wm831x->locked = 1; mutex_unlock(&wm831x->io_lock); } else { dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret); } } EXPORT_SYMBOL_GPL(wm831x_reg_lock); /** * wm831x_reg_unlock: Unlock user keyed registers * * The WM831x has a user key preventing writes to particularly * critical registers. This function locks those registers, * preventing spurious writes. */ int wm831x_reg_unlock(struct wm831x *wm831x) { int ret; /* 0x9716 is the value required to unlock the registers */ ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716); if (ret == 0) { dev_vdbg(wm831x->dev, "Registers unlocked\n"); mutex_lock(&wm831x->io_lock); WARN_ON(!wm831x->locked); wm831x->locked = 0; mutex_unlock(&wm831x->io_lock); } return ret; } EXPORT_SYMBOL_GPL(wm831x_reg_unlock); static bool wm831x_reg_readable(struct device *dev, unsigned int reg) { switch (reg) { case WM831X_RESET_ID: case WM831X_REVISION: case WM831X_PARENT_ID: case <API key>: case <API key>: case WM831X_POWER_STATE: case WM831X_WATCHDOG: case <API key>: case <API key>: case <API key>: case WM831X_SECURITY_KEY: case <API key>: case WM831X_OTP_CONTROL: case WM831X_GPIO_LEVEL: case <API key>: case WM831X_ON_SOURCE: case WM831X_OFF_SOURCE: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_IRQ_CONFIG: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_RTC_TIME_1: case WM831X_RTC_TIME_2: case WM831X_RTC_ALARM_1: case WM831X_RTC_ALARM_2: case WM831X_RTC_CONTROL: case WM831X_RTC_TRIM: case <API key>: case <API key>: case WM831X_TOUCH_DATA_X: case WM831X_TOUCH_DATA_Y: case WM831X_TOUCH_DATA_Z: case WM831X_AUXADC_DATA: case <API key>: case <API key>: case <API key>: case WM831X_COMPARATOR_1: case WM831X_COMPARATOR_2: case WM831X_COMPARATOR_3: case WM831X_COMPARATOR_4: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_STATUS_LED_1: case WM831X_STATUS_LED_2: case <API key>: case <API key>: case WM831X_DCDC_ENABLE: case WM831X_LDO_ENABLE: case WM831X_DCDC_STATUS: case WM831X_LDO_STATUS: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_DC4_CONTROL: case <API key>: case WM831X_EPE1_CONTROL: case WM831X_EPE2_CONTROL: case WM831X_LDO1_CONTROL: case <API key>: case <API key>: case WM831X_LDO2_CONTROL: case <API key>: case <API key>: case WM831X_LDO3_CONTROL: case <API key>: case <API key>: case WM831X_LDO4_CONTROL: case <API key>: case <API key>: case WM831X_LDO5_CONTROL: case <API key>: case <API key>: case WM831X_LDO6_CONTROL: case <API key>: case <API key>: case WM831X_LDO7_CONTROL: case <API key>: case <API key>: case WM831X_LDO8_CONTROL: case <API key>: case <API key>: case WM831X_LDO9_CONTROL: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_UNIQUE_ID_1: case WM831X_UNIQUE_ID_2: case WM831X_UNIQUE_ID_3: case WM831X_UNIQUE_ID_4: case WM831X_UNIQUE_ID_5: case WM831X_UNIQUE_ID_6: case WM831X_UNIQUE_ID_7: case WM831X_UNIQUE_ID_8: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: return true; default: return false; } } static bool <API key>(struct device *dev, unsigned int reg) { struct wm831x *wm831x = dev_get_drvdata(dev); if (wm831x_reg_locked(wm831x, reg)) return false; switch (reg) { case <API key>: case <API key>: case WM831X_POWER_STATE: case WM831X_WATCHDOG: case <API key>: case <API key>: case <API key>: case WM831X_SECURITY_KEY: case <API key>: case WM831X_OTP_CONTROL: case WM831X_GPIO_LEVEL: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_IRQ_CONFIG: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_RTC_TIME_1: case WM831X_RTC_TIME_2: case WM831X_RTC_ALARM_1: case WM831X_RTC_ALARM_2: case WM831X_RTC_CONTROL: case WM831X_RTC_TRIM: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_COMPARATOR_1: case WM831X_COMPARATOR_2: case WM831X_COMPARATOR_3: case WM831X_COMPARATOR_4: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_STATUS_LED_1: case WM831X_STATUS_LED_2: case <API key>: case <API key>: case WM831X_DCDC_ENABLE: case WM831X_LDO_ENABLE: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_DC4_CONTROL: case <API key>: case WM831X_EPE1_CONTROL: case WM831X_EPE2_CONTROL: case WM831X_LDO1_CONTROL: case <API key>: case <API key>: case WM831X_LDO2_CONTROL: case <API key>: case <API key>: case WM831X_LDO3_CONTROL: case <API key>: case <API key>: case WM831X_LDO4_CONTROL: case <API key>: case <API key>: case WM831X_LDO5_CONTROL: case <API key>: case <API key>: case WM831X_LDO6_CONTROL: case <API key>: case <API key>: case WM831X_LDO7_CONTROL: case <API key>: case <API key>: case WM831X_LDO8_CONTROL: case <API key>: case <API key>: case WM831X_LDO9_CONTROL: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: return true; default: return false; } } static bool wm831x_reg_volatile(struct device *dev, unsigned int reg) { switch (reg) { case <API key>: case WM831X_ON_SOURCE: case WM831X_OFF_SOURCE: case WM831X_GPIO_LEVEL: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case WM831X_RTC_TIME_1: case WM831X_RTC_TIME_2: case WM831X_TOUCH_DATA_X: case WM831X_TOUCH_DATA_Y: case WM831X_TOUCH_DATA_Z: case WM831X_AUXADC_DATA: case <API key>: case WM831X_DCDC_STATUS: case WM831X_LDO_STATUS: case <API key>: case <API key>: return true; default: return false; } } /** * wm831x_reg_read: Read a single WM831x register. * * @wm831x: Device to read from. * @reg: Register to read. */ int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg) { unsigned int val; int ret; ret = regmap_read(wm831x->regmap, reg, &val); if (ret < 0) return ret; else return val; } EXPORT_SYMBOL_GPL(wm831x_reg_read); /** * wm831x_bulk_read: Read multiple WM831x registers * * @wm831x: Device to read from * @reg: First register * @count: Number of registers * @buf: Buffer to fill. */ int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg, int count, u16 *buf) { return regmap_bulk_read(wm831x->regmap, reg, buf, count); } EXPORT_SYMBOL_GPL(wm831x_bulk_read); static int wm831x_write(struct wm831x *wm831x, unsigned short reg, int bytes, void *src) { u16 *buf = src; int i, ret; BUG_ON(bytes % 2); BUG_ON(bytes <= 0); for (i = 0; i < bytes / 2; i++) { if (wm831x_reg_locked(wm831x, reg)) return -EPERM; dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", buf[i], reg + i, reg + i); ret = regmap_write(wm831x->regmap, reg + i, buf[i]); if (ret != 0) return ret; } return 0; } /** * wm831x_reg_write: Write a single WM831x register. * * @wm831x: Device to write to. * @reg: Register to write to. * @val: Value to write. */ int wm831x_reg_write(struct wm831x *wm831x, unsigned short reg, unsigned short val) { int ret; mutex_lock(&wm831x->io_lock); ret = wm831x_write(wm831x, reg, 2, &val); mutex_unlock(&wm831x->io_lock); return ret; } EXPORT_SYMBOL_GPL(wm831x_reg_write); /** * wm831x_set_bits: Set the value of a bitfield in a WM831x register * * @wm831x: Device to write to. * @reg: Register to write to. * @mask: Mask of bits to set. * @val: Value to set (unshifted) */ int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg, unsigned short mask, unsigned short val) { int ret; mutex_lock(&wm831x->io_lock); if (!wm831x_reg_locked(wm831x, reg)) ret = regmap_update_bits(wm831x->regmap, reg, mask, val); else ret = -EPERM; mutex_unlock(&wm831x->io_lock); return ret; } EXPORT_SYMBOL_GPL(wm831x_set_bits); static struct resource wm831x_io_parent = { .start = 0, .end = 0xffffffff, .flags = IORESOURCE_IO, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_DC1, .end = WM831X_IRQ_UV_DC1, .flags = IORESOURCE_IRQ, }, { .name = "HC", .start = WM831X_IRQ_HC_DC1, .end = WM831X_IRQ_HC_DC1, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_DC2, .end = WM831X_IRQ_UV_DC2, .flags = IORESOURCE_IRQ, }, { .name = "HC", .start = WM831X_IRQ_HC_DC2, .end = WM831X_IRQ_HC_DC2, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_DC3, .end = WM831X_IRQ_UV_DC3, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_DC4_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_DC4, .end = WM831X_IRQ_UV_DC4, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_DC4_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_DC4, .end = WM831X_IRQ_UV_DC4, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .start = WM831X_IRQ_GPIO_1, .end = WM831X_IRQ_GPIO_16, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .start = WM831X_IRQ_CS1, .end = WM831X_IRQ_CS1, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .start = WM831X_IRQ_CS2, .end = WM831X_IRQ_CS2, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO1_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO1, .end = WM831X_IRQ_UV_LDO1, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO2_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO2, .end = WM831X_IRQ_UV_LDO2, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO3_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO3, .end = WM831X_IRQ_UV_LDO3, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO4_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO4, .end = WM831X_IRQ_UV_LDO4, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO5_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO5, .end = WM831X_IRQ_UV_LDO5, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO6_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO6, .end = WM831X_IRQ_UV_LDO6, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO7_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO7, .end = WM831X_IRQ_UV_LDO7, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO8_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO8, .end = WM831X_IRQ_UV_LDO8, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_LDO9_CONTROL, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO9, .end = WM831X_IRQ_UV_LDO9, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, { .name = "UV", .start = WM831X_IRQ_UV_LDO10, .end = WM831X_IRQ_UV_LDO10, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = <API key>, .end = <API key>, .flags = IORESOURCE_IO, }, }; static struct resource wm831x_on_resources[] = { { .start = WM831X_IRQ_ON, .end = WM831X_IRQ_ON, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .name = "SYSLO", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "PWR SRC", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "USB CURR", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "BATT HOT", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "BATT COLD", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "BATT FAIL", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "OV", .start = WM831X_IRQ_CHG_OV, .end = WM831X_IRQ_CHG_OV, .flags = IORESOURCE_IRQ, }, { .name = "END", .start = WM831X_IRQ_CHG_END, .end = WM831X_IRQ_CHG_END, .flags = IORESOURCE_IRQ, }, { .name = "TO", .start = WM831X_IRQ_CHG_TO, .end = WM831X_IRQ_CHG_TO, .flags = IORESOURCE_IRQ, }, { .name = "MODE", .start = WM831X_IRQ_CHG_MODE, .end = WM831X_IRQ_CHG_MODE, .flags = IORESOURCE_IRQ, }, { .name = "START", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .name = "PER", .start = WM831X_IRQ_RTC_PER, .end = WM831X_IRQ_RTC_PER, .flags = IORESOURCE_IRQ, }, { .name = "ALM", .start = WM831X_IRQ_RTC_ALM, .end = WM831X_IRQ_RTC_ALM, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_STATUS_LED_1, .end = WM831X_STATUS_LED_1, .flags = IORESOURCE_IO, }, }; static struct resource <API key>[] = { { .parent = &wm831x_io_parent, .start = WM831X_STATUS_LED_2, .end = WM831X_STATUS_LED_2, .flags = IORESOURCE_IO, }, }; static struct resource <API key>[] = { { .name = "TCHPD", .start = WM831X_IRQ_TCHPD, .end = WM831X_IRQ_TCHPD, .flags = IORESOURCE_IRQ, }, { .name = "TCHDATA", .start = WM831X_IRQ_TCHDATA, .end = WM831X_IRQ_TCHDATA, .flags = IORESOURCE_IRQ, }, }; static struct resource <API key>[] = { { .start = WM831X_IRQ_WDOG_TO, .end = WM831X_IRQ_WDOG_TO, .flags = IORESOURCE_IRQ, }, }; static struct mfd_cell wm8310_devs[] = { { .name = "wm831x-backup", }, { .name = "wm831x-buckv", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckv", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckp", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-boostp", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-clk", }, { .name = "wm831x-epe", .id = 1, }, { .name = "wm831x-epe", .id = 2, }, { .name = "wm831x-gpio", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-hwmon", }, { .name = "wm831x-isink", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-isink", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 5, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 6, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 7, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 8, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 9, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 10, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-alive-ldo", .id = 11, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-on", .num_resources = ARRAY_SIZE(wm831x_on_resources), .resources = wm831x_on_resources, }, { .name = "wm831x-power", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-watchdog", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell wm8311_devs[] = { { .name = "wm831x-backup", }, { .name = "wm831x-buckv", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckv", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckp", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-boostp", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-clk", }, { .name = "wm831x-epe", .id = 1, }, { .name = "wm831x-epe", .id = 2, }, { .name = "wm831x-gpio", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-hwmon", }, { .name = "wm831x-isink", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-isink", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 5, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 7, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-alive-ldo", .id = 11, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-on", .num_resources = ARRAY_SIZE(wm831x_on_resources), .resources = wm831x_on_resources, }, { .name = "wm831x-power", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-watchdog", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell wm8312_devs[] = { { .name = "wm831x-backup", }, { .name = "wm831x-buckv", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckv", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckp", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-boostp", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-clk", }, { .name = "wm831x-epe", .id = 1, }, { .name = "wm831x-epe", .id = 2, }, { .name = "wm831x-gpio", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-hwmon", }, { .name = "wm831x-isink", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-isink", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 5, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 6, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 7, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 8, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 9, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 10, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-alive-ldo", .id = 11, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-on", .num_resources = ARRAY_SIZE(wm831x_on_resources), .resources = wm831x_on_resources, }, { .name = "wm831x-power", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-watchdog", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell wm8320_devs[] = { { .name = "wm831x-backup", }, { .name = "wm831x-buckv", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckv", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckp", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-buckp", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-clk", }, { .name = "wm831x-gpio", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-hwmon", }, { .name = "wm831x-ldo", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 3, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 4, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 5, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-ldo", .id = 6, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 7, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 8, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 9, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-aldo", .id = 10, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-alive-ldo", .id = 11, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-on", .num_resources = ARRAY_SIZE(wm831x_on_resources), .resources = wm831x_on_resources, }, { .name = "wm831x-status", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-status", .id = 2, .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, { .name = "wm831x-watchdog", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell touch_devs[] = { { .name = "wm831x-touch", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell rtc_devs[] = { { .name = "wm831x-rtc", .num_resources = ARRAY_SIZE(<API key>), .resources = <API key>, }, }; static struct mfd_cell backlight_devs[] = { { .name = "wm831x-backlight", }, }; struct regmap_config <API key> = { .reg_bits = 16, .val_bits = 16, .cache_type = REGCACHE_RBTREE, .max_register = <API key>, .readable_reg = wm831x_reg_readable, .writeable_reg = <API key>, .volatile_reg = wm831x_reg_volatile, }; EXPORT_SYMBOL_GPL(<API key>); /* * Instantiate the generic non-control parts of the device. */ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) { struct wm831x_pdata *pdata = wm831x->dev->platform_data; int rev, wm831x_num; enum wm831x_parent parent; int ret, i; mutex_init(&wm831x->io_lock); mutex_init(&wm831x->key_lock); dev_set_drvdata(wm831x->dev, wm831x); wm831x->soft_shutdown = pdata->soft_shutdown; ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID); if (ret < 0) { dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret); goto err; } switch (ret) { case 0x6204: case 0x6246: break; default: dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret); ret = -EINVAL; goto err; } ret = wm831x_reg_read(wm831x, WM831X_REVISION); if (ret < 0) { dev_err(wm831x->dev, "Failed to read revision: %d\n", ret); goto err; } rev = (ret & <API key>) >> <API key>; ret = wm831x_reg_read(wm831x, WM831X_RESET_ID); if (ret < 0) { dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret); goto err; } /* Some engineering samples do not have the ID set, rely on * the device being registered correctly. */ if (ret == 0) { dev_info(wm831x->dev, "Device is an engineering sample\n"); ret = id; } switch (ret) { case WM8310: parent = WM8310; wm831x->num_gpio = 16; wm831x->charger_irq_wake = 1; if (rev > 0) { wm831x->has_gpio_ena = 1; wm831x->has_cs_sts = 1; } dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev); break; case WM8311: parent = WM8311; wm831x->num_gpio = 16; wm831x->charger_irq_wake = 1; if (rev > 0) { wm831x->has_gpio_ena = 1; wm831x->has_cs_sts = 1; } dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev); break; case WM8312: parent = WM8312; wm831x->num_gpio = 16; wm831x->charger_irq_wake = 1; if (rev > 0) { wm831x->has_gpio_ena = 1; wm831x->has_cs_sts = 1; } dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev); break; case WM8320: parent = WM8320; wm831x->num_gpio = 12; dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev); break; case WM8321: parent = WM8321; wm831x->num_gpio = 12; dev_info(wm831x->dev, "WM8321 revision %c\n", 'A' + rev); break; case WM8325: parent = WM8325; wm831x->num_gpio = 12; dev_info(wm831x->dev, "WM8325 revision %c\n", 'A' + rev); break; case WM8326: parent = WM8326; wm831x->num_gpio = 12; dev_info(wm831x->dev, "WM8326 revision %c\n", 'A' + rev); break; default: dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); ret = -EINVAL; goto err; } /* This will need revisiting in future but is OK for all * current parts. */ if (parent != id) dev_warn(wm831x->dev, "Device was registered as a WM%lx\n", id); /* Bootstrap the user key */ ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY); if (ret < 0) { dev_err(wm831x->dev, "Failed to read security key: %d\n", ret); goto err; } if (ret != 0) { dev_warn(wm831x->dev, "Security key had non-zero value %x\n", ret); wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0); } wm831x->locked = 1; if (pdata && pdata->pre_init) { ret = pdata->pre_init(wm831x); if (ret != 0) { dev_err(wm831x->dev, "pre_init() failed: %d\n", ret); goto err; } } if (pdata) { for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { if (!pdata->gpio_defaults[i]) continue; wm831x_reg_write(wm831x, <API key> + i, pdata->gpio_defaults[i] & 0xffff); } } /* Multiply by 10 as we have many subdevices of the same type */ if (pdata && pdata->wm831x_num) wm831x_num = pdata->wm831x_num * 10; else wm831x_num = -1; ret = wm831x_irq_init(wm831x, irq); if (ret != 0) goto err; wm831x_auxadc_init(wm831x); /* The core device is up, instantiate the subdevices. */ switch (parent) { case WM8310: ret = mfd_add_devices(wm831x->dev, wm831x_num, wm8310_devs, ARRAY_SIZE(wm8310_devs), NULL, 0, NULL); break; case WM8311: ret = mfd_add_devices(wm831x->dev, wm831x_num, wm8311_devs, ARRAY_SIZE(wm8311_devs), NULL, 0, NULL); if (!pdata || !pdata->disable_touch) mfd_add_devices(wm831x->dev, wm831x_num, touch_devs, ARRAY_SIZE(touch_devs), NULL, 0, NULL); break; case WM8312: ret = mfd_add_devices(wm831x->dev, wm831x_num, wm8312_devs, ARRAY_SIZE(wm8312_devs), NULL, 0, NULL); if (!pdata || !pdata->disable_touch) mfd_add_devices(wm831x->dev, wm831x_num, touch_devs, ARRAY_SIZE(touch_devs), NULL, 0, NULL); break; case WM8320: case WM8321: case WM8325: case WM8326: ret = mfd_add_devices(wm831x->dev, wm831x_num, wm8320_devs, ARRAY_SIZE(wm8320_devs), NULL, 0, NULL); break; default: /* If this happens the bus probe function is buggy */ BUG(); } if (ret != 0) { dev_err(wm831x->dev, "Failed to add children\n"); goto err_irq; } /* The RTC can only be used if the 32.768kHz crystal is * enabled; this can't be controlled by software at runtime. */ ret = wm831x_reg_read(wm831x, <API key>); if (ret < 0) { dev_err(wm831x->dev, "Failed to read clock status: %d\n", ret); goto err_irq; } if (ret & WM831X_XTAL_ENA) { ret = mfd_add_devices(wm831x->dev, wm831x_num, rtc_devs, ARRAY_SIZE(rtc_devs), NULL, 0, NULL); if (ret != 0) { dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret); goto err_irq; } } else { dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n"); } if (pdata && pdata->backlight) { /* Treat errors as non-critical */ ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, ARRAY_SIZE(backlight_devs), NULL, 0, NULL); if (ret < 0) dev_err(wm831x->dev, "Failed to add backlight: %d\n", ret); } wm831x_otp_init(wm831x); if (pdata && pdata->post_init) { ret = pdata->post_init(wm831x); if (ret != 0) { dev_err(wm831x->dev, "post_init() failed: %d\n", ret); goto err_irq; } } return 0; err_irq: wm831x_irq_exit(wm831x); err: mfd_remove_devices(wm831x->dev); return ret; } void wm831x_device_exit(struct wm831x *wm831x) { wm831x_otp_exit(wm831x); mfd_remove_devices(wm831x->dev); free_irq(wm831x_irq(wm831x, <API key>), wm831x); wm831x_irq_exit(wm831x); } int <API key>(struct wm831x *wm831x) { int reg, mask; /* If the charger IRQs are a wake source then make sure we ack * them even if they're not actively being used (eg, no power * driver or no IRQ line wired up) then acknowledge the * interrupts otherwise suspend won't last very long. */ if (wm831x->charger_irq_wake) { reg = wm831x_reg_read(wm831x, <API key>); mask = <API key> | <API key> | <API key> | WM831X_CHG_OV_EINT | WM831X_CHG_END_EINT | WM831X_CHG_TO_EINT | <API key> | <API key>; /* If any of the interrupts are masked read the statuses */ if (reg & mask) reg = wm831x_reg_read(wm831x, <API key>); if (reg & mask) { dev_info(wm831x->dev, "Acknowledging masked charger IRQs: %x\n", reg & mask); wm831x_reg_write(wm831x, <API key>, reg & mask); } } return 0; } void <API key>(struct wm831x *wm831x) { if (wm831x->soft_shutdown) { dev_info(wm831x->dev, "Initiating shutdown...\n"); wm831x_set_bits(wm831x, WM831X_POWER_STATE, WM831X_CHIP_ON, 0); } } EXPORT_SYMBOL_GPL(<API key>); MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Mark Brown");
using System; using System.Collections.Immutable; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; namespace AsyncPackage { <summary> This Analyzer determines if a method is Async and needs to be returning a Task instead of having a void return type. </summary> [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class AsyncVoidAnalyzer : DiagnosticAnalyzer { internal const string AsyncVoidId = "Async001"; internal static <API key> VoidReturnType = new <API key>(id: AsyncVoidId, title: "Avoid Async Void", messageFormat: "This method has the async keyword but it returns void", category: "Usage", defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); public override void Initialize(AnalysisContext context) { context.<API key>(AnalyzeSymbol, SymbolKind.Method); } public override ImmutableArray<<API key>> <API key> { get { return ImmutableArray.Create(VoidReturnType); } } private void AnalyzeSymbol(<API key> context) { // Filter out methods that do not use Async and that do not have exactly two parameters var methodSymbol = (IMethodSymbol)context.Symbol; var eventType = context.Compilation.<API key>("System.EventArgs"); if (methodSymbol.ReturnsVoid && methodSymbol.IsAsync) { if (methodSymbol.Parameters.Length == 2) { var firstParam = methodSymbol.Parameters[0]; var secondParam = methodSymbol.Parameters[1]; if (firstParam is object) { // Check each parameter for EventHandler shape and return if it matches. if (firstParam.Name.ToLower().Equals("sender") && secondParam.Type == eventType) { return; } else { // Check if the second parameter implements EventArgs. If it does; return. var checkForEventType = secondParam.Type.BaseType; while (checkForEventType.OriginalDefinition != context.Compilation.<API key>("System.Object")) { if (checkForEventType == eventType) { return; } checkForEventType = checkForEventType.BaseType; } } } } context.ReportDiagnostic(Diagnostic.Create(VoidReturnType, methodSymbol.Locations[0], methodSymbol.Name)); return; } return; } } }
#!/usr/bin/env bash set -eu function usage { echo "Usage: $0 [OPTION]..." echo "Run Neutron's test suite(s)" echo "" echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" echo " -s, --no-site-packages Isolate the virtualenv from the global Python environment" echo " -r, --recreate-db Recreate the test database (deprecated, as this is now the default)." echo " -n, --no-recreate-db Don't recreate the test database." echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -u, --update Update the virtual environment with any newer package versions" echo " -p, --pep8 Just run PEP8 and HACKING compliance check" echo " -8, --pep8-only-changed [<basecommit>]" echo " Just run PEP8 and HACKING compliance check on files changed since HEAD~1 (or <basecommit>)" echo " -P, --no-pep8 Don't run static code checks" echo " -c, --coverage Generate coverage report" echo " -d, --debug Run tests with testtools instead of testr. This allows you to use the debugger." echo " -h, --help Print this usage message" echo " --virtual-env-path <path> Location of the virtualenv directory" echo " Default: \$(pwd)" echo " --virtual-env-name <name> Name of the virtualenv directory" echo " Default: .venv" echo " --tools-path <dir> Location of the tools directory" echo " Default: \$(pwd)" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," echo " If no virtualenv is found, the script will ask if you would like to create one. If you " echo " prefer to run tests NOT in a virtual environment, simply pass the -N option." exit } function process_options { i=1 while [ $i -le $ case "${!i}" in -h|--help) usage;; -V|--virtual-env) always_venv=1; never_venv=0;; -N|--no-virtual-env) always_venv=0; never_venv=1;; -s|--no-site-packages) no_site_packages=1;; -r|--recreate-db) recreate_db=1;; -n|--no-recreate-db) recreate_db=0;; -f|--force) force=1;; -u|--update) update=1;; -p|--pep8) just_pep8=1;; -8|--pep8-only-changed) just_pep8_changed=1;; -P|--no-pep8) no_pep8=1;; -c|--coverage) coverage=1;; -d|--debug) debug=1;; --virtual-env-path) (( i++ )) venv_path=${!i} ;; --virtual-env-name) (( i++ )) venv_dir=${!i} ;; --tools-path) (( i++ )) tools_path=${!i} ;; -*) testopts="$testopts ${!i}";; *) testargs="$testargs ${!i}" esac (( i++ )) done } tool_path=${tools_path:-$(pwd)} venv_path=${venv_path:-$(pwd)} venv_dir=${venv_name:-.venv} with_venv=tools/with_venv.sh always_venv=0 never_venv=0 force=0 no_site_packages=0 installvenvopts= testargs= testopts= wrapper="" just_pep8=0 just_pep8_changed=0 no_pep8=0 coverage=0 debug=0 recreate_db=1 update=0 LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=C process_options $@ # Make our paths available to other scripts we call export venv_path export venv_dir export venv_name export tools_dir export venv=${venv_path}/${venv_dir} if [ $no_site_packages -eq 1 ]; then installvenvopts="--no-site-packages" fi function run_tests { # Cleanup *pyc ${wrapper} find . -type f -name "*.pyc" -delete if [ $debug -eq 1 ]; then if [ "$testopts" = "" ] && [ "$testargs" = "" ]; then # Default to running all tests if specific test is not # provided. testargs="discover ./neutron/tests" fi ${wrapper} python -m testtools.run $testopts $testargs # Short circuit because all of the testr and coverage stuff # below does not make sense when running testtools.run for # debugging purposes. return $? fi if [ $coverage -eq 1 ]; then TESTRTESTS="$TESTRTESTS --coverage" else TESTRTESTS="$TESTRTESTS --slowest" fi # Just run the test suites in current environment set +e testargs=`echo "$testargs" | sed -e's/^\s*\(.*\)\s*$/\1/'` TESTRTESTS="$TESTRTESTS --testr-args='--subunit $testopts $testargs'" OS_TEST_PATH=`echo $testargs|grep -o 'neutron\.tests[^[:space:]:]\+'|tr . /` if [ -n "$OS_TEST_PATH" ]; then os_test_dir=$(dirname "$OS_TEST_PATH") else os_test_dir='' fi if [ -d "$OS_TEST_PATH" ]; then wrapper="OS_TEST_PATH=$OS_TEST_PATH $wrapper" elif [ -d "$os_test_dir" ]; then wrapper="OS_TEST_PATH=$os_test_dir $wrapper" fi echo "Running \`${wrapper} $TESTRTESTS\`" bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit2pyunit" RESULT=$? set -e copy_subunit_log if [ $coverage -eq 1 ]; then echo "Generating coverage report in covhtml/" # Don't compute coverage for common code, which is tested elsewhere ${wrapper} coverage combine
<script src="../../../resources/js-test.js"></script> <style> #pusher { width: 1000px; height: 1000px; outline: 1px solid black; } </style> <div id="console"></div> <div id="testArea"> <br> <p id="test">Test content</p> <div id="pusher">This box is here to create scrollbars.</div> </div> <script> if (window.testRunner) testRunner.dumpAsText(); var element = document.getElementById('test'); // Get base numbers var <API key> = element.<API key>(); var <API key> = element.getClientRects(); // Test scrolling down window.scrollBy(0, 50); var <API key> = element.<API key>(); var <API key> = element.getClientRects(); // Reset window.scrollTo(0, 0); // Test scrolling right window.scrollBy(50, 0); var <API key> = element.<API key>(); var <API key> = element.getClientRects(); // Reset window.scrollTo(0, 0); shouldBe("<API key>.top - <API key>.top", "50"); shouldBe("<API key>[0].top - <API key>[0].top", "50"); shouldBe("<API key>.left - <API key>.left", "50"); shouldBe("<API key>[0].left - <API key>[0].left", "50"); if (window.testRunner) { var area = document.getElementById('testArea'); area.parentNode.removeChild(area); } </script>
import * as http from "http"; import connect = require("connect"); const app = connect(); // log all requests app.use((req: http.IncomingMessage, res: http.ServerResponse, next: connect.NextFunction) => { console.log(req, res); next(); }); // "Throw" an Error app.use((req: http.IncomingMessage, res: http.ServerResponse, next: connect.NextFunction) => { next(new Error("Something went wrong!")); }); // "Throw" a number app.use((req: http.IncomingMessage, res: http.ServerResponse, next: connect.NextFunction) => { next(404); }); // Stop on errors app.use((err: any, req: http.IncomingMessage, res: http.ServerResponse, next: connect.NextFunction) => { if (err) { return res.end(`Error: ${err}`); } next(); }); // Use legacy `Function` for `next` parameter. app.use((req: http.IncomingMessage, res: http.ServerResponse, next: Function) => { next(); }); // respond to all requests app.use((req: http.IncomingMessage, res: http.ServerResponse) => { res.end("Hello from Connect!\n"); }); //create node.js http server and listen on port http.createServer(app).listen(3000); //create node.js http server and listen on port using connect shortcut app.listen(3000);
<?php abstract class <API key> extends Phobject {}
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ #include <net/if.h> #include "<API key>.h" static int <API key>(NetDev *netdev, Link *link, sd_netlink_message *req) { VLan *v = VLAN(netdev); int r; assert(netdev); assert(v); assert(link); assert(req); if (v->id <= VLANID_MAX) { r = <API key>(req, IFLA_VLAN_ID, v->id); if (r < 0) return <API key>(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m"); } return 0; } static int netdev_vlan_verify(NetDev *netdev, const char *filename) { VLan *v = VLAN(netdev); assert(netdev); assert(v); assert(filename); if (v->id > VLANID_MAX) { log_warning("VLAN without valid Id (%"PRIu64") configured in %s. Ignoring", v->id, filename); return -EINVAL; } return 0; } static void vlan_init(NetDev *netdev) { VLan *v = VLAN(netdev); assert(netdev); assert(v); v->id = VLANID_MAX + 1; } const NetDevVTable vlan_vtable = { .object_size = sizeof(VLan), .init = vlan_init, .sections = "Match\0NetDev\0VLAN\0", .fill_message_create = <API key>, .create_type = <API key>, .config_verify = netdev_vlan_verify, };
<?php // Moodle is free software: you can redistribute it and/or modify // (at your option) any later version. // Moodle is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the defined('MOODLE_INTERNAL') || die(); $string['admindirname'] = 'Dossièr d\'administracion'; $string['availablelangs'] = 'Paquetatges de lenga disponibles'; $string['chooselanguagehead'] = 'Causitz ua lenga'; $string['cliinstallheader'] = 'Programa d\'installacion de Moodle {$a} en linha de comanda'; $string['clitablesexist'] = 'Las taulas de la banca de dadas que son ja presentas. L\'installacion en linha de comanda ne pòt pas contunhar.'; $string['databasehost'] = 'Servidor de banca de dadas'; $string['databasename'] = 'Nom de la banca de dadas'; $string['databasetypehead'] = 'Seleccionar un pilòt de banca de dadas'; $string['dataroot'] = 'Dossièr de dadas'; $string['dbprefix'] = 'Prefix de las taulas'; $string['dirroot'] = 'Dossièr Moodle'; $string['environmenthead'] = 'Verificacion de l\'environament...'; $string['errorsinenvironment'] = 'Mauescaduda de la verificacion de l\'environament !'; $string['installation'] = 'Installacion'; $string['paths'] = 'Camins'; $string['<API key>'] = 'Lo dossièr de dadas ({$a->dataroot}) ne pòt pas èster creat per l\'installador.'; $string['pathshead'] = 'Confirmar los camins d\'accès'; $string['pathsrodataroot'] = 'Lo dossièr de dadas n\'ei pas accessible en escritura.'; $string['<API key>'] = 'L\'emplaçament deu dossièr de dadas n\'ei pas segur'; $string['pathswrongadmindir'] = 'Lo dossièr d\'administracion n\'existeish pas'; $string['phpextension'] = 'Extension PHP {$a}'; $string['phpversion'] = 'Version de PHP'; $string['welcomep10'] = '{$a->installername} ({$a->installerversion})'; $string['wwwroot'] = 'Adreça web';
// class template regex -*- C++ -*- // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // Under Section 7 of GPL version 3, you are granted additional // 3.1, as published by the Free Software Foundation. // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /** * @file bits/regex_executor.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{regex} */ // FIXME convert comments to doxygen format. namespace std _GLIBCXX_VISIBILITY(default) { namespace __detail { <API key> /** * @addtogroup regex-detail * @{ */ /** * @brief Takes a regex and an input string and does the matching. * * The %_Executor class has two modes: DFS mode and BFS mode, controlled * by the template parameter %__dfs_mode. */ template<typename _BiIter, typename _Alloc, typename _TraitsT, bool __dfs_mode> class _Executor { using __search_mode = integral_constant<bool, __dfs_mode>; using __dfs = true_type; using __bfs = false_type; enum class _Match_mode : unsigned char { _Exact, _Prefix }; public: typedef typename iterator_traits<_BiIter>::value_type _CharT; typedef basic_regex<_CharT, _TraitsT> _RegexT; typedef std::vector<sub_match<_BiIter>, _Alloc> _ResultsVec; typedef regex_constants::match_flag_type _FlagT; typedef typename _TraitsT::char_class_type _ClassT; typedef _NFA<_TraitsT> _NFAT; public: _Executor(_BiIter __begin, _BiIter __end, _ResultsVec& __results, const _RegexT& __re, _FlagT __flags) : _M_begin(__begin), _M_end(__end), _M_re(__re), _M_nfa(*__re._M_automaton), _M_results(__results), _M_rep_count(_M_nfa.size()), _M_states(_M_nfa._M_start(), _M_nfa.size()), _M_flags((__flags & regex_constants::match_prev_avail) ? (__flags & ~regex_constants::match_not_bol & ~regex_constants::match_not_bow) : __flags) { } // Set matched when string exactly matches the pattern. bool _M_match() { _M_current = _M_begin; return _M_main(_Match_mode::_Exact); } // Set matched when some prefix of the string matches the pattern. bool <API key>() { _M_current = _M_begin; return _M_main(_Match_mode::_Prefix); } bool _M_search(); private: void _M_rep_once_more(_Match_mode __match_mode, _StateIdT); void _M_dfs(_Match_mode __match_mode, _StateIdT __start); bool _M_main(_Match_mode __match_mode) { return _M_main_dispatch(__match_mode, __search_mode{}); } bool _M_main_dispatch(_Match_mode __match_mode, __dfs); bool _M_main_dispatch(_Match_mode __match_mode, __bfs); bool _M_is_word(_CharT __ch) const { static const _CharT __s[2] = { 'w' }; return _M_re._M_automaton->_M_traits.isctype (__ch, _M_re._M_automaton->_M_traits.lookup_classname(__s, __s+1)); } bool _M_at_begin() const { return _M_current == _M_begin && !(_M_flags & (regex_constants::match_not_bol | regex_constants::match_prev_avail)); } bool _M_at_end() const { return _M_current == _M_end && !(_M_flags & regex_constants::match_not_eol); } bool _M_word_boundary() const; bool _M_lookahead(_State<_TraitsT> __state); // Holds additional information used in BFS-mode. template<typename _SearchMode, typename _ResultsVec> struct _State_info; template<typename _ResultsVec> struct _State_info<__bfs, _ResultsVec> { explicit _State_info(_StateIdT __start, size_t __n) : _M_visited_states(new bool[__n]()), _M_start(__start) { } bool _M_visited(_StateIdT __i) { if (_M_visited_states[__i]) return true; _M_visited_states[__i] = true; return false; } void _M_queue(_StateIdT __i, const _ResultsVec& __res) { _M_match_queue.emplace_back(__i, __res); } // Dummy implementations for BFS mode. _BiIter* _M_get_sol_pos() { return nullptr; } // Saves states that need to be considered for the next character. vector<pair<_StateIdT, _ResultsVec>> _M_match_queue; // Indicates which states are already visited. unique_ptr<bool[]> _M_visited_states; // To record current solution. _StateIdT _M_start; }; template<typename _ResultsVec> struct _State_info<__dfs, _ResultsVec> { explicit _State_info(_StateIdT __start, size_t) : _M_start(__start) { } // Dummy implementations for DFS mode. bool _M_visited(_StateIdT) const { return false; } void _M_queue(_StateIdT, const _ResultsVec&) { } _BiIter* _M_get_sol_pos() { return &_M_sol_pos; } // To record current solution. _StateIdT _M_start; _BiIter _M_sol_pos; }; public: _ResultsVec _M_cur_results; _BiIter _M_current; _BiIter _M_begin; const _BiIter _M_end; const _RegexT& _M_re; const _NFAT& _M_nfa; _ResultsVec& _M_results; vector<pair<_BiIter, int>> _M_rep_count; _State_info<__search_mode, _ResultsVec> _M_states; _FlagT _M_flags; // Do we have a solution so far? bool _M_has_sol; }; //@} regex-detail <API key> } // namespace __detail } // namespace std #include <bits/regex_executor.tcc>
/* <API key>: GPL-2.0-or-later */ #ifndef AF9015_H #define AF9015_H #include <linux/hash.h> #include <linux/regmap.h> #include "dvb_usb.h" #include "af9013.h" #include "dvb-pll.h" #include "mt2060.h" #include "qt1010.h" #include "tda18271.h" #include "mxl5005s.h" #include "mc44s803.h" #include "tda18218.h" #include "mxl5007t.h" #define AF9015_FIRMWARE "dvb-usb-af9015.fw" #define AF9015_I2C_EEPROM 0x50 #define AF9015_I2C_DEMOD 0x1c #define AF9015_USB_TIMEOUT 2000 /* EEPROM locations */ #define <API key> 0x18 #define <API key> 0x34 #define <API key> 0x31 #define <API key> 0x32 #define <API key> 0x35 #define <API key> 0x36 #define <API key> 0x37 #define AF9015_EEPROM_IF1L 0x38 #define AF9015_EEPROM_IF1H 0x39 #define <API key> 0x3a #define <API key> 0x3b #define <API key> 0x3c #define <API key> 0x45 #define <API key> 0x46 #define <API key> 0x47 #define AF9015_EEPROM_IF2L 0x48 #define AF9015_EEPROM_IF2H 0x49 #define <API key> 0x4a #define <API key> 0x4b #define <API key> 0x4c #define <API key> (<API key> - <API key>) struct req_t { u8 cmd; /* seq */ /* [1] */ u8 i2c_addr; u16 addr; u8 mbox; u8 addr_len; u8 data_len; u8 *data; }; enum af9015_cmd { GET_CONFIG = 0x10, DOWNLOAD_FIRMWARE = 0x11, BOOT = 0x13, READ_MEMORY = 0x20, WRITE_MEMORY = 0x21, READ_WRITE_I2C = 0x22, COPY_FIRMWARE = 0x23, RECONNECT_USB = 0x5a, <API key> = 0x26, GET_IR_CODE = 0x27, READ_I2C, WRITE_I2C, }; enum af9015_ir_mode { <API key> = 0, AF9015_IR_MODE_HID, AF9015_IR_MODE_RLC, AF9015_IR_MODE_RC6, <API key>, /* just guess */ }; #define BUF_LEN 63 struct af9015_state { struct regmap *regmap; u8 buf[BUF_LEN]; /* bulk USB control message */ u8 ir_mode; u8 rc_repeat; u32 rc_keycode; u8 rc_last[4]; bool rc_failed; u8 dual_mode; u8 seq; /* packet sequence number */ u16 mt2060_if1[2]; u16 firmware_size; u16 firmware_checksum; u32 eeprom_sum; struct <API key> af9013_pdata[2]; struct i2c_client *demod_i2c_client[2]; u8 af9013_i2c_addr[2]; bool <API key>[2]; /* for demod callback override */ int (*set_frontend[2]) (struct dvb_frontend *fe); int (*read_status[2]) (struct dvb_frontend *fe, enum fe_status *status); int (*init[2]) (struct dvb_frontend *fe); int (*sleep[2]) (struct dvb_frontend *fe); int (*tuner_init[2]) (struct dvb_frontend *fe); int (*tuner_sleep[2]) (struct dvb_frontend *fe); struct mutex fe_mutex; }; enum af9015_remote { AF9015_REMOTE_NONE = 0, <API key>, <API key>, <API key>, <API key>, <API key>, }; #endif
var define; var require; (function ( global ) { // "mod" // functionobject /** * * * @inner * @type {Object} */ var modModules = {}; var <API key> = 1; var <API key> = 2; var <API key> = 3; var MODULE_STATE_READY = 4; var <API key> = 5; /** * require * * @inner * @type {Function} */ var actualGlobalRequire = createLocalRequire( '' ); /** * * * @inner * @type {number} */ var waitTimeout; /** * * * @param {string|Array} requireId idid * @param {Function=} callback * @return {*} */ function require( requireId, callback ) { <API key>( requireId ); var timeout = requireConf.waitSeconds; if ( isArray( requireId ) && timeout ) { if ( waitTimeout ) { clearTimeout( waitTimeout ); } waitTimeout = setTimeout( waitTimeoutNotice, timeout * 1000 ); } return actualGlobalRequire( requireId, callback ); } /** * url * * @param {string} id * @return {string} */ require.toUrl = toUrl; /** * * * @inner */ function waitTimeoutNotice() { var hangModules = []; var missModules = []; var missModulesMap = {}; var hasError; for ( var id in modModules ) { if ( !modIsDefined( id ) ) { hangModules.push( id ); hasError = 1; } each( modModules[ id ].realDeps || [], function ( depId ) { if ( !modModules[ depId ] && !missModulesMap[ depId ] ) { hasError = 1; missModules.push( depId ); missModulesMap[ depId ] = 1; } } ); } if ( hasError ) { throw new Error( '[MODULE_TIMEOUT]Hang( ' + ( hangModules.join( ', ' ) || 'none' ) + ' ) Miss( ' + ( missModules.join( ', ' ) || 'none' ) + ' )' ); } } /** * * * @inner * @type {number} */ var tryDefineTimeout; /** * * * @param {string=} id * @param {Array=} dependencies * @param {Function=} factory */ function define() { var argsLen = arguments.length; if ( !argsLen ) { return; } var id; var dependencies; var factory = arguments[ --argsLen ]; while ( argsLen var arg = arguments[ argsLen ]; if ( isString( arg ) ) { id = arg; } else if ( isArray( arg ) ) { dependencies = arg; } } // window // eslbrowserloader // global // definerequire var opera = window.opera; // IEcurrent scriptdata-require-idid if ( !id && document.attachEvent && (!(opera && opera.toString() === '[object Opera]')) ) { var currentScript = getCurrentScript(); id = currentScript && currentScript.getAttribute('data-require-id'); } // ['require', 'exports', 'module'] dependencies = dependencies || ['require', 'exports', 'module']; if ( id ) { modPreDefine( id, dependencies, factory ); // define // definerequire if ( tryDefineTimeout ) { clearTimeout( tryDefineTimeout ); } tryDefineTimeout = setTimeout( modPreAnalyse, 10 ); } else { // loadreadystatechange wait4PreDefines.push( { deps : dependencies, factory : factory } ); } } define.amd = {}; /** * * * @inner * @param {number} state * @return {Array} */ function modGetByState( state ) { var modules = []; for ( var key in modModules ) { var module = modModules[ key ]; if ( module.state == state ) { modules.push( module ); } } return modules; } /** * * * @inner * @return {Object} */ function moduleConfigGetter() { var conf = requireConf.config[ this.id ]; if ( conf && typeof conf === 'object' ) { return conf; } return {}; } /** * * * @inner * @param {string} id * @param {Array.<string>} dependencies * @param {*} factory */ function modPreDefine( id, dependencies, factory ) { if ( modExists( id ) ) { return; } var module = { id : id, deps : dependencies, factory : factory, exports : {}, config : moduleConfigGetter, state : <API key>, hardDeps : {} }; // defining modModules[ id ] = module; } /** * * * factory * "" * * resourceId normalize * modAnalyse * * @inner * @param {Object} modules */ function modPreAnalyse() { var pluginModuleIds = []; var pluginModuleIdsMap = {}; var modules = modGetByState( <API key> ); each( modules, function ( module ) { var realDepends = module.deps.slice( 0 ); module.realDeps = realDepends; // function bodyrequire // factoryBody // AMD`SHOULD NOT` var factory = module.factory; var requireRule = /require\(\s*(['"'])([^'"]+)\1\s*\)/g; var commentRule = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg; if ( isFunction( factory ) ) { factory.toString() .replace( commentRule, '' ) .replace( requireRule, function ( $0, $1, $2 ) { realDepends.push( $2 ); }); } // resourceplugin module id each( realDepends, function ( dependId ) { var idInfo = parseId( dependId ); if ( idInfo.resource ) { var plugId = normalize( idInfo.module, module.id ); if ( !pluginModuleIdsMap[ plugId ] ) { pluginModuleIds.push( plugId ); pluginModuleIdsMap[ plugId ] = 1; } } } ); module.state = <API key>; } ); nativeRequire( pluginModuleIds, function () { modAnalyse( modules ); } ); } /** * * idnormalize * * @inner * @param {Array} modules */ function modAnalyse( modules ) { var requireModules = []; each( modules, function ( module ) { if ( module.state !== <API key> ) { return; } var id = module.id; // normalize var depends = module.deps; var hardDepends = module.hardDeps; var hardDependsCount = isFunction( module.factory ) ? module.factory.length : 0; each( depends, function ( dependId, index ) { dependId = normalize( dependId, id ); depends[ index ] = dependId; if ( index < hardDependsCount ) { hardDepends[ dependId ] = 1; } } ); // id normalize // 1. require/exports/module // 2. dependenciesrequire // 3. dependencies var realDepends = module.realDeps; var len = realDepends.length; var existsDepend = {}; while ( len // normalizedepsrealDeps var dependId = normalize( realDepends[ len ], id ); if ( !dependId || dependId in existsDepend || dependId in BUILDIN_MODULE ) { realDepends.splice( len, 1 ); } else { existsDepend[ dependId ] = 1; realDepends[ len ] = dependId; // require requireModules.push( dependId ); } } module.realDepsIndex = existsDepend; module.state = <API key>; <API key>( module ); <API key>( id ); } ); nativeRequire( requireModules ); } /** * * factory * * @inner * @param {Object} module */ function <API key>( module ) { var id = module.id; module.invokeFactory = invokeFactory; invokeFactory(); var checkingLevel = 0; /** * * * @inner * @return {boolean} */ function <API key>() { checkingLevel++; var isReady = 1; var tryDeps = []; each( module.realDeps, function ( depId ) { if ( !modIsAnalyzed( depId ) ) { isReady = 0; } else if ( !modIsDefined( depId ) ) { switch ( <API key>( id, depId ) ) { case <API key>: case CIRCULAR_DEP_NO: isReady = 0; break; case CIRCULAR_DEP_YES: if ( module.hardDeps[ depId ] ) { tryDeps.push( depId ); } break; } } return !!isReady; } ); isReady && each( tryDeps, function ( depId ) { modTryInvokeFactory( depId ); } ); isReady = isReady && tryDeps.length === 0; isReady && (module.state = MODULE_STATE_READY); checkingLevel return isReady; } /** * * * @inner */ function invokeFactory() { if ( module.state == <API key> || checkingLevel > 1 || !<API key>() ) { return; } // factorymodule try { var factory = module.factory; var exports = isFunction( factory ) ? factory.apply( global, <API key>( module.deps, { require : createLocalRequire( id ), exports : module.exports, module : module } ) ) : factory; if ( typeof exports != 'undefined' ) { module.exports = exports; } module.state = <API key>; module.invokeFactory = null; } catch ( ex ) { if ( /^\[MODULE_MISS\]"([^"]+)/.test( ex.message ) ) { // factoryrequire module.hardDeps[ RegExp.$1 ] = 1; return; } throw ex; } <API key>( id ); modFireDefined( id ); } } /** * idexports * factoryrequirecallback * * @inner * @param {Array} modules id * @param {Object} buildinModules * @return {Array} */ function <API key>( modules, buildinModules ) { var args = []; each( modules, function ( moduleId, index ) { args[ index ] = buildinModules[ moduleId ] || modGetModuleExports( moduleId ); } ); return args; } var <API key> = 0; var CIRCULAR_DEP_NO = 1; var CIRCULAR_DEP_YES = 2; /** * sourcetarget * * @inner * @return {number} */ function <API key>( source, target, meet ) { if ( !modIsAnalyzed( target ) ) { return <API key>; } meet = meet || {}; meet[ target ] = 1; if ( target == source ) { return CIRCULAR_DEP_YES; } var module = modGetModule( target ); var depends = module && module.realDeps; if ( depends ) { var len = depends.length; while ( len var dependId = depends[ len ]; if ( meet[ dependId ] ) { continue; } var state = <API key>( source, dependId, meet ); switch ( state ) { case <API key>: case CIRCULAR_DEP_YES: return state; } } } return CIRCULAR_DEP_NO; } /** * * * @inner * @param {string} id id */ function <API key>( id ) { for ( var key in modModules ) { var realDeps = modModules[ key ].realDepsIndex || {}; realDeps[ id ] && modTryInvokeFactory( key ); } } /** * factory * * @inner * @param {string} id id */ function modTryInvokeFactory( id ) { var module = modModules[ id ]; if ( module && module.invokeFactory ) { module.invokeFactory(); } } /** * * * @inner * @type {Array} */ var modDefinedListener = []; /** * * * @inner * @type {Array} */ var <API key> = []; /** * fire * * @inner * @type {number} */ var modFireLevel = 0; /** * * * @inner * @param {string} id */ function modFireDefined( id ) { modFireLevel++; each( modDefinedListener, function ( listener ) { listener && listener( id ); } ); modFireLevel <API key>(); } /** * * modRemoveDefinedListener * modFireDefined * * @inner * @param {Function} listener */ function <API key>() { if ( modFireLevel < 1 ) { <API key>.sort( function ( a, b ) { return b - a; } ); each( <API key>, function ( index ) { modDefinedListener.splice( index, 1 ); } ); <API key> = []; } } /** * * * @inner * @param {Function} listener */ function <API key>( listener ) { each( modDefinedListener, function ( item, index ) { if ( listener == item ) { <API key>.push( index ); } } ); } /** * * * @inner * @param {Function} listener */ function <API key>( listener ) { modDefinedListener.push( listener ); } /** * * * @inner * @param {string} id * @return {boolean} */ function modExists( id ) { return id in modModules; } /** * * * @inner * @param {string} id * @return {boolean} */ function modIsDefined( id ) { return modExists( id ) && modModules[ id ].state == <API key>; } /** * * * @inner * @param {string} id * @return {boolean} */ function modIsAnalyzed( id ) { return modExists( id ) && modModules[ id ].state >= <API key>; } /** * exports * * @inner * @param {string} id * @return {*} */ function modGetModuleExports( id ) { if ( modIsDefined( id ) ) { return modModules[ id ].exports; } return null; } /** * * * @inner * @param {string} id * @return {Object} */ function modGetModule( id ) { return modModules[ id ]; } /** * * * @inner * @param {string} resourceId * @param {*} value */ function modAddResource( resourceId, value ) { modModules[ resourceId ] = { exports: value || true, state: <API key> }; <API key>( resourceId ); modFireDefined( resourceId ); } /** * module * * @inner * @type {Object} */ var BUILDIN_MODULE = { require : require, exports : 1, module : 1 }; /** * * define * * @inner * @type {Array} */ var wait4PreDefines = []; /** * * * @inner */ function completePreDefine( currentId ) { var preDefines = wait4PreDefines.slice( 0 ); wait4PreDefines.length = 0; wait4PreDefines = []; // define each( preDefines, function ( module ) { var id = module.id || currentId; modPreDefine( id, module.deps, module.factory ); } ); modPreAnalyse(); } /** * * * @param {string|Array} ids * @param {Function=} callback * @return {Object} */ function nativeRequire( ids, callback, baseId ) { callback = callback || new Function(); baseId = baseId || ''; // It MUST throw an error if the module has not // already been loaded and evaluated. if ( isString( ids ) ) { if ( !modIsDefined( ids ) ) { throw new Error( '[MODULE_MISS]"' + ids + '" is not exists!' ); } return modGetModuleExports( ids ); } if ( !isArray( ids ) ) { return; } if ( ids.length === 0 ) { callback(); return; } var isCallbackCalled = 0; <API key>( tryFinishRequire ); each( ids, function ( id ) { if ( id in BUILDIN_MODULE ) { return; } ( id.indexOf( '!' ) > 0 ? loadResource : loadModule )( id, baseId ); } ); tryFinishRequire(); /** * requirecallback * * * @inner */ function tryFinishRequire() { if ( isCallbackCalled ) { return; } var visitedModule = {}; /** * * * @inner * @param {Array} modules * @return {boolean} */ function isAllInited( modules ) { var allInited = 1; each( modules, function ( id ) { if ( visitedModule[ id ] ) { return; } visitedModule[ id ] = 1; if ( BUILDIN_MODULE[ id ] ) { return; } if ( !modIsDefined( id ) || !isAllInited( modGetModule( id ).realDeps ) ) { allInited = 0; return false; } } ); return allInited; } // callback if ( isAllInited( ids ) ) { isCallbackCalled = 1; <API key>( tryFinishRequire ); callback.apply( global, <API key>( ids, BUILDIN_MODULE ) ); } } } /** * * * @inner * @type {Object} */ var loadingModules = {}; /** * * * @inner * @param {string} moduleId */ function loadModule( moduleId ) { if ( loadingModules[ moduleId ] ) { return; } if ( modExists( moduleId ) ) { modAnalyse( [ modGetModule( moduleId ) ] ); return; } loadingModules[ moduleId ] = 1; // script // onerror // devtoolconsole // throwError var script = document.createElement( 'script' ); script.setAttribute( 'data-require-id', moduleId ); script.src = toUrl( moduleId ) ; script.async = true; if ( script.readyState ) { script.onreadystatechange = loadedListener; } else { script.onload = loadedListener; } appendScript( script ); /** * script * * @inner */ function loadedListener() { var readyState = script.readyState; if ( typeof readyState == 'undefined' || /^(loaded|complete)$/.test( readyState ) ) { script.onload = script.onreadystatechange = null; script = null; completePreDefine( moduleId ); delete loadingModules[ moduleId ]; } } } /** * * * @inner * @param {string} pluginAndResource * @param {string} baseId */ function loadResource( pluginAndResource, baseId ) { var idInfo = parseId( pluginAndResource ); var pluginId = idInfo.module; var resourceId = idInfo.resource; /** * plugin * * @inner * @param {*} value resource */ function pluginOnload( value ) { modAddResource( pluginAndResource, value ); } /** * plugin * * @param {string} name id * @param {string} body */ pluginOnload.fromText = function ( id, text ) { new Function( text )(); completePreDefine( id ); }; /** * * * @inner * @param {Object} plugin */ function load( plugin ) { if ( !modIsDefined( pluginAndResource ) ) { plugin.load( resourceId, createLocalRequire( baseId ), pluginOnload, moduleConfigGetter.call( { id: pluginAndResource } ) ); } } if ( !modIsDefined( pluginId ) ) { nativeRequire( [ pluginId ], load ); } else { load( modGetModuleExports( pluginId ) ); } } /** * require * * @inner * @type {Object} */ var requireConf = { baseUrl : './', paths : {}, config : {}, map : {}, packages : [], waitSeconds : 0, urlArgs : {} }; /** * * * @inner * @param {string} name * @param {Any} value */ function mixConfig( name, value ) { var originValue = requireConf[ name ]; var type = typeof originValue; if ( type == 'string' || type == 'number' ) { requireConf[ name ] = value; } else if ( isArray( originValue ) ) { each( value, function ( item ) { originValue.push( item ); } ); } else { for ( var key in value ) { originValue[ key ] = value[ key ]; } } } /** * require * * @param {Object} conf */ require.config = function ( conf ) { // mix for ( var key in requireConf ) { if ( conf.hasOwnProperty( key ) ) { var confItem = conf[ key ]; if ( key == 'urlArgs' && isString( confItem ) ) { defaultUrlArgs = confItem; } else { mixConfig( key, confItem ); } } } createConfIndex(); }; createConfIndex(); /** * * * @inner */ function createConfIndex() { requireConf.baseUrl = requireConf.baseUrl.replace( /\/$/, '' ) + '/'; createPathsIndex(); <API key>(); createPackagesIndex(); createUrlArgsIndex(); } /** * packages * * @inner * @type {Array} */ var packagesIndex; /** * packages * * @inner */ function createPackagesIndex() { packagesIndex = []; each( requireConf.packages, function ( packageConf ) { var pkg = packageConf; if ( isString( packageConf ) ) { pkg = { name: packageConf.split('/')[ 0 ], location: packageConf, main: 'main' }; } pkg.location = pkg.location || pkg.name; pkg.main = (pkg.main || 'main').replace(/\.js$/i, ''); packagesIndex.push( pkg ); } ); packagesIndex.sort( createDescSorter( 'name' ) ); } /** * paths * * @inner * @type {Array} */ var pathsIndex; /** * paths * * @inner */ function createPathsIndex() { pathsIndex = kv2List( requireConf.paths ); pathsIndex.sort( createDescSorter() ); } /** * urlArgs * * @inner * @type {string} */ var defaultUrlArgs; /** * urlArgs * * @inner * @type {Array} */ var urlArgsIndex; /** * urlArgs * * @inner */ function createUrlArgsIndex() { urlArgsIndex = kv2List( requireConf.urlArgs ); urlArgsIndex.sort( createDescSorter() ); } /** * mapping * * @inner * @type {Array} */ var mappingIdIndex; /** * mapping * * @inner */ function <API key>() { mappingIdIndex = []; mappingIdIndex = kv2List( requireConf.map ); mappingIdIndex.sort( createDescSorter() ); each( mappingIdIndex, function ( item ) { var key = item.k; item.v = kv2List( item.v ); item.v.sort( createDescSorter() ); item.reg = key == '*' ? /^/ : createPrefixRegexp( key ); } ); } /** * `+'.extension'`url * * @inner * @param {string} source * @return {string} */ function toUrl( source ) { // .extension var extReg = /(\.[a-z0-9]+)$/i; var queryReg = /(\?[^ var extname = '.js'; var id = source; var query = ''; if ( queryReg.test( source ) ) { query = RegExp.$1; source = source.replace( queryReg, '' ); } if ( extReg.test( source ) ) { extname = RegExp.$1; id = source.replace( extReg, '' ); } if ( !MODULE_ID_REG.test( id ) ) { return source; } var url = id; // paths var isPathMap; each( pathsIndex, function ( item ) { var key = item.k; if ( createPrefixRegexp( key ).test( id ) ) { url = url.replace( key, item.v ); isPathMap = 1; return false; } } ); // packages if ( !isPathMap ) { each( packagesIndex, function ( packageConf ) { var name = packageConf.name; if ( createPrefixRegexp( name ).test( id ) ) { url = url.replace( name, packageConf.location ); return false; } } ); } // baseUrl if ( !/^([a-z]{2,10}:\/)?\//i.test( url ) ) { url = requireConf.baseUrl + url; } // .extension query url += extname + query; var isUrlArgsAppended; /** * urlurlArgs * * @inner * @param {string} args urlArgs */ function appendUrlArgs( args ) { if ( !isUrlArgsAppended ) { url += ( url.indexOf( '?' ) > 0 ? '&' : '?' ) + args; isUrlArgsAppended = 1; } } // urlArgs each( urlArgsIndex, function ( item ) { if ( createPrefixRegexp( item.k ).test( id ) ) { appendUrlArgs( item.v ); return false; } } ); defaultUrlArgs && appendUrlArgs( defaultUrlArgs ); return url; } /** * local require * * @inner * @param {number} baseId module id * @return {Function} */ function createLocalRequire( baseId ) { var requiredCache = {}; function req( requireId, callback ) { if ( isString( requireId ) ) { var requiredModule; if ( !( requiredModule = requiredCache[ requireId ] ) ) { requiredModule = nativeRequire( normalize( requireId, baseId ), callback, baseId ); requiredCache[ requireId ] = requiredModule; } return requiredModule; } else if ( isArray( requireId ) ) { // resourceplugin var <API key> = []; each( requireId, function ( id ) { var idInfo = parseId( id ); var pluginId = normalize( idInfo.module, baseId ); if ( idInfo.resource && !modIsDefined( pluginId ) ) { <API key>.push( pluginId ); } } ); nativeRequire( <API key>, function () { var ids = []; each( requireId, function ( id ) { ids.push( normalize( id, baseId ) ); } ); nativeRequire( ids, callback, baseId ); }, baseId ); } } /** * [module ID] + '.extension'url * * @inner * @param {string} source * @return {string} */ req.toUrl = function ( id ) { return toUrl( normalize( id, baseId ) ); }; return req; } /** * id normalize * * @inner * @param {string} id normalize * @param {string} baseId * @return {string} */ function normalize( id, baseId ) { if ( !id ) { return ''; } var idInfo = parseId( id ); if ( !idInfo ) { return id; } var resourceId = idInfo.resource; var moduleId = relative2absolute( idInfo.module, baseId ); each( packagesIndex, function ( packageConf ) { var name = packageConf.name; var main = name + '/' + packageConf.main; if ( name == moduleId ) { moduleId = moduleId.replace( name, main ); return false; } } ); moduleId = mappingId( moduleId, baseId ); if ( resourceId ) { var module = modGetModuleExports( moduleId ); resourceId = module && module.normalize ? module.normalize( resourceId, function ( resId ) { return normalize( resId, baseId ); } ) : normalize( resourceId, baseId ); return moduleId + '!' + resourceId; } return moduleId; } /** * idid * * @inner * @param {string} id id * @param {string} baseId id * @return {string} */ function relative2absolute( id, baseId ) { if ( /^\.{1,2}/.test( id ) ) { var basePath = baseId.split( '/' ); var namePath = id.split( '/' ); var baseLen = basePath.length - 1; var nameLen = namePath.length; var cutBaseTerms = 0; var cutNameTerms = 0; pathLoop: for ( var i = 0; i < nameLen; i++ ) { var term = namePath[ i ]; switch ( term ) { case '..': if ( cutBaseTerms < baseLen ) { cutBaseTerms++; cutNameTerms++; } else { break pathLoop; } break; case '.': cutNameTerms++; break; default: break pathLoop; } } basePath.length = baseLen - cutBaseTerms; namePath = namePath.slice( cutNameTerms ); basePath.push.apply( basePath, namePath ); return basePath.join( '/' ); } return id; } /** * requireididglobal require * * @inner * @param {string|Array} requireId requireid */ function <API key>( requireId ) { var invalidIds = []; /** * idrelative id * * @inner * @param {string} id id */ function monitor( id ) { if ( /^\.{1,2}/.test( id ) ) { invalidIds.push( id ); } } if ( isString( requireId ) ) { monitor( requireId ); } else { each( requireId, function ( id ) { monitor( id ); } ); } if ( invalidIds.length > 0 ) { throw new Error( '[REQUIRE_FATAL]Relative ID is not allowed in global require: ' + invalidIds.join( ', ' ) ); } } /** * id * * @const * @inner * @type {RegExp} */ var MODULE_ID_REG = /^[-_a-z0-9\.]+(\/[-_a-z0-9\.]+)*$/i; /** * idmoduleresourceObject * * @inner * @param {string} id * @return {Object} */ function parseId( id ) { var segs = id.split( '!' ); if ( MODULE_ID_REG.test( segs[ 0 ] ) ) { return { module : segs[ 0 ], resource : segs[ 1 ] || '' }; } return null; } /** * mapid * * @inner * @param {string} id id * @param {string} baseId id * @return {string} */ function mappingId( id, baseId ) { each( mappingIdIndex, function ( item ) { if ( item.reg.test( baseId ) ) { each( item.v, function ( mapData ) { var key = mapData.k; var rule = createPrefixRegexp( key ); if ( rule.test( id ) ) { id = id.replace( key, mapData.v ); return false; } } ); return false; } } ); return id; } /** * kvObject * * @inner * @param {Object} source * @return {Array.<Object>} */ function kv2List( source ) { var list = []; for ( var key in source ) { if ( source.hasOwnProperty( key ) ) { list.push( { k: key, v: source[ key ] } ); } } return list; } // requirejscurrentlyAddingScriptie // For some cache cases in IE 6-8, the script executes before the end // of the appendChild execution, so to tie an anonymous define // call to the module name (which is stored on the node), hold on // to a reference to this node, but clear after the DOM insertion. var <API key>; var interactiveScript; /** * script * iedefinemodule idid * * @inner * @return {HTMLDocument} */ function getCurrentScript() { if ( <API key> ) { return <API key>; } else if ( interactiveScript && interactiveScript.readyState == 'interactive' ) { return interactiveScript; } else { var scripts = document.<API key>( 'script' ); var scriptLen = scripts.length; while ( scriptLen var script = scripts[ scriptLen ]; if ( script.readyState == 'interactive' ) { interactiveScript = script; return script; } } } } /** * script * * @inner * @param {HTMLScriptElement} script script */ function appendScript( script ) { <API key> = script; var doc = document; (doc.<API key>('head')[0] || doc.body).appendChild( script ); <API key> = null; } /** * id * * @inner * @param {string} prefix id * @return {RegExp} */ function createPrefixRegexp( prefix ) { return new RegExp( '^' + prefix + '(/|$)' ); } /** * * * @inner * @param {*} obj * @return {boolean} */ function isArray( obj ) { return obj instanceof Array; } /** * * * @inner * @param {*} obj * @return {boolean} */ function isFunction( obj ) { return typeof obj == 'function'; } /** * * * @inner * @param {*} obj * @return {boolean} */ function isString( obj ) { return typeof obj == 'string'; } /** * * * @inner * @param {Array} source * @param {function(Array,Number):boolean} iterator */ function each( source, iterator ) { if ( isArray( source ) ) { for ( var i = 0, len = source.length; i < len; i++ ) { if ( iterator( source[ i ], i ) === false ) { break; } } } } /** * * * @inner * @param {string} property * @return {Function} */ function createDescSorter( property ) { property = property || 'k'; return function ( a, b ) { var aValue = a[ property ]; var bValue = b[ property ]; if ( bValue == '*' ) { return -1; } if ( aValue == '*' ) { return 1; } return bValue.length - aValue.length; }; } global.define = define; global.require = require; })( this );
using System; public class T { public static bool test(ref Object[] arr, ref Object o, int index) { GC.Collect(); if (arr[index] == null) { Console.WriteLine("null"); return false; } if (arr[index] != o) { return false; } for (int i = 0; i < arr.Length; i++) { Console.WriteLine(arr[i]); } return (true); } static Object[] o = new Object[5]; public static int Main() { o[1] = "1"; o[2] = "2"; o[3] = "3"; if (test(ref o, ref o[2], 2)) return 100; //error return 1; } }
using System.Collections.Generic; using Xunit; namespace System.ComponentModel.Tests { public partial class <API key> { [Fact] public static void Ctor_netcoreapp11() { Assert.Equal((sbyte)42, new <API key>((sbyte)42).Value); Assert.Equal((ushort)42, new <API key>((ushort)42).Value); Assert.Equal((uint)42, new <API key>((uint)42).Value); Assert.Equal((ulong)42, new <API key>((ulong)42).Value); } } }
(function( root, factory ) { if( typeof define === 'function' && define.amd ) { // AMD. Register as an anonymous module. define( function() { root.Reveal = factory(); return root.Reveal; } ); } else if( typeof exports === 'object' ) { // Node. Does not work with strict CommonJS. module.exports = factory(); } else { // Browser globals. root.Reveal = factory(); } }( this, function() { 'use strict'; var Reveal; // The reveal.js version var VERSION = '3.6.0'; var SLIDES_SELECTOR = '.slides section', <API key> = '.slides>section', <API key> = '.slides>section.present>section', HOME_SLIDE_SELECTOR = '.slides>section:first-of-type', UA = navigator.userAgent, // Configuration defaults, can be overridden at initialization time config = { // The "normal" size of the presentation, aspect ratio will be preserved // when the presentation is scaled to fit different resolutions width: 960, height: 700, // Factor of the display size that should remain empty around the content margin: 0.04, // Bounds for smallest/largest possible scale to apply to content minScale: 0.2, maxScale: 2.0, // Display presentation control arrows controls: true, // Help the user learn the controls by providing hints, for example by // bouncing the down arrow when they first encounter a vertical slide controlsTutorial: true, // Determines where controls appear, "edges" or "bottom-right" controlsLayout: 'bottom-right', // Visibility rule for backwards navigation arrows; "faded", "hidden" // or "visible" controlsBackArrows: 'faded', // Display a presentation progress bar progress: true, // Display the page number of the current slide slideNumber: false, // Determine which displays to show the slide number on showSlideNumber: 'all', // Push each slide change to the browser history history: false, // Enable keyboard shortcuts for navigation keyboard: true, // Optional function that blocks keyboard events when retuning false keyboardCondition: null, // Enable the slide overview mode overview: true, // Vertical centering of slides center: true, // Enables touch navigation on devices with touch input touch: true, // Loop the presentation loop: false, // Change the presentation direction to be RTL rtl: false, // Randomizes the order of slides each time the presentation loads shuffle: false, // Turns fragments on and off globally fragments: true, // Flags if the presentation is running in an embedded mode, // i.e. contained within a limited portion of the screen embedded: false, // Flags if we should show a help overlay when the question-mark // key is pressed help: true, // Flags if it should be possible to pause the presentation (blackout) pause: true, // Flags if speaker notes should be visible to all viewers showNotes: false, // Global override for autolaying embedded media (video/audio/iframe) // - null: Media will only autoplay if data-autoplay is present // - true: All media will autoplay, regardless of individual setting // - false: No media will autoplay, regardless of individual setting autoPlayMedia: null, // Controls automatic progression to the next slide // - 0: Auto-sliding only happens if the data-autoslide HTML attribute // is present on the current slide or fragment // - 1+: All slides will progress automatically at the given interval // - false: No auto-sliding, even if data-autoslide is present autoSlide: 0, // Stop auto-sliding after user input autoSlideStoppable: true, // Use this method for navigation when auto-sliding (defaults to navigateNext) autoSlideMethod: null, // Enable slide navigation via mouse wheel mouseWheel: false, // Apply a 3D roll to links on hover rollingLinks: false, // Hides the address bar on mobile devices hideAddressBar: true, // Opens links in an iframe preview overlay // Add `data-preview-link` and `data-preview-link="false"` to customise each link // individually previewLinks: false, // Exposes the reveal.js API through window.postMessage postMessage: true, // Dispatches all reveal.js events to the parent window through postMessage postMessageEvents: false, // Focuses body when page changes visibility to ensure keyboard shortcuts work <API key>: true, // Transition style transition: 'slide', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds <API key>: 'fade', // none/fade/slide/convex/concave/zoom // Parallax background image <API key>: '', // CSS syntax, e.g. "a.jpg" // Parallax background size <API key>: '', // CSS syntax, e.g. "3000px 2000px" // Amount of pixels to move the parallax background per slide step <API key>: null, <API key>: null, // The maximum number of pages a single slide can expand onto when printing // to PDF, unlimited by default pdfMaxPagesPerSlide: Number.POSITIVE_INFINITY, // Offset used to reduce the height of content within exported PDF pages. // This exists to account for environment differences based on how you // print to PDF. CLI printing options, like phantomjs and wkpdf, can end // on precisely the total height of the document whereas in-browser // printing has to end one pixel before. pdfPageHeightOffset: -1, // Number of slides away from the current that are visible viewDistance: 3, // The display mode that will be used to show slides display: 'block', // Script dependencies to load dependencies: [] }, // Flags if Reveal.initialize() has been called initialized = false, // Flags if reveal.js is loaded (has dispatched the 'ready' event) loaded = false, // Flags if the overview mode is currently active overview = false, // Holds the dimensions of our overview slides, including margins overviewSlideWidth = null, overviewSlideHeight = null, // The horizontal and vertical index of the currently active slide indexh, indexv, // The previous and current slide HTML elements previousSlide, currentSlide, previousBackground, // Remember which directions that the user has navigated towards hasNavigatedRight = false, hasNavigatedDown = false, // Slides may hold a data-state attribute which we pick up and apply // as a class to the body. This list contains the combined state of // all current slides. state = [], // The current scale of the presentation (see width/height config) scale = 1, // CSS transform that is currently applied to the slides container, // split into two groups slidesTransform = { layout: '', overview: '' }, // Cached references to DOM elements dom = {}, // Features supported by the browser, see #checkCapabilities() features = {}, // Client is a mobile device, see #checkCapabilities() isMobileDevice, // Client is a desktop Chrome, see #checkCapabilities() isChrome, // Throttles mouse wheel navigation lastMouseWheelStep = 0, // Delays updates to the URL due to a Chrome thumbnailer bug writeURLTimeout = 0, // Flags if the interaction event listeners are bound eventsAreBound = false, // The current auto-slide duration autoSlide = 0, // Auto slide properties autoSlidePlayer, autoSlideTimeout = 0, autoSlideStartTime = -1, autoSlidePaused = false, // Holds information about the currently ongoing touch input touch = { startX: 0, startY: 0, startSpan: 0, startCount: 0, captured: false, threshold: 40 }, // Holds information about the keyboard shortcuts keyboardShortcuts = { 'N , SPACE': 'Next slide', 'P': 'Previous slide', '&#8592; , H': 'Navigate left', '&#8594; , L': 'Navigate right', '&#8593; , K': 'Navigate up', '&#8595; , J': 'Navigate down', 'Home': 'First slide', 'End': 'Last slide', 'B , .': 'Pause', 'F': 'Fullscreen', 'ESC, O': 'Slide overview' }; /** * Starts up the presentation if the client is capable. */ function initialize( options ) { // Make sure we only initialize once if( initialized === true ) return; initialized = true; checkCapabilities(); if( !features.transforms2d && !features.transforms3d ) { document.body.setAttribute( 'class', 'no-transforms' ); // Since JS won't be running any further, we load all lazy // loading elements upfront var images = toArray( document.<API key>( 'img' ) ), iframes = toArray( document.<API key>( 'iframe' ) ); var lazyLoadable = images.concat( iframes ); for( var i = 0, len = lazyLoadable.length; i < len; i++ ) { var element = lazyLoadable[i]; if( element.getAttribute( 'data-src' ) ) { element.setAttribute( 'src', element.getAttribute( 'data-src' ) ); element.removeAttribute( 'data-src' ); } } // If the browser doesn't support core features we won't be // using JavaScript to control the presentation return; } // Cache references to key DOM elements dom.wrapper = document.querySelector( '.reveal' ); dom.slides = document.querySelector( '.reveal .slides' ); // Force a layout when the whole page, incl fonts, has loaded window.addEventListener( 'load', layout, false ); var query = Reveal.getQueryHash(); // Do not accept new dependencies via query config to avoid // the potential of malicious script injection if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies']; // Copy options over to our config object extend( config, options ); extend( config, query ); // Hide the address bar in mobile browsers hideAddressBar(); // Loads the dependencies and continues to #start() once done load(); } /** * Inspect the client to see what it's capable of, this * should only happens once per runtime. */ function checkCapabilities() { isMobileDevice = /(iphone|ipod|ipad|android)/gi.test( UA ); isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA ); var testElement = document.createElement( 'div' ); features.transforms3d = 'WebkitPerspective' in testElement.style || 'MozPerspective' in testElement.style || 'msPerspective' in testElement.style || 'OPerspective' in testElement.style || 'perspective' in testElement.style; features.transforms2d = 'WebkitTransform' in testElement.style || 'MozTransform' in testElement.style || 'msTransform' in testElement.style || 'OTransform' in testElement.style || 'transform' in testElement.style; features.<API key> = window.<API key> || window.<API key> || window.<API key>; features.<API key> = typeof features.<API key> === 'function'; features.canvas = !!document.createElement( 'canvas' ).getContext; // Transitions in the overview are disabled in desktop and // Safari due to lag features.overviewTransitions = !/Version\/[\d\.]+.*Safari/.test( UA ); // Flags if we should use zoom instead of transform to scale // up slides. Zoom produces crisper results but has a lot of // xbrowser quirks so we only use it in whitelsited browsers. features.zoom = 'zoom' in testElement.style && !isMobileDevice && ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) ); } /** * Loads the dependencies of reveal.js. Dependencies are * defined via the configuration option 'dependencies' * and will be loaded prior to starting/binding reveal.js. * Some dependencies may have an 'async' flag, if so they * will load after reveal.js has been started up. */ function load() { var scripts = [], scriptsAsync = [], scriptsToPreload = 0; // Called once synchronous scripts finish loading function proceed() { if( scriptsAsync.length ) { // Load asynchronous scripts head.js.apply( null, scriptsAsync ); } start(); } function loadScript( s ) { head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], function() { // Extension may contain callback functions if( typeof s.callback === 'function' ) { s.callback.apply( this ); } if( --scriptsToPreload === 0 ) { proceed(); } }); } for( var i = 0, len = config.dependencies.length; i < len; i++ ) { var s = config.dependencies[i]; // Load if there's no condition or the condition is truthy if( !s.condition || s.condition() ) { if( s.async ) { scriptsAsync.push( s.src ); } else { scripts.push( s.src ); } loadScript( s ); } } if( scripts.length ) { scriptsToPreload = scripts.length; // Load synchronous scripts head.js.apply( null, scripts ); } else { proceed(); } } /** * Starts up reveal.js by binding input events and navigating * to the current URL deeplink if there is one. */ function start() { loaded = true; // Make sure we've got all the DOM elements we need setupDOM(); // Listen to messages posted to this window setupPostMessage(); // Prevent the slides from being scrolled out of view <API key>(); // Resets all vertical slides so that only the first is visible resetVerticalSlides(); // Updates the presentation to match the current configuration values configure(); // Read the initial hash readURL(); // Update all backgrounds updateBackground( true ); // Notify listeners that the presentation is ready but use a 1ms // timeout to ensure it's not fired synchronously after #initialize() setTimeout( function() { // Enable transitions now that we're loaded dom.slides.classList.remove( 'no-transition' ); dom.wrapper.classList.add( 'ready' ); dispatchEvent( 'ready', { 'indexh': indexh, 'indexv': indexv, 'currentSlide': currentSlide } ); }, 1 ); // Special setup and config is required when printing to PDF if( isPrintingPDF() ) { <API key>(); // The document needs to have loaded for the PDF layout // measurements to be accurate if( document.readyState === 'complete' ) { setupPDF(); } else { window.addEventListener( 'load', setupPDF ); } } } /** * Finds and stores references to DOM elements which are * required by the presentation. If a required element is * not found, it is created. */ function setupDOM() { // Prevent transitions while we're loading dom.slides.classList.add( 'no-transition' ); if( isMobileDevice ) { dom.wrapper.classList.add( 'no-hover' ); } else { dom.wrapper.classList.remove( 'no-hover' ); } if( /iphone/gi.test( UA ) ) { dom.wrapper.classList.add( 'ua-iphone' ); } else { dom.wrapper.classList.remove( 'ua-iphone' ); } // Background element dom.background = createSingletonNode( dom.wrapper, 'div', 'backgrounds', null ); // Progress bar dom.progress = createSingletonNode( dom.wrapper, 'div', 'progress', '<span></span>' ); dom.progressbar = dom.progress.querySelector( 'span' ); // Arrow controls dom.controls = createSingletonNode( dom.wrapper, 'aside', 'controls', '<button class="navigate-left" aria-label="previous slide"><div class="controls-arrow"></div></button>' + '<button class="navigate-right" aria-label="next slide"><div class="controls-arrow"></div></button>' + '<button class="navigate-up" aria-label="above slide"><div class="controls-arrow"></div></button>' + '<button class="navigate-down" aria-label="below slide"><div class="controls-arrow"></div></button>' ); // Slide number dom.slideNumber = createSingletonNode( dom.wrapper, 'div', 'slide-number', '' ); // Element containing notes that are visible to the audience dom.speakerNotes = createSingletonNode( dom.wrapper, 'div', 'speaker-notes', null ); dom.speakerNotes.setAttribute( 'data-prevent-swipe', '' ); dom.speakerNotes.setAttribute( 'tabindex', '0' ); // Overlay graphic which is displayed during the paused mode createSingletonNode( dom.wrapper, 'div', 'pause-overlay', null ); dom.wrapper.setAttribute( 'role', 'application' ); // There can be multiple instances of controls throughout the page dom.controlsLeft = toArray( document.querySelectorAll( '.navigate-left' ) ); dom.controlsRight = toArray( document.querySelectorAll( '.navigate-right' ) ); dom.controlsUp = toArray( document.querySelectorAll( '.navigate-up' ) ); dom.controlsDown = toArray( document.querySelectorAll( '.navigate-down' ) ); dom.controlsPrev = toArray( document.querySelectorAll( '.navigate-prev' ) ); dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) ); // The right and down arrows in the standard reveal.js controls dom.controlsRightArrow = dom.controls.querySelector( '.navigate-right' ); dom.controlsDownArrow = dom.controls.querySelector( '.navigate-down' ); dom.statusDiv = createStatusDiv(); } /** * Creates a hidden div with role aria-live to announce the * current slide content. Hide the div off-screen to make it * available only to Assistive Technologies. * * @return {HTMLElement} */ function createStatusDiv() { var statusDiv = document.getElementById( 'aria-status-div' ); if( !statusDiv ) { statusDiv = document.createElement( 'div' ); statusDiv.style.position = 'absolute'; statusDiv.style.height = '1px'; statusDiv.style.width = '1px'; statusDiv.style.overflow = 'hidden'; statusDiv.style.clip = 'rect( 1px, 1px, 1px, 1px )'; statusDiv.setAttribute( 'id', 'aria-status-div' ); statusDiv.setAttribute( 'aria-live', 'polite' ); statusDiv.setAttribute( 'aria-atomic','true' ); dom.wrapper.appendChild( statusDiv ); } return statusDiv; } /** * Converts the given HTML element into a string of text * that can be announced to a screen reader. Hidden * elements are excluded. */ function getStatusText( node ) { var text = ''; // Text node if( node.nodeType === 3 ) { text += node.textContent; } // Element node else if( node.nodeType === 1 ) { var isAriaHidden = node.getAttribute( 'aria-hidden' ); var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none'; if( isAriaHidden !== 'true' && !isDisplayHidden ) { toArray( node.childNodes ).forEach( function( child ) { text += getStatusText( child ); } ); } } return text; } /** * Configures the presentation for printing to a static * PDF. */ function setupPDF() { var slideSize = <API key>( window.innerWidth, window.innerHeight ); // Dimensions of the PDF pages var pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ), pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) ); // Dimensions of slides within the pages var slideWidth = slideSize.width, slideHeight = slideSize.height; // Let the browser know what page size we want to print injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0px;}' ); // Limit the size of certain elements to the dimensions of the slide injectStyleSheet( '.reveal section>img, .reveal section>video, .reveal section>iframe{max-width: '+ slideWidth +'px; max-height:'+ slideHeight +'px}' ); document.body.classList.add( 'print-pdf' ); document.body.style.width = pageWidth + 'px'; document.body.style.height = pageHeight + 'px'; // Make sure stretch elements fit on slide layoutSlideContents( slideWidth, slideHeight ); // Add each slide's index as attributes on itself, we need these // indices to generate slide numbers below toArray( dom.wrapper.querySelectorAll( <API key> ) ).forEach( function( hslide, h ) { hslide.setAttribute( 'data-index-h', h ); if( hslide.classList.contains( 'stack' ) ) { toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) { vslide.setAttribute( 'data-index-h', h ); vslide.setAttribute( 'data-index-v', v ); } ); } } ); // Slide and slide background layout toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) { // Vertical stacks are not centred since their section // children will be if( slide.classList.contains( 'stack' ) === false ) { // Center the slide inside of the page, giving the slide some margin var left = ( pageWidth - slideWidth ) / 2, top = ( pageHeight - slideHeight ) / 2; var contentHeight = slide.scrollHeight; var numberOfPages = Math.max( Math.ceil( contentHeight / pageHeight ), 1 ); // Adhere to configured pages per slide limit numberOfPages = Math.min( numberOfPages, config.pdfMaxPagesPerSlide ); // Center slides vertically if( numberOfPages === 1 && config.center || slide.classList.contains( 'center' ) ) { top = Math.max( ( pageHeight - contentHeight ) / 2, 0 ); } // Wrap the slide in a page element and hide its overflow // so that no page ever flows onto another var page = document.createElement( 'div' ); page.className = 'pdf-page'; page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px'; slide.parentNode.insertBefore( page, slide ); page.appendChild( slide ); // Position the slide inside of the page slide.style.left = left + 'px'; slide.style.top = top + 'px'; slide.style.width = slideWidth + 'px'; if( slide.<API key> ) { page.insertBefore( slide.<API key>, slide ); } // Inject notes if `showNotes` is enabled if( config.showNotes ) { // Are there notes for this slide? var notes = getSlideNotes( slide ); if( notes ) { var notesSpacing = 8; var notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline'; var notesElement = document.createElement( 'div' ); notesElement.classList.add( 'speaker-notes' ); notesElement.classList.add( 'speaker-notes-pdf' ); notesElement.setAttribute( 'data-layout', notesLayout ); notesElement.innerHTML = notes; if( notesLayout === 'separate-page' ) { page.parentNode.insertBefore( notesElement, page.nextSibling ); } else { notesElement.style.left = notesSpacing + 'px'; notesElement.style.bottom = notesSpacing + 'px'; notesElement.style.width = ( pageWidth - notesSpacing*2 ) + 'px'; page.appendChild( notesElement ); } } } // Inject slide numbers if `slideNumbers` are enabled if( config.slideNumber && /all|print/i.test( config.showSlideNumber ) ) { var slideNumberH = parseInt( slide.getAttribute( 'data-index-h' ), 10 ) + 1, slideNumberV = parseInt( slide.getAttribute( 'data-index-v' ), 10 ) + 1; var numberElement = document.createElement( 'div' ); numberElement.classList.add( 'slide-number' ); numberElement.classList.add( 'slide-number-pdf' ); numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV ); page.appendChild( numberElement ); } } } ); // Show all fragments toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' .fragment' ) ).forEach( function( fragment ) { fragment.classList.add( 'visible' ); } ); // Notify subscribers that the PDF layout is good to go dispatchEvent( 'pdf-ready' ); } function <API key>() { setInterval( function() { if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) { dom.wrapper.scrollTop = 0; dom.wrapper.scrollLeft = 0; } }, 1000 ); } /** * Creates an HTML element and returns a reference to it. * If the element already exists the existing instance will * be returned. * * @param {HTMLElement} container * @param {string} tagname * @param {string} classname * @param {string} innerHTML * * @return {HTMLElement} */ function createSingletonNode( container, tagname, classname, innerHTML ) { // Find all nodes matching the description var nodes = container.querySelectorAll( '.' + classname ); // Check all matches to find one which is a direct child of // the specified container for( var i = 0; i < nodes.length; i++ ) { var testNode = nodes[i]; if( testNode.parentNode === container ) { return testNode; } } // If no node was found, create it now var node = document.createElement( tagname ); node.className = classname; if( typeof innerHTML === 'string' ) { node.innerHTML = innerHTML; } container.appendChild( node ); return node; } /** * Creates the slide background elements and appends them * to the background container. One element is created per * slide no matter if the given slide has visible background. */ function createBackgrounds() { var printMode = isPrintingPDF(); // Clear prior backgrounds dom.background.innerHTML = ''; dom.background.classList.add( 'no-transition' ); // Iterate over all horizontal slides toArray( dom.wrapper.querySelectorAll( <API key> ) ).forEach( function( slideh ) { var backgroundStack = createBackground( slideh, dom.background ); // Iterate over all vertical slides toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) { createBackground( slidev, backgroundStack ); backgroundStack.classList.add( 'stack' ); } ); } ); // Add parallax background if specified if( config.<API key> ) { dom.background.style.backgroundImage = 'url("' + config.<API key> + '")'; dom.background.style.backgroundSize = config.<API key>; // Make sure the below properties are set on the element - these properties are // needed for proper transitions to be set on the element via CSS. To remove // annoying background slide-in effect when the presentation starts, apply // these properties after short time delay setTimeout( function() { dom.wrapper.classList.add( '<API key>' ); }, 1 ); } else { dom.background.style.backgroundImage = ''; dom.wrapper.classList.remove( '<API key>' ); } } /** * Creates a background for the given slide. * * @param {HTMLElement} slide * @param {HTMLElement} container The element that the background * should be appended to * @return {HTMLElement} New background div */ function createBackground( slide, container ) { var data = { background: slide.getAttribute( 'data-background' ), backgroundSize: slide.getAttribute( '<API key>' ), backgroundImage: slide.getAttribute( '<API key>' ), backgroundVideo: slide.getAttribute( '<API key>' ), backgroundIframe: slide.getAttribute( '<API key>' ), backgroundColor: slide.getAttribute( '<API key>' ), backgroundRepeat: slide.getAttribute( '<API key>' ), backgroundPosition: slide.getAttribute( '<API key>' ), <API key>: slide.getAttribute( '<API key>' ) }; var element = document.createElement( 'div' ); // Carry over custom classes from the slide to the background element.className = 'slide-background ' + slide.className.replace( /present|past|future/, '' ); if( data.background ) { // Auto-wrap image urls in url(...) if( /^(http|file|\/\/)/gi.test( data.background ) || /\.(svg|png|jpg|jpeg|gif|bmp)([?#]|$)/gi.test( data.background ) ) { slide.setAttribute( '<API key>', data.background ); } else { element.style.background = data.background; } } // Create a hash for this combination of background settings. // This is used to determine when two slide backgrounds are // the same. if( data.background || data.backgroundColor || data.backgroundImage || data.backgroundVideo || data.backgroundIframe ) { element.setAttribute( '<API key>', data.background + data.backgroundSize + data.backgroundImage + data.backgroundVideo + data.backgroundIframe + data.backgroundColor + data.backgroundRepeat + data.backgroundPosition + data.<API key> ); } // Additional and optional background properties if( data.backgroundSize ) element.style.backgroundSize = data.backgroundSize; if( data.backgroundSize ) element.setAttribute( '<API key>', data.backgroundSize ); if( data.backgroundColor ) element.style.backgroundColor = data.backgroundColor; if( data.backgroundRepeat ) element.style.backgroundRepeat = data.backgroundRepeat; if( data.backgroundPosition ) element.style.backgroundPosition = data.backgroundPosition; if( data.<API key> ) element.setAttribute( '<API key>', data.<API key> ); container.appendChild( element ); // If backgrounds are being recreated, clear old classes slide.classList.remove( 'has-dark-background' ); slide.classList.remove( '<API key>' ); slide.<API key> = element; // If this slide has a background color, add a class that // signals if it is light or dark. If the slide has no background // color, no class will be set var <API key> = window.getComputedStyle( element ); if( <API key> && <API key>.backgroundColor ) { var rgb = colorToRgb( <API key>.backgroundColor ); // Ignore fully transparent backgrounds. Some browsers return // rgba(0,0,0,0) when reading the computed background color of // an element with no background if( rgb && rgb.a !== 0 ) { if( colorBrightness( <API key>.backgroundColor ) < 128 ) { slide.classList.add( 'has-dark-background' ); } else { slide.classList.add( '<API key>' ); } } } return element; } /** * Registers a listener to postMessage events, this makes it * possible to call all reveal.js API methods from another * window. For example: * * revealWindow.postMessage( JSON.stringify({ * method: 'slide', * args: [ 2 ] * }), '*' ); */ function setupPostMessage() { if( config.postMessage ) { window.addEventListener( 'message', function ( event ) { var data = event.data; // Make sure we're dealing with JSON if( typeof data === 'string' && data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) { data = JSON.parse( data ); // Check if the requested method can be found if( data.method && typeof Reveal[data.method] === 'function' ) { Reveal[data.method].apply( Reveal, data.args ); } } }, false ); } } /** * Applies the configuration settings from the config * object. May be called multiple times. * * @param {object} options */ function configure( options ) { var oldTransition = config.transition; // New config options may be passed when this method // is invoked through the API after initialization if( typeof options === 'object' ) extend( config, options ); // Abort if reveal.js hasn't finished loading, config // changes will be applied automatically once loading // finishes if( loaded === false ) return; var numberOfSlides = dom.wrapper.querySelectorAll( SLIDES_SELECTOR ).length; // Remove the previously configured transition class dom.wrapper.classList.remove( oldTransition ); // Force linear transition based on browser capabilities if( features.transforms3d === false ) config.transition = 'linear'; dom.wrapper.classList.add( config.transition ); dom.wrapper.setAttribute( '<API key>', config.transitionSpeed ); dom.wrapper.setAttribute( '<API key>', config.<API key> ); dom.controls.style.display = config.controls ? 'block' : 'none'; dom.progress.style.display = config.progress ? 'block' : 'none'; dom.controls.setAttribute( '<API key>', config.controlsLayout ); dom.controls.setAttribute( '<API key>', config.controlsBackArrows ); if( config.shuffle ) { shuffle(); } if( config.rtl ) { dom.wrapper.classList.add( 'rtl' ); } else { dom.wrapper.classList.remove( 'rtl' ); } if( config.center ) { dom.wrapper.classList.add( 'center' ); } else { dom.wrapper.classList.remove( 'center' ); } // Exit the paused mode if it was configured off if( config.pause === false ) { resume(); } if( config.showNotes ) { dom.speakerNotes.setAttribute( 'data-layout', typeof config.showNotes === 'string' ? config.showNotes : 'inline' ); } if( config.mouseWheel ) { document.addEventListener( 'DOMMouseScroll', <API key>, false ); document.addEventListener( 'mousewheel', <API key>, false ); } else { document.removeEventListener( 'DOMMouseScroll', <API key>, false ); document.removeEventListener( 'mousewheel', <API key>, false ); } // Rolling 3D links if( config.rollingLinks ) { enableRollingLinks(); } else { disableRollingLinks(); } // Iframe link previews if( config.previewLinks ) { enablePreviewLinks(); disablePreviewLinks( '[data-preview-link=false]' ); } else { disablePreviewLinks(); enablePreviewLinks( '[data-preview-link]:not([data-preview-link=false])' ); } // Remove existing auto-slide controls if( autoSlidePlayer ) { autoSlidePlayer.destroy(); autoSlidePlayer = null; } // Generate auto-slide controls if needed if( numberOfSlides > 1 && config.autoSlide && config.autoSlideStoppable && features.canvas && features.<API key> ) { autoSlidePlayer = new Playback( dom.wrapper, function() { return Math.min( Math.max( ( Date.now() - autoSlideStartTime ) / autoSlide, 0 ), 1 ); } ); autoSlidePlayer.on( 'click', <API key> ); autoSlidePaused = false; } // When fragments are turned off they should be visible if( config.fragments === false ) { toArray( dom.slides.querySelectorAll( '.fragment' ) ).forEach( function( element ) { element.classList.add( 'visible' ); element.classList.remove( 'current-fragment' ); } ); } // Slide numbers var slideNumberDisplay = 'none'; if( config.slideNumber && !isPrintingPDF() ) { if( config.showSlideNumber === 'all' ) { slideNumberDisplay = 'block'; } else if( config.showSlideNumber === 'speaker' && isSpeakerNotes() ) { slideNumberDisplay = 'block'; } } dom.slideNumber.style.display = slideNumberDisplay; sync(); } /** * Binds all event listeners. */ function addEventListeners() { eventsAreBound = true; window.addEventListener( 'hashchange', onWindowHashChange, false ); window.addEventListener( 'resize', onWindowResize, false ); if( config.touch ) { dom.wrapper.addEventListener( 'touchstart', onTouchStart, false ); dom.wrapper.addEventListener( 'touchmove', onTouchMove, false ); dom.wrapper.addEventListener( 'touchend', onTouchEnd, false ); // Support pointer-style touch interaction as well if( window.navigator.pointerEnabled ) { // IE 11 uses un-prefixed version of pointer events dom.wrapper.addEventListener( 'pointerdown', onPointerDown, false ); dom.wrapper.addEventListener( 'pointermove', onPointerMove, false ); dom.wrapper.addEventListener( 'pointerup', onPointerUp, false ); } else if( window.navigator.msPointerEnabled ) { // IE 10 uses prefixed version of pointer events dom.wrapper.addEventListener( 'MSPointerDown', onPointerDown, false ); dom.wrapper.addEventListener( 'MSPointerMove', onPointerMove, false ); dom.wrapper.addEventListener( 'MSPointerUp', onPointerUp, false ); } } if( config.keyboard ) { document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keypress', onDocumentKeyPress, false ); } if( config.progress && dom.progress ) { dom.progress.addEventListener( 'click', onProgressClicked, false ); } if( config.<API key> ) { var visibilityChange; if( 'hidden' in document ) { visibilityChange = 'visibilitychange'; } else if( 'msHidden' in document ) { visibilityChange = 'msvisibilitychange'; } else if( 'webkitHidden' in document ) { visibilityChange = '<API key>'; } if( visibilityChange ) { document.addEventListener( visibilityChange, <API key>, false ); } } // Listen to both touch and click events, in case the device // supports both var pointerEvents = [ 'touchstart', 'click' ]; // Only support touch for Android, fixes double navigations in // stock browser if( UA.match( /android/gi ) ) { pointerEvents = [ 'touchstart' ]; } pointerEvents.forEach( function( eventName ) { dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, <API key>, false ); } ); dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, <API key>, false ); } ); dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } ); dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, <API key>, false ); } ); dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, <API key>, false ); } ); dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, <API key>, false ); } ); } ); } /** * Unbinds all event listeners. */ function <API key>() { eventsAreBound = false; document.removeEventListener( 'keydown', onDocumentKeyDown, false ); document.removeEventListener( 'keypress', onDocumentKeyPress, false ); window.removeEventListener( 'hashchange', onWindowHashChange, false ); window.removeEventListener( 'resize', onWindowResize, false ); dom.wrapper.removeEventListener( 'touchstart', onTouchStart, false ); dom.wrapper.removeEventListener( 'touchmove', onTouchMove, false ); dom.wrapper.removeEventListener( 'touchend', onTouchEnd, false ); // IE11 if( window.navigator.pointerEnabled ) { dom.wrapper.removeEventListener( 'pointerdown', onPointerDown, false ); dom.wrapper.removeEventListener( 'pointermove', onPointerMove, false ); dom.wrapper.removeEventListener( 'pointerup', onPointerUp, false ); } // IE10 else if( window.navigator.msPointerEnabled ) { dom.wrapper.removeEventListener( 'MSPointerDown', onPointerDown, false ); dom.wrapper.removeEventListener( 'MSPointerMove', onPointerMove, false ); dom.wrapper.removeEventListener( 'MSPointerUp', onPointerUp, false ); } if ( config.progress && dom.progress ) { dom.progress.removeEventListener( 'click', onProgressClicked, false ); } [ 'touchstart', 'click' ].forEach( function( eventName ) { dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, <API key>, false ); } ); dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, <API key>, false ); } ); dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } ); dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, <API key>, false ); } ); dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, <API key>, false ); } ); dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, <API key>, false ); } ); } ); } /** * Extend object a with the properties of object b. * If there's a conflict, object b takes precedence. * * @param {object} a * @param {object} b */ function extend( a, b ) { for( var i in b ) { a[ i ] = b[ i ]; } return a; } /** * Converts the target object to an array. * * @param {object} o * @return {object[]} */ function toArray( o ) { return Array.prototype.slice.call( o ); } /** * Utility for deserializing a value. * * @param {*} value * @return {*} */ function deserialize( value ) { if( typeof value === 'string' ) { if( value === 'null' ) return null; else if( value === 'true' ) return true; else if( value === 'false' ) return false; else if( value.match( /^-?[\d\.]+$/ ) ) return parseFloat( value ); } return value; } /** * Measures the distance in pixels between point a * and point b. * * @param {object} a point with x/y properties * @param {object} b point with x/y properties * * @return {number} */ function distanceBetween( a, b ) { var dx = a.x - b.x, dy = a.y - b.y; return Math.sqrt( dx*dx + dy*dy ); } /** * Applies a CSS transform to the target element. * * @param {HTMLElement} element * @param {string} transform */ function transformElement( element, transform ) { element.style.WebkitTransform = transform; element.style.MozTransform = transform; element.style.msTransform = transform; element.style.transform = transform; } /** * Applies CSS transforms to the slides container. The container * is transformed from two separate sources: layout and the overview * mode. * * @param {object} transforms */ function transformSlides( transforms ) { // Pick up new transforms from arguments if( typeof transforms.layout === 'string' ) slidesTransform.layout = transforms.layout; if( typeof transforms.overview === 'string' ) slidesTransform.overview = transforms.overview; // Apply the transforms to the slides container if( slidesTransform.layout ) { transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview ); } else { transformElement( dom.slides, slidesTransform.overview ); } } /** * Injects the given CSS styles into the DOM. * * @param {string} value */ function injectStyleSheet( value ) { var tag = document.createElement( 'style' ); tag.type = 'text/css'; if( tag.styleSheet ) { tag.styleSheet.cssText = value; } else { tag.appendChild( document.createTextNode( value ) ); } document.<API key>( 'head' )[0].appendChild( tag ); } /** * Find the closest parent that matches the given * selector. * * @param {HTMLElement} target The child element * @param {String} selector The CSS selector to match * the parents against * * @return {HTMLElement} The matched parent or null * if no matching parent was found */ function closestParent( target, selector ) { var parent = target.parentNode; while( parent ) { // There's some overhead doing this each time, we don't // want to rewrite the element prototype but should still // be enough to feature detect once at startup... var matchesMethod = parent.matches || parent.matchesSelector || parent.msMatchesSelector; // If we find a match, we're all set if( matchesMethod && matchesMethod.call( parent, selector ) ) { return parent; } // Keep searching parent = parent.parentNode; } return null; } /** * Converts various color input formats to an {r:0,g:0,b:0} object. * * @param {string} color The string representation of a color * @example * colorToRgb('#000'); * @example * colorToRgb('#000000'); * @example * colorToRgb('rgb(0,0,0)'); * @example * colorToRgb('rgba(0,0,0)'); * * @return {{r: number, g: number, b: number, [a]: number}|null} */ function colorToRgb( color ) { var hex3 = color.match( /^#([0-9a-f]{3})$/i ); if( hex3 && hex3[1] ) { hex3 = hex3[1]; return { r: parseInt( hex3.charAt( 0 ), 16 ) * 0x11, g: parseInt( hex3.charAt( 1 ), 16 ) * 0x11, b: parseInt( hex3.charAt( 2 ), 16 ) * 0x11 }; } var hex6 = color.match( /^#([0-9a-f]{6})$/i ); if( hex6 && hex6[1] ) { hex6 = hex6[1]; return { r: parseInt( hex6.substr( 0, 2 ), 16 ), g: parseInt( hex6.substr( 2, 2 ), 16 ), b: parseInt( hex6.substr( 4, 2 ), 16 ) }; } var rgb = color.match( /^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i ); if( rgb ) { return { r: parseInt( rgb[1], 10 ), g: parseInt( rgb[2], 10 ), b: parseInt( rgb[3], 10 ) }; } var rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i ); if( rgba ) { return { r: parseInt( rgba[1], 10 ), g: parseInt( rgba[2], 10 ), b: parseInt( rgba[3], 10 ), a: parseFloat( rgba[4] ) }; } return null; } /** * Calculates brightness on a scale of 0-255. * * @param {string} color See colorToRgb for supported formats. * @see {@link colorToRgb} */ function colorBrightness( color ) { if( typeof color === 'string' ) color = colorToRgb( color ); if( color ) { return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000; } return null; } /** * Returns the remaining height within the parent of the * target element. * * remaining height = [ configured parent height ] - [ current parent height ] * * @param {HTMLElement} element * @param {number} [height] */ function getRemainingHeight( element, height ) { height = height || 0; if( element ) { var newHeight, oldHeight = element.style.height; // Change the .stretch element height to 0 in order find the height of all // the other elements element.style.height = '0px'; newHeight = height - element.parentNode.offsetHeight; // Restore the old height, just in case element.style.height = oldHeight + 'px'; return newHeight; } return height; } /** * Checks if this instance is being used to print a PDF. */ function isPrintingPDF() { return ( /print-pdf/gi ).test( window.location.search ); } /** * Hides the address bar if we're on a mobile device. */ function hideAddressBar() { if( config.hideAddressBar && isMobileDevice ) { // Events that should trigger the address bar to hide window.addEventListener( 'load', removeAddressBar, false ); window.addEventListener( 'orientationchange', removeAddressBar, false ); } } /** * Causes the address bar to hide on mobile devices, * more vertical space ftw. */ function removeAddressBar() { setTimeout( function() { window.scrollTo( 0, 1 ); }, 10 ); } /** * Dispatches an event of the specified type from the * reveal DOM element. */ function dispatchEvent( type, args ) { var event = document.createEvent( 'HTMLEvents', 1, 2 ); event.initEvent( type, true, true ); extend( event, args ); dom.wrapper.dispatchEvent( event ); // If we're in an iframe, post each reveal.js event to the // parent window. Used by the notes plugin if( config.postMessageEvents && window.parent !== window.self ) { window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, state: getState() }), '*' ); } } /** * Wrap all links in 3D goodness. */ function enableRollingLinks() { if( features.transforms3d && !( 'msPerspective' in document.body.style ) ) { var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a' ); for( var i = 0, len = anchors.length; i < len; i++ ) { var anchor = anchors[i]; if( anchor.textContent && !anchor.querySelector( '*' ) && ( !anchor.className || !anchor.classList.contains( anchor, 'roll' ) ) ) { var span = document.createElement('span'); span.setAttribute('data-title', anchor.text); span.innerHTML = anchor.innerHTML; anchor.classList.add( 'roll' ); anchor.innerHTML = ''; anchor.appendChild(span); } } } } /** * Unwrap all 3D links. */ function disableRollingLinks() { var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a.roll' ); for( var i = 0, len = anchors.length; i < len; i++ ) { var anchor = anchors[i]; var span = anchor.querySelector( 'span' ); if( span ) { anchor.classList.remove( 'roll' ); anchor.innerHTML = span.innerHTML; } } } /** * Bind preview frame links. * * @param {string} [selector=a] - selector for anchors */ function enablePreviewLinks( selector ) { var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) ); anchors.forEach( function( element ) { if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) { element.addEventListener( 'click', <API key>, false ); } } ); } /** * Unbind preview frame links. */ function disablePreviewLinks( selector ) { var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) ); anchors.forEach( function( element ) { if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) { element.removeEventListener( 'click', <API key>, false ); } } ); } /** * Opens a preview window for the target URL. * * @param {string} url - url for preview iframe src */ function showPreview( url ) { closeOverlay(); dom.overlay = document.createElement( 'div' ); dom.overlay.classList.add( 'overlay' ); dom.overlay.classList.add( 'overlay-preview' ); dom.wrapper.appendChild( dom.overlay ); dom.overlay.innerHTML = [ '<header>', '<a class="close" href="#"><span class="icon"></span></a>', '<a class="external" href="'+ url +'" target="_blank"><span class="icon"></span></a>', '</header>', '<div class="spinner"></div>', '<div class="viewport">', '<iframe src="'+ url +'"></iframe>', '<small class="viewport-inner">', '<span class="x-frame-error">Unable to load iframe. This is likely due to the site\'s policy (x-frame-options).</span>', '</small>', '</div>' ].join(''); dom.overlay.querySelector( 'iframe' ).addEventListener( 'load', function( event ) { dom.overlay.classList.add( 'loaded' ); }, false ); dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) { closeOverlay(); event.preventDefault(); }, false ); dom.overlay.querySelector( '.external' ).addEventListener( 'click', function( event ) { closeOverlay(); }, false ); setTimeout( function() { dom.overlay.classList.add( 'visible' ); }, 1 ); } /** * Open or close help overlay window. * * @param {Boolean} [override] Flag which overrides the * toggle logic and forcibly sets the desired state. True means * help is open, false means it's closed. */ function toggleHelp( override ){ if( typeof override === 'boolean' ) { override ? showHelp() : closeOverlay(); } else { if( dom.overlay ) { closeOverlay(); } else { showHelp(); } } } /** * Opens an overlay window with help material. */ function showHelp() { if( config.help ) { closeOverlay(); dom.overlay = document.createElement( 'div' ); dom.overlay.classList.add( 'overlay' ); dom.overlay.classList.add( 'overlay-help' ); dom.wrapper.appendChild( dom.overlay ); var html = '<p class="title">Keyboard Shortcuts</p><br/>'; html += '<table><th>KEY</th><th>ACTION</th>'; for( var key in keyboardShortcuts ) { html += '<tr><td>' + key + '</td><td>' + keyboardShortcuts[ key ] + '</td></tr>'; } html += '</table>'; dom.overlay.innerHTML = [ '<header>', '<a class="close" href="#"><span class="icon"></span></a>', '</header>', '<div class="viewport">', '<div class="viewport-inner">'+ html +'</div>', '</div>' ].join(''); dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) { closeOverlay(); event.preventDefault(); }, false ); setTimeout( function() { dom.overlay.classList.add( 'visible' ); }, 1 ); } } /** * Closes any currently open overlay. */ function closeOverlay() { if( dom.overlay ) { dom.overlay.parentNode.removeChild( dom.overlay ); dom.overlay = null; } } /** * Applies <API key> layout rules to the * presentation. */ function layout() { if( dom.wrapper && !isPrintingPDF() ) { var size = <API key>(); // Layout the contents of the slides layoutSlideContents( config.width, config.height ); dom.slides.style.width = size.width + 'px'; dom.slides.style.height = size.height + 'px'; // Determine scale of content to fit within available space scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height ); // Respect max/min scale settings scale = Math.max( scale, config.minScale ); scale = Math.min( scale, config.maxScale ); // Don't apply any scaling styles if scale is 1 if( scale === 1 ) { dom.slides.style.zoom = ''; dom.slides.style.left = ''; dom.slides.style.top = ''; dom.slides.style.bottom = ''; dom.slides.style.right = ''; transformSlides( { layout: '' } ); } else { // Prefer zoom for scaling up so that content remains crisp. // Don't use zoom to scale down since that can lead to shifts // in text layout/line breaks. if( scale > 1 && features.zoom ) { dom.slides.style.zoom = scale; dom.slides.style.left = ''; dom.slides.style.top = ''; dom.slides.style.bottom = ''; dom.slides.style.right = ''; transformSlides( { layout: '' } ); } // Apply scale transform as a fallback else { dom.slides.style.zoom = ''; dom.slides.style.left = '50%'; dom.slides.style.top = '50%'; dom.slides.style.bottom = 'auto'; dom.slides.style.right = 'auto'; transformSlides( { layout: 'translate(-50%, -50%) scale('+ scale +')' } ); } } // Select all slides, vertical and horizontal var slides = toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ); for( var i = 0, len = slides.length; i < len; i++ ) { var slide = slides[ i ]; // Don't bother updating invisible slides if( slide.style.display === 'none' ) { continue; } if( config.center || slide.classList.contains( 'center' ) ) { // Vertical stacks are not centred since their section // children will be if( slide.classList.contains( 'stack' ) ) { slide.style.top = 0; } else { slide.style.top = Math.max( ( size.height - slide.scrollHeight ) / 2, 0 ) + 'px'; } } else { slide.style.top = ''; } } updateProgress(); updateParallax(); if( isOverview() ) { updateOverview(); } } } /** * Applies layout logic to the contents of all slides in * the presentation. * * @param {string|number} width * @param {string|number} height */ function layoutSlideContents( width, height ) { // Handle sizing of elements with the 'stretch' class toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) { // Determine how much vertical space we can use var remainingHeight = getRemainingHeight( element, height ); // Consider the aspect ratio of media elements if( /(img|video)/gi.test( element.nodeName ) ) { var nw = element.naturalWidth || element.videoWidth, nh = element.naturalHeight || element.videoHeight; var es = Math.min( width / nw, remainingHeight / nh ); element.style.width = ( nw * es ) + 'px'; element.style.height = ( nh * es ) + 'px'; } else { element.style.width = width + 'px'; element.style.height = remainingHeight + 'px'; } } ); } /** * Calculates the computed pixel size of our slides. These * values are based on the width and height configuration * options. * * @param {number} [presentationWidth=dom.wrapper.offsetWidth] * @param {number} [presentationHeight=dom.wrapper.offsetHeight] */ function <API key>( presentationWidth, presentationHeight ) { var size = { // Slide size width: config.width, height: config.height, // Presentation size presentationWidth: presentationWidth || dom.wrapper.offsetWidth, presentationHeight: presentationHeight || dom.wrapper.offsetHeight }; // Reduce available space by margin size.presentationWidth -= ( size.presentationWidth * config.margin ); size.presentationHeight -= ( size.presentationHeight * config.margin ); // Slide width may be a percentage of available width if( typeof size.width === 'string' && /%$/.test( size.width ) ) { size.width = parseInt( size.width, 10 ) / 100 * size.presentationWidth; } // Slide height may be a percentage of available height if( typeof size.height === 'string' && /%$/.test( size.height ) ) { size.height = parseInt( size.height, 10 ) / 100 * size.presentationHeight; } return size; } /** * Stores the vertical index of a stack so that the same * vertical slide can be selected when navigating to and * from the stack. * * @param {HTMLElement} stack The vertical stack element * @param {string|number} [v=0] Index to memorize */ function <API key>( stack, v ) { if( typeof stack === 'object' && typeof stack.setAttribute === 'function' ) { stack.setAttribute( '<API key>', v || 0 ); } } /** * Retrieves the vertical index which was stored using * #<API key>() or 0 if no previous index * exists. * * @param {HTMLElement} stack The vertical stack element */ function <API key>( stack ) { if( typeof stack === 'object' && typeof stack.setAttribute === 'function' && stack.classList.contains( 'stack' ) ) { // Prefer manually defined start-indexv var attributeName = stack.hasAttribute( 'data-start-indexv' ) ? 'data-start-indexv' : '<API key>'; return parseInt( stack.getAttribute( attributeName ) || 0, 10 ); } return 0; } /** * Displays the overview of slides (quick nav) by scaling * down and arranging all slide elements. */ function activateOverview() { // Only proceed if enabled in config if( config.overview && !isOverview() ) { overview = true; dom.wrapper.classList.add( 'overview' ); dom.wrapper.classList.remove( '<API key>' ); if( features.overviewTransitions ) { setTimeout( function() { dom.wrapper.classList.add( 'overview-animated' ); }, 1 ); } // Don't auto-slide while in overview mode cancelAutoSlide(); // Move the backgrounds element into the slide container to // that the same scaling is applied dom.slides.appendChild( dom.background ); // Clicking on an overview slide navigates to it toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) { if( !slide.classList.contains( 'stack' ) ) { slide.addEventListener( 'click', <API key>, true ); } } ); // Calculate slide sizes var margin = 70; var slideSize = <API key>(); overviewSlideWidth = slideSize.width + margin; overviewSlideHeight = slideSize.height + margin; // Reverse in RTL mode if( config.rtl ) { overviewSlideWidth = -overviewSlideWidth; } <API key>(); layoutOverview(); updateOverview(); layout(); // Notify observers of the overview showing dispatchEvent( 'overviewshown', { 'indexh': indexh, 'indexv': indexv, 'currentSlide': currentSlide } ); } } /** * Uses CSS transforms to position all slides in a grid for * display inside of the overview mode. */ function layoutOverview() { // Layout slides toArray( dom.wrapper.querySelectorAll( <API key> ) ).forEach( function( hslide, h ) { hslide.setAttribute( 'data-index-h', h ); transformElement( hslide, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' ); if( hslide.classList.contains( 'stack' ) ) { toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) { vslide.setAttribute( 'data-index-h', h ); vslide.setAttribute( 'data-index-v', v ); transformElement( vslide, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' ); } ); } } ); // Layout slide backgrounds toArray( dom.background.childNodes ).forEach( function( hbackground, h ) { transformElement( hbackground, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' ); toArray( hbackground.querySelectorAll( '.slide-background' ) ).forEach( function( vbackground, v ) { transformElement( vbackground, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' ); } ); } ); } /** * Moves the overview viewport to the current slides. * Called each time the current slide changes. */ function updateOverview() { var vmin = Math.min( window.innerWidth, window.innerHeight ); var scale = Math.max( vmin / 5, 150 ) / vmin; transformSlides( { overview: [ 'scale('+ scale +')', 'translateX('+ ( -indexh * overviewSlideWidth ) +'px)', 'translateY('+ ( -indexv * overviewSlideHeight ) +'px)' ].join( ' ' ) } ); } /** * Exits the slide overview and enters the currently * active slide. */ function deactivateOverview() { // Only proceed if enabled in config if( config.overview ) { overview = false; dom.wrapper.classList.remove( 'overview' ); dom.wrapper.classList.remove( 'overview-animated' ); // Temporarily add a class so that transitions can do different things // depending on whether they are exiting/entering overview, or just // moving from slide to slide dom.wrapper.classList.add( '<API key>' ); setTimeout( function () { dom.wrapper.classList.remove( '<API key>' ); }, 1 ); // Move the background element back out dom.wrapper.appendChild( dom.background ); // Clean up changes made to slides toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) { transformElement( slide, '' ); slide.removeEventListener( 'click', <API key>, true ); } ); // Clean up changes made to backgrounds toArray( dom.background.querySelectorAll( '.slide-background' ) ).forEach( function( background ) { transformElement( background, '' ); } ); transformSlides( { overview: '' } ); slide( indexh, indexv ); layout(); cueAutoSlide(); // Notify observers of the overview hiding dispatchEvent( 'overviewhidden', { 'indexh': indexh, 'indexv': indexv, 'currentSlide': currentSlide } ); } } /** * Toggles the slide overview mode on and off. * * @param {Boolean} [override] Flag which overrides the * toggle logic and forcibly sets the desired state. True means * overview is open, false means it's closed. */ function toggleOverview( override ) { if( typeof override === 'boolean' ) { override ? activateOverview() : deactivateOverview(); } else { isOverview() ? deactivateOverview() : activateOverview(); } } /** * Checks if the overview is currently active. * * @return {Boolean} true if the overview is active, * false otherwise */ function isOverview() { return overview; } /** * Checks if the current or specified slide is vertical * (nested within another slide). * * @param {HTMLElement} [slide=currentSlide] The slide to check * orientation of * @return {Boolean} */ function isVerticalSlide( slide ) { // Prefer slide argument, otherwise use current slide slide = slide ? slide : currentSlide; return slide && slide.parentNode && !!slide.parentNode.nodeName.match( /section/i ); } function enterFullscreen() { var element = document.documentElement; // Check which implementation is available var requestMethod = element.requestFullscreen || element.<API key> || element.<API key> || element.<API key> || element.msRequestFullscreen; if( requestMethod ) { requestMethod.apply( element ); } } /** * Enters the paused mode which fades everything on screen to * black. */ function pause() { if( config.pause ) { var wasPaused = dom.wrapper.classList.contains( 'paused' ); cancelAutoSlide(); dom.wrapper.classList.add( 'paused' ); if( wasPaused === false ) { dispatchEvent( 'paused' ); } } } /** * Exits from the paused mode. */ function resume() { var wasPaused = dom.wrapper.classList.contains( 'paused' ); dom.wrapper.classList.remove( 'paused' ); cueAutoSlide(); if( wasPaused ) { dispatchEvent( 'resumed' ); } } /** * Toggles the paused mode on and off. */ function togglePause( override ) { if( typeof override === 'boolean' ) { override ? pause() : resume(); } else { isPaused() ? resume() : pause(); } } /** * Checks if we are currently in the paused mode. * * @return {Boolean} */ function isPaused() { return dom.wrapper.classList.contains( 'paused' ); } /** * Toggles the auto slide mode on and off. * * @param {Boolean} [override] Flag which sets the desired state. * True means autoplay starts, false means it stops. */ function toggleAutoSlide( override ) { if( typeof override === 'boolean' ) { override ? resumeAutoSlide() : pauseAutoSlide(); } else { autoSlidePaused ? resumeAutoSlide() : pauseAutoSlide(); } } /** * Checks if the auto slide mode is currently on. * * @return {Boolean} */ function isAutoSliding() { return !!( autoSlide && !autoSlidePaused ); } /** * Steps from the current point in the presentation to the * slide which matches the specified horizontal and vertical * indices. * * @param {number} [h=indexh] Horizontal index of the target slide * @param {number} [v=indexv] Vertical index of the target slide * @param {number} [f] Index of a fragment within the * target slide to activate * @param {number} [o] Origin for use in multimaster environments */ function slide( h, v, f, o ) { // Remember where we were at before previousSlide = currentSlide; // Query all horizontal slides in the deck var horizontalSlides = dom.wrapper.querySelectorAll( <API key> ); // Abort if there are no slides if( horizontalSlides.length === 0 ) return; // If no vertical index is specified and the upcoming slide is a // stack, resume at its previous vertical index if( v === undefined && !isOverview() ) { v = <API key>( horizontalSlides[ h ] ); } // If we were on a vertical stack, remember what vertical index // it was on so we can resume at the same position when returning if( previousSlide && previousSlide.parentNode && previousSlide.parentNode.classList.contains( 'stack' ) ) { <API key>( previousSlide.parentNode, indexv ); } // Remember the state before this slide var stateBefore = state.concat(); // Reset the state array state.length = 0; var indexhBefore = indexh || 0, indexvBefore = indexv || 0; // Activate and transition to the new slide indexh = updateSlides( <API key>, h === undefined ? indexh : h ); indexv = updateSlides( <API key>, v === undefined ? indexv : v ); // Update the visibility of slides now that the indices have changed <API key>(); layout(); // Apply the new state stateLoop: for( var i = 0, len = state.length; i < len; i++ ) { // Check if this state existed on the previous slide. If it // did, we will avoid adding it repeatedly for( var j = 0; j < stateBefore.length; j++ ) { if( stateBefore[j] === state[i] ) { stateBefore.splice( j, 1 ); continue stateLoop; } } document.documentElement.classList.add( state[i] ); // Dispatch custom event matching the state's name dispatchEvent( state[i] ); } // Clean up the remains of the previous state while( stateBefore.length ) { document.documentElement.classList.remove( stateBefore.pop() ); } // Update the overview if it's currently active if( isOverview() ) { updateOverview(); } // Find the current horizontal slide and any possible vertical slides // within it var <API key> = horizontalSlides[ indexh ], <API key> = <API key>.querySelectorAll( 'section' ); // Store references to the previous and current slides currentSlide = <API key>[ indexv ] || <API key>; // Show fragment, if specified if( typeof f !== 'undefined' ) { navigateFragment( f ); } // Dispatch an event if the slide changed var slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore ); if( slideChanged ) { dispatchEvent( 'slidechanged', { 'indexh': indexh, 'indexv': indexv, 'previousSlide': previousSlide, 'currentSlide': currentSlide, 'origin': o } ); } else { // Ensure that the previous slide is never the same as the current previousSlide = null; } // Solves an edge case where the previous slide maintains the // 'present' class when navigating between adjacent vertical // stacks if( previousSlide ) { previousSlide.classList.remove( 'present' ); previousSlide.setAttribute( 'aria-hidden', 'true' ); // Reset all slides upon navigate to home // Issue: #285 if ( dom.wrapper.querySelector( HOME_SLIDE_SELECTOR ).classList.contains( 'present' ) ) { // Launch async task setTimeout( function () { var slides = toArray( dom.wrapper.querySelectorAll( <API key> + '.stack') ), i; for( i in slides ) { if( slides[i] ) { // Reset stack <API key>( slides[i], 0 ); } } }, 0 ); } } // Handle embedded content if( slideChanged || !previousSlide ) { stopEmbeddedContent( previousSlide ); <API key>( currentSlide ); } // Announce the current slide contents, for screen readers dom.statusDiv.textContent = getStatusText( currentSlide ); updateControls(); updateProgress(); updateBackground(); updateParallax(); updateSlideNumber(); updateNotes(); // Update the URL hash writeURL(); cueAutoSlide(); } /** * Syncs the presentation with the current DOM. Useful * when new slides or control elements are added or when * the configuration has changed. */ function sync() { // Subscribe to input <API key>(); addEventListeners(); // Force a layout to make sure the current config is accounted for layout(); // Reflect the current autoSlide value autoSlide = config.autoSlide; // Start auto-sliding if it's enabled cueAutoSlide(); // Re-create the slide backgrounds createBackgrounds(); // Write the current hash to the URL writeURL(); sortAllFragments(); updateControls(); updateProgress(); updateSlideNumber(); <API key>(); updateBackground( true ); <API key>(); updateNotes(); <API key>(); // Start or stop embedded content depending on global config if( config.autoPlayMedia === false ) { stopEmbeddedContent( currentSlide, { unloadIframes: false } ); } else { <API key>( currentSlide ); } if( isOverview() ) { layoutOverview(); } } /** * Resets all vertical slides so that only the first * is visible. */ function resetVerticalSlides() { var horizontalSlides = toArray( dom.wrapper.querySelectorAll( <API key> ) ); horizontalSlides.forEach( function( horizontalSlide ) { var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); verticalSlides.forEach( function( verticalSlide, y ) { if( y > 0 ) { verticalSlide.classList.remove( 'present' ); verticalSlide.classList.remove( 'past' ); verticalSlide.classList.add( 'future' ); verticalSlide.setAttribute( 'aria-hidden', 'true' ); } } ); } ); } /** * Sorts and formats all of fragments in the * presentation. */ function sortAllFragments() { var horizontalSlides = toArray( dom.wrapper.querySelectorAll( <API key> ) ); horizontalSlides.forEach( function( horizontalSlide ) { var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); verticalSlides.forEach( function( verticalSlide, y ) { sortFragments( verticalSlide.querySelectorAll( '.fragment' ) ); } ); if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) ); } ); } /** * Randomly shuffles all slides in the deck. */ function shuffle() { var slides = toArray( dom.wrapper.querySelectorAll( <API key> ) ); slides.forEach( function( slide ) { // Insert this slide next to another random slide. This may // cause the slide to insert before itself but that's fine. dom.slides.insertBefore( slide, slides[ Math.floor( Math.random() * slides.length ) ] ); } ); } /** * Updates one dimension of slides by showing the slide * with the specified index. * * @param {string} selector A CSS selector that will fetch * the group of slides we are working with * @param {number} index The index of the slide that should be * shown * * @return {number} The index of the slide that is now shown, * might differ from the passed in index if it was out of * bounds. */ function updateSlides( selector, index ) { // Select all slides and convert the NodeList result to // an array var slides = toArray( dom.wrapper.querySelectorAll( selector ) ), slidesLength = slides.length; var printMode = isPrintingPDF(); if( slidesLength ) { // Should the index loop? if( config.loop ) { index %= slidesLength; if( index < 0 ) { index = slidesLength + index; } } // Enforce max and minimum index bounds index = Math.max( Math.min( index, slidesLength - 1 ), 0 ); for( var i = 0; i < slidesLength; i++ ) { var element = slides[i]; var reverse = config.rtl && !isVerticalSlide( element ); element.classList.remove( 'past' ); element.classList.remove( 'present' ); element.classList.remove( 'future' ); // http://www.w3.org/html/wg/drafts/html/master/editing.html#<API key> element.setAttribute( 'hidden', '' ); element.setAttribute( 'aria-hidden', 'true' ); // If this element contains vertical slides if( element.querySelector( 'section' ) ) { element.classList.add( 'stack' ); } // If we're printing static slides, all slides are "present" if( printMode ) { element.classList.add( 'present' ); continue; } if( i < index ) { // Any element previous to index is given the 'past' class element.classList.add( reverse ? 'future' : 'past' ); if( config.fragments ) { var pastFragments = toArray( element.querySelectorAll( '.fragment' ) ); // Show all fragments on prior slides while( pastFragments.length ) { var pastFragment = pastFragments.pop(); pastFragment.classList.add( 'visible' ); pastFragment.classList.remove( 'current-fragment' ); } } } else if( i > index ) { // Any element subsequent to index is given the 'future' class element.classList.add( reverse ? 'past' : 'future' ); if( config.fragments ) { var futureFragments = toArray( element.querySelectorAll( '.fragment.visible' ) ); // No fragments in future slides should be visible ahead of time while( futureFragments.length ) { var futureFragment = futureFragments.pop(); futureFragment.classList.remove( 'visible' ); futureFragment.classList.remove( 'current-fragment' ); } } } } // Mark the current slide as present slides[index].classList.add( 'present' ); slides[index].removeAttribute( 'hidden' ); slides[index].removeAttribute( 'aria-hidden' ); // If this slide has a state associated with it, add it // onto the current state of the deck var slideState = slides[index].getAttribute( 'data-state' ); if( slideState ) { state = state.concat( slideState.split( ' ' ) ); } } else { // Since there are no slides we can't be anywhere beyond the // zeroth index index = 0; } return index; } /** * Optimization method; hide all slides that are far away * from the present slide. */ function <API key>() { // Select all slides and convert the NodeList result to // an array var horizontalSlides = toArray( dom.wrapper.querySelectorAll( <API key> ) ), <API key> = horizontalSlides.length, distanceX, distanceY; if( <API key> && typeof indexh !== 'undefined' ) { // The number of steps away from the present slide that will // be visible var viewDistance = isOverview() ? 10 : config.viewDistance; // Limit view distance on weaker devices if( isMobileDevice ) { viewDistance = isOverview() ? 6 : 2; } // All slides need to be visible when exporting to PDF if( isPrintingPDF() ) { viewDistance = Number.MAX_VALUE; } for( var x = 0; x < <API key>; x++ ) { var horizontalSlide = horizontalSlides[x]; var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ), <API key> = verticalSlides.length; // Determine how far away this slide is from the present distanceX = Math.abs( ( indexh || 0 ) - x ) || 0; // If the presentation is looped, distance should measure // 1 between the first and last slides if( config.loop ) { distanceX = Math.abs( ( ( indexh || 0 ) - x ) % ( <API key> - viewDistance ) ) || 0; } // Show the horizontal slide if it's within the view distance if( distanceX < viewDistance ) { loadSlide( horizontalSlide ); } else { unloadSlide( horizontalSlide ); } if( <API key> ) { var oy = <API key>( horizontalSlide ); for( var y = 0; y < <API key>; y++ ) { var verticalSlide = verticalSlides[y]; distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy ); if( distanceX + distanceY < viewDistance ) { loadSlide( verticalSlide ); } else { unloadSlide( verticalSlide ); } } } } // Flag if there are ANY vertical slides, anywhere in the deck if( dom.wrapper.querySelectorAll( '.slides>section>section' ).length ) { dom.wrapper.classList.add( 'has-vertical-slides' ); } else { dom.wrapper.classList.remove( 'has-vertical-slides' ); } // Flag if there are ANY horizontal slides, anywhere in the deck if( dom.wrapper.querySelectorAll( '.slides>section' ).length > 1 ) { dom.wrapper.classList.add( '<API key>' ); } else { dom.wrapper.classList.remove( '<API key>' ); } } } /** * Pick up notes from the current slide and display them * to the viewer. * * @see {@link config.showNotes} */ function updateNotes() { if( config.showNotes && dom.speakerNotes && currentSlide && !isPrintingPDF() ) { dom.speakerNotes.innerHTML = getSlideNotes() || '<span class="notes-placeholder">No notes on this slide.</span>'; } } /** * Updates the visibility of the speaker notes sidebar that * is used to share annotated slides. The notes sidebar is * only visible if showNotes is true and there are notes on * one or more slides in the deck. */ function <API key>() { if( config.showNotes && hasNotes() ) { dom.wrapper.classList.add( 'show-notes' ); } else { dom.wrapper.classList.remove( 'show-notes' ); } } /** * Checks if there are speaker notes for ANY slide in the * presentation. */ function hasNotes() { return dom.slides.querySelectorAll( '[data-notes], aside.notes' ).length > 0; } /** * Updates the progress bar to reflect the current slide. */ function updateProgress() { // Update progress if enabled if( config.progress && dom.progressbar ) { dom.progressbar.style.width = getProgress() * dom.wrapper.offsetWidth + 'px'; } } /** * Updates the slide number div to reflect the current slide. * * The following slide number formats are available: * "h.v": horizontal . vertical slide number (default) * "h/v": horizontal / vertical slide number * "c": flattened slide number * "c/t": flattened slide number / total slides */ function updateSlideNumber() { // Update slide number if enabled if( config.slideNumber && dom.slideNumber ) { var value = []; var format = 'h.v'; // Check if a custom number format is available if( typeof config.slideNumber === 'string' ) { format = config.slideNumber; } switch( format ) { case 'c': value.push( getSlidePastCount() + 1 ); break; case 'c/t': value.push( getSlidePastCount() + 1, '/', getTotalSlides() ); break; case 'h/v': value.push( indexh + 1 ); if( isVerticalSlide() ) value.push( '/', indexv + 1 ); break; default: value.push( indexh + 1 ); if( isVerticalSlide() ) value.push( '.', indexv + 1 ); } dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] ); } } /** * Applies HTML formatting to a slide number before it's * written to the DOM. * * @param {number} a Current slide * @param {string} delimiter Character to separate slide numbers * @param {(number|*)} b Total slides * @return {string} HTML string fragment */ function formatSlideNumber( a, delimiter, b ) { if( typeof b === 'number' && !isNaN( b ) ) { return '<span class="slide-number-a">'+ a +'</span>' + '<span class="<API key>">'+ delimiter +'</span>' + '<span class="slide-number-b">'+ b +'</span>'; } else { return '<span class="slide-number-a">'+ a +'</span>'; } } /** * Updates the state of all control/navigation arrows. */ function updateControls() { var routes = availableRoutes(); var fragments = availableFragments(); // Remove the 'enabled' class from all directions dom.controlsLeft.concat( dom.controlsRight ) .concat( dom.controlsUp ) .concat( dom.controlsDown ) .concat( dom.controlsPrev ) .concat( dom.controlsNext ).forEach( function( node ) { node.classList.remove( 'enabled' ); node.classList.remove( 'fragmented' ); // Set 'disabled' attribute on all directions node.setAttribute( 'disabled', 'disabled' ); } ); // Add the 'enabled' class to the available routes; remove 'disabled' attribute to enable buttons if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); // Prev/next buttons if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } ); // Highlight fragment directions if( currentSlide ) { // Always apply fragment decorator to prev/next buttons if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); // Apply fragment decorators to directional buttons based on // what slide axis they are in if( isVerticalSlide( currentSlide ) ) { if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); } else { if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } ); } } if( config.controlsTutorial ) { // Highlight control arrows with an animation to ensure // that the viewer knows how to navigate if( !hasNavigatedDown && routes.down ) { dom.controlsDownArrow.classList.add( 'highlight' ); } else { dom.controlsDownArrow.classList.remove( 'highlight' ); if( !hasNavigatedRight && routes.right && indexv === 0 ) { dom.controlsRightArrow.classList.add( 'highlight' ); } else { dom.controlsRightArrow.classList.remove( 'highlight' ); } } } } /** * Updates the background elements to reflect the current * slide. * * @param {boolean} includeAll If true, the backgrounds of * all vertical slides (not just the present) will be updated. */ function updateBackground( includeAll ) { var currentBackground = null; // Reverse past/future classes when in RTL mode var horizontalPast = config.rtl ? 'future' : 'past', horizontalFuture = config.rtl ? 'past' : 'future'; // Update the classes of all backgrounds to match the // states of their slides (past/present/future) toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) { backgroundh.classList.remove( 'past' ); backgroundh.classList.remove( 'present' ); backgroundh.classList.remove( 'future' ); if( h < indexh ) { backgroundh.classList.add( horizontalPast ); } else if ( h > indexh ) { backgroundh.classList.add( horizontalFuture ); } else { backgroundh.classList.add( 'present' ); // Store a reference to the current background element currentBackground = backgroundh; } if( includeAll || h === indexh ) { toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) { backgroundv.classList.remove( 'past' ); backgroundv.classList.remove( 'present' ); backgroundv.classList.remove( 'future' ); if( v < indexv ) { backgroundv.classList.add( 'past' ); } else if ( v > indexv ) { backgroundv.classList.add( 'future' ); } else { backgroundv.classList.add( 'present' ); // Only if this is the present horizontal and vertical slide if( h === indexh ) currentBackground = backgroundv; } } ); } } ); // Stop content inside of previous backgrounds if( previousBackground ) { stopEmbeddedContent( previousBackground ); } // Start content in the current background if( currentBackground ) { <API key>( currentBackground ); var backgroundImageURL = currentBackground.style.backgroundImage || ''; // Restart GIFs (doesn't work in Firefox) if( /\.gif/i.test( backgroundImageURL ) ) { currentBackground.style.backgroundImage = ''; window.getComputedStyle( currentBackground ).opacity; currentBackground.style.backgroundImage = backgroundImageURL; } // Don't transition between identical backgrounds. This // prevents unwanted flicker. var <API key> = previousBackground ? previousBackground.getAttribute( '<API key>' ) : null; var <API key> = currentBackground.getAttribute( '<API key>' ); if( <API key> && <API key> === <API key> && currentBackground !== previousBackground ) { dom.background.classList.add( 'no-transition' ); } previousBackground = currentBackground; } // If there's a background brightness flag for this slide, // bubble it to the .reveal container if( currentSlide ) { [ '<API key>', 'has-dark-background' ].forEach( function( classToBubble ) { if( currentSlide.classList.contains( classToBubble ) ) { dom.wrapper.classList.add( classToBubble ); } else { dom.wrapper.classList.remove( classToBubble ); } } ); } // Allow the first background to apply without transition setTimeout( function() { dom.background.classList.remove( 'no-transition' ); }, 1 ); } /** * Updates the position of the parallax background based * on the current slide index. */ function updateParallax() { if( config.<API key> ) { var horizontalSlides = dom.wrapper.querySelectorAll( <API key> ), verticalSlides = dom.wrapper.querySelectorAll( <API key> ); var backgroundSize = dom.background.style.backgroundSize.split( ' ' ), backgroundWidth, backgroundHeight; if( backgroundSize.length === 1 ) { backgroundWidth = backgroundHeight = parseInt( backgroundSize[0], 10 ); } else { backgroundWidth = parseInt( backgroundSize[0], 10 ); backgroundHeight = parseInt( backgroundSize[1], 10 ); } var slideWidth = dom.background.offsetWidth, <API key> = horizontalSlides.length, <API key>, horizontalOffset; if( typeof config.<API key> === 'number' ) { <API key> = config.<API key>; } else { <API key> = <API key> > 1 ? ( backgroundWidth - slideWidth ) / ( <API key> ) : 0; } horizontalOffset = <API key> * indexh * -1; var slideHeight = dom.background.offsetHeight, verticalSlideCount = verticalSlides.length, <API key>, verticalOffset; if( typeof config.<API key> === 'number' ) { <API key> = config.<API key>; } else { <API key> = ( backgroundHeight - slideHeight ) / ( <API key> ); } verticalOffset = verticalSlideCount > 0 ? <API key> * indexv : 0; dom.background.style.backgroundPosition = horizontalOffset + 'px ' + -verticalOffset + 'px'; } } /** * Called when the given slide is within the configured view * distance. Shows the slide element and loads any content * that is set to load lazily (data-src). * * @param {HTMLElement} slide Slide to show */ function loadSlide( slide, options ) { options = options || {}; // Show the slide element slide.style.display = config.display; // Media elements with data-src attributes toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src]' ) ).forEach( function( element ) { element.setAttribute( 'src', element.getAttribute( 'data-src' ) ); element.setAttribute( 'data-lazy-loaded', '' ); element.removeAttribute( 'data-src' ); } ); // Media elements with <source> children toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( media ) { var sources = 0; toArray( media.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) { source.setAttribute( 'src', source.getAttribute( 'data-src' ) ); source.removeAttribute( 'data-src' ); source.setAttribute( 'data-lazy-loaded', '' ); sources += 1; } ); // If we rewrote sources for this video/audio element, we need // to manually tell it to load from its new origin if( sources > 0 ) { media.load(); } } ); // Show the corresponding background element var indices = getIndices( slide ); var background = getSlideBackground( indices.h, indices.v ); if( background ) { background.style.display = 'block'; // If the background contains media, load it if( background.hasAttribute( 'data-loaded' ) === false ) { background.setAttribute( 'data-loaded', 'true' ); var backgroundImage = slide.getAttribute( '<API key>' ), backgroundVideo = slide.getAttribute( '<API key>' ), backgroundVideoLoop = slide.hasAttribute( '<API key>' ), <API key> = slide.hasAttribute( '<API key>' ), backgroundIframe = slide.getAttribute( '<API key>' ); // Images if( backgroundImage ) { background.style.backgroundImage = 'url('+ backgroundImage +')'; } // Videos else if ( backgroundVideo && !isSpeakerNotes() ) { var video = document.createElement( 'video' ); if( backgroundVideoLoop ) { video.setAttribute( 'loop', '' ); } if( <API key> ) { video.muted = true; } // Inline video playback works (at least in Mobile Safari) as // long as the video is muted and the `playsinline` attribute is // present if( isMobileDevice ) { video.muted = true; video.autoplay = true; video.setAttribute( 'playsinline', '' ); } // Support comma separated lists of video sources backgroundVideo.split( ',' ).forEach( function( source ) { video.innerHTML += '<source src="'+ source +'">'; } ); background.appendChild( video ); } // Iframes else if( backgroundIframe && options.excludeIframes !== true ) { var iframe = document.createElement( 'iframe' ); iframe.setAttribute( 'allowfullscreen', '' ); iframe.setAttribute( 'mozallowfullscreen', '' ); iframe.setAttribute( '<API key>', '' ); // Only load autoplaying content when the slide is shown to // avoid having it play in the background if( /autoplay=(1|true|yes)/gi.test( backgroundIframe ) ) { iframe.setAttribute( 'data-src', backgroundIframe ); } else { iframe.setAttribute( 'src', backgroundIframe ); } iframe.style.width = '100%'; iframe.style.height = '100%'; iframe.style.maxHeight = '100%'; iframe.style.maxWidth = '100%'; background.appendChild( iframe ); } } } } /** * Unloads and hides the given slide. This is called when the * slide is moved outside of the configured view distance. * * @param {HTMLElement} slide */ function unloadSlide( slide ) { // Hide the slide element slide.style.display = 'none'; // Hide the corresponding background element var indices = getIndices( slide ); var background = getSlideBackground( indices.h, indices.v ); if( background ) { background.style.display = 'none'; } // Reset lazy-loaded media elements with src attributes toArray( slide.querySelectorAll( 'video[data-lazy-loaded][src], audio[data-lazy-loaded][src]' ) ).forEach( function( element ) { element.setAttribute( 'data-src', element.getAttribute( 'src' ) ); element.removeAttribute( 'src' ); } ); // Reset lazy-loaded media elements with <source> children toArray( slide.querySelectorAll( 'video[data-lazy-loaded] source[src], audio source[src]' ) ).forEach( function( source ) { source.setAttribute( 'data-src', source.getAttribute( 'src' ) ); source.removeAttribute( 'src' ); } ); } /** * Determine what available routes there are for navigation. * * @return {{left: boolean, right: boolean, up: boolean, down: boolean}} */ function availableRoutes() { var horizontalSlides = dom.wrapper.querySelectorAll( <API key> ), verticalSlides = dom.wrapper.querySelectorAll( <API key> ); var routes = { left: indexh > 0 || config.loop, right: indexh < horizontalSlides.length - 1 || config.loop, up: indexv > 0, down: indexv < verticalSlides.length - 1 }; // reverse horizontal controls for rtl if( config.rtl ) { var left = routes.left; routes.left = routes.right; routes.right = left; } return routes; } /** * Returns an object describing the available fragment * directions. * * @return {{prev: boolean, next: boolean}} */ function availableFragments() { if( currentSlide && config.fragments ) { var fragments = currentSlide.querySelectorAll( '.fragment' ); var hiddenFragments = currentSlide.querySelectorAll( '.fragment:not(.visible)' ); return { prev: fragments.length - hiddenFragments.length > 0, next: !!hiddenFragments.length }; } else { return { prev: false, next: false }; } } /** * Enforces origin-specific format rules for embedded media. */ function <API key>() { var <API key> = function( sourceAttribute, sourceURL, param ) { toArray( dom.slides.querySelectorAll( 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ) ).forEach( function( el ) { var src = el.getAttribute( sourceAttribute ); if( src && src.indexOf( param ) === -1 ) { el.setAttribute( sourceAttribute, src + ( !/\?/.test( src ) ? '?' : '&' ) + param ); } }); }; // YouTube frames must include "?enablejsapi=1" <API key>( 'src', 'youtube.com/embed/', 'enablejsapi=1' ); <API key>( 'data-src', 'youtube.com/embed/', 'enablejsapi=1' ); // Vimeo frames must include "?api=1" <API key>( 'src', 'player.vimeo.com/', 'api=1' ); <API key>( 'data-src', 'player.vimeo.com/', 'api=1' ); // Always show media controls on mobile devices if( isMobileDevice ) { toArray( dom.slides.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { el.controls = true; } ); } } /** * Start playback of any embedded content inside of * the given element. * * @param {HTMLElement} element */ function <API key>( element ) { if( element && !isSpeakerNotes() ) { // Restart GIFs toArray( element.querySelectorAll( 'img[src$=".gif"]' ) ).forEach( function( el ) { // Setting the same unchanged source like this was confirmed // to work in Chrome, FF & Safari el.setAttribute( 'src', el.getAttribute( 'src' ) ); } ); // HTML5 media elements toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) { return; } // Prefer an explicit global autoplay setting var autoplay = config.autoPlayMedia; // If no global setting is available, fall back on the element's // own autoplay setting if( typeof autoplay !== 'boolean' ) { autoplay = el.hasAttribute( 'data-autoplay' ) || !!closestParent( el, '.slide-background' ); } if( autoplay && typeof el.play === 'function' ) { if( el.readyState > 1 ) { startEmbeddedMedia( { target: el } ); } else { el.removeEventListener( 'loadeddata', startEmbeddedMedia ); // remove first to avoid dupes el.addEventListener( 'loadeddata', startEmbeddedMedia ); } } } ); // Normal iframes toArray( element.querySelectorAll( 'iframe[src]' ) ).forEach( function( el ) { if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) { return; } startEmbeddedIframe( { target: el } ); } ); // Lazy loading iframes toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) { if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) { return; } if( el.getAttribute( 'src' ) !== el.getAttribute( 'data-src' ) ) { el.removeEventListener( 'load', startEmbeddedIframe ); // remove first to avoid dupes el.addEventListener( 'load', startEmbeddedIframe ); el.setAttribute( 'src', el.getAttribute( 'data-src' ) ); } } ); } } /** * Starts playing an embedded video/audio element after * it has finished loading. * * @param {object} event */ function startEmbeddedMedia( event ) { var isAttachedToDOM = !!closestParent( event.target, 'html' ), isVisible = !!closestParent( event.target, '.present' ); if( isAttachedToDOM && isVisible ) { event.target.currentTime = 0; event.target.play(); } event.target.removeEventListener( 'loadeddata', startEmbeddedMedia ); } /** * "Starts" the content of an embedded iframe using the * postMessage API. * * @param {object} event */ function startEmbeddedIframe( event ) { var iframe = event.target; if( iframe && iframe.contentWindow ) { var isAttachedToDOM = !!closestParent( event.target, 'html' ), isVisible = !!closestParent( event.target, '.present' ); if( isAttachedToDOM && isVisible ) { // Prefer an explicit global autoplay setting var autoplay = config.autoPlayMedia; // If no global setting is available, fall back on the element's // own autoplay setting if( typeof autoplay !== 'boolean' ) { autoplay = iframe.hasAttribute( 'data-autoplay' ) || !!closestParent( iframe, '.slide-background' ); } // YouTube postMessage API if( /youtube\.com\/embed\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) { iframe.contentWindow.postMessage( '{"event":"command","func":"playVideo","args":""}', '*' ); } // Vimeo postMessage API else if( /player\.vimeo\.com\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) { iframe.contentWindow.postMessage( '{"method":"play"}', '*' ); } // Generic postMessage API else { iframe.contentWindow.postMessage( 'slide:start', '*' ); } } } } /** * Stop playback of any embedded content inside of * the targeted slide. * * @param {HTMLElement} element */ function stopEmbeddedContent( element, options ) { options = extend( { // Defaults unloadIframes: true }, options || {} ); if( element && element.parentNode ) { // HTML5 media elements toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) { el.setAttribute('<API key>', ''); el.pause(); } } ); // Generic postMessage API for non-lazy loaded iframes toArray( element.querySelectorAll( 'iframe' ) ).forEach( function( el ) { if( el.contentWindow ) el.contentWindow.postMessage( 'slide:stop', '*' ); el.removeEventListener( 'load', startEmbeddedIframe ); }); // YouTube postMessage API toArray( element.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) { el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' ); } }); // Vimeo postMessage API toArray( element.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) { el.contentWindow.postMessage( '{"method":"pause"}', '*' ); } }); if( options.unloadIframes === true ) { // Unload lazy-loaded iframes toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) { // Only removing the src doesn't actually unload the frame // in all browsers (Firefox) so we set it to blank first el.setAttribute( 'src', 'about:blank' ); el.removeAttribute( 'src' ); } ); } } } /** * Returns the number of past slides. This can be used as a global * flattened index for slides. * * @return {number} Past slide count */ function getSlidePastCount() { var horizontalSlides = toArray( dom.wrapper.querySelectorAll( <API key> ) ); // The number of past slides var pastCount = 0; // Step through all slides and count the past ones mainLoop: for( var i = 0; i < horizontalSlides.length; i++ ) { var horizontalSlide = horizontalSlides[i]; var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); for( var j = 0; j < verticalSlides.length; j++ ) { // Stop as soon as we arrive at the present if( verticalSlides[j].classList.contains( 'present' ) ) { break mainLoop; } pastCount++; } // Stop as soon as we arrive at the present if( horizontalSlide.classList.contains( 'present' ) ) { break; } // Don't count the wrapping section for vertical slides if( horizontalSlide.classList.contains( 'stack' ) === false ) { pastCount++; } } return pastCount; } /** * Returns a value ranging from 0-1 that represents * how far into the presentation we have navigated. * * @return {number} */ function getProgress() { // The number of past and total slides var totalCount = getTotalSlides(); var pastCount = getSlidePastCount(); if( currentSlide ) { var allFragments = currentSlide.querySelectorAll( '.fragment' ); // If there are fragments in the current slide those should be // accounted for in the progress. if( allFragments.length > 0 ) { var visibleFragments = currentSlide.querySelectorAll( '.fragment.visible' ); // This value represents how big a portion of the slide progress // that is made up by its fragments (0-1) var fragmentWeight = 0.9; // Add fragment progress to the past slide count pastCount += ( visibleFragments.length / allFragments.length ) * fragmentWeight; } } return pastCount / ( totalCount - 1 ); } /** * Checks if this presentation is running inside of the * speaker notes window. * * @return {boolean} */ function isSpeakerNotes() { return !!window.location.search.match( /receiver/gi ); } /** * Reads the current URL (hash) and navigates accordingly. */ function readURL() { var hash = window.location.hash; // Attempt to parse the hash as either an index or name var bits = hash.slice( 2 ).split( '/' ), name = hash.replace( / // If the first bit is invalid and there is a name we can // assume that this is a named link if( isNaN( parseInt( bits[0], 10 ) ) && name.length ) { var element; // Ensure the named link is a valid HTML ID attribute if( /^[a-zA-Z][\w:.-]*$/.test( name ) ) { // Find the slide with the specified ID element = document.getElementById( name ); } if( element ) { // Find the position of the named slide and navigate to it var indices = Reveal.getIndices( element ); slide( indices.h, indices.v ); } // If the slide doesn't exist, navigate to the current slide else { slide( indexh || 0, indexv || 0 ); } } else { // Read the index components of the hash var h = parseInt( bits[0], 10 ) || 0, v = parseInt( bits[1], 10 ) || 0; if( h !== indexh || v !== indexv ) { slide( h, v ); } } } /** * Updates the page URL (hash) to reflect the current * state. * * @param {number} delay The time in ms to wait before * writing the hash */ function writeURL( delay ) { if( config.history ) { // Make sure there's never more than one timeout running clearTimeout( writeURLTimeout ); // If a delay is specified, timeout this call if( typeof delay === 'number' ) { writeURLTimeout = setTimeout( writeURL, delay ); } else if( currentSlide ) { var url = '/'; // Attempt to create a named link based on the slide's ID var id = currentSlide.getAttribute( 'id' ); if( id ) { id = id.replace( /[^a-zA-Z0-9\-\_\:\.]/g, '' ); } // If the current slide has an ID, use that as a named link if( typeof id === 'string' && id.length ) { url = '/' + id; } // Otherwise use the /h/v index else { if( indexh > 0 || indexv > 0 ) url += indexh; if( indexv > 0 ) url += '/' + indexv; } window.location.hash = url; } } } /** * Retrieves the h/v location and fragment of the current, * or specified, slide. * * @param {HTMLElement} [slide] If specified, the returned * index will be for this slide rather than the currently * active one * * @return {{h: number, v: number, f: number}} */ function getIndices( slide ) { // By default, return the current indices var h = indexh, v = indexv, f; // If a slide is specified, return the indices of that slide if( slide ) { var isVertical = isVerticalSlide( slide ); var slideh = isVertical ? slide.parentNode : slide; // Select all horizontal slides var horizontalSlides = toArray( dom.wrapper.querySelectorAll( <API key> ) ); // Now that we know which the horizontal slide is, get its index h = Math.max( horizontalSlides.indexOf( slideh ), 0 ); // Assume we're not vertical v = undefined; // If this is a vertical slide, grab the vertical index if( isVertical ) { v = Math.max( toArray( slide.parentNode.querySelectorAll( 'section' ) ).indexOf( slide ), 0 ); } } if( !slide && currentSlide ) { var hasFragments = currentSlide.querySelectorAll( '.fragment' ).length > 0; if( hasFragments ) { var currentFragment = currentSlide.querySelector( '.current-fragment' ); if( currentFragment && currentFragment.hasAttribute( 'data-fragment-index' ) ) { f = parseInt( currentFragment.getAttribute( 'data-fragment-index' ), 10 ); } else { f = currentSlide.querySelectorAll( '.fragment.visible' ).length - 1; } } } return { h: h, v: v, f: f }; } /** * Retrieves all slides in this presentation. */ function getSlides() { return toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ':not(.stack)' )); } /** * Retrieves the total number of slides in this presentation. * * @return {number} */ function getTotalSlides() { return getSlides().length; } /** * Returns the slide element matching the specified index. * * @return {HTMLElement} */ function getSlide( x, y ) { var horizontalSlide = dom.wrapper.querySelectorAll( <API key> )[ x ]; var verticalSlides = horizontalSlide && horizontalSlide.querySelectorAll( 'section' ); if( verticalSlides && verticalSlides.length && typeof y === 'number' ) { return verticalSlides ? verticalSlides[ y ] : undefined; } return horizontalSlide; } /** * Returns the background element for the given slide. * All slides, even the ones with no background properties * defined, have a background element so as long as the * index is valid an element will be returned. * * @param {number} x Horizontal background index * @param {number} y Vertical background index * @return {(HTMLElement[]|*)} */ function getSlideBackground( x, y ) { var slide = getSlide( x, y ); if( slide ) { return slide.<API key>; } return undefined; } /** * Retrieves the speaker notes from a slide. Notes can be * defined in two ways: * 1. As a data-notes attribute on the slide <section> * 2. As an <aside class="notes"> inside of the slide * * @param {HTMLElement} [slide=currentSlide] * @return {(string|null)} */ function getSlideNotes( slide ) { // Default to the current slide slide = slide || currentSlide; // Notes can be specified via the data-notes attribute... if( slide.hasAttribute( 'data-notes' ) ) { return slide.getAttribute( 'data-notes' ); } // ... or using an <aside class="notes"> element var notesElement = slide.querySelector( 'aside.notes' ); if( notesElement ) { return notesElement.innerHTML; } return null; } /** * Retrieves the current state of the presentation as * an object. This state can then be restored at any * time. * * @return {{indexh: number, indexv: number, indexf: number, paused: boolean, overview: boolean}} */ function getState() { var indices = getIndices(); return { indexh: indices.h, indexv: indices.v, indexf: indices.f, paused: isPaused(), overview: isOverview() }; } /** * Restores the presentation to the given state. * * @param {object} state As generated by getState() * @see {@link getState} generates the parameter `state` */ function setState( state ) { if( typeof state === 'object' ) { slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) ); var pausedFlag = deserialize( state.paused ), overviewFlag = deserialize( state.overview ); if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) { togglePause( pausedFlag ); } if( typeof overviewFlag === 'boolean' && overviewFlag !== isOverview() ) { toggleOverview( overviewFlag ); } } } /** * Return a sorted fragments list, ordered by an increasing * "data-fragment-index" attribute. * * Fragments will be revealed in the order that they are returned by * this function, so you can use the index attributes to control the * order of fragment appearance. * * To maintain a sensible default fragment order, fragments are presumed * to be passed in document order. This function adds a "fragment-index" * attribute to each node if such an attribute is not already present, * and sets that attribute to an integer value which is the position of * the fragment within the fragments list. * * @param {object[]|*} fragments * @return {object[]} sorted Sorted array of fragments */ function sortFragments( fragments ) { fragments = toArray( fragments ); var ordered = [], unordered = [], sorted = []; // Group ordered and unordered elements fragments.forEach( function( fragment, i ) { if( fragment.hasAttribute( 'data-fragment-index' ) ) { var index = parseInt( fragment.getAttribute( 'data-fragment-index' ), 10 ); if( !ordered[index] ) { ordered[index] = []; } ordered[index].push( fragment ); } else { unordered.push( [ fragment ] ); } } ); // Append fragments without explicit indices in their // DOM order ordered = ordered.concat( unordered ); // Manually count the index up per group to ensure there // are no gaps var index = 0; // Push all fragments in their sorted order to an array, // this flattens the groups ordered.forEach( function( group ) { group.forEach( function( fragment ) { sorted.push( fragment ); fragment.setAttribute( 'data-fragment-index', index ); } ); index ++; } ); return sorted; } /** * Navigate to the specified slide fragment. * * @param {?number} index The index of the fragment that * should be shown, -1 means all are invisible * @param {number} offset Integer offset to apply to the * fragment index * * @return {boolean} true if a change was made in any * fragments visibility as part of this call */ function navigateFragment( index, offset ) { if( currentSlide && config.fragments ) { var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) ); if( fragments.length ) { // If no index is specified, find the current if( typeof index !== 'number' ) { var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop(); if( lastVisibleFragment ) { index = parseInt( lastVisibleFragment.getAttribute( 'data-fragment-index' ) || 0, 10 ); } else { index = -1; } } // If an offset is specified, apply it to the index if( typeof offset === 'number' ) { index += offset; } var fragmentsShown = [], fragmentsHidden = []; toArray( fragments ).forEach( function( element, i ) { if( element.hasAttribute( 'data-fragment-index' ) ) { i = parseInt( element.getAttribute( 'data-fragment-index' ), 10 ); } // Visible fragments if( i <= index ) { if( !element.classList.contains( 'visible' ) ) fragmentsShown.push( element ); element.classList.add( 'visible' ); element.classList.remove( 'current-fragment' ); // Announce the fragments one by one to the Screen Reader dom.statusDiv.textContent = getStatusText( element ); if( i === index ) { element.classList.add( 'current-fragment' ); <API key>( element ); } } // Hidden fragments else { if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element ); element.classList.remove( 'visible' ); element.classList.remove( 'current-fragment' ); } } ); if( fragmentsHidden.length ) { dispatchEvent( 'fragmenthidden', { fragment: fragmentsHidden[0], fragments: fragmentsHidden } ); } if( fragmentsShown.length ) { dispatchEvent( 'fragmentshown', { fragment: fragmentsShown[0], fragments: fragmentsShown } ); } updateControls(); updateProgress(); return !!( fragmentsShown.length || fragmentsHidden.length ); } } return false; } /** * Navigate to the next slide fragment. * * @return {boolean} true if there was a next fragment, * false otherwise */ function nextFragment() { return navigateFragment( null, 1 ); } /** * Navigate to the previous slide fragment. * * @return {boolean} true if there was a previous fragment, * false otherwise */ function previousFragment() { return navigateFragment( null, -1 ); } /** * Cues a new automated slide if enabled in the config. */ function cueAutoSlide() { cancelAutoSlide(); if( currentSlide && config.autoSlide !== false ) { var fragment = currentSlide.querySelector( '.current-fragment' ); // When the slide first appears there is no "current" fragment so // we look for a data-autoslide timing on the first fragment if( !fragment ) fragment = currentSlide.querySelector( '.fragment' ); var fragmentAutoSlide = fragment ? fragment.getAttribute( 'data-autoslide' ) : null; var parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null; var slideAutoSlide = currentSlide.getAttribute( 'data-autoslide' ); // Pick value in the following priority order: // 1. Current fragment's data-autoslide // 2. Current slide's data-autoslide // 3. Parent slide's data-autoslide // 4. Global autoSlide setting if( fragmentAutoSlide ) { autoSlide = parseInt( fragmentAutoSlide, 10 ); } else if( slideAutoSlide ) { autoSlide = parseInt( slideAutoSlide, 10 ); } else if( parentAutoSlide ) { autoSlide = parseInt( parentAutoSlide, 10 ); } else { autoSlide = config.autoSlide; } // If there are media elements with data-autoplay, // automatically set the autoSlide duration to the // length of that media. Not applicable if the slide // is divided up into fragments. // playbackRate is accounted for in the duration. if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) { toArray( currentSlide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( el.hasAttribute( 'data-autoplay' ) ) { if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) { autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000; } } } ); } // Cue the next auto-slide if: // - There is an autoSlide value // - Auto-sliding isn't paused by the user // - The presentation isn't paused // - The overview isn't active // - The presentation isn't over if( autoSlide && !autoSlidePaused && !isPaused() && !isOverview() && ( !Reveal.isLastSlide() || availableFragments().next || config.loop === true ) ) { autoSlideTimeout = setTimeout( function() { typeof config.autoSlideMethod === 'function' ? config.autoSlideMethod() : navigateNext(); cueAutoSlide(); }, autoSlide ); autoSlideStartTime = Date.now(); } if( autoSlidePlayer ) { autoSlidePlayer.setPlaying( autoSlideTimeout !== -1 ); } } } /** * Cancels any ongoing request to auto-slide. */ function cancelAutoSlide() { clearTimeout( autoSlideTimeout ); autoSlideTimeout = -1; } function pauseAutoSlide() { if( autoSlide && !autoSlidePaused ) { autoSlidePaused = true; dispatchEvent( 'autoslidepaused' ); clearTimeout( autoSlideTimeout ); if( autoSlidePlayer ) { autoSlidePlayer.setPlaying( false ); } } } function resumeAutoSlide() { if( autoSlide && autoSlidePaused ) { autoSlidePaused = false; dispatchEvent( 'autoslideresumed' ); cueAutoSlide(); } } function navigateLeft() { // Reverse for RTL if( config.rtl ) { if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) { slide( indexh + 1 ); } } // Normal navigation else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) { slide( indexh - 1 ); } } function navigateRight() { hasNavigatedRight = true; // Reverse for RTL if( config.rtl ) { if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) { slide( indexh - 1 ); } } // Normal navigation else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) { slide( indexh + 1 ); } } function navigateUp() { // Prioritize hiding fragments if( ( isOverview() || previousFragment() === false ) && availableRoutes().up ) { slide( indexh, indexv - 1 ); } } function navigateDown() { hasNavigatedDown = true; // Prioritize revealing fragments if( ( isOverview() || nextFragment() === false ) && availableRoutes().down ) { slide( indexh, indexv + 1 ); } } /** * Navigates backwards, prioritized in the following order: * 1) Previous fragment * 2) Previous vertical slide * 3) Previous horizontal slide */ function navigatePrev() { // Prioritize revealing fragments if( previousFragment() === false ) { if( availableRoutes().up ) { navigateUp(); } else { // Fetch the previous horizontal slide, if there is one var previousSlide; if( config.rtl ) { previousSlide = toArray( dom.wrapper.querySelectorAll( <API key> + '.future' ) ).pop(); } else { previousSlide = toArray( dom.wrapper.querySelectorAll( <API key> + '.past' ) ).pop(); } if( previousSlide ) { var v = ( previousSlide.querySelectorAll( 'section' ).length - 1 ) || undefined; var h = indexh - 1; slide( h, v ); } } } } /** * The reverse of #navigatePrev(). */ function navigateNext() { hasNavigatedRight = true; hasNavigatedDown = true; // Prioritize revealing fragments if( nextFragment() === false ) { if( availableRoutes().down ) { navigateDown(); } else if( config.rtl ) { navigateLeft(); } else { navigateRight(); } } } /** * Checks if the target element prevents the triggering of * swipe navigation. */ function isSwipePrevented( target ) { while( target && typeof target.hasAttribute === 'function' ) { if( target.hasAttribute( 'data-prevent-swipe' ) ) return true; target = target.parentNode; } return false; } /** * Called by all event handlers that are based on user * input. * * @param {object} [event] */ function onUserInput( event ) { if( config.autoSlideStoppable ) { pauseAutoSlide(); } } /** * Handler for the document level 'keypress' event. * * @param {object} event */ function onDocumentKeyPress( event ) { // Check if the pressed key is question mark if( event.shiftKey && event.charCode === 63 ) { toggleHelp(); } } /** * Handler for the document level 'keydown' event. * * @param {object} event */ function onDocumentKeyDown( event ) { // If there's a condition specified and it returns false, // ignore this event if( typeof config.keyboardCondition === 'function' && config.keyboardCondition() === false ) { return true; } // Remember if auto-sliding was paused so we can toggle it var autoSlideWasPaused = autoSlidePaused; onUserInput( event ); // Check if there's a focused element that could be using // the keyboard var activeElementIsCE = document.activeElement && document.activeElement.contentEditable !== 'inherit'; var <API key> = document.activeElement && document.activeElement.tagName && /input|textarea/i.test( document.activeElement.tagName ); var <API key> = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className); // Disregard the event if there's a focused element or a // keyboard modifier key is present if( activeElementIsCE || <API key> || <API key> || (event.shiftKey && event.keyCode !== 32) || event.altKey || event.ctrlKey || event.metaKey ) return; // While paused only allow resume keyboard events; 'b', 'v', '.' var resumeKeyCodes = [66,86,190,191]; var key; // Custom key bindings for togglePause should be able to resume if( typeof config.keyboard === 'object' ) { for( key in config.keyboard ) { if( config.keyboard[key] === 'togglePause' ) { resumeKeyCodes.push( parseInt( key, 10 ) ); } } } if( isPaused() && resumeKeyCodes.indexOf( event.keyCode ) === -1 ) { return false; } var triggered = false; // 1. User defined key bindings if( typeof config.keyboard === 'object' ) { for( key in config.keyboard ) { // Check if this binding matches the pressed key if( parseInt( key, 10 ) === event.keyCode ) { var value = config.keyboard[ key ]; // Callback function if( typeof value === 'function' ) { value.apply( null, [ event ] ); } // String shortcuts to reveal.js API else if( typeof value === 'string' && typeof Reveal[ value ] === 'function' ) { Reveal[ value ].call(); } triggered = true; } } } // 2. System defined key bindings if( triggered === false ) { // Assume true and try to prove false triggered = true; switch( event.keyCode ) { // p, page up case 80: case 33: navigatePrev(); break; // n, page down case 78: case 34: navigateNext(); break; // h, left case 72: case 37: navigateLeft(); break; // l, right case 76: case 39: navigateRight(); break; // k, up case 75: case 38: navigateUp(); break; // j, down case 74: case 40: navigateDown(); break; // home case 36: slide( 0 ); break; // end case 35: slide( Number.MAX_VALUE ); break; // space case 32: isOverview() ? deactivateOverview() : event.shiftKey ? navigatePrev() : navigateNext(); break; // return case 13: isOverview() ? deactivateOverview() : triggered = false; break; // two-spot, semicolon, b, v, period, Logitech presenter tools "black screen" button case 58: case 59: case 66: case 86: case 190: case 191: togglePause(); break; case 70: enterFullscreen(); break; case 65: if ( config.autoSlideStoppable ) toggleAutoSlide( autoSlideWasPaused ); break; default: triggered = false; } } // If the input resulted in a triggered action we should prevent // the browsers default behavior if( triggered ) { event.preventDefault && event.preventDefault(); } // ESC or O key else if ( ( event.keyCode === 27 || event.keyCode === 79 ) && features.transforms3d ) { if( dom.overlay ) { closeOverlay(); } else { toggleOverview(); } event.preventDefault && event.preventDefault(); } // If auto-sliding is enabled we need to cue up // another timeout cueAutoSlide(); } /** * Handler for the 'touchstart' event, enables support for * swipe and pinch gestures. * * @param {object} event */ function onTouchStart( event ) { if( isSwipePrevented( event.target ) ) return true; touch.startX = event.touches[0].clientX; touch.startY = event.touches[0].clientY; touch.startCount = event.touches.length; // If there's two touches we need to memorize the distance // between those two points to detect pinching if( event.touches.length === 2 && config.overview ) { touch.startSpan = distanceBetween( { x: event.touches[1].clientX, y: event.touches[1].clientY }, { x: touch.startX, y: touch.startY } ); } } /** * Handler for the 'touchmove' event. * * @param {object} event */ function onTouchMove( event ) { if( isSwipePrevented( event.target ) ) return true; // Each touch should only trigger one action if( !touch.captured ) { onUserInput( event ); var currentX = event.touches[0].clientX; var currentY = event.touches[0].clientY; // If the touch started with two points and still has // two active touches; test for the pinch gesture if( event.touches.length === 2 && touch.startCount === 2 && config.overview ) { // The current distance in pixels between the two touch points var currentSpan = distanceBetween( { x: event.touches[1].clientX, y: event.touches[1].clientY }, { x: touch.startX, y: touch.startY } ); // If the span is larger than the desire amount we've got // ourselves a pinch if( Math.abs( touch.startSpan - currentSpan ) > touch.threshold ) { touch.captured = true; if( currentSpan < touch.startSpan ) { activateOverview(); } else { deactivateOverview(); } } event.preventDefault(); } // There was only one touch point, look for a swipe else if( event.touches.length === 1 && touch.startCount !== 2 ) { var deltaX = currentX - touch.startX, deltaY = currentY - touch.startY; if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) { touch.captured = true; navigateLeft(); } else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) { touch.captured = true; navigateRight(); } else if( deltaY > touch.threshold ) { touch.captured = true; navigateUp(); } else if( deltaY < -touch.threshold ) { touch.captured = true; navigateDown(); } // If we're embedded, only block touch events if they have // triggered an action if( config.embedded ) { if( touch.captured || isVerticalSlide( currentSlide ) ) { event.preventDefault(); } } // Not embedded? Block them all to avoid needless tossing // around of the viewport in iOS else { event.preventDefault(); } } } // There's a bug with swiping on some Android devices unless // the default action is always prevented else if( UA.match( /android/gi ) ) { event.preventDefault(); } } /** * Handler for the 'touchend' event. * * @param {object} event */ function onTouchEnd( event ) { touch.captured = false; } /** * Convert pointer down to touch start. * * @param {object} event */ function onPointerDown( event ) { if( event.pointerType === event.<API key> || event.pointerType === "touch" ) { event.touches = [{ clientX: event.clientX, clientY: event.clientY }]; onTouchStart( event ); } } /** * Convert pointer move to touch move. * * @param {object} event */ function onPointerMove( event ) { if( event.pointerType === event.<API key> || event.pointerType === "touch" ) { event.touches = [{ clientX: event.clientX, clientY: event.clientY }]; onTouchMove( event ); } } /** * Convert pointer up to touch end. * * @param {object} event */ function onPointerUp( event ) { if( event.pointerType === event.<API key> || event.pointerType === "touch" ) { event.touches = [{ clientX: event.clientX, clientY: event.clientY }]; onTouchEnd( event ); } } /** * Handles mouse wheel scrolling, throttled to avoid skipping * multiple slides. * * @param {object} event */ function <API key>( event ) { if( Date.now() - lastMouseWheelStep > 600 ) { lastMouseWheelStep = Date.now(); var delta = event.detail || -event.wheelDelta; if( delta > 0 ) { navigateNext(); } else if( delta < 0 ) { navigatePrev(); } } } /** * Clicking on the progress bar results in a navigation to the * closest approximate horizontal slide using this equation: * * ( clickX / presentationWidth ) * numberOfSlides * * @param {object} event */ function onProgressClicked( event ) { onUserInput( event ); event.preventDefault(); var slidesTotal = toArray( dom.wrapper.querySelectorAll( <API key> ) ).length; var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal ); if( config.rtl ) { slideIndex = slidesTotal - slideIndex; } slide( slideIndex ); } /** * Event handler for navigation control buttons. */ function <API key>( event ) { event.preventDefault(); onUserInput(); navigateLeft(); } function <API key>( event ) { event.preventDefault(); onUserInput(); navigateRight(); } function onNavigateUpClicked( event ) { event.preventDefault(); onUserInput(); navigateUp(); } function <API key>( event ) { event.preventDefault(); onUserInput(); navigateDown(); } function <API key>( event ) { event.preventDefault(); onUserInput(); navigatePrev(); } function <API key>( event ) { event.preventDefault(); onUserInput(); navigateNext(); } /** * Handler for the window level 'hashchange' event. * * @param {object} [event] */ function onWindowHashChange( event ) { readURL(); } /** * Handler for the window level 'resize' event. * * @param {object} [event] */ function onWindowResize( event ) { layout(); } /** * Handle for the window level 'visibilitychange' event. * * @param {object} [event] */ function <API key>( event ) { var isHidden = document.webkitHidden || document.msHidden || document.hidden; // If, after clicking a link or similar and we're coming back, // focus the document.body to ensure we can use keyboard shortcuts if( isHidden === false && document.activeElement !== document.body ) { // Not all elements support .blur() - SVGs among them. if( typeof document.activeElement.blur === 'function' ) { document.activeElement.blur(); } document.body.focus(); } } /** * Invoked when a slide is and we're in the overview. * * @param {object} event */ function <API key>( event ) { // TODO There's a bug here where the event listeners are not // removed after deactivating the overview. if( eventsAreBound && isOverview() ) { event.preventDefault(); var element = event.target; while( element && !element.nodeName.match( /section/gi ) ) { element = element.parentNode; } if( element && !element.classList.contains( 'disabled' ) ) { deactivateOverview(); if( element.nodeName.match( /section/gi ) ) { var h = parseInt( element.getAttribute( 'data-index-h' ), 10 ), v = parseInt( element.getAttribute( 'data-index-v' ), 10 ); slide( h, v ); } } } } /** * Handles clicks on links that are set to preview in the * iframe overlay. * * @param {object} event */ function <API key>( event ) { if( event.currentTarget && event.currentTarget.hasAttribute( 'href' ) ) { var url = event.currentTarget.getAttribute( 'href' ); if( url ) { showPreview( url ); event.preventDefault(); } } } /** * Handles click on the auto-sliding controls element. * * @param {object} [event] */ function <API key>( event ) { // Replay if( Reveal.isLastSlide() && config.loop === false ) { slide( 0, 0 ); resumeAutoSlide(); } // Resume else if( autoSlidePaused ) { resumeAutoSlide(); } // Pause else { pauseAutoSlide(); } } /** * Constructor for the playback component, which displays * play/pause/progress controls. * * @param {HTMLElement} container The component will append * itself to this * @param {function} progressCheck A method which will be * called frequently to get the current progress on a range * of 0-1 */ function Playback( container, progressCheck ) { // Cosmetics this.diameter = 100; this.diameter2 = this.diameter/2; this.thickness = 6; // Flags if we are currently playing this.playing = false; // Current progress on a 0-1 range this.progress = 0; // Used to loop the animation smoothly this.progressOffset = 1; this.container = container; this.progressCheck = progressCheck; this.canvas = document.createElement( 'canvas' ); this.canvas.className = 'playback'; this.canvas.width = this.diameter; this.canvas.height = this.diameter; this.canvas.style.width = this.diameter2 + 'px'; this.canvas.style.height = this.diameter2 + 'px'; this.context = this.canvas.getContext( '2d' ); this.container.appendChild( this.canvas ); this.render(); } /** * @param value */ Playback.prototype.setPlaying = function( value ) { var wasPlaying = this.playing; this.playing = value; // Start repainting if we weren't already if( !wasPlaying && this.playing ) { this.animate(); } else { this.render(); } }; Playback.prototype.animate = function() { var progressBefore = this.progress; this.progress = this.progressCheck(); // When we loop, offset the progress so that it eases // smoothly rather than immediately resetting if( progressBefore > 0.8 && this.progress < 0.2 ) { this.progressOffset = this.progress; } this.render(); if( this.playing ) { features.<API key>.call( window, this.animate.bind( this ) ); } }; /** * Renders the current progress and playback state. */ Playback.prototype.render = function() { var progress = this.playing ? this.progress : 0, radius = ( this.diameter2 ) - this.thickness, x = this.diameter2, y = this.diameter2, iconSize = 28; // Ease towards 1 this.progressOffset += ( 1 - this.progressOffset ) * 0.1; var endAngle = ( - Math.PI / 2 ) + ( progress * ( Math.PI * 2 ) ); var startAngle = ( - Math.PI / 2 ) + ( this.progressOffset * ( Math.PI * 2 ) ); this.context.save(); this.context.clearRect( 0, 0, this.diameter, this.diameter ); // Solid background color this.context.beginPath(); this.context.arc( x, y, radius + 4, 0, Math.PI * 2, false ); this.context.fillStyle = 'rgba( 0, 0, 0, 0.4 )'; this.context.fill(); // Draw progress track this.context.beginPath(); this.context.arc( x, y, radius, 0, Math.PI * 2, false ); this.context.lineWidth = this.thickness; this.context.strokeStyle = 'rgba( 255, 255, 255, 0.2 )'; this.context.stroke(); if( this.playing ) { // Draw progress on top of track this.context.beginPath(); this.context.arc( x, y, radius, startAngle, endAngle, false ); this.context.lineWidth = this.thickness; this.context.strokeStyle = '#fff'; this.context.stroke(); } this.context.translate( x - ( iconSize / 2 ), y - ( iconSize / 2 ) ); // Draw play/pause icons if( this.playing ) { this.context.fillStyle = '#fff'; this.context.fillRect( 0, 0, iconSize / 2 - 4, iconSize ); this.context.fillRect( iconSize / 2 + 4, 0, iconSize / 2 - 4, iconSize ); } else { this.context.beginPath(); this.context.translate( 4, 0 ); this.context.moveTo( 0, 0 ); this.context.lineTo( iconSize - 4, iconSize / 2 ); this.context.lineTo( 0, iconSize ); this.context.fillStyle = '#fff'; this.context.fill(); } this.context.restore(); }; Playback.prototype.on = function( type, listener ) { this.canvas.addEventListener( type, listener, false ); }; Playback.prototype.off = function( type, listener ) { this.canvas.removeEventListener( type, listener, false ); }; Playback.prototype.destroy = function() { this.playing = false; if( this.canvas.parentNode ) { this.container.removeChild( this.canvas ); } }; Reveal = { VERSION: VERSION, initialize: initialize, configure: configure, sync: sync, // Navigation methods slide: slide, left: navigateLeft, right: navigateRight, up: navigateUp, down: navigateDown, prev: navigatePrev, next: navigateNext, // Fragment methods navigateFragment: navigateFragment, prevFragment: previousFragment, nextFragment: nextFragment, // Deprecated aliases navigateTo: slide, navigateLeft: navigateLeft, navigateRight: navigateRight, navigateUp: navigateUp, navigateDown: navigateDown, navigatePrev: navigatePrev, navigateNext: navigateNext, // Forces an update in slide layout layout: layout, // Randomizes the order of slides shuffle: shuffle, // Returns an object with the available routes as booleans (left/right/top/bottom) availableRoutes: availableRoutes, // Returns an object with the available fragments as booleans (prev/next) availableFragments: availableFragments, // Toggles a help overlay with keyboard shortcuts toggleHelp: toggleHelp, // Toggles the overview mode on/off toggleOverview: toggleOverview, // Toggles the "black screen" mode on/off togglePause: togglePause, // Toggles the auto slide mode on/off toggleAutoSlide: toggleAutoSlide, // State checks isOverview: isOverview, isPaused: isPaused, isAutoSliding: isAutoSliding, isSpeakerNotes: isSpeakerNotes, // Slide preloading loadSlide: loadSlide, unloadSlide: unloadSlide, // Adds or removes all internal event listeners (such as keyboard) addEventListeners: addEventListeners, <API key>: <API key>, // Facility for persisting and restoring the presentation state getState: getState, setState: setState, // Presentation progress getSlidePastCount: getSlidePastCount, // Presentation progress on range of 0-1 getProgress: getProgress, // Returns the indices of the current, or specified, slide getIndices: getIndices, // Returns an Array of all slides getSlides: getSlides, // Returns the total number of slides getTotalSlides: getTotalSlides, // Returns the slide element at the specified index getSlide: getSlide, // Returns the slide background element at the specified index getSlideBackground: getSlideBackground, // Returns the speaker notes string for a slide, or null getSlideNotes: getSlideNotes, // Returns the previous slide element, may be null getPreviousSlide: function() { return previousSlide; }, // Returns the current slide element getCurrentSlide: function() { return currentSlide; }, // Returns the current scale of the presentation content getScale: function() { return scale; }, // Returns the current configuration object getConfig: function() { return config; }, // Helper method, retrieves query string as a key/value hash getQueryHash: function() { var query = {}; location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) { query[ a.split( '=' ).shift() ] = a.split( '=' ).pop(); } ); // Basic deserialization for( var i in query ) { var value = query[ i ]; query[ i ] = deserialize( unescape( value ) ); } return query; }, // Returns true if we're currently on the first slide isFirstSlide: function() { return ( indexh === 0 && indexv === 0 ); }, // Returns true if we're currently on the last slide isLastSlide: function() { if( currentSlide ) { // Does this slide has next a sibling? if( currentSlide.nextElementSibling ) return false; // If it's vertical, does its parent have a next sibling? if( isVerticalSlide( currentSlide ) && currentSlide.parentNode.nextElementSibling ) return false; return true; } return false; }, // Checks if reveal.js has been loaded and is ready for use isReady: function() { return loaded; }, // Forward event binding to the reveal DOM element addEventListener: function( type, listener, useCapture ) { if( 'addEventListener' in window ) { ( dom.wrapper || document.querySelector( '.reveal' ) ).addEventListener( type, listener, useCapture ); } }, removeEventListener: function( type, listener, useCapture ) { if( 'addEventListener' in window ) { ( dom.wrapper || document.querySelector( '.reveal' ) ).removeEventListener( type, listener, useCapture ); } }, // Programatically triggers a keyboard event triggerKey: function( keyCode ) { onDocumentKeyDown( { keyCode: keyCode } ); }, // Registers a new shortcut to include in the help overlay <API key>: function( key, value ) { keyboardShortcuts[key] = value; } }; return Reveal; }));
# Makefile for the linux kernel. # Object file lists. obj-y := mm.o devices.o cpu.o CFLAGS_mm.o = -<API key> CFLAGS_devices.o = -<API key> obj-$(CONFIG_ARCH_MX31) += clock-imx31.o iomux-imx31.o obj-$(CONFIG_ARCH_MX35) += clock-imx35.o obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o obj-$(<API key>) += mach-mx31lilly.o mx31lilly-db.o obj-$(<API key>) += mach-mx31lite.o mx31lite-db.o obj-$(CONFIG_MACH_PCM037) += mach-pcm037.o obj-$(<API key>) += mach-pcm037_eet.o obj-$(<API key>) += mach-mx31_3ds.o <API key>.o = -<API key> obj-$(<API key>) += mach-mx31moboard.o <API key>.o \ mx31moboard-marxbot.o <API key>.o obj-$(CONFIG_MACH_QONG) += mach-qong.o obj-$(CONFIG_MACH_PCM043) += mach-pcm043.o obj-$(<API key>) += mach-armadillo5x0.o obj-$(<API key>) += mach-mx35_3ds.o obj-$(<API key>) += mach-kzm_arm11_01.o obj-$(<API key>) += mach-cpuimx35.o obj-$(<API key>) += <API key>.o
# Makefile for staging directory # fix for build system bug... obj-$(CONFIG_STAGING) += staging.o obj-y += media/ obj-$(CONFIG_ET131X) += et131x/ obj-$(CONFIG_SLICOSS) += slicoss/ obj-$(CONFIG_USBIP_CORE) += usbip/ obj-$(CONFIG_W35UND) += winbond/ obj-$(CONFIG_PRISM2_USB) += wlan-ng/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_COMEDI) += comedi/ obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ obj-$(CONFIG_PANEL) += panel/ obj-$(CONFIG_R8187SE) += rtl8187se/ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_R8712U) += rtl8712/ obj-$(CONFIG_R8188EU) += rtl8188eu/ obj-$(CONFIG_RTS5139) += rts5139/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_IDE_PHISON) += phison/ obj-$(CONFIG_LINE6_USB) += line6/ obj-$(<API key>) += netlogic/ obj-$(<API key>) += serqt_usb2/ obj-$(<API key>) += octeon/ obj-$(CONFIG_OCTEON_USB) += octeon-usb/ obj-$(CONFIG_VT6655) += vt6655/ obj-$(CONFIG_VT6656) += vt6656/ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_ZSMALLOC) += zsmalloc/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/ obj-$(CONFIG_CRYSTALHD) += crystalhd/ obj-$(CONFIG_CXT1E1) += cxt1e1/ obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/ obj-$(<API key>) += quickstart/ obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/ obj-$(<API key>) += keucr/ obj-$(CONFIG_BCM_WIMAX) += bcm/ obj-$(CONFIG_FT1000) += ft1000/ obj-$(CONFIG_SPEAKUP) += speakup/ obj-$(<API key>) += cptm1217/ obj-$(<API key>) += ste_rmi4/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ obj-$(<API key>) += gdm72xx/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ obj-$(<API key>) += silicom/ obj-$(CONFIG_CED1401) += ced1401/ obj-$(CONFIG_DRM_IMX) += imx-drm/ obj-$(CONFIG_DGRP) += dgrp/ obj-$(CONFIG_SB105X) += sb105x/ obj-$(<API key>) += fwserial/ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_USB_DWC2) += dwc2/ obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_USB_BTMTK) += btmtk_usb/ obj-$(CONFIG_XILLYBUS) += xillybus/ obj-$(CONFIG_DGNC) += dgnc/ obj-$(CONFIG_DGAP) += dgap/ obj-$(<API key>) += mt29f_spinand/
// <API key>: GPL-2.0-only #include <linux/interrupt.h> #include <linux/if.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/delay.h> #include <linux/crc32.h> #include <linux/eeprom_93cx6.h> #include <linux/module.h> #include <net/mac80211.h> #include "adm8211.h" MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); MODULE_AUTHOR("Jouni Malinen <j@w1.fi>"); MODULE_DESCRIPTION("Driver for IEEE 802.11b wireless cards based on ADMtek ADM8211"); <API key>("ADM8211"); MODULE_LICENSE("GPL"); static unsigned int tx_ring_size __read_mostly = 16; static unsigned int rx_ring_size __read_mostly = 16; module_param(tx_ring_size, uint, 0); module_param(rx_ring_size, uint, 0); static const struct pci_device_id <API key>[] = { /* ADMtek ADM8211 */ { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */ { PCI_DEVICE(0x1200, 0x8201) }, { PCI_DEVICE(0x1317, 0x8201) }, /* ADM8211A */ { PCI_DEVICE(0x1317, 0x8211) }, /* ADM8211B/C */ { 0 } }; static struct ieee80211_rate adm8211_rates[] = { { .bitrate = 10, .flags = <API key> }, { .bitrate = 20, .flags = <API key> }, { .bitrate = 55, .flags = <API key> }, { .bitrate = 110, .flags = <API key> }, { .bitrate = 220, .flags = <API key> }, }; static const struct ieee80211_channel adm8211_channels[] = { { .center_freq = 2412}, { .center_freq = 2417}, { .center_freq = 2422}, { .center_freq = 2427}, { .center_freq = 2432}, { .center_freq = 2437}, { .center_freq = 2442}, { .center_freq = 2447}, { .center_freq = 2452}, { .center_freq = 2457}, { .center_freq = 2462}, { .center_freq = 2467}, { .center_freq = 2472}, { .center_freq = 2484}, }; static void <API key>(struct eeprom_93cx6 *eeprom) { struct adm8211_priv *priv = eeprom->data; u32 reg = ADM8211_CSR_READ(SPR); eeprom->reg_data_in = reg & ADM8211_SPR_SDI; eeprom->reg_data_out = reg & ADM8211_SPR_SDO; eeprom->reg_data_clock = reg & ADM8211_SPR_SCLK; eeprom->reg_chip_select = reg & ADM8211_SPR_SCS; } static void <API key>(struct eeprom_93cx6 *eeprom) { struct adm8211_priv *priv = eeprom->data; u32 reg = 0x4000 | ADM8211_SPR_SRS; if (eeprom->reg_data_in) reg |= ADM8211_SPR_SDI; if (eeprom->reg_data_out) reg |= ADM8211_SPR_SDO; if (eeprom->reg_data_clock) reg |= ADM8211_SPR_SCLK; if (eeprom->reg_chip_select) reg |= ADM8211_SPR_SCS; ADM8211_CSR_WRITE(SPR, reg); ADM8211_CSR_READ(SPR); /* eeprom_delay */ } static int adm8211_read_eeprom(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; unsigned int words, i; struct <API key> chan_range; u16 cr49; struct eeprom_93cx6 eeprom = { .data = priv, .register_read = <API key>, .register_write = <API key> }; if (ADM8211_CSR_READ(CSR_TEST0) & <API key>) { /* 256 * 16-bit = 512 bytes */ eeprom.width = <API key>; words = 256; } else { /* 64 * 16-bit = 128 bytes */ eeprom.width = <API key>; words = 64; } priv->eeprom_len = words * 2; priv->eeprom = kmalloc(priv->eeprom_len, GFP_KERNEL); if (!priv->eeprom) return -ENOMEM; <API key>(&eeprom, 0, (__le16 *)priv->eeprom, words); cr49 = le16_to_cpu(priv->eeprom->cr49); priv->rf_type = (cr49 >> 3) & 0x7; switch (priv->rf_type) { case <API key>: case ADM8211_TYPE_RFMD: case ADM8211_TYPE_MARVEL: case ADM8211_TYPE_AIROHA: case ADM8211_TYPE_ADMTEK: break; default: if (priv->pdev->revision < ADM8211_REV_CA) priv->rf_type = ADM8211_TYPE_RFMD; else priv->rf_type = ADM8211_TYPE_AIROHA; printk(KERN_WARNING "%s (adm8211): Unknown RFtype %d\n", pci_name(priv->pdev), (cr49 >> 3) & 0x7); } priv->bbp_type = cr49 & 0x7; switch (priv->bbp_type) { case <API key>: case ADM8211_TYPE_RFMD: case ADM8211_TYPE_MARVEL: case ADM8211_TYPE_AIROHA: case ADM8211_TYPE_ADMTEK: break; default: if (priv->pdev->revision < ADM8211_REV_CA) priv->bbp_type = ADM8211_TYPE_RFMD; else priv->bbp_type = ADM8211_TYPE_ADMTEK; printk(KERN_WARNING "%s (adm8211): Unknown BBPtype: %d\n", pci_name(priv->pdev), cr49 >> 3); } if (priv->eeprom->country_code >= ARRAY_SIZE(cranges)) { printk(KERN_WARNING "%s (adm8211): Invalid country code (%d)\n", pci_name(priv->pdev), priv->eeprom->country_code); chan_range = cranges[2]; } else chan_range = cranges[priv->eeprom->country_code]; printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n", pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max); BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels)); memcpy(priv->channels, adm8211_channels, sizeof(priv->channels)); priv->band.channels = priv->channels; priv->band.n_channels = ARRAY_SIZE(adm8211_channels); priv->band.bitrates = adm8211_rates; priv->band.n_bitrates = ARRAY_SIZE(adm8211_rates); for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++) if (i < chan_range.min || i > chan_range.max) priv->channels[i - 1].flags |= <API key>; switch (priv->eeprom->specific_bbptype) { case <API key>: case <API key>: case ADM8211_BBP_ADM8011: priv->specific_bbptype = priv->eeprom->specific_bbptype; break; default: if (priv->pdev->revision < ADM8211_REV_CA) priv->specific_bbptype = <API key>; else priv->specific_bbptype = ADM8211_BBP_ADM8011; printk(KERN_WARNING "%s (adm8211): Unknown specific BBP: %d\n", pci_name(priv->pdev), priv->eeprom->specific_bbptype); } switch (priv->eeprom->specific_rftype) { case ADM8211_RFMD2948: case ADM8211_RFMD2958: case <API key>: case ADM8211_MAX2820: case ADM8211_AL2210L: priv->transceiver_type = priv->eeprom->specific_rftype; break; default: if (priv->pdev->revision == ADM8211_REV_BA) priv->transceiver_type = <API key>; else if (priv->pdev->revision == ADM8211_REV_CA) priv->transceiver_type = ADM8211_AL2210L; else if (priv->pdev->revision == ADM8211_REV_AB) priv->transceiver_type = ADM8211_RFMD2948; printk(KERN_WARNING "%s (adm8211): Unknown transceiver: %d\n", pci_name(priv->pdev), priv->eeprom->specific_rftype); break; } printk(KERN_DEBUG "%s (adm8211): RFtype=%d BBPtype=%d Specific BBP=%d " "Transceiver=%d\n", pci_name(priv->pdev), priv->rf_type, priv->bbp_type, priv->specific_bbptype, priv->transceiver_type); return 0; } static inline void adm8211_write_sram(struct ieee80211_hw *dev, u32 addr, u32 data) { struct adm8211_priv *priv = dev->priv; ADM8211_CSR_WRITE(WEPCTL, addr | <API key> | (priv->pdev->revision < ADM8211_REV_BA ? 0 : <API key> )); ADM8211_CSR_READ(WEPCTL); msleep(1); ADM8211_CSR_WRITE(WESK, data); ADM8211_CSR_READ(WESK); msleep(1); } static void <API key>(struct ieee80211_hw *dev, unsigned int addr, u8 *buf, unsigned int len) { struct adm8211_priv *priv = dev->priv; u32 reg = ADM8211_CSR_READ(WEPCTL); unsigned int i; if (priv->pdev->revision < ADM8211_REV_BA) { for (i = 0; i < len; i += 2) { u16 val = buf[i] | (buf[i + 1] << 8); adm8211_write_sram(dev, addr + i / 2, val); } } else { for (i = 0; i < len; i += 4) { u32 val = (buf[i + 0] << 0 ) | (buf[i + 1] << 8 ) | (buf[i + 2] << 16) | (buf[i + 3] << 24); adm8211_write_sram(dev, addr + i / 4, val); } } ADM8211_CSR_WRITE(WEPCTL, reg); } static void adm8211_clear_sram(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; u32 reg = ADM8211_CSR_READ(WEPCTL); unsigned int addr; for (addr = 0; addr < ADM8211_SRAM_SIZE; addr++) adm8211_write_sram(dev, addr, 0); ADM8211_CSR_WRITE(WEPCTL, reg); } static int adm8211_get_stats(struct ieee80211_hw *dev, struct <API key> *stats) { struct adm8211_priv *priv = dev->priv; memcpy(stats, &priv->stats, sizeof(*stats)); return 0; } static void <API key>(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; unsigned int dirty_tx; spin_lock(&priv->lock); for (dirty_tx = priv->dirty_tx; priv->cur_tx - dirty_tx; dirty_tx++) { unsigned int entry = dirty_tx % priv->tx_ring_size; u32 status = le32_to_cpu(priv->tx_ring[entry].status); struct ieee80211_tx_info *txi; struct <API key> *info; struct sk_buff *skb; if (status & TDES0_CONTROL_OWN || !(status & TDES0_CONTROL_DONE)) break; info = &priv->tx_buffers[entry]; skb = info->skb; txi = IEEE80211_SKB_CB(skb); /* TODO: check TDES0_STATUS_TUF and TDES0_STATUS_TRO */ pci_unmap_single(priv->pdev, info->mapping, info->skb->len, PCI_DMA_TODEVICE); <API key>(txi); skb_pull(skb, sizeof(struct adm8211_tx_hdr)); memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen); if (!(txi->flags & <API key>) && !(status & TDES0_STATUS_ES)) txi->flags |= <API key>; <API key>(dev, skb); info->skb = NULL; } if (priv->cur_tx - dirty_tx < priv->tx_ring_size - 2) <API key>(dev, 0); priv->dirty_tx = dirty_tx; spin_unlock(&priv->lock); } static void <API key>(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; unsigned int entry = priv->cur_rx % priv->rx_ring_size; u32 status; unsigned int pktlen; struct sk_buff *skb, *newskb; unsigned int limit = priv->rx_ring_size; u8 rssi, rate; while (!(priv->rx_ring[entry].status & cpu_to_le32(RDES0_STATUS_OWN))) { if (!limit break; status = le32_to_cpu(priv->rx_ring[entry].status); rate = (status & RDES0_STATUS_RXDR) >> 12; rssi = le32_to_cpu(priv->rx_ring[entry].length) & RDES1_STATUS_RSSI; pktlen = status & RDES0_STATUS_FL; if (pktlen > RX_PKT_SIZE) { if (net_ratelimit()) wiphy_debug(dev->wiphy, "frame too long (%d)\n", pktlen); pktlen = RX_PKT_SIZE; } if (!priv->soft_rx_crc && status & RDES0_STATUS_ES) { skb = NULL; /* old buffer will be reused */ /* TODO: update RX error stats */ /* TODO: check RDES0_STATUS_CRC*E */ } else if (pktlen < RX_COPY_BREAK) { skb = dev_alloc_skb(pktlen); if (skb) { <API key>( priv->pdev, priv->rx_buffers[entry].mapping, pktlen, PCI_DMA_FROMDEVICE); skb_put_data(skb, skb_tail_pointer(priv->rx_buffers[entry].skb), pktlen); <API key>( priv->pdev, priv->rx_buffers[entry].mapping, RX_PKT_SIZE, PCI_DMA_FROMDEVICE); } } else { newskb = dev_alloc_skb(RX_PKT_SIZE); if (newskb) { skb = priv->rx_buffers[entry].skb; skb_put(skb, pktlen); pci_unmap_single( priv->pdev, priv->rx_buffers[entry].mapping, RX_PKT_SIZE, PCI_DMA_FROMDEVICE); priv->rx_buffers[entry].skb = newskb; priv->rx_buffers[entry].mapping = pci_map_single(priv->pdev, skb_tail_pointer(newskb), RX_PKT_SIZE, PCI_DMA_FROMDEVICE); if (<API key>(priv->pdev, priv->rx_buffers[entry].mapping)) { priv->rx_buffers[entry].skb = NULL; dev_kfree_skb(newskb); skb = NULL; /* TODO: update rx dropped stats */ } } else { skb = NULL; /* TODO: update rx dropped stats */ } priv->rx_ring[entry].buffer1 = cpu_to_le32(priv->rx_buffers[entry].mapping); } priv->rx_ring[entry].status = cpu_to_le32(RDES0_STATUS_OWN | RDES0_STATUS_SQL); priv->rx_ring[entry].length = cpu_to_le32(RX_PKT_SIZE | (entry == priv->rx_ring_size - 1 ? RDES1_CONTROL_RER : 0)); if (skb) { struct ieee80211_rx_status rx_status = {0}; if (priv->pdev->revision < ADM8211_REV_CA) rx_status.signal = rssi; else rx_status.signal = 100 - rssi; rx_status.rate_idx = rate; rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; rx_status.band = NL80211_BAND_2GHZ; memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); <API key>(dev, skb); } entry = (++priv->cur_rx) % priv->rx_ring_size; } /* TODO: check LPC and update stats? */ } static irqreturn_t adm8211_interrupt(int irq, void *dev_id) { #define ADM8211_INT(x) \ do { \ if (unlikely(stsr & ADM8211_STSR_ wiphy_debug(dev->wiphy, "%s\n", } while (0) struct ieee80211_hw *dev = dev_id; struct adm8211_priv *priv = dev->priv; u32 stsr = ADM8211_CSR_READ(STSR); ADM8211_CSR_WRITE(STSR, stsr); if (stsr == 0xffffffff) return IRQ_HANDLED; if (!(stsr & (ADM8211_STSR_NISS | ADM8211_STSR_AISS))) return IRQ_HANDLED; if (stsr & ADM8211_STSR_RCI) <API key>(dev); if (stsr & ADM8211_STSR_TCI) <API key>(dev); ADM8211_INT(PCF); ADM8211_INT(BCNTC); ADM8211_INT(GPINT); ADM8211_INT(ATIMTC); ADM8211_INT(TSFTF); ADM8211_INT(TSCZ); ADM8211_INT(SQL); ADM8211_INT(WEPTD); ADM8211_INT(ATIME); ADM8211_INT(TEIS); ADM8211_INT(FBE); ADM8211_INT(REIS); ADM8211_INT(GPTT); ADM8211_INT(RPS); ADM8211_INT(RDU); ADM8211_INT(TUF); ADM8211_INT(TPS); return IRQ_HANDLED; #undef ADM8211_INT } #define WRITE_SYN(name,v_mask,v_shift,a_mask,a_shift,bits,prewrite,postwrite)\ static void <API key> ## name (struct ieee80211_hw *dev, \ u16 addr, u32 value) { \ struct adm8211_priv *priv = dev->priv; \ unsigned int i; \ u32 reg, bitbuf; \ \ value &= v_mask; \ addr &= a_mask; \ bitbuf = (value << v_shift) | (addr << a_shift); \ \ ADM8211_CSR_WRITE(SYNRF, <API key>); \ ADM8211_CSR_READ(SYNRF); \ ADM8211_CSR_WRITE(SYNRF, <API key>); \ ADM8211_CSR_READ(SYNRF); \ \ if (prewrite) { \ ADM8211_CSR_WRITE(SYNRF, <API key>); \ ADM8211_CSR_READ(SYNRF); \ } \ \ for (i = 0; i <= bits; i++) { \ if (bitbuf & (1 << (bits - i))) \ reg = <API key>; \ else \ reg = <API key>; \ \ ADM8211_CSR_WRITE(SYNRF, reg); \ ADM8211_CSR_READ(SYNRF); \ \ ADM8211_CSR_WRITE(SYNRF, reg | <API key>); \ ADM8211_CSR_READ(SYNRF); \ ADM8211_CSR_WRITE(SYNRF, reg | <API key>); \ ADM8211_CSR_READ(SYNRF); \ } \ \ if (postwrite == 1) { \ ADM8211_CSR_WRITE(SYNRF, reg | <API key>); \ ADM8211_CSR_READ(SYNRF); \ } \ if (postwrite == 2) { \ ADM8211_CSR_WRITE(SYNRF, reg | <API key>); \ ADM8211_CSR_READ(SYNRF); \ } \ \ ADM8211_CSR_WRITE(SYNRF, 0); \ ADM8211_CSR_READ(SYNRF); \ } WRITE_SYN(max2820, 0x00FFF, 0, 0x0F, 12, 15, 1, 1) WRITE_SYN(al2210l, 0xFFFFF, 4, 0x0F, 0, 23, 1, 1) WRITE_SYN(rfmd2958, 0x3FFFF, 0, 0x1F, 18, 23, 0, 1) WRITE_SYN(rfmd2948, 0x0FFFF, 4, 0x0F, 0, 21, 0, 2) #undef WRITE_SYN static int adm8211_write_bbp(struct ieee80211_hw *dev, u8 addr, u8 data) { struct adm8211_priv *priv = dev->priv; unsigned int timeout; u32 reg; timeout = 10; while (timeout > 0) { reg = ADM8211_CSR_READ(BBPCTL); if (!(reg & (ADM8211_BBPCTL_WR | ADM8211_BBPCTL_RD))) break; timeout msleep(2); } if (timeout == 0) { wiphy_debug(dev->wiphy, "adm8211_write_bbp(%d,%d) failed prewrite (reg=0x%08x)\n", addr, data, reg); return -ETIMEDOUT; } switch (priv->bbp_type) { case <API key>: reg = <API key>; /* three wire interface */ break; case ADM8211_TYPE_RFMD: reg = (0x20 << 24) | ADM8211_BBPCTL_TXCE | ADM8211_BBPCTL_CCAP | (0x01 << 18); break; case ADM8211_TYPE_ADMTEK: reg = (0x20 << 24) | ADM8211_BBPCTL_TXCE | ADM8211_BBPCTL_CCAP | (0x05 << 18); break; } reg |= ADM8211_BBPCTL_WR | (addr << 8) | data; ADM8211_CSR_WRITE(BBPCTL, reg); timeout = 10; while (timeout > 0) { reg = ADM8211_CSR_READ(BBPCTL); if (!(reg & ADM8211_BBPCTL_WR)) break; timeout msleep(2); } if (timeout == 0) { ADM8211_CSR_WRITE(BBPCTL, ADM8211_CSR_READ(BBPCTL) & ~ADM8211_BBPCTL_WR); wiphy_debug(dev->wiphy, "adm8211_write_bbp(%d,%d) failed postwrite (reg=0x%08x)\n", addr, data, reg); return -ETIMEDOUT; } return 0; } static int <API key>(struct ieee80211_hw *dev, unsigned int chan) { static const u32 <API key>[] = {0x22BD, 0x22D2, 0x22E8, 0x22FE, 0x2314, 0x232A, 0x2340, 0x2355, 0x236B, 0x2381, 0x2397, 0x23AD, 0x23C2, 0x23F7}; static const u32 <API key>[] = {0x05D17, 0x3A2E8, 0x2E8BA, 0x22E8B, 0x1745D, 0x0BA2E, 0x00000, 0x345D1, 0x28BA2, 0x1D174, 0x11745, 0x05D17, 0x3A2E8, 0x11745}; struct adm8211_priv *priv = dev->priv; u8 ant_power = priv->ant_power > 0x3F ? priv->eeprom->antenna_power[chan - 1] : priv->ant_power; u8 tx_power = priv->tx_power > 0x3F ? priv->eeprom->tx_power[chan - 1] : priv->tx_power; u8 lpf_cutoff = priv->lpf_cutoff == 0xFF ? priv->eeprom->lpf_cutoff[chan - 1] : priv->lpf_cutoff; u8 lnags_thresh = priv->lnags_threshold == 0xFF ? priv->eeprom->lnags_threshold[chan - 1] : priv->lnags_threshold; u32 reg; ADM8211_IDLE(); /* Program synthesizer to new channel */ switch (priv->transceiver_type) { case ADM8211_RFMD2958: case <API key>: <API key>(dev, 0x00, 0x04007); <API key>(dev, 0x02, 0x00033); <API key>(dev, 0x05, <API key>[chan - 1]); <API key>(dev, 0x06, <API key>[chan - 1]); break; case ADM8211_RFMD2948: <API key>(dev, SI4126_MAIN_CONF, SI4126_MAIN_XINDIV2); <API key>(dev, SI4126_POWERDOWN, <API key> | <API key>); <API key>(dev, <API key>, 0); <API key>(dev, SI4126_RF2_N_DIV, (chan == 14 ? 2110 : (2033 + (chan * 5)))); <API key>(dev, SI4126_IF_N_DIV, 1496); <API key>(dev, SI4126_RF2_R_DIV, 44); <API key>(dev, SI4126_IF_R_DIV, 44); break; case ADM8211_MAX2820: <API key>(dev, 0x3, (chan == 14 ? 0x054 : (0x7 + (chan * 5)))); break; case ADM8211_AL2210L: <API key>(dev, 0x0, (chan == 14 ? 0x229B4 : (0x22967 + (chan * 5)))); break; default: wiphy_debug(dev->wiphy, "unsupported transceiver type %d\n", priv->transceiver_type); break; } /* write BBP regs */ if (priv->bbp_type == ADM8211_TYPE_RFMD) { /* SMC 2635W specific? adm8211b doesn't use the 2948 though.. */ /* TODO: remove if SMC 2635W doesn't need this */ if (priv->transceiver_type == ADM8211_RFMD2948) { reg = ADM8211_CSR_READ(GPIO); reg &= 0xfffc0000; reg |= <API key>; if (chan != 14) reg |= ADM8211_CSR_GPIO_O0; ADM8211_CSR_WRITE(GPIO, reg); } if (priv->transceiver_type == ADM8211_RFMD2958) { /* set PCNT2 */ <API key>(dev, 0x0B, 0x07100); /* set PCNT1 P_DESIRED/MID_BIAS */ reg = le16_to_cpu(priv->eeprom->cr49); reg >>= 13; reg <<= 15; reg |= ant_power << 9; <API key>(dev, 0x0A, reg); /* set TXRX TX_GAIN */ <API key>(dev, 0x09, 0x00050 | (priv->pdev->revision < ADM8211_REV_CA ? tx_power : 0)); } else { reg = ADM8211_CSR_READ(PLCPHD); reg &= 0xff00ffff; reg |= tx_power << 18; ADM8211_CSR_WRITE(PLCPHD, reg); } ADM8211_CSR_WRITE(SYNRF, ADM8211_SYNRF_SELRF | ADM8211_SYNRF_PE1 | <API key>); ADM8211_CSR_READ(SYNRF); msleep(30); /* RF3000 BBP */ if (priv->transceiver_type != ADM8211_RFMD2958) adm8211_write_bbp(dev, <API key>, tx_power<<2); adm8211_write_bbp(dev, <API key>, lpf_cutoff); adm8211_write_bbp(dev, <API key>, lnags_thresh); adm8211_write_bbp(dev, 0x1c, priv->pdev->revision == ADM8211_REV_BA ? priv->eeprom->cr28 : 0); adm8211_write_bbp(dev, 0x1d, priv->eeprom->cr29); ADM8211_CSR_WRITE(SYNRF, 0); /* Nothing to do for ADMtek BBP */ } else if (priv->bbp_type != ADM8211_TYPE_ADMTEK) wiphy_debug(dev->wiphy, "unsupported BBP type %d\n", priv->bbp_type); ADM8211_RESTORE(); /* update current channel for adhoc (and maybe AP mode) */ reg = ADM8211_CSR_READ(CAP0); reg &= ~0xF; reg |= chan; ADM8211_CSR_WRITE(CAP0, reg); return 0; } static void adm8211_update_mode(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; ADM8211_IDLE(); priv->soft_rx_crc = 0; switch (priv->mode) { case <API key>: priv->nar &= ~(ADM8211_NAR_PR | ADM8211_NAR_EA); priv->nar |= ADM8211_NAR_ST | ADM8211_NAR_SR; break; case <API key>: priv->nar &= ~ADM8211_NAR_PR; priv->nar |= ADM8211_NAR_EA | ADM8211_NAR_ST | ADM8211_NAR_SR; /* don't trust the error bits on rev 0x20 and up in adhoc */ if (priv->pdev->revision >= ADM8211_REV_BA) priv->soft_rx_crc = 1; break; case <API key>: priv->nar &= ~(ADM8211_NAR_EA | ADM8211_NAR_ST); priv->nar |= ADM8211_NAR_PR | ADM8211_NAR_SR; break; } ADM8211_RESTORE(); } static void adm8211_hw_init_syn(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; switch (priv->transceiver_type) { case ADM8211_RFMD2958: case <API key>: /* comments taken from ADMtek vendor driver */ /* Reset RF2958 after power on */ <API key>(dev, 0x1F, 0x00000); /* Initialize RF VCO Core Bias to maximum */ <API key>(dev, 0x0C, 0x3001F); /* Initialize IF PLL */ <API key>(dev, 0x01, 0x29C03); /* Initialize IF PLL Coarse Tuning */ <API key>(dev, 0x03, 0x1FF6F); /* Initialize RF PLL */ <API key>(dev, 0x04, 0x29403); /* Initialize RF PLL Coarse Tuning */ <API key>(dev, 0x07, 0x1456F); /* Initialize TX gain and filter BW (R9) */ <API key>(dev, 0x09, (priv->transceiver_type == ADM8211_RFMD2958 ? 0x10050 : 0x00050)); /* Initialize CAL register */ <API key>(dev, 0x08, 0x3FFF8); break; case ADM8211_MAX2820: <API key>(dev, 0x1, 0x01E); <API key>(dev, 0x2, 0x001); <API key>(dev, 0x3, 0x054); <API key>(dev, 0x4, 0x310); <API key>(dev, 0x5, 0x000); break; case ADM8211_AL2210L: <API key>(dev, 0x0, 0x0196C); <API key>(dev, 0x1, 0x007CB); <API key>(dev, 0x2, 0x3582F); <API key>(dev, 0x3, 0x010A9); <API key>(dev, 0x4, 0x77280); <API key>(dev, 0x5, 0x45641); <API key>(dev, 0x6, 0xEA130); <API key>(dev, 0x7, 0x80000); <API key>(dev, 0x8, 0x7850F); <API key>(dev, 0x9, 0xF900C); <API key>(dev, 0xA, 0x00000); <API key>(dev, 0xB, 0x00000); break; case ADM8211_RFMD2948: default: break; } } static int adm8211_hw_init_bbp(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; u32 reg; /* write addresses */ if (priv->bbp_type == <API key>) { ADM8211_CSR_WRITE(MMIWA, 0x100E0C0A); ADM8211_CSR_WRITE(MMIRD0, 0x00007C7E); ADM8211_CSR_WRITE(MMIRD1, 0x00100000); } else if (priv->bbp_type == ADM8211_TYPE_RFMD || priv->bbp_type == ADM8211_TYPE_ADMTEK) { /* check specific BBP type */ switch (priv->specific_bbptype) { case <API key>: case <API key>: ADM8211_CSR_WRITE(MMIWA, 0x00009101); ADM8211_CSR_WRITE(MMIRD0, 0x00000301); break; case ADM8211_BBP_ADM8011: ADM8211_CSR_WRITE(MMIWA, 0x00008903); ADM8211_CSR_WRITE(MMIRD0, 0x00001716); reg = ADM8211_CSR_READ(BBPCTL); reg &= ~ADM8211_BBPCTL_TYPE; reg |= 0x5 << 18; ADM8211_CSR_WRITE(BBPCTL, reg); break; } switch (priv->pdev->revision) { case ADM8211_REV_CA: if (priv->transceiver_type == ADM8211_RFMD2958 || priv->transceiver_type == <API key> || priv->transceiver_type == ADM8211_RFMD2948) ADM8211_CSR_WRITE(SYNCTL, 0x1 << 22); else if (priv->transceiver_type == ADM8211_MAX2820 || priv->transceiver_type == ADM8211_AL2210L) ADM8211_CSR_WRITE(SYNCTL, 0x3 << 22); break; case ADM8211_REV_BA: reg = ADM8211_CSR_READ(MMIRD1); reg &= 0x0000FFFF; reg |= 0x7e100000; ADM8211_CSR_WRITE(MMIRD1, reg); break; case ADM8211_REV_AB: case ADM8211_REV_AF: default: ADM8211_CSR_WRITE(MMIRD1, 0x7e100000); break; } /* For RFMD */ ADM8211_CSR_WRITE(MACTEST, 0x800); } adm8211_hw_init_syn(dev); /* Set RF Power control IF pin to PE1+PHYRST# */ ADM8211_CSR_WRITE(SYNRF, ADM8211_SYNRF_SELRF | ADM8211_SYNRF_PE1 | <API key>); ADM8211_CSR_READ(SYNRF); msleep(20); /* write BBP regs */ if (priv->bbp_type == ADM8211_TYPE_RFMD) { /* RF3000 BBP */ /* another set: * 11: c8 * 14: 14 * 15: 50 (chan 1..13; chan 14: d0) * 1c: 00 * 1d: 84 */ adm8211_write_bbp(dev, RF3000_CCA_CTRL, 0x80); /* antenna selection: diversity */ adm8211_write_bbp(dev, <API key>, 0x80); adm8211_write_bbp(dev, <API key>, 0x74); adm8211_write_bbp(dev, <API key>, 0x38); adm8211_write_bbp(dev, <API key>, 0x40); if (priv->eeprom->major_version < 2) { adm8211_write_bbp(dev, 0x1c, 0x00); adm8211_write_bbp(dev, 0x1d, 0x80); } else { if (priv->pdev->revision == ADM8211_REV_BA) adm8211_write_bbp(dev, 0x1c, priv->eeprom->cr28); else adm8211_write_bbp(dev, 0x1c, 0x00); adm8211_write_bbp(dev, 0x1d, priv->eeprom->cr29); } } else if (priv->bbp_type == ADM8211_TYPE_ADMTEK) { /* reset baseband */ adm8211_write_bbp(dev, 0x00, 0xFF); /* antenna selection: diversity */ adm8211_write_bbp(dev, 0x07, 0x0A); /* TODO: find documentation for this */ switch (priv->transceiver_type) { case ADM8211_RFMD2958: case <API key>: adm8211_write_bbp(dev, 0x00, 0x00); adm8211_write_bbp(dev, 0x01, 0x00); adm8211_write_bbp(dev, 0x02, 0x00); adm8211_write_bbp(dev, 0x03, 0x00); adm8211_write_bbp(dev, 0x06, 0x0f); adm8211_write_bbp(dev, 0x09, 0x00); adm8211_write_bbp(dev, 0x0a, 0x00); adm8211_write_bbp(dev, 0x0b, 0x00); adm8211_write_bbp(dev, 0x0c, 0x00); adm8211_write_bbp(dev, 0x0f, 0xAA); adm8211_write_bbp(dev, 0x10, 0x8c); adm8211_write_bbp(dev, 0x11, 0x43); adm8211_write_bbp(dev, 0x18, 0x40); adm8211_write_bbp(dev, 0x20, 0x23); adm8211_write_bbp(dev, 0x21, 0x02); adm8211_write_bbp(dev, 0x22, 0x28); adm8211_write_bbp(dev, 0x23, 0x30); adm8211_write_bbp(dev, 0x24, 0x2d); adm8211_write_bbp(dev, 0x28, 0x35); adm8211_write_bbp(dev, 0x2a, 0x8c); adm8211_write_bbp(dev, 0x2b, 0x81); adm8211_write_bbp(dev, 0x2c, 0x44); adm8211_write_bbp(dev, 0x2d, 0x0A); adm8211_write_bbp(dev, 0x29, 0x40); adm8211_write_bbp(dev, 0x60, 0x08); adm8211_write_bbp(dev, 0x64, 0x01); break; case ADM8211_MAX2820: adm8211_write_bbp(dev, 0x00, 0x00); adm8211_write_bbp(dev, 0x01, 0x00); adm8211_write_bbp(dev, 0x02, 0x00); adm8211_write_bbp(dev, 0x03, 0x00); adm8211_write_bbp(dev, 0x06, 0x0f); adm8211_write_bbp(dev, 0x09, 0x05); adm8211_write_bbp(dev, 0x0a, 0x02); adm8211_write_bbp(dev, 0x0b, 0x00); adm8211_write_bbp(dev, 0x0c, 0x0f); adm8211_write_bbp(dev, 0x0f, 0x55); adm8211_write_bbp(dev, 0x10, 0x8d); adm8211_write_bbp(dev, 0x11, 0x43); adm8211_write_bbp(dev, 0x18, 0x4a); adm8211_write_bbp(dev, 0x20, 0x20); adm8211_write_bbp(dev, 0x21, 0x02); adm8211_write_bbp(dev, 0x22, 0x23); adm8211_write_bbp(dev, 0x23, 0x30); adm8211_write_bbp(dev, 0x24, 0x2d); adm8211_write_bbp(dev, 0x2a, 0x8c); adm8211_write_bbp(dev, 0x2b, 0x81); adm8211_write_bbp(dev, 0x2c, 0x44); adm8211_write_bbp(dev, 0x29, 0x4a); adm8211_write_bbp(dev, 0x60, 0x2b); adm8211_write_bbp(dev, 0x64, 0x01); break; case ADM8211_AL2210L: adm8211_write_bbp(dev, 0x00, 0x00); adm8211_write_bbp(dev, 0x01, 0x00); adm8211_write_bbp(dev, 0x02, 0x00); adm8211_write_bbp(dev, 0x03, 0x00); adm8211_write_bbp(dev, 0x06, 0x0f); adm8211_write_bbp(dev, 0x07, 0x05); adm8211_write_bbp(dev, 0x08, 0x03); adm8211_write_bbp(dev, 0x09, 0x00); adm8211_write_bbp(dev, 0x0a, 0x00); adm8211_write_bbp(dev, 0x0b, 0x00); adm8211_write_bbp(dev, 0x0c, 0x10); adm8211_write_bbp(dev, 0x0f, 0x55); adm8211_write_bbp(dev, 0x10, 0x8d); adm8211_write_bbp(dev, 0x11, 0x43); adm8211_write_bbp(dev, 0x18, 0x4a); adm8211_write_bbp(dev, 0x20, 0x20); adm8211_write_bbp(dev, 0x21, 0x02); adm8211_write_bbp(dev, 0x22, 0x23); adm8211_write_bbp(dev, 0x23, 0x30); adm8211_write_bbp(dev, 0x24, 0x2d); adm8211_write_bbp(dev, 0x2a, 0xaa); adm8211_write_bbp(dev, 0x2b, 0x81); adm8211_write_bbp(dev, 0x2c, 0x44); adm8211_write_bbp(dev, 0x29, 0xfa); adm8211_write_bbp(dev, 0x60, 0x2d); adm8211_write_bbp(dev, 0x64, 0x01); break; case ADM8211_RFMD2948: break; default: wiphy_debug(dev->wiphy, "unsupported transceiver %d\n", priv->transceiver_type); break; } } else wiphy_debug(dev->wiphy, "unsupported BBP %d\n", priv->bbp_type); ADM8211_CSR_WRITE(SYNRF, 0); /* Set RF CAL control source to MAC control */ reg = ADM8211_CSR_READ(SYNCTL); reg |= <API key>; ADM8211_CSR_WRITE(SYNCTL, reg); return 0; } /* configures hw beacons/probe responses */ static int adm8211_set_rate(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; u32 reg; int i = 0; u8 rate_buf[12] = {0}; /* write supported rates */ if (priv->pdev->revision != ADM8211_REV_BA) { rate_buf[0] = ARRAY_SIZE(adm8211_rates); for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++) rate_buf[i + 1] = (adm8211_rates[i].bitrate / 5) | 0x80; } else { /* workaround for rev BA specific bug */ rate_buf[0] = 0x04; rate_buf[1] = 0x82; rate_buf[2] = 0x04; rate_buf[3] = 0x0b; rate_buf[4] = 0x16; } <API key>(dev, <API key>, rate_buf, ARRAY_SIZE(adm8211_rates) + 1); reg = ADM8211_CSR_READ(PLCPHD) & 0x00FFFFFF; /* keep bits 0-23 */ reg |= 1 << 15; /* short preamble */ reg |= 110 << 24; ADM8211_CSR_WRITE(PLCPHD, reg); /* MTMLT = 512 TU (max TX MSDU lifetime) * BCNTSIG = plcp_signal (beacon, probe resp, and atim TX rate) * SRTYLIM = 224 (short retry limit, TX header value is default) */ ADM8211_CSR_WRITE(TXLMT, (512 << 16) | (110 << 8) | (224 << 0)); return 0; } static void adm8211_hw_init(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; u32 reg; u8 cline; reg = ADM8211_CSR_READ(PAR); reg |= ADM8211_PAR_MRLE | ADM8211_PAR_MRME; reg &= ~(ADM8211_PAR_BAR | ADM8211_PAR_CAL); if (!pci_set_mwi(priv->pdev)) { reg |= 0x1 << 24; <API key>(priv->pdev, PCI_CACHE_LINE_SIZE, &cline); switch (cline) { case 0x8: reg |= (0x1 << 14); break; case 0x10: reg |= (0x2 << 14); break; case 0x20: reg |= (0x3 << 14); break; default: reg |= (0x0 << 14); break; } } ADM8211_CSR_WRITE(PAR, reg); reg = ADM8211_CSR_READ(CSR_TEST1); reg &= ~(0xF << 28); reg |= (1 << 28) | (1 << 31); ADM8211_CSR_WRITE(CSR_TEST1, reg); /* lose link after 4 lost beacons */ reg = (0x04 << 21) | ADM8211_WCSR_TSFTWE | ADM8211_WCSR_LSOE; ADM8211_CSR_WRITE(WCSR, reg); /* Disable APM, enable receive FIFO threshold, and set drain receive * threshold to store-and-forward */ reg = ADM8211_CSR_READ(CMDR); reg &= ~(ADM8211_CMDR_APM | ADM8211_CMDR_DRT); reg |= ADM8211_CMDR_RTE | ADM8211_CMDR_DRT_SF; ADM8211_CSR_WRITE(CMDR, reg); adm8211_set_rate(dev); /* 4-bit values: * PWR1UP = 8 * 2 ms * PWR0PAPE = 8 us or 5 us * PWR1PAPE = 1 us or 3 us * PWR0TRSW = 5 us * PWR1TRSW = 12 us * PWR0PE2 = 13 us * PWR1PE2 = 1 us * PWR0TXPE = 8 or 6 */ if (priv->pdev->revision < ADM8211_REV_CA) ADM8211_CSR_WRITE(TOFS2, 0x8815cd18); else ADM8211_CSR_WRITE(TOFS2, 0x8535cd16); /* Enable store and forward for transmit */ priv->nar = ADM8211_NAR_SF | ADM8211_NAR_PB; ADM8211_CSR_WRITE(NAR, priv->nar); /* Reset RF */ ADM8211_CSR_WRITE(SYNRF, ADM8211_SYNRF_RADIO); ADM8211_CSR_READ(SYNRF); msleep(10); ADM8211_CSR_WRITE(SYNRF, 0); ADM8211_CSR_READ(SYNRF); msleep(5); /* Set CFP Max Duration to 0x10 TU */ reg = ADM8211_CSR_READ(CFPP); reg &= ~(0xffff << 8); reg |= 0x0010 << 8; ADM8211_CSR_WRITE(CFPP, reg); /* USCNT = 0x16 (number of system clocks, 22 MHz, in 1us * TUCNT = 0x3ff - Tu counter 1024 us */ ADM8211_CSR_WRITE(TOFS0, (0x16 << 24) | 0x3ff); /* SLOT=20 us, SIFS=110 cycles of 22 MHz (5 us), * DIFS=50 us, EIFS=100 us */ if (priv->pdev->revision < ADM8211_REV_CA) ADM8211_CSR_WRITE(IFST, (20 << 23) | (110 << 15) | (50 << 9) | 100); else ADM8211_CSR_WRITE(IFST, (20 << 23) | (24 << 15) | (50 << 9) | 100); /* PCNT = 1 (MAC idle time awake/sleep, unit S) * RMRD = 2346 * 8 + 1 us (max RX duration) */ ADM8211_CSR_WRITE(RMD, (1 << 16) | 18769); /* MART=65535 us, MIRT=256 us, TSFTOFST=0 us */ ADM8211_CSR_WRITE(RSPT, 0xffffff00); /* Initialize BBP (and SYN) */ adm8211_hw_init_bbp(dev); /* make sure interrupts are off */ ADM8211_CSR_WRITE(IER, 0); /* ACK interrupts */ ADM8211_CSR_WRITE(STSR, ADM8211_CSR_READ(STSR)); /* Setup WEP (turns it off for now) */ reg = ADM8211_CSR_READ(MACTEST); reg &= ~(7 << 20); ADM8211_CSR_WRITE(MACTEST, reg); reg = ADM8211_CSR_READ(WEPCTL); reg &= ~<API key>; reg |= <API key>; ADM8211_CSR_WRITE(WEPCTL, reg); /* Clear the missed-packet counter. */ ADM8211_CSR_READ(LPC); } static int adm8211_hw_reset(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; u32 reg, tmp; int timeout = 100; /* Power-on issue */ /* TODO: check if this is necessary */ ADM8211_CSR_WRITE(FRCTL, 0); /* Reset the chip */ tmp = ADM8211_CSR_READ(PAR); ADM8211_CSR_WRITE(PAR, ADM8211_PAR_SWR); while ((ADM8211_CSR_READ(PAR) & ADM8211_PAR_SWR) && timeout msleep(50); if (timeout <= 0) return -ETIMEDOUT; ADM8211_CSR_WRITE(PAR, tmp); if (priv->pdev->revision == ADM8211_REV_BA && (priv->transceiver_type == <API key> || priv->transceiver_type == ADM8211_RFMD2958)) { reg = ADM8211_CSR_READ(CSR_TEST1); reg |= (1 << 4) | (1 << 5); ADM8211_CSR_WRITE(CSR_TEST1, reg); } else if (priv->pdev->revision == ADM8211_REV_CA) { reg = ADM8211_CSR_READ(CSR_TEST1); reg &= ~((1 << 4) | (1 << 5)); ADM8211_CSR_WRITE(CSR_TEST1, reg); } ADM8211_CSR_WRITE(FRCTL, 0); reg = ADM8211_CSR_READ(CSR_TEST0); reg |= <API key>; /* EEPROM Recall */ ADM8211_CSR_WRITE(CSR_TEST0, reg); adm8211_clear_sram(dev); return 0; } static u64 adm8211_get_tsft(struct ieee80211_hw *dev, struct ieee80211_vif *vif) { struct adm8211_priv *priv = dev->priv; u32 tsftl; u64 tsft; tsftl = ADM8211_CSR_READ(TSFTL); tsft = ADM8211_CSR_READ(TSFTH); tsft <<= 32; tsft |= tsftl; return tsft; } static void <API key>(struct ieee80211_hw *dev, unsigned short bi, unsigned short li) { struct adm8211_priv *priv = dev->priv; u32 reg; /* BP (beacon interval) = data->beacon_interval * LI (listen interval) = data->listen_interval (in beacon intervals) */ reg = (bi << 16) | li; ADM8211_CSR_WRITE(BPLI, reg); } static void adm8211_set_bssid(struct ieee80211_hw *dev, const u8 *bssid) { struct adm8211_priv *priv = dev->priv; u32 reg; ADM8211_CSR_WRITE(BSSID0, le32_to_cpu(*(__le32 *)bssid)); reg = ADM8211_CSR_READ(ABDA1); reg &= 0x0000ffff; reg |= (bssid[4] << 16) | (bssid[5] << 24); ADM8211_CSR_WRITE(ABDA1, reg); } static int adm8211_config(struct ieee80211_hw *dev, u32 changed) { struct adm8211_priv *priv = dev->priv; struct ieee80211_conf *conf = &dev->conf; int channel = <API key>(conf->chandef.chan->center_freq); if (channel != priv->channel) { priv->channel = channel; <API key>(dev, priv->channel); } return 0; } static void <API key>(struct ieee80211_hw *dev, struct ieee80211_vif *vif, struct ieee80211_bss_conf *conf, u32 changes) { struct adm8211_priv *priv = dev->priv; if (!(changes & BSS_CHANGED_BSSID)) return; if (!ether_addr_equal(conf->bssid, priv->bssid)) { adm8211_set_bssid(dev, conf->bssid); memcpy(priv->bssid, conf->bssid, ETH_ALEN); } } static u64 <API key>(struct ieee80211_hw *hw, struct netdev_hw_addr_list *mc_list) { unsigned int bit_nr; u32 mc_filter[2]; struct netdev_hw_addr *ha; mc_filter[1] = mc_filter[0] = 0; <API key>(ha, mc_list) { bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; bit_nr &= 0x3F; mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); } return mc_filter[0] | ((u64)(mc_filter[1]) << 32); } static void <API key>(struct ieee80211_hw *dev, unsigned int changed_flags, unsigned int *total_flags, u64 multicast) { static const u8 bcast[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; struct adm8211_priv *priv = dev->priv; unsigned int new_flags; u32 mc_filter[2]; mc_filter[0] = multicast; mc_filter[1] = multicast >> 32; new_flags = 0; if (*total_flags & FIF_ALLMULTI || multicast == ~(0ULL)) { new_flags |= FIF_ALLMULTI; priv->nar &= ~ADM8211_NAR_PR; priv->nar |= ADM8211_NAR_MM; mc_filter[1] = mc_filter[0] = ~0; } else { priv->nar &= ~(ADM8211_NAR_MM | ADM8211_NAR_PR); } ADM8211_IDLE_RX(); ADM8211_CSR_WRITE(MAR0, mc_filter[0]); ADM8211_CSR_WRITE(MAR1, mc_filter[1]); ADM8211_CSR_READ(NAR); if (priv->nar & ADM8211_NAR_PR) ieee80211_hw_set(dev, RX_INCLUDES_FCS); else __clear_bit(<API key>, dev->flags); if (*total_flags & <API key>) adm8211_set_bssid(dev, bcast); else adm8211_set_bssid(dev, priv->bssid); ADM8211_RESTORE(); *total_flags = new_flags; } static int <API key>(struct ieee80211_hw *dev, struct ieee80211_vif *vif) { struct adm8211_priv *priv = dev->priv; if (priv->mode != <API key>) return -EOPNOTSUPP; switch (vif->type) { case <API key>: priv->mode = vif->type; break; default: return -EOPNOTSUPP; } ADM8211_IDLE(); ADM8211_CSR_WRITE(PAR0, le32_to_cpu(*(__le32 *)vif->addr)); ADM8211_CSR_WRITE(PAR1, le16_to_cpu(*(__le16 *)(vif->addr + 4))); adm8211_update_mode(dev); ADM8211_RESTORE(); return 0; } static void <API key>(struct ieee80211_hw *dev, struct ieee80211_vif *vif) { struct adm8211_priv *priv = dev->priv; priv->mode = <API key>; } static int adm8211_init_rings(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; struct adm8211_desc *desc = NULL; struct <API key> *rx_info; struct <API key> *tx_info; unsigned int i; for (i = 0; i < priv->rx_ring_size; i++) { desc = &priv->rx_ring[i]; desc->status = 0; desc->length = cpu_to_le32(RX_PKT_SIZE); priv->rx_buffers[i].skb = NULL; } /* Mark the end of RX ring; hw returns to base address after this * descriptor */ desc->length |= cpu_to_le32(RDES1_CONTROL_RER); for (i = 0; i < priv->rx_ring_size; i++) { desc = &priv->rx_ring[i]; rx_info = &priv->rx_buffers[i]; rx_info->skb = dev_alloc_skb(RX_PKT_SIZE); if (rx_info->skb == NULL) break; rx_info->mapping = pci_map_single(priv->pdev, skb_tail_pointer(rx_info->skb), RX_PKT_SIZE, PCI_DMA_FROMDEVICE); if (<API key>(priv->pdev, rx_info->mapping)) { dev_kfree_skb(rx_info->skb); rx_info->skb = NULL; break; } desc->buffer1 = cpu_to_le32(rx_info->mapping); desc->status = cpu_to_le32(RDES0_STATUS_OWN | RDES0_STATUS_SQL); } /* Setup TX ring. TX buffers descriptors will be filled in as needed */ for (i = 0; i < priv->tx_ring_size; i++) { desc = &priv->tx_ring[i]; tx_info = &priv->tx_buffers[i]; tx_info->skb = NULL; tx_info->mapping = 0; desc->status = 0; } desc->length = cpu_to_le32(TDES1_CONTROL_TER); priv->cur_rx = priv->cur_tx = priv->dirty_tx = 0; ADM8211_CSR_WRITE(RDB, priv->rx_ring_dma); ADM8211_CSR_WRITE(TDBD, priv->tx_ring_dma); return 0; } static void adm8211_free_rings(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; unsigned int i; for (i = 0; i < priv->rx_ring_size; i++) { if (!priv->rx_buffers[i].skb) continue; pci_unmap_single( priv->pdev, priv->rx_buffers[i].mapping, RX_PKT_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(priv->rx_buffers[i].skb); } for (i = 0; i < priv->tx_ring_size; i++) { if (!priv->tx_buffers[i].skb) continue; pci_unmap_single(priv->pdev, priv->tx_buffers[i].mapping, priv->tx_buffers[i].skb->len, PCI_DMA_TODEVICE); dev_kfree_skb(priv->tx_buffers[i].skb); } } static int adm8211_start(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; int retval; /* Power up MAC and RF chips */ retval = adm8211_hw_reset(dev); if (retval) { wiphy_err(dev->wiphy, "hardware reset failed\n"); goto fail; } retval = adm8211_init_rings(dev); if (retval) { wiphy_err(dev->wiphy, "failed to initialize rings\n"); goto fail; } /* Init hardware */ adm8211_hw_init(dev); <API key>(dev, priv->channel); retval = request_irq(priv->pdev->irq, adm8211_interrupt, IRQF_SHARED, "adm8211", dev); if (retval) { wiphy_err(dev->wiphy, "failed to register IRQ handler\n"); goto fail; } ADM8211_CSR_WRITE(IER, ADM8211_IER_NIE | ADM8211_IER_AIE | ADM8211_IER_RCIE | ADM8211_IER_TCIE | ADM8211_IER_TDUIE | ADM8211_IER_GPTIE); priv->mode = <API key>; adm8211_update_mode(dev); ADM8211_CSR_WRITE(RDR, 0); <API key>(dev, 100, 10); return 0; fail: return retval; } static void adm8211_stop(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; priv->mode = <API key>; priv->nar = 0; ADM8211_CSR_WRITE(NAR, 0); ADM8211_CSR_WRITE(IER, 0); ADM8211_CSR_READ(NAR); free_irq(priv->pdev->irq, dev); adm8211_free_rings(dev); } static void <API key>(int *dur, int *plcp, size_t payload_len, int len, int plcp_signal, int short_preamble) { /* Alternative calculation from NetBSD: */ /* IEEE 802.11b durations for DSSS PHY in microseconds */ #define <API key> 144 #define <API key> 72 #define <API key> 24 #define <API key> 48 #define <API key> 112 #define <API key> 56 #define <API key> 112 #define <API key> 56 #define <API key> 20 #define <API key> 10 int remainder; *dur = (80 * (24 + payload_len) + plcp_signal - 1) / plcp_signal; if (plcp_signal <= PLCP_SIGNAL_2M) /* 1-2Mbps WLAN: send ACK/CTS at 1Mbps */ *dur += 3 * (<API key> + <API key> + <API key>) + <API key> + <API key>; else /* 5-11Mbps WLAN: send ACK/CTS at 2Mbps */ *dur += 3 * (<API key> + <API key> + <API key>) + <API key> + <API key>; /* lengthen duration if long preamble */ if (!short_preamble) *dur += 3 * (<API key> - <API key>) + 3 * (<API key> - <API key>); *plcp = (80 * len) / plcp_signal; remainder = (80 * len) % plcp_signal; if (plcp_signal == PLCP_SIGNAL_11M && remainder <= 30 && remainder > 0) *plcp = (*plcp | 0x8000) + 1; else if (remainder) (*plcp)++; } static int adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb, u16 plcp_signal, size_t hdrlen) { struct adm8211_priv *priv = dev->priv; unsigned long flags; dma_addr_t mapping; unsigned int entry; u32 flag; mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); if (<API key>(priv->pdev, mapping)) return -ENOMEM; spin_lock_irqsave(&priv->lock, flags); if (priv->cur_tx - priv->dirty_tx == priv->tx_ring_size / 2) flag = TDES1_CONTROL_IC | TDES1_CONTROL_LS | TDES1_CONTROL_FS; else flag = TDES1_CONTROL_LS | TDES1_CONTROL_FS; if (priv->cur_tx - priv->dirty_tx == priv->tx_ring_size - 2) <API key>(dev, 0); entry = priv->cur_tx % priv->tx_ring_size; priv->tx_buffers[entry].skb = skb; priv->tx_buffers[entry].mapping = mapping; priv->tx_buffers[entry].hdrlen = hdrlen; priv->tx_ring[entry].buffer1 = cpu_to_le32(mapping); if (entry == priv->tx_ring_size - 1) flag |= TDES1_CONTROL_TER; priv->tx_ring[entry].length = cpu_to_le32(flag | skb->len); /* Set TX rate (SIGNAL field in PLCP PPDU format) */ flag = TDES0_CONTROL_OWN | (plcp_signal << 20) | 8 ; priv->tx_ring[entry].status = cpu_to_le32(flag); priv->cur_tx++; <API key>(&priv->lock, flags); /* Trigger transmit poll */ ADM8211_CSR_WRITE(TDR, 0); return 0; } /* Put adm8211_tx_hdr on skb and transmit */ static void adm8211_tx(struct ieee80211_hw *dev, struct <API key> *control, struct sk_buff *skb) { struct adm8211_tx_hdr *txhdr; size_t payload_len, hdrlen; int plcp, dur, len, plcp_signal, short_preamble; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_rate *txrate = <API key>(dev, info); u8 rc_flags; rc_flags = info->control.rates[0].flags; short_preamble = !!(rc_flags & <API key>); plcp_signal = txrate->bitrate; hdr = (struct ieee80211_hdr *)skb->data; hdrlen = ieee80211_hdrlen(hdr->frame_control); memcpy(skb->cb, skb->data, hdrlen); hdr = (struct ieee80211_hdr *)skb->cb; skb_pull(skb, hdrlen); payload_len = skb->len; txhdr = skb_push(skb, sizeof(*txhdr)); memset(txhdr, 0, sizeof(*txhdr)); memcpy(txhdr->da, ieee80211_get_DA(hdr), ETH_ALEN); txhdr->signal = plcp_signal; txhdr->frame_body_size = cpu_to_le16(payload_len); txhdr->frame_control = hdr->frame_control; len = hdrlen + payload_len + FCS_LEN; txhdr->frag = cpu_to_le16(0x0FFF); <API key>(&dur, &plcp, payload_len, len, plcp_signal, short_preamble); txhdr->plcp_frag_head_len = cpu_to_le16(plcp); txhdr->plcp_frag_tail_len = cpu_to_le16(plcp); txhdr->dur_frag_head = cpu_to_le16(dur); txhdr->dur_frag_tail = cpu_to_le16(dur); txhdr->header_control = cpu_to_le16(<API key>); if (short_preamble) txhdr->header_control |= cpu_to_le16(<API key>); if (rc_flags & <API key>) txhdr->header_control |= cpu_to_le16(<API key>); txhdr->retry_limit = info->control.rates[0].count; if (adm8211_tx_raw(dev, skb, plcp_signal, hdrlen)) { /* Drop packet */ <API key>(dev, skb); } } static int adm8211_alloc_rings(struct ieee80211_hw *dev) { struct adm8211_priv *priv = dev->priv; unsigned int ring_size; priv->rx_buffers = kmalloc(sizeof(*priv->rx_buffers) * priv->rx_ring_size + sizeof(*priv->tx_buffers) * priv->tx_ring_size, GFP_KERNEL); if (!priv->rx_buffers) return -ENOMEM; priv->tx_buffers = (void *)priv->rx_buffers + sizeof(*priv->rx_buffers) * priv->rx_ring_size; /* Allocate TX/RX descriptors */ ring_size = sizeof(struct adm8211_desc) * priv->rx_ring_size + sizeof(struct adm8211_desc) * priv->tx_ring_size; priv->rx_ring = <API key>(priv->pdev, ring_size, &priv->rx_ring_dma); if (!priv->rx_ring) { kfree(priv->rx_buffers); priv->rx_buffers = NULL; priv->tx_buffers = NULL; return -ENOMEM; } priv->tx_ring = priv->rx_ring + priv->rx_ring_size; priv->tx_ring_dma = priv->rx_ring_dma + sizeof(struct adm8211_desc) * priv->rx_ring_size; return 0; } static const struct ieee80211_ops adm8211_ops = { .tx = adm8211_tx, .start = adm8211_start, .stop = adm8211_stop, .add_interface = <API key>, .remove_interface = <API key>, .config = adm8211_config, .bss_info_changed = <API key>, .prepare_multicast = <API key>, .configure_filter = <API key>, .get_stats = adm8211_get_stats, .get_tsf = adm8211_get_tsft }; static int adm8211_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct ieee80211_hw *dev; struct adm8211_priv *priv; unsigned long mem_addr, mem_len; unsigned int io_addr, io_len; int err; u32 reg; u8 perm_addr[ETH_ALEN]; err = pci_enable_device(pdev); if (err) { printk(KERN_ERR "%s (adm8211): Cannot enable new PCI device\n", pci_name(pdev)); return err; } io_addr = pci_resource_start(pdev, 0); io_len = pci_resource_len(pdev, 0); mem_addr = pci_resource_start(pdev, 1); mem_len = pci_resource_len(pdev, 1); if (io_len < 256 || mem_len < 1024) { printk(KERN_ERR "%s (adm8211): Too short PCI resources\n", pci_name(pdev)); goto err_disable_pdev; } /* check signature */ <API key>(pdev, 0x80 /* CR32 */, &reg); if (reg != ADM8211_SIG1 && reg != ADM8211_SIG2) { printk(KERN_ERR "%s (adm8211): Invalid signature (0x%x)\n", pci_name(pdev), reg); goto err_disable_pdev; } err = pci_request_regions(pdev, "adm8211"); if (err) { printk(KERN_ERR "%s (adm8211): Cannot obtain PCI resources\n", pci_name(pdev)); return err; /* someone else grabbed it? don't disable it */ } if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || <API key>(pdev, DMA_BIT_MASK(32))) { printk(KERN_ERR "%s (adm8211): No suitable DMA available\n", pci_name(pdev)); goto err_free_reg; } pci_set_master(pdev); dev = ieee80211_alloc_hw(sizeof(*priv), &adm8211_ops); if (!dev) { printk(KERN_ERR "%s (adm8211): ieee80211 alloc failed\n", pci_name(pdev)); err = -ENOMEM; goto err_free_reg; } priv = dev->priv; priv->pdev = pdev; spin_lock_init(&priv->lock); SET_IEEE80211_DEV(dev, &pdev->dev); pci_set_drvdata(pdev, dev); priv->map = pci_iomap(pdev, 1, mem_len); if (!priv->map) priv->map = pci_iomap(pdev, 0, io_len); if (!priv->map) { printk(KERN_ERR "%s (adm8211): Cannot map device memory\n", pci_name(pdev)); err = -ENOMEM; goto err_free_dev; } priv->rx_ring_size = rx_ring_size; priv->tx_ring_size = tx_ring_size; err = adm8211_alloc_rings(dev); if (err) { printk(KERN_ERR "%s (adm8211): Cannot allocate TX/RX ring\n", pci_name(pdev)); goto err_iounmap; } *(__le32 *)perm_addr = cpu_to_le32(ADM8211_CSR_READ(PAR0)); *(__le16 *)&perm_addr[4] = cpu_to_le16(ADM8211_CSR_READ(PAR1) & 0xFFFF); if (!is_valid_ether_addr(perm_addr)) { printk(KERN_WARNING "%s (adm8211): Invalid hwaddr in EEPROM!\n", pci_name(pdev)); eth_random_addr(perm_addr); } <API key>(dev, perm_addr); dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr); /* dev->flags = RX_INCLUDES_FCS in promisc mode */ ieee80211_hw_set(dev, SIGNAL_UNSPEC); dev->wiphy->interface_modes = BIT(<API key>); dev->max_signal = 100; /* FIXME: find better value */ dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ priv->retry_limit = 3; priv->ant_power = 0x40; priv->tx_power = 0x40; priv->lpf_cutoff = 0xFF; priv->lnags_threshold = 0xFF; priv->mode = <API key>; /* Power-on issue. EEPROM won't read correctly without */ if (pdev->revision >= ADM8211_REV_BA) { ADM8211_CSR_WRITE(FRCTL, 0); ADM8211_CSR_READ(FRCTL); ADM8211_CSR_WRITE(FRCTL, 1); ADM8211_CSR_READ(FRCTL); msleep(100); } err = adm8211_read_eeprom(dev); if (err) { printk(KERN_ERR "%s (adm8211): Can't alloc eeprom buffer\n", pci_name(pdev)); goto err_free_desc; } priv->channel = 1; dev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; <API key>(dev->wiphy, <API key>); err = <API key>(dev); if (err) { printk(KERN_ERR "%s (adm8211): Cannot register device\n", pci_name(pdev)); goto err_free_eeprom; } wiphy_info(dev->wiphy, "hwaddr %pM, Rev 0x%02x\n", dev->wiphy->perm_addr, pdev->revision); return 0; err_free_eeprom: kfree(priv->eeprom); err_free_desc: pci_free_consistent(pdev, sizeof(struct adm8211_desc) * priv->rx_ring_size + sizeof(struct adm8211_desc) * priv->tx_ring_size, priv->rx_ring, priv->rx_ring_dma); kfree(priv->rx_buffers); err_iounmap: pci_iounmap(pdev, priv->map); err_free_dev: ieee80211_free_hw(dev); err_free_reg: pci_release_regions(pdev); err_disable_pdev: pci_disable_device(pdev); return err; } static void adm8211_remove(struct pci_dev *pdev) { struct ieee80211_hw *dev = pci_get_drvdata(pdev); struct adm8211_priv *priv; if (!dev) return; <API key>(dev); priv = dev->priv; pci_free_consistent(pdev, sizeof(struct adm8211_desc) * priv->rx_ring_size + sizeof(struct adm8211_desc) * priv->tx_ring_size, priv->rx_ring, priv->rx_ring_dma); kfree(priv->rx_buffers); kfree(priv->eeprom); pci_iounmap(pdev, priv->map); pci_release_regions(pdev); pci_disable_device(pdev); ieee80211_free_hw(dev); } #ifdef CONFIG_PM static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state) { pci_save_state(pdev); pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } static int adm8211_resume(struct pci_dev *pdev) { pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); return 0; } #endif /* CONFIG_PM */ MODULE_DEVICE_TABLE(pci, <API key>); /* TODO: implement enable_wake */ static struct pci_driver adm8211_driver = { .name = "adm8211", .id_table = <API key>, .probe = adm8211_probe, .remove = adm8211_remove, #ifdef CONFIG_PM .suspend = adm8211_suspend, .resume = adm8211_resume, #endif /* CONFIG_PM */ }; module_pci_driver(adm8211_driver);
var <API key> = [ [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ], [ "<API key>", "<API key>.html#<API key>", null ] ];
<?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); function <API key> () { global $mod_strings; global $app_strings; $<API key> = $app_strings['<API key>']; $<API key>= $mod_strings['LBL_MESSAGE_FOR']; $the_script = <<<EOQ <script type="text/javascript" language="Javascript"> function verify_data(form,formname) { if (!check_form(formname)) return false; var isError = false; var errorMessage = ""; var thecheckbox=document.getElementById('all_prospect_lists'); var theselectbox=document.getElementById('message_for'); if (!thecheckbox.checked && theselectbox.selectedIndex < 0) { isError=true; errorMessage="$<API key>"; } if (isError == true) { alert("$<API key>" + errorMessage); return false; } return true; } </script> EOQ; return $the_script; } ?>
package docker import ( "fmt" "strings" "github.com/containers/image/docker/policyconfiguration" "github.com/containers/image/docker/reference" "github.com/containers/image/transports" "github.com/containers/image/types" "github.com/pkg/errors" ) func init() { transports.Register(Transport) } // Transport is an ImageTransport for Docker registry-hosted images. var Transport = dockerTransport{} type dockerTransport struct{} func (t dockerTransport) Name() string { return "docker" } // ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an ImageReference. func (t dockerTransport) ParseReference(reference string) (types.ImageReference, error) { return ParseReference(reference) } // <API key> checks that scope is a valid name for a signature.<API key> keys // (i.e. a valid <API key>() or <API key>() return value). // It is acceptable to allow an invalid value which will never be matched, it can "only" cause user confusion. // scope passed to this function will not be "", that value is always allowed. func (t dockerTransport) <API key>(scope string) error { // FIXME? We could be verifying the various character set and length restrictions // from docker/distribution/reference.regexp.go, but other than that there // are few semantically invalid strings. return nil } // dockerReference is an ImageReference for Docker images. type dockerReference struct { ref reference.Named // By construction we know that !reference.IsNameOnly(ref) } // ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an Docker ImageReference. func ParseReference(refString string) (types.ImageReference, error) { if !strings.HasPrefix(refString, " return nil, errors.Errorf("docker: image reference %s does not start with //", refString) } ref, err := reference.<API key>(strings.TrimPrefix(refString, " if err != nil { return nil, err } ref = reference.TagNameOnly(ref) return NewReference(ref) } // NewReference returns a Docker reference for a named reference. The reference must satisfy !reference.IsNameOnly(). func NewReference(ref reference.Named) (types.ImageReference, error) { if reference.IsNameOnly(ref) { return nil, errors.Errorf("Docker reference %s has neither a tag nor a digest", reference.FamiliarString(ref)) } // A github.com/distribution/reference value can have a tag and a digest at the same time! // tag and digest), so fail. This MAY be accepted in the future. // (Even if it were supported, the semantics of policy namespaces are unclear - should we drop // the tag or the digest first?) _, isTagged := ref.(reference.NamedTagged) _, isDigested := ref.(reference.Canonical) if isTagged && isDigested { return nil, errors.Errorf("Docker references with both a tag and digest are currently not supported") } return dockerReference{ ref: ref, }, nil } func (ref dockerReference) Transport() types.ImageTransport { return Transport } // <API key> returns a string representation of the reference, which MUST be such that // reference.Transport().ParseReference(reference.<API key>()) returns an equivalent reference. // NOTE: The returned string is not promised to be equal to the original input to ParseReference; // e.g. default attribute values omitted by the user may be filled in in the return value, or vice versa. // WARNING: Do not use the return value in the UI to describe an image, it does not contain the Transport().Name() prefix. func (ref dockerReference) <API key>() string { return "//" + reference.FamiliarString(ref.ref) } // DockerReference returns a Docker reference associated with this reference // (fully explicit, i.e. !reference.IsNameOnly, but reflecting user intent, // not e.g. after redirect or alias processing), or nil if unknown/not applicable. func (ref dockerReference) DockerReference() reference.Named { return ref.ref } // <API key> returns a string representation of the reference, suitable for policy lookup. // This MUST reflect user intent, not e.g. after processing of third-party redirects or aliases; // The value SHOULD be fully explicit about its semantics, with no hidden defaults, AND canonical // (i.e. various references with exactly the same semantics should return the same configuration identity) // It is fine for the return value to be equal to <API key>(), and it is desirable but // not required/guaranteed that it will be a valid input to Transport().ParseReference(). // Returns "" if configuration identities for these references are not supported. func (ref dockerReference) <API key>() string { res, err := policyconfiguration.<API key>(ref.ref) if res == "" || err != nil { // Coverage: Should never happen, NewReference above should refuse values which could cause a failure. panic(fmt.Sprintf("Internal inconsistency: policyconfiguration.<API key> returned %#v, %v", res, err)) } return res } // <API key> returns a list of other policy configuration namespaces to search // for if explicit configuration for <API key>() is not set. The list will be processed // in order, terminating on first match, and an implicit "" is always checked at the end. // It is STRONGLY recommended for the first element, if any, to be a prefix of <API key>(), // and each following element to be a prefix of the element preceding it. func (ref dockerReference) <API key>() []string { return policyconfiguration.<API key>(ref.ref) } // NewImage returns a types.Image for this reference, possibly specialized for this ImageTransport. // The caller must call .Close() on the returned Image. // NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource, // verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage. func (ref dockerReference) NewImage(ctx *types.SystemContext) (types.Image, error) { return newImage(ctx, ref) } // NewImageSource returns a types.ImageSource for this reference, // asking the backend to use a manifest from <API key> if possible. // nil <API key> means manifest.<API key>. // The caller must call .Close() on the returned ImageSource. func (ref dockerReference) NewImageSource(ctx *types.SystemContext, <API key> []string) (types.ImageSource, error) { return newImageSource(ctx, ref, <API key>) } // NewImageDestination returns a types.ImageDestination for this reference. // The caller must call .Close() on the returned ImageDestination. func (ref dockerReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) { return newImageDestination(ctx, ref) } // DeleteImage deletes the named image from the registry, if supported. func (ref dockerReference) DeleteImage(ctx *types.SystemContext) error { return deleteImage(ctx, ref) } // tagOrDigest returns a tag or digest from the reference. func (ref dockerReference) tagOrDigest() (string, error) { if ref, ok := ref.ref.(reference.Canonical); ok { return ref.Digest().String(), nil } if ref, ok := ref.ref.(reference.NamedTagged); ok { return ref.Tag(), nil } // This should not happen, NewReference above refuses reference.IsNameOnly values. return "", errors.Errorf("Internal inconsistency: Reference %s unexpectedly has neither a digest nor a tag", reference.FamiliarString(ref.ref)) }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Button - Icons</title> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <script src="../../jquery-1.4.4.js"></script> <script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.button.js"></script> <link rel="stylesheet" href="../demos.css"> <script> $(function() { $( ".demo button:first" ).button({ icons: { primary: "ui-icon-locked" }, text: false }).next().button({ icons: { primary: "ui-icon-locked" } }).next().button({ icons: { primary: "ui-icon-gear", secondary: "<API key>" } }).next().button({ icons: { primary: "ui-icon-gear", secondary: "<API key>" }, text: false }); }); </script> </head> <body> <div class="demo"> <button>Button with icon only</button> <button>Button with icon on the left</button> <button>Button with two icons</button> <button>Button with two icons and no text</button> </div><!-- End demo --> <div class="demo-description"> <p>Some buttons with various combinations of text and icons, here specified via metadata.</p> </div><!-- End demo-description --> </body> </html>
#include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> #include <linux/device.h> #include <scsi/scsi_host.h> #include <scsi/scsi_cmnd.h> #include <linux/libata.h> #define DRV_NAME "sata_sil24" #define DRV_VERSION "1.1" /* * Port request block (PRB) 32 bytes */ struct sil24_prb { __le16 ctrl; __le16 prot; __le32 rx_cnt; u8 fis[6 * 4]; }; /* * Scatter gather entry (SGE) 16 bytes */ struct sil24_sge { __le64 addr; __le32 cnt; __le32 flags; }; enum { SIL24_HOST_BAR = 0, SIL24_PORT_BAR = 2, /* sil24 fetches in chunks of 64bytes. The first block * contains the PRB and two SGEs. From the second block, it's * consisted of four SGEs and called SGT. Calculate the * number of SGTs that fit into one page. */ SIL24_PRB_SZ = sizeof(struct sil24_prb) + 2 * sizeof(struct sil24_sge), SIL24_MAX_SGT = (PAGE_SIZE - SIL24_PRB_SZ) / (4 * sizeof(struct sil24_sge)), /* This will give us one unused SGEs for ATA. This extra SGE * will be used to store CDB for ATAPI devices. */ SIL24_MAX_SGE = 4 * SIL24_MAX_SGT + 1, /* * Global controller registers (128 bytes @ BAR0) */ /* 32 bit regs */ HOST_SLOT_STAT = 0x00, /* 32 bit slot stat * 4 */ HOST_CTRL = 0x40, HOST_IRQ_STAT = 0x44, HOST_PHY_CFG = 0x48, HOST_BIST_CTRL = 0x50, HOST_BIST_PTRN = 0x54, HOST_BIST_STAT = 0x58, HOST_MEM_BIST_STAT = 0x5c, HOST_FLASH_CMD = 0x70, /* 8 bit regs */ HOST_FLASH_DATA = 0x74, <API key> = 0x75, HOST_GPIO_CTRL = 0x76, HOST_I2C_ADDR = 0x78, /* 32 bit */ HOST_I2C_DATA = 0x7c, HOST_I2C_XFER_CNT = 0x7e, HOST_I2C_CTRL = 0x7f, /* HOST_SLOT_STAT bits */ HOST_SSTAT_ATTN = (1 << 31), /* HOST_CTRL bits */ HOST_CTRL_M66EN = (1 << 16), /* M66EN PCI bus signal */ HOST_CTRL_TRDY = (1 << 17), /* latched PCI TRDY */ HOST_CTRL_STOP = (1 << 18), /* latched PCI STOP */ HOST_CTRL_DEVSEL = (1 << 19), /* latched PCI DEVSEL */ HOST_CTRL_REQ64 = (1 << 20), /* latched PCI REQ64 */ <API key> = (1 << 31), /* global reset */ /* * Port registers * (8192 bytes @ +0x0000, +0x2000, +0x4000 and +0x6000 @ BAR2) */ PORT_REGS_SIZE = 0x2000, PORT_LRAM = 0x0000, /* 31 LRAM slots and PMP regs */ PORT_LRAM_SLOT_SZ = 0x0080, /* 32 bytes PRB + 2 SGE, ACT... */ PORT_PMP = 0x0f80, /* 8 bytes PMP * 16 (128 bytes) */ PORT_PMP_STATUS = 0x0000, /* port device status offset */ PORT_PMP_QACTIVE = 0x0004, /* port device QActive offset */ PORT_PMP_SIZE = 0x0008, /* 8 bytes per PMP */ /* 32 bit regs */ PORT_CTRL_STAT = 0x1000, /* write: ctrl-set, read: stat */ PORT_CTRL_CLR = 0x1004, /* write: ctrl-clear */ PORT_IRQ_STAT = 0x1008, /* high: status, low: interrupt */ PORT_IRQ_ENABLE_SET = 0x1010, /* write: enable-set */ PORT_IRQ_ENABLE_CLR = 0x1014, /* write: enable-clear */ <API key>= 0x101c, PORT_EXEC_FIFO = 0x1020, /* command execution fifo */ PORT_CMD_ERR = 0x1024, /* command error number */ PORT_FIS_CFG = 0x1028, PORT_FIFO_THRES = 0x102c, /* 16 bit regs */ PORT_DECODE_ERR_CNT = 0x1040, <API key> = 0x1042, PORT_CRC_ERR_CNT = 0x1044, PORT_CRC_ERR_THRESH = 0x1046, PORT_HSHK_ERR_CNT = 0x1048, <API key> = 0x104a, /* 32 bit regs */ PORT_PHY_CFG = 0x1050, PORT_SLOT_STAT = 0x1800, PORT_CMD_ACTIVATE = 0x1c00, /* 64 bit cmd activate * 31 (248 bytes) */ PORT_CONTEXT = 0x1e04, PORT_EXEC_DIAG = 0x1e00, /* 32bit exec diag * 16 (64 bytes, 0-10 used on 3124) */ PORT_PSD_DIAG = 0x1e40, /* 32bit psd diag * 16 (64 bytes, 0-8 used on 3124) */ PORT_SCONTROL = 0x1f00, PORT_SSTATUS = 0x1f04, PORT_SERROR = 0x1f08, PORT_SACTIVE = 0x1f0c, /* PORT_CTRL_STAT bits */ PORT_CS_PORT_RST = (1 << 0), /* port reset */ PORT_CS_DEV_RST = (1 << 1), /* device reset */ PORT_CS_INIT = (1 << 2), /* port initialize */ PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */ PORT_CS_CDB16 = (1 << 5), /* 0=12b cdb, 1=16b cdb */ PORT_CS_PMP_RESUME = (1 << 6), /* PMP resume */ PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */ PORT_CS_PMP_EN = (1 << 13), /* port multiplier enable */ PORT_CS_RDY = (1 << 31), /* port ready to accept commands */ /* PORT_IRQ_STAT/ENABLE_SET/CLR */ /* bits[11:0] are masked */ PORT_IRQ_COMPLETE = (1 << 0), /* command(s) completed */ PORT_IRQ_ERROR = (1 << 1), /* command execution error */ <API key> = (1 << 2), /* port ready change */ PORT_IRQ_PWR_CHG = (1 << 3), /* power management change */ PORT_IRQ_PHYRDY_CHG = (1 << 4), /* PHY ready change */ PORT_IRQ_COMWAKE = (1 << 5), /* COMWAKE received */ PORT_IRQ_UNK_FIS = (1 << 6), /* unknown FIS received */ PORT_IRQ_DEV_XCHG = (1 << 7), /* device exchanged */ PORT_IRQ_8B10B = (1 << 8), /* 8b/10b decode error threshold */ PORT_IRQ_CRC = (1 << 9), /* CRC error threshold */ PORT_IRQ_HANDSHAKE = (1 << 10), /* handshake error threshold */ PORT_IRQ_SDB_NOTIFY = (1 << 11), /* SDB notify received */ DEF_PORT_IRQ = PORT_IRQ_COMPLETE | PORT_IRQ_ERROR | PORT_IRQ_PHYRDY_CHG | PORT_IRQ_DEV_XCHG | PORT_IRQ_UNK_FIS | PORT_IRQ_SDB_NOTIFY, /* bits[27:16] are unmasked (raw) */ PORT_IRQ_RAW_SHIFT = 16, <API key> = 0x7ff, PORT_IRQ_RAW_MASK = (0x7ff << PORT_IRQ_RAW_SHIFT), /* ENABLE_SET/CLR specific, intr steering - 2 bit field */ <API key> = 30, PORT_IRQ_STEER_MASK = (3 << <API key>), /* PORT_CMD_ERR constants */ PORT_CERR_DEV = 1, /* Error bit in D2H Register FIS */ PORT_CERR_SDB = 2, /* Error bit in SDB FIS */ PORT_CERR_DATA = 3, /* Error in data FIS not detected by dev */ PORT_CERR_SEND = 4, /* Initial cmd FIS transmission failure */ <API key> = 5, /* Protocol mismatch */ PORT_CERR_DIRECTION = 6, /* Data direction mismatch */ PORT_CERR_UNDERRUN = 7, /* Ran out of SGEs while writing */ PORT_CERR_OVERRUN = 8, /* Ran out of SGEs while reading */ PORT_CERR_PKT_PROT = 11, /* DIR invalid in 1st PIO setup of ATAPI */ <API key> = 16, /* PLD ecode 00 - SGT not on qword boundary */ <API key> = 17, /* PLD ecode 01 - target abort */ <API key> = 18, /* PLD ecode 10 - master abort */ <API key> = 19, /* PLD ecode 11 - PCI parity err while fetching SGT */ <API key> = 24, /* ctrl[15:13] 001 - PRB not on qword boundary */ <API key> = 25, /* ctrl[15:13] 010 - target abort */ <API key> = 26, /* ctrl[15:13] 100 - master abort */ <API key> = 27, /* ctrl[15:13] 110 - PCI parity err while fetching PRB */ PORT_CERR_XFR_UNDEF = 32, /* PSD ecode 00 - undefined */ <API key> = 33, /* PSD ecode 01 - target abort */ <API key> = 34, /* PSD ecode 10 - master abort */ <API key> = 35, /* PSD ecode 11 - PCI prity err during transfer */ <API key> = 36, /* FIS received while sending service */ /* bits of PRB control field */ PRB_CTRL_PROTOCOL = (1 << 0), /* override def. ATA protocol */ <API key> = (1 << 4), /* PACKET cmd read */ <API key> = (1 << 5), /* PACKET cmd write */ PRB_CTRL_NIEN = (1 << 6), /* Mask completion irq */ PRB_CTRL_SRST = (1 << 7), /* Soft reset request (ign BSY?) */ /* PRB protocol field */ PRB_PROT_PACKET = (1 << 0), PRB_PROT_TCQ = (1 << 1), PRB_PROT_NCQ = (1 << 2), PRB_PROT_READ = (1 << 3), PRB_PROT_WRITE = (1 << 4), <API key> = (1 << 5), /* * Other constants */ SGE_TRM = (1 << 31), /* Last SGE in chain */ SGE_LNK = (1 << 30), /* linked list Points to SGT, not SGE */ SGE_DRD = (1 << 29), /* discard data read (/dev/null) data address ignored */ SIL24_MAX_CMDS = 31, /* board id */ BID_SIL3124 = 0, BID_SIL3132 = 1, BID_SIL3131 = 2, /* host flags */ SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ | ATA_FLAG_ACPI_SATA | ATA_FLAG_AN | ATA_FLAG_PMP, <API key> = (1 << 24), /* IRQ loss errata on PCI-X */ IRQ_STAT_4PORTS = 0xf, }; struct sil24_ata_block { struct sil24_prb prb; struct sil24_sge sge[SIL24_MAX_SGE]; }; struct sil24_atapi_block { struct sil24_prb prb; u8 cdb[16]; struct sil24_sge sge[SIL24_MAX_SGE]; }; union sil24_cmd_block { struct sil24_ata_block ata; struct sil24_atapi_block atapi; }; static struct sil24_cerr_info { unsigned int err_mask, action; const char *desc; } sil24_cerr_db[] = { [0] = { AC_ERR_DEV, 0, "device error" }, [PORT_CERR_DEV] = { AC_ERR_DEV, 0, "device error via D2H FIS" }, [PORT_CERR_SDB] = { AC_ERR_DEV, 0, "device error via SDB FIS" }, [PORT_CERR_DATA] = { AC_ERR_ATA_BUS, ATA_EH_RESET, "error in data FIS" }, [PORT_CERR_SEND] = { AC_ERR_ATA_BUS, ATA_EH_RESET, "failed to transmit command FIS" }, [<API key>] = { AC_ERR_HSM, ATA_EH_RESET, "protocol mismatch" }, [PORT_CERR_DIRECTION] = { AC_ERR_HSM, ATA_EH_RESET, "data directon mismatch" }, [PORT_CERR_UNDERRUN] = { AC_ERR_HSM, ATA_EH_RESET, "ran out of SGEs while writing" }, [PORT_CERR_OVERRUN] = { AC_ERR_HSM, ATA_EH_RESET, "ran out of SGEs while reading" }, [PORT_CERR_PKT_PROT] = { AC_ERR_HSM, ATA_EH_RESET, "invalid data directon for ATAPI CDB" }, [<API key>] = { AC_ERR_SYSTEM, ATA_EH_RESET, "SGT not on qword boundary" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI target abort while fetching SGT" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI master abort while fetching SGT" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI parity error while fetching SGT" }, [<API key>] = { AC_ERR_SYSTEM, ATA_EH_RESET, "PRB not on qword boundary" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI target abort while fetching PRB" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI master abort while fetching PRB" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI parity error while fetching PRB" }, [PORT_CERR_XFR_UNDEF] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "undefined error while transferring data" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI target abort while transferring data" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI master abort while transferring data" }, [<API key>] = { AC_ERR_HOST_BUS, ATA_EH_RESET, "PCI parity error while transferring data" }, [<API key>] = { AC_ERR_HSM, ATA_EH_RESET, "FIS received while sending service FIS" }, }; /* * ap->private_data * * The preview driver always returned 0 for status. We emulate it * here from the previous interrupt. */ struct sil24_port_priv { union sil24_cmd_block *cmd_block; /* 32 cmd blocks */ dma_addr_t cmd_block_dma; /* DMA base addr for them */ int do_port_rst; }; static void sil24_dev_config(struct ata_device *dev); static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val); static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val); static int sil24_qc_defer(struct ata_queued_cmd *qc); static void sil24_qc_prep(struct ata_queued_cmd *qc); static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); static bool sil24_qc_fill_rtf(struct ata_queued_cmd *qc); static void sil24_pmp_attach(struct ata_port *ap); static void sil24_pmp_detach(struct ata_port *ap); static void sil24_freeze(struct ata_port *ap); static void sil24_thaw(struct ata_port *ap); static int sil24_softreset(struct ata_link *link, unsigned int *class, unsigned long deadline); static int sil24_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline); static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline); static void sil24_error_handler(struct ata_port *ap); static void <API key>(struct ata_queued_cmd *qc); static int sil24_port_start(struct ata_port *ap); static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); #ifdef CONFIG_PM static int <API key>(struct pci_dev *pdev); static int sil24_port_resume(struct ata_port *ap); #endif static const struct pci_device_id sil24_pci_tbl[] = { { PCI_VDEVICE(CMD, 0x3124), BID_SIL3124 }, { PCI_VDEVICE(INTEL, 0x3124), BID_SIL3124 }, { PCI_VDEVICE(CMD, 0x3132), BID_SIL3132 }, { PCI_VDEVICE(CMD, 0x0242), BID_SIL3132 }, { PCI_VDEVICE(CMD, 0x0244), BID_SIL3132 }, { PCI_VDEVICE(CMD, 0x3131), BID_SIL3131 }, { PCI_VDEVICE(CMD, 0x3531), BID_SIL3131 }, { } /* terminate list */ }; static struct pci_driver sil24_pci_driver = { .name = DRV_NAME, .id_table = sil24_pci_tbl, .probe = sil24_init_one, .remove = ata_pci_remove_one, #ifdef CONFIG_PM .suspend = <API key>, .resume = <API key>, #endif }; static struct scsi_host_template sil24_sht = { ATA_NCQ_SHT(DRV_NAME), .can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, }; static struct ata_port_operations sil24_ops = { .inherits = &sata_pmp_port_ops, .qc_defer = sil24_qc_defer, .qc_prep = sil24_qc_prep, .qc_issue = sil24_qc_issue, .qc_fill_rtf = sil24_qc_fill_rtf, .freeze = sil24_freeze, .thaw = sil24_thaw, .softreset = sil24_softreset, .hardreset = sil24_hardreset, .pmp_softreset = sil24_softreset, .pmp_hardreset = sil24_pmp_hardreset, .error_handler = sil24_error_handler, .post_internal_cmd = <API key>, .dev_config = sil24_dev_config, .scr_read = sil24_scr_read, .scr_write = sil24_scr_write, .pmp_attach = sil24_pmp_attach, .pmp_detach = sil24_pmp_detach, .port_start = sil24_port_start, #ifdef CONFIG_PM .port_resume = sil24_port_resume, #endif }; static int sata_sil24_msi; /* Disable MSI */ module_param_named(msi, sata_sil24_msi, bool, S_IRUGO); MODULE_PARM_DESC(msi, "Enable MSI (Default: false)"); /* * Use bits 30-31 of port_flags to encode available port numbers. * Current maxium is 4. */ #define SIL24_NPORTS2FLAG(nports) ((((unsigned)(nports) - 1) & 0x3) << 30) #define SIL24_FLAG2NPORTS(flag) ((((flag) >> 30) & 0x3) + 1) static const struct ata_port_info sil24_port_info[] = { /* sil_3124 */ { .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) | <API key>, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, .port_ops = &sil24_ops, }, /* sil_3132 */ { .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2), .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, .port_ops = &sil24_ops, }, /* sil_3131/sil_3531 */ { .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1), .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, .port_ops = &sil24_ops, }, }; static int sil24_tag(int tag) { if (unlikely(ata_tag_internal(tag))) return 0; return tag; } static unsigned long sil24_port_offset(struct ata_port *ap) { return ap->port_no * PORT_REGS_SIZE; } static void __iomem *sil24_port_base(struct ata_port *ap) { return ap->host->iomap[SIL24_PORT_BAR] + sil24_port_offset(ap); } static void sil24_dev_config(struct ata_device *dev) { void __iomem *port = sil24_port_base(dev->link->ap); if (dev->cdb_len == 16) writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); else writel(PORT_CS_CDB16, port + PORT_CTRL_CLR); } static void sil24_read_tf(struct ata_port *ap, int tag, struct ata_taskfile *tf) { void __iomem *port = sil24_port_base(ap); struct sil24_prb __iomem *prb; u8 fis[6 * 4]; prb = port + PORT_LRAM + sil24_tag(tag) * PORT_LRAM_SLOT_SZ; memcpy_fromio(fis, prb->fis, sizeof(fis)); ata_tf_from_fis(fis, tf); } static int sil24_scr_map[] = { [SCR_CONTROL] = 0, [SCR_STATUS] = 1, [SCR_ERROR] = 2, [SCR_ACTIVE] = 3, }; static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val) { void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { void __iomem *addr; addr = scr_addr + sil24_scr_map[sc_reg] * 4; *val = readl(scr_addr + sil24_scr_map[sc_reg] * 4); return 0; } return -EINVAL; } static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val) { void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { void __iomem *addr; addr = scr_addr + sil24_scr_map[sc_reg] * 4; writel(val, scr_addr + sil24_scr_map[sc_reg] * 4); return 0; } return -EINVAL; } static void sil24_config_port(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); /* configure IRQ WoC */ if (ap->flags & <API key>) writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_STAT); else writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR); /* zero error counters. */ writel(0x8000, port + <API key>); writel(0x8000, port + PORT_CRC_ERR_THRESH); writel(0x8000, port + <API key>); writel(0x0000, port + PORT_DECODE_ERR_CNT); writel(0x0000, port + PORT_CRC_ERR_CNT); writel(0x0000, port + PORT_HSHK_ERR_CNT); /* always use 64bit activation */ writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_CLR); /* clear port multiplier enable and resume bits */ writel(PORT_CS_PMP_EN | PORT_CS_PMP_RESUME, port + PORT_CTRL_CLR); } static void sil24_config_pmp(struct ata_port *ap, int attached) { void __iomem *port = sil24_port_base(ap); if (attached) writel(PORT_CS_PMP_EN, port + PORT_CTRL_STAT); else writel(PORT_CS_PMP_EN, port + PORT_CTRL_CLR); } static void sil24_clear_pmp(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); int i; writel(PORT_CS_PMP_RESUME, port + PORT_CTRL_CLR); for (i = 0; i < SATA_PMP_MAX_PORTS; i++) { void __iomem *pmp_base = port + PORT_PMP + i * PORT_PMP_SIZE; writel(0, pmp_base + PORT_PMP_STATUS); writel(0, pmp_base + PORT_PMP_QACTIVE); } } static int sil24_init_port(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); struct sil24_port_priv *pp = ap->private_data; u32 tmp; /* clear PMP error status */ if (sata_pmp_attached(ap)) sil24_clear_pmp(ap); writel(PORT_CS_INIT, port + PORT_CTRL_STAT); ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_INIT, PORT_CS_INIT, 10, 100); tmp = ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_RDY, 0, 10, 100); if ((tmp & (PORT_CS_INIT | PORT_CS_RDY)) != PORT_CS_RDY) { pp->do_port_rst = 1; ap->link.eh_context.i.action |= ATA_EH_RESET; return -EIO; } return 0; } static int <API key>(struct ata_port *ap, int pmp, const struct ata_taskfile *tf, int is_cmd, u32 ctrl, unsigned long timeout_msec) { void __iomem *port = sil24_port_base(ap); struct sil24_port_priv *pp = ap->private_data; struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; dma_addr_t paddr = pp->cmd_block_dma; u32 irq_enabled, irq_mask, irq_stat; int rc; prb->ctrl = cpu_to_le16(ctrl); ata_tf_to_fis(tf, pmp, is_cmd, prb->fis); /* temporarily plug completion and error interrupts */ irq_enabled = readl(port + PORT_IRQ_ENABLE_SET); writel(PORT_IRQ_COMPLETE | PORT_IRQ_ERROR, port + PORT_IRQ_ENABLE_CLR); writel((u32)paddr, port + PORT_CMD_ACTIVATE); writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + 4); irq_mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT; irq_stat = ata_wait_register(port + PORT_IRQ_STAT, irq_mask, 0x0, 10, timeout_msec); writel(irq_mask, port + PORT_IRQ_STAT); /* clear IRQs */ irq_stat >>= PORT_IRQ_RAW_SHIFT; if (irq_stat & PORT_IRQ_COMPLETE) rc = 0; else { /* force port into known state */ sil24_init_port(ap); if (irq_stat & PORT_IRQ_ERROR) rc = -EIO; else rc = -EBUSY; } /* restore IRQ enabled */ writel(irq_enabled, port + PORT_IRQ_ENABLE_SET); return rc; } static int sil24_softreset(struct ata_link *link, unsigned int *class, unsigned long deadline) { struct ata_port *ap = link->ap; int pmp = sata_srst_pmp(link); unsigned long timeout_msec = 0; struct ata_taskfile tf; const char *reason; int rc; DPRINTK("ENTER\n"); /* put the port into known state */ if (sil24_init_port(ap)) { reason = "port not ready"; goto err; } /* do SRST */ if (time_after(deadline, jiffies)) timeout_msec = jiffies_to_msecs(deadline - jiffies); ata_tf_init(link->device, &tf); /* doesn't really matter */ rc = <API key>(ap, pmp, &tf, 0, PRB_CTRL_SRST, timeout_msec); if (rc == -EBUSY) { reason = "timeout"; goto err; } else if (rc) { reason = "SRST command error"; goto err; } sil24_read_tf(ap, 0, &tf); *class = ata_dev_classify(&tf); DPRINTK("EXIT, class=%u\n", *class); return 0; err: ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason); return -EIO; } static int sil24_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline) { struct ata_port *ap = link->ap; void __iomem *port = sil24_port_base(ap); struct sil24_port_priv *pp = ap->private_data; int did_port_rst = 0; const char *reason; int tout_msec, rc; u32 tmp; retry: /* Sometimes, DEV_RST is not enough to recover the controller. * This happens often after PM DMA CS errata. */ if (pp->do_port_rst) { ata_port_printk(ap, KERN_WARNING, "controller in dubious " "state, performing PORT_RST\n"); writel(PORT_CS_PORT_RST, port + PORT_CTRL_STAT); msleep(10); writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR); ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_RDY, 0, 10, 5000); /* restore port configuration */ sil24_config_port(ap); sil24_config_pmp(ap, ap->nr_pmp_links); pp->do_port_rst = 0; did_port_rst = 1; } /* sil24 does the right thing(tm) without any protection */ sata_set_spd(link); tout_msec = 100; if (ata_link_online(link)) tout_msec = 5000; writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); tmp = ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, tout_msec); /* SStatus oscillates between zero and valid status after * DEV_RST, debounce it. */ rc = sata_link_debounce(link, <API key>, deadline); if (rc) { reason = "PHY debouncing failed"; goto err; } if (tmp & PORT_CS_DEV_RST) { if (ata_link_offline(link)) return 0; reason = "link not ready"; goto err; } /* Sil24 doesn't store signature FIS after hardreset, so we * can't wait for BSY to clear. Some devices take a long time * to get ready and those devices will choke if we don't wait * for BSY clearance here. Tell libata to perform follow-up * softreset. */ return -EAGAIN; err: if (!did_port_rst) { pp->do_port_rst = 1; goto retry; } ata_link_printk(link, KERN_ERR, "hardreset failed (%s)\n", reason); return -EIO; } static inline void sil24_fill_sg(struct ata_queued_cmd *qc, struct sil24_sge *sge) { struct scatterlist *sg; struct sil24_sge *last_sge = NULL; unsigned int si; for_each_sg(qc->sg, sg, qc->n_elem, si) { sge->addr = cpu_to_le64(sg_dma_address(sg)); sge->cnt = cpu_to_le32(sg_dma_len(sg)); sge->flags = 0; last_sge = sge; sge++; } last_sge->flags = cpu_to_le32(SGE_TRM); } static int sil24_qc_defer(struct ata_queued_cmd *qc) { struct ata_link *link = qc->dev->link; struct ata_port *ap = link->ap; u8 prot = qc->tf.protocol; /* * There is a bug in the chip: * Port LRAM Causes the PRB/SGT Data to be Corrupted * If the host issues a read request for LRAM and SActive registers * while active commands are available in the port, PRB/SGT data in * the LRAM can become corrupted. This issue applies only when * reading from, but not writing to, the LRAM. * * Therefore, reading LRAM when there is no particular error [and * other commands may be outstanding] is prohibited. * * To avoid this bug there are two situations where a command must run * exclusive of any other commands on the port: * * - ATAPI commands which check the sense data * - Passthrough ATA commands which always have <API key> * set. * */ int is_excl = (ata_is_atapi(prot) || (qc->flags & <API key>)); if (unlikely(ap->excl_link)) { if (link == ap->excl_link) { if (ap->nr_active_links) return ATA_DEFER_PORT; qc->flags |= <API key>; } else return ATA_DEFER_PORT; } else if (unlikely(is_excl)) { ap->excl_link = link; if (ap->nr_active_links) return ATA_DEFER_PORT; qc->flags |= <API key>; } return ata_std_qc_defer(qc); } static void sil24_qc_prep(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; struct sil24_port_priv *pp = ap->private_data; union sil24_cmd_block *cb; struct sil24_prb *prb; struct sil24_sge *sge; u16 ctrl = 0; cb = &pp->cmd_block[sil24_tag(qc->tag)]; if (!ata_is_atapi(qc->tf.protocol)) { prb = &cb->ata.prb; sge = cb->ata.sge; if (ata_is_data(qc->tf.protocol)) { u16 prot = 0; ctrl = PRB_CTRL_PROTOCOL; if (ata_is_ncq(qc->tf.protocol)) prot |= PRB_PROT_NCQ; if (qc->tf.flags & ATA_TFLAG_WRITE) prot |= PRB_PROT_WRITE; else prot |= PRB_PROT_READ; prb->prot = cpu_to_le16(prot); } } else { prb = &cb->atapi.prb; sge = cb->atapi.sge; memset(cb->atapi.cdb, 0, 32); memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len); if (ata_is_data(qc->tf.protocol)) { if (qc->tf.flags & ATA_TFLAG_WRITE) ctrl = <API key>; else ctrl = <API key>; } } prb->ctrl = cpu_to_le16(ctrl); ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, prb->fis); if (qc->flags & ATA_QCFLAG_DMAMAP) sil24_fill_sg(qc, sge); } static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; struct sil24_port_priv *pp = ap->private_data; void __iomem *port = sil24_port_base(ap); unsigned int tag = sil24_tag(qc->tag); dma_addr_t paddr; void __iomem *activate; paddr = pp->cmd_block_dma + tag * sizeof(*pp->cmd_block); activate = port + PORT_CMD_ACTIVATE + tag * 8; writel((u32)paddr, activate); writel((u64)paddr >> 32, activate + 4); return 0; } static bool sil24_qc_fill_rtf(struct ata_queued_cmd *qc) { sil24_read_tf(qc->ap, qc->tag, &qc->result_tf); return true; } static void sil24_pmp_attach(struct ata_port *ap) { u32 *gscr = ap->link.device->gscr; sil24_config_pmp(ap, 1); sil24_init_port(ap); if (<API key>(gscr) == 0x11ab && sata_pmp_gscr_devid(gscr) == 0x4140) { ata_port_printk(ap, KERN_INFO, "disabling NCQ support due to sil24-mv4140 quirk\n"); ap->flags &= ~ATA_FLAG_NCQ; } } static void sil24_pmp_detach(struct ata_port *ap) { sil24_init_port(ap); sil24_config_pmp(ap, 0); ap->flags |= ATA_FLAG_NCQ; } static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline) { int rc; rc = sil24_init_port(link->ap); if (rc) { ata_link_printk(link, KERN_ERR, "hardreset failed (port not ready)\n"); return rc; } return sata_std_hardreset(link, class, deadline); } static void sil24_freeze(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear * PORT_IRQ_ENABLE instead. */ writel(0xffff, port + PORT_IRQ_ENABLE_CLR); } static void sil24_thaw(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); u32 tmp; /* clear IRQ */ tmp = readl(port + PORT_IRQ_STAT); writel(tmp, port + PORT_IRQ_STAT); /* turn IRQ back on */ writel(DEF_PORT_IRQ, port + PORT_IRQ_ENABLE_SET); } static void sil24_error_intr(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); struct sil24_port_priv *pp = ap->private_data; struct ata_queued_cmd *qc = NULL; struct ata_link *link; struct ata_eh_info *ehi; int abort = 0, freeze = 0; u32 irq_stat; /* on error, we need to clear IRQ explicitly */ irq_stat = readl(port + PORT_IRQ_STAT); writel(irq_stat, port + PORT_IRQ_STAT); /* first, analyze and record host port events */ link = &ap->link; ehi = &link->eh_info; ata_ehi_clear_desc(ehi); ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat); if (irq_stat & PORT_IRQ_SDB_NOTIFY) { ata_ehi_push_desc(ehi, "SDB notify"); <API key>(ap); } if (irq_stat & (PORT_IRQ_PHYRDY_CHG | PORT_IRQ_DEV_XCHG)) { ata_ehi_hotplugged(ehi); ata_ehi_push_desc(ehi, "%s", irq_stat & PORT_IRQ_PHYRDY_CHG ? "PHY RDY changed" : "device exchanged"); freeze = 1; } if (irq_stat & PORT_IRQ_UNK_FIS) { ehi->err_mask |= AC_ERR_HSM; ehi->action |= ATA_EH_RESET; ata_ehi_push_desc(ehi, "unknown FIS"); freeze = 1; } /* deal with command error */ if (irq_stat & PORT_IRQ_ERROR) { struct sil24_cerr_info *ci = NULL; unsigned int err_mask = 0, action = 0; u32 context, cerr; int pmp; abort = 1; /* DMA Context Switch Failure in Port Multiplier Mode * errata. If we have active commands to 3 or more * devices, any error condition on active devices can * corrupt DMA context switching. */ if (ap->nr_active_links >= 3) { ehi->err_mask |= AC_ERR_OTHER; ehi->action |= ATA_EH_RESET; ata_ehi_push_desc(ehi, "PMP DMA CS errata"); pp->do_port_rst = 1; freeze = 1; } /* find out the offending link and qc */ if (sata_pmp_attached(ap)) { context = readl(port + PORT_CONTEXT); pmp = (context >> 5) & 0xf; if (pmp < ap->nr_pmp_links) { link = &ap->pmp_link[pmp]; ehi = &link->eh_info; qc = ata_qc_from_tag(ap, link->active_tag); ata_ehi_clear_desc(ehi); ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat); } else { err_mask |= AC_ERR_HSM; action |= ATA_EH_RESET; freeze = 1; } } else qc = ata_qc_from_tag(ap, link->active_tag); /* analyze CMD_ERR */ cerr = readl(port + PORT_CMD_ERR); if (cerr < ARRAY_SIZE(sil24_cerr_db)) ci = &sil24_cerr_db[cerr]; if (ci && ci->desc) { err_mask |= ci->err_mask; action |= ci->action; if (action & ATA_EH_RESET) freeze = 1; ata_ehi_push_desc(ehi, "%s", ci->desc); } else { err_mask |= AC_ERR_OTHER; action |= ATA_EH_RESET; freeze = 1; ata_ehi_push_desc(ehi, "unknown command error %d", cerr); } /* record error info */ if (qc) qc->err_mask |= err_mask; else ehi->err_mask |= err_mask; ehi->action |= action; /* if PMP, resume */ if (sata_pmp_attached(ap)) writel(PORT_CS_PMP_RESUME, port + PORT_CTRL_STAT); } /* freeze or abort */ if (freeze) ata_port_freeze(ap); else if (abort) { if (qc) ata_link_abort(qc->dev->link); else ata_port_abort(ap); } } static inline void sil24_host_intr(struct ata_port *ap) { void __iomem *port = sil24_port_base(ap); u32 slot_stat, qc_active; int rc; /* If PCIX_IRQ_WOC, there's an inherent race window between * clearing IRQ pending status and reading PORT_SLOT_STAT * which may cause spurious interrupts afterwards. This is * unavoidable and much better than losing interrupts which * happens if IRQ pending is cleared after reading * PORT_SLOT_STAT. */ if (ap->flags & <API key>) writel(PORT_IRQ_COMPLETE, port + PORT_IRQ_STAT); slot_stat = readl(port + PORT_SLOT_STAT); if (unlikely(slot_stat & HOST_SSTAT_ATTN)) { sil24_error_intr(ap); return; } qc_active = slot_stat & ~HOST_SSTAT_ATTN; rc = <API key>(ap, qc_active); if (rc > 0) return; if (rc < 0) { struct ata_eh_info *ehi = &ap->link.eh_info; ehi->err_mask |= AC_ERR_HSM; ehi->action |= ATA_EH_RESET; ata_port_freeze(ap); return; } /* spurious interrupts are expected if PCIX_IRQ_WOC */ if (!(ap->flags & <API key>) && ata_ratelimit()) ata_port_printk(ap, KERN_INFO, "spurious interrupt " "(slot_stat 0x%x active_tag %d sactive 0x%x)\n", slot_stat, ap->link.active_tag, ap->link.sactive); } static irqreturn_t sil24_interrupt(int irq, void *dev_instance) { struct ata_host *host = dev_instance; void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; unsigned handled = 0; u32 status; int i; status = readl(host_base + HOST_IRQ_STAT); if (status == 0xffffffff) { printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, " "PCI fault or device removal?\n"); goto out; } if (!(status & IRQ_STAT_4PORTS)) goto out; spin_lock(&host->lock); for (i = 0; i < host->n_ports; i++) if (status & (1 << i)) { struct ata_port *ap = host->ports[i]; if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { sil24_host_intr(ap); handled++; } else printk(KERN_ERR DRV_NAME ": interrupt from disabled port %d\n", i); } spin_unlock(&host->lock); out: return IRQ_RETVAL(handled); } static void sil24_error_handler(struct ata_port *ap) { struct sil24_port_priv *pp = ap->private_data; if (sil24_init_port(ap)) ata_eh_freeze_port(ap); <API key>(ap); pp->do_port_rst = 0; } static void <API key>(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; /* make DMA engine forget about the failed command */ if ((qc->flags & ATA_QCFLAG_FAILED) && sil24_init_port(ap)) ata_eh_freeze_port(ap); } static int sil24_port_start(struct ata_port *ap) { struct device *dev = ap->host->dev; struct sil24_port_priv *pp; union sil24_cmd_block *cb; size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; dma_addr_t cb_dma; pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); if (!pp) return -ENOMEM; cb = dmam_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL); if (!cb) return -ENOMEM; memset(cb, 0, cb_size); pp->cmd_block = cb; pp->cmd_block_dma = cb_dma; ap->private_data = pp; ata_port_pbar_desc(ap, SIL24_HOST_BAR, -1, "host"); ata_port_pbar_desc(ap, SIL24_PORT_BAR, sil24_port_offset(ap), "port"); return 0; } static void <API key>(struct ata_host *host) { void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; u32 tmp; int i; /* GPIO off */ writel(0, host_base + HOST_FLASH_CMD); /* clear global reset & mask interrupts during initialization */ writel(0, host_base + HOST_CTRL); /* init ports */ for (i = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; void __iomem *port = sil24_port_base(ap); /* Initial PHY setting */ writel(0x20c, port + PORT_PHY_CFG); /* Clear port RST */ tmp = readl(port + PORT_CTRL_STAT); if (tmp & PORT_CS_PORT_RST) { writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR); tmp = ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_PORT_RST, PORT_CS_PORT_RST, 10, 100); if (tmp & PORT_CS_PORT_RST) dev_printk(KERN_ERR, host->dev, "failed to clear port RST\n"); } /* configure port */ sil24_config_port(ap); } /* Turn on interrupts */ writel(IRQ_STAT_4PORTS, host_base + HOST_CTRL); } static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { extern int <API key>; static int printed_version; struct ata_port_info pi = sil24_port_info[ent->driver_data]; const struct ata_port_info *ppi[] = { &pi, NULL }; void __iomem * const *iomap; struct ata_host *host; int rc; u32 tmp; /* cause link error if sil24_cmd_block is sized wrongly */ if (sizeof(union sil24_cmd_block) != PAGE_SIZE) <API key> = 1; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); /* acquire resources */ rc = pcim_enable_device(pdev); if (rc) return rc; rc = pcim_iomap_regions(pdev, (1 << SIL24_HOST_BAR) | (1 << SIL24_PORT_BAR), DRV_NAME); if (rc) return rc; iomap = pcim_iomap_table(pdev); /* apply workaround for completion IRQ loss on PCI-X errata */ if (pi.flags & <API key>) { tmp = readl(iomap[SIL24_HOST_BAR] + HOST_CTRL); if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL)) dev_printk(KERN_INFO, &pdev->dev, "Applying completion IRQ loss on PCI-X " "errata fix\n"); else pi.flags &= ~<API key>; } /* allocate and fill host */ host = <API key>(&pdev->dev, ppi, SIL24_FLAG2NPORTS(ppi[0]->flags)); if (!host) return -ENOMEM; host->iomap = iomap; /* configure and activate the device */ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { rc = <API key>(pdev, DMA_BIT_MASK(64)); if (rc) { rc = <API key>(pdev, DMA_BIT_MASK(32)); if (rc) { dev_printk(KERN_ERR, &pdev->dev, "64-bit DMA enable failed\n"); return rc; } } } else { rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc) { dev_printk(KERN_ERR, &pdev->dev, "32-bit DMA enable failed\n"); return rc; } rc = <API key>(pdev, DMA_BIT_MASK(32)); if (rc) { dev_printk(KERN_ERR, &pdev->dev, "32-bit consistent DMA enable failed\n"); return rc; } } /* Set max read request size to 4096. This slightly increases * write throughput for pci-e variants. */ pcie_set_readrq(pdev, 4096); <API key>(host); if (sata_sil24_msi && !pci_enable_msi(pdev)) { dev_printk(KERN_INFO, &pdev->dev, "Using MSI\n"); pci_intx(pdev, 0); } pci_set_master(pdev); return ata_host_activate(host, pdev->irq, sil24_interrupt, IRQF_SHARED, &sil24_sht); } #ifdef CONFIG_PM static int <API key>(struct pci_dev *pdev) { struct ata_host *host = dev_get_drvdata(&pdev->dev); void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; int rc; rc = <API key>(pdev); if (rc) return rc; if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) writel(<API key>, host_base + HOST_CTRL); <API key>(host); ata_host_resume(host); return 0; } static int sil24_port_resume(struct ata_port *ap) { sil24_config_pmp(ap, ap->nr_pmp_links); return 0; } #endif static int __init sil24_init(void) { return pci_register_driver(&sil24_pci_driver); } static void __exit sil24_exit(void) { <API key>(&sil24_pci_driver); } MODULE_AUTHOR("Tejun Heo"); MODULE_DESCRIPTION("Silicon Image 3124/3132 SATA low-level driver"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, sil24_pci_tbl); module_init(sil24_init); module_exit(sil24_exit);
"""Unit tests for abc.py.""" import unittest from test import support import abc from inspect import isabstract class TestABC(unittest.TestCase): def <API key>(self): @abc.abstractmethod def foo(self): pass self.assertTrue(foo.<API key>) def bar(self): pass self.assertFalse(hasattr(bar, "<API key>")) def <API key>(self): @abc.abstractproperty def foo(self): pass self.assertTrue(foo.<API key>) def bar(self): pass self.assertFalse(hasattr(bar, "<API key>")) class C(metaclass=abc.ABCMeta): @abc.abstractproperty def foo(self): return 3 class D(C): @property def foo(self): return super().foo self.assertEqual(D().foo, 3) def <API key>(self): @abc.abstractclassmethod def foo(cls): pass self.assertTrue(foo.<API key>) @classmethod def bar(cls): pass self.assertFalse(hasattr(bar, "<API key>")) class C(metaclass=abc.ABCMeta): @abc.abstractclassmethod def foo(cls): return cls.__name__ self.assertRaises(TypeError, C) class D(C): @classmethod def foo(cls): return super().foo() self.assertEqual(D.foo(), 'D') self.assertEqual(D().foo(), 'D') def <API key>(self): @abc.<API key> def foo(): pass self.assertTrue(foo.<API key>) @staticmethod def bar(): pass self.assertFalse(hasattr(bar, "<API key>")) class C(metaclass=abc.ABCMeta): @abc.<API key> def foo(): return 3 self.assertRaises(TypeError, C) class D(C): @staticmethod def foo(): return 4 self.assertEqual(D.foo(), 4) self.assertEqual(D().foo(), 4) def <API key>(self): for abstractthing in [abc.abstractmethod, abc.abstractproperty, abc.abstractclassmethod, abc.<API key>]: class C(metaclass=abc.ABCMeta): @abstractthing def foo(self): pass # abstract def bar(self): pass # concrete self.assertEqual(C.__abstractmethods__, {"foo"}) self.assertRaises(TypeError, C) # because foo is abstract self.assertTrue(isabstract(C)) class D(C): def bar(self): pass # concrete override of concrete self.assertEqual(D.__abstractmethods__, {"foo"}) self.assertRaises(TypeError, D) # because foo is still abstract self.assertTrue(isabstract(D)) class E(D): def foo(self): pass self.assertEqual(E.__abstractmethods__, set()) E() # now foo is concrete, too self.assertFalse(isabstract(E)) class F(E): @abstractthing def bar(self): pass # abstract override of concrete self.assertEqual(F.__abstractmethods__, {"bar"}) self.assertRaises(TypeError, F) # because bar is abstract now self.assertTrue(isabstract(F)) def test_metaclass_abc(self): # Metaclasses can be ABCs, too. class A(metaclass=abc.ABCMeta): @abc.abstractmethod def x(self): pass self.assertEqual(A.__abstractmethods__, {"x"}) class meta(type, A): def x(self): return 1 class C(metaclass=meta): pass def <API key>(self): class A(metaclass=abc.ABCMeta): pass class B(object): pass b = B() self.assertFalse(issubclass(B, A)) self.assertFalse(issubclass(B, (A,))) self.assertNotIsInstance(b, A) self.assertNotIsInstance(b, (A,)) A.register(B) self.assertTrue(issubclass(B, A)) self.assertTrue(issubclass(B, (A,))) self.assertIsInstance(b, A) self.assertIsInstance(b, (A,)) class C(B): pass c = C() self.assertTrue(issubclass(C, A)) self.assertTrue(issubclass(C, (A,))) self.assertIsInstance(c, A) self.assertIsInstance(c, (A,)) def <API key>(self): class A(metaclass=abc.ABCMeta): pass class B: pass b = B() self.assertFalse(isinstance(b, A)) self.assertFalse(isinstance(b, (A,))) A.register(B) self.assertTrue(isinstance(b, A)) self.assertTrue(isinstance(b, (A,))) def <API key>(self): class A(metaclass=abc.ABCMeta): pass A.register(int) self.assertIsInstance(42, A) self.assertIsInstance(42, (A,)) self.assertTrue(issubclass(int, A)) self.assertTrue(issubclass(int, (A,))) class B(A): pass B.register(str) class C(str): pass self.assertIsInstance("", A) self.assertIsInstance("", (A,)) self.assertTrue(issubclass(str, A)) self.assertTrue(issubclass(str, (A,))) self.assertTrue(issubclass(C, A)) self.assertTrue(issubclass(C, (A,))) def <API key>(self): class A(metaclass=abc.ABCMeta): pass A.register(A) # should pass silently class A1(A): pass self.assertRaises(RuntimeError, A1.register, A) # cycles not allowed class B(object): pass A1.register(B) A1.register(B) # should pass silently class C(A): pass A.register(C) # should pass silently self.assertRaises(RuntimeError, C.register, A) # cycles not allowed C.register(B) def <API key>(self): class A(metaclass=abc.ABCMeta): pass self.assertRaisesRegex(TypeError, "Can only register classes", A.register, 4) def <API key>(self): class A(metaclass=abc.ABCMeta): pass self.assertTrue(issubclass(A, A)) self.assertTrue(issubclass(A, (A,))) class B(metaclass=abc.ABCMeta): pass self.assertFalse(issubclass(A, B)) self.assertFalse(issubclass(A, (B,))) self.assertFalse(issubclass(B, A)) self.assertFalse(issubclass(B, (A,))) class C(metaclass=abc.ABCMeta): pass A.register(B) class B1(B): pass self.assertTrue(issubclass(B1, A)) self.assertTrue(issubclass(B1, (A,))) class C1(C): pass B1.register(C1) self.assertFalse(issubclass(C, B)) self.assertFalse(issubclass(C, (B,))) self.assertFalse(issubclass(C, B1)) self.assertFalse(issubclass(C, (B1,))) self.assertTrue(issubclass(C1, A)) self.assertTrue(issubclass(C1, (A,))) self.assertTrue(issubclass(C1, B)) self.assertTrue(issubclass(C1, (B,))) self.assertTrue(issubclass(C1, B1)) self.assertTrue(issubclass(C1, (B1,))) C1.register(int) class MyInt(int): pass self.assertTrue(issubclass(MyInt, A)) self.assertTrue(issubclass(MyInt, (A,))) self.assertIsInstance(42, A) self.assertIsInstance(42, (A,)) def <API key>(self): class A(metaclass=abc.ABCMeta): pass class B(object): counter = 0 def __new__(cls): B.counter += 1 return super().__new__(cls) class C(A, B): pass self.assertEqual(B.counter, 0) C() self.assertEqual(B.counter, 1) def test_main(): support.run_unittest(TestABC) if __name__ == "__main__": unittest.main()
// Use of this source code is governed by a BSD-style // This file contains the code to check that locks are not passed by value. package main import ( "bytes" "fmt" "go/ast" "go/token" "go/types" ) func init() { register("copylocks", "check that locks are not passed by value", checkCopyLocks, funcDecl, rangeStmt, funcLit, assignStmt) } // checkCopyLocks checks whether node might // inadvertently copy a lock. func checkCopyLocks(f *File, node ast.Node) { switch node := node.(type) { case *ast.RangeStmt: checkCopyLocksRange(f, node) case *ast.FuncDecl: checkCopyLocksFunc(f, node.Name.Name, node.Recv, node.Type) case *ast.FuncLit: checkCopyLocksFunc(f, "func", nil, node.Type) case *ast.AssignStmt: <API key>(f, node) } } // <API key> checks whether an assignment // copies a lock. func <API key>(f *File, as *ast.AssignStmt) { for _, x := range as.Lhs { if path := lockPath(f.pkg.typesPkg, f.pkg.types[x].Type); path != nil { f.Badf(x.Pos(), "assignment copies lock value to %v: %v", f.gofmt(x), path) } } } // checkCopyLocksFunc checks whether a function might // inadvertently copy a lock, by checking whether // its receiver, parameters, or return values // are locks. func checkCopyLocksFunc(f *File, name string, recv *ast.FieldList, typ *ast.FuncType) { if recv != nil && len(recv.List) > 0 { expr := recv.List[0].Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { f.Badf(expr.Pos(), "%s passes lock by value: %v", name, path) } } if typ.Params != nil { for _, field := range typ.Params.List { expr := field.Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { f.Badf(expr.Pos(), "%s passes lock by value: %v", name, path) } } } if typ.Results != nil { for _, field := range typ.Results.List { expr := field.Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { f.Badf(expr.Pos(), "%s returns lock by value: %v", name, path) } } } } // checkCopyLocksRange checks whether a range statement // might inadvertently copy a lock by checking whether // any of the range variables are locks. func checkCopyLocksRange(f *File, r *ast.RangeStmt) { <API key>(f, r.Tok, r.Key) <API key>(f, r.Tok, r.Value) } func <API key>(f *File, rtok token.Token, e ast.Expr) { if e == nil { return } id, isId := e.(*ast.Ident) if isId && id.Name == "_" { return } var typ types.Type if rtok == token.DEFINE { if !isId { return } obj := f.pkg.defs[id] if obj == nil { return } typ = obj.Type() } else { typ = f.pkg.types[e].Type } if typ == nil { return } if path := lockPath(f.pkg.typesPkg, typ); path != nil { f.Badf(e.Pos(), "range var %s copies lock: %v", f.gofmt(e), path) } } type typePath []types.Type // String pretty-prints a typePath. func (path typePath) String() string { n := len(path) var buf bytes.Buffer for i := range path { if i > 0 { fmt.Fprint(&buf, " contains ") } // The human-readable path is in reverse order, outermost to innermost. fmt.Fprint(&buf, path[n-i-1].String()) } return buf.String() } // lockPath returns a typePath describing the location of a lock value // contained in typ. If there is no contained lock, it returns nil. func lockPath(tpkg *types.Package, typ types.Type) typePath { if typ == nil { return nil } // We're only interested in the case in which the underlying // type is a struct. (Interfaces and pointers are safe to copy.) styp, ok := typ.Underlying().(*types.Struct) if !ok { return nil } // We're looking for cases in which a reference to this type // can be locked, but a value cannot. This differentiates // embedded interfaces from embedded values. if plock := types.NewMethodSet(types.NewPointer(typ)).Lookup(tpkg, "Lock"); plock != nil { if lock := types.NewMethodSet(typ).Lookup(tpkg, "Lock"); lock == nil { return []types.Type{typ} } } nfields := styp.NumFields() for i := 0; i < nfields; i++ { ftyp := styp.Field(i).Type() subpath := lockPath(tpkg, ftyp) if subpath != nil { return append(subpath, typ) } } return nil }
/* * @test * @bug 4984908 5058132 6653154 * @summary Basic test of valueOf(String) * @author Josh Bloch * * @compile ValueOf.java * @run main ValueOf */ import java.util.*; import java.lang.reflect.Method; public class ValueOf { static Random rnd = new Random(); public static void main(String[] args) throws Exception { test(Silly0.class); test(Silly1.class); test(Silly31.class); test(Silly32.class); test(Silly33.class); test(Silly63.class); test(Silly64.class); test(Silly65.class); test(Silly127.class); test(Silly128.class); test(Silly129.class); test(Silly500.class); test(Specialized.class); <API key>(); } static <T extends Enum<T>> void test(Class<T> enumClass) throws Exception { Set<T> s = EnumSet.allOf(enumClass); test(enumClass, s); // Delete half the elements from set at random for (Iterator<T> i = s.iterator(); i.hasNext(); ) { i.next(); if (rnd.nextBoolean()) i.remove(); } test(enumClass, s); } static <T extends Enum<T>> void test(Class<T> enumClass, Set<T> s) throws Exception { Method valueOf = enumClass.getDeclaredMethod("valueOf", String.class); Set<T> copy = EnumSet.noneOf(enumClass); for (T e : s) copy.add((T) valueOf.invoke(null, e.name())); if (!copy.equals(s)) throw new Exception(copy + " != " + s); } static void <API key>() { try { Enum.valueOf(Specialized.class, "BAZ"); throw new RuntimeException("Expected <API key> not thrown."); } catch(<API key> iae) { String message = iae.getMessage(); if (! "No enum constant ValueOf.Specialized.BAZ".equals(message)) throw new RuntimeException("Unexpected detail message: ``" + message + "''."); } } enum Silly0 { }; enum Silly1 { e1 } enum Silly31 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30 } enum Silly32 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31 } enum Silly33 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32 } enum Silly63 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62 } enum Silly64 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63 } enum Silly65 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64 } enum Silly127 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126 } enum Silly128 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126, e127 } enum Silly129 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126, e127, e128 } enum Silly500 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126, e127, e128, e129, e130, e131, e132, e133, e134, e135, e136, e137, e138, e139, e140, e141, e142, e143, e144, e145, e146, e147, e148, e149, e150, e151, e152, e153, e154, e155, e156, e157, e158, e159, e160, e161, e162, e163, e164, e165, e166, e167, e168, e169, e170, e171, e172, e173, e174, e175, e176, e177, e178, e179, e180, e181, e182, e183, e184, e185, e186, e187, e188, e189, e190, e191, e192, e193, e194, e195, e196, e197, e198, e199, e200, e201, e202, e203, e204, e205, e206, e207, e208, e209, e210, e211, e212, e213, e214, e215, e216, e217, e218, e219, e220, e221, e222, e223, e224, e225, e226, e227, e228, e229, e230, e231, e232, e233, e234, e235, e236, e237, e238, e239, e240, e241, e242, e243, e244, e245, e246, e247, e248, e249, e250, e251, e252, e253, e254, e255, e256, e257, e258, e259, e260, e261, e262, e263, e264, e265, e266, e267, e268, e269, e270, e271, e272, e273, e274, e275, e276, e277, e278, e279, e280, e281, e282, e283, e284, e285, e286, e287, e288, e289, e290, e291, e292, e293, e294, e295, e296, e297, e298, e299, e300, e301, e302, e303, e304, e305, e306, e307, e308, e309, e310, e311, e312, e313, e314, e315, e316, e317, e318, e319, e320, e321, e322, e323, e324, e325, e326, e327, e328, e329, e330, e331, e332, e333, e334, e335, e336, e337, e338, e339, e340, e341, e342, e343, e344, e345, e346, e347, e348, e349, e350, e351, e352, e353, e354, e355, e356, e357, e358, e359, e360, e361, e362, e363, e364, e365, e366, e367, e368, e369, e370, e371, e372, e373, e374, e375, e376, e377, e378, e379, e380, e381, e382, e383, e384, e385, e386, e387, e388, e389, e390, e391, e392, e393, e394, e395, e396, e397, e398, e399, e400, e401, e402, e403, e404, e405, e406, e407, e408, e409, e410, e411, e412, e413, e414, e415, e416, e417, e418, e419, e420, e421, e422, e423, e424, e425, e426, e427, e428, e429, e430, e431, e432, e433, e434, e435, e436, e437, e438, e439, e440, e441, e442, e443, e444, e445, e446, e447, e448, e449, e450, e451, e452, e453, e454, e455, e456, e457, e458, e459, e460, e461, e462, e463, e464, e465, e466, e467, e468, e469, e470, e471, e472, e473, e474, e475, e476, e477, e478, e479, e480, e481, e482, e483, e484, e485, e486, e487, e488, e489, e490, e491, e492, e493, e494, e495, e496, e497, e498, e499 } enum Specialized { FOO { public void foo() {} }; abstract public void foo(); }; }
</div> <p id="footer">@NAME@ &mdash; npm@@VERSION@</p> <script> ;(function () { var wrapper = document.getElementById("wrapper") var els = Array.prototype.slice.call(wrapper.<API key>("*"), 0) .filter(function (el) { return el.parentNode === wrapper && el.tagName.match(/H[1-6]/) && el.id }) var l = 2 , toc = document.createElement("ul") toc.innerHTML = els.map(function (el) { var i = el.tagName.charAt(1) , out = "" while (i > l) { out += "<ul>" l ++ } while (i < l) { out += "</ul>" l } out += "<li><a href='#" + el.id + "'>" + ( el.innerText || el.text || el.innerHTML) + "</a>" return out }).join("\n") toc.id = "toc" document.body.appendChild(toc) })() </script> </body></html>
// Generated by class-dump 3.5 (64 bit). #pragma mark - // File: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/CoreThemeDefinition.framework/CoreThemeDefinition // UUID: <API key> // Arch: arm64 // Objective-C Garbage Collection: Unknown
"use strict"; const fs = require("fs"); const path = require("path"); const webdriverCommands_1 = require("./webdriverCommands"); // Generate a random 8 character ID to avoid collisions. function getLogId() { return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(36).slice(0, 8); } /** * Logs WebDriver commands, transforming the command into a user-friendly description. */ class WebDriverLogger { constructor() { this.logName = `webdriver_log_${getLogId()}.txt`; } /** * Start logging to the specified directory. Will create a file named * 'webdriver_log_<process id>.txt' * * @param logDir The directory to create log files in. */ setLogDir(logDir) { this.logStream = fs.createWriteStream(path.join(logDir, this.logName), { flags: 'a' }); } /** * Logs a webdriver command to the log file. * * @param command The command to log. */ logWebDriverCommand(command) { if (!this.logStream) { return; } let cmdLog = this.printCommand(command); let logLine; if (command.getParam('sessionId')) { let session = command.getParam('sessionId').slice(0, 6); logLine = `${this.timestamp()} [${session}] ${cmdLog}\n`; } else { logLine = `${this.timestamp()} ${cmdLog}\n`; } this.logStream.write(logLine); } printCommand(command) { switch (command.commandName) { case webdriverCommands_1.CommandName.NewSession: let desired = command.data['desiredCapabilities']; return `Getting new "${desired['browserName']}" session`; case webdriverCommands_1.CommandName.DeleteSession: let sessionId = command.getParam('sessionId').slice(0, 6); return `Deleting session ${sessionId}`; case webdriverCommands_1.CommandName.Go: return `Navigating to ${command.data['url']}`; case webdriverCommands_1.CommandName.GetCurrentURL: return `Getting current URL`; default: return `Unknown command ${command.data['url']}`; } } timestamp() { let d = new Date(); let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours(); let minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes(); let seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds(); let millis = d.getMilliseconds().toString(); millis = '000'.slice(0, 3 - millis.length) + millis; return `[${hours}:${minutes}:${seconds}.${millis}]`; } } exports.WebDriverLogger = WebDriverLogger; //# sourceMappingURL=webdriverLogger.js.map
// Generated by class-dump 3.5 (64 bit). #pragma mark - // File: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/IMDMessageServices.framework/IMDMessageServices // UUID: <API key> // Arch: arm64 // Objective-C Garbage Collection: Unknown
<?php /** * Class which implements the openid session store logic. * * This class has the interface specified in the constructor of the * <API key> class. * * @package simpleSAMLphp * @version $Id$ */ class <API key> { /** * Retrieve a key from the session store. * * @param string $key The key we should retrieve. * @return mixed The value stored with the given key, or NULL if the key isn't found. */ public function get($key) { assert('is_string($key)'); $session = SimpleSAML_Session::getInstance(); return $session->getData('openid.session', $key); } /** * Save a value to the session store under the given key. * * @param string $key The key we should save. * @param mixed NULL $value The value we should save. */ public function set($key, $value) { assert('is_string($key)'); $session = SimpleSAML_Session::getInstance(); $session->setData('openid.session', $key, $value); } /** * Delete a key from the session store. * * @param string $key The key we should delete. */ public function del($key) { assert('is_string($key)'); $session = SimpleSAML_Session::getInstance(); $session->deleteData('openid.session', $key); } }
(function($, window, document, undefined) { 'use strict'; var defaults = { scale: 1, zoom: true, enableZoomAfter: 300 }; var Zoom = function(element) { this.core = $(element).data('lightGallery'); this.core.s = $.extend({}, defaults, this.core.s); if (this.core.s.zoom && this.core.doCss()) { this.init(); // Store the zoomable timeout value just to clear it while closing this.zoomabletimeout = false; // Set the initial value center this.pageX = $(window).width() / 2; this.pageY = ($(window).height() / 2) + $(window).scrollTop(); } return this; }; Zoom.prototype.init = function() { var _this = this; var zoomIcons = '<span id="lg-zoom-in" class="lg-icon"></span><span id="lg-zoom-out" class="lg-icon"></span>'; this.core.$outer.find('.lg-toolbar').append(zoomIcons); // Add zoomable class _this.core.$el.on('onSlideItemLoad.lg.tm.zoom', function(event, index, delay) { // delay will be 0 except first time var _speed = _this.core.s.enableZoomAfter + delay; // set _speed value 0 if gallery opened from direct url and if it is first slide if ($('body').hasClass('lg-from-hash') && delay) { // will execute only once _speed = 0; } else { // Remove lg-from-hash to enable starting animation. $('body').removeClass('lg-from-hash'); } _this.zoomabletimeout = setTimeout(function() { _this.core.$slide.eq(index).addClass('lg-zoomable'); }, _speed + 30); }); var scale = 1; /** * @desc Image zoom * Translate the wrap and scale the image to get better user experience * * @param {String} scaleVal - Zoom decrement/increment value */ var zoom = function(scaleVal) { var $image = _this.core.$outer.find('.lg-current .lg-image'); var _x; var _y; // Find offset manually to avoid issue after zoom var offsetX = ($(window).width() - $image.width()) / 2; var offsetY = (($(window).height() - $image.height()) / 2) + $(window).scrollTop(); _x = _this.pageX - offsetX; _y = _this.pageY - offsetY; var x = (scaleVal - 1) * (_x); var y = (scaleVal - 1) * (_y); $image.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal); $image.parent().css('transform', 'translate3d(-' + x + 'px, -' + y + 'px, 0)').attr('data-x', x).attr('data-y', y); }; var callScale = function() { if (scale > 1) { _this.core.$outer.addClass('lg-zoomed'); } else { _this.resetZoom(); } if (scale < 1) { scale = 1; } zoom(scale); }; var actualSize = function(event, $image, index) { var w = $image.width(); var nw; if (_this.core.s.dynamic) { nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w; } else { nw = _this.core.$items.eq(index).attr('data-width') || $image[0].naturalWidth || w; } var _scale; if (_this.core.$outer.hasClass('lg-zoomed')) { scale = 1; } else { if (nw > w) { _scale = nw / w; scale = _scale || 2; } } _this.pageX = event.pageX || event.originalEvent.targetTouches[0].pageX; _this.pageY = event.pageY || event.originalEvent.targetTouches[0].pageY; callScale(); setTimeout(function() { _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab'); }, 10); }; var tapped = false; // event triggered after appending slide content _this.core.$el.on('onAferAppendSlide.lg.tm.zoom', function(event, index) { // Get the current element var $image = _this.core.$slide.eq(index).find('.lg-image'); $image.on('dblclick', function(event) { actualSize(event, $image, index); }); $image.on('touchstart', function(event) { if (!tapped) { tapped = setTimeout(function() { tapped = null; }, 300); } else { clearTimeout(tapped); tapped = null; actualSize(event, $image, index); } event.preventDefault(); }); }); // Update zoom on resize and orientationchange $(window).on('resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom', function() { _this.pageX = $(window).width() / 2; _this.pageY = ($(window).height() / 2) + $(window).scrollTop(); zoom(scale); }); $('#lg-zoom-out').on('click.lg', function() { if (_this.core.$outer.find('.lg-current .lg-image').length) { scale -= _this.core.s.scale; callScale(); } }); $('#lg-zoom-in').on('click.lg', function() { if (_this.core.$outer.find('.lg-current .lg-image').length) { scale += _this.core.s.scale; callScale(); } }); // Reset zoom on slide change _this.core.$el.on('onBeforeSlide.lg.tm', function() { scale = 1; _this.resetZoom(); }); // Drag option after zoom if (!_this.core.isTouch) { _this.zoomDrag(); } if (_this.core.isTouch) { _this.zoomSwipe(); } }; // Reset zoom effect Zoom.prototype.resetZoom = function() { this.core.$outer.removeClass('lg-zoomed'); this.core.$slide.find('.lg-img-wrap').removeAttr('style data-x data-y'); this.core.$slide.find('.lg-image').removeAttr('style data-scale'); // Reset pagx pagy values to center this.pageX = $(window).width() / 2; this.pageY = ($(window).height() / 2) + $(window).scrollTop(); }; Zoom.prototype.zoomSwipe = function() { var _this = this; var startCoords = {}; var endCoords = {}; var isMoved = false; // Allow x direction drag var allowX = false; // Allow Y direction drag var allowY = false; _this.core.$slide.on('touchstart.lg', function(e) { if (_this.core.$outer.hasClass('lg-zoomed')) { var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); allowY = $image.outerHeight() * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); allowX = $image.outerWidth() * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); if ((allowX || allowY)) { e.preventDefault(); startCoords = { x: e.originalEvent.targetTouches[0].pageX, y: e.originalEvent.targetTouches[0].pageY }; } } }); _this.core.$slide.on('touchmove.lg', function(e) { if (_this.core.$outer.hasClass('lg-zoomed')) { var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); var distanceX; var distanceY; e.preventDefault(); isMoved = true; endCoords = { x: e.originalEvent.targetTouches[0].pageX, y: e.originalEvent.targetTouches[0].pageY }; // reset opacity and transition duration _this.core.$outer.addClass('lg-zoom-dragging'); if (allowY) { distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); } else { distanceY = -Math.abs(_$el.attr('data-y')); } if (allowX) { distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); } else { distanceX = -Math.abs(_$el.attr('data-x')); } if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); } } }); _this.core.$slide.on('touchend.lg', function() { if (_this.core.$outer.hasClass('lg-zoomed')) { if (isMoved) { isMoved = false; _this.core.$outer.removeClass('lg-zoom-dragging'); _this.touchendZoom(startCoords, endCoords, allowX, allowY); } } }); }; Zoom.prototype.zoomDrag = function() { var _this = this; var startCoords = {}; var endCoords = {}; var isDraging = false; var isMoved = false; // Allow x direction drag var allowX = false; // Allow Y direction drag var allowY = false; _this.core.$slide.on('mousedown.lg.zoom', function(e) { // execute only on .lg-object var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); allowY = $image.outerHeight() * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); allowX = $image.outerWidth() * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); if (_this.core.$outer.hasClass('lg-zoomed')) { if ($(e.target).hasClass('lg-object') && (allowX || allowY)) { e.preventDefault(); startCoords = { x: e.pageX, y: e.pageY }; isDraging = true; _this.core.$outer.scrollLeft += 1; _this.core.$outer.scrollLeft -= 1; _this.core.$outer.removeClass('lg-grab').addClass('lg-grabbing'); } } }); $(window).on('mousemove.lg.zoom', function(e) { if (isDraging) { var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); var distanceX; var distanceY; isMoved = true; endCoords = { x: e.pageX, y: e.pageY }; // reset opacity and transition duration _this.core.$outer.addClass('lg-zoom-dragging'); if (allowY) { distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); } else { distanceY = -Math.abs(_$el.attr('data-y')); } if (allowX) { distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); } else { distanceX = -Math.abs(_$el.attr('data-x')); } _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); } }); $(window).on('mouseup.lg.zoom', function(e) { if (isDraging) { isDraging = false; _this.core.$outer.removeClass('lg-zoom-dragging'); // Fix for chrome mouse move on click if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) { endCoords = { x: e.pageX, y: e.pageY }; _this.touchendZoom(startCoords, endCoords, allowX, allowY); } isMoved = false; } _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab'); }); }; Zoom.prototype.touchendZoom = function(startCoords, endCoords, allowX, allowY) { var _this = this; var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); var distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); var distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); var minY = (_this.core.$outer.find('.lg').height() - $image.outerHeight()) / 2; var maxY = Math.abs(($image.outerHeight() * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').height() + minY); var minX = (_this.core.$outer.find('.lg').width() - $image.outerWidth()) / 2; var maxX = Math.abs(($image.outerWidth() * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').width() + minX); if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { if (allowY) { if (distanceY <= -maxY) { distanceY = -maxY; } else if (distanceY >= -minY) { distanceY = -minY; } } if (allowX) { if (distanceX <= -maxX) { distanceX = -maxX; } else if (distanceX >= -minX) { distanceX = -minX; } } if (allowY) { _$el.attr('data-y', Math.abs(distanceY)); } else { distanceY = -Math.abs(_$el.attr('data-y')); } if (allowX) { _$el.attr('data-x', Math.abs(distanceX)); } else { distanceX = -Math.abs(_$el.attr('data-x')); } _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); } }; Zoom.prototype.destroy = function() { var _this = this; // Unbind all events added by lightGallery zoom plugin _this.core.$el.off('.lg.zoom'); $(window).off('.lg.zoom'); _this.core.$slide.off('.lg.zoom'); _this.core.$el.off('.lg.tm.zoom'); _this.resetZoom(); clearTimeout(_this.zoomabletimeout); _this.zoomabletimeout = false; }; $.fn.lightGallery.modules.zoom = Zoom; })(jQuery, window, document);
#include "config.h" #if ENABLE(WEB_AUDIO) #include "<API key>.h" #include "AudioDSPKernel.h" namespace WebCore { // setNumberOfChannels() may later be called if the object is not yet in an "initialized" state. <API key>::<API key>(double sampleRate, unsigned numberOfChannels) : AudioProcessor(sampleRate) , m_numberOfChannels(numberOfChannels) , m_hasJustReset(true) { } void <API key>::initialize() { if (isInitialized()) return; ASSERT(!m_kernels.size()); // Create processing kernels, one per channel. for (unsigned i = 0; i < numberOfChannels(); ++i) m_kernels.append(createKernel()); m_initialized = true; } void <API key>::uninitialize() { if (!isInitialized()) return; m_kernels.clear(); m_initialized = false; } void <API key>::process(AudioBus* source, AudioBus* destination, size_t framesToProcess) { ASSERT(source && destination); if (!source || !destination) return; if (!isInitialized()) { destination->zero(); return; } bool channelCountMatches = source->numberOfChannels() == destination->numberOfChannels() && source->numberOfChannels() == m_kernels.size(); ASSERT(channelCountMatches); if (!channelCountMatches) return; for (unsigned i = 0; i < m_kernels.size(); ++i) m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->data(), framesToProcess); } // Resets filter state void <API key>::reset() { if (!isInitialized()) return; // Forces snap to parameter values - first time. // Any processing depending on this value must set it to false at the appropriate time. m_hasJustReset = true; for (unsigned i = 0; i < m_kernels.size(); ++i) m_kernels[i]->reset(); } void <API key>::setNumberOfChannels(unsigned numberOfChannels) { ASSERT(!isInitialized()); if (!isInitialized()) m_numberOfChannels = numberOfChannels; } } // namespace WebCore #endif // ENABLE(WEB_AUDIO)
'use strict'; angular.module("ngLocale", [], ["$provide", function($provide) { var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"}; $provide.value("$locale", { "DATETIME_FORMATS": { "AMPMS": [ "nt\u0254\u0301ng\u0254\u0301", "mp\u00f3kwa" ], "DAY": [ "eyenga", "mok\u0254l\u0254 mwa yambo", "mok\u0254l\u0254 mwa m\u00edbal\u00e9", "mok\u0254l\u0254 mwa m\u00eds\u00e1to", "mok\u0254l\u0254 ya m\u00edn\u00e9i", "mok\u0254l\u0254 ya m\u00edt\u00e1no", "mp\u0254\u0301s\u0254" ], "MONTH": [ "s\u00e1nz\u00e1 ya yambo", "s\u00e1nz\u00e1 ya m\u00edbal\u00e9", "s\u00e1nz\u00e1 ya m\u00eds\u00e1to", "s\u00e1nz\u00e1 ya m\u00ednei", "s\u00e1nz\u00e1 ya m\u00edt\u00e1no", "s\u00e1nz\u00e1 ya mot\u00f3b\u00e1", "s\u00e1nz\u00e1 ya nsambo", "s\u00e1nz\u00e1 ya mwambe", "s\u00e1nz\u00e1 ya libwa", "s\u00e1nz\u00e1 ya z\u00f3mi", "s\u00e1nz\u00e1 ya z\u00f3mi na m\u0254\u030ck\u0254\u0301", "s\u00e1nz\u00e1 ya z\u00f3mi na m\u00edbal\u00e9" ], "SHORTDAY": [ "eye", "ybo", "mbl", "mst", "min", "mtn", "mps" ], "SHORTMONTH": [ "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "\u0254tb", "nvb", "dsb" ], "fullDate": "EEEE d MMMM y", "longDate": "d MMMM y", "medium": "d MMM y HH:mm:ss", "mediumDate": "d MMM y", "mediumTime": "HH:mm:ss", "short": "d/M/y HH:mm", "shortDate": "d/M/y", "shortTime": "HH:mm" }, "NUMBER_FORMATS": { "CURRENCY_SYM": "FCFA", "DECIMAL_SEP": ",", "GROUP_SEP": ".", "PATTERNS": [ { "gSize": 3, "lgSize": 3, "maxFrac": 3, "minFrac": 0, "minInt": 1, "negPre": "-", "negSuf": "", "posPre": "", "posSuf": "" }, { "gSize": 3, "lgSize": 3, "maxFrac": 2, "minFrac": 2, "minInt": 1, "negPre": "-", "negSuf": "\u00a0\u00a4", "posPre": "", "posSuf": "\u00a0\u00a4" } ] }, "id": "ln-cf", "pluralCat": function (n, opt_precision) { if (n >= 0 && n <= 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;} }); }]);
// Type definitions for lodash.methodOf 4.5 import { methodOf } from "lodash"; export = methodOf;
// PR c++/41090 // { dg-do run } // { dg-options "-save-temps" } // { dg-final { scan-assembler "_ZN1CC4Ev" } } // { dg-final cleanup-saved-temps } int i; struct A { A() {} }; struct C: virtual A { C(); }; C::C() { static void *labelref = &&label; goto *labelref; label: i = 1; } int main() { C c; return (i != 1); }
/* (the GPL), available at */ /* to copy and distribute the resulting executable under terms of your*/ /* choice, provided that you also meet, for each linked */ /* module.An independent module is a module which is not derived from */ /* this software. The special exception does not apply to any */ /* modifications of the software. */ /* Notwithstanding the above, under no circumstances may you combine */ /* this software in any way with any other Broadcom software provided */ /* without Broadcom's express prior written consent. */ #ifndef _CSL_CAPH_SRCMIXER_ #define _CSL_CAPH_SRCMIXER_ #include "chal_caph.h" #include "csl_caph_cfifo.h" #include "csl_caph_switch.h" #if defined(<API key>) /* Total number of input channels */ #define MAX_INCHNLS 0x9 /* Total number of single input channels */ #define MAX_SINGLE_INCHNLS 0xC #else /* Total number of input channels */ #define MAX_INCHNLS 0x7 /* Total number of single input channels */ #define MAX_SINGLE_INCHNLS 0xA #endif /* Total number of output channels */ #ifdef <API key> #define <API key> 0x6 /* for stereo IHF */ #else #define <API key> 0x5 #endif /* Bit Selection for Mixer Spkr gain */ /* It will magnify the input by Bit_Select*6.02dB */ #define BIT_SELECT 0x0 /* Gain values to mute the mixer input path */ #define MIX_IN_MUTE 0x0000 /* Gain values to pass the mixer input path */ /* adjustable to different gains. */ #define MIX_IN_PASS 0x7FFF /* Mixer input gain steps */ #define MIX_IN_GAINSTEP 0x7FFF #define MIX_IN_NO_GAINSTEP 0x0000 #define <API key> 0x0 #define <API key> 0x0 /* SRCMixer Input FIFO threshold */ #define INFIFO_NO_THRES 0x0 #ifndef GAIN_NA #define GAIN_NA 0x8001 #endif enum <API key> { <API key>, <API key>, <API key>, <API key>, }; #define <API key> enum <API key> enum <API key> { <API key> = 0x0000, <API key> = 0x0001, <API key> = 0x0002, <API key> = 0x0004, <API key> = 0x0008, <API key> = 0x0010, <API key> = 0x0020, <API key> = 0x0040, <API key> = 0x0080, <API key> = 0x0100, <API key> = 0x0200, <API key> = (<API key> | <API key> | <API key> | <API key>), <API key> = (<API key> | <API key>), <API key> = (<API key> | <API key>), <API key> = (<API key> | <API key>), <API key> = (<API key> | <API key>), <API key> = 0x0400, <API key> = 0x0800, <API key> = (<API key> | <API key>), }; #define <API key> enum <API key> enum <API key> { <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, }; #define <API key> enum <API key> enum CSL_CAPH_MIXER_e { <API key> = 0x00, <API key> = 0x01, <API key> = 0x02, <API key> = (<API key> | <API key>), <API key> = 0x04, <API key> = 0x08, #ifdef <API key> <API key> = (<API key>|<API key>), #endif }; #define CSL_CAPH_MIXER_e enum CSL_CAPH_MIXER_e enum <API key> { <API key>, <API key>, <API key>, }; #define <API key> enum <API key> struct <API key> { <API key> inChnl; UInt8 inThres; <API key> inSampleRate; <API key> inDataFmt; CSL_CAPH_MIXER_e outChnl; <API key> tapOutChnl; UInt8 outThres; <API key> outSampleRate; <API key> outDataFmt; CSL_CAPH_DEVICE_e sink; }; #define <API key> struct <API key> enum <API key> { <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, }; #define <API key> enum <API key> struct MixGainMapping_t { int requestGain_mB; int requestGain_qDB; /* dB in Q13.2 */ unsigned int mixerInputGain; /* Register value. */ /* Register value. Bit12:0, Output Fine Gain */ unsigned int mixerOutputFineGain; }; void <API key>(UInt32 baseAddress, UInt32 caphIntcHandle); void <API key>(void); <API key> <API key>(<API key> dataFormat, <API key> sampleRate, <API key> srOut); CSL_CAPH_MIXER_e <API key>(CSL_CAPH_DEVICE_e sink); void <API key>(<API key> chnl); void <API key>(CSL_CAPH_MIXER_e chnl); void <API key>(<API key> chnl); void <API key>(<API key> routeConfig); void <API key>(<API key> routeConfig); void <API key>(<API key> routeConfig); <API key> <API key>( <API key> inSampleRate); void <API key>(<API key> inChnl, CSL_CAPH_MIXER_e outChnl, int gainL_mB, int gainR_mB); void <API key>(CSL_CAPH_MIXER_e outChnl, int gainL_mB, int gainR_mB); void <API key>(CSL_CAPH_MIXER_e outChnl, int gainL_mB, int gainR_mB); void <API key>(CSL_CAPH_MIXER_e outChnl, unsigned int bit_shift_l, unsigned int bit_shift_r); UInt32 <API key>(<API key> fifo); <API key> <API key>(<API key> inChnl); <API key> <API key>(CSL_CAPH_MIXER_e outChnl); <API key> <API key>(<API key> outChnl); <API key> <API key>(<API key> inChnl); <API key> <API key>(<API key> sampleRate); <API key> <API key>(<API key> sampleRate); <API key> <API key>(<API key> inChnl); UInt16 <API key>(UInt16 inChnl); void <API key>(<API key> chnl); void <API key>(CSL_CAPH_MIXER_e outChnl, <API key> inChnl); <API key> <API key>(<API key> inChnl); void <API key>(Boolean stIHF); void <API key>(Boolean mode); void <API key>(<API key> chnl, CSL_CAPH_ARM_DSP_e csl_owner); void <API key>(<API key> chnl, CSL_CAPH_ARM_DSP_e csl_owner); void <API key>(<API key> chnl, CSL_CAPH_ARM_DSP_e csl_owner); void <API key>(<API key> chnl, CSL_CAPH_ARM_DSP_e csl_owner); UInt16 <API key>(CSL_CAPH_MIXER_e outChnl); void <API key>(<API key> inChnl); void <API key>(<API key> inChnl); void <API key>(<API key> in, int enable); #endif /* _CSL_CAPH_SRCMIXER_ */
Popup.template.events({ 'click .js-back-view'() { Popup.back(); }, 'click .js-close-pop-over'() { Popup.close(); }, 'click .js-confirm'() { this.<API key>.call(this); }, // This handler intends to solve a pretty tricky bug with our popup // transition. The transition is implemented using a large container // (.content-container) that is moved on the x-axis (from 0 to n*PopupSize) // inside a wrapper (.container-wrapper) with a hidden overflow. The problem // is that sometimes the wrapper is scrolled -- even if there are no // scrollbars. This happen for instance when the newly opened popup has some // focused field, the browser will automatically scroll the wrapper, resulting // in moving the whole popup container outside of the popup wrapper. To // disable this behavior we have to manually reset the scrollLeft position // whenever it is modified. 'scroll .content-wrapper'(evt) { evt.currentTarget.scrollLeft = 0; }, }); // When a popup content is removed (ie, when the user press the "back" button), // we need to wait for the container translation to end before removing the // actual DOM element. For that purpose we use the undocumented `_uihooks` API. Popup.template.onRendered(() => { const container = this.find('.content-container'); container._uihooks = { removeElement(node) { $(node).addClass('no-height'); $(container).one(CSSEvents.transitionend, () => { node.parentNode.removeChild(node); }); }, }; });
// C++ informative line for the emacs editor: -*- C++ -*- #ifndef _H5StrType_H #define _H5StrType_H #ifndef H5_NO_NAMESPACE namespace H5 { #endif class H5_DLLCPP StrType : public AtomType { public: // Creates a string type using a predefined type StrType(const PredType& pred_type); // Creates a string type with specified length - may be obsolete StrType(const PredType& pred_type, const size_t& size); // Creates a string type with specified length StrType(const int dummy, const size_t& size); // Gets the string datatype of the specified dataset StrType(const DataSet& dataset); // Retrieves the character set type of this string datatype. H5T_cset_t getCset() const; // Sets character set to be used. void setCset(H5T_cset_t cset) const; // Retrieves the string padding method for this string datatype. H5T_str_t getStrpad() const; // Defines the storage mechanism for character strings. void setStrpad(H5T_str_t strpad) const; \brief Returns this class name virtual H5std_string fromClass () const { return("StrType"); } // default constructor StrType(); // Creates a string datatype using an existing id StrType(const hid_t existing_id); // Copy constructor - makes a copy of the original object StrType(const StrType& original); // Noop destructor. virtual ~StrType(); }; #ifndef H5_NO_NAMESPACE } #endif #endif
#ifndef __RK610_CONTROL_H_ #define __RK610_CONTROL_H_ #define INVALID_GPIO -1 //#define RK610_DEBUG #ifdef RK610_DEBUG #define RK610_DBG(dev, format, arg...) \ do{\ dev_printk(KERN_INFO , dev , format , ## arg);\ }while(0) #else #define RK610_DBG(dev, format, arg...) #endif #define RK610_ERR(dev, format, arg...) \ do{\ dev_printk(KERN_ERR , dev , format , ## arg);\ }while(0) #define <API key> 0x00 #define <API key> 0x01 #define <API key> 0x02 #define <API key> 0x03 #define <API key> 0x04 #define <API key> 0x05 #define C_PLL_DISABLE_FRAC 1 << 0 #define C_PLL_BYPSS_ENABLE 1 << 1 #define C_PLL_POWER_ON 1 << 2 #define C_PLL_LOCLED 1 << 7 #define <API key> 0x29 #define <API key> 1 << 7 #define <API key> 0 << 7 #define <API key> 1 << 6 #define <API key> 0 << 5 enum { <API key> = 0, <API key>, <API key>, <API key> }; #define <API key>(n) n << 4 #define <API key> 1 << 3 #define <API key> 0 << 3 #define <API key> 1 << 2 #define <API key> 0 << 2 #define RGB2CCIR_CVBS_PAL 0 << 1 #define RGB2CCIR_CVBS_NTSC 1 << 1 #define RGB2CCIR_DISABLE 0 #define RGB2CCIR_ENABLE 1 #define <API key> 0x2a #define <API key> 0x2b #define <API key> 0x2c #define <API key> 1 << 5 #define <API key> 0x1F #define <API key> 0x2d #define <API key> 1<<4 #define <API key> 1<<3 #define <API key> 1<<2 #define <API key> 1<<0 #define <API key> 0x2e /* CODEC PLL REG */ #define C_PLL_CON0 0x00 #define C_PLL_CON1 0x01 #define C_PLL_CON2 0x02 #define C_PLL_CON3 0x03 #define C_PLL_CON4 0x04 #define C_PLL_CON5 0x05 /* SCALER PLL REG */ #define S_PLL_CON0 0x06 #define S_PLL_CON1 0x07 #define S_PLL_CON2 0x08 /* LVDS REG */ #define LVDS_CON0 0x09 #define LVDS_CON1 0x0a /* LCD1 REG */ #define LCD1_CON 0x0b /* SCALER REG */ #define SCL_CON0 0x0c #define SCL_CON1 0x0d #define SCL_CON2 0x0e #define SCL_CON3 0x0f #define SCL_CON4 0x10 #define SCL_CON5 0x11 #define SCL_CON6 0x12 #define SCL_CON7 0x13 #define SCL_CON8 0x14 #define SCL_CON9 0x15 #define SCL_CON10 0x16 #define SCL_CON11 0x17 #define SCL_CON12 0x18 #define SCL_CON13 0x19 #define SCL_CON14 0x1a #define SCL_CON15 0x1b #define SCL_CON16 0x1c #define SCL_CON17 0x1d #define SCL_CON18 0x1e #define SCL_CON19 0x1f #define SCL_CON20 0x20 #define SCL_CON21 0x21 #define SCL_CON22 0x22 #define SCL_CON23 0x23 #define SCL_CON24 0x24 #define SCL_CON25 0x25 #define SCL_CON26 0x26 #define SCL_CON27 0x27 #define SCL_CON28 0x28 /* TVE REG */ #define TVE_CON 0x29 /* CCIR REG */ #define CCIR_RESET 0X2a /* CLOCK REG */ #define CLOCK_CON0 0X2b #define CLOCK_CON1 0X2c /* CODEC REG */ #define CODEC_CON 0x2e #define I2C_CON 0x2f struct <API key> { int (*rk610_power_on_init)(void); }; struct rk610_core_info{ struct i2c_client *client; struct device *dev; struct <API key> *pdata; struct dentry *debugfs_dir; void *lcd_pdata; }; extern int <API key>(const char reg, const char data); #endif /*end of __RK610_CONTROL_H_*/
<!DOCTYPE html> <html> <body> <p>Tests <API key> does not mark scripts elements it parsed as already started. You should see PASS below:</p> <div id="test"></div> <script> var range = document.createRange(); var node = document.getElementById("test"); var count = 0; range.selectNodeContents(node); node.appendChild(range.<API key>("<script> count++; </script" + ">")); node.textContent = count == 1 ? 'PASS' : 'FAIL - expected one execution but executed ' + count + ' times'; if (window.testRunner) testRunner.dumpAsText(); </script> </body> </html>
<!DOCTYPE html> <html> <body> <p>This tests inserting a td element "beforeBegin" of another td element using insertAdjacentHTML. If the context element was not properly adjusted, then td will be stripped by the parser.</p> <table><tr><td></td></tr></table> <script> if (window.testRunner) testRunner.dumpAsText(); var td = document.querySelector('td'); td.insertAdjacentHTML('beforeBegin', '<td></td>'); document.write(document.<API key>('td').length == 2 ? 'PASS' : 'FAIL'); </script> </body> </html>
<?php /** * @see <API key> */ require_once 'Zend/Service/Simpy/WatchlistFilter.php'; class <API key> implements IteratorAggregate { /** * List of filters in the set * * @var array of <API key> objects */ protected $_filters = array(); /** * Adds a filter to the set * * @param <API key> $filter Filter to be added * @return void */ public function add(<API key> $filter) { $this->_filters[] = $filter; } /** * Returns an iterator for the watchlist filter set * * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_filters); } /** * Returns the number of filters in the set * * @return int */ public function getLength() { return count($this->_filters); } }
package sun.nio.cs.ext; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import sun.nio.cs.Surrogate; abstract class ISO2022 extends Charset { private static final byte ISO_ESC = 0x1b; private static final byte ISO_SI = 0x0f; private static final byte ISO_SO = 0x0e; private static final byte ISO_SS2_7 = 0x4e; private static final byte ISO_SS3_7 = 0x4f; private static final byte MSB = (byte)0x80; private static final char REPLACE_CHAR = '\uFFFD'; private static final byte minDesignatorLength = 3; public ISO2022(String csname, String[] aliases) { super(csname, aliases); } public CharsetDecoder newDecoder() { return new Decoder(this); } public CharsetEncoder newEncoder() { return new Encoder(this); } protected static class Decoder extends CharsetDecoder { // Value to be filled by subclass protected byte SODesig[][]; protected byte SS2Desig[][] = null; protected byte SS3Desig[][] = null; protected CharsetDecoder SODecoder[]; protected CharsetDecoder SS2Decoder[] = null; protected CharsetDecoder SS3Decoder[] = null; private static final byte SOFlag = 0; private static final byte SS2Flag = 1; private static final byte SS3Flag = 2; private int curSODes, curSS2Des, curSS3Des; private boolean shiftout; private CharsetDecoder tmpDecoder[]; protected Decoder(Charset cs) { super(cs, 1.0f, 1.0f); } protected void implReset() { curSODes = 0; curSS2Des = 0; curSS3Des = 0; shiftout = false; } private char decode(byte byte1, byte byte2, byte shiftFlag) { byte1 |= MSB; byte2 |= MSB; byte[] tmpByte = { byte1,byte2 }; char[] tmpChar = new char[1]; int i = 0, tmpIndex = 0; switch(shiftFlag) { case SOFlag: tmpIndex = curSODes; tmpDecoder = SODecoder; break; case SS2Flag: tmpIndex = curSS2Des; tmpDecoder = SS2Decoder; break; case SS3Flag: tmpIndex = curSS3Des; tmpDecoder = SS3Decoder; break; } if (tmpDecoder != null) { for(i = 0; i < tmpDecoder.length; i++) { if(tmpIndex == i) { try { ByteBuffer bb = ByteBuffer.wrap(tmpByte,0,2); CharBuffer cc = CharBuffer.wrap(tmpChar,0,1); tmpDecoder[i].decode(bb, cc, true); cc.flip(); return cc.get(); } catch (Exception e) {} } } } return REPLACE_CHAR; } private int findDesig(byte[] in, int sp, int sl, byte[][] desigs) { if (desigs == null) return -1; int i = 0; while (i < desigs.length) { if (desigs[i] != null && sl - sp >= desigs[i].length) { int j = 0; while (j < desigs[i].length && in[sp+j] == desigs[i][j]) { j++; } if (j == desigs[i].length) return i; } i++; } return -1; } private int findDesigBuf(ByteBuffer in, byte[][] desigs) { if (desigs == null) return -1; int i = 0; while (i < desigs.length) { if (desigs[i] != null && in.remaining() >= desigs[i].length) { int j = 0; in.mark(); while (j < desigs[i].length && in.get() == desigs[i][j]) { j++; } if (j == desigs[i].length) return i; in.reset(); } i++; } return -1; } private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { byte[] sa = src.array(); int sp = src.arrayOffset() + src.position(); int sl = src.arrayOffset() + src.limit(); assert (sp <= sl); sp = (sp <= sl ? sp : sl); char[] da = dst.array(); int dp = dst.arrayOffset() + dst.position(); int dl = dst.arrayOffset() + dst.limit(); assert (dp <= dl); dp = (dp <= dl ? dp : dl); int b1 = 0, b2 = 0, b3 = 0; try { while (sp < sl) { b1 = sa[sp] & 0xff; int inputSize = 1; switch (b1) { case ISO_SO: shiftout = true; inputSize = 1; break; case ISO_SI: shiftout = false; inputSize = 1; break; case ISO_ESC: if (sl - sp - 1 < minDesignatorLength) return CoderResult.UNDERFLOW; int desig = findDesig(sa, sp + 1, sl, SODesig); if (desig != -1) { curSODes = desig; inputSize = SODesig[desig].length + 1; break; } desig = findDesig(sa, sp + 1, sl, SS2Desig); if (desig != -1) { curSS2Des = desig; inputSize = SS2Desig[desig].length + 1; break; } desig = findDesig(sa, sp + 1, sl, SS3Desig); if (desig != -1) { curSS3Des = desig; inputSize = SS3Desig[desig].length + 1; break; } if (sl - sp < 2) return CoderResult.UNDERFLOW; b1 = sa[sp + 1]; switch(b1) { case ISO_SS2_7: if (sl - sp < 4) return CoderResult.UNDERFLOW; b2 = sa[sp +2]; b3 = sa[sp +3]; if (dl - dp <1) return CoderResult.OVERFLOW; da[dp] = decode((byte)b2, (byte)b3, SS2Flag); dp++; inputSize = 4; break; case ISO_SS3_7: if (sl - sp < 4) return CoderResult.UNDERFLOW; b2 = sa[sp + 2]; b3 = sa[sp + 3]; if (dl - dp <1) return CoderResult.OVERFLOW; da[dp] = decode((byte)b2, (byte)b3, SS3Flag); dp++; inputSize = 4; break; default: return CoderResult.malformedForLength(2); } break; default: if (dl - dp < 1) return CoderResult.OVERFLOW; if (!shiftout) { da[dp++]=(char)(sa[sp] & 0xff); } else { if (dl - dp < 1) return CoderResult.OVERFLOW; if (sl - sp < 2) return CoderResult.UNDERFLOW; b2 = sa[sp+1] & 0xff; da[dp++] = decode((byte)b1, (byte)b2, SOFlag); inputSize = 2; } break; } sp += inputSize; } return CoderResult.UNDERFLOW; } finally { src.position(sp - src.arrayOffset()); dst.position(dp - dst.arrayOffset()); } } private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { int mark = src.position(); int b1 = 0, b2 = 0, b3 = 0; try { while (src.hasRemaining()) { b1 = src.get(); int inputSize = 1; switch (b1) { case ISO_SO: shiftout = true; break; case ISO_SI: shiftout = false; break; case ISO_ESC: if (src.remaining() < minDesignatorLength) return CoderResult.UNDERFLOW; int desig = findDesigBuf(src, SODesig); if (desig != -1) { curSODes = desig; inputSize = SODesig[desig].length + 1; break; } desig = findDesigBuf(src, SS2Desig); if (desig != -1) { curSS2Des = desig; inputSize = SS2Desig[desig].length + 1; break; } desig = findDesigBuf(src, SS3Desig); if (desig != -1) { curSS3Des = desig; inputSize = SS3Desig[desig].length + 1; break; } if (src.remaining() < 1) return CoderResult.UNDERFLOW; b1 = src.get(); switch(b1) { case ISO_SS2_7: if (src.remaining() < 2) return CoderResult.UNDERFLOW; b2 = src.get(); b3 = src.get(); if (dst.remaining() < 1) return CoderResult.OVERFLOW; dst.put(decode((byte)b2, (byte)b3, SS2Flag)); inputSize = 4; break; case ISO_SS3_7: if (src.remaining() < 2) return CoderResult.UNDERFLOW; b2 = src.get(); b3 = src.get(); if (dst.remaining() < 1) return CoderResult.OVERFLOW; dst.put(decode((byte)b2, (byte)b3, SS3Flag)); inputSize = 4; break; default: return CoderResult.malformedForLength(2); } break; default: if (dst.remaining() < 1) return CoderResult.OVERFLOW; if (!shiftout) { dst.put((char)(b1 & 0xff)); } else { if (dst.remaining() < 1) return CoderResult.OVERFLOW; if (src.remaining() < 1) return CoderResult.UNDERFLOW; b2 = src.get() & 0xff; dst.put(decode((byte)b1, (byte)b2, SOFlag)); inputSize = 2; } break; } mark += inputSize; } return CoderResult.UNDERFLOW; } catch (Exception e) { e.printStackTrace(); return CoderResult.OVERFLOW; } finally { src.position(mark); } } protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { if (src.hasArray() && dst.hasArray()) return decodeArrayLoop(src, dst); else return decodeBufferLoop(src, dst); } } protected static class Encoder extends CharsetEncoder { private final Surrogate.Parser sgp = new Surrogate.Parser(); public static final byte SS2 = (byte)0x8e; public static final byte PLANE2 = (byte)0xA2; public static final byte PLANE3 = (byte)0xA3; private final byte MSB = (byte)0x80; protected final byte <API key> = 4; protected String SODesig, SS2Desig = null, SS3Desig = null; protected CharsetEncoder ISOEncoder; private boolean shiftout = false; private boolean SODesDefined = false; private boolean SS2DesDefined = false; private boolean SS3DesDefined = false; private boolean newshiftout = false; private boolean newSODesDefined = false; private boolean newSS2DesDefined = false; private boolean newSS3DesDefined = false; protected Encoder(Charset cs) { super(cs, 4.0f, 8.0f); } public boolean canEncode(char c) { return (ISOEncoder.canEncode(c)); } protected void implReset() { shiftout = false; SODesDefined = false; SS2DesDefined = false; SS3DesDefined = false; } private int unicodeToNative(char unicode, byte ebyte[]) { int index = 0; byte tmpByte[]; char convChar[] = {unicode}; byte convByte[] = new byte[4]; int converted; try{ CharBuffer cc = CharBuffer.wrap(convChar); ByteBuffer bb = ByteBuffer.allocate(4); ISOEncoder.encode(cc, bb, true); bb.flip(); converted = bb.remaining(); bb.get(convByte,0,converted); } catch(Exception e) { return -1; } if (converted == 2) { if (!SODesDefined) { newSODesDefined = true; ebyte[0] = ISO_ESC; tmpByte = SODesig.getBytes(); System.arraycopy(tmpByte,0,ebyte,1,tmpByte.length); index = tmpByte.length+1; } if (!shiftout) { newshiftout = true; ebyte[index++] = ISO_SO; } ebyte[index++] = (byte)(convByte[0] & 0x7f); ebyte[index++] = (byte)(convByte[1] & 0x7f); } else { if(convByte[0] == SS2) { if (convByte[1] == PLANE2) { if (!SS2DesDefined) { newSS2DesDefined = true; ebyte[0] = ISO_ESC; tmpByte = SS2Desig.getBytes(); System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length); index = tmpByte.length+1; } ebyte[index++] = ISO_ESC; ebyte[index++] = ISO_SS2_7; ebyte[index++] = (byte)(convByte[2] & 0x7f); ebyte[index++] = (byte)(convByte[3] & 0x7f); } else if (convByte[1] == PLANE3) { if(!SS3DesDefined){ newSS3DesDefined = true; ebyte[0] = ISO_ESC; tmpByte = SS3Desig.getBytes(); System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length); index = tmpByte.length+1; } ebyte[index++] = ISO_ESC; ebyte[index++] = ISO_SS3_7; ebyte[index++] = (byte)(convByte[2] & 0x7f); ebyte[index++] = (byte)(convByte[3] & 0x7f); } } } return index; } private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { char[] sa = src.array(); int sp = src.arrayOffset() + src.position(); int sl = src.arrayOffset() + src.limit(); assert (sp <= sl); sp = (sp <= sl ? sp : sl); byte[] da = dst.array(); int dp = dst.arrayOffset() + dst.position(); int dl = dst.arrayOffset() + dst.limit(); assert (dp <= dl); dp = (dp <= dl ? dp : dl); int outputSize = 0; byte[] outputByte = new byte[8]; newshiftout = shiftout; newSODesDefined = SODesDefined; newSS2DesDefined = SS2DesDefined; newSS3DesDefined = SS3DesDefined; try { while (sp < sl) { char c = sa[sp]; if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); } if (c < 0x80) { // ASCII if (shiftout){ newshiftout = false; outputSize = 2; outputByte[0] = ISO_SI; outputByte[1] = (byte)(c & 0x7f); } else { outputSize = 1; outputByte[0] = (byte)(c & 0x7f); } if(sa[sp] == '\n'){ newSODesDefined = false; newSS2DesDefined = false; newSS3DesDefined = false; } } else { outputSize = unicodeToNative(c, outputByte); if (outputSize == 0) { return CoderResult.unmappableForLength(1); } } if (dl - dp < outputSize) return CoderResult.OVERFLOW; for (int i = 0; i < outputSize; i++) da[dp++] = outputByte[i]; sp++; shiftout = newshiftout; SODesDefined = newSODesDefined; SS2DesDefined = newSS2DesDefined; SS3DesDefined = newSS3DesDefined; } return CoderResult.UNDERFLOW; } finally { src.position(sp - src.arrayOffset()); dst.position(dp - dst.arrayOffset()); } } private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { int outputSize = 0; byte[] outputByte = new byte[8]; int inputSize = 0; // Size of input newshiftout = shiftout; newSODesDefined = SODesDefined; newSS2DesDefined = SS2DesDefined; newSS3DesDefined = SS3DesDefined; int mark = src.position(); try { while (src.hasRemaining()) { char inputChar = src.get(); if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, src) < 0) return sgp.error(); return sgp.unmappableResult(); } if (inputChar < 0x80) { // ASCII if (shiftout){ newshiftout = false; outputSize = 2; outputByte[0] = ISO_SI; outputByte[1] = (byte)(inputChar & 0x7f); } else { outputSize = 1; outputByte[0] = (byte)(inputChar & 0x7f); } if(inputChar == '\n'){ newSODesDefined = false; newSS2DesDefined = false; newSS3DesDefined = false; } } else { outputSize = unicodeToNative(inputChar, outputByte); if (outputSize == 0) { return CoderResult.unmappableForLength(1); } } if (dst.remaining() < outputSize) return CoderResult.OVERFLOW; for (int i = 0; i < outputSize; i++) dst.put(outputByte[i]); mark++; shiftout = newshiftout; SODesDefined = newSODesDefined; SS2DesDefined = newSS2DesDefined; SS3DesDefined = newSS3DesDefined; } return CoderResult.UNDERFLOW; } finally { src.position(mark); } } protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { if (src.hasArray() && dst.hasArray()) return encodeArrayLoop(src, dst); else return encodeBufferLoop(src, dst); } } }
<body onpageshow='onPageshow(event)' onpagehide='onPagehide(event)'> <p>Subframe</p> <iframe src="<API key>.html"></iframe> <script> window.onload = function(evt) { top.log("Subframe window.onload"); } window.onunload = function(evt) { top.log("Subframe window.onunload"); } function onPageshow(evt) { top.log("Subframe window.onpageshow" + ", target = " + evt.target + ", persisted = " + evt.persisted); top.postMessage("subframe-loaded", "*"); } function onPagehide(evt) { top.log("Subframe window.onpagehide" + ", target = " + evt.target + ", persisted = " + evt.persisted); } </script> </body>
#ifndef <API key> #define <API key> #include <linux/types.h> #include <linux/blkdev.h> /* * Block number. */ typedef uint64_t dm_block_t; struct dm_block; dm_block_t dm_block_location(struct dm_block *b); void *dm_block_data(struct dm_block *b); /* * @name should be a unique identifier for the block manager, no longer * than 32 chars. * * @max_held_per_thread should be the maximum number of locks, read or * write, that an individual thread holds at any one time. */ struct dm_block_manager; struct dm_block_manager *<API key>( struct block_device *bdev, unsigned block_size, unsigned max_held_per_thread); void <API key>(struct dm_block_manager *bm); unsigned dm_bm_block_size(struct dm_block_manager *bm); dm_block_t dm_bm_nr_blocks(struct dm_block_manager *bm); /* * The validator allows the caller to verify newly-read data and modify * the data just before writing, e.g. to calculate checksums. It's * important to be consistent with your use of validators. The only time * you can change validators is if you call <API key>. */ struct dm_block_validator { const char *name; void (*prepare_for_write)(struct dm_block_validator *v, struct dm_block *b, size_t block_size); /* * Return 0 if the checksum is valid or < 0 on error. */ int (*check)(struct dm_block_validator *v, struct dm_block *b, size_t block_size); }; /* * You can have multiple concurrent readers or a single writer holding a * block lock. */ /* * dm_bm_lock() locks a block and returns through @result a pointer to * memory that holds a copy of that block. If you have write-locked the * block then any changes you make to memory pointed to by @result will be * written back to the disk sometime after dm_bm_unlock is called. */ int dm_bm_read_lock(struct dm_block_manager *bm, dm_block_t b, struct dm_block_validator *v, struct dm_block **result); int dm_bm_write_lock(struct dm_block_manager *bm, dm_block_t b, struct dm_block_validator *v, struct dm_block **result); /* * The *_try_lock variants return -EWOULDBLOCK if the block isn't * available immediately. */ int dm_bm_read_try_lock(struct dm_block_manager *bm, dm_block_t b, struct dm_block_validator *v, struct dm_block **result); /* * Use <API key>() when you know you're going to * overwrite the block completely. It saves a disk read. */ int <API key>(struct dm_block_manager *bm, dm_block_t b, struct dm_block_validator *v, struct dm_block **result); void dm_bm_unlock(struct dm_block *b); /* * It's a common idiom to have a superblock that should be committed last. * * @superblock should be write-locked on entry. It will be unlocked during * this function. All dirty blocks are guaranteed to be written and flushed * before the superblock. * * This method always blocks. */ int dm_bm_flush(struct dm_block_manager *bm); /* * Request data is prefetched into the cache. */ void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b); /* * Switches the bm to a read only mode. Once read-only mode * has been entered the following functions will return -EPERM. * * dm_bm_write_lock * <API key> * <API key> * * Additionally you should not use dm_bm_unlock_move, however no error will * be returned if you do. */ bool dm_bm_is_read_only(struct dm_block_manager *bm); void dm_bm_set_read_only(struct dm_block_manager *bm); void <API key>(struct dm_block_manager *bm); u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor); #endif /* <API key> */
# webFrame `web-frame` . 200% : javascript var webFrame = require('web-frame'); webFrame.setZoomFactor(2); ## Methods `web-frame` : `webFrame.setZoomFactor(factor)` * `factor` Number - Zoom . 100 . (: 300% = 3.0) `webFrame.getZoomFactor()` . `webFrame.setZoomLevel(level)` * `level` Number - Zoom level . 0 " " . 20% 50% 300% . `webFrame.getZoomLevel()` . `webFrame.setZoomLevelLimits(minimumLevel, maximumLevel)` * `minimumLevel` Number * `maximumLevel` Number , . `webFrame.<API key>(language, autoCorrectWord, provider)` * `language` String * `autoCorrectWord` Boolean * `provider` Object Input field text area (spell checking) . `provider` `spellCheck` . [node-spellchecker][spellchecker] : javascript require('web-frame').<API key>("en-US", true, { spellCheck: function(text) { return !(require('spellchecker').isMisspelled(text)); } }); `webFrame.<API key>(scheme)` * `scheme` String `scheme` . . `https` `data` . `webFrame.<API key>(scheme)` * `scheme` String `scheme` . [spellchecker]: https://github.com/atom/node-spellchecker
<?php class <API key> extends <API key> { public function getResourceName($camelized = false) { if ($camelized) { return 'Countries'; } return 'countries'; } public function __construct($client, $uri) { $this->instance_name = "<API key>"; parent::__construct($client, $uri); } public function get($isoCountry) { $instance = new $this->instance_name($this->client, $this->uri . "/$isoCountry"); $instance->iso_country = $isoCountry; return $instance; } }
#include <lxc/lxccontainer.h> #include <unistd.h> #include <signal.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> #include <string.h> #include <errno.h> #define MYNAME "lxctest1" #define TSTERR(x) do { \ fprintf(stderr, "%d: %s\n", __LINE__, x); \ } while (0) int main() { struct lxc_container *c; const char *p1, *p2; int retval = -1; c = lxc_container_new(MYNAME, NULL); if (!c) { TSTERR("create using default path"); goto err; } p1 = c->get_config_path(c); p2 = c->config_file_name(c); if (!p1 || !p2 || strncmp(p1, p2, strlen(p1))) { TSTERR("Bad result for path names"); goto err; } #define CPATH "/boo" #define FPATH "/boo/lxctest1/config" if (!c->set_config_path(c, "/boo")) { TSTERR("Error setting custom path"); goto err; } p1 = c->get_config_path(c); p2 = c->config_file_name(c); if (strcmp(p1, CPATH) || strcmp(p2, FPATH)) { TSTERR("Bad result for path names after set_config_path()"); goto err; } lxc_container_put(c); c = lxc_container_new(MYNAME, CPATH); if (!c) { TSTERR("create using custom path"); goto err; } p1 = c->get_config_path(c); p2 = c->config_file_name(c); if (strcmp(p1, CPATH) || strcmp(p2, FPATH)) { TSTERR("Bad result for path names after create with custom path"); goto err; } retval = 0; err: lxc_container_put(c); return retval; }
// file at the top-level directory of this distribution and at // option. This file may not be copied, modified, or distributed // except according to those terms. // pretty-expanded FIXME #23616 extern fn f() { } pub fn main() { }
<?php final class Phabricator<API key> extends <API key> { public function <API key>() { return new Phabricator<API key>(); } }
// Use of this source code is governed by a BSD-style package gc import ( "cmd/internal/obj" "fmt" "strconv" ) /* * <API key> object file output */ const ( ArhdrSize = 60 ) func formathdr(arhdr []byte, name string, size int64) { copy(arhdr[:], fmt.Sprintf("%-16s%-12d%-6d%-6d%-8o%-10d`\n", name, 0, 0, 0, 0644, size)) } func dumpobj() { var err error bout, err = obj.Bopenw(outfile) if err != nil { Flusherrors() fmt.Printf("can't create %s: %v\n", outfile, err) errorexit() } startobj := int64(0) var arhdr [ArhdrSize]byte if writearchive != 0 { obj.Bwritestring(bout, "!<arch>\n") arhdr = [ArhdrSize]byte{} bout.Write(arhdr[:]) startobj = obj.Boffset(bout) } fmt.Fprintf(bout, "go object %s %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion(), obj.Expstring()) dumpexport() if writearchive != 0 { bout.Flush() size := obj.Boffset(bout) - startobj if size&1 != 0 { obj.Bputc(bout, 0) } obj.Bseek(bout, startobj-ArhdrSize, 0) formathdr(arhdr[:], "__.PKGDEF", size) bout.Write(arhdr[:]) bout.Flush() obj.Bseek(bout, startobj+size+(size&1), 0) arhdr = [ArhdrSize]byte{} bout.Write(arhdr[:]) startobj = obj.Boffset(bout) fmt.Fprintf(bout, "go object %s %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion(), obj.Expstring()) } if pragcgobuf != "" { if writearchive != 0 { // write empty export section; must be before cgo section fmt.Fprintf(bout, "\n$$\n\n$$\n\n") } fmt.Fprintf(bout, "\n$$ // cgo\n") fmt.Fprintf(bout, "%s\n$$\n\n", pragcgobuf) } fmt.Fprintf(bout, "\n!\n") var externs *NodeList if externdcl != nil { externs = externdcl.End } dumpglobls() dumptypestructs() // Dump extra globals. tmp := externdcl if externs != nil { externdcl = externs.Next } dumpglobls() externdcl = tmp zero := Pkglookup("zerovalue", Runtimepkg) ggloblsym(zero, int32(zerosize), obj.DUPOK|obj.RODATA) dumpdata() obj.Writeobjdirect(Ctxt, bout) if writearchive != 0 { bout.Flush() size := obj.Boffset(bout) - startobj if size&1 != 0 { obj.Bputc(bout, 0) } obj.Bseek(bout, startobj-ArhdrSize, 0) formathdr(arhdr[:], "_go_.o", size) bout.Write(arhdr[:]) } obj.Bterm(bout) } func dumpglobls() { var n *Node // add globals for l := externdcl; l != nil; l = l.Next { n = l.N if n.Op != ONAME { continue } if n.Type == nil { Fatal("external %v nil type\n", n) } if n.Class == PFUNC { continue } if n.Sym.Pkg != localpkg { continue } dowidth(n.Type) ggloblnod(n) } for l := funcsyms; l != nil; l = l.Next { n = l.N dsymptr(n.Sym, 0, n.Sym.Def.Func.Shortname.Sym, 0) ggloblsym(n.Sym, int32(Widthptr), obj.DUPOK|obj.RODATA) } // Do not reprocess funcsyms on next dumpglobls call. funcsyms = nil } func Bputname(b *obj.Biobuf, s *obj.LSym) { obj.Bwritestring(b, s.Name) obj.Bputc(b, 0) } func Linksym(s *Sym) *obj.LSym { if s == nil { return nil } if s.Lsym != nil { return s.Lsym } var name string if isblanksym(s) { name = "_" } else if s.Linkname != "" { name = s.Linkname } else { name = s.Pkg.Prefix + "." + s.Name } ls := obj.Linklookup(Ctxt, name, 0) s.Lsym = ls return ls } func duintxx(s *Sym, off int, v uint64, wid int) int { // Update symbol data directly instead of generating a // DATA instruction that liblink will have to interpret later. // This reduces compilation time and memory usage. off = int(Rnd(int64(off), int64(wid))) return int(obj.Setuintxx(Ctxt, Linksym(s), int64(off), v, int64(wid))) } func duint8(s *Sym, off int, v uint8) int { return duintxx(s, off, uint64(v), 1) } func duint16(s *Sym, off int, v uint16) int { return duintxx(s, off, uint64(v), 2) } func duint32(s *Sym, off int, v uint32) int { return duintxx(s, off, uint64(v), 4) } func duint64(s *Sym, off int, v uint64) int { return duintxx(s, off, v, 8) } func duintptr(s *Sym, off int, v uint64) int { return duintxx(s, off, v, Widthptr) } var stringsym_gen int func stringsym(s string) (hdr, data *Sym) { var symname string var pkg *Pkg if len(s) > 100 { // huge strings are made static to avoid long names stringsym_gen++ symname = fmt.Sprintf(".gostring.%d", stringsym_gen) pkg = localpkg } else { // small strings get named by their contents, // so that multiple modules using the same string // can share it. symname = strconv.Quote(s) pkg = gostringpkg } symhdr := Pkglookup("hdr."+symname, pkg) symdata := Pkglookup(symname, pkg) // SymUniq flag indicates that data is generated already if symhdr.Flags&SymUniq != 0 { return symhdr, symdata } symhdr.Flags |= SymUniq symhdr.Def = newname(symhdr) // string header off := 0 off = dsymptr(symhdr, off, symdata, 0) off = duintxx(symhdr, off, uint64(len(s)), Widthint) ggloblsym(symhdr, int32(off), obj.DUPOK|obj.RODATA|obj.LOCAL) // string data if symdata.Flags&SymUniq != 0 { return symhdr, symdata } symdata.Flags |= SymUniq symdata.Def = newname(symdata) off = 0 var m int for n := 0; n < len(s); n += m { m = 8 if m > len(s)-n { m = len(s) - n } off = dsname(symdata, off, s[n:n+m]) } off = duint8(symdata, off, 0) // terminating NUL for runtime off = (off + Widthptr - 1) &^ (Widthptr - 1) // round to pointer alignment ggloblsym(symdata, int32(off), obj.DUPOK|obj.RODATA|obj.LOCAL) return symhdr, symdata } var slicebytes_gen int func slicebytes(nam *Node, s string, len int) { var m int slicebytes_gen++ symname := fmt.Sprintf(".gobytes.%d", slicebytes_gen) sym := Pkglookup(symname, localpkg) sym.Def = newname(sym) off := 0 for n := 0; n < len; n += m { m = 8 if m > len-n { m = len - n } off = dsname(sym, off, s[n:n+m]) } ggloblsym(sym, int32(off), obj.NOPTR|obj.LOCAL) if nam.Op != ONAME { Fatal("slicebytes %v", nam) } off = int(nam.Xoffset) off = dsymptr(nam.Sym, off, sym, 0) off = duintxx(nam.Sym, off, uint64(len), Widthint) duintxx(nam.Sym, off, uint64(len), Widthint) } func dstringptr(s *Sym, off int, str string) int { off = int(Rnd(int64(off), int64(Widthptr))) p := Thearch.Gins(obj.ADATA, nil, nil) p.From.Type = obj.TYPE_MEM p.From.Name = obj.NAME_EXTERN p.From.Sym = Linksym(s) p.From.Offset = int64(off) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(Widthptr) Datastring(str+"\x00", &p.To) // TODO(rsc): Remove NUL p.To.Type = obj.TYPE_ADDR p.To.Etype = Simtype[TINT] off += Widthptr return off } func Datastring(s string, a *obj.Addr) { _, symdata := stringsym(s) a.Type = obj.TYPE_MEM a.Name = obj.NAME_EXTERN a.Sym = Linksym(symdata) a.Node = symdata.Def a.Offset = 0 a.Etype = Simtype[TINT] } func datagostring(sval string, a *obj.Addr) { symhdr, _ := stringsym(sval) a.Type = obj.TYPE_MEM a.Name = obj.NAME_EXTERN a.Sym = Linksym(symhdr) a.Node = symhdr.Def a.Offset = 0 a.Etype = TSTRING } func dgostringptr(s *Sym, off int, str string) int { if str == "" { return duintptr(s, off, 0) } return dgostrlitptr(s, off, &str) } func dgostrlitptr(s *Sym, off int, lit *string) int { if lit == nil { return duintptr(s, off, 0) } off = int(Rnd(int64(off), int64(Widthptr))) p := Thearch.Gins(obj.ADATA, nil, nil) p.From.Type = obj.TYPE_MEM p.From.Name = obj.NAME_EXTERN p.From.Sym = Linksym(s) p.From.Offset = int64(off) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(Widthptr) datagostring(*lit, &p.To) p.To.Type = obj.TYPE_ADDR p.To.Etype = Simtype[TINT] off += Widthptr return off } func dsname(s *Sym, off int, t string) int { p := Thearch.Gins(obj.ADATA, nil, nil) p.From.Type = obj.TYPE_MEM p.From.Name = obj.NAME_EXTERN p.From.Offset = int64(off) p.From.Sym = Linksym(s) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(len(t)) p.To.Type = obj.TYPE_SCONST p.To.Val = t return off + len(t) } func dsymptr(s *Sym, off int, x *Sym, xoff int) int { off = int(Rnd(int64(off), int64(Widthptr))) p := Thearch.Gins(obj.ADATA, nil, nil) p.From.Type = obj.TYPE_MEM p.From.Name = obj.NAME_EXTERN p.From.Sym = Linksym(s) p.From.Offset = int64(off) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(Widthptr) p.To.Type = obj.TYPE_ADDR p.To.Name = obj.NAME_EXTERN p.To.Sym = Linksym(x) p.To.Offset = int64(xoff) off += Widthptr return off } func gdata(nam *Node, nr *Node, wid int) { if nr.Op == OLITERAL { switch nr.Val().Ctype() { case CTCPLX: gdatacomplex(nam, nr.Val().U.(*Mpcplx)) return case CTSTR: gdatastring(nam, nr.Val().U.(string)) return } } p := Thearch.Gins(obj.ADATA, nam, nr) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(wid) } func gdatacomplex(nam *Node, cval *Mpcplx) { w := cplxsubtype(int(nam.Type.Etype)) w = int(Types[w].Width) p := Thearch.Gins(obj.ADATA, nam, nil) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(w) p.To.Type = obj.TYPE_FCONST p.To.Val = mpgetflt(&cval.Real) p = Thearch.Gins(obj.ADATA, nam, nil) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(w) p.From.Offset += int64(w) p.To.Type = obj.TYPE_FCONST p.To.Val = mpgetflt(&cval.Imag) } func gdatastring(nam *Node, sval string) { var nod1 Node p := Thearch.Gins(obj.ADATA, nam, nil) Datastring(sval, &p.To) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = Types[Tptr].Width p.To.Type = obj.TYPE_ADDR //print("%v\n", p); Nodconst(&nod1, Types[TINT], int64(len(sval))) p = Thearch.Gins(obj.ADATA, nam, &nod1) p.From3 = new(obj.Addr) p.From3.Type = obj.TYPE_CONST p.From3.Offset = int64(Widthint) p.From.Offset += int64(Widthptr) }
#ifndef <API key> #define <API key> #include <exception> #include <boost/assert.hpp> #include <boost/config.hpp> #include <boost/context/<API key>.hpp> #include <boost/coroutine2/detail/coroutine.hpp> #ifdef <API key> # include BOOST_ABI_PREFIX #endif namespace boost { namespace coroutines2 { typedef boost::context::<API key> <API key>; }} #ifdef <API key> # include BOOST_ABI_SUFFIX #endif #endif // <API key>
// file at the top-level directory of this distribution and at // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. // pretty-expanded FIXME #23616 use std::marker::PhantomData; struct Splits<'a, T:'a, P>(PhantomData<(&'a T, P)>); struct SplitsN<I>(PhantomData<I>); trait SliceExt2 { type Item; fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> where P: FnMut(&Self::Item) -> bool; fn splitn2<'a, P>(&'a self, n: u32, pred: P) -> SplitsN<Splits<'a, Self::Item, P>> where P: FnMut(&Self::Item) -> bool; } impl<T> SliceExt2 for [T] { type Item = T; fn split2<P>(&self, pred: P) -> Splits<T, P> where P: FnMut(&T) -> bool { loop {} } fn splitn2<P>(&self, n: u32, pred: P) -> SplitsN<Splits<T, P>> where P: FnMut(&T) -> bool { SliceExt2::split2(self, pred); loop {} } } fn main() { }
--TEST #2382: Data Providers throw error with uncloneable object --FILE <?php $_SERVER['argv'][1] = '--no-configuration'; $_SERVER['argv'][2] = 'Issue2382Test'; $_SERVER['argv'][3] = __DIR__ . '/2382/Issue2382Test.php'; require __DIR__ . '/../../bootstrap.php'; PHPUnit\TextUI\Command::main(); ?> --EXPECTF PHPUnit %s by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: %s, Memory: %s OK (1 test, 1 assertion)
#ifndef <API key> #define <API key> #include <pcl/features/feature.h> namespace pcl { /** \brief Normal-based feature signature estimation class. Obtains the feature vector by applying Discrete Cosine and * Fourier Transforms on an NxM array of real numbers representing the projection distances of the points in the input * cloud to a disc around the point of interest. * Please consult the following publication for more details: * Xinju Li and Igor Guskov * Multi-scale features for approximate alignment of point-based surfaces * Proceedings of the third Eurographics symposium on Geometry processing * July 2005, Vienna, Austria * * \note These features were meant to be used at keypoints detected by a detector using different smoothing radii * (e.g., <API key>) * \author Alexandru-Eugen Ichim */ template <typename PointT, typename PointNT, typename PointFeature> class <API key> : public FeatureFromNormals<PointT, PointNT, PointFeature> { public: using Feature<PointT, PointFeature>::input_; using Feature<PointT, PointFeature>::tree_; using Feature<PointT, PointFeature>::search_radius_; using PCLBase<PointT>::indices_; using FeatureFromNormals<PointT, PointNT, PointFeature>::normals_; typedef pcl::PointCloud<PointFeature> FeatureCloud; typedef typename boost::shared_ptr<<API key><PointT, PointNT, PointFeature> > Ptr; typedef typename boost::shared_ptr<const <API key><PointT, PointNT, PointFeature> > ConstPtr; /** \brief Empty constructor, initializes the internal parameters to the default values */ <API key> () : FeatureFromNormals<PointT, PointNT, PointFeature> (), scale_h_ (), N_ (36), M_ (8), N_prime_ (4), M_prime_ (3) { } /** \brief Setter method for the N parameter - the length of the columns used for the Discrete Fourier Transform. * \param[in] n the length of the columns used for the Discrete Fourier Transform. */ inline void setN (size_t n) { N_ = n; } /** \brief Returns the N parameter - the length of the columns used for the Discrete Fourier Transform. */ inline size_t getN () { return N_; } /** \brief Setter method for the M parameter - the length of the rows used for the Discrete Cosine Transform. * \param[in] m the length of the rows used for the Discrete Cosine Transform. */ inline void setM (size_t m) { M_ = m; } /** \brief Returns the M parameter - the length of the rows used for the Discrete Cosine Transform */ inline size_t getM () { return M_; } /** \brief Setter method for the N' parameter - the number of columns to be taken from the matrix of DFT and DCT * values that will be contained in the output feature vector * \note This value directly influences the dimensions of the type of output points (PointFeature) * \param[in] n_prime the number of columns from the matrix of DFT and DCT that will be contained in the output */ inline void setNPrime (size_t n_prime) { N_prime_ = n_prime; } /** \brief Returns the N' parameter - the number of rows to be taken from the matrix of DFT and DCT * values that will be contained in the output feature vector * \note This value directly influences the dimensions of the type of output points (PointFeature) */ inline size_t getNPrime () { return N_prime_; } /** \brief Setter method for the M' parameter - the number of rows to be taken from the matrix of DFT and DCT * values that will be contained in the output feature vector * \note This value directly influences the dimensions of the type of output points (PointFeature) * \param[in] m_prime the number of rows from the matrix of DFT and DCT that will be contained in the output */ inline void setMPrime (size_t m_prime) { M_prime_ = m_prime; } /** \brief Returns the M' parameter - the number of rows to be taken from the matrix of DFT and DCT * values that will be contained in the output feature vector * \note This value directly influences the dimensions of the type of output points (PointFeature) */ inline size_t getMPrime () { return M_prime_; } /** \brief Setter method for the scale parameter - used to determine the radius of the sampling disc around the * point of interest - linked to the smoothing scale of the input cloud */ inline void setScale (float scale) { scale_h_ = scale; } /** \brief Returns the scale parameter - used to determine the radius of the sampling disc around the * point of interest - linked to the smoothing scale of the input cloud */ inline float getScale () { return scale_h_; } protected: void computeFeature (FeatureCloud &output); private: float scale_h_; size_t N_, M_, N_prime_, M_prime_; }; } #ifdef PCL_NO_PRECOMPILE #include <pcl/features/impl/<API key>.hpp> #endif #endif /* <API key> */
<!DOCTYPE html> <title>position:relative top constraint should behave correctly for &lt;thead&gt; elements</title> <link rel="match" href="<API key>.html" /> <link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" /> <meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;thead&gt; elements" /> <style> table { border-collapse:collapse; } td { padding: 0; } td > div { height: 50px; width: 50px; } .group { display: inline-block; position: relative; width: 150px; height: 200px; } .indicator { position: absolute; background-color: red; left: 0; top: 100px; height: 50px; width: 50px; } .relative { position: relative; top: 100px; background-color: green; } </style> <div class="group"> <div> <div class="indicator"></div> <table> <thead class="relative"> <tr><td><div></div></td></tr> </thead> <tbody> <tr><td><div></div></td></tr> </tbody> </table> </div> </div> <div>You should see a green box above. No red should be visible.</div>
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Tabs - Sortable</title> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <script src="../../jquery-1.10.2.js"></script> <script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.sortable.js"></script> <script src="../../ui/jquery.ui.tabs.js"></script> <link rel="stylesheet" href="../demos.css"> <script> $(function() { var tabs = $( "#tabs" ).tabs(); tabs.find( ".ui-tabs-nav" ).sortable({ axis: "x", stop: function() { tabs.tabs( "refresh" ); } }); }); </script> </head> <body> <div id="tabs"> <ul> <li><a href="#tabs-1">Nunc tincidunt</a></li> <li><a href="#tabs-2">Proin dolor</a></li> <li><a href="#tabs-3">Aenean lacinia</a></li> </ul> <div id="tabs-1"> <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p> </div> <div id="tabs-2"> <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p> </div> <div id="tabs-3"> <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p> <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p> </div> </div> <div class="demo-description"> <p>Drag the tabs above to re-order them.</p> <p>Making tabs sortable is as simple as calling <code>.sortable()</code> on the <code>.ui-tabs-nav</code> element.</p> </div> </body> </html>
#ifndef __ASM_PROM_H #define __ASM_PROM_H #ifdef CONFIG_OF #include <asm/bootinfo.h> extern int <API key>(unsigned long node, const char *uname, int depth, void *data); extern int reserve_mem_mach(unsigned long addr, unsigned long size); extern void free_mem_mach(unsigned long addr, unsigned long size); extern void device_tree_init(void); #else /* CONFIG_OF */ static inline void device_tree_init(void) { } #endif /* CONFIG_OF */ #endif /* __ASM_PROM_H */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>static</title> <style type="text/css" media="screen"> body { margin: 1px; padding: 5px; } div.static { position: static; top: 0; left: 0; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: hidden; } #static-2 { top: 20px; left: 20px; } #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; } </style> <script src="../../../src/core.js"></script> <script src="../../../src/deferred.js"></script> <script src="../../../src/support.js"></script> <script src="../../../src/sizzle/sizzle.js"></script> <script src="../../../src/sizzle-jquery.js"></script> <script src="../../../src/traversing.js"></script> <script src="../../../src/data.js"></script> <script src="../../../src/event.js"></script> <script src="../../../src/css.js"></script> <script src="../../../src/offset.js"></script> <script type="text/javascript" charset="utf-8"> jQuery(function($) { $('.static').click(function() { $('#marker').css( $(this).offset() ); var pos = $(this).position(); $(this).css({ position: 'absolute', top: pos.top, left: pos.left }); return false; }); }); </script> </head> <body> <div id="static-1" class="static"><div id="static-1-1" class="static"><div id="static-1-1-1" class="static"></div></div></div> <div id="static-2" class="static"></div> <div id="marker"></div> <p class="instructions">Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.</p> </body> </html>
package com.sun.corba.se.spi.copyobject ; public class <API key> extends Exception { public <API key>() { super() ; } public <API key>( String msg ) { super( msg ) ; } public <API key>( String msg, Throwable t ) { super( msg, t ) ; } }
//>>built define("dojox/editor/plugins/nls/nb/PasteFromWord",({"pasteFromWord":"Lim inn fra Word","instructions":"Lim inn innhold fra Word til tekstboksen nedenfor. Når du er fornøyd med innholdet du skal sette inn, trykker du på innlimingsknappen. Hvis du vil avbryte innsettingen av teksten, trykker du på avbruddsknappen."}));
# <API key>: GPL-2.0-only ifneq '$(<API key>)' '""' BUILTIN_DTB := $(patsubst "%",%,$(<API key>)).dtb.o else BUILTIN_DTB := endif obj-$(CONFIG_OF) += $(BUILTIN_DTB) clean-files := *.dtb *.dtb.S
#ifndef __CAPIUTIL_H__ #define __CAPIUTIL_H__ #include <asm/types.h> #define CAPIMSG_BASELEN 8 #define CAPIMSG_U8(m, off) (m[off]) #define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8)) #define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24)) #define CAPIMSG_LEN(m) CAPIMSG_U16(m,0) #define CAPIMSG_APPID(m) CAPIMSG_U16(m,2) #define CAPIMSG_COMMAND(m) CAPIMSG_U8(m,4) #define CAPIMSG_SUBCOMMAND(m) CAPIMSG_U8(m,5) #define CAPIMSG_CMD(m) (((m[4])<<8)|(m[5])) #define CAPIMSG_MSGID(m) CAPIMSG_U16(m,6) #define CAPIMSG_CONTROLLER(m) (m[8] & 0x7f) #define CAPIMSG_CONTROL(m) CAPIMSG_U32(m, 8) #define CAPIMSG_NCCI(m) CAPIMSG_CONTROL(m) #define CAPIMSG_DATALEN(m) CAPIMSG_U16(m,16) /* DATA_B3_REQ */ static inline void capimsg_setu8(void *m, int off, __u8 val) { ((__u8 *)m)[off] = val; } static inline void capimsg_setu16(void *m, int off, __u16 val) { ((__u8 *)m)[off] = val & 0xff; ((__u8 *)m)[off+1] = (val >> 8) & 0xff; } static inline void capimsg_setu32(void *m, int off, __u32 val) { ((__u8 *)m)[off] = val & 0xff; ((__u8 *)m)[off+1] = (val >> 8) & 0xff; ((__u8 *)m)[off+2] = (val >> 16) & 0xff; ((__u8 *)m)[off+3] = (val >> 24) & 0xff; } #define CAPIMSG_SETLEN(m, len) capimsg_setu16(m, 0, len) #define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid) #define CAPIMSG_SETCOMMAND(m,cmd) capimsg_setu8(m, 4, cmd) #define <API key>(m, cmd) capimsg_setu8(m, 5, cmd) #define CAPIMSG_SETMSGID(m, msgid) capimsg_setu16(m, 6, msgid) #define CAPIMSG_SETCONTROL(m, contr) capimsg_setu32(m, 8, contr) #define CAPIMSG_SETDATALEN(m, len) capimsg_setu16(m, 16, len) typedef __u8 *_cstruct; typedef enum { CAPI_COMPOSE, CAPI_DEFAULT } _cmstruct; /* The _cmsg structure contains all possible CAPI 2.0 parameter. All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE assembles the parameter and builds CAPI2.0 conform messages. CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the parameter in the _cmsg structure */ typedef struct { /* Header */ __u16 ApplId; __u8 Command; __u8 Subcommand; __u16 Messagenumber; /* Parameter */ union { __u32 adrController; __u32 adrPLCI; __u32 adrNCCI; } adr; _cmstruct AdditionalInfo; _cstruct B1configuration; __u16 B1protocol; _cstruct B2configuration; __u16 B2protocol; _cstruct B3configuration; __u16 B3protocol; _cstruct BC; _cstruct BChannelinformation; _cmstruct BProtocol; _cstruct CalledPartyNumber; _cstruct <API key>; _cstruct CallingPartyNumber; _cstruct <API key>; __u32 CIPmask; __u32 CIPmask2; __u16 CIPValue; __u32 Class; _cstruct ConnectedNumber; _cstruct ConnectedSubaddress; __u32 Data; __u16 DataHandle; __u16 DataLength; _cstruct <API key>; _cstruct Facilitydataarray; _cstruct <API key>; _cstruct <API key>; __u16 FacilitySelector; __u16 Flags; __u32 Function; _cstruct HLC; __u16 Info; _cstruct InfoElement; __u32 InfoMask; __u16 InfoNumber; _cstruct Keypadfacility; _cstruct LLC; _cstruct ManuData; __u32 ManuID; _cstruct NCPI; __u16 Reason; __u16 Reason_B3; __u16 Reject; _cstruct Useruserdata; /* intern */ unsigned l, p; unsigned char *par; __u8 *m; /* buffer to construct message */ __u8 buf[180]; } _cmsg; /* * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0 * conform message */ unsigned capi_cmsg2message(_cmsg * cmsg, __u8 * msg); /* * capi_message2cmsg disassembles a CAPI message an writes the parameter * into _cmsg for easy access */ unsigned capi_message2cmsg(_cmsg * cmsg, __u8 * msg); /* * capi_cmsg_header() fills the _cmsg structure with default values, so only * parameter with non default values must be changed before sending the * message. */ unsigned capi_cmsg_header(_cmsg * cmsg, __u16 _ApplId, __u8 _Command, __u8 _Subcommand, __u16 _Messagenumber, __u32 _Controller); /* * capi_info2str generated a readable string for Capi2.0 reasons. */ char *capi_info2str(__u16 reason); /* * Debugging / Tracing functions */ char *capi_cmd2str(__u8 cmd, __u8 subcmd); char *capi_cmsg2str(_cmsg * cmsg); char *capi_message2str(__u8 * msg); static inline void capi_cmsg_answer(_cmsg * cmsg) { cmsg->Subcommand |= 0x01; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct NCPI) { capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr); cmsg->NCPI = NCPI; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 FacilitySelector, _cstruct <API key>) { capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr); cmsg->FacilitySelector = FacilitySelector; cmsg-><API key> = <API key>; } static inline void capi_fill_INFO_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct CalledPartyNumber, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray) { capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr); cmsg->CalledPartyNumber = CalledPartyNumber; cmsg->BChannelinformation = BChannelinformation; cmsg->Keypadfacility = Keypadfacility; cmsg->Useruserdata = Useruserdata; cmsg->Facilitydataarray = Facilitydataarray; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u32 InfoMask, __u32 CIPmask, __u32 CIPmask2, _cstruct CallingPartyNumber, _cstruct <API key>) { capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr); cmsg->InfoMask = InfoMask; cmsg->CIPmask = CIPmask; cmsg->CIPmask2 = CIPmask2; cmsg->CallingPartyNumber = CallingPartyNumber; cmsg-><API key> = <API key>; } static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray) { capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr); cmsg->BChannelinformation = BChannelinformation; cmsg->Keypadfacility = Keypadfacility; cmsg->Useruserdata = Useruserdata; cmsg->Facilitydataarray = Facilitydataarray; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 CIPValue, _cstruct CalledPartyNumber, _cstruct CallingPartyNumber, _cstruct <API key>, _cstruct <API key>, __u16 B1protocol, __u16 B2protocol, __u16 B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration, _cstruct BC, _cstruct LLC, _cstruct HLC, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray) { capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr); cmsg->CIPValue = CIPValue; cmsg->CalledPartyNumber = CalledPartyNumber; cmsg->CallingPartyNumber = CallingPartyNumber; cmsg-><API key> = <API key>; cmsg-><API key> = <API key>; cmsg->B1protocol = B1protocol; cmsg->B2protocol = B2protocol; cmsg->B3protocol = B3protocol; cmsg->B1configuration = B1configuration; cmsg->B2configuration = B2configuration; cmsg->B3configuration = B3configuration; cmsg->BC = BC; cmsg->LLC = LLC; cmsg->HLC = HLC; cmsg->BChannelinformation = BChannelinformation; cmsg->Keypadfacility = Keypadfacility; cmsg->Useruserdata = Useruserdata; cmsg->Facilitydataarray = Facilitydataarray; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u32 Data, __u16 DataLength, __u16 DataHandle, __u16 Flags) { capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr); cmsg->Data = Data; cmsg->DataLength = DataLength; cmsg->DataHandle = DataHandle; cmsg->Flags = Flags; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray) { capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr); cmsg->BChannelinformation = BChannelinformation; cmsg->Keypadfacility = Keypadfacility; cmsg->Useruserdata = Useruserdata; cmsg->Facilitydataarray = Facilitydataarray; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct NCPI) { capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr); cmsg->NCPI = NCPI; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u32 ManuID, __u32 Class, __u32 Function, _cstruct ManuData) { capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr); cmsg->ManuID = ManuID; cmsg->Class = Class; cmsg->Function = Function; cmsg->ManuData = ManuData; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, _cstruct NCPI) { capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr); cmsg->NCPI = NCPI; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 B1protocol, __u16 B2protocol, __u16 B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) { capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr); cmsg->B1protocol = B1protocol; cmsg->B2protocol = B2protocol; cmsg->B3protocol = B3protocol; cmsg->B1configuration = B1configuration; cmsg->B2configuration = B2configuration; cmsg->B3configuration = B3configuration; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 Reject, __u16 B1protocol, __u16 B2protocol, __u16 B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration, _cstruct ConnectedNumber, _cstruct ConnectedSubaddress, _cstruct LLC, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray) { capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr); cmsg->Reject = Reject; cmsg->B1protocol = B1protocol; cmsg->B2protocol = B2protocol; cmsg->B3protocol = B3protocol; cmsg->B1configuration = B1configuration; cmsg->B2configuration = B2configuration; cmsg->B3configuration = B3configuration; cmsg->ConnectedNumber = ConnectedNumber; cmsg->ConnectedSubaddress = ConnectedSubaddress; cmsg->LLC = LLC; cmsg->BChannelinformation = BChannelinformation; cmsg->Keypadfacility = Keypadfacility; cmsg->Useruserdata = Useruserdata; cmsg->Facilitydataarray = Facilitydataarray; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 Reject, _cstruct NCPI) { capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr); cmsg->Reject = Reject; cmsg->NCPI = NCPI; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 DataHandle) { capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr); cmsg->DataHandle = DataHandle; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u16 FacilitySelector) { capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr); cmsg->FacilitySelector = FacilitySelector; } static inline void capi_fill_INFO_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr); } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr, __u32 ManuID, __u32 Class, __u32 Function, _cstruct ManuData) { capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr); cmsg->ManuID = ManuID; cmsg->Class = Class; cmsg->Function = Function; cmsg->ManuData = ManuData; } static inline void <API key>(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, __u32 adr) { capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr); } #endif /* __CAPIUTIL_H__ */
// <API key>: GPL-2.0 #include <linux/device.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/slab.h> #include "musb_core.h" #define MUSB_HSDMA_BASE 0x200 #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) #define MUSB_HSDMA_CONTROL 0x4 #define MUSB_HSDMA_ADDRESS 0x8 #define MUSB_HSDMA_COUNT 0xc #define <API key>(_bchannel, _offset) \ (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) #define <API key>(mbase, bchannel) \ musb_readl(mbase, \ <API key>(bchannel, MUSB_HSDMA_ADDRESS)) #define <API key>(mbase, bchannel, addr) \ musb_writel(mbase, \ <API key>(bchannel, MUSB_HSDMA_ADDRESS), \ addr) #define <API key>(mbase, bchannel) \ musb_readl(mbase, \ <API key>(bchannel, MUSB_HSDMA_COUNT)) #define <API key>(mbase, bchannel, len) \ musb_writel(mbase, \ <API key>(bchannel, MUSB_HSDMA_COUNT), \ len) /* control register (16-bit): */ #define <API key> 0 #define <API key> 1 #define <API key> 2 #define <API key> 3 #define <API key> 4 #define <API key> 8 #define <API key> 9 #define <API key> (3 << <API key>) #define <API key> 0 #define <API key> 1 #define <API key> 2 #define <API key> 3 #define MUSB_HSDMA_CHANNELS 8 struct musb_dma_controller; struct musb_dma_channel { struct dma_channel channel; struct musb_dma_controller *controller; u32 start_addr; u32 len; u16 max_packet_sz; u8 idx; u8 epnum; u8 transmit; }; struct musb_dma_controller { struct dma_controller controller; struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS]; void *private_data; void __iomem *base; u8 channel_count; u8 used_channels; int irq; }; static void dma_channel_release(struct dma_channel *channel); static void dma_controller_stop(struct musb_dma_controller *controller) { struct musb *musb = controller->private_data; struct dma_channel *channel; u8 bit; if (controller->used_channels != 0) { dev_err(musb->controller, "Stopping DMA controller while channel active\n"); for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { if (controller->used_channels & (1 << bit)) { channel = &controller->channel[bit].channel; dma_channel_release(channel); if (!controller->used_channels) break; } } } } static struct dma_channel *<API key>(struct dma_controller *c, struct musb_hw_ep *hw_ep, u8 transmit) { struct musb_dma_controller *controller = container_of(c, struct musb_dma_controller, controller); struct musb_dma_channel *musb_channel = NULL; struct dma_channel *channel = NULL; u8 bit; for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { if (!(controller->used_channels & (1 << bit))) { controller->used_channels |= (1 << bit); musb_channel = &(controller->channel[bit]); musb_channel->controller = controller; musb_channel->idx = bit; musb_channel->epnum = hw_ep->epnum; musb_channel->transmit = transmit; channel = &(musb_channel->channel); channel->private_data = musb_channel; channel->status = <API key>; channel->max_len = 0x100000; /* Tx => mode 1; Rx => mode 0 */ channel->desired_mode = transmit; channel->actual_len = 0; break; } } return channel; } static void dma_channel_release(struct dma_channel *channel) { struct musb_dma_channel *musb_channel = channel->private_data; channel->actual_len = 0; musb_channel->start_addr = 0; musb_channel->len = 0; musb_channel->controller->used_channels &= ~(1 << musb_channel->idx); channel->status = <API key>; } static void configure_channel(struct dma_channel *channel, u16 packet_sz, u8 mode, dma_addr_t dma_addr, u32 len) { struct musb_dma_channel *musb_channel = channel->private_data; struct musb_dma_controller *controller = musb_channel->controller; struct musb *musb = controller->private_data; void __iomem *mbase = controller->base; u8 bchannel = musb_channel->idx; u16 csr = 0; musb_dbg(musb, "%p, pkt_sz %d, addr %pad, len %d, mode %d", channel, packet_sz, &dma_addr, len, mode); if (mode) { csr |= 1 << <API key>; BUG_ON(len < packet_sz); } csr |= <API key> << <API key>; csr |= (musb_channel->epnum << <API key>) | (1 << <API key>) | (1 << <API key>) | (musb_channel->transmit ? (1 << <API key>) : 0); /* address/count */ <API key>(mbase, bchannel, dma_addr); <API key>(mbase, bchannel, len); /* control (this should start things) */ musb_writew(mbase, <API key>(bchannel, MUSB_HSDMA_CONTROL), csr); } static int dma_channel_program(struct dma_channel *channel, u16 packet_sz, u8 mode, dma_addr_t dma_addr, u32 len) { struct musb_dma_channel *musb_channel = channel->private_data; struct musb_dma_controller *controller = musb_channel->controller; struct musb *musb = controller->private_data; musb_dbg(musb, "ep%d-%s pkt_sz %d, dma_addr %pad length %d, mode %d", musb_channel->epnum, musb_channel->transmit ? "Tx" : "Rx", packet_sz, &dma_addr, len, mode); BUG_ON(channel->status == <API key> || channel->status == <API key>); /* * The DMA engine in RTL1.8 and above cannot handle * DMA addresses that are not aligned to a 4 byte boundary. * It ends up masking the last two bits of the address * programmed in DMA_ADDR. * * Fail such DMA transfers, so that the backup PIO mode * can carry out the transfer */ if ((musb->hwvers >= MUSB_HWVERS_1800) && (dma_addr % 4)) return false; channel->actual_len = 0; musb_channel->start_addr = dma_addr; musb_channel->len = len; musb_channel->max_packet_sz = packet_sz; channel->status = <API key>; configure_channel(channel, packet_sz, mode, dma_addr, len); return true; } static int dma_channel_abort(struct dma_channel *channel) { struct musb_dma_channel *musb_channel = channel->private_data; void __iomem *mbase = musb_channel->controller->base; struct musb *musb = musb_channel->controller->private_data; u8 bchannel = musb_channel->idx; int offset; u16 csr; if (channel->status == <API key>) { if (musb_channel->transmit) { offset = musb->io.ep_offset(musb_channel->epnum, MUSB_TXCSR); /* * The programming guide says that we must clear * the DMAENAB bit before the DMAMODE bit... */ csr = musb_readw(mbase, offset); csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB); musb_writew(mbase, offset, csr); csr &= ~MUSB_TXCSR_DMAMODE; musb_writew(mbase, offset, csr); } else { offset = musb->io.ep_offset(musb_channel->epnum, MUSB_RXCSR); csr = musb_readw(mbase, offset); csr &= ~(<API key> | MUSB_RXCSR_DMAENAB | MUSB_RXCSR_DMAMODE); musb_writew(mbase, offset, csr); } musb_writew(mbase, <API key>(bchannel, MUSB_HSDMA_CONTROL), 0); <API key>(mbase, bchannel, 0); <API key>(mbase, bchannel, 0); channel->status = <API key>; } return 0; } static irqreturn_t dma_controller_irq(int irq, void *private_data) { struct musb_dma_controller *controller = private_data; struct musb *musb = controller->private_data; struct musb_dma_channel *musb_channel; struct dma_channel *channel; void __iomem *mbase = controller->base; irqreturn_t retval = IRQ_NONE; unsigned long flags; u8 bchannel; u8 int_hsdma; u32 addr, count; u16 csr; spin_lock_irqsave(&musb->lock, flags); int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); if (!int_hsdma) { musb_dbg(musb, "spurious DMA irq"); for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { musb_channel = (struct musb_dma_channel *) &(controller->channel[bchannel]); channel = &musb_channel->channel; if (channel->status == <API key>) { count = <API key>(mbase, bchannel); if (count == 0) int_hsdma |= (1 << bchannel); } } musb_dbg(musb, "int_hsdma = 0x%x", int_hsdma); if (!int_hsdma) goto done; } for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { if (int_hsdma & (1 << bchannel)) { musb_channel = (struct musb_dma_channel *) &(controller->channel[bchannel]); channel = &musb_channel->channel; csr = musb_readw(mbase, <API key>(bchannel, MUSB_HSDMA_CONTROL)); if (csr & (1 << <API key>)) { musb_channel->channel.status = <API key>; } else { u8 devctl; addr = <API key>(mbase, bchannel); channel->actual_len = addr - musb_channel->start_addr; musb_dbg(musb, "ch %p, 0x%x -> 0x%x (%zu / %d) %s", channel, musb_channel->start_addr, addr, channel->actual_len, musb_channel->len, (channel->actual_len < musb_channel->len) ? "=> reconfig 0" : "=> complete"); devctl = musb_readb(mbase, MUSB_DEVCTL); channel->status = <API key>; /* completed */ if ((devctl & MUSB_DEVCTL_HM) && (musb_channel->transmit) && ((channel->desired_mode == 0) || (channel->actual_len & (musb_channel->max_packet_sz - 1))) ) { u8 epnum = musb_channel->epnum; int offset = musb->io.ep_offset(epnum, MUSB_TXCSR); u16 txcsr; /* * The programming guide says that we * must clear DMAENAB before DMAMODE. */ musb_ep_select(mbase, epnum); txcsr = musb_readw(mbase, offset); txcsr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_AUTOSET); musb_writew(mbase, offset, txcsr); /* Send out the packet */ txcsr &= ~MUSB_TXCSR_DMAMODE; txcsr |= MUSB_TXCSR_TXPKTRDY; musb_writew(mbase, offset, txcsr); } musb_dma_completion(musb, musb_channel->epnum, musb_channel->transmit); } } } retval = IRQ_HANDLED; done: <API key>(&musb->lock, flags); return retval; } void <API key>(struct dma_controller *c) { struct musb_dma_controller *controller = container_of(c, struct musb_dma_controller, controller); dma_controller_stop(controller); if (controller->irq) free_irq(controller->irq, c); kfree(controller); } EXPORT_SYMBOL_GPL(<API key>); struct dma_controller *<API key>(struct musb *musb, void __iomem *base) { struct musb_dma_controller *controller; struct device *dev = musb->controller; struct platform_device *pdev = to_platform_device(dev); int irq = <API key>(pdev, "dma"); if (irq <= 0) { dev_err(dev, "No DMA interrupt line!\n"); return NULL; } controller = kzalloc(sizeof(*controller), GFP_KERNEL); if (!controller) return NULL; controller->channel_count = MUSB_HSDMA_CHANNELS; controller->private_data = musb; controller->base = base; controller->controller.channel_alloc = <API key>; controller->controller.channel_release = dma_channel_release; controller->controller.channel_program = dma_channel_program; controller->controller.channel_abort = dma_channel_abort; if (request_irq(irq, dma_controller_irq, 0, dev_name(musb->controller), &controller->controller)) { dev_err(dev, "request_irq %d failed!\n", irq); <API key>(&controller->controller); return NULL; } controller->irq = irq; return &controller->controller; } EXPORT_SYMBOL_GPL(<API key>);
#ifndef <API key> #define <API key> #include "libctiny.h" extern char * _ppszArgv[]; int __cdecl <API key>(); #endif // <API key>
#ifndef LINUX_LOCKD_BIND_H #define LINUX_LOCKD_BIND_H #include <linux/lockd/nlm.h> /* need xdr-encoded error codes too, so... */ #include <linux/lockd/xdr.h> #ifdef CONFIG_LOCKD_V4 #include <linux/lockd/xdr4.h> #endif /* Dummy declarations */ struct svc_rqst; /* * This is the set of functions for lockd->nfsd communication */ struct nlmsvc_binding { __be32 (*fopen)(struct svc_rqst *, struct nfs_fh *, struct file **); void (*fclose)(struct file *); }; extern const struct nlmsvc_binding *nlmsvc_ops; /* * Similar to nfs_client_initdata, but without the NFS-specific * rpc_ops field. */ struct nlmclnt_initdata { const char *hostname; const struct sockaddr *address; size_t addrlen; unsigned short protocol; u32 nfs_version; int noresvport; struct net *net; }; /* * Functions exported by the lockd module */ extern struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init); extern void nlmclnt_done(struct nlm_host *host); extern int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl); extern int lockd_up(struct net *net); extern void lockd_down(struct net *net); #endif /* LINUX_LOCKD_BIND_H */
<div :my-var="model"></div><span v-for="item in items" :key="item.id" :value="item.name"></span><span v-for="item in items" :key="item.id" :value="item.name"></span><a :link="goHere" value="static" :my-value="dynamic" @click="onClick()" :another="more">Click Me!</a>
#ifndef <API key> #define <API key> #pragma once #include <vector> #include "base/basictypes.h" class AutomationProvider; // Stores a list of all AutomationProvider objects. class <API key> { public: ~<API key>(); typedef std::vector<AutomationProvider*> list_type; typedef list_type::iterator iterator; typedef list_type::const_iterator const_iterator; // Adds and removes automation providers from the global list. bool AddProvider(AutomationProvider* provider); bool RemoveProvider(AutomationProvider* provider); const_iterator begin() { return <API key>.begin(); } const_iterator end() { return <API key>.end(); } size_t size() { return <API key>.size(); } static <API key>* GetInstance(); private: <API key>(); void <API key>(); list_type <API key>; static <API key>* instance_; <API key>(<API key>); }; #endif // <API key>
#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/of.h> #include <linux/regulator/consumer.h> #include <linux/backlight.h> #include <video/of_display_timing.h> #include "../dss/omapdss.h" struct panel_drv_data { struct omap_dss_device dssdev; struct omap_dss_device *in; struct videomode vm; struct backlight_device *backlight; struct gpio_desc *enable_gpio; struct regulator *vcc_supply; }; #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev) static int panel_dpi_connect(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in; int r; if (<API key>(dssdev)) return 0; in = <API key>(dssdev->dev->of_node); if (IS_ERR(in)) { dev_err(dssdev->dev, "failed to find video source\n"); return PTR_ERR(in); } r = in->ops.dpi->connect(in, dssdev); if (r) { omap_dss_put_device(in); return r; } ddata->in = in; return 0; } static void <API key>(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in = ddata->in; if (!<API key>(dssdev)) return; in->ops.dpi->disconnect(in, dssdev); omap_dss_put_device(in); ddata->in = NULL; } static int panel_dpi_enable(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in = ddata->in; int r; if (!<API key>(dssdev)) return -ENODEV; if (<API key>(dssdev)) return 0; in->ops.dpi->set_timings(in, &ddata->vm); r = in->ops.dpi->enable(in); if (r) return r; r = regulator_enable(ddata->vcc_supply); if (r) { in->ops.dpi->disable(in); return r; } <API key>(ddata->enable_gpio, 1); backlight_enable(ddata->backlight); dssdev->state = <API key>; return 0; } static void panel_dpi_disable(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in = ddata->in; if (!<API key>(dssdev)) return; backlight_disable(ddata->backlight); <API key>(ddata->enable_gpio, 0); regulator_disable(ddata->vcc_supply); in->ops.dpi->disable(in); dssdev->state = <API key>; } static void <API key>(struct omap_dss_device *dssdev, struct videomode *vm) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in = ddata->in; ddata->vm = *vm; dssdev->panel.vm = *vm; in->ops.dpi->set_timings(in, vm); } static void <API key>(struct omap_dss_device *dssdev, struct videomode *vm) { struct panel_drv_data *ddata = to_panel_data(dssdev); *vm = ddata->vm; } static int <API key>(struct omap_dss_device *dssdev, struct videomode *vm) { struct panel_drv_data *ddata = to_panel_data(dssdev); struct omap_dss_device *in = ddata->in; return in->ops.dpi->check_timings(in, vm); } static struct omap_dss_driver panel_dpi_ops = { .connect = panel_dpi_connect, .disconnect = <API key>, .enable = panel_dpi_enable, .disable = panel_dpi_disable, .set_timings = <API key>, .get_timings = <API key>, .check_timings = <API key>, }; static int panel_dpi_probe_of(struct platform_device *pdev) { struct panel_drv_data *ddata = <API key>(pdev); struct device_node *node = pdev->dev.of_node; int r; struct display_timing timing; struct gpio_desc *gpio; gpio = <API key>(&pdev->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(gpio)) return PTR_ERR(gpio); ddata->enable_gpio = gpio; /* * Many different panels are supported by this driver and there are * probably very different needs for their reset pins in regards to * timing and order relative to the enable gpio. So for now it's just * ensured that the reset line isn't active. */ gpio = <API key>(&pdev->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(gpio)) return PTR_ERR(gpio); ddata->vcc_supply = devm_regulator_get(&pdev->dev, "vcc"); if (IS_ERR(ddata->vcc_supply)) return PTR_ERR(ddata->vcc_supply); ddata->backlight = <API key>(&pdev->dev); if (IS_ERR(ddata->backlight)) return PTR_ERR(ddata->backlight); r = <API key>(node, "panel-timing", &timing); if (r) { dev_err(&pdev->dev, "failed to get video timing\n"); return r; } <API key>(&timing, &ddata->vm); return 0; } static int panel_dpi_probe(struct platform_device *pdev) { struct panel_drv_data *ddata; struct omap_dss_device *dssdev; int r; ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); if (ddata == NULL) return -ENOMEM; <API key>(pdev, ddata); r = panel_dpi_probe_of(pdev); if (r) return r; dssdev = &ddata->dssdev; dssdev->dev = &pdev->dev; dssdev->driver = &panel_dpi_ops; dssdev->type = <API key>; dssdev->owner = THIS_MODULE; dssdev->panel.vm = ddata->vm; r = <API key>(dssdev); if (r) { dev_err(&pdev->dev, "Failed to register panel\n"); return r; } return 0; } static int __exit panel_dpi_remove(struct platform_device *pdev) { struct panel_drv_data *ddata = <API key>(pdev); struct omap_dss_device *dssdev = &ddata->dssdev; <API key>(dssdev); panel_dpi_disable(dssdev); <API key>(dssdev); return 0; } static const struct of_device_id panel_dpi_of_match[] = { { .compatible = "omapdss,panel-dpi", }, {}, }; MODULE_DEVICE_TABLE(of, panel_dpi_of_match); static struct platform_driver panel_dpi_driver = { .probe = panel_dpi_probe, .remove = __exit_p(panel_dpi_remove), .driver = { .name = "panel-dpi", .of_match_table = panel_dpi_of_match, .suppress_bind_attrs = true, }, }; <API key>(panel_dpi_driver); MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>"); MODULE_DESCRIPTION("Generic MIPI DPI Panel Driver"); MODULE_LICENSE("GPL");
/* { <API key> vect_float } */ #include <stdarg.h> #include "tree-vect.h" #define N 32 int int_arr[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; float float_arr[N]; char char_arr[N]; __attribute__ ((noinline)) int main1 () { int i; for (i = 0; i < N; i++){ float_arr[i] = (float) int_arr[i]; char_arr[i] = 0; } /* check results: */ for (i = 0; i < N; i++) { if (float_arr[i] != (float) int_arr[i]) abort (); if (char_arr[i] != 0) abort (); } return 0; } int main (void) { check_vect (); return main1 (); } /* { dg-final { <API key> "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } } */
#include <linux/kthread.h> #include <linux/socket.h> #include "usbip_common.h" #include "stub.h" static void <API key>(struct stub_priv *priv) { struct urb *urb = priv->urb; kfree(urb->setup_packet); urb->setup_packet = NULL; kfree(urb->transfer_buffer); urb->transfer_buffer = NULL; list_del(&priv->list); kmem_cache_free(stub_priv_cache, priv); usb_free_urb(urb); } /* be in spin_lock_irqsave(&sdev->priv_lock, flags) */ void <API key>(struct stub_device *sdev, __u32 seqnum, __u32 status) { struct stub_unlink *unlink; unlink = kzalloc(sizeof(struct stub_unlink), GFP_ATOMIC); if (!unlink) { usbip_event_add(&sdev->ud, <API key>); return; } unlink->seqnum = seqnum; unlink->status = status; list_add_tail(&unlink->list, &sdev->unlink_tx); } /** * stub_complete - completion handler of a usbip urb * @urb: pointer to the urb completed * * When a urb has completed, the USB core driver calls this function mostly in * the interrupt context. To return the result of a urb, the completed urb is * linked to the pending list of returning. * */ void stub_complete(struct urb *urb) { struct stub_priv *priv = (struct stub_priv *) urb->context; struct stub_device *sdev = priv->sdev; unsigned long flags; usbip_dbg_stub_tx("complete! status %d\n", urb->status); switch (urb->status) { case 0: break; case -ENOENT: dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() because of cleaning up a virtual connection\n"); return; case -ECONNRESET: dev_info(&urb->dev->dev, "unlinked by a call to usb_unlink_urb()\n"); break; case -EPIPE: dev_info(&urb->dev->dev, "endpoint %d is stalled\n", usb_pipeendpoint(urb->pipe)); break; case -ESHUTDOWN: dev_info(&urb->dev->dev, "device removed?\n"); break; default: dev_info(&urb->dev->dev, "urb completion with non-zero status %d\n", urb->status); break; } /* link a urb to the queue of tx. */ spin_lock_irqsave(&sdev->priv_lock, flags); if (sdev->ud.tcp_socket == NULL) { usbip_dbg_stub_tx("ignore urb for closed connection %p", urb); /* It will be freed in <API key>(). */ } else if (priv->unlinking) { <API key>(sdev, priv->seqnum, urb->status); <API key>(priv); } else { list_move_tail(&priv->list, &sdev->priv_tx); } <API key>(&sdev->priv_lock, flags); /* wake up tx_thread */ wake_up(&sdev->tx_waitq); } static inline void setup_base_pdu(struct usbip_header_basic *base, __u32 command, __u32 seqnum) { base->command = command; base->seqnum = seqnum; base->devid = 0; base->ep = 0; base->direction = 0; } static void <API key>(struct usbip_header *rpdu, struct urb *urb) { struct stub_priv *priv = (struct stub_priv *) urb->context; setup_base_pdu(&rpdu->base, USBIP_RET_SUBMIT, priv->seqnum); usbip_pack_pdu(rpdu, urb, USBIP_RET_SUBMIT, 1); } static void <API key>(struct usbip_header *rpdu, struct stub_unlink *unlink) { setup_base_pdu(&rpdu->base, USBIP_RET_UNLINK, unlink->seqnum); rpdu->u.ret_unlink.status = unlink->status; } static struct stub_priv *<API key>(struct stub_device *sdev) { unsigned long flags; struct stub_priv *priv, *tmp; spin_lock_irqsave(&sdev->priv_lock, flags); <API key>(priv, tmp, &sdev->priv_tx, list) { list_move_tail(&priv->list, &sdev->priv_free); <API key>(&sdev->priv_lock, flags); return priv; } <API key>(&sdev->priv_lock, flags); return NULL; } static int <API key>(struct stub_device *sdev) { unsigned long flags; struct stub_priv *priv, *tmp; struct msghdr msg; size_t txsize; size_t total_size = 0; while ((priv = <API key>(sdev)) != NULL) { int ret; struct urb *urb = priv->urb; struct usbip_header pdu_header; struct <API key> *iso_buffer = NULL; struct kvec *iov = NULL; int iovnum = 0; txsize = 0; memset(&pdu_header, 0, sizeof(pdu_header)); memset(&msg, 0, sizeof(msg)); if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) iovnum = 2 + urb->number_of_packets; else iovnum = 2; iov = kcalloc(iovnum, sizeof(struct kvec), GFP_KERNEL); if (!iov) { usbip_event_add(&sdev->ud, <API key>); return -1; } iovnum = 0; /* 1. setup usbip_header */ <API key>(&pdu_header, urb); usbip_dbg_stub_tx("setup txdata seqnum: %d urb: %p\n", pdu_header.base.seqnum, urb); <API key>(&pdu_header, 1); iov[iovnum].iov_base = &pdu_header; iov[iovnum].iov_len = sizeof(pdu_header); iovnum++; txsize += sizeof(pdu_header); /* 2. setup transfer buffer */ if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS && urb->actual_length > 0) { iov[iovnum].iov_base = urb->transfer_buffer; iov[iovnum].iov_len = urb->actual_length; iovnum++; txsize += urb->actual_length; } else if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { /* * For isochronous packets: actual length is the sum of * the actual length of the individual, packets, but as * the packet offsets are not changed there will be * padding between the packets. To optimally use the * bandwidth the padding is not transmitted. */ int i; for (i = 0; i < urb->number_of_packets; i++) { iov[iovnum].iov_base = urb->transfer_buffer + urb->iso_frame_desc[i].offset; iov[iovnum].iov_len = urb->iso_frame_desc[i].actual_length; iovnum++; txsize += urb->iso_frame_desc[i].actual_length; } if (txsize != sizeof(pdu_header) + urb->actual_length) { dev_err(&sdev->udev->dev, "actual length of urb %d does not match iso packet sizes %zu\n", urb->actual_length, txsize-sizeof(pdu_header)); kfree(iov); usbip_event_add(&sdev->ud, <API key>); return -1; } } /* 3. setup <API key> */ if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { ssize_t len = 0; iso_buffer = <API key>(urb, &len); if (!iso_buffer) { usbip_event_add(&sdev->ud, <API key>); kfree(iov); return -1; } iov[iovnum].iov_base = iso_buffer; iov[iovnum].iov_len = len; txsize += len; iovnum++; } ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, iov, iovnum, txsize); if (ret != txsize) { dev_err(&sdev->udev->dev, "sendmsg failed!, retval %d for %zd\n", ret, txsize); kfree(iov); kfree(iso_buffer); usbip_event_add(&sdev->ud, <API key>); return -1; } kfree(iov); kfree(iso_buffer); total_size += txsize; } spin_lock_irqsave(&sdev->priv_lock, flags); <API key>(priv, tmp, &sdev->priv_free, list) { <API key>(priv); } <API key>(&sdev->priv_lock, flags); return total_size; } static struct stub_unlink *<API key>(struct stub_device *sdev) { unsigned long flags; struct stub_unlink *unlink, *tmp; spin_lock_irqsave(&sdev->priv_lock, flags); <API key>(unlink, tmp, &sdev->unlink_tx, list) { list_move_tail(&unlink->list, &sdev->unlink_free); <API key>(&sdev->priv_lock, flags); return unlink; } <API key>(&sdev->priv_lock, flags); return NULL; } static int <API key>(struct stub_device *sdev) { unsigned long flags; struct stub_unlink *unlink, *tmp; struct msghdr msg; struct kvec iov[1]; size_t txsize; size_t total_size = 0; while ((unlink = <API key>(sdev)) != NULL) { int ret; struct usbip_header pdu_header; txsize = 0; memset(&pdu_header, 0, sizeof(pdu_header)); memset(&msg, 0, sizeof(msg)); memset(&iov, 0, sizeof(iov)); usbip_dbg_stub_tx("setup ret unlink %lu\n", unlink->seqnum); /* 1. setup usbip_header */ <API key>(&pdu_header, unlink); <API key>(&pdu_header, 1); iov[0].iov_base = &pdu_header; iov[0].iov_len = sizeof(pdu_header); txsize += sizeof(pdu_header); ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, iov, 1, txsize); if (ret != txsize) { dev_err(&sdev->udev->dev, "sendmsg failed!, retval %d for %zd\n", ret, txsize); usbip_event_add(&sdev->ud, <API key>); return -1; } usbip_dbg_stub_tx("send txdata\n"); total_size += txsize; } spin_lock_irqsave(&sdev->priv_lock, flags); <API key>(unlink, tmp, &sdev->unlink_free, list) { list_del(&unlink->list); kfree(unlink); } <API key>(&sdev->priv_lock, flags); return total_size; } int stub_tx_loop(void *data) { struct usbip_device *ud = data; struct stub_device *sdev = container_of(ud, struct stub_device, ud); while (!kthread_should_stop()) { if (<API key>(ud)) break; /* * send_ret_submit comes earlier than send_ret_unlink. stub_rx * looks at only priv_init queue. If the completion of a URB is * earlier than the receive of CMD_UNLINK, priv is moved to * priv_tx queue and stub_rx does not find the target priv. In * this case, vhci_rx receives the result of the submit request * and then receives the result of the unlink request. The * result of the submit is given back to the usbcore as the * completion of the unlink request. The request of the * unlink is ignored. This is ok because a driver who calls * usb_unlink_urb() understands the unlink was too late by * getting the status of the given-backed URB which has the * status of usb_submit_urb(). */ if (<API key>(sdev) < 0) break; if (<API key>(sdev) < 0) break; <API key>(sdev->tx_waitq, (!list_empty(&sdev->priv_tx) || !list_empty(&sdev->unlink_tx) || kthread_should_stop())); } return 0; }
from django.template import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError from django.utils.encoding import force_unicode from django.utils.html import escape from django.utils.safestring import SafeData, EscapeData from django.utils.formats import localize class DebugLexer(Lexer): def __init__(self, template_string, origin): super(DebugLexer, self).__init__(template_string, origin) def tokenize(self): "Return a list of tokens from a given template_string" result, upto = [], 0 for match in tag_re.finditer(self.template_string): start, end = match.span() if start > upto: result.append(self.create_token(self.template_string[upto:start], (upto, start), False)) upto = start result.append(self.create_token(self.template_string[start:end], (start, end), True)) upto = end last_bit = self.template_string[upto:] if last_bit: result.append(self.create_token(last_bit, (upto, upto + len(last_bit)), False)) return result def create_token(self, token_string, source, in_tag): token = super(DebugLexer, self).create_token(token_string, in_tag) token.source = self.origin, source return token class DebugParser(Parser): def __init__(self, lexer): super(DebugParser, self).__init__(lexer) self.command_stack = [] def enter_command(self, command, token): self.command_stack.append( (command, token.source) ) def exit_command(self): self.command_stack.pop() def error(self, token, msg): return self.source_error(token.source, msg) def source_error(self, source,msg): e = TemplateSyntaxError(msg) e.source = source return e def create_nodelist(self): return DebugNodeList() def <API key>(self, contents): return DebugVariableNode(contents) def extend_nodelist(self, nodelist, node, token): node.source = token.source super(DebugParser, self).extend_nodelist(nodelist, node, token) def unclosed_block_tag(self, parse_until): command, source = self.command_stack.pop() msg = "Unclosed tag '%s'. Looking for one of: %s " % (command, ', '.join(parse_until)) raise self.source_error(source, msg) def <API key>(self, token, e): if not hasattr(e, 'source'): e.source = token.source class DebugNodeList(NodeList): def render_node(self, node, context): try: result = node.render(context) except TemplateSyntaxError, e: if not hasattr(e, 'source'): e.source = node.source raise except Exception, e: from sys import exc_info wrapped = TemplateSyntaxError(u'Caught %s while rendering: %s' % (e.__class__.__name__, force_unicode(e, errors='replace'))) wrapped.source = node.source wrapped.exc_info = exc_info() raise wrapped, None, wrapped.exc_info[2] return result class DebugVariableNode(VariableNode): def render(self, context): try: output = self.filter_expression.resolve(context) output = localize(output) output = force_unicode(output) except TemplateSyntaxError, e: if not hasattr(e, 'source'): e.source = self.source raise except UnicodeDecodeError: return '' if (context.autoescape and not isinstance(output, SafeData)) or isinstance(output, EscapeData): return escape(output) else: return output
#ifndef _UAPI_LINUX_ICMP_H #define _UAPI_LINUX_ICMP_H #include <linux/types.h> #define ICMP_ECHOREPLY 0 /* Echo Reply */ #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ #define ICMP_SOURCE_QUENCH 4 /* Source Quench */ #define ICMP_REDIRECT 5 /* Redirect (change route) */ #define ICMP_ECHO 8 /* Echo Request */ #define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ #define ICMP_PARAMETERPROB 12 /* Parameter Problem */ #define ICMP_TIMESTAMP 13 /* Timestamp Request */ #define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ #define ICMP_INFO_REQUEST 15 /* Information Request */ #define ICMP_INFO_REPLY 16 /* Information Reply */ #define ICMP_ADDRESS 17 /* Address Mask Request */ #define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ #define NR_ICMP_TYPES 18 /* Codes for UNREACH. */ #define ICMP_NET_UNREACH 0 /* Network Unreachable */ #define ICMP_HOST_UNREACH 1 /* Host Unreachable */ #define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ #define ICMP_PORT_UNREACH 3 /* Port Unreachable */ #define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ #define ICMP_SR_FAILED 5 /* Source Route failed */ #define ICMP_NET_UNKNOWN 6 #define ICMP_HOST_UNKNOWN 7 #define ICMP_HOST_ISOLATED 8 #define ICMP_NET_ANO 9 #define ICMP_HOST_ANO 10 #define ICMP_NET_UNR_TOS 11 #define ICMP_HOST_UNR_TOS 12 #define ICMP_PKT_FILTERED 13 /* Packet filtered */ #define ICMP_PREC_VIOLATION 14 /* Precedence violation */ #define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ #define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ /* Codes for REDIRECT. */ #define ICMP_REDIR_NET 0 /* Redirect Net */ #define ICMP_REDIR_HOST 1 /* Redirect Host */ #define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ #define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ /* Codes for TIME_EXCEEDED. */ #define ICMP_EXC_TTL 0 /* TTL count exceeded */ #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ struct icmphdr { __u8 type; __u8 code; __sum16 checksum; union { struct { __be16 id; __be16 sequence; } echo; __be32 gateway; struct { __be16 __unused; __be16 mtu; } frag; } un; }; /* * constants for (set|get)sockopt */ #define ICMP_FILTER 1 struct icmp_filter { __u32 data; }; #endif /* _UAPI_LINUX_ICMP_H */
# <API key>: true class JobsManager @@managers = {} attr :adapter_name def self.current_manager @@managers[ENV["AJ_ADAPTER"]] ||= new(ENV["AJ_ADAPTER"]) end def initialize(adapter_name) @adapter_name = adapter_name require_relative "adapters/#{adapter_name}" extend "#{adapter_name.camelize}JobsManager".constantize end def setup ActiveJob::Base.queue_adapter = nil end def clear_jobs end def start_workers end def stop_workers end end
<?php // Moodle is free software: you can redistribute it and/or modify // (at your option) any later version. // Moodle is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the namespace <API key>\local\ui; use html_writer; defined('MOODLE_INTERNAL') || die; class text_attribute extends element { /** @var bool $isdisabled Is this input disabled? */ private $isdisabled; /** * Constructor * * @param string $name The input name (the first bit) * @param string $value The input initial value. * @param string $label The label for this input field. * @param bool $isdisabled Is this input disabled. */ public function __construct($name, $value, $label, $isdisabled = false) { $this->isdisabled = $isdisabled; parent::__construct($name, $value, $label); } /** * Nasty function allowing custom textbox behaviour outside the class. * @return bool Is this a textbox. */ public function is_textbox() { return true; } /** * Render the html for this field. * @return string The HTML. */ public function html() { $attributes = array( 'type' => 'text', 'name' => $this->name, 'value' => $this->value, 'id' => $this->name ); if ($this->isdisabled) { $attributes['disabled'] = 'DISABLED'; } $hidden = array( 'type' => 'hidden', 'name' => 'old' . $this->name, 'value' => $this->value ); $label = ''; if (preg_match("/^feedback/", $this->name)) { $labeltitle = get_string('feedbackfor', '<API key>', $this->label); $attributes['tabindex'] = '2'; $label = html_writer::tag('label', $labeltitle, array('for' => $this->name, 'class' => 'accesshide')); } else if (preg_match("/^finalgrade/", $this->name)) { $labeltitle = get_string('gradefor', '<API key>', $this->label); $attributes['tabindex'] = '1'; $label = html_writer::tag('label', $labeltitle, array('for' => $this->name, 'class' => 'accesshide')); } return ( $label . html_writer::empty_tag('input', $attributes) . html_writer::empty_tag('input', $hidden) ); } }
#ifndef <API key> #define <API key> // 8192S Regsiter offset definition // BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF // 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF // 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 // 3. RF register 0x00-2E // 4. Bit Mask for BB/RF register // 5. Other defintion for BB/RF R/W // 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF // 1. Page1(0x100) #define rPMAC_Reset 0x100 #define rPMAC_TxStart 0x104 #define rPMAC_TxLegacySIG 0x108 #define rPMAC_TxHTSIG1 0x10c #define rPMAC_TxHTSIG2 0x110 #define rPMAC_PHYDebug 0x114 #define rPMAC_TxPacketNum 0x118 #define rPMAC_TxIdle 0x11c #define rPMAC_TxMACHeader0 0x120 #define rPMAC_TxMACHeader1 0x124 #define rPMAC_TxMACHeader2 0x128 #define rPMAC_TxMACHeader3 0x12c #define rPMAC_TxMACHeader4 0x130 #define rPMAC_TxMACHeader5 0x134 #define rPMAC_TxDataType 0x138 #define rPMAC_TxRandomSeed 0x13c #define <API key> 0x140 #define rPMAC_CCKPLCPHeader 0x144 #define rPMAC_CCKCRC16 0x148 #define rPMAC_OFDMRxCRC32OK 0x170 #define rPMAC_OFDMRxCRC32Er 0x174 #define <API key> 0x178 #define rPMAC_OFDMRxCRC8Er 0x17c #define rPMAC_CCKCRxRC16Er 0x180 #define rPMAC_CCKCRxRC32Er 0x184 #define rPMAC_CCKCRxRC32OK 0x188 #define rPMAC_TxStatus 0x18c // 2. Page2(0x200) // The following two definition are only used for USB interface. //#define RF_BB_CMD_ADDR 0x02c0 // RF/BB read/write command address. //#define RF_BB_CMD_DATA 0x02c4 // RF/BB read/write command data. // 3. Page8(0x800) #define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC // RF BW Setting?? #define rFPGA0_TxInfo 0x804 // Status report?? #define rFPGA0_PSDFunction 0x808 #define rFPGA0_TxGainStage 0x80c // Set TX PWR init gain? #define rFPGA0_RFTiming1 0x810 // Useless now #define rFPGA0_RFTiming2 0x814 //#define rFPGA0_XC_RFTiming 0x818 //#define rFPGA0_XD_RFTiming 0x81c #define <API key> 0x820 // RF 3 wire register #define <API key> 0x824 #define <API key> 0x828 #define <API key> 0x82c #define <API key> 0x830 #define <API key> 0x834 #define <API key> 0x838 #define <API key> 0x83c #define <API key> 0x840 #define <API key> 0x844 #define <API key> 0x848 #define <API key> 0x84c #define <API key> 0x850 // Useless now #define <API key> 0x854 #define <API key> 0x858 // RF Channel switch #define <API key> 0x85c #define <API key> 0x860 // RF Channel switch #define <API key> 0x864 #define <API key> 0x868 #define <API key> 0x86c #define <API key> 0x870 // RF Interface Software Control #define <API key> 0x874 #define <API key> 0x878 // RF Parameter #define <API key> 0x87c #define <API key> 0x880 // Crystal cap setting RF-R/W protection for parameter4?? #define <API key> 0x884 #define <API key> 0x888 // Useless now #define <API key> 0x88c #define <API key> 0x8a0 // Tranceiver LSSI Readback #define <API key> 0x8a4 #define <API key> 0x8a8 #define <API key> 0x8ac #define rFPGA0_PSDReport 0x8b4 // Useless now #define <API key> 0x8e0 // Useless now // RF Interface Readback Value #define <API key> 0x8e4 // Useless now // 4. Page9(0x900) #define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC // RF BW Setting?? #define rFPGA1_TxBlock 0x904 // Useless now #define rFPGA1_DebugSelect 0x908 // Useless now #define rFPGA1_TxInfo 0x90c // Useless now // Status report?? // 5. PageA(0xA00) // Set Control channel to upper or lower. These settings are required only for 40MHz #define rCCK0_System 0xa00 #define rCCK0_AFESetting 0xa04 // Disable init gain now // Select RX path by RSSI #define rCCK0_CCA 0xa08 // Disable init gain now // Init gain #define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level // Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series #define rCCK0_RxAGC2 0xa10 //AGC & DAGC #define rCCK0_RxHP 0xa14 #define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold #define rCCK0_DSPParameter2 0xa1c //SQ threshold #define rCCK0_TxFilter1 0xa20 #define rCCK0_TxFilter2 0xa24 #define rCCK0_DebugPort 0xa28 //debug port and Tx filter3 #define <API key> 0xa2c //0xa2d useless now 0xa30-a4f channel report #define rCCK0_TRSSIReport 0xa50 #define rCCK0_RxReport 0xa54 //0xa57 #define <API key> 0xa5c //0xa5b #define <API key> 0xa58 //0xa5c // 6. PageC(0xC00) #define rOFDM0_LSTF 0xc00 #define <API key> 0xc04 #define rOFDM0_TRMuxPar 0xc08 #define <API key> 0xc0c #define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter #define <API key> 0xc14 //RxIQ imblance matrix #define rOFDM0_XBRxAFE 0xc18 #define <API key> 0xc1c #define rOFDM0_XCRxAFE 0xc20 #define <API key> 0xc24 #define rOFDM0_XDRxAFE 0xc28 #define <API key> 0xc2c #define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD // DM tune init gain #define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync. #define rOFDM0_RxDetector3 0xc38 //Frame Sync. #define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI #define rOFDM0_RxDSP 0xc40 //Rx Sync Path #define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC #define <API key> 0xc48 //CCA Drop threshold #define <API key> 0xc4c // energy CCA #define rOFDM0_XAAGCCore1 0xc50 // DIG #define rOFDM0_XAAGCCore2 0xc54 #define rOFDM0_XBAGCCore1 0xc58 #define rOFDM0_XBAGCCore2 0xc5c #define rOFDM0_XCAGCCore1 0xc60 #define rOFDM0_XCAGCCore2 0xc64 #define rOFDM0_XDAGCCore1 0xc68 #define rOFDM0_XDAGCCore2 0xc6c #define <API key> 0xc70 #define <API key> 0xc74 #define rOFDM0_AGCRSSITable 0xc78 #define rOFDM0_HTSTFAGC 0xc7c #define <API key> 0xc80 // TX PWR TRACK and DIG #define rOFDM0_XATxAFE 0xc84 #define <API key> 0xc88 #define rOFDM0_XBTxAFE 0xc8c #define <API key> 0xc90 #define rOFDM0_XCTxAFE 0xc94 #define <API key> 0xc98 #define rOFDM0_XDTxAFE 0xc9c #define <API key> 0xce0 #define <API key> 0xce4 #define rOFDM0_FrameSync 0xcf0 #define rOFDM0_DFSReport 0xcf4 #define rOFDM0_TxCoeff1 0xca4 #define rOFDM0_TxCoeff2 0xca8 #define rOFDM0_TxCoeff3 0xcac #define rOFDM0_TxCoeff4 0xcb0 #define rOFDM0_TxCoeff5 0xcb4 #define rOFDM0_TxCoeff6 0xcb8 // 7. PageD(0xD00) #define rOFDM1_LSTF 0xd00 #define <API key> 0xd04 #define rOFDM1_CFO 0xd08 // No setting now #define rOFDM1_CSI1 0xd10 #define rOFDM1_SBD 0xd14 #define rOFDM1_CSI2 0xd18 #define rOFDM1_CFOTracking 0xd2c #define rOFDM1_TRxMesaure1 0xd34 #define rOFDM1_IntfDet 0xd3c #define <API key> 0xd50 #define <API key> 0xd54 #define <API key> 0xd58 #define rOFDM_PHYCounter1 0xda0 //cca, parity fail #define rOFDM_PHYCounter2 0xda4 #define rOFDM_PHYCounter3 0xda8 //MCS not support #define rOFDM_ShortCFOAB 0xdac // No setting now #define rOFDM_ShortCFOCD 0xdb0 #define rOFDM_LongCFOAB 0xdb4 #define rOFDM_LongCFOCD 0xdb8 #define rOFDM_TailCFOAB 0xdbc #define rOFDM_TailCFOCD 0xdc0 #define rOFDM_PWMeasure1 0xdc4 #define rOFDM_PWMeasure2 0xdc8 #define rOFDM_BWReport 0xdcc #define rOFDM_AGCReport 0xdd0 #define rOFDM_RxSNR 0xdd4 #define rOFDM_RxEVMCSI 0xdd8 #define rOFDM_SIGReport 0xddc // 8. PageE(0xE00) #define rTxAGC_Rate18_06 0xe00 #define rTxAGC_Rate54_24 0xe04 #define rTxAGC_CCK_Mcs32 0xe08 #define rTxAGC_Mcs03_Mcs00 0xe10 #define rTxAGC_Mcs07_Mcs04 0xe14 #define rTxAGC_Mcs11_Mcs08 0xe18 #define rTxAGC_Mcs15_Mcs12 0xe1c // Analog- control in RX_WAIT_CCA : REG: EE0 [Analog- Power & Control Register] #define rRx_Wait_CCCA 0xe70 #define rAnapar_Ctrl_BB 0xee0 // 7. RF Register 0x00-0x2E (RF 8256) // RF-0222D 0x00-3F //Zebra1 #define RTL92SE_FPGA_VERIFY 0 #define rZebra1_HSSIEnable 0x0 // Useless now #define rZebra1_TRxEnable1 0x1 #define rZebra1_TRxEnable2 0x2 #define rZebra1_AGC 0x4 #define rZebra1_ChargePump 0x5 //#if (RTL92SE_FPGA_VERIFY == 1) #define rZebra1_Channel 0x7 // RF channel switch //#else //#endif #define rZebra1_TxGain 0x8 // Useless now #define rZebra1_TxLPF 0x9 #define rZebra1_RxLPF 0xb #define rZebra1_RxHPFCorner 0xc //Zebra4 #define rGlobalCtrl 0 // Useless now #define rRTL8256_TxLPF 19 #define rRTL8256_RxLPF 11 //RTL8258 #define rRTL8258_TxLPF 0x11 // Useless now #define rRTL8258_RxLPF 0x13 #define rRTL8258_RSSILPF 0xa // RL6052 Register definition #define RF_AC 0x00 #define RF_IQADJ_G1 0x01 #define RF_IQADJ_G2 0x02 #define RF_POW_TRSW 0x05 #define RF_GAIN_RX 0x06 #define RF_GAIN_TX 0x07 #define RF_TXM_IDAC 0x08 #define RF_BS_IQGEN 0x0F #define RF_MODE1 0x10 #define RF_MODE2 0x11 #define RF_RX_AGC_HP 0x12 #define RF_TX_AGC 0x13 #define RF_BIAS 0x14 #define RF_IPA 0x15 #define RF_POW_ABILITY 0x17 #define RF_MODE_AG 0x18 #define rRfChannel 0x18 // RF channel and BW switch #define RF_CHNLBW 0x18 // RF channel and BW switch #define RF_TOP 0x19 #define RF_RX_G1 0x1A #define RF_RX_G2 0x1B #define RF_RX_BB2 0x1C #define RF_RX_BB1 0x1D #define RF_RCK1 0x1E #define RF_RCK2 0x1F #define RF_TX_G1 0x20 #define RF_TX_G2 0x21 #define RF_TX_G3 0x22 #define RF_TX_BB1 0x23 #define RF_T_METER 0x24 #define RF_SYN_G1 0x25 // RF TX Power control #define RF_SYN_G2 0x26 // RF TX Power control #define RF_SYN_G3 0x27 // RF TX Power control #define RF_SYN_G4 0x28 // RF TX Power control #define RF_SYN_G5 0x29 // RF TX Power control #define RF_SYN_G6 0x2A // RF TX Power control #define RF_SYN_G7 0x2B // RF TX Power control #define RF_SYN_G8 0x2C // RF TX Power control #define RF_RCK_OS 0x30 // RF TX PA control #define RF_TXPA_G1 0x31 // RF TX PA control #define RF_TXPA_G2 0x32 // RF TX PA control #define RF_TXPA_G3 0x33 // RF TX PA control //Bit Mask // 1. Page1(0x100) #define bBBResetB 0x100 // Useless now? #define bGlobalResetB 0x200 #define bOFDMTxStart 0x4 #define bCCKTxStart 0x8 #define bCRC32Debug 0x100 #define bPMACLoopback 0x10 #define bTxLSIG 0xffffff #define bOFDMTxRate 0xf #define bOFDMTxReserved 0x10 #define bOFDMTxLength 0x1ffe0 #define bOFDMTxParity 0x20000 #define bTxHTSIG1 0xffffff #define bTxHTMCSRate 0x7f #define bTxHTBW 0x80 #define bTxHTLength 0xffff00 #define bTxHTSIG2 0xffffff #define bTxHTSmoothing 0x1 #define bTxHTSounding 0x2 #define bTxHTReserved 0x4 #define bTxHTAggreation 0x8 #define bTxHTSTBC 0x30 #define bTxHTAdvanceCoding 0x40 #define bTxHTShortGI 0x80 #define bTxHTNumberHT_LTF 0x300 #define bTxHTCRC8 0x3fc00 #define bCounterReset 0x10000 #define bNumOfOFDMTx 0xffff #define bNumOfCCKTx 0xffff0000 #define bTxIdleInterval 0xffff #define bOFDMService 0xffff0000 #define bTxMACHeader 0xffffffff #define bTxDataInit 0xff #define bTxHTMode 0x100 #define bTxDataType 0x30000 #define bTxRandomSeed 0xffffffff #define bCCKTxPreamble 0x1 #define bCCKTxSFD 0xffff0000 #define bCCKTxSIG 0xff #define bCCKTxService 0xff00 #define bCCKLengthExt 0x8000 #define bCCKTxLength 0xffff0000 #define bCCKTxCRC16 0xffff #define bCCKTxStatus 0x1 #define bOFDMTxStatus 0x2 #define <API key>(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff)) // 2. Page8(0x800) #define bRFMOD 0x1 // Reg 0x800 rFPGA0_RFMOD #define bJapanMode 0x2 #define bCCKTxSC 0x30 #define bCCKEn 0x1000000 #define bOFDMEn 0x2000000 #define bOFDMRxADCPhase 0x10000 // Useless now #define bOFDMTxDACPhase 0x40000 #define bXATxAGC 0x3f #define bXBTxAGC 0xf00 // Reg 80c rFPGA0_TxGainStage #define bXCTxAGC 0xf000 #define bXDTxAGC 0xf0000 #define bPAStart 0xf0000000 // Useless now #define bTRStart 0x00f00000 #define bRFStart 0x0000f000 #define bBBStart 0x000000f0 #define bBBCCKStart 0x0000000f #define bPAEnd 0xf //Reg0x814 #define bTREnd 0x0f000000 #define bRFEnd 0x000f0000 #define bCCAMask 0x000000f0 //T2R #define bR2RCCAMask 0x00000f00 #define bHSSI_R2TDelay 0xf8000000 #define bHSSI_T2RDelay 0xf80000 #define bContTxHSSI 0x400 //chane gain at continue Tx #define bIGFromCCK 0x200 #define bAGCAddress 0x3f #define bRxHPTx 0x7000 #define bRxHPT2R 0x38000 #define bRxHPCCKIni 0xc0000 #define bAGCTxCode 0xc00000 #define bAGCRxCode 0x300000 #define b3WireDataLength 0x800 // Reg 0x820~84f <API key> #define b3WireAddressLength 0x400 #define b3WireRFPowerDown 0x1 // Useless now //#define bHWSISelect 0x8 #define b5GPAPEPolarity 0x40000000 #define b2GPAPEPolarity 0x80000000 #define bRFSW_TxDefaultAnt 0x3 #define bRFSW_TxOptionAnt 0x30 #define bRFSW_RxDefaultAnt 0x300 #define bRFSW_RxOptionAnt 0x3000 #define bRFSI_3WireData 0x1 #define bRFSI_3WireClock 0x2 #define bRFSI_3WireLoad 0x4 #define bRFSI_3WireRW 0x8 #define bRFSI_3Wire 0xf #define bRFSI_RFENV 0x10 // Reg 0x870 <API key> #define bRFSI_TRSW 0x20 // Useless now #define bRFSI_TRSWB 0x40 #define bRFSI_ANTSW 0x100 #define bRFSI_ANTSWB 0x200 #define bRFSI_PAPE 0x400 #define bRFSI_PAPE5G 0x800 #define bBandSelect 0x1 #define bHTSIG2_GI 0x80 #define bHTSIG2_Smoothing 0x01 #define bHTSIG2_Sounding 0x02 #define bHTSIG2_Aggreaton 0x08 #define bHTSIG2_STBC 0x30 #define bHTSIG2_AdvCoding 0x40 #define bHTSIG2_NumOfHTLTF 0x300 #define bHTSIG2_CRC8 0x3fc #define bHTSIG1_MCS 0x7f #define bHTSIG1_BandWidth 0x80 #define bHTSIG1_HTLength 0xffff #define bLSIG_Rate 0xf #define bLSIG_Reserved 0x10 #define bLSIG_Length 0x1fffe #define bLSIG_Parity 0x20 #define bCCKRxPhase 0x4 #if (RTL92SE_FPGA_VERIFY == 1) #define bLSSIReadAddress 0x3f000000 //LSSI "Read" Address // Reg 0x824 <API key> #else #define bLSSIReadAddress 0x7f800000 // T65 RF #endif #define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal #if (RTL92SE_FPGA_VERIFY == 1) #define bLSSIReadBackData 0xfff // Reg 0x8a0 <API key> #else #define bLSSIReadBackData 0xfffff // T65 RF #endif #define bLSSIReadOKFlag 0x1000 // Useless now #define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz #define bRegulator0Standby 0x1 #define <API key> 0x2 #define bRegulator1Standby 0x4 #define bPLLPowerUp 0x8 #define bDPLLPowerUp 0x10 #define bDA10PowerUp 0x20 #define bAD7PowerUp 0x200 #define bDA6PowerUp 0x2000 #define bXtalPowerUp 0x4000 #define b40MDClkPowerUP 0x8000 #define bDA6DebugMode 0x20000 #define bDA6Swing 0x380000 #define bADClkPhase 0x4000000 // Reg 0x880 <API key> 20/40 CCK support switch 40/80 BB MHZ #define b80MClkDelay 0x18000000 // Useless #define bAFEWatchDogEnable 0x20000000 #define bXtalCap01 0xc0000000 // Reg 0x884 <API key> Crystal cap #define bXtalCap23 0x3 #define bXtalCap92x 0x0f000000 #define bXtalCap 0x0f000000 #define bIntDifClkEnable 0x400 // Useless #define bExtSigClkEnable 0x800 #define <API key> 0x10000 #define bAD11SHGain 0xc0000 #define bAD11InputRange 0x700000 #define bAD11OPCurrent 0x3800000 #define bIPathLoopback 0x4000000 #define bQPathLoopback 0x8000000 #define bAFELoopback 0x10000000 #define bDA10Swing 0x7e0 #define bDA10Reverse 0x800 #define bDAClkSource 0x1000 #define bAD7InputRange 0x6000 #define bAD7Gain 0x38000 #define bAD7OutputCMMode 0x40000 #define bAD7InputCMMode 0x380000 #define bAD7Current 0xc00000 #define bRegulatorAdjust 0x7000000 #define bAD11PowerUpAtTx 0x1 #define bDA10PSAtTx 0x10 #define bAD11PowerUpAtRx 0x100 #define bDA10PSAtRx 0x1000 #define bCCKRxAGCFormat 0x200 #define bPSDFFTSamplepPoint 0xc000 #define bPSDAverageNum 0x3000 #define bIQPathControl 0xc00 #define bPSDFreq 0x3ff #define bPSDAntennaPath 0x30 #define bPSDIQSwitch 0x40 #define bPSDRxTrigger 0x400000 #define bPSDTxTrigger 0x80000000 #define bPSDSineToneScale 0x7f000000 #define bPSDReport 0xffff // 3. Page9(0x900) #define bOFDMTxSC 0x30000000 // Useless #define bCCKTxOn 0x1 #define bOFDMTxOn 0x2 #define bDebugPage 0xfff //reset debug page and also HWord, LWord #define bDebugItem 0xff //reset debug page and LWord #define bAntL 0x10 #define bAntNonHT 0x100 #define bAntHT1 0x1000 #define bAntHT2 0x10000 #define bAntHT1S1 0x100000 #define bAntNonHTS1 0x1000000 // 4. PageA(0xA00) #define bCCKBBMode 0x3 // Useless #define bCCKTxPowerSaving 0x80 #define bCCKRxPowerSaving 0x40 #define bCCKSideBand 0x10 // Reg 0xa00 rCCK0_System 20/40 switch #define bCCKScramble 0x8 // Useless #define bCCKAntDiversity 0x8000 #define bCCKCarrierRecovery 0x4000 #define bCCKTxRate 0x3000 #define bCCKDCCancel 0x0800 #define bCCKISICancel 0x0400 #define bCCKMatchFilter 0x0200 #define bCCKEqualizer 0x0100 #define bCCKPreambleDetect 0x800000 #define bCCKFastFalseCCA 0x400000 #define bCCKChEstStart 0x300000 #define bCCKCCACount 0x080000 #define bCCKcs_lim 0x070000 #define bCCKBistMode 0x80000000 #define bCCKCCAMask 0x40000000 #define bCCKTxDACPhase 0x4 #define bCCKRxADCPhase 0x20000000 //r_rx_clk #define bCCKr_cp_mode0 0x0100 #define bCCKTxDCOffset 0xf0 #define bCCKRxDCOffset 0xf #define bCCKCCAMode 0xc000 #define bCCKFalseCS_lim 0x3f00 #define bCCKCS_ratio 0xc00000 #define bCCKCorgBit_sel 0x300000 #define bCCKPD_lim 0x0f0000 #define bCCKNewCCA 0x80000000 #define bCCKRxHPofIG 0x8000 #define bCCKRxIG 0x7f00 #define bCCKLNAPolarity 0x800000 #define bCCKRx1stGain 0x7f0000 #define bCCKRFExtend 0x20000000 //CCK Rx Iinital gain polarity #define bCCKRxAGCSatLevel 0x1f000000 #define bCCKRxAGCSatCount 0xe0 #define bCCKRxRFSettle 0x1f //AGCsamp_dly #define bCCKFixedRxAGC 0x8000 //#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824 #define bCCKAntennaPolarity 0x2000 #define bCCKTxFilterType 0x0c00 #define bCCKRxAGCReportType 0x0300 #define bCCKRxDAGCEn 0x80000000 #define bCCKRxDAGCPeriod 0x20000000 #define bCCKRxDAGCSatLevel 0x1f000000 #define bCCKTimingRecovery 0x800000 #define bCCKTxC0 0x3f0000 #define bCCKTxC1 0x3f000000 #define bCCKTxC2 0x3f #define bCCKTxC3 0x3f00 #define bCCKTxC4 0x3f0000 #define bCCKTxC5 0x3f000000 #define bCCKTxC6 0x3f #define bCCKTxC7 0x3f00 #define bCCKDebugPort 0xff0000 #define bCCKDACDebug 0x0f000000 #define <API key> 0x8000 #define bCCKFalseAlarmRead 0x4000 #define bCCKTRSSI 0x7f #define bCCKRxAGCReport 0xfe #define bCCKRxReport_AntSel 0x80000000 #define bCCKRxReport_MFOff 0x40000000 #define <API key> 0x20000000 #define <API key> 0x10000000 #define <API key> 0x08000000 #define <API key> 0x04000000 #define bCCKRxReport_RxRate 0x03000000 #define <API key> 0xff #define <API key> 0xff000000 #define bCCKRxHPAGCStart 0xe000 #define bCCKRxHPAGCFinal 0x1c00 #define <API key> 0x8000 #define bCCKFACounterFreeze 0x4000 #define bCCKTxPathSel 0x10000000 #define bCCKDefaultRxPath 0xc000000 #define bCCKOptionRxPath 0x3000000 // 5. PageC(0xC00) #define bNumOfSTF 0x3 // Useless #define bShift_L 0xc0 #define bGI_TH 0xc #define bRxPathA 0x1 #define bRxPathB 0x2 #define bRxPathC 0x4 #define bRxPathD 0x8 #define bTxPathA 0x1 #define bTxPathB 0x2 #define bTxPathC 0x4 #define bTxPathD 0x8 #define bTRSSIFreq 0x200 #define bADCBackoff 0x3000 #define bDFIRBackoff 0xc000 #define bTRSSILatchPhase 0x10000 #define bRxIDCOffset 0xff #define bRxQDCOffset 0xff00 #define bRxDFIRMode 0x1800000 #define bRxDCNFType 0xe000000 #define bRXIQImb_A 0x3ff #define bRXIQImb_B 0xfc00 #define bRXIQImb_C 0x3f0000 #define bRXIQImb_D 0xffc00000 #define bDC_dc_Notch 0x60000 #define bRxNBINotch 0x1f000000 #define bPD_TH 0xf #define bPD_TH_Opt2 0xc000 #define bPWED_TH 0x700 #define bIfMF_Win_L 0x800 #define bPD_Option 0x1000 #define bMF_Win_L 0xe000 #define bBW_Search_L 0x30000 #define bwin_enh_L 0xc0000 #define bBW_TH 0x700000 #define bED_TH2 0x3800000 #define bBW_option 0x4000000 #define bRatio_TH 0x18000000 #define bWindow_L 0xe0000000 #define bSBD_Option 0x1 #define bFrame_TH 0x1c #define bFS_Option 0x60 #define bDC_Slope_check 0x80 #define <API key> 0xe00 #define bFrame_Weight_Short 0x7000 #define bSub_Tune 0xe00000 #define bFrame_DC_Length 0xe000000 #define bSBD_start_offset 0x30000000 #define bFrame_TH_2 0x7 #define bFrame_GI2_TH 0x38 #define bGI2_Sync_en 0x40 #define bSarch_Short_Early 0x300 #define bSarch_Short_Late 0xc00 #define bSarch_GI2_Late 0x70000 #define bCFOAntSum 0x1 #define bCFOAcc 0x2 #define bCFOStartOffset 0xc #define bCFOLookBack 0x70 #define bCFOSumWeight 0x80 #define bDAGCEnable 0x10000 #define bTXIQImb_A 0x3ff #define bTXIQImb_B 0xfc00 #define bTXIQImb_C 0x3f0000 #define bTXIQImb_D 0xffc00000 #define bTxIDCOffset 0xff #define bTxQDCOffset 0xff00 #define bTxDFIRMode 0x10000 #define bTxPesudoNoiseOn 0x4000000 #define bTxPesudoNoise_A 0xff #define bTxPesudoNoise_B 0xff00 #define bTxPesudoNoise_C 0xff0000 #define bTxPesudoNoise_D 0xff000000 #define bCCADropOption 0x20000 #define bCCADropThres 0xfff00000 #define bEDCCA_H 0xf #define bEDCCA_L 0xf0 #define bLambda_ED 0x300 #define bRxInitialGain 0x7f #define bRxAntDivEn 0x80 #define bRxAGCAddressForLNA 0x7f00 #define bRxHighPowerFlow 0x8000 #define bRxAGCFreezeThres 0xc0000 #define bRxFreezeStep_AGC1 0x300000 #define bRxFreezeStep_AGC2 0xc00000 #define bRxFreezeStep_AGC3 0x3000000 #define bRxFreezeStep_AGC0 0xc000000 #define bRxRssi_Cmp_En 0x10000000 #define bRxQuickAGCEn 0x20000000 #define <API key> 0x40000000 #define <API key> 0x80000000 #define bRxAGCShift 0x7f #define bTRSW_Tri_Only 0x80 #define bPowerThres 0x300 #define bRxAGCEn 0x1 #define bRxAGCTogetherEn 0x2 #define bRxAGCMin 0x4 #define bRxHP_Ini 0x7 #define bRxHP_TRLNA 0x70 #define bRxHP_RSSI 0x700 #define bRxHP_BBP1 0x7000 #define bRxHP_BBP2 0x70000 #define bRxHP_BBP3 0x700000 #define bRSSI_H 0x7f0000 //the threshold for high power #define bRSSI_Gen 0x7f000000 //the threshold for ant diversity #define bRxSettle_TRSW 0x7 #define bRxSettle_LNA 0x38 #define bRxSettle_RSSI 0x1c0 #define bRxSettle_BBP 0xe00 #define bRxSettle_RxHP 0x7000 #define <API key> 0x38000 #define bRxSettle_AntSW 0xc0000 #define bRxProcessTime_DAGC 0x300000 #define bRxSettle_HSSI 0x400000 #define <API key> 0x800000 #define <API key> 0x3000000 #define bRSSITableSelect 0xc000000 #define bRxHP_Final 0x7000000 #define bRxHTSettle_BBP 0x7 #define bRxHTSettle_HSSI 0x8 #define bRxHTSettle_RxHP 0x70 #define bRxHTSettle_BBPPW 0x80 #define bRxHTSettle_Idle 0x300 #define <API key> 0x1c00 #define bRxHTRxHPEn 0x8000 #define bRxHTAGCFreezeThres 0x30000 #define bRxHTAGCTogetherEn 0x40000 #define bRxHTAGCMin 0x80000 #define bRxHTAGCEn 0x100000 #define bRxHTDAGCEn 0x200000 #define bRxHTRxHP_BBP 0x1c00000 #define bRxHTRxHP_Final 0xe0000000 #define bRxPWRatioTH 0x3 #define bRxPWRatioEn 0x4 #define bRxMFHold 0x3800 #define bRxPD_Delay_TH1 0x38 #define bRxPD_Delay_TH2 0x1c0 #define bRxPD_DC_COUNT_MAX 0x600 //#define bRxMF_Hold 0x3800 #define bRxPD_Delay_TH 0x8000 #define bRxProcess_Delay 0xf0000 #define <API key> 0x700000 #define <API key> 0x3800000 #define bRxSGI_Guard_L 0xc000000 #define bRxSGI_Search_L 0x30000000 #define bRxSGI_TH 0xc0000000 #define bDFSCnt0 0xff #define bDFSCnt1 0xff00 #define bDFSFlag 0xf0000 #define bMFWeightSum 0x300000 #define bMinIdxTH 0x7f000000 #define bDAFormat 0x40000 #define bTxChEmuEnable 0x01000000 #define bTRSWIsolation_A 0x7f #define bTRSWIsolation_B 0x7f00 #define bTRSWIsolation_C 0x7f0000 #define bTRSWIsolation_D 0x7f000000 #define bExtLNAGain 0x7c00 // 6. PageE(0xE00) #define bSTBCEn 0x4 // Useless #define bAntennaMapping 0x10 #define bNss 0x20 #define bCFOAntSumD 0x200 #define bPHYCounterReset 0x8000000 #define bCFOReportGet 0x4000000 #define bOFDMContinueTx 0x10000000 #define bOFDMSingleCarrier 0x20000000 #define bOFDMSingleTone 0x40000000 //#define bRxPath1 0x01 //#define bRxPath2 0x02 //#define bRxPath3 0x04 //#define bRxPath4 0x08 //#define bTxPath1 0x10 //#define bTxPath2 0x20 #define bHTDetect 0x100 #define bCFOEn 0x10000 #define bCFOValue 0xfff00000 #define bSigTone_Re 0x3f #define bSigTone_Im 0x7f00 #define bCounter_CCA 0xffff #define bCounter_ParityFail 0xffff0000 #define <API key> 0xffff #define bCounter_CRC8Fail 0xffff0000 #define <API key> 0xffff #define bCounter_FastSync 0xffff #define bShortCFO 0xfff #define bShortCFOTLength 12 //total #define bShortCFOFLength 11 //fraction #define bLongCFO 0x7ff #define bLongCFOTLength 11 #define bLongCFOFLength 11 #define bTailCFO 0x1fff #define bTailCFOTLength 13 #define bTailCFOFLength 12 #define bmax_en_pwdB 0xffff #define bCC_power_dB 0xffff0000 #define bnoise_pwdB 0xffff #define bPowerMeasTLength 10 #define bPowerMeasFLength 3 #define bRx_HT_BW 0x1 #define bRxSC 0x6 #define bRx_HT 0x8 #define bNB_intf_det_on 0x1 #define bIntf_win_len_cfg 0x30 #define bNB_Intf_TH_cfg 0x1c0 #define bRFGain 0x3f #define bTableSel 0x40 #define bTRSW 0x80 #define bRxSNR_A 0xff #define bRxSNR_B 0xff00 #define bRxSNR_C 0xff0000 #define bRxSNR_D 0xff000000 #define bSNREVMTLength 8 #define bSNREVMFLength 1 #define bCSI1st 0xff #define bCSI2nd 0xff00 #define bRxEVM1st 0xff0000 #define bRxEVM2nd 0xff000000 #define bSIGEVM 0xff #define bPWDB 0xff00 #define bSGIEN 0x10000 #define bSFactorQAM1 0xf // Useless #define bSFactorQAM2 0xf0 #define bSFactorQAM3 0xf00 #define bSFactorQAM4 0xf000 #define bSFactorQAM5 0xf0000 #define bSFactorQAM6 0xf0000 #define bSFactorQAM7 0xf00000 #define bSFactorQAM8 0xf000000 #define bSFactorQAM9 0xf0000000 #define bCSIScheme 0x100000 #define bNoiseLvlTopSet 0x3 // Useless #define bChSmooth 0x4 #define bChSmoothCfg1 0x38 #define bChSmoothCfg2 0x1c0 #define bChSmoothCfg3 0xe00 #define bChSmoothCfg4 0x7000 #define bMRCMode 0x800000 #define bTHEVMCfg 0x7000000 #define bLoopFitType 0x1 // Useless #define bUpdCFO 0x40 #define bUpdCFOOffData 0x80 #define bAdvUpdCFO 0x100 #define bAdvTimeCtrl 0x800 #define bUpdClko 0x1000 #define bFC 0x6000 #define bTrackingMode 0x8000 #define bPhCmpEnable 0x10000 #define bUpdClkoLTF 0x20000 #define bComChCFO 0x40000 #define bCSIEstiMode 0x80000 #define bAdvUpdEqz 0x100000 #define bUChCfg 0x7000000 #define bUpdEqz 0x8000000 #define bTxAGCRate18_06 0x7f7f7f7f // Useless #define bTxAGCRate54_24 0x7f7f7f7f #define bTxAGCRateMCS32 0x7f #define bTxAGCRateCCK 0x7f00 #define bTxAGCRateMCS3_MCS0 0x7f7f7f7f #define bTxAGCRateMCS7_MCS4 0x7f7f7f7f #define <API key> 0x7f7f7f7f #define <API key> 0x7f7f7f7f //Rx Pseduo noise #define bRxPesudoNoiseOn 0x20000000 // Useless #define bRxPesudoNoise_A 0xff #define bRxPesudoNoise_B 0xff00 #define bRxPesudoNoise_C 0xff0000 #define bRxPesudoNoise_D 0xff000000 #define bPesudoNoiseState_A 0xffff #define bPesudoNoiseState_B 0xffff0000 #define bPesudoNoiseState_C 0xffff #define bPesudoNoiseState_D 0xffff0000 //7. RF Register //Zebra1 #define bZebra1_HSSIEnable 0x8 // Useless #define bZebra1_TRxControl 0xc00 #define <API key> 0x07f #define bZebra1_RxCorner 0xc00 #define <API key> 0x38 #define <API key> 0x7 #define bZebra1_ChannelNum 0xf80 #define bZebra1_TxLPFBW 0x400 #define bZebra1_RxLPFBW 0x600 //Zebra4 #define <API key> 0x100 // Useless #define <API key> 0x40 #define bRTL8256_TxLPFBW 0x18 #define bRTL8256_RxLPFBW 0x600 //RTL8258 #define bRTL8258_TxLPFBW 0xc // Useless #define bRTL8258_RxLPFBW 0xc00 #define bRTL8258_RSSILPFBW 0xc0 // Other Definition //byte endable for sb_write #define bByte0 0x1 // Useless #define bByte1 0x2 #define bByte2 0x4 #define bByte3 0x8 #define bWord0 0x3 #define bWord1 0xc #define bDWord 0xf //for PutRegsetting & GetRegSetting BitMask #define bMaskByte0 0xff // Reg 0xc50 rOFDM0_XAAGCCore~0xC6f #define bMaskByte1 0xff00 #define bMaskByte2 0xff0000 #define bMaskByte3 0xff000000 #define bMaskHWord 0xffff0000 #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff //for PutRFRegsetting & GetRFRegSetting BitMask #if (RTL92SE_FPGA_VERIFY == 1) //#define bMask12Bits 0xfff // RF Reg mask bits //#define bMask20Bits 0xfff // RF Reg mask bits T65 RF #define bRFRegOffsetMask 0xfff #else //#define bMask12Bits 0xfffff // RF Reg mask bits //#define bMask20Bits 0xfffff // RF Reg mask bits T65 RF #define bRFRegOffsetMask 0xfffff #endif #define bEnable 0x1 // Useless #define bDisable 0x0 #define LeftAntenna 0x0 // Useless #define RightAntenna 0x1 #define tCheckTxStatus 500 //500ms // Useless #define tUpdateRxCounter 100 //100ms #define rateCCK 0 // Useless #define rateOFDM 1 #define rateHT 2 //define Register-End #define bPMAC_End 0x1ff // Useless #define bFPGAPHY0_End 0x8ff #define bFPGAPHY1_End 0x9ff #define bCCKPHY0_End 0xaff #define bOFDMPHY0_End 0xcff #define bOFDMPHY1_End 0xdff //define max debug item in each debug page //#define bMaxItem_FPGA_PHY0 0x9 //#define bMaxItem_FPGA_PHY1 0x3 //#define bMaxItem_PHY_11B 0x16 //#define bMaxItem_OFDM_PHY0 0x29 //#define bMaxItem_OFDM_PHY1 0x0 #define bPMACControl 0x0 // Useless #define bWMACControl 0x1 #define bWNICControl 0x2 #define ANTENNA_A 0x1 // Useless #define ANTENNA_B 0x2 #define ANTENNA_AB 0x3 // ANTENNA_A |ANTENNA_B #define ANTENNA_C 0x4 #define ANTENNA_D 0x8 #define RCR_AAP BIT(0) // accept all physical address #define RCR_APM BIT(1) // accept physical match #define RCR_AM BIT(2) // accept multicast #define RCR_AB BIT(3) // accept broadcast #define RCR_ACRC32 BIT(5) // accept error packet #define RCR_9356SEL BIT(6) #define RCR_AICV BIT(12) // Accept ICV error packet #define RCR_RXFTH0 (BIT(13)|BIT(14)|BIT(15)) // Rx FIFO threshold #define RCR_ADF BIT(18) // Accept Data(frame type) frame #define RCR_ACF BIT(19) // Accept control frame #define RCR_AMF BIT(20) // Accept management frame #define RCR_ADD3 BIT(21) #define RCR_APWRMGT BIT(22) // Accept power management packet #define RCR_CBSSID BIT(23) // Accept BSSID match packet #define RCR_ENMARP BIT(28) // enable mac auto reset phy #define RCR_EnCS1 BIT(29) // enable carrier sense method 1 #define RCR_EnCS2 BIT(30) // enable carrier sense method 2 #define RCR_OnlyErlPkt BIT(31) // Rx Early mode is performed for packet size greater than 1536 #endif //<API key>
#include "chrome/browser/notifications/<API key>.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/ui/views/notifications/balloon_view.h" #include "ui/gfx/rect.h" Balloon* <API key>::MakeBalloon(const Notification& notification, Profile* profile) { Balloon* balloon = new Balloon(notification, profile, this); balloon->set_view(new BalloonViewImpl(this)); gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height()); balloon->set_content_size(size); return balloon; } int <API key>::Layout::InterBalloonMargin() const { return 3; } int <API key>::Layout::<API key>() const { return 2; } int <API key>::Layout::VerticalEdgeMargin() const { return 0; } void <API key>::PositionBalloons(bool reposition) { <API key>(reposition); } void <API key>::DidProcessMessage(const MSG& msg) { switch (msg.message) { case WM_MOUSEMOVE: case WM_MOUSELEAVE: case WM_NCMOUSELEAVE: <API key>(); break; } } bool <API key>::<API key>() const { DWORD pos = GetMessagePos(); gfx::Point cursor(pos); return <API key>().Contains(cursor); } void <API key>::<API key>( PositionPreference position) { if (position == DEFAULT_POSITION) position = LOWER_RIGHT; // All positioning schemes are vertical, and windows // uses the normal screen orientation. if (position == UPPER_RIGHT) layout_.set_placement(Layout::<API key>); else if (position == UPPER_LEFT) layout_.set_placement(Layout::<API key>); else if (position == LOWER_LEFT) layout_.set_placement(Layout::<API key>); else if (position == LOWER_RIGHT) layout_.set_placement(Layout::<API key>); else NOTREACHED(); PositionBalloons(true); } // static BalloonCollection* BalloonCollection::Create() { return new <API key>(); }
require 'typhoeus/hydra/addable' require 'typhoeus/hydra/before' require 'typhoeus/hydra/cacheable' require 'typhoeus/hydra/block_connection' require 'typhoeus/hydra/memoizable' require 'typhoeus/hydra/queueable' require 'typhoeus/hydra/runnable' require 'typhoeus/hydra/stubbable' module Typhoeus # Hydra manages making parallel HTTP requests. This # is achieved by using libcurls multi interface: # The benefits are that you don't have to worry running # the requests by yourself. # Hydra will also handle how many requests you can # make in parallel. Things will get flakey if you # try to make too many requests at the same time. # The built in limit is 200. When more requests than # that are queued up, hydra will save them for later # and start the requests as others are finished. You # can raise or lower the concurrency limit through # the Hydra constructor. # Regarding the asynchronous behavior of the hydra, # it is important to know that this is completely hidden # from the developer and you are free to apply # whatever technique you want to your code. That should not # conflict with libcurls internal concurrency mechanism. # @example Use the hydra to do multiple requests. # hydra = Typhoeus::Hydra.new # requests.each{ |request| hydra.queue(request) } # hydra.run # @note Callbacks are going to delay the request # execution. class Hydra include Hydra::Addable include Hydra::Runnable include Hydra::Memoizable include Hydra::Cacheable include Hydra::BlockConnection include Hydra::Stubbable include Hydra::Before include Hydra::Queueable # @example Set max_concurrency. # Typhoeus::Hydra.new(max_concurrency: 20) attr_accessor :max_concurrency # @api private attr_reader :multi class << self # Returns a memoized hydra instance. # @example Get a hydra. # Typhoeus::Hydra.hydra # @return [Typhoeus::Hydra] A new hydra. def hydra Thread.current[:typhoeus_hydra] ||= new end end # Create a new hydra. All # options are also available. # @example Create a hydra. # Typhoeus::Hydra.new # @example Create a hydra with max_concurrency. # Typhoeus::Hydra.new(max_concurrency: 20) # @param [ Hash ] options The options hash. # @option options :max_concurrency [ Integer ] Number # of max concurrent connections to create. Default is # 200. # Ethon::Multi#initialize def initialize(options = {}) @options = options @max_concurrency = @options.fetch(:max_concurrency, 200) @multi = Ethon::Multi.new(options.reject{|k,_| k==:max_concurrency}) end end end
#ifndef <API key> #define <API key> namespace Catch { // ResultWas::OfType enum struct ResultWas { enum OfType { Unknown = -1, Ok = 0, Info = 1, Warning = 2, FailureBit = 0x10, ExpressionFailed = FailureBit | 1, ExplicitFailure = FailureBit | 2, Exception = 0x100 | FailureBit, ThrewException = Exception | 1, DidntThrowException = Exception | 2, FatalErrorCondition = 0x200 | FailureBit }; }; inline bool isOk( ResultWas::OfType resultType ) { return ( resultType & ResultWas::FailureBit ) == 0; } inline bool isJustInfo( int flags ) { return flags == ResultWas::Info; } // ResultDisposition::Flags enum struct ResultDisposition { enum Flags { Normal = 0x01, ContinueOnFailure = 0x02, // Failures fail test, but execution continues FalseTest = 0x04, // Prefix expression with ! SuppressFail = 0x08 // Failures are reported but do not fail the test }; }; inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) ); } inline bool <API key>( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } inline bool <API key>( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } } // end namespace Catch #endif // <API key>
<?php App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; /** * <API key> class * * @package Cake.Test.Case.Model.Behavior */ class <API key> extends CakeTestCase { /** * Whether backup global state for each test method or not * * @var bool */ public $backupGlobals = false; /** * settings property * * @var array */ public $settings = array( 'modelClass' => 'NumberTree', 'leftField' => 'lft', 'rightField' => 'rght', 'parentField' => 'parent_id' ); /** * fixtures property * * @var array */ public $fixtures = array('core.number_tree', 'core.person'); /** * testInitialize method * * @return void */ public function testInitialize() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->find('count'); $this->assertEquals(7, $result); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); $save[$modelClass]['id'] = $result[$modelClass]['id']; $save[$modelClass][$leftField] = 0; $this->Tree->create(); $this->Tree->save($save); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); $save[$modelClass]['id'] = $result[$modelClass]['id']; $save[$modelClass][$rightField] = 0; $this->Tree->create(); $this->Tree->save($save); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); // Bypass behavior and any other logic $this->Tree->updateAll(array($parentField => null), array('id' => $result[$modelClass]['id'])); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover('MPTT'); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); $this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0)); $node1 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0)); $node11 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0)); $node12 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0)); $this->Tree->create(); $this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0)); $this->Tree->Behaviors->enable('Tree'); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); $result = $this->Tree->find('first', array( 'fields' => array('name', $parentField, $leftField, $rightField), 'conditions' => array('name' => 'Main'), 'recursive' => -1 )); $expected = array( $modelClass => array( 'name' => 'Main', $parentField => null, $leftField => 1, $rightField => 10 ) ); $this->assertEquals($expected, $result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); $this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0)); $node1 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0)); $node11 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0)); $node12 = $this->Tree->id; $this->Tree->create(); $this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0)); $this->Tree->create(); $this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0)); $this->Tree->create(); $this->Tree->save(array('name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0)); $this->Tree->Behaviors->enable('Tree'); $this->Tree->bindModel(array('belongsTo' => array('Parent' => array( 'className' => $this->Tree->name, 'foreignKey' => $parentField )))); $this->Tree->bindModel(array('hasMany' => array('Child' => array( 'className' => $this->Tree->name, 'foreignKey' => $parentField )))); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $count = $this->Tree->find('count'); $this->assertEquals(6, $count); $result = $this->Tree->recover('parent', 'delete'); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); $count = $this->Tree->find('count'); $this->assertEquals(5, $count); $result = $this->Tree->find('first', array( 'fields' => array('name', $parentField, $leftField, $rightField), 'conditions' => array('name' => 'Main'), 'recursive' => -1 )); $expected = array( $modelClass => array( 'name' => 'Main', $parentField => null, $leftField => 1, $rightField => 10 ) ); $this->assertEquals($expected, $result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->updateAll(array($parentField => null)); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->updateAll(array($leftField => 0, $rightField => 0)); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $this->Tree->recover(); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * Reproduces a situation where a single node has lft= rght, and all other lft and rght fields follow sequentially * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 3); $result = $this->Tree->findByName('1.1'); $this->Tree->updateAll(array($rightField => $result[$modelClass][$leftField]), array('id' => $result[$modelClass]['id'])); $this->Tree->updateAll(array($leftField => $this->Tree->escapeField($leftField) . ' -1'), array($leftField . ' >' => $result[$modelClass][$leftField])); $this->Tree->updateAll(array($rightField => $this->Tree->escapeField($rightField) . ' -1'), array($rightField . ' >' => $result[$modelClass][$leftField])); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); $result = $this->Tree->recover(); $this->assertTrue($result); $result = $this->Tree->verify(); $this->assertTrue($result); } /** * testAddOrphan method * * @return void */ public function testAddOrphan() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->create(); $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null)); $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testAddMiddle method * * @return void */ public function testAddMiddle() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $initialCount = $this->Tree->find('count'); $this->Tree->create(); $result = $this->Tree->save(array($modelClass => array('name' => 'testAddMiddle', $parentField => $data[$modelClass]['id']))); $expected = array_merge(array($modelClass => array('name' => 'testAddMiddle', $parentField => '2')), $result); $this->assertSame($expected, $result); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount + 1, $laterCount); $children = $this->Tree->children($data[$modelClass]['id'], true, array('name')); $expected = array(array($modelClass => array('name' => '1.1.1')), array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => 'testAddMiddle'))); $this->assertSame($expected, $children); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array( 'fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1') )); $this->Tree->create(); $result = $this->Tree->save(array($modelClass => array( 'id' => 100, 'name' => 'testAddMiddle', $parentField => $data[$modelClass]['id']) )); $expected = array_merge( array($modelClass => array('id' => 100, 'name' => 'testAddMiddle', $parentField => '2')), $result ); $this->assertSame($expected, $result); $this->assertTrue($this->Tree->verify()); } /** * testAddInvalid method * * @return void */ public function testAddInvalid() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $initialCount = $this->Tree->find('count'); //$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave'); $this->Tree->create(); $saveSuccess = $this->Tree->save(array($modelClass => array('name' => 'testAddInvalid', $parentField => 99999))); $this->assertFalse($saveSuccess); $laterCount = $this->Tree->find('count'); $this->assertSame($initialCount, $laterCount); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->create(); $this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null)); $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null)); $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testMovePromote method * * @return void */ public function testMovePromote() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parentId = $parent[$modelClass]['id']; $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); $direct = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); $this->assertEquals($expected, $direct); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parentId = $parent[$modelClass]['id']; $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->whitelist = array($parentField, 'name', 'description'); $this->Tree->saveField($parentField, $parentId); $result = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); $this->assertEquals($expected, $result); $this->assertTrue($this->Tree->verify()); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->whitelist = array('name', $parentField); $this->Tree->create(); $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); $result = $this->Tree->findByName('testAddOrphan', array('name', $parentField, $leftField, $rightField)); $expected = array('name' => 'testAddOrphan', $parentField => null, $leftField => '15', $rightField => 16); $this->assertEquals($expected, $result[$modelClass]); $this->assertTrue($this->Tree->verify()); } /** * testMoveBefore method * * @return void */ public function testMoveBefore() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $parentId = $parent[$modelClass]['id']; $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); $result = $this->Tree->children($parentId, true, array('name')); $expected = array(array($modelClass => array('name' => '1.1.1')), array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => '1.2'))); $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testMoveAfter method * * @return void */ public function testMoveAfter() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $parentId = $parent[$modelClass]['id']; $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); $result = $this->Tree->children($parentId, true, array('name')); $expected = array(array($modelClass => array('name' => '1.2.1')), array($modelClass => array('name' => '1.2.2')), array($modelClass => array('name' => '1.1'))); $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parentId = $parent[$modelClass]['id']; $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $expected = $this->Tree->find('all'); $before = $this->Tree->read(null, $data[$modelClass]['id']); $this->Tree->id = $parentId; $this->Tree->saveField($parentField, $data[$modelClass]['id']); $results = $this->Tree->find('all'); $after = $this->Tree->read(null, $data[$modelClass]['id']); $this->assertEquals($expected, $results); $this->assertEquals($before, $after); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testMoveInvalid method * * @return void */ public function testMoveInvalid() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $initialCount = $this->Tree->find('count'); $data = $this->Tree->findByName('1.1'); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, 999999); $laterCount = $this->Tree->find('count'); $this->assertSame($initialCount, $laterCount); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testMoveSelfInvalid method * * @return void */ public function testMoveSelfInvalid() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->id = null; $initialCount = $this->Tree->find('count'); $data = $this->Tree->findByName('1.1'); $this->Tree->id = $data[$modelClass]['id']; $saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id); $this->assertFalse($saveSuccess); $laterCount = $this->Tree->find('count'); $this->assertSame($initialCount, $laterCount); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testMoveUpSuccess method * * @return void */ public function testMoveUpSuccess() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->moveUp($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array(array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.1'))); $this->assertSame($expected, $result); } /** * testMoveUpFail method * * @return void */ public function testMoveUpFail() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveUp($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array(array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2'))); $this->assertSame($expected, $result); } /** * testMoveUp2 method * * @return void */ public function testMoveUp2() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveUp($data[$modelClass]['id'], 2); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array( array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.5')), array($modelClass => array('name' => '1.3')), array($modelClass => array('name' => '1.4')), array($modelClass => array('name' => '1.6')), array($modelClass => array('name' => '1.7')), array($modelClass => array('name' => '1.8')), array($modelClass => array('name' => '1.9')), array($modelClass => array('name' => '1.10'))); $this->assertSame($expected, $result); } /** * testMoveUpFirst method * * @return void */ public function testMoveUpFirst() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveUp($data[$modelClass]['id'], true); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array( array($modelClass => array('name' => '1.5')), array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.3')), array($modelClass => array('name' => '1.4')), array($modelClass => array('name' => '1.6')), array($modelClass => array('name' => '1.7')), array($modelClass => array('name' => '1.8')), array($modelClass => array('name' => '1.9')), array($modelClass => array('name' => '1.10'))); $this->assertSame($expected, $result); } /** * testMoveDownSuccess method * * @return void */ public function testMoveDownSuccess() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveDown($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array(array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.1'))); $this->assertSame($expected, $result); } /** * testMoveDownFail method * * @return void */ public function testMoveDownFail() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->moveDown($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array(array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2'))); $this->assertSame($expected, $result); } /** * testMoveDownLast method * * @return void */ public function testMoveDownLast() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveDown($data[$modelClass]['id'], true); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array( array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.3')), array($modelClass => array('name' => '1.4')), array($modelClass => array('name' => '1.6')), array($modelClass => array('name' => '1.7')), array($modelClass => array('name' => '1.8')), array($modelClass => array('name' => '1.9')), array($modelClass => array('name' => '1.10')), array($modelClass => array('name' => '1.5'))); $this->assertSame($expected, $result); } /** * testMoveDown2 method * * @return void */ public function testMoveDown2() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveDown($data[$modelClass]['id'], 2); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array( array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.3')), array($modelClass => array('name' => '1.4')), array($modelClass => array('name' => '1.6')), array($modelClass => array('name' => '1.7')), array($modelClass => array('name' => '1.5')), array($modelClass => array('name' => '1.8')), array($modelClass => array('name' => '1.9')), array($modelClass => array('name' => '1.10'))); $this->assertSame($expected, $result); } /** * testSaveNoMove method * * @return void */ public function testSaveNoMove() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField('name', 'renamed'); $parent = $this->Tree->findByName('1. Root', array('id')); $this->Tree->id = $parent[$modelClass]['id']; $result = $this->Tree->children(null, true, array('name')); $expected = array( array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.3')), array($modelClass => array('name' => '1.4')), array($modelClass => array('name' => 'renamed')), array($modelClass => array('name' => '1.6')), array($modelClass => array('name' => '1.7')), array($modelClass => array('name' => '1.8')), array($modelClass => array('name' => '1.9')), array($modelClass => array('name' => '1.10'))); $this->assertSame($expected, $result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 1); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->save(array($parentField => null)); $result = $this->Tree->verify(); $this->assertTrue($result); $this->Tree->moveUp(); $result = $this->Tree->find('all', array('fields' => 'name', 'order' => $modelClass . '.' . $leftField . ' ASC')); $expected = array(array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1. Root'))); $this->assertSame($expected, $result); } /** * testDelete method * * @return void */ public function testDelete() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1.1'); $return = $this->Tree->delete($result[$modelClass]['id']); $this->assertEquals(true, $return); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1'); $return = $this->Tree->delete($result[$modelClass]['id']); $this->assertEquals(true, $return); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 2, $laterCount); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * Test deleting a record that doesn't exist. * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $this->Tree->delete(99999); } /** * testRemove method * * @return void */ public function testRemove() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1'); $this->Tree->removeFromTree($result[$modelClass]['id']); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount, $laterCount); $children = $this->Tree->children($result[$modelClass][$parentField], true, array('name')); $expected = array(array($modelClass => array('name' => '1.1.1')), array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => '1.2'))); $this->assertEquals($expected, $children); $topNodes = $this->Tree->children(false, true, array('name')); $expected = array(array($modelClass => array('name' => '1. Root')), array($modelClass => array('name' => '1.1'))); $this->assertEquals($expected, $topNodes); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $initialTopNodes = $this->Tree->childCount(false); $result = $this->Tree->findByName('1. Root'); $this->Tree->removeFromTree($result[$modelClass]['id']); $laterCount = $this->Tree->find('count'); $laterTopNodes = $this->Tree->childCount(false); $this->assertEquals($initialCount, $laterCount); $this->assertEquals($initialTopNodes, $laterTopNodes); $topNodes = $this->Tree->children(false, true, array('name')); $expected = array(array($modelClass => array('name' => '1.1')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1. Root'))); $this->assertEquals($expected, $topNodes); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1.1'); $this->Tree->removeFromTree($result[$modelClass]['id']); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount, $laterCount); $nodes = $this->Tree->find('list', array('order' => $leftField)); $expected = array( 1 => '1. Root', 2 => '1.1', 4 => '1.1.2', 5 => '1.2', 6 => '1.2.1', 7 => '1.2.2', 3 => '1.1.1', ); $this->assertEquals($expected, $nodes); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testRemoveAndDelete method * * @return void */ public function testRemoveAndDelete() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1'); $this->Tree->removeFromTree($result[$modelClass]['id'], true); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); $children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc'); $expected = array( array($modelClass => array('name' => '1.1.1')), array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => '1.2')) ); $this->assertEquals($expected, $children); $topNodes = $this->Tree->children(false, true, array('name')); $expected = array(array($modelClass => array('name' => '1. Root'))); $this->assertEquals($expected, $topNodes); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $initialCount = $this->Tree->find('count'); $result = $this->Tree->findByName('1.1.1'); $this->Tree->removeFromTree($result[$modelClass]['id'], true); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); $nodes = $this->Tree->find('list', array('order' => $leftField)); $expected = array( 1 => '1. Root', 2 => '1.1', 4 => '1.1.2', 5 => '1.2', 6 => '1.2.1', 7 => '1.2.2', ); $this->assertEquals($expected, $nodes); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); } /** * testChildren method * * @return void */ public function testChildren() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13))); $this->assertEquals($expected, $direct); $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)), array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)), array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)), array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12))); $this->assertEquals($expected, $total); $this->assertEquals(array(), $this->Tree->children(10000)); } /** * testCountChildren method * * @return void */ public function testCountChildren() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->childCount(null, true); $this->assertEquals(2, $direct); $total = $this->Tree->childCount(); $this->assertEquals(6, $total); $this->Tree->read(null, $data[$modelClass]['id']); $id = $this->Tree->field('id', array($modelClass . '.name' => '1.2')); $total = $this->Tree->childCount($id); $this->assertEquals(2, $total); } /** * testGetParentNode method * * @return void */ public function testGetParentNode() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $this->Tree->id = $data[$modelClass]['id']; $result = $this->Tree->getParentNode(null, array('name')); $expected = array($modelClass => array('name' => '1.2')); $this->assertSame($expected, $result); } /** * testGetPath method * * @return void */ public function testGetPath() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $this->Tree->id = $data[$modelClass]['id']; $result = $this->Tree->getPath(null, array('name')); $expected = array(array($modelClass => array('name' => '1. Root')), array($modelClass => array('name' => '1.2')), array($modelClass => array('name' => '1.2.2'))); $this->assertSame($expected, $result); } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->bindModel(array('belongsTo' => array('Dummy' => array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); $this->Tree->initialize(2, 2); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13))); $this->assertEquals($expected, $direct); $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField)); $expected = array( array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)), array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)), array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)), array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12)) ); $this->assertEquals($expected, $total); } /** * testReorderTree method * * @return void */ public function testReorderTree() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(3, 3); $nodes = $this->Tree->find('list', array('order' => $leftField)); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveDown($data[$modelClass]['id']); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2.1'))); $this->Tree->moveDown($data[$modelClass]['id']); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.3.2.2'))); $this->Tree->moveDown($data[$modelClass]['id']); $unsortedNodes = $this->Tree->find('list', array('order' => $leftField)); $this->assertEquals($nodes, $unsortedNodes); $this->assertNotEquals(array_keys($nodes), array_keys($unsortedNodes)); $this->Tree->reorder(); $sortedNodes = $this->Tree->find('list', array('order' => $leftField)); $this->assertSame($nodes, $sortedNodes); } /** * test reordering large-ish trees with cacheQueries = true. * This caused infinite loops when moving down elements as stale data is returned * from the memory cache * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 10); $original = $this->Tree->cacheQueries; $this->Tree->cacheQueries = true; $this->Tree->reorder(array('field' => 'name', 'direction' => 'DESC')); $this->assertTrue($this->Tree->cacheQueries, 'cacheQueries was not restored after reorder(). %s'); $this->Tree->cacheQueries = $original; } /** * <API key> method * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->bindModel(array('belongsTo' => array('Dummy' => array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); $this->Tree->initialize(2, 2); $result = $this->Tree->generateTreeList(); $expected = array(1 => '1. Root', 2 => '_1.1', 3 => '__1.1.1', 4 => '__1.1.2', 5 => '_1.2', 6 => '__1.2.1', 7 => '__1.2.2'); $this->assertSame($expected, $result); } /** * Test the formatting options of generateTreeList() * * @return void */ public function <API key>() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); $result = $this->Tree->generateTreeList( null, "{n}.$modelClass.id", array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name") ); $this->assertEquals('1 - 1. Root', $result[1]); $this->assertEquals('_2 - 1.1', $result[2]); $this->assertEquals('__3 - 1.1.1', $result[3]); } /** * testArraySyntax method * * @return void */ public function testArraySyntax() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(3, 3); $this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2))); $this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2))); $this->assertSame($this->Tree->getPath(4), $this->Tree->getPath(array('id' => 4))); } /** * testFindThreaded method * * @return void */ public function testFindThreaded() { $Model = new Person(); $Model->recursive = -1; $Model->Behaviors->load('Tree', array('parent' => 'mother_id')); $result = $Model->find('threaded'); $expected = array( array( 'Person' => array( 'id' => '4', 'name' => 'mother - grand mother', 'mother_id' => '0', 'father_id' => '0' ), 'children' => array( array( 'Person' => array( 'id' => '2', 'name' => 'mother', 'mother_id' => '4', 'father_id' => '5' ), 'children' => array( array( 'Person' => array( 'id' => '1', 'name' => 'person', 'mother_id' => '2', 'father_id' => '3' ), 'children' => array() ) ) ) ) ), array( 'Person' => array( 'id' => '5', 'name' => 'mother - grand father', 'mother_id' => '0', 'father_id' => '0' ), 'children' => array() ), array( 'Person' => array( 'id' => '6', 'name' => 'father - grand mother', 'mother_id' => '0', 'father_id' => '0' ), 'children' => array( array( 'Person' => array( 'id' => '3', 'name' => 'father', 'mother_id' => '6', 'father_id' => '7' ), 'children' => array() ) ) ), array( 'Person' => array( 'id' => '7', 'name' => 'father - grand father', 'mother_id' => '0', 'father_id' => '0' ), 'children' => array() ) ); $this->assertEquals($expected, $result); } }
#ifndef I40IW_OSDEP_H #define I40IW_OSDEP_H #include <linux/kernel.h> #include <linux/string.h> #include <linux/bitops.h> #include <net/tcp.h> #include <crypto/hash.h> /* get readq/writeq support for 32 bit kernels, use the low-first version */ #include <linux/<API key>.h> #define STATS_TIMER_DELAY 1000 static inline void set_64bit_val(u64 *wqe_words, u32 byte_index, u64 value) { wqe_words[byte_index >> 3] = value; } /** * set_32bit_val - set 32 value to hw wqe * @wqe_words: wqe addr to write * @byte_index: index in wqe * @value: value to write **/ static inline void set_32bit_val(u32 *wqe_words, u32 byte_index, u32 value) { wqe_words[byte_index >> 2] = value; } /** * get_64bit_val - read 64 bit value from wqe * @wqe_words: wqe addr * @byte_index: index to read from * @value: read value **/ static inline void get_64bit_val(u64 *wqe_words, u32 byte_index, u64 *value) { *value = wqe_words[byte_index >> 3]; } /** * get_32bit_val - read 32 bit value from wqe * @wqe_words: wqe addr * @byte_index: index to reaad from * @value: return 32 bit value **/ static inline void get_32bit_val(u32 *wqe_words, u32 byte_index, u32 *value) { *value = wqe_words[byte_index >> 2]; } struct i40iw_dma_mem { void *va; dma_addr_t pa; u32 size; } __packed; struct i40iw_virt_mem { void *va; u32 size; } __packed; #define i40iw_debug(h, m, s, ...) \ do { \ if (((m) & (h)->debug_mask)) \ pr_info("i40iw " s, ##__VA_ARGS__); \ } while (0) #define i40iw_flush(a) readl((a)->hw_addr + I40E_GLGEN_STAT) #define I40E_GLHMC_VFSDCMD(_i) (0x000C8000 + ((_i) * 4)) \ /* _i=0...31 */ #define <API key> 31 #define <API key> 0 #define <API key> (0xFFF \ << <API key>) #define <API key> 16 #define <API key> (0xF << <API key>) #define <API key> 20 #define <API key> (0x1FF << <API key>) #define <API key> 29 #define <API key> (0x3 \ << <API key>) #define <API key> 31 #define <API key> (0x1 << <API key>) #define <API key>(_i) (0x000C8200 + ((_i) * 4)) \ /* _i=0...31 */ #define <API key> 31 #define <API key> 0 #define <API key> (0xFFFFFFFF \ << <API key>) #define <API key>(_i) (0x000C8100 + ((_i) * 4)) \ /* _i=0...31 */ #define <API key> 31 #define <API key> 0 #define <API key> (0x1 \ << <API key>) #define <API key> 1 #define <API key> (0x1 \ << <API key>) #define <API key> 2 #define <API key> (0x3FF \ << <API key>) #define <API key> 12 #define <API key> (0xFFFFF \ << <API key>) #define <API key> 0x0000D200 #define <API key> 0 #define <API key> (0x1 \ << <API key>) #define <API key> 1 #define <API key> (0x1 << <API key>) #define <API key> 2 #define <API key> (0x1 \ << <API key>) #define <API key> 3 #define <API key> (0x1 \ << <API key>) #define <API key> 4 #define <API key> (0x1 \ << <API key>) struct i40iw_sc_dev; struct i40iw_sc_qp; struct i40iw_puda_buf; struct <API key>; struct <API key>; struct i40iw_hmc_fcn_info; struct <API key>; struct <API key>; struct i40iw_device; struct i40iw_hmc_info; struct i40iw_hw; u8 __iomem *i40iw_get_hw_addr(void *dev); void <API key>(struct i40iw_sc_dev *dev, struct i40iw_sc_qp *qp); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev); bool <API key>(struct i40iw_sc_dev *dev); enum i40iw_status_code <API key>(struct shash_desc *desc, void *addr, u32 length, u32 value); struct i40iw_sc_qp *i40iw_ieq_get_qp(struct i40iw_sc_dev *dev, struct i40iw_puda_buf *buf); void <API key>(struct i40iw_puda_buf *buf, u16 length, u32 seqnum); void <API key>(struct shash_desc *); enum i40iw_status_code <API key>(struct shash_desc **); enum i40iw_status_code <API key>(struct <API key> *info, struct i40iw_puda_buf *buf); enum i40iw_status_code i40iw_cqp_sds_cmd(struct i40iw_sc_dev *dev, struct <API key> *info); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev, struct i40iw_hmc_fcn_info *hmcfcninfo); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev, struct i40iw_dma_mem *values_mem, u8 hmc_fn_id); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev, struct i40iw_dma_mem *values_mem, u8 hmc_fn_id); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev, struct i40iw_dma_mem *mem); enum i40iw_status_code <API key>(struct i40iw_sc_dev *dev, struct <API key> *info); void <API key>(struct i40iw_sc_dev *dev, struct <API key> *work_info, u32 iw_vf_idx); void *i40iw_remove_head(struct list_head *list); void <API key>(struct i40iw_sc_dev *dev, struct i40iw_sc_qp *qp, bool suspend); void i40iw_qp_mss_modify(struct i40iw_sc_dev *dev, struct i40iw_sc_qp *qp); void <API key>(struct i40iw_sc_qp *qp, u8 next_state, u8 term, u8 term_len); void <API key>(struct i40iw_sc_qp *qp, int timeout_occurred); void <API key>(struct i40iw_sc_qp *qp); void <API key>(struct i40iw_sc_qp *qp); enum i40iw_status_code <API key>(struct i40iw_device *iwdev, struct <API key> *info, bool wait); struct i40iw_sc_vsi; void <API key>(struct i40iw_sc_vsi *vsi); void <API key>(struct i40iw_sc_vsi *vsi); #define i40iw_mmiowb() mmiowb() void i40iw_wr32(struct i40iw_hw *hw, u32 reg, u32 value); u32 i40iw_rd32(struct i40iw_hw *hw, u32 reg); #endif /* _I40IW_OSDEP_H_ */
/** * @fileOverview Defines the {@link CKEDITOR.dom} object, which contains DOM * manipulation objects and function. */ /** * DOM manipulation objects and function.<br /><br /> * @see CKEDITOR.dom.element * @see CKEDITOR.dom.node * @namespace * @example */ CKEDITOR.dom = {}; // PACKAGER_RENAME( CKEDITOR.dom )
using System; using System.Reflection; using System.Reflection.Emit; using Xunit; namespace System.Reflection.Emit.Tests { public class <API key> { [Fact] public void <API key>() { AssemblyName an = new AssemblyName(); an.Name = "<API key>"; AssemblyBuilder ab = AssemblyBuilder.<API key>(an, <API key>.Run); ModuleBuilder mb = TestLibrary.Utilities.GetModuleBuilder(ab, "Module1"); TypeBuilder tb = mb.DefineType("DynamicRandomClass", TypeAttributes.Public); Type[] parameterTypes = { typeof(int), typeof(double) }; ConstructorBuilder cb = tb.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, parameterTypes, null, null); Assert.Contains("Public", cb.Attributes.ToString()); } [Fact] public void <API key>() { AssemblyName an = new AssemblyName(); an.Name = "<API key>"; AssemblyBuilder ab = AssemblyBuilder.<API key>(an, <API key>.Run); ModuleBuilder mb = TestLibrary.Utilities.GetModuleBuilder(ab, "Module1"); TypeBuilder tb = mb.DefineType("DynamicRandomClass", TypeAttributes.Public); Type[] parameterTypes = { typeof(int), typeof(double) }; System.Reflection.Emit.ConstructorBuilder cb = tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, parameterTypes); Assert.Contains("Public", cb.Attributes.ToString()); } } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Login Page - Photon Admin Panel Theme</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <link rel="shortcut icon" href="favicon.ico.html"/> <link rel="apple-touch-icon" href="iosicon.png.html"/> <link rel="stylesheet" href="css/css_compiled/photon-min.css-v1.1.html" media="all"/> <link rel="stylesheet" href="css/css_compiled/photon-min-part2.css-v1.1.html" media="all"/> <link rel="stylesheet" href="css/css_compiled/<API key>.css-v1.1.html" media="all"/> <!--[if IE]> <link rel="stylesheet" type="text/css" href="css/css_compiled/ie-only-min.css?v1.1" /> <![endif] <!--[if lt IE 9]> <link rel="stylesheet" type="text/css" href="css/css_compiled/ie8-only-min.css?v1.1" /> <script type="text/javascript" src="js/plugins/excanvas.js"></script> <script type="text/javascript" src="js/plugins/html5shiv.js"></script> <script type="text/javascript" src="js/plugins/respond.min.js"></script> <script type="text/javascript" src="js/plugins/fixFontIcons.js"></script> <![endif] <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script> <script type="text/javascript" src="js/bootstrap/bootstrap.min.js.html"></script> <script type="text/javascript" src="js/plugins/modernizr.custom.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.pnotify.min.js.html"></script> <script type="text/javascript" src="js/plugins/less-1.3.1.min.js.html"></script> <script type="text/javascript" src="js/plugins/xbreadcrumbs.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.maskedinput-1.3.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.autotab-1.1b.js.html"></script> <script type="text/javascript" src="js/plugins/charCount.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.textareaCounter.js.html"></script> <script type="text/javascript" src="js/plugins/elrte.min.js.html"></script> <script type="text/javascript" src="js/plugins/elrte.en.js.html"></script> <script type="text/javascript" src="js/plugins/select2.js.html"></script> <script type="text/javascript" src="js/plugins/jquery-picklist.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.validate.min.js.html"></script> <script type="text/javascript" src="js/plugins/additional-methods.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.form.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.metadata.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.mockjax.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.uniform.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.tagsinput.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.rating.pack.js.html"></script> <script type="text/javascript" src="js/plugins/farbtastic.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.timeentry.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.dataTables.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.jstree.js.html"></script> <script type="text/javascript" src="js/plugins/dataTables.bootstrap.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.mousewheel.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.mCustomScrollbar.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.flot.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.flot.stack.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.flot.pie.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.flot.resize.js.html"></script> <script type="text/javascript" src="js/plugins/raphael.2.1.0.min.js.html"></script> <script type="text/javascript" src="js/plugins/justgage.1.0.1.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.qrcode.min.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.clock.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.countdown.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.jqtweet.js.html"></script> <script type="text/javascript" src="js/plugins/jquery.cookie.js.html"></script> <script type="text/javascript" src="js/plugins/<API key>.min.js.html"></script> <script type="text/javascript" src="js/plugins/prettify/prettify.js.html"></script> <script type="text/javascript" src="js/plugins/bootstrapSwitch.js.html"></script> <script type="text/javascript" src="js/plugins/mfupload.js.html"></script> <script type="text/javascript" src="js/common.js.html"></script> </head> <body class="body-login"> <div class="nav-fixed-topright" style="visibility: hidden"> <ul class="nav nav-user-menu"> <li class="<API key>"> <a href="javascript:;"> <i class="user-icon"></i><span class="nav-user-selection">Theme Options</span><i class="icon-menu-arrow"></i> </a> <ul class="nav user-sub-menu"> <li class="light"> <a href="javascript:;"> <i class='icon-photon stop'></i>Light Version </a> </li> <li class="dark"> <a href="javascript:;"> <i class='icon-photon stop'></i>Dark Version </a> </li> </ul> </li> <li> <a href="javascript:;"> <i class="icon-photon mail"></i> </a> </li> <li> <a href="javascript:;"> <i class="icon-photon comment_alt2_stroke"></i> <div class="notification-count">12</div> </a> </li> </ul> </div> <script> $(function(){ setTimeout(function(){ $('.nav-fixed-topright').removeAttr('style'); }, 300); $(window).scroll(function(){ if($('.<API key>').length){ var scrollState = $(window).scrollTop(); if (scrollState > 0) $('.nav-fixed-topright').addClass('nav-released'); else $('.nav-fixed-topright').removeClass('nav-released') } }); $('.<API key>').on('click', function(){ $(this).toggleClass('active-user-menu'); }); $('.user-sub-menu .light').on('click', function(){ if ($('body').is('.light-version')) return; $('body').addClass('light-version'); setTimeout(function() { $.cookie('themeColor', 'light', { expires: 7, path: '/' }); }, 500); }); $('.user-sub-menu .dark').on('click', function(){ if ($('body').is('.light-version')) { $('body').removeClass('light-version'); $.cookie('themeColor', 'dark', { expires: 7, path: '/' }); } }); }); </script> <div class="container-login"> <div class="<API key>"> <div class="form-window-login"> <div class="<API key>"> <div class="login-logo"> <img src="images/photon/login-logo@2x.png.html" alt="Photon UI"/> </div> <h2 class="login-title">Welcome to Photon UI!</h2> <div class="login-member">Not a Member?&nbsp;<a href="xbreadcrumbs.js.html#">Sign Up &#187;</a> <a href="xbreadcrumbs.js.html#" class="btn btn-facebook"><i class="icon-fb"></i>Login with Facebook<i class="icon-fb-arrow"></i></a> </div> <div class="login-or">Or</div> <div class="login-input-area"> <form method="POST" action="dashboard.php"> <span class="help-block">Login With Your Photon Account</span> <input type="text" name="email" placeholder="Email"> <input type="password" name="password" placeholder="Password"> <button type="submit" class="btn btn-large btn-success btn-login">Login</button> </form> <a href="xbreadcrumbs.js.html#" class="forgot-pass">Forgot Your Password?</a> </div> </div> </div> </div> </div> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1936460-27']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https: var s = document.<API key>('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>
#include <media/msm/vidc_type.h> #include "vcd.h" #define <API key> 3600 #define <API key>(client, round_adjustment) \ do {\ if ((client)->rounds < round_adjustment) {\ (client)->rounds = 0;\ VCD_MSG_HIGH("%s(): WARNING: Scheduler list unsorted",\ __func__);\ } else\ (client)->rounds -= round_adjustment;\ } while (0) u32 vcd_sched_create(struct list_head *sched_list) { u32 rc = VCD_S_SUCCESS; if (!sched_list) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else INIT_LIST_HEAD(sched_list); return rc; } void vcd_sched_destroy(struct list_head *sched_clnt_list) { struct vcd_sched_clnt_ctx *sched_clnt, *sched_clnt_next; if (sched_clnt_list) <API key>(sched_clnt, sched_clnt_next, sched_clnt_list, list) { list_del_init(&sched_clnt->list); sched_clnt->clnt_active = false; } } void <API key>(struct list_head *sched_clnt_list, struct vcd_sched_clnt_ctx *sched_new_clnt, bool tail) { struct vcd_sched_clnt_ctx *sched_clnt; if (!list_empty(sched_clnt_list)) { if (tail) sched_clnt = list_entry(sched_clnt_list->prev, struct vcd_sched_clnt_ctx, list); else sched_clnt = list_first_entry(sched_clnt_list, struct vcd_sched_clnt_ctx, list); sched_new_clnt->rounds = sched_clnt->rounds; } else sched_new_clnt->rounds = 0; if (tail) list_add_tail(&sched_new_clnt->list, sched_clnt_list); else list_add(&sched_new_clnt->list, sched_clnt_list); } u32 <API key>(struct vcd_clnt_ctxt *cctxt) { struct vcd_property_hdr prop_hdr; struct vcd_sched_clnt_ctx *sched_cctxt; u32 rc = VCD_S_SUCCESS; if (!cctxt) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else if (cctxt->sched_clnt_hdl) VCD_MSG_HIGH( "%s(): Scheduler client already exists!", __func__); else { sched_cctxt = (struct vcd_sched_clnt_ctx *) kmalloc(sizeof(struct vcd_sched_clnt_ctx), GFP_KERNEL); if (sched_cctxt) { prop_hdr.prop_id = <API key>; prop_hdr.sz = sizeof(cctxt->frm_p_units); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &cctxt->frm_p_units); if (VCD_FAILED(rc)) { kfree(sched_cctxt); VCD_MSG_ERROR( "Failed: Get <API key>"); return rc; } if (cctxt->decoding) { cctxt->frm_rate.fps_numerator = <API key>; cctxt->frm_rate.fps_denominator = 1; } else { prop_hdr.prop_id = VCD_I_FRAME_RATE; prop_hdr.sz = sizeof(cctxt->frm_rate); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &cctxt->frm_rate); if (VCD_FAILED(rc)) { kfree(sched_cctxt); VCD_MSG_ERROR( "Failed: Get VCD_I_FRAME_RATE"); return rc; } } if (!cctxt->perf_set_by_client) cctxt->reqd_perf_lvl = cctxt->frm_p_units * cctxt->frm_rate.fps_numerator / cctxt->frm_rate.fps_denominator; cctxt->sched_clnt_hdl = sched_cctxt; memset(sched_cctxt, 0, sizeof(struct vcd_sched_clnt_ctx)); sched_cctxt->tkns = 0; sched_cctxt->round_perfrm = <API key> * cctxt->frm_rate.fps_denominator / cctxt->frm_rate.fps_numerator; sched_cctxt->clnt_active = true; sched_cctxt->clnt_data = cctxt; INIT_LIST_HEAD(&sched_cctxt->ip_frm_list); <API key>( &cctxt->dev_ctxt->sched_clnt_list, sched_cctxt, false); } } return rc; } u32 <API key>(struct vcd_sched_clnt_ctx *sched_cctxt) { u32 rc = VCD_S_SUCCESS; struct vcd_clnt_ctxt *cctxt; if (!sched_cctxt) { VCD_MSG_ERROR("%s(): Invalid handle ptr", __func__); rc = <API key>; } else if (!list_empty(&sched_cctxt->ip_frm_list)) { VCD_MSG_ERROR( "%s(): Cannot remove client, queue no empty", __func__); rc = VCD_ERR_ILLEGAL_OP; } else { cctxt = sched_cctxt->clnt_data; list_del(&sched_cctxt->list); memset(sched_cctxt, 0, sizeof(struct vcd_sched_clnt_ctx)); kfree(sched_cctxt); } return rc; } u32 <API key>(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; if (!cctxt || !cctxt->sched_clnt_hdl) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else { cctxt->sched_clnt_hdl->rounds /= cctxt->sched_clnt_hdl->round_perfrm; cctxt->sched_clnt_hdl->round_perfrm = <API key> * cctxt->frm_rate.fps_denominator / cctxt->frm_rate.fps_numerator; cctxt->sched_clnt_hdl->rounds *= cctxt->sched_clnt_hdl->round_perfrm; } return rc; } u32 <API key>( struct vcd_sched_clnt_ctx *sched_cctxt, struct vcd_buffer_entry *buffer, u32 tail) { u32 rc = VCD_S_SUCCESS; if (!sched_cctxt || !buffer) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else if (tail) list_add_tail(&buffer->sched_list, &sched_cctxt->ip_frm_list); else list_add(&buffer->sched_list, &sched_cctxt->ip_frm_list); return rc; } u32 <API key>( struct vcd_sched_clnt_ctx *sched_cctxt, struct vcd_buffer_entry **buffer) { u32 rc = VCD_ERR_QEMPTY; if (!sched_cctxt || !buffer) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else { *buffer = NULL; if (!list_empty(&sched_cctxt->ip_frm_list)) { *buffer = list_first_entry( &sched_cctxt->ip_frm_list, struct vcd_buffer_entry, sched_list); list_del(&(*buffer)->sched_list); rc = VCD_S_SUCCESS; } } return rc; } u32 <API key>(struct vcd_sched_clnt_ctx *sched_cctxt) { u32 rc = VCD_S_SUCCESS; struct vcd_buffer_entry *buffer = NULL; if (!sched_cctxt) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else if (!list_empty(&sched_cctxt->ip_frm_list)) { buffer = list_entry(sched_cctxt->ip_frm_list.prev, struct vcd_buffer_entry, sched_list); buffer->frame.flags |= VCD_FRAME_FLAG_EOS; VCD_MSG_LOW("%s: added EOS flag to last buffer entry", __func__); } else { rc = VCD_ERR_QEMPTY; VCD_MSG_HIGH("%s: EOS need to be processed as last buffer", __func__); } return rc; } u32 <API key>( struct vcd_clnt_ctxt *cctxt, u32 state) { u32 rc = VCD_S_SUCCESS; struct vcd_sched_clnt_ctx *sched_cctxt; if (!cctxt || !cctxt->sched_clnt_hdl) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else { sched_cctxt = cctxt->sched_clnt_hdl; if (state != sched_cctxt->clnt_active) { sched_cctxt->clnt_active = state; if (state) <API key>(&cctxt->dev_ctxt->\ sched_clnt_list, sched_cctxt, false); else list_del_init(&sched_cctxt->list); } } return rc; } u32 <API key>(struct list_head *sched_clnt_list, struct vcd_clnt_ctxt **cctxt, struct vcd_buffer_entry **buffer) { u32 rc = VCD_ERR_QEMPTY, round_adjustment = 0; struct vcd_sched_clnt_ctx *sched_clnt, *clnt_nxt; if (!sched_clnt_list || !cctxt || !buffer) { VCD_MSG_ERROR("%s(): Invalid parameter", __func__); rc = <API key>; } else if (!list_empty(sched_clnt_list)) { *cctxt = NULL; *buffer = NULL; <API key>(sched_clnt, clnt_nxt, sched_clnt_list, list) { if (&sched_clnt->list == sched_clnt_list->next) round_adjustment = sched_clnt->rounds; if (*cctxt) { if ((*cctxt)->sched_clnt_hdl->rounds >= sched_clnt->rounds) list_move(&(*cctxt)->sched_clnt_hdl\ ->list, &sched_clnt->list); <API key>(sched_clnt, round_adjustment); } else if (sched_clnt->tkns && !list_empty(&sched_clnt->ip_frm_list)) { *cctxt = sched_clnt->clnt_data; sched_clnt->rounds += sched_clnt->round_perfrm; } else <API key>(sched_clnt, round_adjustment); } if (*cctxt) { rc = <API key>( (*cctxt)->sched_clnt_hdl, buffer); if (rc == VCD_S_SUCCESS) { (*cctxt)->sched_clnt_hdl->tkns <API key>((*cctxt)->\ sched_clnt_hdl, round_adjustment); } } } return rc; }
#include "sqliteInt.h" /* ** A complete page cache is an instance of this structure. */ struct PCache { PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */ PgHdr *pSynced; /* Last synced page in dirty page list */ int nRef; /* Number of referenced pages */ int szCache; /* Configured cache size */ int szPage; /* Size of every page in this cache */ int szExtra; /* Size of extra space for each page */ u8 bPurgeable; /* True if pages are on backing store */ u8 eCreate; /* eCreate value for for xFetch() */ int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */ void *pStress; /* Argument to xStress */ sqlite3_pcache *pCache; /* Pluggable cache module */ PgHdr *pPage1; /* Reference to page 1 */ }; /* ** Some of the assert() macros in this code are too expensive to run ** even during normal debugging. Use them only rarely on long-running ** tests. Enable the expensive asserts using the ** -<API key>=1 compile-time option. */ #ifdef <API key> # define expensive_assert(X) assert(X) #else # define expensive_assert(X) #endif /* Allowed values for second argument to <API key>() */ #define <API key> 1 /* Remove pPage from dirty list */ #define <API key> 2 /* Add pPage to the dirty list */ #define <API key> 3 /* Move pPage to the front of the list */ /* ** Manage pPage's participation on the dirty list. Bits of the addRemove ** argument determines what operation to do. The 0x01 bit means first ** remove pPage from the dirty list. The 0x02 means add pPage back to ** the dirty list. Doing both moves pPage to the front of the dirty list. */ static void <API key>(PgHdr *pPage, u8 addRemove){ PCache *p = pPage->pCache; if( addRemove & <API key> ){ assert( pPage->pDirtyNext || pPage==p->pDirtyTail ); assert( pPage->pDirtyPrev || pPage==p->pDirty ); /* Update the PCache1.pSynced variable if necessary. */ if( p->pSynced==pPage ){ PgHdr *pSynced = pPage->pDirtyPrev; while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){ pSynced = pSynced->pDirtyPrev; } p->pSynced = pSynced; } if( pPage->pDirtyNext ){ pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev; }else{ assert( pPage==p->pDirtyTail ); p->pDirtyTail = pPage->pDirtyPrev; } if( pPage->pDirtyPrev ){ pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext; }else{ assert( pPage==p->pDirty ); p->pDirty = pPage->pDirtyNext; if( p->pDirty==0 && p->bPurgeable ){ assert( p->eCreate==1 ); p->eCreate = 2; } } pPage->pDirtyNext = 0; pPage->pDirtyPrev = 0; } if( addRemove & <API key> ){ assert( pPage->pDirtyNext==0 && pPage->pDirtyPrev==0 && p->pDirty!=pPage ); pPage->pDirtyNext = p->pDirty; if( pPage->pDirtyNext ){ assert( pPage->pDirtyNext->pDirtyPrev==0 ); pPage->pDirtyNext->pDirtyPrev = pPage; }else{ p->pDirtyTail = pPage; if( p->bPurgeable ){ assert( p->eCreate==2 ); p->eCreate = 1; } } p->pDirty = pPage; if( !p->pSynced && 0==(pPage->flags&PGHDR_NEED_SYNC) ){ p->pSynced = pPage; } } } /* ** Wrapper around the pluggable caches xUnpin method. If the cache is ** being used for an in-memory database, this function is a no-op. */ static void pcacheUnpin(PgHdr *p){ if( p->pCache->bPurgeable ){ if( p->pgno==1 ){ p->pCache->pPage1 = 0; } sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0); } } /* ** Compute the number of pages of cache requested. */ static int numberOfCachePages(PCache *p){ if( p->szCache>=0 ){ return p->szCache; }else{ return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); } } int <API key>(void){ if( sqlite3GlobalConfig.pcache2.xInit==0 ){ /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the ** built-in default page cache is used instead of the application defined ** page cache. */ <API key>(); } return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg); } void <API key>(void){ if( sqlite3GlobalConfig.pcache2.xShutdown ){ /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg); } } /* ** Return the size in bytes of a PCache object. */ int sqlite3PcacheSize(void){ return sizeof(PCache); } /* ** Create a new PCache object. Storage space to hold the object ** has already been allocated and is passed in as the p pointer. ** The caller discovers how much space needs to be allocated by ** calling sqlite3PcacheSize(). */ int sqlite3PcacheOpen( int szPage, /* Size of every page */ int szExtra, /* Extra space associated with each page */ int bPurgeable, /* True if pages are on backing store */ int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */ void *pStress, /* Argument to xStress */ PCache *p /* Preallocated space for the PCache */ ){ memset(p, 0, sizeof(PCache)); p->szPage = 1; p->szExtra = szExtra; p->bPurgeable = bPurgeable; p->eCreate = 2; p->xStress = xStress; p->pStress = pStress; p->szCache = 100; return <API key>(p, szPage); } /* ** Change the page size for PCache object. The caller must ensure that there ** are no outstanding page references when this function is called. */ int <API key>(PCache *pCache, int szPage){ assert( pCache->nRef==0 && pCache->pDirty==0 ); if( pCache->szPage ){ sqlite3_pcache *pNew; pNew = sqlite3GlobalConfig.pcache2.xCreate( szPage, pCache->szExtra + sizeof(PgHdr), pCache->bPurgeable ); if( pNew==0 ) return SQLITE_NOMEM; sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache)); if( pCache->pCache ){ sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache); } pCache->pCache = pNew; pCache->pPage1 = 0; pCache->szPage = szPage; } return SQLITE_OK; } sqlite3_pcache_page *sqlite3PcacheFetch( PCache *pCache, /* Obtain the page from this cache */ Pgno pgno, /* Page number to obtain */ int createFlag /* If true, create page if it does not exist already */ ){ int eCreate; assert( pCache!=0 ); assert( pCache->pCache!=0 ); assert( createFlag==3 || createFlag==0 ); assert( pgno>0 ); /* eCreate defines what to do if the page does not exist. ** 0 Do not allocate a new page. (createFlag==0) ** 1 Allocate a new page if doing so is inexpensive. ** (createFlag==1 AND bPurgeable AND pDirty) ** 2 Allocate a new page even it doing so is difficult. ** (createFlag==1 AND !(bPurgeable AND pDirty) */ eCreate = createFlag & pCache->eCreate; assert( eCreate==0 || eCreate==1 || eCreate==2 ); assert( createFlag==0 || pCache->eCreate==eCreate ); assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) ); return sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate); } /* ** If the sqlite3PcacheFetch() routine is unable to allocate a new ** page because new clean pages are available for reuse and the cache ** size limit has been reached, then this routine can be invoked to ** try harder to allocate a page. This routine might invoke the stress ** callback to spill dirty pages to the journal. It will then try to ** allocate the new page and will only fail to allocate a new page on ** an OOM error. ** ** This routine should be invoked only after sqlite3PcacheFetch() fails. */ int <API key>( PCache *pCache, /* Obtain the page from this cache */ Pgno pgno, /* Page number to obtain */ sqlite3_pcache_page **ppPage /* Write result here */ ){ PgHdr *pPg; if( pCache->eCreate==2 ) return 0; /* Find a dirty page to write-out and recycle. First try to find a ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC ** cleared), but if that is not possible settle for any other ** unreferenced dirty page. */ for(pPg=pCache->pSynced; pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); pPg=pPg->pDirtyPrev ); pCache->pSynced = pPg; if( !pPg ){ for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev); } if( pPg ){ int rc; #ifdef <API key> sqlite3_log(SQLITE_FULL, "spill page %d making room for %d - cache used: %d/%d", pPg->pgno, pgno, sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache), numberOfCachePages(pCache)); #endif rc = pCache->xStress(pCache->pStress, pPg); if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ return rc; } } *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2); return *ppPage==0 ? SQLITE_NOMEM : SQLITE_OK; } /* ** This is a helper routine for <API key>() ** ** In the uncommon case where the page being fetched has not been ** initialized, this routine is invoked to do the initialization. ** This routine is broken out into a separate function since it ** requires extra stack manipulation that can be avoided in the common ** case. */ static SQLITE_NOINLINE PgHdr *<API key>( PCache *pCache, /* Obtain the page from this cache */ Pgno pgno, /* Page number obtained */ sqlite3_pcache_page *pPage /* Page obtained by prior PcacheFetch() call */ ){ PgHdr *pPgHdr; assert( pPage!=0 ); pPgHdr = (PgHdr*)pPage->pExtra; assert( pPgHdr->pPage==0 ); memset(pPgHdr, 0, sizeof(PgHdr)); pPgHdr->pPage = pPage; pPgHdr->pData = pPage->pBuf; pPgHdr->pExtra = (void *)&pPgHdr[1]; memset(pPgHdr->pExtra, 0, pCache->szExtra); pPgHdr->pCache = pCache; pPgHdr->pgno = pgno; return <API key>(pCache,pgno,pPage); } /* ** This routine converts the sqlite3_pcache_page object returned by ** sqlite3PcacheFetch() into an initialized PgHdr object. This routine ** must be called after sqlite3PcacheFetch() in order to get a usable ** result. */ PgHdr *<API key>( PCache *pCache, /* Obtain the page from this cache */ Pgno pgno, /* Page number obtained */ sqlite3_pcache_page *pPage /* Page obtained by prior PcacheFetch() call */ ){ PgHdr *pPgHdr; if( pPage==0 ) return 0; pPgHdr = (PgHdr *)pPage->pExtra; if( !pPgHdr->pPage ){ return <API key>(pCache, pgno, pPage); } if( 0==pPgHdr->nRef ){ pCache->nRef++; } pPgHdr->nRef++; if( pgno==1 ){ pCache->pPage1 = pPgHdr; } return pPgHdr; } /* ** Decrement the reference count on a page. If the page is clean and the ** reference count drops to 0, then it is made eligible for recycling. */ void SQLITE_NOINLINE <API key>(PgHdr *p){ assert( p->nRef>0 ); p->nRef if( p->nRef==0 ){ p->pCache->nRef if( (p->flags&PGHDR_DIRTY)==0 ){ pcacheUnpin(p); }else if( p->pDirtyPrev!=0 ){ /* Move the page to the head of the dirty list. */ <API key>(p, <API key>); } } } /* ** Increase the reference count of a supplied page by 1. */ void sqlite3PcacheRef(PgHdr *p){ assert(p->nRef>0); p->nRef++; } /* ** Drop a page from the cache. There must be exactly one reference to the ** page. This function deletes that reference, so after it returns the ** page pointed to by p is invalid. */ void sqlite3PcacheDrop(PgHdr *p){ assert( p->nRef==1 ); if( p->flags&PGHDR_DIRTY ){ <API key>(p, <API key>); } p->pCache->nRef if( p->pgno==1 ){ p->pCache->pPage1 = 0; } sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1); } /* ** Make sure the page is marked as dirty. If it isn't dirty already, ** make it so. */ void <API key>(PgHdr *p){ p->flags &= ~PGHDR_DONT_WRITE; assert( p->nRef>0 ); if( 0==(p->flags & PGHDR_DIRTY) ){ p->flags |= PGHDR_DIRTY; <API key>(p, <API key>); } } /* ** Make sure the page is marked as clean. If it isn't clean already, ** make it so. */ void <API key>(PgHdr *p){ if( (p->flags & PGHDR_DIRTY) ){ <API key>(p, <API key>); p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC); if( p->nRef==0 ){ pcacheUnpin(p); } } } /* ** Make every page in the cache clean. */ void <API key>(PCache *pCache){ PgHdr *p; while( (p = pCache->pDirty)!=0 ){ <API key>(p); } } /* ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. */ void <API key>(PCache *pCache){ PgHdr *p; for(p=pCache->pDirty; p; p=p->pDirtyNext){ p->flags &= ~PGHDR_NEED_SYNC; } pCache->pSynced = pCache->pDirtyTail; } /* ** Change the page number of page p to newPgno. */ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ PCache *pCache = p->pCache; assert( p->nRef>0 ); assert( newPgno>0 ); sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); p->pgno = newPgno; if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ <API key>(p, <API key>); } } /* ** Drop every cache entry whose page number is greater than "pgno". The ** caller must ensure that there are no outstanding references to any pages ** other than page 1 with a page number greater than pgno. ** ** If there is a reference to page 1 and the pgno parameter passed to this ** function is 0, then the data area associated with page 1 is zeroed, but ** the page object is not dropped. */ void <API key>(PCache *pCache, Pgno pgno){ if( pCache->pCache ){ PgHdr *p; PgHdr *pNext; for(p=pCache->pDirty; p; p=pNext){ pNext = p->pDirtyNext; /* This routine never gets call with a positive pgno except right ** after <API key>(). So if there are dirty pages, ** it must be that pgno==0. */ assert( p->pgno>0 ); if( ALWAYS(p->pgno>pgno) ){ assert( p->flags&PGHDR_DIRTY ); <API key>(p); } } if( pgno==0 && pCache->pPage1 ){ memset(pCache->pPage1->pData, 0, pCache->szPage); pgno = 1; } sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1); } } /* ** Close a cache. */ void sqlite3PcacheClose(PCache *pCache){ assert( pCache->pCache!=0 ); sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache); } /* ** Discard the contents of the cache. */ void sqlite3PcacheClear(PCache *pCache){ <API key>(pCache, 0); } /* ** Merge two lists of pages connected by pDirty and in pgno order. ** Do not both fixing the pDirtyPrev pointers. */ static PgHdr *<API key>(PgHdr *pA, PgHdr *pB){ PgHdr result, *pTail; pTail = &result; while( pA && pB ){ if( pA->pgno<pB->pgno ){ pTail->pDirty = pA; pTail = pA; pA = pA->pDirty; }else{ pTail->pDirty = pB; pTail = pB; pB = pB->pDirty; } } if( pA ){ pTail->pDirty = pA; }else if( pB ){ pTail->pDirty = pB; }else{ pTail->pDirty = 0; } return result.pDirty; } /* ** Sort the list of pages in accending order by pgno. Pages are ** connected by pDirty pointers. The pDirtyPrev pointers are ** corrupted by this sort. ** ** Since there cannot be more than 2^31 distinct pages in a database, ** there cannot be more than 31 buckets required by the merge sorter. ** One extra bucket is added to catch overflow in case something ** ever changes to make the previous sentence incorrect. */ #define N_SORT_BUCKET 32 static PgHdr *pcacheSortDirtyList(PgHdr *pIn){ PgHdr *a[N_SORT_BUCKET], *p; int i; memset(a, 0, sizeof(a)); while( pIn ){ p = pIn; pIn = p->pDirty; p->pDirty = 0; for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){ if( a[i]==0 ){ a[i] = p; break; }else{ p = <API key>(a[i], p); a[i] = 0; } } if( NEVER(i==N_SORT_BUCKET-1) ){ /* To get here, there need to be 2^(N_SORT_BUCKET) elements in ** the input list. But that is impossible. */ a[i] = <API key>(a[i], p); } } p = a[0]; for(i=1; i<N_SORT_BUCKET; i++){ p = <API key>(p, a[i]); } return p; } /* ** Return a list of all dirty pages in the cache, sorted by page number. */ PgHdr *<API key>(PCache *pCache){ PgHdr *p; for(p=pCache->pDirty; p; p=p->pDirtyNext){ p->pDirty = p->pDirtyNext; } return pcacheSortDirtyList(pCache->pDirty); } /* ** Return the total number of referenced pages held by the cache. */ int <API key>(PCache *pCache){ return pCache->nRef; } /* ** Return the number of references to the page supplied as an argument. */ int <API key>(PgHdr *p){ return p->nRef; } /* ** Return the total number of pages in the cache. */ int <API key>(PCache *pCache){ assert( pCache->pCache!=0 ); return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache); } #ifdef SQLITE_TEST /* ** Get the suggested cache-size value. */ int <API key>(PCache *pCache){ return numberOfCachePages(pCache); } #endif /* ** Set the suggested cache-size value. */ void <API key>(PCache *pCache, int mxPage){ assert( pCache->pCache!=0 ); pCache->szCache = mxPage; sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache, numberOfCachePages(pCache)); } /* ** Free up as much memory as possible from the page cache. */ void sqlite3PcacheShrink(PCache *pCache){ assert( pCache->pCache!=0 ); sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache); } #if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG) /* ** For all dirty pages currently in the cache, invoke the specified ** callback. This is only used if the SQLITE_CHECK_PAGES macro is ** defined. */ void <API key>(PCache *pCache, void (*xIter)(PgHdr *)){ PgHdr *pDirty; for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){ xIter(pDirty); } } #endif
<!doctype html> <html lang="en" data-framework="durandal"> <head> <meta charset="utf-8"> <title>Durandal • TodoMVC</title> <link rel="stylesheet" href="bower_components/todomvc-common/base.css"> <link rel="stylesheet" href="css/app.css"> </head> <body> <div id="applicationHost"> <!-- This is where the shell will be loaded into by idetifying as 'applicationHost' --> </div> <script src="bower_components/todomvc-common/base.js"></script> <script src="bower_components/jquery/jquery.js"></script> <script src="bower_components/knockout/knockout.js"></script> <script src="bower_components/sammy/sammy.js"></script> <script src="bower_components/requirejs/require.js" data-main="../durandal/js/main.js"></script> </body> </html>