answer
stringlengths
15
1.25M
#ifndef __ASM_ARCH_PSC_H #define __ASM_ARCH_PSC_H #define <API key> 0x01C41000 /* Power and Sleep Controller (PSC) Domains */ #define <API key> 0 #define <API key> 1 #define <API key> 0 #define <API key> 1 #define DAVINCI_LPSC_TPCC 2 #define DAVINCI_LPSC_TPTC0 3 #define DAVINCI_LPSC_TPTC1 4 #define DAVINCI_LPSC_EMAC 5 #define <API key> 6 #define DAVINCI_LPSC_USB 9 #define DAVINCI_LPSC_ATA 10 #define DAVINCI_LPSC_VLYNQ 11 #define DAVINCI_LPSC_UHPI 12 #define <API key> 13 #define DAVINCI_LPSC_AEMIF 14 #define DAVINCI_LPSC_MMC_SD 15 #define DAVINCI_LPSC_McBSP 17 #define DAVINCI_LPSC_I2C 18 #define DAVINCI_LPSC_UART0 19 #define DAVINCI_LPSC_UART1 20 #define DAVINCI_LPSC_UART2 21 #define DAVINCI_LPSC_SPI 22 #define DAVINCI_LPSC_PWM0 23 #define DAVINCI_LPSC_PWM1 24 #define DAVINCI_LPSC_PWM2 25 #define DAVINCI_LPSC_GPIO 26 #define DAVINCI_LPSC_TIMER0 27 #define DAVINCI_LPSC_TIMER1 28 #define DAVINCI_LPSC_TIMER2 29 #define <API key> 30 #define DAVINCI_LPSC_ARM 31 #define DAVINCI_LPSC_SCR2 32 #define DAVINCI_LPSC_SCR3 33 #define DAVINCI_LPSC_SCR4 34 #define <API key> 35 #define DAVINCI_LPSC_CFG27 36 #define DAVINCI_LPSC_CFG3 37 #define DAVINCI_LPSC_CFG5 38 #define DAVINCI_LPSC_GEM 39 #define DAVINCI_LPSC_IMCOP 40 #define DM355_LPSC_TIMER3 5 #define DM355_LPSC_SPI1 6 #define DM355_LPSC_MMC_SD1 7 #define DM355_LPSC_McBSP1 8 #define DM355_LPSC_PWM3 10 #define DM355_LPSC_SPI2 11 #define DM355_LPSC_RTO 12 #define DM355_LPSC_VPSS_DAC 41 /* DM365 */ #define DM365_LPSC_TIMER3 5 #define DM365_LPSC_SPI1 6 #define DM365_LPSC_MMC_SD1 7 #define DM365_LPSC_McBSP1 8 #define DM365_LPSC_PWM3 10 #define DM365_LPSC_SPI2 11 #define DM365_LPSC_RTO 12 #define DM365_LPSC_TIMER4 17 #define DM365_LPSC_SPI0 22 #define DM365_LPSC_SPI3 38 #define DM365_LPSC_SPI4 39 #define DM365_LPSC_EMAC 40 #define <API key> 44 #define DM365_LPSC_DAC_CLK 46 #define DM365_LPSC_VPSSMSTR 47 #define DM365_LPSC_MJCP 50 /* * LPSC Assignments */ #define DM646X_LPSC_ARM 0 #define <API key> 1 #define DM646X_LPSC_HDVICP0 2 #define DM646X_LPSC_HDVICP1 3 #define DM646X_LPSC_TPCC 4 #define DM646X_LPSC_TPTC0 5 #define DM646X_LPSC_TPTC1 6 #define DM646X_LPSC_TPTC2 7 #define DM646X_LPSC_TPTC3 8 #define DM646X_LPSC_PCI 13 #define DM646X_LPSC_EMAC 14 #define DM646X_LPSC_VDCE 15 #define <API key> 16 #define DM646X_LPSC_VPSSSLV 17 #define DM646X_LPSC_TSIF0 18 #define DM646X_LPSC_TSIF1 19 #define <API key> 20 #define DM646X_LPSC_AEMIF 21 #define DM646X_LPSC_McASP0 22 #define DM646X_LPSC_McASP1 23 #define DM646X_LPSC_CRGEN0 24 #define DM646X_LPSC_CRGEN1 25 #define DM646X_LPSC_UART0 26 #define DM646X_LPSC_UART1 27 #define DM646X_LPSC_UART2 28 #define DM646X_LPSC_PWM0 29 #define DM646X_LPSC_PWM1 30 #define DM646X_LPSC_I2C 31 #define DM646X_LPSC_SPI 32 #define DM646X_LPSC_GPIO 33 #define DM646X_LPSC_TIMER0 34 #define DM646X_LPSC_TIMER1 35 #define <API key> 45 /* PSC0 defines */ #define DA8XX_LPSC0_TPCC 0 #define DA8XX_LPSC0_TPTC0 1 #define DA8XX_LPSC0_TPTC1 2 #define DA8XX_LPSC0_EMIF25 3 #define DA8XX_LPSC0_SPI0 4 #define DA8XX_LPSC0_MMC_SD 5 #define DA8XX_LPSC0_AINTC 6 #define <API key> 7 #define <API key> 8 #define DA8XX_LPSC0_UART0 9 #define DA8XX_LPSC0_SCR0_SS 10 #define DA8XX_LPSC0_SCR1_SS 11 #define DA8XX_LPSC0_SCR2_SS 12 #define DA8XX_LPSC0_PRUSS 13 #define DA8XX_LPSC0_ARM 14 #define DA8XX_LPSC0_GEM 15 /* PSC1 defines */ #define DA850_LPSC1_TPCC1 0 #define DA8XX_LPSC1_USB20 1 #define DA8XX_LPSC1_USB11 2 #define DA8XX_LPSC1_GPIO 3 #define DA8XX_LPSC1_UHPI 4 #define DA8XX_LPSC1_CPGMAC 5 #define DA8XX_LPSC1_EMIF3C 6 #define DA8XX_LPSC1_McASP0 7 #define DA830_LPSC1_McASP1 8 #define DA850_LPSC1_SATA 8 #define DA830_LPSC1_McASP2 9 #define DA8XX_LPSC1_SPI1 10 #define DA8XX_LPSC1_I2C 11 #define DA8XX_LPSC1_UART1 12 #define DA8XX_LPSC1_UART2 13 #define DA8XX_LPSC1_LCDC 16 #define DA8XX_LPSC1_PWM 17 #define DA850_LPSC1_MMC_SD1 18 #define DA8XX_LPSC1_ECAP 20 #define DA830_LPSC1_EQEP 21 #define DA850_LPSC1_TPTC2 21 #define <API key> 24 #define <API key> 25 #define <API key> 26 #define <API key> 31 /* TNETV107X LPSC Assignments */ #define TNETV107X_LPSC_ARM 0 #define TNETV107X_LPSC_GEM 1 #define <API key> 2 #define TNETV107X_LPSC_TPCC 3 #define <API key> 4 #define <API key> 5 #define TNETV107X_LPSC_RAM 6 #define <API key> 7 #define TNETV107X_LPSC_LCD 8 #define <API key> 9 #define <API key> 10 #define <API key> 11 #define TNETV107X_LPSC_TSC 12 #define TNETV107X_LPSC_ROM 13 #define <API key> 14 #define <API key> 15 #define <API key> 16 #define <API key> 17 #define <API key> 18 #define TNETV107X_LPSC_GPIO 19 #define TNETV107X_LPSC_MDIO 20 #define <API key> 21 #define <API key> 22 #define <API key> 23 #define <API key> 24 #define <API key> 25 #define <API key> 26 #define <API key> 27 #define TNETV107X_LPSC_SSP 28 #define TNETV107X_LPSC_TDM0 29 #define <API key> 30 #define <API key> 31 #define TNETV107X_LPSC_USB0 32 #define TNETV107X_LPSC_TDM1 33 #define <API key> 34 #define <API key> 35 #define <API key> 36 #define <API key> 37 #define <API key> 38 #define <API key> 39 #define TNETV107X_LPSC_USB1 40 #define <API key> 41 #define <API key> 42 #define <API key> 43 #define TNETV107X_LPSC_MAX 44 /* PSC register offsets */ #define EPCPR 0x070 #define PTCMD 0x120 #define PTSTAT 0x128 #define PDSTAT 0x200 #define PDCTL 0x300 #define MDSTAT 0x800 #define MDCTL 0xA00 /* PSC module states */ #define <API key> 0 #define PSC_STATE_SYNCRST 1 #define PSC_STATE_DISABLE 2 #define PSC_STATE_ENABLE 3 #define MDSTAT_STATE_MASK 0x3f #define PDSTAT_STATE_MASK 0x1f #define MDCTL_FORCE BIT(31) #define PDCTL_NEXT BIT(0) #define PDCTL_EPCGOOD BIT(8) #ifndef __ASSEMBLER__ extern int <API key>(unsigned int ctlr, unsigned int id); extern void davinci_psc_config(unsigned int domain, unsigned int ctlr, unsigned int id, bool enable, u32 flags); #endif #endif /* __ASM_ARCH_PSC_H */
package dns import ( "crypto" "crypto/dsa" "crypto/ecdsa" "crypto/rsa" "io" "math/big" "strconv" "strings" ) // NewPrivateKey returns a PrivateKey by parsing the string s. // s should be in the same form of the BIND private key files. func (k *DNSKEY) NewPrivateKey(s string) (crypto.PrivateKey, error) { if s == "" || s[len(s)-1] != '\n' { // We need a closing newline return k.ReadPrivateKey(strings.NewReader(s+"\n"), "") } return k.ReadPrivateKey(strings.NewReader(s), "") } // ReadPrivateKey reads a private key from the io.Reader q. The string file is // only used in error reporting. // The public key must be known, because some cryptographic algorithms embed // the public inside the privatekey. func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (crypto.PrivateKey, error) { m, err := parseKey(q, file) if m == nil { return nil, err } if _, ok := m["private-key-format"]; !ok { return nil, ErrPrivKey } if m["private-key-format"] != "v1.2" && m["private-key-format"] != "v1.3" { return nil, ErrPrivKey } // TODO(mg): check if the pubkey matches the private key algo, err := strconv.Atoi(strings.SplitN(m["algorithm"], " ", 2)[0]) if err != nil { return nil, ErrPrivKey } switch uint8(algo) { case DSA: priv, err := readPrivateKeyDSA(m) if err != nil { return nil, err } pub := k.publicKeyDSA() if pub == nil { return nil, ErrKey } priv.PublicKey = *pub return priv, nil case RSAMD5: fallthrough case RSASHA1: fallthrough case RSASHA1NSEC3SHA1: fallthrough case RSASHA256: fallthrough case RSASHA512: priv, err := readPrivateKeyRSA(m) if err != nil { return nil, err } pub := k.publicKeyRSA() if pub == nil { return nil, ErrKey } priv.PublicKey = *pub return priv, nil case ECCGOST: return nil, ErrPrivKey case ECDSAP256SHA256: fallthrough case ECDSAP384SHA384: priv, err := readPrivateKeyECDSA(m) if err != nil { return nil, err } pub := k.publicKeyECDSA() if pub == nil { return nil, ErrKey } priv.PublicKey = *pub return priv, nil default: return nil, ErrPrivKey } } // Read a private key (file) string and create a public key. Return the private key. func readPrivateKeyRSA(m map[string]string) (*rsa.PrivateKey, error) { p := new(rsa.PrivateKey) p.Primes = []*big.Int{nil, nil} for k, v := range m { switch k { case "modulus", "publicexponent", "privateexponent", "prime1", "prime2": v1, err := fromBase64([]byte(v)) if err != nil { return nil, err } switch k { case "modulus": p.PublicKey.N = big.NewInt(0) p.PublicKey.N.SetBytes(v1) case "publicexponent": i := big.NewInt(0) i.SetBytes(v1) p.PublicKey.E = int(i.Int64()) // int64 should be large enough case "privateexponent": p.D = big.NewInt(0) p.D.SetBytes(v1) case "prime1": p.Primes[0] = big.NewInt(0) p.Primes[0].SetBytes(v1) case "prime2": p.Primes[1] = big.NewInt(0) p.Primes[1].SetBytes(v1) } case "exponent1", "exponent2", "coefficient": // not used in Go (yet) case "created", "publish", "activate": // not used in Go (yet) } } return p, nil } func readPrivateKeyDSA(m map[string]string) (*dsa.PrivateKey, error) { p := new(dsa.PrivateKey) p.X = big.NewInt(0) for k, v := range m { switch k { case "private_value(x)": v1, err := fromBase64([]byte(v)) if err != nil { return nil, err } p.X.SetBytes(v1) case "created", "publish", "activate": /* not used in Go (yet) */ } } return p, nil } func readPrivateKeyECDSA(m map[string]string) (*ecdsa.PrivateKey, error) { p := new(ecdsa.PrivateKey) p.D = big.NewInt(0) // TODO: validate that the required flags are present for k, v := range m { switch k { case "privatekey": v1, err := fromBase64([]byte(v)) if err != nil { return nil, err } p.D.SetBytes(v1) case "created", "publish", "activate": /* not used in Go (yet) */ } } return p, nil } // parseKey reads a private key from r. It returns a map[string]string, // with the key-value pairs, or an error when the file is not correct. func parseKey(r io.Reader, file string) (map[string]string, error) { s := scanInit(r) m := make(map[string]string) c := make(chan lex) k := "" // Start the lexer go klexer(s, c) for l := range c { // It should alternate switch l.value { case zKey: k = l.token case zValue: if k == "" { return nil, &ParseError{file, "no private key seen", l} } //println("Setting", strings.ToLower(k), "to", l.token, "b") m[strings.ToLower(k)] = l.token k = "" } } return m, nil } // klexer scans the sourcefile and returns tokens on the channel c. func klexer(s *scan, c chan lex) { var l lex str := "" // Hold the current read text commt := false key := true x, err := s.tokenText() defer close(c) for err == nil { l.column = s.position.Column l.line = s.position.Line switch x { case ':': if commt { break } l.token = str if key { l.value = zKey c <- l // Next token is a space, eat it s.tokenText() key = false str = "" } else { l.value = zValue } case ';': commt = true case '\n': if commt { // Reset a comment commt = false } l.value = zValue l.token = str c <- l str = "" commt = false key = true default: if commt { break } str += string(x) } x, err = s.tokenText() } if len(str) > 0 { // Send remainder l.token = str l.value = zValue c <- l } }
#include <linux/clk.h> #include <linux/errno.h> #include <linux/device.h> #include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/module.h> #include <linux/io.h> #include <linux/irqdomain.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_gpio.h> #include <asm/mach/irq.h> #include <mach/hardware.h> #include <mach/at91_pio.h> #include "generic.h" struct at91_gpio_chip { struct gpio_chip chip; struct at91_gpio_chip *next; /* Bank sharing same clock */ int pioc_hwirq; /* PIO bank interrupt identifier on AIC */ int pioc_virq; /* PIO bank Linux virtual interrupt */ int pioc_idx; /* PIO bank index */ void __iomem *regbase; /* PIO bank virtual address */ struct clk *clock; /* associated clock */ struct irq_domain *domain; /* associated irq domain */ }; #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) static void <API key>(struct seq_file *s, struct gpio_chip *chip); static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val); static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); static int <API key>(struct gpio_chip *chip, unsigned offset, int val); static int <API key>(struct gpio_chip *chip, unsigned offset); static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset); #define AT91_GPIO_CHIP(name, nr_gpio) \ { \ .chip = { \ .label = name, \ .direction_input = <API key>, \ .direction_output = <API key>, \ .get = at91_gpiolib_get, \ .set = at91_gpiolib_set, \ .dbg_show = <API key>, \ .to_irq = at91_gpiolib_to_irq, \ .ngpio = nr_gpio, \ }, \ } static struct at91_gpio_chip gpio_chip[] = { AT91_GPIO_CHIP("pioA", 32), AT91_GPIO_CHIP("pioB", 32), AT91_GPIO_CHIP("pioC", 32), AT91_GPIO_CHIP("pioD", 32), AT91_GPIO_CHIP("pioE", 32), }; static int gpio_banks; static unsigned long at91_gpio_caps; /* All PIO controllers support PIO3 features */ #define AT91_GPIO_CAP_PIO3 (1 << 0) #define has_pio3() (at91_gpio_caps & AT91_GPIO_CAP_PIO3) static inline void __iomem *pin_to_controller(unsigned pin) { pin /= 32; if (likely(pin < gpio_banks)) return gpio_chip[pin].regbase; return NULL; } static inline unsigned pin_to_mask(unsigned pin) { return 1 << (pin % 32); } static char peripheral_function(void __iomem *pio, unsigned mask) { char ret = 'X'; u8 select; if (pio) { if (has_pio3()) { select = !!(__raw_readl(pio + PIO_ABCDSR1) & mask); select |= (!!(__raw_readl(pio + PIO_ABCDSR2) & mask) << 1); ret = 'A' + select; } else { ret = __raw_readl(pio + PIO_ABSR) & mask ? 'B' : 'A'; } } return ret; } /* Not all hardware capabilities are exposed through these calls; they * only encapsulate the most common features and modes. (So if you * want to change signals in groups, do it directly.) * * Bootloaders will usually handle some of the pin multiplexing setup. * The intent is certainly that by the time Linux is fully booted, all * pins should have been fully initialized. These setup calls should * only be used by board setup routines, or possibly in driver probe(). * * For bootloaders doing all that setup, these calls could be inlined * as NOPs so Linux won't duplicate any setup code */ /* * mux the pin to the "GPIO" peripheral role. */ int __init_or_module <API key>(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); __raw_writel(mask, pio + PIO_PER); return 0; } EXPORT_SYMBOL(<API key>); /* * mux the pin to the "A" internal peripheral role. */ int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); if (has_pio3()) { __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask, pio + PIO_ABCDSR2); } else { __raw_writel(mask, pio + PIO_ASR); } __raw_writel(mask, pio + PIO_PDR); return 0; } EXPORT_SYMBOL(at91_set_A_periph); /* * mux the pin to the "B" internal peripheral role. */ int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); if (has_pio3()) { __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask, pio + PIO_ABCDSR2); } else { __raw_writel(mask, pio + PIO_BSR); } __raw_writel(mask, pio + PIO_PDR); return 0; } EXPORT_SYMBOL(at91_set_B_periph); /* * mux the pin to the "C" internal peripheral role. */ int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio || !has_pio3()) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); __raw_writel(mask, pio + PIO_PDR); return 0; } EXPORT_SYMBOL(at91_set_C_periph); /* * mux the pin to the "D" internal peripheral role. */ int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio || !has_pio3()) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); __raw_writel(mask, pio + PIO_PDR); return 0; } EXPORT_SYMBOL(at91_set_D_periph); /* * mux the pin to the gpio controller (instead of "A", "B", "C" * or "D" peripheral), and configure it for an input. */ int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); __raw_writel(mask, pio + PIO_ODR); __raw_writel(mask, pio + PIO_PER); return 0; } EXPORT_SYMBOL(at91_set_gpio_input); /* * mux the pin to the gpio controller (instead of "A", "B", "C" * or "D" peripheral), and configure it for an output. */ int __init_or_module <API key>(unsigned pin, int value) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + PIO_IDR); __raw_writel(mask, pio + PIO_PUDR); __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR)); __raw_writel(mask, pio + PIO_OER); __raw_writel(mask, pio + PIO_PER); return 0; } EXPORT_SYMBOL(<API key>); /* * enable/disable the glitch filter; mostly used with IRQ handling. */ int __init_or_module at91_set_deglitch(unsigned pin, int is_on) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; if (has_pio3() && is_on) __raw_writel(mask, pio + PIO_IFSCDR); __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR)); return 0; } EXPORT_SYMBOL(at91_set_deglitch); /* * enable/disable the debounce filter; */ int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio || !has_pio3()) return -EINVAL; if (is_on) { __raw_writel(mask, pio + PIO_IFSCER); __raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR); __raw_writel(mask, pio + PIO_IFER); } else { __raw_writel(mask, pio + PIO_IFDR); } return 0; } EXPORT_SYMBOL(at91_set_debounce); /* * enable/disable the multi-driver; This is only valid for output and * allows the output pin to run as an open collector output. */ int __init_or_module <API key>(unsigned pin, int is_on) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + (is_on ? PIO_MDER : PIO_MDDR)); return 0; } EXPORT_SYMBOL(<API key>); /* * enable/disable the pull-down. * If pull-up already enabled while calling the function, we disable it. */ int __init_or_module at91_set_pulldown(unsigned pin, int is_on) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio || !has_pio3()) return -EINVAL; /* Disable pull-up anyway */ __raw_writel(mask, pio + PIO_PUDR); __raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR)); return 0; } EXPORT_SYMBOL(at91_set_pulldown); /* * disable Schmitt trigger */ int __init_or_module <API key>(unsigned pin) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio || !has_pio3()) return -EINVAL; __raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT); return 0; } EXPORT_SYMBOL(<API key>); /* * assuming the pin is muxed as a gpio output, set its value. */ int at91_set_gpio_value(unsigned pin, int value) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (!pio) return -EINVAL; __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR)); return 0; } EXPORT_SYMBOL(at91_set_gpio_value); /* * read the pin's value (works even if it's not muxed as a gpio). */ int at91_get_gpio_value(unsigned pin) { void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); u32 pdsr; if (!pio) return -EINVAL; pdsr = __raw_readl(pio + PIO_PDSR); return (pdsr & mask) != 0; } EXPORT_SYMBOL(at91_get_gpio_value); #ifdef CONFIG_PM static u32 wakeups[MAX_GPIO_BANKS]; static u32 backups[MAX_GPIO_BANKS]; static int gpio_irq_set_wake(struct irq_data *d, unsigned state) { struct at91_gpio_chip *at91_gpio = <API key>(d); unsigned mask = 1 << d->hwirq; unsigned bank = at91_gpio->pioc_idx; if (unlikely(bank >= MAX_GPIO_BANKS)) return -EINVAL; if (state) wakeups[bank] |= mask; else wakeups[bank] &= ~mask; irq_set_irq_wake(at91_gpio->pioc_virq, state); return 0; } void at91_gpio_suspend(void) { int i; for (i = 0; i < gpio_banks; i++) { void __iomem *pio = gpio_chip[i].regbase; backups[i] = __raw_readl(pio + PIO_IMR); __raw_writel(backups[i], pio + PIO_IDR); __raw_writel(wakeups[i], pio + PIO_IER); if (!wakeups[i]) { clk_unprepare(gpio_chip[i].clock); clk_disable(gpio_chip[i].clock); } else { #ifdef CONFIG_PM_DEBUG printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]); #endif } } } void at91_gpio_resume(void) { int i; for (i = 0; i < gpio_banks; i++) { void __iomem *pio = gpio_chip[i].regbase; if (!wakeups[i]) { if (clk_prepare(gpio_chip[i].clock) == 0) clk_enable(gpio_chip[i].clock); } __raw_writel(wakeups[i], pio + PIO_IDR); __raw_writel(backups[i], pio + PIO_IER); } } #else #define gpio_irq_set_wake NULL #endif /* Several AIC controller irqs are dispatched through this GPIO handler. * To use any AT91_PIN_* as an externally triggered IRQ, first call * at91_set_gpio_input() then maybe enable its glitch filter. * Then just request_irq() with the pin ID; it works like any ARM IRQ * handler. * First implementation always triggers on rising and falling edges * whereas the newer PIO3 can be additionally configured to trigger on * level, edge with any polarity. * * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after * configuring them with at91_set_a_periph() or at91_set_b_periph(). * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering. */ static void gpio_irq_mask(struct irq_data *d) { struct at91_gpio_chip *at91_gpio = <API key>(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; if (pio) __raw_writel(mask, pio + PIO_IDR); } static void gpio_irq_unmask(struct irq_data *d) { struct at91_gpio_chip *at91_gpio = <API key>(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; if (pio) __raw_writel(mask, pio + PIO_IER); } static int gpio_irq_type(struct irq_data *d, unsigned type) { switch (type) { case IRQ_TYPE_NONE: case IRQ_TYPE_EDGE_BOTH: return 0; default: return -EINVAL; } } /* Alternate irq type for PIO3 support */ static int alt_gpio_irq_type(struct irq_data *d, unsigned type) { struct at91_gpio_chip *at91_gpio = <API key>(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; switch (type) { case <API key>: __raw_writel(mask, pio + PIO_ESR); __raw_writel(mask, pio + PIO_REHLSR); break; case <API key>: __raw_writel(mask, pio + PIO_ESR); __raw_writel(mask, pio + PIO_FELLSR); break; case IRQ_TYPE_LEVEL_LOW: __raw_writel(mask, pio + PIO_LSR); __raw_writel(mask, pio + PIO_FELLSR); break; case IRQ_TYPE_LEVEL_HIGH: __raw_writel(mask, pio + PIO_LSR); __raw_writel(mask, pio + PIO_REHLSR); break; case IRQ_TYPE_EDGE_BOTH: /* * disable additional interrupt modes: * fall back to default behavior */ __raw_writel(mask, pio + PIO_AIMDR); return 0; case IRQ_TYPE_NONE: default: pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq)); return -EINVAL; } /* enable additional interrupt modes */ __raw_writel(mask, pio + PIO_AIMER); return 0; } static struct irq_chip gpio_irqchip = { .name = "GPIO", .irq_disable = gpio_irq_mask, .irq_mask = gpio_irq_mask, .irq_unmask = gpio_irq_unmask, /* .irq_set_type is set dynamically */ .irq_set_wake = gpio_irq_set_wake, }; static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_data *idata = <API key>(desc); struct at91_gpio_chip *at91_gpio = <API key>(idata); void __iomem *pio = at91_gpio->regbase; unsigned long isr; int n; chained_irq_enter(chip, desc); for (;;) { /* Reading ISR acks pending (edge triggered) GPIO interrupts. * When there none are pending, we're finished unless we need * to process multiple banks (like ID_PIOCDE on sam9263). */ isr = __raw_readl(pio + PIO_ISR) & __raw_readl(pio + PIO_IMR); if (!isr) { if (!at91_gpio->next) break; at91_gpio = at91_gpio->next; pio = at91_gpio->regbase; continue; } n = find_first_bit(&isr, BITS_PER_LONG); while (n < BITS_PER_LONG) { generic_handle_irq(irq_find_mapping(at91_gpio->domain, n)); n = find_next_bit(&isr, BITS_PER_LONG, n + 1); } } chained_irq_exit(chip, desc); /* now it may re-trigger */ } #ifdef CONFIG_DEBUG_FS static void gpio_printf(struct seq_file *s, void __iomem *pio, unsigned mask) { char *trigger = NULL; char *polarity = NULL; if (__raw_readl(pio + PIO_IMR) & mask) { if (!has_pio3() || !(__raw_readl(pio + PIO_AIMMR) & mask )) { trigger = "edge"; polarity = "both"; } else { if (__raw_readl(pio + PIO_ELSR) & mask) { trigger = "level"; polarity = __raw_readl(pio + PIO_FRLHSR) & mask ? "high" : "low"; } else { trigger = "edge"; polarity = __raw_readl(pio + PIO_FRLHSR) & mask ? "rising" : "falling"; } } seq_printf(s, "IRQ:%s-%s\t", trigger, polarity); } else { seq_printf(s, "GPIO:%s\t\t", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0"); } } static int at91_gpio_show(struct seq_file *s, void *unused) { int bank, j; /* print heading */ seq_printf(s, "Pin\t"); for (bank = 0; bank < gpio_banks; bank++) { seq_printf(s, "PIO%c\t\t", 'A' + bank); }; seq_printf(s, "\n\n"); /* print pin status */ for (j = 0; j < 32; j++) { seq_printf(s, "%i:\t", j); for (bank = 0; bank < gpio_banks; bank++) { unsigned pin = (32 * bank) + j; void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); if (__raw_readl(pio + PIO_PSR) & mask) gpio_printf(s, pio, mask); else seq_printf(s, "%c\t\t", peripheral_function(pio, mask)); } seq_printf(s, "\n"); } return 0; } static int at91_gpio_open(struct inode *inode, struct file *file) { return single_open(file, at91_gpio_show, NULL); } static const struct file_operations <API key> = { .open = at91_gpio_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int __init <API key>(void) { /* /sys/kernel/debug/at91_gpio */ (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &<API key>); return 0; } postcore_initcall(<API key>); #endif /* * This lock class tells lockdep that GPIO irqs are in a different * category than their parents, so it won't report false recursion. */ static struct lock_class_key gpio_lock_class; #if defined(CONFIG_OF) static int at91_gpio_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw) { struct at91_gpio_chip *at91_gpio = h->host_data; <API key>(virq, &gpio_lock_class); /* * Can use the "simple" and not "edge" handler since it's * shorter, and the AIC handles interrupts sanely. */ <API key>(virq, &gpio_irqchip, handle_simple_irq); set_irq_flags(virq, IRQF_VALID); irq_set_chip_data(virq, at91_gpio); return 0; } static struct irq_domain_ops at91_gpio_ops = { .map = at91_gpio_irq_map, .xlate = <API key>, }; int __init <API key>(struct device_node *node, struct device_node *parent) { struct at91_gpio_chip *prev = NULL; int alias_idx = of_alias_get_id(node, "gpio"); struct at91_gpio_chip *at91_gpio = &gpio_chip[alias_idx]; /* Setup proper .irq_set_type function */ if (has_pio3()) gpio_irqchip.irq_set_type = alt_gpio_irq_type; else gpio_irqchip.irq_set_type = gpio_irq_type; /* Disable irqs of this PIO controller */ __raw_writel(~0, at91_gpio->regbase + PIO_IDR); /* Setup irq domain */ at91_gpio->domain = <API key>(node, at91_gpio->chip.ngpio, &at91_gpio_ops, at91_gpio); if (!at91_gpio->domain) panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n", at91_gpio->pioc_idx); /* Setup chained handler */ if (at91_gpio->pioc_idx) prev = &gpio_chip[at91_gpio->pioc_idx - 1]; /* The toplevel handler handles one bank of GPIOs, except * on some SoC it can handles up to three... * We only set up the handler for the first of the list. */ if (prev && prev->next == at91_gpio) return 0; at91_gpio->pioc_virq = irq_create_mapping(irq_find_host(parent), at91_gpio->pioc_hwirq); irq_set_chip_data(at91_gpio->pioc_virq, at91_gpio); <API key>(at91_gpio->pioc_virq, gpio_irq_handler); return 0; } #else int __init <API key>(struct device_node *node, struct device_node *parent) { return -EINVAL; } #endif /* * irqdomain initialization: pile up irqdomains on top of AIC range */ static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio) { int irq_base; irq_base = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0); if (irq_base < 0) panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n", at91_gpio->pioc_idx, irq_base); at91_gpio->domain = <API key>(NULL, at91_gpio->chip.ngpio, irq_base, 0, &<API key>, NULL); if (!at91_gpio->domain) panic("at91_gpio.%d: couldn't allocate irq domain.\n", at91_gpio->pioc_idx); } /* * Called from the processor-specific init to enable GPIO interrupt support. */ void __init at91_gpio_irq_setup(void) { unsigned pioc; int gpio_irqnbr = 0; struct at91_gpio_chip *this, *prev; /* Setup proper .irq_set_type function */ if (has_pio3()) gpio_irqchip.irq_set_type = alt_gpio_irq_type; else gpio_irqchip.irq_set_type = gpio_irq_type; for (pioc = 0, this = gpio_chip, prev = NULL; pioc++ < gpio_banks; prev = this, this++) { int offset; __raw_writel(~0, this->regbase + PIO_IDR); /* setup irq domain for this GPIO controller */ at91_gpio_irqdomain(this); for (offset = 0; offset < this->chip.ngpio; offset++) { unsigned int virq = irq_find_mapping(this->domain, offset); <API key>(virq, &gpio_lock_class); /* * Can use the "simple" and not "edge" handler since it's * shorter, and the AIC handles interrupts sanely. */ <API key>(virq, &gpio_irqchip, handle_simple_irq); set_irq_flags(virq, IRQF_VALID); irq_set_chip_data(virq, this); gpio_irqnbr++; } /* The toplevel handler handles one bank of GPIOs, except * on some SoC it can handles up to three... * We only set up the handler for the first of the list. */ if (prev && prev->next == this) continue; this->pioc_virq = irq_create_mapping(NULL, this->pioc_hwirq); irq_set_chip_data(this->pioc_virq, this); <API key>(this->pioc_virq, gpio_irq_handler); } pr_info("AT91: %d gpio irqs in %d banks\n", gpio_irqnbr, gpio_banks); } /* gpiolib support */ static int <API key>(struct gpio_chip *chip, unsigned offset) { struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; __raw_writel(mask, pio + PIO_ODR); return 0; } static int <API key>(struct gpio_chip *chip, unsigned offset, int val) { struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR)); __raw_writel(mask, pio + PIO_OER); return 0; } static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset) { struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 pdsr; pdsr = __raw_readl(pio + PIO_PDSR); return (pdsr & mask) != 0; } static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val) { struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR)); } static void <API key>(struct seq_file *s, struct gpio_chip *chip) { int i; for (i = 0; i < chip->ngpio; i++) { unsigned pin = chip->base + i; void __iomem *pio = pin_to_controller(pin); unsigned mask = pin_to_mask(pin); const char *gpio_label; gpio_label = <API key>(chip, i); if (gpio_label) { seq_printf(s, "[%s] GPIO%s%d: ", gpio_label, chip->label, i); if (__raw_readl(pio + PIO_PSR) & mask) seq_printf(s, "[gpio] %s\n", at91_get_gpio_value(pin) ? "set" : "clear"); else seq_printf(s, "[periph %c]\n", peripheral_function(pio, mask)); } } } static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset) { struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); int virq; if (offset < chip->ngpio) virq = irq_create_mapping(at91_gpio->domain, offset); else virq = -ENXIO; dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n", chip->label, offset + chip->base, virq); return virq; } static int __init at91_gpio_setup_clk(int idx) { struct at91_gpio_chip *at91_gpio = &gpio_chip[idx]; /* retreive PIO controller's clock */ at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label); if (IS_ERR(at91_gpio->clock)) { pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", idx); goto err; } if (clk_prepare(at91_gpio->clock)) goto clk_prep_err; /* enable PIO controller's clock */ if (clk_enable(at91_gpio->clock)) { pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx); goto clk_err; } return 0; clk_err: clk_unprepare(at91_gpio->clock); clk_prep_err: clk_put(at91_gpio->clock); err: return -EINVAL; } #ifdef CONFIG_OF_GPIO static void __init <API key>(struct device_node *np) { int alias_idx; struct at91_gpio_chip *at91_gpio; if (!np) return; alias_idx = of_alias_get_id(np, "gpio"); if (alias_idx >= MAX_GPIO_BANKS) { pr_err("at91_gpio, failed alias idx(%d) > MAX_GPIO_BANKS(%d), ignoring.\n", alias_idx, MAX_GPIO_BANKS); return; } at91_gpio = &gpio_chip[alias_idx]; at91_gpio->chip.base = alias_idx * at91_gpio->chip.ngpio; at91_gpio->regbase = of_iomap(np, 0); if (!at91_gpio->regbase) { pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", alias_idx); return; } /* Get the interrupts property */ if (<API key>(np, "interrupts", &at91_gpio->pioc_hwirq)) { pr_err("at91_gpio.%d, failed to get interrupts property, ignoring.\n", alias_idx); goto ioremap_err; } /* Get capabilities from compatibility property */ if (<API key>(np, "atmel,at91sam9x5-gpio")) at91_gpio_caps |= AT91_GPIO_CAP_PIO3; /* Setup clock */ if (at91_gpio_setup_clk(alias_idx)) goto ioremap_err; at91_gpio->chip.of_node = np; gpio_banks = max(gpio_banks, alias_idx + 1); at91_gpio->pioc_idx = alias_idx; return; ioremap_err: iounmap(at91_gpio->regbase); } static int __init of_at91_gpio_init(void) { struct device_node *np = NULL; /* * This isn't ideal, but it gets things hooked up until this * driver is converted into a platform_device */ <API key>(np, NULL, "atmel,at91rm9200-gpio") <API key>(np); return gpio_banks > 0 ? 0 : -EINVAL; } #else static int __init of_at91_gpio_init(void) { return -EINVAL; } #endif static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq) { struct at91_gpio_chip *at91_gpio = &gpio_chip[idx]; at91_gpio->chip.base = idx * at91_gpio->chip.ngpio; at91_gpio->pioc_hwirq = pioc_hwirq; at91_gpio->pioc_idx = idx; at91_gpio->regbase = ioremap(regbase, 512); if (!at91_gpio->regbase) { pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", idx); return; } if (at91_gpio_setup_clk(idx)) goto ioremap_err; gpio_banks = max(gpio_banks, idx + 1); return; ioremap_err: iounmap(at91_gpio->regbase); } /* * Called from the processor-specific init to enable GPIO pin support. */ void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks) { unsigned i; struct at91_gpio_chip *at91_gpio, *last = NULL; BUG_ON(nr_banks > MAX_GPIO_BANKS); if (of_at91_gpio_init() < 0) { /* No GPIO controller found in device tree */ for (i = 0; i < nr_banks; i++) at91_gpio_init_one(i, data[i].regbase, data[i].id); } for (i = 0; i < gpio_banks; i++) { at91_gpio = &gpio_chip[i]; /* * GPIO controller are grouped on some SoC: * PIOC, PIOD and PIOE can share the same IRQ line */ if (last && last->pioc_hwirq == at91_gpio->pioc_hwirq) last->next = at91_gpio; last = at91_gpio; gpiochip_add(&at91_gpio->chip); } }
! { dg-do compile } ! This tests the fix for PR28735 in which an ICE would be triggered in resolve_ref ! because the references to 'a' and 'b' in the dummy arguments of mysub have ! no symtrees in module bar, being private there. ! ! Contributed by Andrew Sampson <adsspamtrap01@yahoo.com> ! ! module foo implicit none public integer, allocatable :: a(:), b(:) end module foo ! module bar use foo implicit none private ! This triggered the ICE public :: mysub ! since a and b are not public contains subroutine mysub(n, parray1) integer, intent(in) :: n real, dimension(a(n):b(n)) :: parray1 if ((n == 1) .and. size(parray1, 1) /= 10) call abort () if ((n == 2) .and. size(parray1, 1) /= 42) call abort () end subroutine mysub end module bar ! subroutine sub() use foo use bar real :: z(100) allocate (a(2), b(2)) a = (/1, 6/) b = (/10, 47/) call mysub (1, z) call mysub (2, z) return end ! use bar call sub () end
using System; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Text; internal static partial class Interop { internal static partial class Winsock { [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, BestFitMapping = false, <API key> = true, SetLastError = true)] internal static extern int GetAddrInfoW( [In] string nodename, [In] string servicename, [In] ref AddressInfo hints, [Out] out SafeFreeAddrInfo handle ); } }
#include <linux/clk.h> #include <linux/clocksource.h> #include <linux/ptp_clock_kernel.h> #include <linux/net_tstamp.h> #include "xgbe.h" #include "xgbe-common.h" static cycle_t xgbe_cc_read(const struct cyclecounter *cc) { struct xgbe_prv_data *pdata = container_of(cc, struct xgbe_prv_data, tstamp_cc); u64 nsec; nsec = pdata->hw_if.get_tstamp_time(pdata); return nsec; } static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, ptp_clock_info); unsigned long flags; u64 adjust; u32 addend, diff; unsigned int neg_adjust = 0; if (delta < 0) { neg_adjust = 1; delta = -delta; } adjust = pdata->tstamp_addend; adjust *= delta; diff = div_u64(adjust, 1000000000UL); addend = (neg_adjust) ? pdata->tstamp_addend - diff : pdata->tstamp_addend + diff; spin_lock_irqsave(&pdata->tstamp_lock, flags); pdata->hw_if.<API key>(pdata, addend); <API key>(&pdata->tstamp_lock, flags); return 0; } static int xgbe_adjtime(struct ptp_clock_info *info, s64 delta) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, ptp_clock_info); unsigned long flags; spin_lock_irqsave(&pdata->tstamp_lock, flags); timecounter_adjtime(&pdata->tstamp_tc, delta); <API key>(&pdata->tstamp_lock, flags); return 0; } static int xgbe_gettime(struct ptp_clock_info *info, struct timespec *ts) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, ptp_clock_info); unsigned long flags; u64 nsec; spin_lock_irqsave(&pdata->tstamp_lock, flags); nsec = timecounter_read(&pdata->tstamp_tc); <API key>(&pdata->tstamp_lock, flags); *ts = ns_to_timespec(nsec); return 0; } static int xgbe_settime(struct ptp_clock_info *info, const struct timespec *ts) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, ptp_clock_info); unsigned long flags; u64 nsec; nsec = timespec_to_ns(ts); spin_lock_irqsave(&pdata->tstamp_lock, flags); timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, nsec); <API key>(&pdata->tstamp_lock, flags); return 0; } static int xgbe_enable(struct ptp_clock_info *info, struct ptp_clock_request *request, int on) { return -EOPNOTSUPP; } void xgbe_ptp_register(struct xgbe_prv_data *pdata) { struct ptp_clock_info *info = &pdata->ptp_clock_info; struct ptp_clock *clock; struct cyclecounter *cc = &pdata->tstamp_cc; u64 dividend; snprintf(info->name, sizeof(info->name), "%s", netdev_name(pdata->netdev)); info->owner = THIS_MODULE; info->max_adj = pdata->ptpclk_rate; info->adjfreq = xgbe_adjfreq; info->adjtime = xgbe_adjtime; info->gettime = xgbe_gettime; info->settime = xgbe_settime; info->enable = xgbe_enable; clock = ptp_clock_register(info, pdata->dev); if (IS_ERR(clock)) { dev_err(pdata->dev, "ptp_clock_register failed\n"); return; } pdata->ptp_clock = clock; /* Calculate the addend: * addend = 2^32 / (PTP ref clock / 50Mhz) * = (2^32 * 50Mhz) / PTP ref clock */ dividend = 50000000; dividend <<= 32; pdata->tstamp_addend = div_u64(dividend, pdata->ptpclk_rate); /* Setup the timecounter */ cc->read = xgbe_cc_read; cc->mask = CLOCKSOURCE_MASK(64); cc->mult = 1; cc->shift = 0; timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, ktime_to_ns(ktime_get_real())); /* Disable all timestamping to start */ XGMAC_IOWRITE(pdata, MAC_TCR, 0); pdata->tstamp_config.tx_type = HWTSTAMP_TX_OFF; pdata->tstamp_config.rx_filter = <API key>; } void xgbe_ptp_unregister(struct xgbe_prv_data *pdata) { if (pdata->ptp_clock) <API key>(pdata->ptp_clock); }
(function(window, angular, undefined) { 'use strict'; /** * @ngdoc object * @name angular.mock * @description * * Namespace from 'angular-mocks.js' which contains testing related code. */ angular.mock = {}; /** * ! This is a private undocumented service ! * * @name $browser * * @description * This service is a mock implementation of {@link ng.$browser}. It provides fake * implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr, * cookies, etc... * * The api of this service is the same as that of the real {@link ng.$browser $browser}, except * that there are several helper methods available which can be used in tests. */ angular.mock.$BrowserProvider = function() { this.$get = function() { return new angular.mock.$Browser(); }; }; angular.mock.$Browser = function() { var self = this; this.isMock = true; self.$$url = "http://server/"; self.$$lastUrl = self.$$url; // used by url polling fn self.pollFns = []; // TODO(vojta): remove this temporary api self.$$<API key> = angular.noop; self.$$<API key> = angular.noop; // register url polling fn self.onUrlChange = function(listener) { self.pollFns.push( function() { if (self.$$lastUrl !== self.$$url || self.$$state !== self.$$lastState) { self.$$lastUrl = self.$$url; self.$$lastState = self.$$state; listener(self.$$url, self.$$state); } } ); return listener; }; self.$$checkUrlChange = angular.noop; self.cookieHash = {}; self.lastCookieHash = {}; self.deferredFns = []; self.deferredNextId = 0; self.defer = function(fn, delay) { delay = delay || 0; self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId}); self.deferredFns.sort(function(a, b) { return a.time - b.time;}); return self.deferredNextId++; }; /** * @name $browser#defer.now * * @description * Current milliseconds mock time. */ self.defer.now = 0; self.defer.cancel = function(deferId) { var fnIndex; angular.forEach(self.deferredFns, function(fn, index) { if (fn.id === deferId) fnIndex = index; }); if (fnIndex !== undefined) { self.deferredFns.splice(fnIndex, 1); return true; } return false; }; /** * @name $browser#defer.flush * * @description * Flushes all pending requests and executes the defer callbacks. * * @param {number=} number of milliseconds to flush. See {@link #defer.now} */ self.defer.flush = function(delay) { if (angular.isDefined(delay)) { self.defer.now += delay; } else { if (self.deferredFns.length) { self.defer.now = self.deferredFns[self.deferredFns.length - 1].time; } else { throw new Error('No deferred tasks to be flushed'); } } while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) { self.deferredFns.shift().fn(); } }; self.$$baseHref = '/'; self.baseHref = function() { return this.$$baseHref; }; }; angular.mock.$Browser.prototype = { /** * @name $browser#poll * * @description * run all fns in pollFns */ poll: function poll() { angular.forEach(this.pollFns, function(pollFn) { pollFn(); }); }, addPollFn: function(pollFn) { this.pollFns.push(pollFn); return pollFn; }, url: function(url, replace, state) { if (angular.isUndefined(state)) { state = null; } if (url) { this.$$url = url; // Native pushState serializes & copies the object; simulate it. this.$$state = angular.copy(state); return this; } return this.$$url; }, state: function() { return this.$$state; }, cookies: function(name, value) { if (name) { if (angular.isUndefined(value)) { delete this.cookieHash[name]; } else { if (angular.isString(value) && //strings only value.length <= 4096) { //strict cookie storage limits this.cookieHash[name] = value; } } } else { if (!angular.equals(this.cookieHash, this.lastCookieHash)) { this.lastCookieHash = angular.copy(this.cookieHash); this.cookieHash = angular.copy(this.cookieHash); } return this.cookieHash; } }, <API key>: function(fn) { fn(); } }; /** * @ngdoc provider * @name $<API key> * * @description * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors * passed to the `$exceptionHandler`. */ /** * @ngdoc service * @name $exceptionHandler * * @description * Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed * to it. See {@link ngMock.$<API key> $<API key>} for configuration * information. * * * ```js * describe('$<API key>', function() { * * it('should capture log messages and exceptions', function() { * * module(function($<API key>) { * $<API key>.mode('log'); * }); * * inject(function($log, $exceptionHandler, $timeout) { * $timeout(function() { $log.log(1); }); * $timeout(function() { $log.log(2); throw 'banana peel'; }); * $timeout(function() { $log.log(3); }); * expect($exceptionHandler.errors).toEqual([]); * expect($log.assertEmpty()); * $timeout.flush(); * expect($exceptionHandler.errors).toEqual(['banana peel']); * expect($log.log.logs).toEqual([[1], [2], [3]]); * }); * }); * }); * ``` */ angular.mock.$<API key> = function() { var handler; /** * @ngdoc method * @name $<API key>#mode * * @description * Sets the logging mode. * * @param {string} mode Mode of operation, defaults to `rethrow`. * * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log` * mode stores an array of errors in `$exceptionHandler.errors`, to allow later * assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and * {@link ngMock.$log#reset reset()} * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there * is a bug in the application or test, so this mock will make these tests fail. * For any implementations that expect exceptions to be thrown, the `rethrow` mode * will also maintain a log of thrown errors. */ this.mode = function(mode) { switch (mode) { case 'log': case 'rethrow': var errors = []; handler = function(e) { if (arguments.length == 1) { errors.push(e); } else { errors.push([].slice.call(arguments, 0)); } if (mode === "rethrow") { throw e; } }; handler.errors = errors; break; default: throw new Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!"); } }; this.$get = function() { return handler; }; this.mode('rethrow'); }; /** * @ngdoc service * @name $log * * @description * Mock implementation of {@link ng.$log} that gathers all logged messages in arrays * (one array per logging level). These arrays are exposed as `logs` property of each of the * level-specific log function, e.g. for level `error` the array is exposed as `$log.error.logs`. * */ angular.mock.$LogProvider = function() { var debug = true; function concat(array1, array2, index) { return array1.concat(Array.prototype.slice.call(array2, index)); } this.debugEnabled = function(flag) { if (angular.isDefined(flag)) { debug = flag; return this; } else { return debug; } }; this.$get = function() { var $log = { log: function() { $log.log.logs.push(concat([], arguments, 0)); }, warn: function() { $log.warn.logs.push(concat([], arguments, 0)); }, info: function() { $log.info.logs.push(concat([], arguments, 0)); }, error: function() { $log.error.logs.push(concat([], arguments, 0)); }, debug: function() { if (debug) { $log.debug.logs.push(concat([], arguments, 0)); } } }; /** * @ngdoc method * @name $log#reset * * @description * Reset all of the logging arrays to empty. */ $log.reset = function() { /** * @ngdoc property * @name $log#log.logs * * @description * Array of messages logged using {@link ng.$log#log `log()`}. * * @example * ```js * $log.log('Some Log'); * var first = $log.log.logs.unshift(); * ``` */ $log.log.logs = []; /** * @ngdoc property * @name $log#info.logs * * @description * Array of messages logged using {@link ng.$log#info `info()`}. * * @example * ```js * $log.info('Some Info'); * var first = $log.info.logs.unshift(); * ``` */ $log.info.logs = []; /** * @ngdoc property * @name $log#warn.logs * * @description * Array of messages logged using {@link ng.$log#warn `warn()`}. * * @example * ```js * $log.warn('Some Warning'); * var first = $log.warn.logs.unshift(); * ``` */ $log.warn.logs = []; /** * @ngdoc property * @name $log#error.logs * * @description * Array of messages logged using {@link ng.$log#error `error()`}. * * @example * ```js * $log.error('Some Error'); * var first = $log.error.logs.unshift(); * ``` */ $log.error.logs = []; /** * @ngdoc property * @name $log#debug.logs * * @description * Array of messages logged using {@link ng.$log#debug `debug()`}. * * @example * ```js * $log.debug('Some Error'); * var first = $log.debug.logs.unshift(); * ``` */ $log.debug.logs = []; }; /** * @ngdoc method * @name $log#assertEmpty * * @description * Assert that all of the logging methods have no logged messages. If any messages are present, * an exception is thrown. */ $log.assertEmpty = function() { var errors = []; angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) { angular.forEach($log[logLevel].logs, function(log) { angular.forEach(log, function(logItem) { errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + (logItem.stack || '')); }); }); }); if (errors.length) { errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or " + "an expected log message was not checked and removed:"); errors.push(''); throw new Error(errors.join('\n } }; $log.reset(); return $log; }; }; /** * @ngdoc service * @name $interval * * @description * Mock implementation of the $interval service. * * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to * move forward by `millis` milliseconds and trigger any functions scheduled to run in that * time. * * @param {function()} fn A function that should be called repeatedly. * @param {number} delay Number of milliseconds between each function call. * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat * indefinitely. * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. * @returns {promise} A promise which will be notified on each iteration. */ angular.mock.$IntervalProvider = function() { this.$get = ['$browser', '$rootScope', '$q', '$$q', function($browser, $rootScope, $q, $$q) { var repeatFns = [], nextRepeatId = 0, now = 0; var $interval = function(fn, delay, count, invokeApply) { var iteration = 0, skipApply = (angular.isDefined(invokeApply) && !invokeApply), deferred = (skipApply ? $$q : $q).defer(), promise = deferred.promise; count = (angular.isDefined(count)) ? count : 0; promise.then(null, null, fn); promise.$$intervalId = nextRepeatId; function tick() { deferred.notify(iteration++); if (count > 0 && iteration >= count) { var fnIndex; deferred.resolve(iteration); angular.forEach(repeatFns, function(fn, index) { if (fn.id === promise.$$intervalId) fnIndex = index; }); if (fnIndex !== undefined) { repeatFns.splice(fnIndex, 1); } } if (skipApply) { $browser.defer.flush(); } else { $rootScope.$apply(); } } repeatFns.push({ nextTime:(now + delay), delay: delay, fn: tick, id: nextRepeatId, deferred: deferred }); repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;}); nextRepeatId++; return promise; }; /** * @ngdoc method * @name $interval#cancel * * @description * Cancels a task associated with the `promise`. * * @param {promise} promise A promise from calling the `$interval` function. * @returns {boolean} Returns `true` if the task was successfully cancelled. */ $interval.cancel = function(promise) { if (!promise) return false; var fnIndex; angular.forEach(repeatFns, function(fn, index) { if (fn.id === promise.$$intervalId) fnIndex = index; }); if (fnIndex !== undefined) { repeatFns[fnIndex].deferred.reject('canceled'); repeatFns.splice(fnIndex, 1); return true; } return false; }; /** * @ngdoc method * @name $interval#flush * @description * * Runs interval tasks scheduled to be run in the next `millis` milliseconds. * * @param {number=} millis maximum timeout amount to flush up until. * * @return {number} The amount of time moved forward. */ $interval.flush = function(millis) { now += millis; while (repeatFns.length && repeatFns[0].nextTime <= now) { var task = repeatFns[0]; task.fn(); task.nextTime += task.delay; repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;}); } return millis; }; return $interval; }]; }; /* jshint -W101 */ /* The R_ISO8061_STR regex is never going to fit into the 100 char limit! * This directive should go inside the anonymous function but a bug in JSHint means that it would * not be enacted early enough to prevent the warning. */ var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; function jsonStringToDate(string) { var match; if (match = string.match(R_ISO8061_STR)) { var date = new Date(0), tzHour = 0, tzMin = 0; if (match[9]) { tzHour = int(match[9] + match[10]); tzMin = int(match[9] + match[11]); } date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); date.setUTCHours(int(match[4] || 0) - tzHour, int(match[5] || 0) - tzMin, int(match[6] || 0), int(match[7] || 0)); return date; } return string; } function int(str) { return parseInt(str, 10); } function padNumber(num, digits, trim) { var neg = ''; if (num < 0) { neg = '-'; num = -num; } num = '' + num; while (num.length < digits) num = '0' + num; if (trim) num = num.substr(num.length - digits); return neg + num; } /** * @ngdoc type * @name angular.mock.TzDate * @description * * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`. * * Mock of the Date type which has its timezone specified via constructor arg. * * The main purpose is to create Date-like instances with timezone fixed to the specified timezone * offset, so that we can test code that depends on local timezone settings without dependency on * the time zone settings of the machine where the code is running. * * @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored) * @param {(number|string)} timestamp Timestamp representing the desired time in *UTC* * * @example * !!!! WARNING !!!!! * This is not a complete Date object so only methods that were implemented can be called safely. * To make matters worse, TzDate instances inherit stuff from Date via a prototype. * * We do our best to intercept calls to "unimplemented" methods, but since the list of methods is * incomplete we might be missing some non-standard methods. This can result in errors like: * "Date.prototype.foo called on incompatible Object". * * ```js * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z'); * newYearInBratislava.getTimezoneOffset() => -60; * newYearInBratislava.getFullYear() => 2010; * newYearInBratislava.getMonth() => 0; * newYearInBratislava.getDate() => 1; * newYearInBratislava.getHours() => 0; * newYearInBratislava.getMinutes() => 0; * newYearInBratislava.getSeconds() => 0; * ``` * */ angular.mock.TzDate = function(offset, timestamp) { var self = new Date(0); if (angular.isString(timestamp)) { var tsStr = timestamp; self.origDate = jsonStringToDate(timestamp); timestamp = self.origDate.getTime(); if (isNaN(timestamp)) throw { name: "Illegal Argument", message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string" }; } else { self.origDate = new Date(timestamp); } var localOffset = new Date(timestamp).getTimezoneOffset(); self.offsetDiff = localOffset * 60 * 1000 - offset * 1000 * 60 * 60; self.date = new Date(timestamp + self.offsetDiff); self.getTime = function() { return self.date.getTime() - self.offsetDiff; }; self.toLocaleDateString = function() { return self.date.toLocaleDateString(); }; self.getFullYear = function() { return self.date.getFullYear(); }; self.getMonth = function() { return self.date.getMonth(); }; self.getDate = function() { return self.date.getDate(); }; self.getHours = function() { return self.date.getHours(); }; self.getMinutes = function() { return self.date.getMinutes(); }; self.getSeconds = function() { return self.date.getSeconds(); }; self.getMilliseconds = function() { return self.date.getMilliseconds(); }; self.getTimezoneOffset = function() { return offset * 60; }; self.getUTCFullYear = function() { return self.origDate.getUTCFullYear(); }; self.getUTCMonth = function() { return self.origDate.getUTCMonth(); }; self.getUTCDate = function() { return self.origDate.getUTCDate(); }; self.getUTCHours = function() { return self.origDate.getUTCHours(); }; self.getUTCMinutes = function() { return self.origDate.getUTCMinutes(); }; self.getUTCSeconds = function() { return self.origDate.getUTCSeconds(); }; self.getUTCMilliseconds = function() { return self.origDate.getUTCMilliseconds(); }; self.getDay = function() { return self.date.getDay(); }; // provide this method only on browsers that already have it if (self.toISOString) { self.toISOString = function() { return padNumber(self.origDate.getUTCFullYear(), 4) + '-' + padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' + padNumber(self.origDate.getUTCDate(), 2) + 'T' + padNumber(self.origDate.getUTCHours(), 2) + ':' + padNumber(self.origDate.getUTCMinutes(), 2) + ':' + padNumber(self.origDate.getUTCSeconds(), 2) + '.' + padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'; }; } //hide all methods not implemented in this mock that the Date prototype exposes var <API key> = ['getUTCDay', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString', 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf']; angular.forEach(<API key>, function(methodName) { self[methodName] = function() { throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock"); }; }); return self; }; //make "tzDateInstance instanceof Date" return true angular.mock.TzDate.prototype = Date.prototype; /* jshint +W101 */ angular.mock.animate = angular.module('ngAnimateMock', ['ng']) .config(['$provide', function($provide) { var reflowQueue = []; $provide.value('$$animateReflow', function(fn) { var index = reflowQueue.length; reflowQueue.push(fn); return function cancel() { reflowQueue.splice(index, 1); }; }); $provide.decorator('$animate', ['$delegate', '$$asyncCallback', '$timeout', '$browser', function($delegate, $$asyncCallback, $timeout, $browser) { var animate = { queue: [], cancel: $delegate.cancel, enabled: $delegate.enabled, <API key>: function() { $$asyncCallback.flush(); }, <API key>: function() { $timeout.flush(0); }, triggerCallbacks: function() { this.<API key>(); this.<API key>(); }, triggerReflow: function() { angular.forEach(reflowQueue, function(fn) { fn(); }); reflowQueue = []; } }; angular.forEach( ['animate','enter','leave','move','addClass','removeClass','setClass'], function(method) { animate[method] = function() { animate.queue.push({ event: method, element: arguments[0], options: arguments[arguments.length - 1], args: arguments }); return $delegate[method].apply($delegate, arguments); }; }); return animate; }]); }]); /** * @ngdoc function * @name angular.mock.dump * @description * * *NOTE*: this is not an injectable instance, just a globally available function. * * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for * debugging. * * This method is also available on window, where it can be used to display objects on debug * console. * * @param {*} object - any object to turn into string. * @return {string} a serialized string of the argument */ angular.mock.dump = function(object) { return serialize(object); function serialize(object) { var out; if (angular.isElement(object)) { object = angular.element(object); out = angular.element('<div></div>'); angular.forEach(object, function(element) { out.append(angular.element(element).clone()); }); out = out.html(); } else if (angular.isArray(object)) { out = []; angular.forEach(object, function(o) { out.push(serialize(o)); }); out = '[ ' + out.join(', ') + ' ]'; } else if (angular.isObject(object)) { if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) { out = serializeScope(object); } else if (object instanceof Error) { out = object.stack || ('' + object.name + ': ' + object.message); } else { // TODO(i): this prevents methods being logged, // we should have a better way to serialize objects out = angular.toJson(object, true); } } else { out = String(object); } return out; } function serializeScope(scope, offset) { offset = offset || ' '; var log = [offset + 'Scope(' + scope.$id + '): {']; for (var key in scope) { if (Object.prototype.hasOwnProperty.call(scope, key) && !key.match(/^(\$|this)/)) { log.push(' ' + key + ': ' + angular.toJson(scope[key])); } } var child = scope.$$childHead; while (child) { log.push(serializeScope(child, offset + ' ')); child = child.$$nextSibling; } log.push('}'); return log.join('\n' + offset); } }; angular.mock.$HttpBackendProvider = function() { this.$get = ['$rootScope', '$timeout', <API key>]; }; /** * General factory function for $httpBackend mock. * Returns instance for unit testing (when no arguments specified): * - passing through is disabled * - auto flushing is disabled * * Returns instance for e2e testing (when `$delegate` and `$browser` specified): * - passing through (delegating request to real backend) is enabled * - auto flushing is enabled * * @param {Object=} $delegate Real $httpBackend instance (allow passing through if specified) * @param {Object=} $browser Auto-flushing enabled if specified * @return {Object} Instance of $httpBackend mock */ function <API key>($rootScope, $timeout, $delegate, $browser) { var definitions = [], expectations = [], responses = [], responsesPush = angular.bind(responses, responses.push), copy = angular.copy; function createResponse(status, data, headers, statusText) { if (angular.isFunction(status)) return status; return function() { return angular.isNumber(status) ? [status, data, headers, statusText] : [200, status, data, headers]; }; } // TODO(vojta): change params to: method, url, data, headers, callback function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) { var xhr = new MockXhr(), expectation = expectations[0], wasExpected = false; function prettyPrint(data) { return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp) ? data : angular.toJson(data); } function wrapResponse(wrapped) { if (!$browser && timeout) { timeout.then ? timeout.then(handleTimeout) : $timeout(handleTimeout, timeout); } return handleResponse; function handleResponse() { var response = wrapped.response(method, url, data, headers); xhr.$$respHeaders = response[2]; callback(copy(response[0]), copy(response[1]), xhr.<API key>(), copy(response[3] || '')); } function handleTimeout() { for (var i = 0, ii = responses.length; i < ii; i++) { if (responses[i] === handleResponse) { responses.splice(i, 1); callback(-1, undefined, ''); break; } } } } if (expectation && expectation.match(method, url)) { if (!expectation.matchData(data)) throw new Error('Expected ' + expectation + ' with different data\n' + 'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data); if (!expectation.matchHeaders(headers)) throw new Error('Expected ' + expectation + ' with different headers\n' + 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + prettyPrint(headers)); expectations.shift(); if (expectation.response) { responses.push(wrapResponse(expectation)); return; } wasExpected = true; } var i = -1, definition; while ((definition = definitions[++i])) { if (definition.match(method, url, data, headers || {})) { if (definition.response) { // if $browser specified, we do auto flush all requests ($browser ? $browser.defer : responsesPush)(wrapResponse(definition)); } else if (definition.passThrough) { $delegate(method, url, data, callback, headers, timeout, withCredentials); } else throw new Error('No response defined !'); return; } } throw wasExpected ? new Error('No response defined !') : new Error('Unexpected request: ' + method + ' ' + url + '\n' + (expectation ? 'Expected ' + expectation : 'No more request expected')); } $httpBackend.when = function(method, url, data, headers) { var definition = new MockHttpExpectation(method, url, data, headers), chain = { respond: function(status, data, headers, statusText) { definition.passThrough = undefined; definition.response = createResponse(status, data, headers, statusText); return chain; } }; if ($browser) { chain.passThrough = function() { definition.response = undefined; definition.passThrough = true; return chain; }; } definitions.push(definition); return chain; }; /** * @ngdoc method * @name $httpBackend#whenGET * @description * Creates a new backend definition for GET requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenHEAD * @description * Creates a new backend definition for HEAD requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenDELETE * @description * Creates a new backend definition for DELETE requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenPOST * @description * Creates a new backend definition for POST requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives * data string and returns true if the data is as expected. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenPUT * @description * Creates a new backend definition for PUT requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives * data string and returns true if the data is as expected. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenJSONP * @description * Creates a new backend definition for JSONP requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ createShortMethods('when'); $httpBackend.expect = function(method, url, data, headers) { var expectation = new MockHttpExpectation(method, url, data, headers), chain = { respond: function(status, data, headers, statusText) { expectation.response = createResponse(status, data, headers, statusText); return chain; } }; expectations.push(expectation); return chain; }; /** * @ngdoc method * @name $httpBackend#expectGET * @description * Creates a new request expectation for GET requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. See #expect for more info. */ /** * @ngdoc method * @name $httpBackend#expectHEAD * @description * Creates a new request expectation for HEAD requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#expectDELETE * @description * Creates a new request expectation for DELETE requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#expectPOST * @description * Creates a new request expectation for POST requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that * receives data string and returns true if the data is as expected, or Object if request body * is in JSON format. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#expectPUT * @description * Creates a new request expectation for PUT requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that * receives data string and returns true if the data is as expected, or Object if request body * is in JSON format. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#expectPATCH * @description * Creates a new request expectation for PATCH requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that * receives data string and returns true if the data is as expected, or Object if request body * is in JSON format. * @param {Object=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#expectJSONP * @description * Creates a new request expectation for JSONP requests. For more info see `expect()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @returns {requestHandler} Returns an object with `respond` method that controls how a matched * request is handled. You can save this object for later use and invoke `respond` again in * order to change how a matched request is handled. */ createShortMethods('expect'); /** * @ngdoc method * @name $httpBackend#flush * @description * Flushes all pending requests using the trained responses. * * @param {number=} count Number of responses to flush (in the order they arrived). If undefined, * all pending requests will be flushed. If there are no pending requests when the flush method * is called an exception is thrown (as this typically a sign of programming error). */ $httpBackend.flush = function(count, digest) { if (digest !== false) $rootScope.$digest(); if (!responses.length) throw new Error('No pending request to flush !'); if (angular.isDefined(count) && count !== null) { while (count if (!responses.length) throw new Error('No more pending request to flush !'); responses.shift()(); } } else { while (responses.length) { responses.shift()(); } } $httpBackend.<API key>(digest); }; /** * @ngdoc method * @name $httpBackend#<API key> * @description * Verifies that all of the requests defined via the `expect` api were made. If any of the * requests were not made, <API key> throws an exception. * * Typically, you would call this method following each test case that asserts requests using an * "afterEach" clause. * * ```js * afterEach($httpBackend.<API key>); * ``` */ $httpBackend.<API key> = function(digest) { if (digest !== false) $rootScope.$digest(); if (expectations.length) { throw new Error('Unsatisfied requests: ' + expectations.join(', ')); } }; /** * @ngdoc method * @name $httpBackend#<API key> * @description * Verifies that there are no outstanding requests that need to be flushed. * * Typically, you would call this method following each test case that asserts requests using an * "afterEach" clause. * * ```js * afterEach($httpBackend.<API key>); * ``` */ $httpBackend.<API key> = function() { if (responses.length) { throw new Error('Unflushed requests: ' + responses.length); } }; /** * @ngdoc method * @name $httpBackend#resetExpectations * @description * Resets all request expectations, but preserves all backend definitions. Typically, you would * call resetExpectations during a multiple-phase test when you want to reuse the same instance of * $httpBackend mock. */ $httpBackend.resetExpectations = function() { expectations.length = 0; responses.length = 0; }; return $httpBackend; function createShortMethods(prefix) { angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD'], function(method) { $httpBackend[prefix + method] = function(url, headers) { return $httpBackend[prefix](method, url, undefined, headers); }; }); angular.forEach(['PUT', 'POST', 'PATCH'], function(method) { $httpBackend[prefix + method] = function(url, data, headers) { return $httpBackend[prefix](method, url, data, headers); }; }); } } function MockHttpExpectation(method, url, data, headers) { this.data = data; this.headers = headers; this.match = function(m, u, d, h) { if (method != m) return false; if (!this.matchUrl(u)) return false; if (angular.isDefined(d) && !this.matchData(d)) return false; if (angular.isDefined(h) && !this.matchHeaders(h)) return false; return true; }; this.matchUrl = function(u) { if (!url) return true; if (angular.isFunction(url.test)) return url.test(u); if (angular.isFunction(url)) return url(u); return url == u; }; this.matchHeaders = function(h) { if (angular.isUndefined(headers)) return true; if (angular.isFunction(headers)) return headers(h); return angular.equals(headers, h); }; this.matchData = function(d) { if (angular.isUndefined(data)) return true; if (data && angular.isFunction(data.test)) return data.test(d); if (data && angular.isFunction(data)) return data(d); if (data && !angular.isString(data)) { return angular.equals(angular.fromJson(angular.toJson(data)), angular.fromJson(d)); } return data == d; }; this.toString = function() { return method + ' ' + url; }; } function createMockXhr() { return new MockXhr(); } function MockXhr() { // hack for testing $http, $httpBackend MockXhr.$$lastInstance = this; this.open = function(method, url, async) { this.$$method = method; this.$$url = url; this.$$async = async; this.$$reqHeaders = {}; this.$$respHeaders = {}; }; this.send = function(data) { this.$$data = data; }; this.setRequestHeader = function(key, value) { this.$$reqHeaders[key] = value; }; this.getResponseHeader = function(name) { // the lookup must be case insensitive, // that's why we try two quick lookups first and full scan last var header = this.$$respHeaders[name]; if (header) return header; name = angular.lowercase(name); header = this.$$respHeaders[name]; if (header) return header; header = undefined; angular.forEach(this.$$respHeaders, function(headerVal, headerName) { if (!header && angular.lowercase(headerName) == name) header = headerVal; }); return header; }; this.<API key> = function() { var lines = []; angular.forEach(this.$$respHeaders, function(value, key) { lines.push(key + ': ' + value); }); return lines.join('\n'); }; this.abort = angular.noop; } /** * @ngdoc service * @name $timeout * @description * * This service is just a simple decorator for {@link ng.$timeout $timeout} service * that adds a "flush" and "<API key>" methods. */ angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $browser) { /** * @ngdoc method * @name $timeout#flush * @description * * Flushes the queue of pending tasks. * * @param {number=} delay maximum timeout amount to flush up until */ $delegate.flush = function(delay) { $browser.defer.flush(delay); }; /** * @ngdoc method * @name $timeout#<API key> * @description * * Verifies that there are no pending tasks that need to be flushed. */ $delegate.<API key> = function() { if ($browser.deferredFns.length) { throw new Error('Deferred tasks to flush (' + $browser.deferredFns.length + '): ' + <API key>($browser.deferredFns)); } }; function <API key>(tasks) { var result = []; angular.forEach(tasks, function(task) { result.push('{id: ' + task.id + ', ' + 'time: ' + task.time + '}'); }); return result.join(', '); } return $delegate; }]; angular.mock.$RAFDecorator = ['$delegate', function($delegate) { var queue = []; var rafFn = function(fn) { var index = queue.length; queue.push(fn); return function() { queue.splice(index, 1); }; }; rafFn.supported = $delegate.supported; rafFn.flush = function() { if (queue.length === 0) { throw new Error('No rAF callbacks present'); } var length = queue.length; for (var i = 0; i < length; i++) { queue[i](); } queue = []; }; return rafFn; }]; angular.mock.$<API key> = ['$delegate', function($delegate) { var callbacks = []; var addFn = function(fn) { callbacks.push(fn); }; addFn.flush = function() { angular.forEach(callbacks, function(fn) { fn(); }); callbacks = []; }; return addFn; }]; angular.mock.$RootElementProvider = function() { this.$get = function() { return angular.element('<div ng-app></div>'); }; }; * var ctrl = $controller('MyDirective', { /* no locals &#42;/ }, { name: 'Clark Kent' }); * expect(ctrl.name).toEqual('Clark Kent'); * expect($log.info.logs).toEqual(['Clark Kent']); * }); * }); * * ``` * * @param {Function|string} constructor If called with a function then it's considered to be the * controller constructor function. Otherwise it's considered to be a string which is used * to retrieve the controller constructor using the following steps: * * * check if a controller with given name is registered via `$controllerProvider` * * check if evaluating the string on the current scope returns a constructor * * if $controllerProvider#allowGlobals, check `window[constructor]` on the global * `window` object (not recommended) * * The string can use the `controller as property` syntax, where the controller instance is published * as the specified property on the `scope`; the `scope` must be injected into `locals` param for this * to work correctly. * * @param {Object} locals Injection locals for Controller. * @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used * to simulate the `bindToController` feature and simplify certain kinds of tests. * @return {Object} Instance of given controller. */ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) { return function(expression, locals, later, ident) { if (later && typeof later === 'object') { var create = $delegate(expression, locals, true, ident); angular.extend(create.instance, later); return create(); } return $delegate(expression, locals, later, ident); }; }]; /** * @ngdoc module * @name ngMock * @packageName angular-mocks * @description * * # ngMock * * The `ngMock` module provides support to inject and mock Angular services into unit tests. * In addition, ngMock also extends various core ng services such that they can be * inspected and controlled in a synchronous manner within test code. * * * <div <API key>="ngMock"></div> * */ angular.module('ngMock', ['ng']).provider({ $browser: angular.mock.$BrowserProvider, $exceptionHandler: angular.mock.$<API key>, $log: angular.mock.$LogProvider, $interval: angular.mock.$IntervalProvider, $httpBackend: angular.mock.$HttpBackendProvider, $rootElement: angular.mock.$RootElementProvider }).config(['$provide', function($provide) { $provide.decorator('$timeout', angular.mock.$TimeoutDecorator); $provide.decorator('$$rAF', angular.mock.$RAFDecorator); $provide.decorator('$$asyncCallback', angular.mock.$<API key>); $provide.decorator('$rootScope', angular.mock.$RootScopeDecorator); $provide.decorator('$controller', angular.mock.$ControllerDecorator); }]); /** * @ngdoc module * @name ngMockE2E * @module ngMockE2E * @packageName angular-mocks * @description * * The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing. * Currently there is only one mock present in this module - * the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock. */ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { $provide.decorator('$httpBackend', angular.mock.e2e.$<API key>); }]); /** * @ngdoc service * @name $httpBackend * @module ngMockE2E * @description * Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of * applications that use the {@link ng.$http $http service}. * * *Note*: For fake http backend implementation suitable for unit testing please see * {@link ngMock.$httpBackend unit-testing $httpBackend mock}. * * This implementation can be used to respond with static or dynamic responses via the `when` api * and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the * real $httpBackend for specific requests (e.g. to interact with certain remote apis or to fetch * templates from a webserver). * * As opposed to unit-testing, in an end-to-end testing scenario or in scenario when an application * is being developed with the real backend api replaced with a mock, it is often desirable for * certain category of requests to bypass the mock and issue a real http request (e.g. to fetch * templates or static files from the webserver). To configure the backend with this behavior * use the `passThrough` request handler of `when` instead of `respond`. * * Additionally, we don't want to manually have to flush mocked out requests like we do during unit * testing. For this reason the e2e $httpBackend flushes mocked out requests * automatically, closely simulating the behavior of the XMLHttpRequest object. * * To setup the application to run with this http backend, you have to create a module that depends * on the `ngMockE2E` and your application modules and defines the fake backend: * * ```js * myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']); * myAppDev.run(function($httpBackend) { * phones = [{name: 'phone1'}, {name: 'phone2'}]; * * // returns the current list of phones * $httpBackend.whenGET('/phones').respond(phones); * * // adds a new phone to the phones array * $httpBackend.whenPOST('/phones').respond(function(method, url, data) { * var phone = angular.fromJson(data); * phones.push(phone); * return [200, phone, {}]; * }); * $httpBackend.whenGET(/^\/templates\//).passThrough(); * //... * }); * ``` * * Afterwards, bootstrap your app with this new module. */ /** * @ngdoc method * @name $httpBackend#whenGET * @module ngMockE2E * @description * Creates a new backend definition for GET requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenHEAD * @module ngMockE2E * @description * Creates a new backend definition for HEAD requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenDELETE * @module ngMockE2E * @description * Creates a new backend definition for DELETE requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenPOST * @module ngMockE2E * @description * Creates a new backend definition for POST requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp)=} data HTTP request body. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenPUT * @module ngMockE2E * @description * Creates a new backend definition for PUT requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp)=} data HTTP request body. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenPATCH * @module ngMockE2E * @description * Creates a new backend definition for PATCH requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @param {(string|RegExp)=} data HTTP request body. * @param {(Object|function(Object))=} headers HTTP headers. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ /** * @ngdoc method * @name $httpBackend#whenJSONP * @module ngMockE2E * @description * Creates a new backend definition for JSONP requests. For more info see `when()`. * * @param {string|RegExp|function(string)} url HTTP url or function that receives the url * and returns true if the url match the current definition. * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that * control how a matched request is handled. You can save this object for later use and invoke * `respond` or `passThrough` again in order to change how a matched request is handled. */ angular.mock.e2e = {}; angular.mock.e2e.$<API key> = ['$rootScope', '$timeout', '$delegate', '$browser', <API key>]; /** * @ngdoc type * @name $rootScope.Scope * @module ngMock * @description * {@link ng.$rootScope.Scope Scope} type decorated with helper methods useful for testing. These * methods are automatically available on any {@link ng.$rootScope.Scope Scope} instance when * `ngMock` module is loaded. * * In addition to all the regular `Scope` methods, the following helper methods are available: */ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) { var $rootScopePrototype = Object.getPrototypeOf($delegate); $rootScopePrototype.$countChildScopes = countChildScopes; $rootScopePrototype.$countWatchers = countWatchers; return $delegate; /** * @ngdoc method * @name $rootScope.Scope#$countChildScopes * @module ngMock * @description * Counts all the direct and indirect child scopes of the current scope. * * The current scope is excluded from the count. The count includes all isolate child scopes. * * @returns {number} Total number of child scopes. */ function countChildScopes() { // jshint validthis: true var count = 0; // exclude the current scope var pendingChildHeads = [this.$$childHead]; var currentScope; while (pendingChildHeads.length) { currentScope = pendingChildHeads.shift(); while (currentScope) { count += 1; pendingChildHeads.push(currentScope.$$childHead); currentScope = currentScope.$$nextSibling; } } return count; } /** * @ngdoc method * @name $rootScope.Scope#$countWatchers * @module ngMock * @description * Counts all the watchers of direct and indirect child scopes of the current scope. * * The watchers of the current scope are included in the count and so are all the watchers of * isolate child scopes. * * @returns {number} Total number of watchers. */ function countWatchers() { // jshint validthis: true var count = this.$$watchers ? this.$$watchers.length : 0; // include the current scope var pendingChildHeads = [this.$$childHead]; var currentScope; while (pendingChildHeads.length) { currentScope = pendingChildHeads.shift(); while (currentScope) { count += currentScope.$$watchers ? currentScope.$$watchers.length : 0; pendingChildHeads.push(currentScope.$$childHead); currentScope = currentScope.$$nextSibling; } } return count; } }]; if (window.jasmine || window.mocha) { var currentSpec = null, annotatedFunctions = [], isSpecRunning = function() { return !!currentSpec; }; angular.mock.$$annotate = angular.injector.$$annotate; angular.injector.$$annotate = function(fn) { if (typeof fn === 'function' && !fn.$inject) { annotatedFunctions.push(fn); } return angular.mock.$$annotate.apply(this, arguments); }; (window.beforeEach || window.setup)(function() { annotatedFunctions = []; currentSpec = this; }); (window.afterEach || window.teardown)(function() { var injector = currentSpec.$injector; annotatedFunctions.forEach(function(fn) { delete fn.$inject; }); angular.forEach(currentSpec.$modules, function(module) { if (module && module.$$hashKey) { module.$$hashKey = undefined; } }); currentSpec.$injector = null; currentSpec.$modules = null; currentSpec = null; if (injector) { injector.get('$rootElement').off(); injector.get('$browser').pollFns.length = 0; } // clean up jquery's fragment cache angular.forEach(angular.element.fragments, function(val, key) { delete angular.element.fragments[key]; }); MockXhr.$$lastInstance = null; angular.forEach(angular.callbacks, function(val, key) { delete angular.callbacks[key]; }); angular.callbacks.counter = 0; }); window.module = angular.mock.module = function() { var moduleFns = Array.prototype.slice.call(arguments, 0); return isSpecRunning() ? workFn() : workFn; function workFn() { if (currentSpec.$injector) { throw new Error('Injector already created, can not register a module!'); } else { var modules = currentSpec.$modules || (currentSpec.$modules = []); angular.forEach(moduleFns, function(module) { if (angular.isObject(module) && !angular.isArray(module)) { modules.push(function($provide) { angular.forEach(module, function(value, key) { $provide.value(key, value); }); }); } else { modules.push(module); } }); } } }; /** * @ngdoc function * @name angular.mock.inject * @description * * *NOTE*: This function is also published on window for easy access.<br> * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha * * The inject function wraps a function into an injectable function. The inject() creates new * instance of {@link auto.$injector $injector} per test, which is then used for * resolving references. * * * ## Resolving References (Underscore Wrapping) * Often, we would like to inject a reference once, in a `beforeEach()` block and reuse this * in multiple `it()` clauses. To be able to do this we must assign the reference to a variable * that is declared in the scope of the `describe()` block. Since we would, most likely, want * the variable to have the same name of the reference we have a problem, since the parameter * to the `inject()` function would hide the outer variable. * * To help with this, the injected parameters can, optionally, be enclosed with underscores. * These are ignored by the injector when the reference name is resolved. * * For example, the parameter `_myService_` would be resolved as the reference `myService`. * Since it is available in the function body as _myService_, we can then assign it to a variable * defined in an outer scope. * * ``` * // Defined out reference variable outside * var myService; * * // Wrap the parameter in underscores * beforeEach( inject( function(_myService_){ * myService = _myService_; * })); * * // Use myService in a series of tests. * it('makes use of myService', function() { * myService.doStuff(); * }); * * ``` * * See also {@link angular.mock.module angular.mock.module} * * ## Example * Example of what a typical jasmine tests looks like with the inject method. * ```js * * angular.module('myApplicationModule', []) * .value('mode', 'app') * .value('version', 'v1.0.1'); * * * describe('MyApp', function() { * * // You need to load modules that you want to test, * // it loads only the "ng" module by default. * beforeEach(module('myApplicationModule')); * * * // inject() is used to inject arguments of all given functions * it('should provide a version', inject(function(mode, version) { * expect(version).toEqual('v1.0.1'); * expect(mode).toEqual('app'); * })); * * * // The inject and module method can also be used inside of the it or beforeEach * it('should override a version and test the new version is injected', function() { * // module() takes functions or strings (module aliases) * module(function($provide) { * $provide.value('version', 'overridden'); // override version here * }); * * inject(function(version) { * expect(version).toEqual('overridden'); * }); * }); * }); * * ``` * * @param {...Function} fns any number of functions which will be injected using the injector. */ var <API key> = function(e, errorForStack) { this.message = e.message; this.name = e.name; if (e.line) this.line = e.line; if (e.sourceId) this.sourceId = e.sourceId; if (e.stack && errorForStack) this.stack = e.stack + '\n' + errorForStack.stack; if (e.stackArray) this.stackArray = e.stackArray; }; <API key>.prototype.toString = Error.prototype.toString; window.inject = angular.mock.inject = function() { var blockFns = Array.prototype.slice.call(arguments, 0); var errorForStack = new Error('Declaration Location'); return isSpecRunning() ? workFn.call(currentSpec) : workFn; function workFn() { var modules = currentSpec.$modules || []; var strictDi = !!currentSpec.$injectorStrict; modules.unshift('ngMock'); modules.unshift('ng'); var injector = currentSpec.$injector; if (!injector) { if (strictDi) { // If strictDi is enabled, annotate the providerInjector blocks angular.forEach(modules, function(moduleFn) { if (typeof moduleFn === "function") { angular.injector.$$annotate(moduleFn); } }); } injector = currentSpec.$injector = angular.injector(modules, strictDi); currentSpec.$injectorStrict = strictDi; } for (var i = 0, ii = blockFns.length; i < ii; i++) { if (currentSpec.$injectorStrict) { // If the injector is strict / strictDi, and the spec wants to inject using automatic // annotation, then annotate the function here. injector.annotate(blockFns[i]); } try { /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */ injector.invoke(blockFns[i] || angular.noop, this); /* jshint +W040 */ } catch (e) { if (e.stack && errorForStack) { throw new <API key>(e, errorForStack); } throw e; } finally { errorForStack = null; } } } }; angular.mock.inject.strictDi = function(value) { value = arguments.length ? !!value : true; return isSpecRunning() ? workFn() : workFn; function workFn() { if (value !== currentSpec.$injectorStrict) { if (currentSpec.$injector) { throw new Error('Injector already created, can not modify strict annotations'); } else { currentSpec.$injectorStrict = value; } } } }; } })(window, window.angular);
<?php /** * @see <API key> */ require_once 'Zend/Validate/File/Exists.php'; class <API key> extends <API key> { /** * @const string Error constants */ const DOES_EXIST = '<API key>'; /** * @var array Error message templates */ protected $_messageTemplates = array( self::DOES_EXIST => "The file '%value%' does exist" ); /** * Defined by <API key> * * Returns true if and only if the file does not exist in the set destinations * * @param string $value Real file to check for * @param array $file File data from Zend_File_Transfer * @return boolean */ public function isValid($value, $file = null) { $directories = $this->getDirectory(true); if (($file !== null) and (!empty($file['destination']))) { $directories[] = $file['destination']; } else if (!isset($file['name'])) { $file['name'] = $value; } foreach ($directories as $directory) { if (empty($directory)) { continue; } $check = true; if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { $this->_throw($file, self::DOES_EXIST); return false; } } if (!isset($check)) { $this->_throw($file, self::DOES_EXIST); return false; } return true; } }
#include <linux/rcupdate.h> #include <linux/rculist.h> #include <linux/kernel.h> #include <linux/export.h> #include <linux/percpu.h> #include <linux/init.h> #include <linux/gfp.h> #include <linux/smp.h> #include <linux/cpu.h> #include "smpboot.h" #ifdef <API key> enum { CSD_FLAG_LOCK = 0x01, }; struct call_function_data { struct call_single_data __percpu *csd; cpumask_var_t cpumask; cpumask_var_t cpumask_ipi; }; static <API key>(struct call_function_data, cfd_data); struct call_single_queue { struct list_head list; raw_spinlock_t lock; }; static <API key>(struct call_single_queue, call_single_queue); static int hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; struct call_function_data *cfd = &per_cpu(cfd_data, cpu); switch (action) { case CPU_UP_PREPARE: case <API key>: if (!<API key>(&cfd->cpumask, GFP_KERNEL, cpu_to_node(cpu))) return notifier_from_errno(-ENOMEM); if (!<API key>(&cfd->cpumask_ipi, GFP_KERNEL, cpu_to_node(cpu))) return notifier_from_errno(-ENOMEM); cfd->csd = alloc_percpu(struct call_single_data); if (!cfd->csd) { free_cpumask_var(cfd->cpumask); return notifier_from_errno(-ENOMEM); } break; #ifdef CONFIG_HOTPLUG_CPU case CPU_UP_CANCELED: case <API key>: case CPU_DEAD: case CPU_DEAD_FROZEN: free_cpumask_var(cfd->cpumask); free_cpumask_var(cfd->cpumask_ipi); free_percpu(cfd->csd); break; #endif }; return NOTIFY_OK; } static struct notifier_block __cpuinitdata <API key> = { .notifier_call = hotplug_cfd, }; void __init call_function_init(void) { void *cpu = (void *)(long)smp_processor_id(); int i; <API key>(i) { struct call_single_queue *q = &per_cpu(call_single_queue, i); raw_spin_lock_init(&q->lock); INIT_LIST_HEAD(&q->list); } hotplug_cfd(&<API key>, CPU_UP_PREPARE, cpu); <API key>(&<API key>); } /* * csd_lock/csd_unlock used to serialize access to per-cpu csd resources * * For non-synchronous ipi calls the csd can still be in use by the * previous function call. For multi-cpu calls its even more interesting * as we'll have to ensure no other cpu is observing our csd. */ static void csd_lock_wait(struct call_single_data *csd) { while (csd->flags & CSD_FLAG_LOCK) cpu_relax(); } static void csd_lock(struct call_single_data *csd) { csd_lock_wait(csd); csd->flags |= CSD_FLAG_LOCK; /* * prevent CPU from reordering the above assignment * to ->flags with any subsequent assignments to other * fields of the specified call_single_data structure: */ smp_mb(); } static void csd_unlock(struct call_single_data *csd) { WARN_ON(!(csd->flags & CSD_FLAG_LOCK)); /* * ensure we're all done before releasing data: */ smp_mb(); csd->flags &= ~CSD_FLAG_LOCK; } /* * Insert a previously allocated call_single_data element * for execution on the given CPU. data must already have * ->func, ->info, and ->flags set. */ static void generic_exec_single(int cpu, struct call_single_data *csd, int wait) { struct call_single_queue *dst = &per_cpu(call_single_queue, cpu); unsigned long flags; int ipi; <API key>(&dst->lock, flags); ipi = list_empty(&dst->list); list_add_tail(&csd->list, &dst->list); <API key>(&dst->lock, flags); /* * The list addition should be visible before sending the IPI * handler locks the list to pull the entry off it because of * normal cache coherency rules implied by spinlocks. * * If IPIs can go out of order to the cache coherency protocol * in an architecture, sufficient synchronisation should be added * to arch code to make it appear to obey cache coherency WRT * locking and barrier primitives. Generic code isn't really * equipped to do the right thing... */ if (ipi) <API key>(cpu); if (wait) csd_lock_wait(csd); } /* * Invoked by arch to handle an IPI for call function single. Must be * called from the arch with interrupts disabled. */ void <API key>(void) { struct call_single_queue *q = &__get_cpu_var(call_single_queue); LIST_HEAD(list); /* * Shouldn't receive this interrupt on a cpu that is not yet online. */ WARN_ON_ONCE(!cpu_online(smp_processor_id())); raw_spin_lock(&q->lock); list_replace_init(&q->list, &list); raw_spin_unlock(&q->lock); while (!list_empty(&list)) { struct call_single_data *csd; unsigned int csd_flags; csd = list_entry(list.next, struct call_single_data, list); list_del(&csd->list); /* * 'csd' can be invalid after this call if flags == 0 * (when called through generic_exec_single()), * so save them away before making the call: */ csd_flags = csd->flags; csd->func(csd->info); /* * Unlocked CSDs are valid through generic_exec_single(): */ if (csd_flags & CSD_FLAG_LOCK) csd_unlock(csd); } } static <API key>(struct call_single_data, csd_data); /* * <API key> - Run a function on a specific CPU * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait until function has completed on other CPUs. * * Returns 0 on success, else a negative status code. */ int <API key>(int cpu, smp_call_func_t func, void *info, int wait) { struct call_single_data d = { .flags = 0, }; unsigned long flags; int this_cpu; int err = 0; /* * prevent preemption and reschedule on another processor, * as well as CPU removal */ this_cpu = get_cpu(); /* * Can deadlock when called with interrupts disabled. * We allow cpu's that are not yet online though, as no one else can * send smp call function interrupt to this cpu and as such deadlocks * can't happen. */ WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() && !oops_in_progress); if (cpu == this_cpu) { local_irq_save(flags); func(info); local_irq_restore(flags); } else { if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) { struct call_single_data *csd = &d; if (!wait) csd = &__get_cpu_var(csd_data); csd_lock(csd); csd->func = func; csd->info = info; generic_exec_single(cpu, csd, wait); } else { err = -ENXIO; /* CPU not online */ } } put_cpu(); return err; } EXPORT_SYMBOL(<API key>); /* * <API key> - Run a function on any of the given cpus * @mask: The mask of cpus it can run on. * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait until function has completed. * * Returns 0 on success, else a negative status code (if no cpus were online). * Note that @wait will be implicitly turned on in case of allocation failures, * since we fall back to on-stack allocation. * * Selection preference: * 1) current cpu if in @mask * 2) any cpu of current node if in @mask * 3) any other online cpu in @mask */ int <API key>(const struct cpumask *mask, smp_call_func_t func, void *info, int wait) { unsigned int cpu; const struct cpumask *nodemask; int ret; /* Try for same CPU (cheapest) */ cpu = get_cpu(); if (cpumask_test_cpu(cpu, mask)) goto call; /* Try for same node. */ nodemask = cpumask_of_node(cpu_to_node(cpu)); for (cpu = cpumask_first_and(nodemask, mask); cpu < nr_cpu_ids; cpu = cpumask_next_and(cpu, nodemask, mask)) { if (cpu_online(cpu)) goto call; } /* Any online will do: <API key> handles nr_cpu_ids. */ cpu = cpumask_any_and(mask, cpu_online_mask); call: ret = <API key>(cpu, func, info, wait); put_cpu(); return ret; } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>(): Run a function on a specific CPU * @cpu: The CPU to run on. * @data: Pre-allocated and setup data structure * @wait: If true, wait until function has completed on specified CPU. * * Like <API key>(), but allow caller to pass in a * pre-allocated data structure. Useful for embedding @data inside * other structures, for instance. */ void <API key>(int cpu, struct call_single_data *csd, int wait) { unsigned int this_cpu; unsigned long flags; this_cpu = get_cpu(); /* * Can deadlock when called with interrupts disabled. * We allow cpu's that are not yet online though, as no one else can * send smp call function interrupt to this cpu and as such deadlocks * can't happen. */ WARN_ON_ONCE(cpu_online(smp_processor_id()) && wait && irqs_disabled() && !oops_in_progress); if (cpu == this_cpu) { local_irq_save(flags); csd->func(csd->info); local_irq_restore(flags); } else { csd_lock(csd); generic_exec_single(cpu, csd, wait); } put_cpu(); } /** * <API key>(): Run a function on a set of other CPUs. * @mask: The set of cpus to run on (only runs on online subset). * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait (atomically) until function has completed * on other CPUs. * * If @wait is true, then returns once @func has returned. * * You must not call this function with disabled interrupts or from a * hardware interrupt handler or from a bottom half handler. Preemption * must be disabled when calling this function. */ void <API key>(const struct cpumask *mask, smp_call_func_t func, void *info, bool wait) { struct call_function_data *cfd; int cpu, next_cpu, this_cpu = smp_processor_id(); /* * Can deadlock when called with interrupts disabled. * We allow cpu's that are not yet online though, as no one else can * send smp call function interrupt to this cpu and as such deadlocks * can't happen. */ WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() && !oops_in_progress && !<API key>); /* Try to fastpath. So, what's a CPU they want? Ignoring this one. */ cpu = cpumask_first_and(mask, cpu_online_mask); if (cpu == this_cpu) cpu = cpumask_next_and(cpu, mask, cpu_online_mask); /* No online cpus? We're done. */ if (cpu >= nr_cpu_ids) return; /* Do we have another CPU which isn't us? */ next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask); if (next_cpu == this_cpu) next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask); /* Fastpath: do that cpu by itself. */ if (next_cpu >= nr_cpu_ids) { <API key>(cpu, func, info, wait); return; } cfd = &__get_cpu_var(cfd_data); cpumask_and(cfd->cpumask, mask, cpu_online_mask); cpumask_clear_cpu(this_cpu, cfd->cpumask); /* Some callers race with other cpus changing the passed mask */ if (unlikely(!cpumask_weight(cfd->cpumask))) return; /* * After we put an entry into the list, cfd->cpumask may be cleared * again when another CPU sends another IPI for a SMP function call, so * cfd->cpumask will be zero. */ cpumask_copy(cfd->cpumask_ipi, cfd->cpumask); for_each_cpu(cpu, cfd->cpumask) { struct call_single_data *csd = per_cpu_ptr(cfd->csd, cpu); struct call_single_queue *dst = &per_cpu(call_single_queue, cpu); unsigned long flags; csd_lock(csd); csd->func = func; csd->info = info; <API key>(&dst->lock, flags); list_add_tail(&csd->list, &dst->list); <API key>(&dst->lock, flags); } /* Send a message to all CPUs in the map */ <API key>(cfd->cpumask_ipi); if (wait) { for_each_cpu(cpu, cfd->cpumask) { struct call_single_data *csd; csd = per_cpu_ptr(cfd->csd, cpu); csd_lock_wait(csd); } } } EXPORT_SYMBOL(<API key>); /** * smp_call_function(): Run a function on all other CPUs. * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait (atomically) until function has completed * on other CPUs. * * Returns 0. * * If @wait is true, then returns once @func has returned; otherwise * it returns just before the target cpu calls @func. * * You must not call this function with disabled interrupts or from a * hardware interrupt handler or from a bottom half handler. */ int smp_call_function(smp_call_func_t func, void *info, int wait) { preempt_disable(); <API key>(cpu_online_mask, func, info, wait); preempt_enable(); return 0; } EXPORT_SYMBOL(smp_call_function); #endif /* <API key> */ /* Setup configured maximum number of CPUs to activate */ unsigned int setup_max_cpus = NR_CPUS; EXPORT_SYMBOL(setup_max_cpus); /* * Setup routine for controlling SMP activation * * Command-line option of "nosmp" or "maxcpus=0" will disable SMP * activation entirely (the MPS table probe still happens, though). * * Command-line option of "maxcpus=<NUM>", where <NUM> is an integer * greater than 0, limits the maximum number of CPUs activated in * SMP mode to <NUM>. */ void __weak <API key>(void) { } static int __init nosmp(char *str) { setup_max_cpus = 0; <API key>(); return 0; } early_param("nosmp", nosmp); /* this is hard limit */ static int __init nrcpus(char *str) { int nr_cpus; get_option(&str, &nr_cpus); if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) nr_cpu_ids = nr_cpus; return 0; } early_param("nr_cpus", nrcpus); static int __init maxcpus(char *str) { get_option(&str, &setup_max_cpus); if (setup_max_cpus == 0) <API key>(); return 0; } early_param("maxcpus", maxcpus); /* Setup number of possible processor ids */ int nr_cpu_ids __read_mostly = NR_CPUS; EXPORT_SYMBOL(nr_cpu_ids); /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */ void __init setup_nr_cpu_ids(void) { nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; } /* Called by boot processor to activate the rest. */ void __init smp_init(void) { unsigned int cpu; idle_threads_init(); /* FIXME: This should be done in userspace --RR */ <API key>(cpu) { if (num_online_cpus() >= setup_max_cpus) break; if (!cpu_online(cpu)) cpu_up(cpu); } /* Any cleanup work */ printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus()); smp_cpus_done(setup_max_cpus); } /* * Call a function on all processors. May be used during early boot while * <API key> is set. Use local_irq_save/restore() instead * of local_irq_disable/enable(). */ int on_each_cpu(void (*func) (void *info), void *info, int wait) { unsigned long flags; int ret = 0; preempt_disable(); ret = smp_call_function(func, info, wait); local_irq_save(flags); func(info); local_irq_restore(flags); preempt_enable(); return ret; } EXPORT_SYMBOL(on_each_cpu); /** * on_each_cpu_mask(): Run a function on processors specified by * cpumask, which may include the local processor. * @mask: The set of cpus to run on (only runs on online subset). * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait (atomically) until function has completed * on other CPUs. * * If @wait is true, then returns once @func has returned. * * You must not call this function with disabled interrupts or * from a hardware interrupt handler or from a bottom half handler. */ void on_each_cpu_mask(const struct cpumask *mask, smp_call_func_t func, void *info, bool wait) { int cpu = get_cpu(); <API key>(mask, func, info, wait); if (cpumask_test_cpu(cpu, mask)) { local_irq_disable(); func(info); local_irq_enable(); } put_cpu(); } EXPORT_SYMBOL(on_each_cpu_mask); /* * on_each_cpu_cond(): Call a function on each processor for which * the supplied function cond_func returns true, optionally waiting * for all the required CPUs to finish. This may include the local * processor. * @cond_func: A callback function that is passed a cpu id and * the the info parameter. The function is called * with preemption disabled. The function should * return a blooean value indicating whether to IPI * the specified CPU. * @func: The function to run on all applicable CPUs. * This must be fast and non-blocking. * @info: An arbitrary pointer to pass to both functions. * @wait: If true, wait (atomically) until function has * completed on other CPUs. * @gfp_flags: GFP flags to use when allocating the cpumask * used internally by the function. * * The function might sleep if the GFP flags indicates a non * atomic allocation is allowed. * * Preemption is disabled to protect against CPUs going offline but not online. * CPUs going online during the call will not be seen or sent an IPI. * * You must not call this function with disabled interrupts or * from a hardware interrupt handler or from a bottom half handler. */ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), smp_call_func_t func, void *info, bool wait, gfp_t gfp_flags) { cpumask_var_t cpus; int cpu, ret; might_sleep_if(gfp_flags & __GFP_WAIT); if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) { preempt_disable(); for_each_online_cpu(cpu) if (cond_func(cpu, info)) cpumask_set_cpu(cpu, cpus); on_each_cpu_mask(cpus, func, info, wait); preempt_enable(); free_cpumask_var(cpus); } else { /* * No free cpumask, bother. No matter, we'll * just have to IPI them one by one. */ preempt_disable(); for_each_online_cpu(cpu) if (cond_func(cpu, info)) { ret = <API key>(cpu, func, info, wait); WARN_ON_ONCE(ret); } preempt_enable(); } } EXPORT_SYMBOL(on_each_cpu_cond); static void do_nothing(void *unused) { } /** * kick_all_cpus_sync - Force all cpus out of idle * * Used to synchronize the update of pm_idle function pointer. It's * called after the pointer is updated and returns after the dummy * callback function has been executed on all cpus. The execution of * the function can only happen on the remote cpus after they have * left the idle function which had been called via pm_idle function * pointer. So it's guaranteed that nothing uses the previous pointer * anymore. */ void kick_all_cpus_sync(void) { /* Make sure the change is visible before we kick the cpus */ smp_mb(); smp_call_function(do_nothing, NULL, 1); } EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
<?php /** * WordPress CRON API * * @package WordPress */ function <API key>( $timestamp, $hook, $args = array()) { // don't schedule a duplicate if there's already an identical event due in the next 10 minutes $next = wp_next_scheduled($hook, $args); if ( $next && $next <= $timestamp + 600 ) return; $crons = _get_cron_array(); $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args ); $event = apply_filters('schedule_event', $event); // A plugin disallowed this event if ( ! $event ) return false; $key = md5(serialize($event->args)); $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args ); uksort( $crons, "strnatcasecmp" ); _set_cron_array( $crons ); } /** * Schedule a periodic event. * * Schedules a hook which will be executed by the WordPress actions core on a * specific interval, specified by you. The action will trigger when someone * visits your WordPress site, if the scheduled time has passed. * * Valid values for the recurrence are hourly, daily and twicedaily. These can * be extended using the cron_schedules filter in wp_get_schedules(). * * Use wp_next_scheduled() to prevent duplicates * * @since 2.1.0 * * @param int $timestamp Timestamp for when to run the event. * @param string $recurrence How often the event should recur. * @param string $hook Action hook to execute when cron is run. * @param array $args Optional. Arguments to pass to the hook's callback function. * @return bool|null False on failure, null when complete with scheduling event. */ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { $crons = _get_cron_array(); $schedules = wp_get_schedules(); if ( !isset( $schedules[$recurrence] ) ) return false; $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); $event = apply_filters('schedule_event', $event); // A plugin disallowed this event if ( ! $event ) return false; $key = md5(serialize($event->args)); $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval ); uksort( $crons, "strnatcasecmp" ); _set_cron_array( $crons ); } /** * Reschedule a recurring event. * * @since 2.1.0 * * @param int $timestamp Timestamp for when to run the event. * @param string $recurrence How often the event should recur. * @param string $hook Action hook to execute when cron is run. * @param array $args Optional. Arguments to pass to the hook's callback function. * @return bool|null False on failure. Null when event is rescheduled. */ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) { $crons = _get_cron_array(); $schedules = wp_get_schedules(); $key = md5(serialize($args)); $interval = 0; // First we try to get it from the schedule if ( 0 == $interval ) $interval = $schedules[$recurrence]['interval']; // Now we try to get it from the saved interval in case the schedule disappears if ( 0 == $interval ) $interval = $crons[$timestamp][$hook][$key]['interval']; // Now we assume something is wrong and fail to schedule if ( 0 == $interval ) return false; $now = time(); if ( $timestamp >= $now ) $timestamp = $now + $interval; else $timestamp = $now + ($interval - (($now - $timestamp) % $interval)); wp_schedule_event( $timestamp, $recurrence, $hook, $args ); } /** * Unschedule a previously scheduled cron job. * * The $timestamp and $hook parameters are required, so that the event can be * identified. * * @since 2.1.0 * * @param int $timestamp Timestamp for when to run the event. * @param string $hook Action hook, the execution of which will be unscheduled. * @param array $args Arguments to pass to the hook's callback function. * Although not passed to a callback function, these arguments are used * to uniquely identify the scheduled event, so they should be the same * as those used when originally scheduling the event. */ function wp_unschedule_event( $timestamp, $hook, $args = array() ) { $crons = _get_cron_array(); $key = md5(serialize($args)); unset( $crons[$timestamp][$hook][$key] ); if ( empty($crons[$timestamp][$hook]) ) unset( $crons[$timestamp][$hook] ); if ( empty($crons[$timestamp]) ) unset( $crons[$timestamp] ); _set_cron_array( $crons ); } /** * Unschedule all cron jobs attached to a specific hook. * * @since 2.1.0 * * @param string $hook Action hook, the execution of which will be unscheduled. * @param array $args Optional. Arguments that were to be pass to the hook's callback function. */ function <API key>( $hook, $args = array() ) { // Backward compatibility // Previously this function took the arguments as discrete vars rather than an array like the rest of the API if ( !is_array($args) ) { <API key>( __FUNCTION__, '3.0', __('This argument has changed to an array to match the behavior of the other cron functions.') ); $args = array_slice( func_get_args(), 1 ); } while ( $timestamp = wp_next_scheduled( $hook, $args ) ) wp_unschedule_event( $timestamp, $hook, $args ); } /** * Retrieve the next timestamp for a cron event. * * @since 2.1.0 * * @param string $hook Action hook to execute when cron is run. * @param array $args Optional. Arguments to pass to the hook's callback function. * @return bool|int The UNIX timestamp of the next time the scheduled event will occur. */ function wp_next_scheduled( $hook, $args = array() ) { $crons = _get_cron_array(); $key = md5(serialize($args)); if ( empty($crons) ) return false; foreach ( $crons as $timestamp => $cron ) { if ( isset( $cron[$hook][$key] ) ) return $timestamp; } return false; } /** * Send request to run cron through HTTP request that doesn't halt page loading. * * @since 2.1.0 * * @return null Cron could not be spawned, because it is not needed to run. */ function spawn_cron( $local_time = 0 ) { if ( !$local_time ) $local_time = time(); if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) return; /* * multiple processes on multiple web servers can run this code concurrently * try to make this as atomic as possible by setting doing_cron switch */ $lock = get_transient('doing_cron'); if ( $lock > $local_time + 10*60 ) $lock = 0; // don't run if another process is currently running it or more than once every 60 sec. if ( $lock + <API key> > $local_time ) return; //sanity check $crons = _get_cron_array(); if ( !is_array($crons) ) return; $keys = array_keys( $crons ); if ( isset($keys[0]) && $keys[0] > $local_time ) return; if ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ) { if ( !empty($_POST) || defined('DOING_AJAX') ) return; $doing_wp_cron = $local_time; set_transient( 'doing_cron', $doing_wp_cron ); ob_start(); wp_redirect( add_query_arg('doing_wp_cron', $doing_wp_cron, stripslashes($_SERVER['REQUEST_URI'])) ); echo ' '; // flush any buffers and send the headers while ( @ob_end_flush() ); flush(); WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' ); return; } $doing_wp_cron = $local_time; set_transient( 'doing_cron', $doing_wp_cron ); $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron=' . $doing_wp_cron; wp_remote_post( $cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('<API key>', true)) ); } /** * Run scheduled callbacks or spawn cron for all scheduled events. * * @since 2.1.0 * * @return null When doesn't need to run Cron. */ function wp_cron() { // Prevent infinite loops caused by lack of wp-cron.php if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) ) return; if ( false === $crons = _get_cron_array() ) return; $local_time = time(); $keys = array_keys( $crons ); if ( isset($keys[0]) && $keys[0] > $local_time ) return; $schedules = wp_get_schedules(); foreach ( $crons as $timestamp => $cronhooks ) { if ( $timestamp > $local_time ) break; foreach ( (array) $cronhooks as $hook => $args ) { if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) continue; spawn_cron( $local_time ); break 2; } } } /** * Retrieve supported and filtered Cron recurrences. * * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by * hooking into the 'cron_schedules' filter. The filter accepts an array of * arrays. The outer array has a key that is the name of the schedule or for * example 'weekly'. The value is an array with two keys, one is 'interval' and * the other is 'display'. * * The 'interval' is a number in seconds of when the cron job should run. So for * 'hourly', the time is 3600 or 60*60. For weekly, the value would be * 60*60*24*7 or 604800. The value of 'interval' would then be 604800. * * The 'display' is the description. For the 'weekly' key, the 'display' would * be <code>__('Once Weekly')</code>. * * For your plugin, you will be passed an array. you can easily add your * schedule by doing the following. * <code> * // filter parameter variable name is 'array' * $array['weekly'] = array( * 'interval' => 604800, * 'display' => __('Once Weekly') * ); * </code> * * @since 2.1.0 * * @return array */ function wp_get_schedules() { $schedules = array( 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ), 'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ), 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ), ); return array_merge( apply_filters( 'cron_schedules', array() ), $schedules ); } /** * Retrieve Cron schedule for hook with arguments. * * @since 2.1.0 * * @param string $hook Action hook to execute when cron is run. * @param array $args Optional. Arguments to pass to the hook's callback function. * @return string|bool False, if no schedule. Schedule on success. */ function wp_get_schedule($hook, $args = array()) { $crons = _get_cron_array(); $key = md5(serialize($args)); if ( empty($crons) ) return false; foreach ( $crons as $timestamp => $cron ) { if ( isset( $cron[$hook][$key] ) ) return $cron[$hook][$key]['schedule']; } return false; } // Private functions /** * Retrieve cron info array option. * * @since 2.1.0 * @access private * * @return array CRON info array. */ function _get_cron_array() { $cron = get_option('cron'); if ( ! is_array($cron) ) return false; if ( !isset($cron['version']) ) $cron = _upgrade_cron_array($cron); unset($cron['version']); return $cron; } /** * Updates the CRON option with the new CRON array. * * @since 2.1.0 * @access private * * @param array $cron Cron info array from {@link _get_cron_array()}. */ function _set_cron_array($cron) { $cron['version'] = 2; update_option( 'cron', $cron ); } /** * Upgrade a Cron info array. * * This function upgrades the Cron info array to version 2. * * @since 2.1.0 * @access private * * @param array $cron Cron info array from {@link _get_cron_array()}. * @return array An upgraded Cron info array. */ function _upgrade_cron_array($cron) { if ( isset($cron['version']) && 2 == $cron['version']) return $cron; $new_cron = array(); foreach ( (array) $cron as $timestamp => $hooks) { foreach ( (array) $hooks as $hook => $args ) { $key = md5(serialize($args['args'])); $new_cron[$timestamp][$hook][$key] = $args; } } $new_cron['version'] = 2; update_option( 'cron', $new_cron ); return $new_cron; }
import parse = require('xml-parser'); declare var assert: { equal<T>(a: T, b: T): void }; var doc: parse.Document = parse( '<?xml version="1.0" encoding="utf-8"?>' + '<mydoc><child a="1">foo</child><child/></mydoc>'); var declaration: parse.Declaration = doc.declaration; assert.equal(declaration.attributes['version'], '1.0'); assert.equal(declaration.attributes['encoding'], 'utf-8'); var root: parse.Node = doc.root; assert.equal(root.name, 'mydoc'); var children: parse.Node[] = root.children; assert.equal(children.length, 2); var child1: parse.Node = children[0]; assert.equal(child1.name, 'child'); assert.equal(child1.attributes['a'], '1'); assert.equal(child1.content, 'foo');
#include <linux/kernel.h> #include <linux/net.h> #include <linux/netdevice.h> #include <linux/phonet.h> #include <net/sock.h> #include <net/phonet/pn_dev.h> /* when accessing, remember to lock with spin_lock(&pndevs.lock); */ struct phonet_device_list pndevs = { .list = LIST_HEAD_INIT(pndevs.list), .lock = <API key>(pndevs.lock), }; /* Allocate new Phonet device. */ static struct phonet_device *<API key>(struct net_device *dev) { struct phonet_device *pnd = kmalloc(sizeof(*pnd), GFP_ATOMIC); if (pnd == NULL) return NULL; pnd->netdev = dev; bitmap_zero(pnd->addrs, 64); list_add(&pnd->list, &pndevs.list); return pnd; } static struct phonet_device *__phonet_get(struct net_device *dev) { struct phonet_device *pnd; list_for_each_entry(pnd, &pndevs.list, list) { if (pnd->netdev == dev) return pnd; } return NULL; } static void <API key>(struct phonet_device *pnd) { list_del(&pnd->list); kfree(pnd); } struct net_device *phonet_device_get(struct net *net) { struct phonet_device *pnd; struct net_device *dev; spin_lock_bh(&pndevs.lock); list_for_each_entry(pnd, &pndevs.list, list) { dev = pnd->netdev; BUG_ON(!dev); if (net_eq(dev_net(dev), net) && (dev->reg_state == NETREG_REGISTERED) && ((pnd->netdev->flags & IFF_UP)) == IFF_UP) break; dev = NULL; } if (dev) dev_hold(dev); spin_unlock_bh(&pndevs.lock); return dev; } int phonet_address_add(struct net_device *dev, u8 addr) { struct phonet_device *pnd; int err = 0; spin_lock_bh(&pndevs.lock); /* Find or create Phonet-specific device data */ pnd = __phonet_get(dev); if (pnd == NULL) pnd = <API key>(dev); if (unlikely(pnd == NULL)) err = -ENOMEM; else if (test_and_set_bit(addr >> 2, pnd->addrs)) err = -EEXIST; spin_unlock_bh(&pndevs.lock); return err; } int phonet_address_del(struct net_device *dev, u8 addr) { struct phonet_device *pnd; int err = 0; spin_lock_bh(&pndevs.lock); pnd = __phonet_get(dev); if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs)) err = -EADDRNOTAVAIL; else if (bitmap_empty(pnd->addrs, 64)) <API key>(pnd); spin_unlock_bh(&pndevs.lock); return err; } /* Gets a source address toward a destination, through a interface. */ u8 phonet_address_get(struct net_device *dev, u8 addr) { struct phonet_device *pnd; spin_lock_bh(&pndevs.lock); pnd = __phonet_get(dev); if (pnd) { BUG_ON(bitmap_empty(pnd->addrs, 64)); /* Use same source address as destination, if possible */ if (!test_bit(addr >> 2, pnd->addrs)) addr = find_first_bit(pnd->addrs, 64) << 2; } else addr = PN_NO_ADDR; spin_unlock_bh(&pndevs.lock); return addr; } int <API key>(struct net *net, u8 addr) { struct phonet_device *pnd; spin_lock_bh(&pndevs.lock); list_for_each_entry(pnd, &pndevs.list, list) { if (!net_eq(dev_net(pnd->netdev), net)) continue; /* Don't allow unregistering devices! */ if ((pnd->netdev->reg_state != NETREG_REGISTERED) || ((pnd->netdev->flags & IFF_UP)) != IFF_UP) continue; if (test_bit(addr >> 2, pnd->addrs)) { spin_unlock_bh(&pndevs.lock); return 0; } } spin_unlock_bh(&pndevs.lock); return -EADDRNOTAVAIL; } /* notify Phonet of device events */ static int <API key>(struct notifier_block *me, unsigned long what, void *arg) { struct net_device *dev = arg; if (what == NETDEV_UNREGISTER) { struct phonet_device *pnd; /* Destroy phonet-specific device data */ spin_lock_bh(&pndevs.lock); pnd = __phonet_get(dev); if (pnd) <API key>(pnd); spin_unlock_bh(&pndevs.lock); } return 0; } static struct notifier_block <API key> = { .notifier_call = <API key>, .priority = 0, }; /* Initialize Phonet devices list */ void phonet_device_init(void) { <API key>(&<API key>); } void phonet_device_exit(void) { struct phonet_device *pnd, *n; rtnl_unregister_all(PF_PHONET); rtnl_lock(); spin_lock_bh(&pndevs.lock); <API key>(pnd, n, &pndevs.list, list) <API key>(pnd); spin_unlock_bh(&pndevs.lock); rtnl_unlock(); <API key>(&<API key>); }
let arr = []; for(let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) { arr.push(() => i); } }
/* <API key>: BSD-3-Clause-Clear */ #ifndef ATH11K_AHB_H #define ATH11K_AHB_H #include "core.h" #define <API key> (3 * HZ) struct ath11k_base; struct ath11k_ahb { struct rproc *tgt_rproc; }; static inline struct ath11k_ahb *ath11k_ahb_priv(struct ath11k_base *ab) { return (struct ath11k_ahb *)ab->drv_priv; } #endif
#include "sqlite3.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ int sqlite3Fts2Init(sqlite3 *db); #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */
#ifndef <API key> #define <API key> #include <cstdarg> #include <boost/cstdint.hpp> #include <boost/detail/winapi/config.hpp> #ifdef <API key> #pragma once #endif #if defined( BOOST_USE_WINDOWS_H ) # include <windows.h> #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__) # include <winerror.h> # ifdef UNDER_CE # ifndef WINAPI # ifndef <API key> # define WINAPI __cdecl // Note this doesn't match the desktop definition # else # define WINAPI __stdcall # endif # endif // Windows CE defines a few functions as inline functions in kfuncs.h typedef int BOOL; typedef unsigned long DWORD; typedef void* HANDLE; # include <kfuncs.h> # else # ifndef WINAPI # define WINAPI __stdcall # endif # endif # ifndef NTAPI # define NTAPI __stdcall # endif #else # error "Win32 functions not available" #endif #ifndef NO_STRICT #ifndef STRICT #define STRICT 1 #endif #endif #if defined(STRICT) #define <API key>(x) struct x##__; typedef struct x##__ *x #else #define <API key>(x) typedef void* x #endif #if !defined( BOOST_USE_WINDOWS_H ) extern "C" { union _LARGE_INTEGER; struct <API key>; <API key>(HINSTANCE); typedef HINSTANCE HMODULE; } #endif #if defined(__GNUC__) #define <API key> __attribute__ ((__may_alias__)) #else #define <API key> #endif // MinGW64 gcc 4.8.2 fails to compile function declarations with boost::detail::winapi::VOID_ arguments even though // the typedef expands to void. In Windows SDK, VOID is a macro which unfolds to void. We use our own macro in such cases. #define <API key> void namespace boost { namespace detail { namespace winapi { #if defined( BOOST_USE_WINDOWS_H ) typedef ::BOOL BOOL_; typedef ::PBOOL PBOOL_; typedef ::LPBOOL LPBOOL_; typedef ::BOOLEAN BOOLEAN_; typedef ::PBOOLEAN PBOOLEAN_; typedef ::BYTE BYTE_; typedef ::PBYTE PBYTE_; typedef ::LPBYTE LPBYTE_; typedef ::WORD WORD_; typedef ::PWORD PWORD_; typedef ::LPWORD LPWORD_; typedef ::DWORD DWORD_; typedef ::PDWORD PDWORD_; typedef ::LPDWORD LPDWORD_; typedef ::HANDLE HANDLE_; typedef ::PHANDLE PHANDLE_; typedef ::SHORT SHORT_; typedef ::PSHORT PSHORT_; typedef ::USHORT USHORT_; typedef ::PUSHORT PUSHORT_; typedef ::INT INT_; typedef ::PINT PINT_; typedef ::LPINT LPINT_; typedef ::UINT UINT_; typedef ::PUINT PUINT_; typedef ::LONG LONG_; typedef ::PLONG PLONG_; typedef ::LPLONG LPLONG_; typedef ::ULONG ULONG_; typedef ::PULONG PULONG_; typedef ::LONGLONG LONGLONG_; typedef ::ULONGLONG ULONGLONG_; typedef ::INT_PTR INT_PTR_; typedef ::UINT_PTR UINT_PTR_; typedef ::LONG_PTR LONG_PTR_; typedef ::ULONG_PTR ULONG_PTR_; typedef ::DWORD_PTR DWORD_PTR_; typedef ::PDWORD_PTR PDWORD_PTR_; typedef ::SIZE_T SIZE_T_; typedef ::PSIZE_T PSIZE_T_; typedef ::SSIZE_T SSIZE_T_; typedef ::PSSIZE_T PSSIZE_T_; typedef VOID VOID_; // VOID is a macro typedef ::PVOID PVOID_; typedef ::LPVOID LPVOID_; typedef ::LPCVOID LPCVOID_; typedef ::CHAR CHAR_; typedef ::LPSTR LPSTR_; typedef ::LPCSTR LPCSTR_; typedef ::WCHAR WCHAR_; typedef ::LPWSTR LPWSTR_; typedef ::LPCWSTR LPCWSTR_; #else // defined( BOOST_USE_WINDOWS_H ) typedef int BOOL_; typedef BOOL_* PBOOL_; typedef BOOL_* LPBOOL_; typedef unsigned char BYTE_; typedef BYTE_* PBYTE_; typedef BYTE_* LPBYTE_; typedef BYTE_ BOOLEAN_; typedef BOOLEAN_* PBOOLEAN_; typedef unsigned short WORD_; typedef WORD_* PWORD_; typedef WORD_* LPWORD_; typedef unsigned long DWORD_; typedef DWORD_* PDWORD_; typedef DWORD_* LPDWORD_; typedef void* HANDLE_; typedef void** PHANDLE_; typedef short SHORT_; typedef SHORT_* PSHORT_; typedef unsigned short USHORT_; typedef USHORT_* PUSHORT_; typedef int INT_; typedef INT_* PINT_; typedef INT_* LPINT_; typedef unsigned int UINT_; typedef UINT_* PUINT_; typedef long LONG_; typedef LONG_* PLONG_; typedef LONG_* LPLONG_; typedef unsigned long ULONG_; typedef ULONG_* PULONG_; typedef boost::int64_t LONGLONG_; typedef boost::uint64_t ULONGLONG_; # ifdef _WIN64 # if defined(__CYGWIN__) typedef long INT_PTR_; typedef unsigned long UINT_PTR_; typedef long LONG_PTR_; typedef unsigned long ULONG_PTR_; # else typedef __int64 INT_PTR_; typedef unsigned __int64 UINT_PTR_; typedef __int64 LONG_PTR_; typedef unsigned __int64 ULONG_PTR_; # endif # else typedef int INT_PTR_; typedef unsigned int UINT_PTR_; typedef long LONG_PTR_; typedef unsigned long ULONG_PTR_; # endif typedef ULONG_PTR_ DWORD_PTR_, *PDWORD_PTR_; typedef ULONG_PTR_ SIZE_T_, *PSIZE_T_; typedef LONG_PTR_ SSIZE_T_, *PSSIZE_T_; typedef void VOID_; typedef void *PVOID_; typedef void *LPVOID_; typedef const void *LPCVOID_; typedef char CHAR_; typedef CHAR_ *LPSTR_; typedef const CHAR_ *LPCSTR_; typedef wchar_t WCHAR_; typedef WCHAR_ *LPWSTR_; typedef const WCHAR_ *LPCWSTR_; #endif // defined( BOOST_USE_WINDOWS_H ) typedef ::HMODULE HMODULE_; typedef union <API key> _LARGE_INTEGER { struct { DWORD_ LowPart; LONG_ HighPart; } u; LONGLONG_ QuadPart; } LARGE_INTEGER_, *PLARGE_INTEGER_; typedef struct <API key> <API key> { DWORD_ nLength; LPVOID_ <API key>; BOOL_ bInheritHandle; } <API key>, *<API key>, *<API key>; } } } #endif // <API key>
#ifndef __NVHOST_INTR_H #define __NVHOST_INTR_H #include <linux/kthread.h> #include <linux/semaphore.h> #include <linux/interrupt.h> struct nvhost_channel; enum nvhost_intr_action { /** * Perform cleanup after a submit has completed. * 'data' points to a channel */ <API key> = 0, /** * Save a HW context. * 'data' points to a context */ <API key>, /** * Wake up a task. * 'data' points to a wait_queue_head_t */ <API key>, /** * Wake up a interruptible task. * 'data' points to a wait_queue_head_t */ <API key>, <API key> }; struct nvhost_intr; struct nvhost_intr_syncpt { struct nvhost_intr *intr; u8 id; u8 irq_requested; u16 irq; spinlock_t lock; struct list_head wait_head; char thresh_irq_name[12]; }; struct nvhost_intr { struct nvhost_intr_syncpt *syncpt; struct mutex mutex; int host_general_irq; bool <API key>; }; #define intr_to_dev(x) container_of(x, struct nvhost_master, intr) #define intr_op(intr) (intr_to_dev(intr)->op.intr) #define intr_syncpt_to_intr(is) (is->intr) /** * Schedule an action to be taken when a sync point reaches the given threshold. * * @id the sync point * @thresh the threshold * @action the action to take * @data a pointer to extra data depending on action, see above * @waiter waiter allocated with <API key> - assumes ownership * @ref must be passed if cancellation is possible, else NULL * * This is a non-blocking api. */ int <API key>(struct nvhost_intr *intr, u32 id, u32 thresh, enum nvhost_intr_action action, void *data, void *waiter, void **ref); /** * Allocate a waiter. */ void *<API key>(void); /** * Unreference an action submitted to <API key>(). * You must call this if you passed non-NULL as ref. * @ref the ref returned from <API key>() */ void nvhost_intr_put_ref(struct nvhost_intr *intr, void *ref); int nvhost_intr_init(struct nvhost_intr *intr, u32 irq_gen, u32 irq_sync); void nvhost_intr_deinit(struct nvhost_intr *intr); void nvhost_intr_start(struct nvhost_intr *intr, u32 hz); void nvhost_intr_stop(struct nvhost_intr *intr); irqreturn_t <API key>(int irq, void *dev_id); #endif
#ifndef _EXT4_JBD2_H #define _EXT4_JBD2_H #include <linux/fs.h> #include <linux/jbd2.h> #include "ext4.h" #define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal) /* Define the number of blocks we need to account to a transaction to * modify one block of data. * * We may have to touch one inode, one bitmap buffer, up to three * indirection blocks, the group and superblock summaries, and the data * block to complete the transaction. * * For extents-enabled fs we may have to allocate and modify up to * 5 levels of tree + root which are stored in the inode. */ #define <API key>(sb) \ (<API key>(sb, <API key>) \ ? 27U : 8U) /* Extended attribute operations touch at most two data buffers, * two bitmap buffers, and two group summaries, in addition to the inode * and the superblock, which are already accounted for. */ #define <API key> 6U /* Define the minimum size for a transaction which modifies data. This * needs to take into account the fact that we may end up modifying two * quota files too (one for the group, one for the user quota). The * superblock only gets updated once, of course, so don't bother * counting that again for the quota updates. */ #define <API key>(sb) (<API key>(sb) + \ <API key> - 2 + \ <API key>(sb)) /* * Define the number of metadata blocks we need to account to modify data. * * This include super block, inode block, quota blocks and xattr blocks */ #define <API key>(sb) (<API key> + \ <API key>(sb)) /* Delete operations potentially hit one directory's namespace plus an * entire inode, plus arbitrary amounts of bitmap/indirection data. Be * generous. We can grow the delete transaction later if necessary. */ #define <API key>(sb) (2 * <API key>(sb) + 64) /* Define an arbitrary limit for the amount of data we will anticipate * writing to any given transaction. For unbounded transactions such as * write(2) and truncate(2) we can write more than this, but we always * start off at the maximum transaction size and grow the transaction * optimistically as we go. */ #define EXT4_MAX_TRANS_DATA 64U /* We break up a large truncate or write transaction once the handle's * buffer credits gets this low, we need either to extend the * transaction or to start a new one. Reserve enough space here for * inode, bitmap, superblock, group and indirection updates for at least * one block, plus two quota updates. Quota allocations are not * needed. */ #define <API key> 12U #define <API key> 8 #ifdef CONFIG_QUOTA /* Amount of blocks needed for quota update - we know that the structure was * allocated so we need to update only data block */ #define <API key>(sb) (test_opt(sb, QUOTA) ? 1 : 0) /* Amount of blocks needed for quota insert/delete - we do some block writes * but inode, sb and group updates are done only once */ #define <API key>(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\ (<API key>(sb)-3)+3+DQUOT_INIT_REWRITE) : 0) #define <API key>(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\ (<API key>(sb)-3)+3+DQUOT_DEL_REWRITE) : 0) #else #define <API key>(sb) 0 #define <API key>(sb) 0 #define <API key>(sb) 0 #endif #define <API key>(sb) (MAXQUOTAS*<API key>(sb)) #define <API key>(sb) (MAXQUOTAS*<API key>(sb)) #define <API key>(sb) (MAXQUOTAS*<API key>(sb)) int <API key>(handle_t *handle, struct inode *inode, struct ext4_iloc *iloc); /* * On success, We end up with an outstanding reference count against * iloc->bh. This _must_ be cleaned up later. */ int <API key>(handle_t *handle, struct inode *inode, struct ext4_iloc *iloc); int <API key>(handle_t *handle, struct inode *inode); /* * Wrapper functions with which ext4 calls into JBD. */ void <API key>(const char *caller, unsigned int line, const char *err_fn, struct buffer_head *bh, handle_t *handle, int err); int <API key>(const char *where, unsigned int line, handle_t *handle, struct buffer_head *bh); int __ext4_forget(const char *where, unsigned int line, handle_t *handle, int is_metadata, struct inode *inode, struct buffer_head *bh, ext4_fsblk_t blocknr); int <API key>(const char *where, unsigned int line, handle_t *handle, struct buffer_head *bh); int <API key>(const char *where, unsigned int line, handle_t *handle, struct inode *inode, struct buffer_head *bh); int <API key>(const char *where, unsigned int line, handle_t *handle, struct super_block *sb); #define <API key>(handle, bh) \ <API key>(__func__, __LINE__, (handle), (bh)) #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \ __ext4_forget(__func__, __LINE__, (handle), (is_metadata), (inode), \ (bh), (block_nr)) #define <API key>(handle, bh) \ <API key>(__func__, __LINE__, (handle), (bh)) #define <API key>(handle, inode, bh) \ <API key>(__func__, __LINE__, (handle), (inode), \ (bh)) #define <API key>(handle, sb) \ <API key>(__func__, __LINE__, (handle), (sb)) handle_t *<API key>(struct super_block *sb, int nblocks); int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle); #define <API key> ((unsigned long) 4096) /* Note: Do not use this for NULL handles. This is only to determine if * a properly allocated handle is using a journal or not. */ static inline int ext4_handle_valid(handle_t *handle) { if ((unsigned long)handle < <API key>) return 0; return 1; } static inline void ext4_handle_sync(handle_t *handle) { if (ext4_handle_valid(handle)) handle->h_sync = 1; } static inline void <API key>(handle_t *handle, struct buffer_head *bh) { if (ext4_handle_valid(handle)) <API key>(handle, bh); } static inline int <API key>(handle_t *handle) { if (ext4_handle_valid(handle)) return is_handle_aborted(handle); return 0; } static inline int <API key>(handle_t *handle, int needed) { if (ext4_handle_valid(handle) && handle->h_buffer_credits < needed) return 0; return 1; } static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks) { return <API key>(inode->i_sb, nblocks); } #define ext4_journal_stop(handle) \ __ext4_journal_stop(__func__, __LINE__, (handle)) static inline handle_t *<API key>(void) { return <API key>(); } static inline int ext4_journal_extend(handle_t *handle, int nblocks) { if (ext4_handle_valid(handle)) return jbd2_journal_extend(handle, nblocks); return 0; } static inline int <API key>(handle_t *handle, int nblocks) { if (ext4_handle_valid(handle)) return <API key>(handle, nblocks); return 0; } static inline int <API key>(struct inode *inode) { if (EXT4_JOURNAL(inode) != NULL) return <API key>(inode); return 0; } static inline int <API key>(journal_t *journal) { if (journal) return <API key>(journal); return 0; } static inline int <API key>(handle_t *handle, struct inode *inode) { if (ext4_handle_valid(handle)) { if (unlikely(EXT4_I(inode)->jinode == NULL)) { /* Should never happen */ WARN(true, "inode #%lu has NULL jinode\n", inode->i_ino); return 0; } return <API key>(handle, EXT4_I(inode)->jinode); } return 0; } static inline void <API key>(handle_t *handle, struct inode *inode, int datasync) { struct ext4_inode_info *ei = EXT4_I(inode); if (ext4_handle_valid(handle)) { ei->i_sync_tid = handle->h_transaction->t_tid; if (datasync) ei->i_datasync_tid = handle->h_transaction->t_tid; } } /* super.c */ int ext4_force_commit(struct super_block *sb); /* * Ext4 inode journal modes */ #define <API key> 0x01 /* journal data mode */ #define <API key> 0x02 /* ordered data mode */ #define <API key> 0x04 /* writeback data mode */ static inline int <API key>(struct inode *inode) { if (EXT4_JOURNAL(inode) == NULL) return <API key>; /* writeback */ /* We do not support data journalling with delayed allocation */ if (!S_ISREG(inode->i_mode) || test_opt(inode->i_sb, DATA_FLAGS) == <API key>) return <API key>; /* journal data */ if (<API key>(inode, <API key>) && !test_opt(inode->i_sb, DELALLOC)) return <API key>; /* journal data */ if (test_opt(inode->i_sb, DATA_FLAGS) == <API key>) return <API key>; /* ordered */ if (test_opt(inode->i_sb, DATA_FLAGS) == <API key>) return <API key>; /* writeback */ else BUG(); } static inline int <API key>(struct inode *inode) { return <API key>(inode) & <API key>; } static inline int <API key>(struct inode *inode) { return <API key>(inode) & <API key>; } static inline int <API key>(struct inode *inode) { return <API key>(inode) & <API key>; } /* * This function controls whether or not we should try to go down the * dioread_nolock code paths, which makes it safe to avoid taking * i_mutex for direct I/O reads. This only works for extent-based * files, and it doesn't work if data journaling is enabled, since the * dioread_nolock code uses b_private to pass information back to the * I/O completion handler, and this conflicts with the jbd's use of * b_private. */ static inline int <API key>(struct inode *inode) { if (!test_opt(inode->i_sb, DIOREAD_NOLOCK)) return 0; if (!S_ISREG(inode->i_mode)) return 0; if (!(<API key>(inode, EXT4_INODE_EXTENTS))) return 0; if (<API key>(inode)) return 0; return 1; } #endif /* _EXT4_JBD2_H */
#include <linux/kernel.h> #include <linux/init.h> #include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/stmp_device.h> #include <asm/exception.h> #include "irqchip.h" #define HW_ICOLL_VECTOR 0x0000 #define HW_ICOLL_LEVELACK 0x0010 #define HW_ICOLL_CTRL 0x0020 #define <API key> 0x0070 #define <API key>(n) (0x0124 + (n) * 0x10) #define <API key>(n) (0x0128 + (n) * 0x10) #define <API key> 0x00000004 #define <API key> 0x1 #define ICOLL_NUM_IRQS 128 static void __iomem *icoll_base; static struct irq_domain *icoll_domain; static void icoll_ack_irq(struct irq_data *d) { /* * The Interrupt Collector is able to prioritize irqs. * Currently only level 0 is used. So acking can use * <API key> unconditionally. */ __raw_writel(<API key>, icoll_base + HW_ICOLL_LEVELACK); } static void icoll_mask_irq(struct irq_data *d) { __raw_writel(<API key>, icoll_base + <API key>(d->hwirq)); } static void icoll_unmask_irq(struct irq_data *d) { __raw_writel(<API key>, icoll_base + <API key>(d->hwirq)); } static struct irq_chip mxs_icoll_chip = { .irq_ack = icoll_ack_irq, .irq_mask = icoll_mask_irq, .irq_unmask = icoll_unmask_irq, }; asmlinkage void <API key> icoll_handle_irq(struct pt_regs *regs) { u32 irqnr; irqnr = __raw_readl(icoll_base + <API key>); __raw_writel(irqnr, icoll_base + HW_ICOLL_VECTOR); irqnr = irq_find_mapping(icoll_domain, irqnr); handle_IRQ(irqnr, regs); } static int <API key>(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw) { <API key>(virq, &mxs_icoll_chip, handle_level_irq); set_irq_flags(virq, IRQF_VALID); return 0; } static struct irq_domain_ops <API key> = { .map = <API key>, .xlate = <API key>, }; static int __init icoll_of_init(struct device_node *np, struct device_node *interrupt_parent) { icoll_base = of_iomap(np, 0); WARN_ON(!icoll_base); /* * Interrupt Collector reset, which initializes the priority * for each irq to level 0. */ stmp_reset_block(icoll_base + HW_ICOLL_CTRL); icoll_domain = <API key>(np, ICOLL_NUM_IRQS, &<API key>, NULL); return icoll_domain ? 0 : -ENODEV; } IRQCHIP_DECLARE(mxs, "fsl,icoll", icoll_of_init);
<?php /** * Exception for 503 Service Unavailable responses * * @package Requests */ /** * Exception for 503 Service Unavailable responses * * @package Requests */ class <API key> extends <API key> { /** * HTTP status code * * @var integer */ protected $code = 503; /** * Reason phrase * * @var string */ protected $reason = 'Service Unavailable'; }
#include "reiserfs.h" #include <linux/errno.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/xattr.h> #include <linux/slab.h> #include "xattr.h" #include <linux/security.h> #include <asm/uaccess.h> static int security_get(struct dentry *dentry, const char *name, void *buffer, size_t size, int handler_flags) { if (strlen(name) < sizeof(<API key>)) return -EINVAL; if (IS_PRIVATE(dentry->d_inode)) return -EPERM; return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); } static int security_set(struct dentry *dentry, const char *name, const void *buffer, size_t size, int flags, int handler_flags) { if (strlen(name) < sizeof(<API key>)) return -EINVAL; if (IS_PRIVATE(dentry->d_inode)) return -EPERM; return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); } static size_t security_list(struct dentry *dentry, char *list, size_t list_len, const char *name, size_t namelen, int handler_flags) { const size_t len = namelen + 1; if (IS_PRIVATE(dentry->d_inode)) return 0; if (list && len <= list_len) { memcpy(list, name, namelen); list[namelen] = '\0'; } return len; } /* Initializes the security context for a new inode and returns the number * of blocks needed for the transaction. If successful, reiserfs_security * must be released using <API key> when the caller is done. */ int <API key>(struct inode *dir, struct inode *inode, const struct qstr *qstr, struct <API key> *sec) { int blocks = 0; int error; sec->name = NULL; /* Don't add selinux attributes on xattrs - they'll never get used */ if (IS_PRIVATE(dir)) return 0; error = <API key>(inode, dir, qstr, &sec->name, &sec->value, &sec->length); if (error) { if (error == -EOPNOTSUPP) error = 0; sec->name = NULL; sec->value = NULL; sec->length = 0; return error; } if (sec->length && <API key>(inode->i_sb)) { blocks = <API key>(inode) + <API key>(inode, sec->length); /* We don't want to count the directories twice if we have * a default ACL. */ REISERFS_I(inode)->i_flags |= i_has_xattr_dir; } return blocks; } int <API key>(struct <API key> *th, struct inode *inode, struct <API key> *sec) { int error; if (strlen(sec->name) < sizeof(<API key>)) return -EINVAL; error = <API key>(th, inode, sec->name, sec->value, sec->length, XATTR_CREATE); if (error == -ENODATA || error == -EOPNOTSUPP) error = 0; return error; } void <API key>(struct <API key> *sec) { kfree(sec->name); kfree(sec->value); sec->name = NULL; sec->value = NULL; } const struct xattr_handler <API key> = { .prefix = <API key>, .get = security_get, .set = security_set, .list = security_list, };
#include <media/rc-core.h> #include <linux/spinlock.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/slab.h> #include <linux/device.h> #include "rc-core-priv.h" /* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */ #define IR_TAB_MIN_SIZE 256 #define IR_TAB_MAX_SIZE 8192 /* FIXME: IR_KEYPRESS_TIMEOUT should be protocol specific */ #define IR_KEYPRESS_TIMEOUT 250 /* Used to keep track of known keymaps */ static LIST_HEAD(rc_map_list); static DEFINE_SPINLOCK(rc_map_lock); static struct rc_map_list *seek_rc_map(const char *name) { struct rc_map_list *map = NULL; spin_lock(&rc_map_lock); list_for_each_entry(map, &rc_map_list, list) { if (!strcmp(name, map->map.name)) { spin_unlock(&rc_map_lock); return map; } } spin_unlock(&rc_map_lock); return NULL; } struct rc_map *rc_map_get(const char *name) { struct rc_map_list *map; map = seek_rc_map(name); #ifdef MODULE if (!map) { int rc = request_module(name); if (rc < 0) { printk(KERN_ERR "Couldn't load IR keymap %s\n", name); return NULL; } msleep(20); /* Give some time for IR to register */ map = seek_rc_map(name); } #endif if (!map) { printk(KERN_ERR "IR keymap %s not found\n", name); return NULL; } printk(KERN_INFO "Registered IR keymap %s\n", map->map.name); return &map->map; } EXPORT_SYMBOL_GPL(rc_map_get); int rc_map_register(struct rc_map_list *map) { spin_lock(&rc_map_lock); list_add_tail(&map->list, &rc_map_list); spin_unlock(&rc_map_lock); return 0; } EXPORT_SYMBOL_GPL(rc_map_register); void rc_map_unregister(struct rc_map_list *map) { spin_lock(&rc_map_lock); list_del(&map->list); spin_unlock(&rc_map_lock); } EXPORT_SYMBOL_GPL(rc_map_unregister); static struct rc_map_table empty[] = { { 0x2a, KEY_COFFEE }, }; static struct rc_map_list empty_map = { .map = { .scan = empty, .size = ARRAY_SIZE(empty), .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ .name = RC_MAP_EMPTY, } }; /** * ir_create_table() - initializes a scancode table * @rc_map: the rc_map to initialize * @name: name to assign to the table * @rc_type: ir type to assign to the new table * @size: initial size of the table * @return: zero on success or a negative error code * * This routine will initialize the rc_map and will allocate * memory to hold at least the specified number of elements. */ static int ir_create_table(struct rc_map *rc_map, const char *name, u64 rc_type, size_t size) { rc_map->name = name; rc_map->rc_type = rc_type; rc_map->alloc = roundup_pow_of_two(size * sizeof(struct rc_map_table)); rc_map->size = rc_map->alloc / sizeof(struct rc_map_table); rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL); if (!rc_map->scan) return -ENOMEM; IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", rc_map->size, rc_map->alloc); return 0; } /** * ir_free_table() - frees memory allocated by a scancode table * @rc_map: the table whose mappings need to be freed * * This routine will free memory alloctaed for key mappings used by given * scancode table. */ static void ir_free_table(struct rc_map *rc_map) { rc_map->size = 0; kfree(rc_map->scan); rc_map->scan = NULL; } /** * ir_resize_table() - resizes a scancode table if necessary * @rc_map: the rc_map to resize * @gfp_flags: gfp flags to use when allocating memory * @return: zero on success or a negative error code * * This routine will shrink the rc_map if it has lots of * unused entries and grow it if it is full. */ static int ir_resize_table(struct rc_map *rc_map, gfp_t gfp_flags) { unsigned int oldalloc = rc_map->alloc; unsigned int newalloc = oldalloc; struct rc_map_table *oldscan = rc_map->scan; struct rc_map_table *newscan; if (rc_map->size == rc_map->len) { /* All entries in use -> grow keytable */ if (rc_map->alloc >= IR_TAB_MAX_SIZE) return -ENOMEM; newalloc *= 2; IR_dprintk(1, "Growing table to %u bytes\n", newalloc); } if ((rc_map->len * 3 < rc_map->size) && (oldalloc > IR_TAB_MIN_SIZE)) { /* Less than 1/3 of entries in use -> shrink keytable */ newalloc /= 2; IR_dprintk(1, "Shrinking table to %u bytes\n", newalloc); } if (newalloc == oldalloc) return 0; newscan = kmalloc(newalloc, gfp_flags); if (!newscan) { IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc); return -ENOMEM; } memcpy(newscan, rc_map->scan, rc_map->len * sizeof(struct rc_map_table)); rc_map->scan = newscan; rc_map->alloc = newalloc; rc_map->size = rc_map->alloc / sizeof(struct rc_map_table); kfree(oldscan); return 0; } /** * ir_update_mapping() - set a keycode in the scancode->keycode table * @dev: the struct rc_dev device descriptor * @rc_map: scancode table to be adjusted * @index: index of the mapping that needs to be updated * @keycode: the desired keycode * @return: previous keycode assigned to the mapping * * This routine is used to update scancode->keycode mapping at given * position. */ static unsigned int ir_update_mapping(struct rc_dev *dev, struct rc_map *rc_map, unsigned int index, unsigned int new_keycode) { int old_keycode = rc_map->scan[index].keycode; int i; /* Did the user wish to remove the mapping? */ if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) { IR_dprintk(1, "#%d: Deleting scan 0x%04x\n", index, rc_map->scan[index].scancode); rc_map->len memmove(&rc_map->scan[index], &rc_map->scan[index+ 1], (rc_map->len - index) * sizeof(struct rc_map_table)); } else { IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n", index, old_keycode == KEY_RESERVED ? "New" : "Replacing", rc_map->scan[index].scancode, new_keycode); rc_map->scan[index].keycode = new_keycode; __set_bit(new_keycode, dev->input_dev->keybit); } if (old_keycode != KEY_RESERVED) { /* A previous mapping was updated... */ __clear_bit(old_keycode, dev->input_dev->keybit); /* ... but another scancode might use the same keycode */ for (i = 0; i < rc_map->len; i++) { if (rc_map->scan[i].keycode == old_keycode) { __set_bit(old_keycode, dev->input_dev->keybit); break; } } /* Possibly shrink the keytable, failure is not a problem */ ir_resize_table(rc_map, GFP_ATOMIC); } return old_keycode; } /** * <API key>() - set a keycode in the scancode->keycode table * @dev: the struct rc_dev device descriptor * @rc_map: scancode table to be searched * @scancode: the desired scancode * @resize: controls whether we allowed to resize the table to * accommodate not yet present scancodes * @return: index of the mapping containing scancode in question * or -1U in case of failure. * * This routine is used to locate given scancode in rc_map. * If scancode is not yet present the routine will allocate a new slot * for it. */ static unsigned int <API key>(struct rc_dev *dev, struct rc_map *rc_map, unsigned int scancode, bool resize) { unsigned int i; /* * Unfortunately, some hardware-based IR decoders don't provide * all bits for the complete IR code. In general, they provide only * the command part of the IR code. Yet, as it is possible to replace * the provided IR with another one, it is needed to allow loading * IR tables from other remotes. So, we support specifying a mask to * indicate the valid bits of the scancodes. */ if (dev->scanmask) scancode &= dev->scanmask; /* First check if we already have a mapping for this ir command */ for (i = 0; i < rc_map->len; i++) { if (rc_map->scan[i].scancode == scancode) return i; /* Keytable is sorted from lowest to highest scancode */ if (rc_map->scan[i].scancode >= scancode) break; } /* No previous mapping found, we might need to grow the table */ if (rc_map->size == rc_map->len) { if (!resize || ir_resize_table(rc_map, GFP_ATOMIC)) return -1U; } /* i is the proper index to insert our new keycode */ if (i < rc_map->len) memmove(&rc_map->scan[i + 1], &rc_map->scan[i], (rc_map->len - i) * sizeof(struct rc_map_table)); rc_map->scan[i].scancode = scancode; rc_map->scan[i].keycode = KEY_RESERVED; rc_map->len++; return i; } /** * ir_setkeycode() - set a keycode in the scancode->keycode table * @idev: the struct input_dev device descriptor * @scancode: the desired scancode * @keycode: result * @return: -EINVAL if the keycode could not be inserted, otherwise zero. * * This routine is used to handle evdev EVIOCSKEY ioctl. */ static int ir_setkeycode(struct input_dev *idev, const struct input_keymap_entry *ke, unsigned int *old_keycode) { struct rc_dev *rdev = input_get_drvdata(idev); struct rc_map *rc_map = &rdev->rc_map; unsigned int index; unsigned int scancode; int retval = 0; unsigned long flags; spin_lock_irqsave(&rc_map->lock, flags); if (ke->flags & <API key>) { index = ke->index; if (index >= rc_map->len) { retval = -EINVAL; goto out; } } else { retval = <API key>(ke, &scancode); if (retval) goto out; index = <API key>(rdev, rc_map, scancode, true); if (index >= rc_map->len) { retval = -ENOMEM; goto out; } } *old_keycode = ir_update_mapping(rdev, rc_map, index, ke->keycode); out: <API key>(&rc_map->lock, flags); return retval; } /** * ir_setkeytable() - sets several entries in the scancode->keycode table * @dev: the struct rc_dev device descriptor * @to: the struct rc_map to copy entries to * @from: the struct rc_map to copy entries from * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero. * * This routine is used to handle table initialization. */ static int ir_setkeytable(struct rc_dev *dev, const struct rc_map *from) { struct rc_map *rc_map = &dev->rc_map; unsigned int i, index; int rc; rc = ir_create_table(rc_map, from->name, from->rc_type, from->size); if (rc) return rc; IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", rc_map->size, rc_map->alloc); for (i = 0; i < from->size; i++) { index = <API key>(dev, rc_map, from->scan[i].scancode, false); if (index >= rc_map->len) { rc = -ENOMEM; break; } ir_update_mapping(dev, rc_map, index, from->scan[i].keycode); } if (rc) ir_free_table(rc_map); return rc; } /** * <API key>() - locate mapping by scancode * @rc_map: the struct rc_map to search * @scancode: scancode to look for in the table * @return: index in the table, -1U if not found * * This routine performs binary search in RC keykeymap table for * given scancode. */ static unsigned int <API key>(const struct rc_map *rc_map, unsigned int scancode) { int start = 0; int end = rc_map->len - 1; int mid; while (start <= end) { mid = (start + end) / 2; if (rc_map->scan[mid].scancode < scancode) start = mid + 1; else if (rc_map->scan[mid].scancode > scancode) end = mid - 1; else return mid; } return -1U; } /** * ir_getkeycode() - get a keycode from the scancode->keycode table * @idev: the struct input_dev device descriptor * @scancode: the desired scancode * @keycode: used to return the keycode, if found, or KEY_RESERVED * @return: always returns zero. * * This routine is used to handle evdev EVIOCGKEY ioctl. */ static int ir_getkeycode(struct input_dev *idev, struct input_keymap_entry *ke) { struct rc_dev *rdev = input_get_drvdata(idev); struct rc_map *rc_map = &rdev->rc_map; struct rc_map_table *entry; unsigned long flags; unsigned int index; unsigned int scancode; int retval; spin_lock_irqsave(&rc_map->lock, flags); if (ke->flags & <API key>) { index = ke->index; } else { retval = <API key>(ke, &scancode); if (retval) goto out; index = <API key>(rc_map, scancode); } if (index < rc_map->len) { entry = &rc_map->scan[index]; ke->index = index; ke->keycode = entry->keycode; ke->len = sizeof(entry->scancode); memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode)); } else if (!(ke->flags & <API key>)) { /* * We do not really know the valid range of scancodes * so let's respond with KEY_RESERVED to anything we * do not have mapping for [yet]. */ ke->index = index; ke->keycode = KEY_RESERVED; } else { retval = -EINVAL; goto out; } retval = 0; out: <API key>(&rc_map->lock, flags); return retval; } /** * <API key>() - gets the keycode that corresponds to a scancode * @dev: the struct rc_dev descriptor of the device * @scancode: the scancode to look for * @return: the corresponding keycode, or KEY_RESERVED * * This routine is used by drivers which need to convert a scancode to a * keycode. Normally it should not be used since drivers should have no * interest in keycodes. */ u32 <API key>(struct rc_dev *dev, u32 scancode) { struct rc_map *rc_map = &dev->rc_map; unsigned int keycode; unsigned int index; unsigned long flags; spin_lock_irqsave(&rc_map->lock, flags); index = <API key>(rc_map, scancode); keycode = index < rc_map->len ? rc_map->scan[index].keycode : KEY_RESERVED; <API key>(&rc_map->lock, flags); if (keycode != KEY_RESERVED) IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n", dev->input_name, scancode, keycode); return keycode; } EXPORT_SYMBOL_GPL(<API key>); /** * ir_do_keyup() - internal function to signal the release of a keypress * @dev: the struct rc_dev descriptor of the device * @sync: whether or not to call input_sync * * This function is used internally to release a keypress, it must be * called with keylock held. */ static void ir_do_keyup(struct rc_dev *dev, bool sync) { if (!dev->keypressed) return; IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode); input_report_key(dev->input_dev, dev->last_keycode, 0); if (sync) input_sync(dev->input_dev); dev->keypressed = false; } /** * rc_keyup() - signals the release of a keypress * @dev: the struct rc_dev descriptor of the device * * This routine is used to signal that a key has been released on the * remote control. */ void rc_keyup(struct rc_dev *dev) { unsigned long flags; spin_lock_irqsave(&dev->keylock, flags); ir_do_keyup(dev, true); <API key>(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(rc_keyup); /** * ir_timer_keyup() - generates a keyup event after a timeout * @cookie: a pointer to the struct rc_dev for the device * * This routine will generate a keyup event some time after a keydown event * is generated when no further activity has been detected. */ static void ir_timer_keyup(unsigned long cookie) { struct rc_dev *dev = (struct rc_dev *)cookie; unsigned long flags; /* * ir->keyup_jiffies is used to prevent a race condition if a * hardware interrupt occurs at this point and the keyup timer * event is moved further into the future as a result. * * The timer will then be reactivated and this function called * again in the future. We need to exit gracefully in that case * to allow the input subsystem to do its auto-repeat magic or * a keyup event might follow immediately after the keydown. */ spin_lock_irqsave(&dev->keylock, flags); if (<API key>(dev->keyup_jiffies)) ir_do_keyup(dev, true); <API key>(&dev->keylock, flags); } /** * rc_repeat() - signals that a key is still pressed * @dev: the struct rc_dev descriptor of the device * * This routine is used by IR decoders when a repeat message which does * not include the necessary bits to reproduce the scancode has been * received. */ void rc_repeat(struct rc_dev *dev) { unsigned long flags; spin_lock_irqsave(&dev->keylock, flags); input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); input_sync(dev->input_dev); if (!dev->keypressed) goto out; dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); mod_timer(&dev->timer_keyup, dev->keyup_jiffies); out: <API key>(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(rc_repeat); /** * ir_do_keydown() - internal function to process a keypress * @dev: the struct rc_dev descriptor of the device * @scancode: the scancode of the keypress * @keycode: the keycode of the keypress * @toggle: the toggle value of the keypress * * This function is used internally to register a keypress, it must be * called with keylock held. */ static void ir_do_keydown(struct rc_dev *dev, int scancode, u32 keycode, u8 toggle) { bool new_event = !dev->keypressed || dev->last_scancode != scancode || dev->last_toggle != toggle; if (new_event && dev->keypressed) ir_do_keyup(dev, false); input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); if (new_event && keycode != KEY_RESERVED) { /* Register a keypress */ dev->keypressed = true; dev->last_scancode = scancode; dev->last_toggle = toggle; dev->last_keycode = keycode; IR_dprintk(1, "%s: key down event, " "key 0x%04x, scancode 0x%04x\n", dev->input_name, keycode, scancode); input_report_key(dev->input_dev, keycode, 1); } input_sync(dev->input_dev); } /** * rc_keydown() - generates input event for a key press * @dev: the struct rc_dev descriptor of the device * @scancode: the scancode that we're seeking * @toggle: the toggle value (protocol dependent, if the protocol doesn't * support toggle values, this should be set to zero) * * This routine is used to signal that a key has been pressed on the * remote control. */ void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle) { unsigned long flags; u32 keycode = <API key>(dev, scancode); spin_lock_irqsave(&dev->keylock, flags); ir_do_keydown(dev, scancode, keycode, toggle); if (dev->keypressed) { dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); mod_timer(&dev->timer_keyup, dev->keyup_jiffies); } <API key>(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(rc_keydown); /** * <API key>() - generates input event for a key press without * an automatic keyup event at a later time * @dev: the struct rc_dev descriptor of the device * @scancode: the scancode that we're seeking * @toggle: the toggle value (protocol dependent, if the protocol doesn't * support toggle values, this should be set to zero) * * This routine is used to signal that a key has been pressed on the * remote control. The driver must manually call rc_keyup() at a later stage. */ void <API key>(struct rc_dev *dev, int scancode, u8 toggle) { unsigned long flags; u32 keycode = <API key>(dev, scancode); spin_lock_irqsave(&dev->keylock, flags); ir_do_keydown(dev, scancode, keycode, toggle); <API key>(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(<API key>); static int ir_open(struct input_dev *idev) { struct rc_dev *rdev = input_get_drvdata(idev); return rdev->open(rdev); } static void ir_close(struct input_dev *idev) { struct rc_dev *rdev = input_get_drvdata(idev); if (rdev) rdev->close(rdev); } /* class for /sys/class/rc */ static char *ir_devnode(struct device *dev, mode_t *mode) { return kasprintf(GFP_KERNEL, "rc/%s", dev_name(dev)); } static struct class ir_input_class = { .name = "rc", .devnode = ir_devnode, }; static struct { u64 type; char *name; } proto_names[] = { { RC_TYPE_UNKNOWN, "unknown" }, { RC_TYPE_RC5, "rc-5" }, { RC_TYPE_NEC, "nec" }, { RC_TYPE_RC6, "rc-6" }, { RC_TYPE_JVC, "jvc" }, { RC_TYPE_SONY, "sony" }, { RC_TYPE_RC5_SZ, "rc-5-sz" }, { RC_TYPE_LIRC, "lirc" }, { RC_TYPE_OTHER, "other" }, }; #define PROTO_NONE "none" /** * show_protocols() - shows the current IR protocol(s) * @device: the device descriptor * @mattr: the device attribute struct (unused) * @buf: a pointer to the output buffer * * This routine is a callback routine for input read the IR protocol type(s). * it is trigged by reading /sys/class/rc/rc?/protocols. * It returns the protocol names of supported protocols. * Enabled protocols are printed in brackets. * * dev->lock is taken to guard against races between device * registration, store_protocols and show_protocols. */ static ssize_t show_protocols(struct device *device, struct device_attribute *mattr, char *buf) { struct rc_dev *dev = to_rc_dev(device); u64 allowed, enabled; char *tmp = buf; int i; /* Device is being removed */ if (!dev) return -EINVAL; mutex_lock(&dev->lock); if (dev->driver_type == RC_DRIVER_SCANCODE) { enabled = dev->rc_map.rc_type; allowed = dev->allowed_protos; } else if (dev->raw) { enabled = dev->raw->enabled_protocols; allowed = <API key>(); } else { mutex_unlock(&dev->lock); return -ENODEV; } IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", (long long)allowed, (long long)enabled); for (i = 0; i < ARRAY_SIZE(proto_names); i++) { if (allowed & enabled & proto_names[i].type) tmp += sprintf(tmp, "[%s] ", proto_names[i].name); else if (allowed & proto_names[i].type) tmp += sprintf(tmp, "%s ", proto_names[i].name); } if (tmp != buf) tmp *tmp = '\n'; mutex_unlock(&dev->lock); return tmp + 1 - buf; } /** * store_protocols() - changes the current IR protocol(s) * @device: the device descriptor * @mattr: the device attribute struct (unused) * @buf: a pointer to the input buffer * @len: length of the input buffer * * This routine is for changing the IR protocol type. * It is trigged by writing to /sys/class/rc/rc?/protocols. * Writing "+proto" will add a protocol to the list of enabled protocols. * Writing "-proto" will remove a protocol from the list of enabled protocols. * Writing "proto" will enable only "proto". * Writing "none" will disable all protocols. * Returns -EINVAL if an invalid protocol combination or unknown protocol name * is used, otherwise @len. * * dev->lock is taken to guard against races between device * registration, store_protocols and show_protocols. */ static ssize_t store_protocols(struct device *device, struct device_attribute *mattr, const char *data, size_t len) { struct rc_dev *dev = to_rc_dev(device); bool enable, disable; const char *tmp; u64 type; u64 mask; int rc, i, count = 0; unsigned long flags; ssize_t ret; /* Device is being removed */ if (!dev) return -EINVAL; mutex_lock(&dev->lock); if (dev->driver_type == RC_DRIVER_SCANCODE) type = dev->rc_map.rc_type; else if (dev->raw) type = dev->raw->enabled_protocols; else { IR_dprintk(1, "Protocol switching not supported\n"); ret = -EINVAL; goto out; } while ((tmp = strsep((char **) &data, " \n")) != NULL) { if (!*tmp) break; if (*tmp == '+') { enable = true; disable = false; tmp++; } else if (*tmp == '-') { enable = false; disable = true; tmp++; } else { enable = false; disable = false; } if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) { tmp += sizeof(PROTO_NONE); mask = 0; count++; } else { for (i = 0; i < ARRAY_SIZE(proto_names); i++) { if (!strcasecmp(tmp, proto_names[i].name)) { tmp += strlen(proto_names[i].name); mask = proto_names[i].type; break; } } if (i == ARRAY_SIZE(proto_names)) { IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); ret = -EINVAL; goto out; } count++; } if (enable) type |= mask; else if (disable) type &= ~mask; else type = mask; } if (!count) { IR_dprintk(1, "Protocol not specified\n"); ret = -EINVAL; goto out; } if (dev->change_protocol) { rc = dev->change_protocol(dev, type); if (rc < 0) { IR_dprintk(1, "Error setting protocols to 0x%llx\n", (long long)type); ret = -EINVAL; goto out; } } if (dev->driver_type == RC_DRIVER_SCANCODE) { spin_lock_irqsave(&dev->rc_map.lock, flags); dev->rc_map.rc_type = type; <API key>(&dev->rc_map.lock, flags); } else { dev->raw->enabled_protocols = type; } IR_dprintk(1, "Current protocol(s): 0x%llx\n", (long long)type); ret = len; out: mutex_unlock(&dev->lock); return ret; } static void rc_dev_release(struct device *device) { struct rc_dev *dev = to_rc_dev(device); kfree(dev); module_put(THIS_MODULE); } #define ADD_HOTPLUG_VAR(fmt, val...) \ do { \ int err = add_uevent_var(env, fmt, val); \ if (err) \ return err; \ } while (0) static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) { struct rc_dev *dev = to_rc_dev(device); if (dev->rc_map.name) ADD_HOTPLUG_VAR("NAME=%s", dev->rc_map.name); if (dev->driver_name) ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name); return 0; } /* * Static device attribute struct with the sysfs attributes for IR's */ static DEVICE_ATTR(protocols, S_IRUGO | S_IWUSR, show_protocols, store_protocols); static struct attribute *rc_dev_attrs[] = { &dev_attr_protocols.attr, NULL, }; static struct attribute_group rc_dev_attr_grp = { .attrs = rc_dev_attrs, }; static const struct attribute_group *rc_dev_attr_groups[] = { &rc_dev_attr_grp, NULL }; static struct device_type rc_dev_type = { .groups = rc_dev_attr_groups, .release = rc_dev_release, .uevent = rc_dev_uevent, }; struct rc_dev *rc_allocate_device(void) { struct rc_dev *dev; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return NULL; dev->input_dev = <API key>(); if (!dev->input_dev) { kfree(dev); return NULL; } dev->input_dev->getkeycode = ir_getkeycode; dev->input_dev->setkeycode = ir_setkeycode; input_set_drvdata(dev->input_dev, dev); spin_lock_init(&dev->rc_map.lock); spin_lock_init(&dev->keylock); mutex_init(&dev->lock); setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev); dev->dev.type = &rc_dev_type; dev->dev.class = &ir_input_class; device_initialize(&dev->dev); __module_get(THIS_MODULE); return dev; } EXPORT_SYMBOL_GPL(rc_allocate_device); void rc_free_device(struct rc_dev *dev) { if (dev) { input_free_device(dev->input_dev); put_device(&dev->dev); } } EXPORT_SYMBOL_GPL(rc_free_device); int rc_register_device(struct rc_dev *dev) { static atomic_t devno = ATOMIC_INIT(0); struct rc_map *rc_map; const char *path; int rc; if (!dev || !dev->map_name) return -EINVAL; rc_map = rc_map_get(dev->map_name); if (!rc_map) rc_map = rc_map_get(RC_MAP_EMPTY); if (!rc_map || !rc_map->scan || rc_map->size == 0) return -EINVAL; set_bit(EV_KEY, dev->input_dev->evbit); set_bit(EV_REP, dev->input_dev->evbit); set_bit(EV_MSC, dev->input_dev->evbit); set_bit(MSC_SCAN, dev->input_dev->mscbit); if (dev->open) dev->input_dev->open = ir_open; if (dev->close) dev->input_dev->close = ir_close; /* * Take the lock here, as the device sysfs node will appear * when device_add() is called, which may trigger an ir-keytable udev * rule, which will in turn call show_protocols and access either * dev->rc_map.rc_type or dev->raw->enabled_protocols before it has * been initialized. */ mutex_lock(&dev->lock); dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1); dev_set_name(&dev->dev, "rc%ld", dev->devno); dev_set_drvdata(&dev->dev, dev); rc = device_add(&dev->dev); if (rc) goto out_unlock; rc = ir_setkeytable(dev, rc_map); if (rc) goto out_dev; dev->input_dev->dev.parent = &dev->dev; memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id)); dev->input_dev->phys = dev->input_phys; dev->input_dev->name = dev->input_name; rc = <API key>(dev->input_dev); if (rc) goto out_table; /* * Default delay of 250ms is too short for some protocols, especially * since the timeout is currently set to 250ms. Increase it to 500ms, * to avoid wrong repetition of the keycodes. Note that this must be * set after the call to <API key>(). */ dev->input_dev->rep[REP_DELAY] = 500; /* * As a repeat event on protocols like RC-5 and NEC take as long as * 110/114ms, using 33ms as a repeat period is not the right thing * to do. */ dev->input_dev->rep[REP_PERIOD] = 125; path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); printk(KERN_INFO "%s: %s as %s\n", dev_name(&dev->dev), dev->input_name ? dev->input_name : "Unspecified device", path ? path : "N/A"); kfree(path); if (dev->driver_type == RC_DRIVER_IR_RAW) { rc = <API key>(dev); if (rc < 0) goto out_input; } mutex_unlock(&dev->lock); if (dev->change_protocol) { rc = dev->change_protocol(dev, rc_map->rc_type); if (rc < 0) goto out_raw; } IR_dprintk(1, "Registered rc%ld (driver: %s, remote: %s, mode %s)\n", dev->devno, dev->driver_name ? dev->driver_name : "unknown", rc_map->name ? rc_map->name : "unknown", dev->driver_type == RC_DRIVER_IR_RAW ? "raw" : "cooked"); return 0; out_raw: if (dev->driver_type == RC_DRIVER_IR_RAW) <API key>(dev); out_input: <API key>(dev->input_dev); dev->input_dev = NULL; out_table: ir_free_table(&dev->rc_map); out_dev: device_del(&dev->dev); out_unlock: if (mutex_is_locked(&dev->lock)) mutex_unlock(&dev->lock); return rc; } EXPORT_SYMBOL_GPL(rc_register_device); void <API key>(struct rc_dev *dev) { if (!dev) return; del_timer_sync(&dev->timer_keyup); if (dev->driver_type == RC_DRIVER_IR_RAW) <API key>(dev); <API key>(dev->input_dev); dev->input_dev = NULL; ir_free_table(&dev->rc_map); IR_dprintk(1, "Freed keycode table\n"); device_unregister(&dev->dev); } EXPORT_SYMBOL_GPL(<API key>); /* * Init/exit code for the module. Basically, creates/removes /sys/class/rc */ static int __init rc_core_init(void) { int rc = class_register(&ir_input_class); if (rc) { printk(KERN_ERR "rc_core: unable to register rc class\n"); return rc; } /* Initialize/load the decoders/keymap code that will be used */ ir_raw_init(); rc_map_register(&empty_map); return 0; } static void __exit rc_core_exit(void) { class_unregister(&ir_input_class); rc_map_unregister(&empty_map); } module_init(rc_core_init); module_exit(rc_core_exit); int rc_core_debug; /* ir_debug level (0,1,2) */ EXPORT_SYMBOL_GPL(rc_core_debug); module_param_named(debug, rc_core_debug, int, 0644); MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); MODULE_LICENSE("GPL");
// Use, modification, and distribution are subject to the // File : $RCSfile$ // Version : $Revision: 49312 $ // Description : offline implementation of char parameter #define <API key> #include <boost/test/utils/runtime/cla/char_parameter.ipp>
var baseIndexOf = require('./baseIndexOf'), cacheIndexOf = require('./cacheIndexOf'), createCache = require('./createCache'), getArray = require('./getArray'), largeArraySize = require('./largeArraySize'), releaseArray = require('./releaseArray'), releaseObject = require('./releaseObject'); /** * The base implementation of `_.uniq` without support for callback shorthands * or `thisArg` binding. * * @private * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. * @param {Function} [callback] The function called per iteration. * @returns {Array} Returns a <API key> array. */ function baseUniq(array, isSorted, callback) { var index = -1, indexOf = baseIndexOf, length = array ? array.length : 0, result = []; var isLarge = !isSorted && length >= largeArraySize, seen = (callback || isLarge) ? getArray() : result; if (isLarge) { var cache = createCache(seen); indexOf = cacheIndexOf; seen = cache; } while (++index < length) { var value = array[index], computed = callback ? callback(value, index, array) : value; if (isSorted ? !index || seen[seen.length - 1] !== computed : indexOf(seen, computed) < 0 ) { if (callback || isLarge) { seen.push(computed); } result.push(value); } } if (isLarge) { releaseArray(seen.array); releaseObject(seen); } else if (callback) { releaseArray(seen); } return result; } module.exports = baseUniq;
jQuery.extend(jQuery.fn.pickadate.defaults,{monthsFull:["janúar","febrúar","mars","apríl","maí","júní","júlí","ágúst","september","október","nóvember","desember"],monthsShort:["jan","feb","mar","apr","maí","jún","júl","ágú","sep","okt","nóv","des"],weekdaysFull:["sunnudagur","mánudagur","þriðjudagur","miðvikudagur","fimmtudagur","föstudagur","laugardagur"],weekdaysShort:["sun","mán","þri","mið","fim","fös","lau"],today:"Í dag",clear:"Hreinsa",firstDay:1,format:"dd. mmmm yyyy",formatSubmit:"yyyy/mm/dd"}),jQuery.extend(jQuery.fn.pickatime.defaults,{clear:"Hreinsa"});
var <API key> = (window.history != null ? window.history.pushState : null) != null; createTest('Nested route with the many children as a tokens, callbacks should yield historic params', { '/a': { '/:id': { '/:id': function(a, b) { if (!<API key>) { shared.fired.push(location.hash.replace(/^#/, ''), a, b); } else { shared.fired.push(location.pathname, a, b); } } } } }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['/a/b/c', 'b', 'c']); this.finish(); }); }); createTest('Nested route with the first child as a token, callback should yield a param', { '/foo': { '/:id': { on: function(id) { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname, id); } } } } }, function() { this.navigate('/foo/a', function() { this.navigate('/foo/b/c', function() { deepEqual(shared.fired, ['/foo/a', 'a']); this.finish(); }); }); }); createTest('Nested route with the first child as a regexp, callback should yield a param', { '/foo': { '/(\\w+)': { on: function(value) { if (!<API key>) { shared.fired.push(location.hash.replace(/^#/, ''), value); } else { shared.fired.push(location.pathname, value); } } } } }, function() { this.navigate('/foo/a', function() { this.navigate('/foo/b/c', function() { deepEqual(shared.fired, ['/foo/a', 'a']); this.finish(); }); }); }); createTest('Nested route with the several regular expressions, callback should yield a param', { '/a': { '/(\\w+)': { '/(\\w+)': function(a, b) { shared.fired.push(a, b); } } } }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['b', 'c']); this.finish(); }); }); createTest('Single nested route with on member containing function value', { '/a': { '/b': { on: function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } } } }, function() { this.navigate('/a/b', function() { deepEqual(shared.fired, ['/a/b']); this.finish(); }); }); createTest('Single non-nested route with on member containing function value', { '/a/b': { on: function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } } }, function() { this.navigate('/a/b', function() { deepEqual(shared.fired, ['/a/b']); this.finish(); }); }); createTest('Single nested route with on member containing array of function values', { '/a': { '/b': { on: [function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } }, function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } }] } } }, function() { this.navigate('/a/b', function() { deepEqual(shared.fired, ['/a/b', '/a/b']); this.finish(); }); }); createTest('method should only fire once on the route.', { '/a': { '/b': { once: function() { shared.fired_count++; } } } }, function() { this.navigate('/a/b', function() { this.navigate('/a/b', function() { this.navigate('/a/b', function() { deepEqual(shared.fired_count, 1); this.finish(); }); }); }); }); createTest('method should only fire once on the route, multiple nesting.', { '/a': { on: function() { shared.fired_count++; }, once: function() { shared.fired_count++; } }, '/b': { on: function() { shared.fired_count++; }, once: function() { shared.fired_count++; } } }, function() { this.navigate('/a', function() { this.navigate('/b', function() { this.navigate('/a', function() { this.navigate('/b', function() { deepEqual(shared.fired_count, 6); this.finish(); }); }); }); }); }); createTest('overlapping routes with tokens.', { '/a/:b/c' : function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } }, '/a/:b/c/:d' : function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } }, function() { this.navigate('/a/b/c', function() { this.navigate('/a/b/c/d', function() { deepEqual(shared.fired, ['/a/b/c', '/a/b/c/d']); this.finish(); }); }); }); // // // Recursion features createTest('Nested routes with no recursion', { '/a': { '/b': { '/c': { on: function c() { shared.fired.push('c'); } }, on: function b() { shared.fired.push('b'); } }, on: function a() { shared.fired.push('a'); } } }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['c']); this.finish(); }); }); createTest('Nested routes with backward recursion', { '/a': { '/b': { '/c': { on: function c() { shared.fired.push('c'); } }, on: function b() { shared.fired.push('b'); } }, on: function a() { shared.fired.push('a'); } } }, { recurse: 'backward' }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['c', 'b', 'a']); this.finish(); }); }); createTest('Breaking out of nested routes with backward recursion', { '/a': { '/:b': { '/c': { on: function c() { shared.fired.push('c'); } }, on: function b() { shared.fired.push('b'); return false; } }, on: function a() { shared.fired.push('a'); } } }, { recurse: 'backward' }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['c', 'b']); this.finish(); }); }); createTest('Nested routes with forward recursion', { '/a': { '/b': { '/c': { on: function c() { shared.fired.push('c'); } }, on: function b() { shared.fired.push('b'); } }, on: function a() { shared.fired.push('a'); } } }, { recurse: 'forward' }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['a', 'b', 'c']); this.finish(); }); }); createTest('Nested routes with forward recursion, single route with an after event.', { '/a': { '/b': { '/c': { on: function c() { shared.fired.push('c'); }, after: function() { shared.fired.push('c-after'); } }, on: function b() { shared.fired.push('b'); } }, on: function a() { shared.fired.push('a'); } } }, { recurse: 'forward' }, function() { this.navigate('/a/b/c', function() { this.navigate('/a/b', function() { deepEqual(shared.fired, ['a', 'b', 'c', 'c-after', 'a', 'b']); this.finish(); }); }); }); createTest('Breaking out of nested routes with forward recursion', { '/a': { '/b': { '/c': { on: function c() { shared.fired.push('c'); } }, on: function b() { shared.fired.push('b'); return false; } }, on: function a() { shared.fired.push('a'); } } }, { recurse: 'forward' }, function() { this.navigate('/a/b/c', function() { deepEqual(shared.fired, ['a', 'b']); this.finish(); }); }); // ABOVE IS WORKING // // Special Events createTest('All global event should fire after every route', { '/a': { on: function a() { shared.fired.push('a'); } }, '/b': { '/c': { on: function a() { shared.fired.push('a'); } } }, '/d': { '/:e': { on: function a() { shared.fired.push('a'); } } } }, { after: function() { shared.fired.push('b'); } }, function() { this.navigate('/a', function() { this.navigate('/b/c', function() { this.navigate('/d/e', function() { deepEqual(shared.fired, ['a', 'b', 'a', 'b', 'a']); this.finish(); }); }); }); }); createTest('Not found.', { '/a': { on: function a() { shared.fired.push('a'); } }, '/b': { on: function a() { shared.fired.push('b'); } } }, { notfound: function() { shared.fired.push('notfound'); } }, function() { this.navigate('/c', function() { this.navigate('/d', function() { deepEqual(shared.fired, ['notfound', 'notfound']); this.finish(); }); }); }); createTest('On all.', { '/a': { on: function a() { shared.fired.push('a'); } }, '/b': { on: function a() { shared.fired.push('b'); } } }, { on: function() { shared.fired.push('c'); } }, function() { this.navigate('/a', function() { this.navigate('/b', function() { deepEqual(shared.fired, ['a', 'c', 'b', 'c']); this.finish(); }); }); }); createTest('After all.', { '/a': { on: function a() { shared.fired.push('a'); } }, '/b': { on: function a() { shared.fired.push('b'); } } }, { after: function() { shared.fired.push('c'); } }, function() { this.navigate('/a', function() { this.navigate('/b', function() { deepEqual(shared.fired, ['a', 'c', 'b']); this.finish(); }); }); }); createTest('resource object.', { '/a': { '/b/:c': { on: 'f1' }, on: 'f2' }, '/d': { on: ['f1', 'f2'] } }, { resource: { f1: function (name){ shared.fired.push("f1-" + name); }, f2: function (name){ shared.fired.push("f2"); } } }, function() { this.navigate('/a/b/c', function() { this.navigate('/d', function() { deepEqual(shared.fired, ['f1-c', 'f1-undefined', 'f2']); this.finish(); }); }); }); createTest('argument matching should be case agnostic', { '/fooBar/:name': { on: function(name) { shared.fired.push("fooBar-" + name); } } }, function() { this.navigate('/fooBar/tesTing', function() { deepEqual(shared.fired, ['fooBar-tesTing']); this.finish(); }); }); createTest('sanity test', { '/is/:this/:sane': { on: function(a, b) { shared.fired.push('yes ' + a + ' is ' + b); } }, '/': { on: function() { shared.fired.push('is there sanity?'); } } }, function() { this.navigate('/is/there/sanity', function() { deepEqual(shared.fired, ['yes there is sanity']); this.finish(); }); }); createTest('`/` route should be navigable from the routing table', { '/': { on: function root() { shared.fired.push('/'); } }, '/:username': { on: function afunc(username) { shared.fired.push('/' + username); } } }, function() { this.navigate('/', function root() { deepEqual(shared.fired, ['/']); this.finish(); }); }); createTest('`/` route should not override a `/:token` route', { '/': { on: function root() { shared.fired.push('/'); } }, '/:username': { on: function afunc(username) { shared.fired.push('/' + username); } } }, function() { this.navigate('/a', function afunc() { deepEqual(shared.fired, ['/a']); this.finish(); }); }); createTest('should accept the root as a token.', { '/:a': { on: function root() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } } }, function() { this.navigate('/a', function root() { deepEqual(shared.fired, ['/a']); this.finish(); }); }); createTest('routes should allow wildcards.', { '/:a/b*d': { on: function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } } }, function() { this.navigate('/a/bcd', function root() { deepEqual(shared.fired, ['/a/bcd']); this.finish(); }); }); createTest('functions should have |this| context of the router instance.', { '/': { on: function root() { shared.fired.push(!!this.routes); } } }, function() { this.navigate('/', function root() { deepEqual(shared.fired, [true]); this.finish(); }); }); createTest('setRoute with a single parameter should change location correctly', { '/bonk': { on: function() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(window.location.pathname); } } } }, function() { var self = this; this.router.setRoute('/bonk'); setTimeout(function() { deepEqual(shared.fired, ['/bonk']); self.finish(); }, 14) }); createTest('route should accept _ and . within parameters', { '/:a': { on: function root() { if (!<API key>) { shared.fired.push(location.hash.replace(/^ } else { shared.fired.push(location.pathname); } } } }, function() { this.navigate('/a_complex_route.co.uk', function root() { deepEqual(shared.fired, ['/a_complex_route.co.uk']); this.finish(); }); });
<reference types="easeljs"/> var target = new createjs.DisplayObject(); // Chainable modules : target.alpha = 1; createjs.Tween.get(target).wait(500, false).to({ alpha: 0, visible: false }, 1000).call(onComplete); function onComplete() { //Tween complete }
#ifndef <API key> #define <API key> // $Id: lower_bound.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ // $Revision: 49267 $ #include <boost/mpl/less.hpp> #include <boost/mpl/lambda.hpp> #include <boost/mpl/aux_/na_spec.hpp> #include <boost/mpl/aux_/config/workaround.hpp> #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) # define <API key> #endif #if !defined(<API key>) # include <boost/mpl/minus.hpp> # include <boost/mpl/divides.hpp> # include <boost/mpl/size.hpp> # include <boost/mpl/advance.hpp> # include <boost/mpl/begin_end.hpp> # include <boost/mpl/long.hpp> # include <boost/mpl/eval_if.hpp> # include <boost/mpl/prior.hpp> # include <boost/mpl/deref.hpp> # include <boost/mpl/apply.hpp> # include <boost/mpl/aux_/value_wknd.hpp> #else # include <boost/mpl/not.hpp> # include <boost/mpl/find.hpp> # include <boost/mpl/bind.hpp> #endif #include <boost/config.hpp> namespace boost { namespace mpl { #if defined(<API key>) // agurt 23/oct/02: has a wrong complexity etc., but at least it works // feel free to contribute a better implementation! template< typename <API key>(Sequence) , typename <API key>(T) , typename Predicate = less<> , typename pred_ = typename lambda<Predicate>::type > struct lower_bound : find_if< Sequence, bind1< not_<>, bind2<pred_,_,T> > > { }; #else namespace aux { template< typename Distance , typename Predicate , typename T , typename DeferredIterator > struct <API key>; template< typename Distance , typename Predicate , typename T , typename DeferredIterator > struct lower_bound_step { typedef typename eval_if< Distance , <API key><Distance,Predicate,T,DeferredIterator> , DeferredIterator >::type type; }; template< typename Distance , typename Predicate , typename T , typename DeferredIterator > struct <API key> { typedef typename divides< Distance, long_<2> >::type offset_; typedef typename DeferredIterator::type iter_; typedef typename advance< iter_,offset_ >::type middle_; typedef typename apply2< Predicate , typename deref<middle_>::type , T >::type cond_; typedef typename prior< minus< Distance, offset_> >::type step_; typedef lower_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_; typedef lower_bound_step< step_,Predicate,T,next<middle_> > step_backward_; typedef typename eval_if< cond_ , step_backward_ , step_forward_ >::type type; }; } // namespace aux template< typename <API key>(Sequence) , typename <API key>(T) , typename Predicate = less<> > struct lower_bound { private: typedef typename lambda<Predicate>::type pred_; typedef typename size<Sequence>::type size_; public: typedef typename aux::lower_bound_step< size_,pred_,T,begin<Sequence> >::type type; }; #endif // <API key> <API key>(2, lower_bound) }} #endif // <API key>
(function(window, angular, undefined) { 'use strict'; /** * @ngdoc overview * @name ngResource * @description */ angular.module('ngResource', ['ng']). factory('$resource', ['$http', '$parse', function($http, $parse) { var DEFAULT_ACTIONS = { 'get': {method:'GET'}, 'save': {method:'POST'}, 'query': {method:'GET', isArray:true}, 'remove': {method:'DELETE'}, 'delete': {method:'DELETE'} }; var noop = angular.noop, forEach = angular.forEach, extend = angular.extend, copy = angular.copy, isFunction = angular.isFunction, getter = function(obj, path) { return $parse(path)(obj); }; function encodeUriSegment(val) { return encodeUriQuery(val, true). replace(/%26/gi, '&'). replace(/%3D/gi, '='). replace(/%2B/gi, '+'); } function encodeUriQuery(val, pctEncodeSpaces) { return encodeURIComponent(val). replace(/%40/gi, '@'). replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); } function Route(template, defaults) { this.template = template = template + ' this.defaults = defaults || {}; var urlParams = this.urlParams = {}; forEach(template.split(/\W/), function(param){ if (param && (new RegExp("(^|[^\\\\]):" + param + "\\W").test(template))) { urlParams[param] = true; } }); this.template = template.replace(/\\:/g, ':'); } Route.prototype = { url: function(params) { var self = this, url = this.template, val, encodedVal; params = params || {}; forEach(this.urlParams, function(_, urlParam){ val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; if (angular.isDefined(val) && val !== null) { encodedVal = encodeUriSegment(val); url = url.replace(new RegExp(":" + urlParam + "(\\W)", "g"), encodedVal + "$1"); } else { url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W)", "g"), function(match, leadingSlashes, tail) { if (tail.charAt(0) == '/') { return tail; } else { return leadingSlashes + tail; } }); } }); url = url.replace(/\/? var query = []; forEach(params, function(value, key){ if (!self.urlParams[key]) { query.push(encodeUriQuery(key) + '=' + encodeUriQuery(value)); } }); query.sort();
#include <linux/module.h> #include <linux/sched.h> #include <linux/stddef.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/mii.h> #include <linux/usb.h> #include <linux/crc32.h> #include <linux/usb/usbnet.h> #include "sr9700.h" static int sr_read(struct usbnet *dev, u8 reg, u16 length, void *data) { int err; err = usbnet_read_cmd(dev, SR_RD_REGS, SR_REQ_RD_REG, 0, reg, data, length); if ((err != length) && (err >= 0)) err = -EINVAL; return err; } static int sr_write(struct usbnet *dev, u8 reg, u16 length, void *data) { int err; err = usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, 0, reg, data, length); if ((err >= 0) && (err < length)) err = -EINVAL; return err; } static int sr_read_reg(struct usbnet *dev, u8 reg, u8 *value) { return sr_read(dev, reg, 1, value); } static int sr_write_reg(struct usbnet *dev, u8 reg, u8 value) { return usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, value, reg, NULL, 0); } static void sr_write_async(struct usbnet *dev, u8 reg, u16 length, const void *data) { <API key>(dev, SR_WR_REGS, SR_REQ_WR_REG, 0, reg, data, length); } static void sr_write_reg_async(struct usbnet *dev, u8 reg, u8 value) { <API key>(dev, SR_WR_REGS, SR_REQ_WR_REG, value, reg, NULL, 0); } static int <API key>(struct usbnet *dev, int phy) { int i; for (i = 0; i < SR_SHARE_TIMEOUT; i++) { u8 tmp = 0; int ret; udelay(1); ret = sr_read_reg(dev, SR_EPCR, &tmp); if (ret < 0) return ret; /* ready */ if (!(tmp & EPCR_ERRE)) return 0; } netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); return -EIO; } static int sr_share_read_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) { int ret; mutex_lock(&dev->phy_mutex); sr_write_reg(dev, SR_EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); sr_write_reg(dev, SR_EPCR, phy ? (EPCR_EPOS | EPCR_ERPRR) : EPCR_ERPRR); ret = <API key>(dev, phy); if (ret < 0) goto out_unlock; sr_write_reg(dev, SR_EPCR, 0x0); ret = sr_read(dev, SR_EPDR, 2, value); netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", phy, reg, *value, ret); out_unlock: mutex_unlock(&dev->phy_mutex); return ret; } static int sr_share_write_word(struct usbnet *dev, int phy, u8 reg, __le16 value) { int ret; mutex_lock(&dev->phy_mutex); ret = sr_write(dev, SR_EPDR, 2, &value); if (ret < 0) goto out_unlock; sr_write_reg(dev, SR_EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); sr_write_reg(dev, SR_EPCR, phy ? (EPCR_WEP | EPCR_EPOS | EPCR_ERPRW) : (EPCR_WEP | EPCR_ERPRW)); ret = <API key>(dev, phy); if (ret < 0) goto out_unlock; sr_write_reg(dev, SR_EPCR, 0x0); out_unlock: mutex_unlock(&dev->phy_mutex); return ret; } static int sr_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) { return sr_share_read_word(dev, 0, offset, value); } static int <API key>(struct net_device *netdev) { return SR_EEPROM_LEN; } static int sr9700_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, u8 *data) { struct usbnet *dev = netdev_priv(netdev); __le16 *buf = (__le16 *)data; int ret = 0; int i; /* access is 16bit */ if ((eeprom->offset & 0x01) || (eeprom->len & 0x01)) return -EINVAL; for (i = 0; i < eeprom->len / 2; i++) { ret = sr_read_eeprom_word(dev, eeprom->offset / 2 + i, buf + i); if (ret < 0) break; } return ret; } static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); __le16 res; int rc = 0; if (phy_id) { netdev_dbg(netdev, "Only internal phy supported\n"); return 0; } /* Access NSR_LINKST bit for link status instead of MII_BMSR */ if (loc == MII_BMSR) { u8 value; sr_read_reg(dev, SR_NSR, &value); if (value & NSR_LINKST) rc = 1; } sr_share_read_word(dev, 1, loc, &res); if (rc == 1) res = le16_to_cpu(res) | BMSR_LSTATUS; else res = le16_to_cpu(res) & ~BMSR_LSTATUS; netdev_dbg(netdev, "sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", phy_id, loc, res); return res; } static void sr_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) { struct usbnet *dev = netdev_priv(netdev); __le16 res = cpu_to_le16(val); if (phy_id) { netdev_dbg(netdev, "Only internal phy supported\n"); return; } netdev_dbg(netdev, "sr_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", phy_id, loc, val); sr_share_write_word(dev, 1, loc, res); } static u32 sr9700_get_link(struct net_device *netdev) { struct usbnet *dev = netdev_priv(netdev); u8 value = 0; int rc = 0; /* Get the Link Status directly */ sr_read_reg(dev, SR_NSR, &value); if (value & NSR_LINKST) rc = 1; return rc; } static int sr9700_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) { struct usbnet *dev = netdev_priv(netdev); return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); } static const struct ethtool_ops sr9700_ethtool_ops = { .get_drvinfo = usbnet_get_drvinfo, .get_link = sr9700_get_link, .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .get_eeprom_len = <API key>, .get_eeprom = sr9700_get_eeprom, .nway_reset = usbnet_nway_reset, .get_link_ksettings = <API key>, .set_link_ksettings = <API key>, }; static void <API key>(struct net_device *netdev) { struct usbnet *dev = netdev_priv(netdev); /* We use the 20 byte dev->data for our 8 byte filter buffer * to avoid allocating memory that is tricky to free later */ u8 *hashes = (u8 *)&dev->data; /* rx_ctl setting : enable, disable_long, disable_crc */ u8 rx_ctl = RCR_RXEN | RCR_DIS_CRC | RCR_DIS_LONG; memset(hashes, 0x00, SR_MCAST_SIZE); /* broadcast address */ hashes[SR_MCAST_SIZE - 1] |= SR_MCAST_ADDR_FLAG; if (netdev->flags & IFF_PROMISC) { rx_ctl |= RCR_PRMSC; } else if (netdev->flags & IFF_ALLMULTI || netdev_mc_count(netdev) > SR_MCAST_MAX) { rx_ctl |= RCR_RUNT; } else if (!netdev_mc_empty(netdev)) { struct netdev_hw_addr *ha; <API key>(ha, netdev) { u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; hashes[crc >> 3] |= 1 << (crc & 0x7); } } sr_write_async(dev, SR_MAR, SR_MCAST_SIZE, hashes); sr_write_reg_async(dev, SR_RCR, rx_ctl); } static int <API key>(struct net_device *netdev, void *p) { struct usbnet *dev = netdev_priv(netdev); struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) { netdev_err(netdev, "not setting invalid mac address %pM\n", addr->sa_data); return -EINVAL; } eth_hw_addr_set(netdev, addr->sa_data); sr_write_async(dev, SR_PAR, 6, netdev->dev_addr); return 0; } static const struct net_device_ops sr9700_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, .ndo_change_mtu = usbnet_change_mtu, .ndo_get_stats64 = dev_get_tstats64, .ndo_validate_addr = eth_validate_addr, .ndo_eth_ioctl = sr9700_ioctl, .ndo_set_rx_mode = <API key>, .ndo_set_mac_address = <API key>, }; static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf) { struct net_device *netdev; struct mii_if_info *mii; u8 addr[ETH_ALEN]; int ret; ret = <API key>(dev, intf); if (ret) goto out; netdev = dev->net; netdev->netdev_ops = &sr9700_netdev_ops; netdev->ethtool_ops = &sr9700_ethtool_ops; netdev->hard_header_len += SR_TX_OVERHEAD; dev->hard_mtu = netdev->mtu + netdev->hard_header_len; /* bulkin buffer is preferably not less than 3K */ dev->rx_urb_size = 3072; mii = &dev->mii; mii->dev = netdev; mii->mdio_read = sr_mdio_read; mii->mdio_write = sr_mdio_write; mii->phy_id_mask = 0x1f; mii->reg_num_mask = 0x1f; sr_write_reg(dev, SR_NCR, NCR_RST); udelay(20); /* read MAC * After Chip Power on, the Chip will reload the MAC from * EEPROM automatically to PAR. In case there is no EEPROM externally, * a default MAC address is stored in PAR for making chip work properly. */ if (sr_read(dev, SR_PAR, ETH_ALEN, addr) < 0) { netdev_err(netdev, "Error reading MAC address\n"); ret = -ENODEV; goto out; } eth_hw_addr_set(netdev, addr); /* power up and reset phy */ sr_write_reg(dev, SR_PRR, PRR_PHY_RST); /* at least 10ms, here 20ms for safe */ msleep(20); sr_write_reg(dev, SR_PRR, 0); /* at least 1ms, here 2ms for reading right register */ udelay(2 * 1000); /* receive broadcast packets */ <API key>(netdev); sr_mdio_write(netdev, mii->phy_id, MII_BMCR, BMCR_RESET); sr_mdio_write(netdev, mii->phy_id, MII_ADVERTISE, ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); mii_nway_restart(mii); out: return ret; } static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { struct sk_buff *sr_skb; int len; /* skb content (packets) format : * p0 p1 p2 ...... pm * / \ * / \ * / \ * / \ * p0b0 p0b1 p0b2 p0b3 ...... p0b(n-4) p0b(n-3)...p0bn * * p0 : packet 0 * p0b0 : packet 0 byte 0 * * b0: rx status * b1: packet length (incl crc) low * b2: packet length (incl crc) high * b3..n-4: packet data * bn-3..bn: ethernet packet crc */ if (unlikely(skb->len < SR_RX_OVERHEAD)) { netdev_err(dev->net, "unexpected tiny rx frame\n"); return 0; } /* one skb may contains multiple packets */ while (skb->len > SR_RX_OVERHEAD) { if (skb->data[0] != 0x40) return 0; /* ignore the CRC length */ len = (skb->data[1] | (skb->data[2] << 8)) - 4; if (len > ETH_FRAME_LEN) return 0; /* the last packet of current skb */ if (skb->len == (len + SR_RX_OVERHEAD)) { skb_pull(skb, 3); skb->len = len; <API key>(skb, len); skb->truesize = len + sizeof(struct sk_buff); return 2; } /* skb_clone is used for address align */ sr_skb = skb_clone(skb, GFP_ATOMIC); if (!sr_skb) return 0; sr_skb->len = len; sr_skb->data = skb->data + 3; <API key>(sr_skb, len); sr_skb->truesize = len + sizeof(struct sk_buff); usbnet_skb_return(dev, sr_skb); skb_pull(skb, len + SR_RX_OVERHEAD); } return 0; } static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { int len; /* SR9700 can only send out one ethernet packet at once. * * b0 b1 b2 b3 ...... b(n-4) b(n-3)...bn * * b0: rx status * b1: packet length (incl crc) low * b2: packet length (incl crc) high * b3..n-4: packet data * bn-3..bn: ethernet packet crc */ len = skb->len; if (skb_cow_head(skb, SR_TX_OVERHEAD)) { dev_kfree_skb_any(skb); return NULL; } __skb_push(skb, SR_TX_OVERHEAD); /* usbnet adds padding if length is a multiple of packet size * if so, adjust length value in header */ if ((skb->len % dev->maxpacket) == 0) len++; skb->data[0] = len; skb->data[1] = len >> 8; return skb; } static void sr9700_status(struct usbnet *dev, struct urb *urb) { int link; u8 *buf; /* format: b0: net status b1: tx status 1 b2: tx status 2 b3: rx status b4: rx overflow b5: rx count b6: tx count b7: gpr */ if (urb->actual_length < 8) return; buf = urb->transfer_buffer; link = !!(buf[0] & 0x40); if (netif_carrier_ok(dev->net) != link) { usbnet_link_change(dev, link, 1); netdev_dbg(dev->net, "Link Status is: %d\n", link); } } static int sr9700_link_reset(struct usbnet *dev) { struct ethtool_cmd ecmd; mii_check_media(&dev->mii, 1, 1); mii_ethtool_gset(&dev->mii, &ecmd); netdev_dbg(dev->net, "link_reset() speed: %d duplex: %d\n", ecmd.speed, ecmd.duplex); return 0; } static const struct driver_info sr9700_driver_info = { .description = "CoreChip SR9700 USB Ethernet", .flags = FLAG_ETHER, .bind = sr9700_bind, .rx_fixup = sr9700_rx_fixup, .tx_fixup = sr9700_tx_fixup, .status = sr9700_status, .link_reset = sr9700_link_reset, .reset = sr9700_link_reset, }; static const struct usb_device_id products[] = { { USB_DEVICE(0x0fe6, 0x9700), /* SR9700 device */ .driver_info = (unsigned long)&sr9700_driver_info, }, {}, /* END */ }; MODULE_DEVICE_TABLE(usb, products); static struct usb_driver sr9700_usb_driver = { .name = "sr9700", .id_table = products, .probe = usbnet_probe, .disconnect = usbnet_disconnect, .suspend = usbnet_suspend, .resume = usbnet_resume, .<API key> = 1, }; module_usb_driver(sr9700_usb_driver); MODULE_AUTHOR("liujl <liujunliang_ljl@163.com>"); MODULE_DESCRIPTION("SR9700 one chip USB 1.1 USB to Ethernet device from http: MODULE_LICENSE("GPL");
#include <linux/init.h> #include <linux/irq.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> #include <linux/smsc911x.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/mtd/physmap.h> #include <linux/mtd/map.h> #include <mach/magicpanelr2.h> #include <asm/heartbeat.h> #include <cpu/sh7720.h> #define LAN9115_READY (__raw_readl(0xA8000084UL) & 0x00000001UL) /* Wait until reset finished. Timeout is 100ms. */ static int __init <API key>(void) { int i; if (LAN9115_READY) return 1; for (i = 0; i < 10; ++i) { mdelay(10); if (LAN9115_READY) return 1; } return 0; } static void __init reset_ethernet(void) { /* PMDR: LAN_RESET=on */ CLRBITS_OUTB(0x10, PORT_PMDR); udelay(200); /* PMDR: LAN_RESET=off */ SETBITS_OUTB(0x10, PORT_PMDR); } static void __init setup_chip_select(void) { /* CS2: LAN (0x08000000 - 0x0bffffff) */ /* no idle cycles, normal space, 8 bit data bus */ __raw_writel(0x36db0400, CS2BCR); /* (SW:1.5 WR:3 HW:1.5), ext. wait */ __raw_writel(0x000003c0, CS2WCR); /* CS4: CAN1 (0xb0000000 - 0xb3ffffff) */ /* no idle cycles, normal space, 8 bit data bus */ __raw_writel(0x00000200, CS4BCR); /* (SW:1.5 WR:3 HW:1.5), ext. wait */ __raw_writel(0x00100981, CS4WCR); /* CS5a: CAN2 (0xb4000000 - 0xb5ffffff) */ /* no idle cycles, normal space, 8 bit data bus */ __raw_writel(0x00000200, CS5ABCR); /* (SW:1.5 WR:3 HW:1.5), ext. wait */ __raw_writel(0x00100981, CS5AWCR); /* CS5b: CAN3 (0xb6000000 - 0xb7ffffff) */ /* no idle cycles, normal space, 8 bit data bus */ __raw_writel(0x00000200, CS5BBCR); /* (SW:1.5 WR:3 HW:1.5), ext. wait */ __raw_writel(0x00100981, CS5BWCR); /* CS6a: Rotary (0xb8000000 - 0xb9ffffff) */ /* no idle cycles, normal space, 8 bit data bus */ __raw_writel(0x00000200, CS6ABCR); /* (SW:1.5 WR:3 HW:1.5), no ext. wait */ __raw_writel(0x001009C1, CS6AWCR); } static void __init <API key>(void) { /* A7 GPO(LED8); A6 GPO(LED7); A5 GPO(LED6); A4 GPO(LED5); * A3 GPO(LED4); A2 GPO(LED3); A1 GPO(LED2); A0 GPO(LED1); */ __raw_writew(0x5555, PORT_PACR); /* 01 01 01 01 01 01 01 01 */ /* B7 GPO(RST4); B6 GPO(RST3); B5 GPO(RST2); B4 GPO(RST1); * B3 GPO(PB3); B2 GPO(PB2); B1 GPO(PB1); B0 GPO(PB0); */ __raw_writew(0x5555, PORT_PBCR); /* 01 01 01 01 01 01 01 01 */ /* C7 GPO(PC7); C6 GPO(PC6); C5 GPO(PC5); C4 GPO(PC4); * C3 LCD_DATA3; C2 LCD_DATA2; C1 LCD_DATA1; C0 LCD_DATA0; */ __raw_writew(0x5500, PORT_PCCR); /* 01 01 01 01 00 00 00 00 */ /* D7 GPO(PD7); D6 GPO(PD6); D5 GPO(PD5); D4 GPO(PD4); * D3 GPO(PD3); D2 GPO(PD2); D1 GPO(PD1); D0 GPO(PD0); */ __raw_writew(0x5555, PORT_PDCR); /* 01 01 01 01 01 01 01 01 */ /* E7 (x); E6 GPI(nu); E5 GPI(nu); E4 LCD_M_DISP; * E3 LCD_CL1; E2 LCD_CL2; E1 LCD_DON; E0 LCD_FLM; */ __raw_writew(0x3C00, PORT_PECR); /* 00 11 11 00 00 00 00 00 */ /* F7 (x); F6 DA1(VLCD); F5 DA0(nc); F4 AN3; * F3 AN2(MID_AD); F2 AN1(EARTH_AD); F1 AN0(TEMP); F0 GPI+(nc); */ __raw_writew(0x0002, PORT_PFCR); /* 00 00 00 00 00 00 00 10 */ /* G7 (x); G6 IRQ5(TOUCH_BUSY); G5 IRQ4(TOUCH_IRQ); G4 GPI(KEY2); * G3 GPI(KEY1); G2 GPO(LED11); G1 GPO(LED10); G0 GPO(LED9); */ __raw_writew(0x03D5, PORT_PGCR); /* 00 00 00 11 11 01 01 01 */ /* H7 (x); H6 /RAS(BRAS); H5 /CAS(BCAS); H4 CKE(BCKE); * H3 GPO(EARTH_OFF); H2 GPO(EARTH_TEST); H1 USB2_PWR; H0 USB1_PWR; */ __raw_writew(0x0050, PORT_PHCR); /* 00 00 00 00 01 01 00 00 */ /* J7 (x); J6 AUDCK; J5 ASEBRKAK; J4 AUDATA3; * J3 AUDATA2; J2 AUDATA1; J1 AUDATA0; J0 AUDSYNC; */ __raw_writew(0x0000, PORT_PJCR); /* 00 00 00 00 00 00 00 00 */ /* K7 (x); K6 (x); K5 (x); K4 (x); * K3 PINT7(/PWR2); K2 PINT6(/PWR1); K1 PINT5(nu); K0 PINT4(FLASH_READY) */ __raw_writew(0x00FF, PORT_PKCR); /* 00 00 00 00 11 11 11 11 */ /* L7 TRST; L6 TMS; L5 TDO; L4 TDI; * L3 TCK; L2 (x); L1 (x); L0 (x); */ __raw_writew(0x0000, PORT_PLCR); /* 00 00 00 00 00 00 00 00 */ /* M7 GPO(CURRENT_SINK); M6 GPO(PWR_SWITCH); M5 GPO(LAN_SPEED); * M4 GPO(LAN_RESET); M3 GPO(BUZZER); M2 GPO(LCD_BL); * M1 CS5B(CAN3_CS); M0 GPI+(nc); */ __raw_writew(0x5552, PORT_PMCR); /* 01 01 01 01 01 01 00 10 */ /* CURRENT_SINK=off, PWR_SWITCH=off, LAN_SPEED=100MBit, * LAN_RESET=off, BUZZER=off, LCD_BL=off */ #if <API key> == 2 __raw_writeb(0x30, PORT_PMDR); #elif <API key> == 3 __raw_writeb(0xF0, PORT_PMDR); #else #error Unknown revision of PLATFORM_MP_R2 #endif /* P7 (x); P6 (x); P5 (x); * P4 GPO(nu); P3 IRQ3(LAN_IRQ); P2 IRQ2(CAN3_IRQ); * P1 IRQ1(CAN2_IRQ); P0 IRQ0(CAN1_IRQ) */ __raw_writew(0x0100, PORT_PPCR); /* 00 00 00 01 00 00 00 00 */ __raw_writeb(0x10, PORT_PPDR); /* R7 A25; R6 A24; R5 A23; R4 A22; * R3 A21; R2 A20; R1 A19; R0 A0; */ gpio_request(GPIO_FN_A25, NULL); gpio_request(GPIO_FN_A24, NULL); gpio_request(GPIO_FN_A23, NULL); gpio_request(GPIO_FN_A22, NULL); gpio_request(GPIO_FN_A21, NULL); gpio_request(GPIO_FN_A20, NULL); gpio_request(GPIO_FN_A19, NULL); gpio_request(GPIO_FN_A0, NULL); /* S7 (x); S6 (x); S5 (x); S4 GPO(EEPROM_CS2); * S3 GPO(EEPROM_CS1); S2 SIOF0_TXD; S1 SIOF0_RXD; S0 SIOF0_SCK; */ __raw_writew(0x0140, PORT_PSCR); /* 00 00 00 01 01 00 00 00 */ /* T7 (x); T6 (x); T5 (x); T4 COM1_CTS; * T3 COM1_RTS; T2 COM1_TXD; T1 COM1_RXD; T0 GPO(WDOG) */ __raw_writew(0x0001, PORT_PTCR); /* 00 00 00 00 00 00 00 01 */ /* U7 (x); U6 (x); U5 (x); U4 GPI+(/AC_FAULT); * U3 GPO(TOUCH_CS); U2 TOUCH_TXD; U1 TOUCH_RXD; U0 TOUCH_SCK; */ __raw_writew(0x0240, PORT_PUCR); /* 00 00 00 10 01 00 00 00 */ /* V7 (x); V6 (x); V5 (x); V4 GPO(MID2); * V3 GPO(MID1); V2 CARD_TxD; V1 CARD_RxD; V0 GPI+(/BAT_FAULT); */ __raw_writew(0x0142, PORT_PVCR); /* 00 00 00 01 01 00 00 10 */ } static void __init mpr2_setup(char **cmdline_p) { /* set Pin Select Register A: * /PCC_CD1, /PCC_CD2, PCC_BVD1, PCC_BVD2, * /IOIS16, IRQ4, IRQ5, USB1d_SUSPEND */ __raw_writew(0xAABC, PORT_PSELA); /* set Pin Select Register B: * /SCIF0_RTS, /SCIF0_CTS, LCD_VCPWC, * LCD_VEPWC, IIC_SDA, IIC_SCL, Reserved */ __raw_writew(0x3C00, PORT_PSELB); /* set Pin Select Register C: * SIOF1_SCK, SIOF1_RxD, SCIF1_RxD, SCIF1_TxD, Reserved */ __raw_writew(0x0000, PORT_PSELC); /* set Pin Select Register D: Reserved, SIOF1_TxD, Reserved, SIOF1_MCLK, * Reserved, SIOF1_SYNC, Reserved, SCIF1_SCK, Reserved */ __raw_writew(0x0000, PORT_PSELD); /* set USB TxRx Control: Reserved, DRV, Reserved, USB_TRANS, USB_SEL */ __raw_writew(0x0101, PORT_UTRCTL); /* set USB Clock Control: USSCS, USSTB, Reserved (HighByte always A5) */ __raw_writew(0xA5C0, PORT_UCLKCR_W); setup_chip_select(); <API key>(); reset_ethernet(); printk(KERN_INFO "Magic Panel Release 2 A.%i\n", <API key>); if (<API key>() == 0) printk(KERN_WARNING "Ethernet not ready\n"); } static struct resource smsc911x_resources[] = { [0] = { .start = 0xa8000000, .end = 0xabffffff, .flags = IORESOURCE_MEM, }, [1] = { .start = 35, .end = 35, .flags = IORESOURCE_IRQ, }, }; static struct <API key> smsc911x_config = { .phy_interface = <API key>, .irq_polarity = <API key>, .irq_type = <API key>, .flags = SMSC911X_USE_32BIT, }; static struct platform_device smsc911x_device = { .name = "smsc911x", .id = -1, .num_resources = ARRAY_SIZE(smsc911x_resources), .resource = smsc911x_resources, .dev = { .platform_data = &smsc911x_config, }, }; static struct resource heartbeat_resources[] = { [0] = { .start = PA_LED, .end = PA_LED, .flags = IORESOURCE_MEM, }, }; static struct heartbeat_data heartbeat_data = { .flags = HEARTBEAT_INVERTED, }; static struct platform_device heartbeat_device = { .name = "heartbeat", .id = -1, .dev = { .platform_data = &heartbeat_data, }, .num_resources = ARRAY_SIZE(heartbeat_resources), .resource = heartbeat_resources, }; static struct mtd_partition mpr2_partitions[] = { /* Reserved for bootloader, read-only */ { .name = "Bootloader", .offset = 0x00000000UL, .size = <API key>, .mask_flags = MTD_WRITEABLE, }, /* Reserved for kernel image */ { .name = "Kernel", .offset = MTDPART_OFS_NXTBLK, .size = <API key>, }, /* Rest is used for Flash FS */ { .name = "Flash_FS", .offset = MTDPART_OFS_NXTBLK, .size = MTDPART_SIZ_FULL, } }; static struct physmap_flash_data flash_data = { .parts = mpr2_partitions, .nr_parts = ARRAY_SIZE(mpr2_partitions), .width = 2, }; static struct resource flash_resource = { .start = 0x00000000, .end = 0x2000000UL, .flags = IORESOURCE_MEM, }; static struct platform_device flash_device = { .name = "physmap-flash", .id = -1, .resource = &flash_resource, .num_resources = 1, .dev = { .platform_data = &flash_data, }, }; /* * Add all resources to the platform_device */ static struct platform_device *mpr2_devices[] __initdata = { &heartbeat_device, &smsc911x_device, &flash_device, }; static int __init mpr2_devices_setup(void) { return <API key>(mpr2_devices, ARRAY_SIZE(mpr2_devices)); } device_initcall(mpr2_devices_setup); /* * Initialize IRQ setting */ static void __init init_mpr2_IRQ(void) { plat_irq_setup_pins(IRQ_MODE_IRQ); /* install handlers for IRQ0-5 */ irq_set_irq_type(32, IRQ_TYPE_LEVEL_LOW); /* IRQ0 CAN1 */ irq_set_irq_type(33, IRQ_TYPE_LEVEL_LOW); /* IRQ1 CAN2 */ irq_set_irq_type(34, IRQ_TYPE_LEVEL_LOW); /* IRQ2 CAN3 */ irq_set_irq_type(35, IRQ_TYPE_LEVEL_LOW); /* IRQ3 SMSC9115 */ irq_set_irq_type(36, <API key>); /* IRQ4 touchscreen */ irq_set_irq_type(37, <API key>); /* IRQ5 touchscreen */ intc_set_priority(32, 13); /* IRQ0 CAN1 */ intc_set_priority(33, 13); /* IRQ0 CAN2 */ intc_set_priority(34, 13); /* IRQ0 CAN3 */ intc_set_priority(35, 6); /* IRQ3 SMSC9115 */ } /* * The Machine Vector */ static struct sh_machine_vector mv_mpr2 __initmv = { .mv_name = "mpr2", .mv_setup = mpr2_setup, .mv_init_irq = init_mpr2_IRQ, };
import { Duration, isDuration } from './constructor'; import toInt from '../utils/to-int'; import hasOwnProp from '../utils/has-own-prop'; import { DATE, HOUR, MINUTE, SECOND, MILLISECOND } from '../units/constants'; import { cloneWithOffset } from '../units/offset'; import { createLocal } from '../create/local'; // ASP.NET json date format regex var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/; // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere // and further modified to allow for strings containing both week and day var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/; export function createDuration (input, key) { var duration = input, // matching against regexp is expensive, do it on demand match = null, sign, ret, diffRes; if (isDuration(input)) { duration = { ms : input._milliseconds, d : input._days, M : input._months }; } else if (typeof input === 'number') { duration = {}; if (key) { duration[key] = input; } else { duration.milliseconds = input; } } else if (!!(match = aspNetRegex.exec(input))) { sign = (match[1] === '-') ? -1 : 1; duration = { y : 0, d : toInt(match[DATE]) * sign, h : toInt(match[HOUR]) * sign, m : toInt(match[MINUTE]) * sign, s : toInt(match[SECOND]) * sign, ms : toInt(match[MILLISECOND]) * sign }; } else if (!!(match = isoRegex.exec(input))) { sign = (match[1] === '-') ? -1 : 1; duration = { y : parseIso(match[2], sign), M : parseIso(match[3], sign), w : parseIso(match[4], sign), d : parseIso(match[5], sign), h : parseIso(match[6], sign), m : parseIso(match[7], sign), s : parseIso(match[8], sign) }; } else if (duration == null) {// checks for null or undefined duration = {}; } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to)); duration = {}; duration.ms = diffRes.milliseconds; duration.M = diffRes.months; } ret = new Duration(duration); if (isDuration(input) && hasOwnProp(input, '_locale')) { ret._locale = input._locale; } return ret; } createDuration.fn = Duration.prototype; function parseIso (inp, sign) { // We'd normally use ~~inp for this, but unfortunately it also // converts floats to ints. // inp may be undefined, so careful calling replace on it. var res = inp && parseFloat(inp.replace(',', '.')); // apply sign while we're at it return (isNaN(res) ? 0 : res) * sign; } function <API key>(base, other) { var res = {milliseconds: 0, months: 0}; res.months = other.month() - base.month() + (other.year() - base.year()) * 12; if (base.clone().add(res.months, 'M').isAfter(other)) { --res.months; } res.milliseconds = +other - +(base.clone().add(res.months, 'M')); return res; } function momentsDifference(base, other) { var res; if (!(base.isValid() && other.isValid())) { return {milliseconds: 0, months: 0}; } other = cloneWithOffset(other, base); if (base.isBefore(other)) { res = <API key>(base, other); } else { res = <API key>(other, base); res.milliseconds = -res.milliseconds; res.months = -res.months; } return res; }
// { dg-do assemble } template <class T> void foo(); // { dg-message "" } candidate void (*bar)() = foo<void>; void (*baz)() = foo; // { dg-error "" } can't deduce T
<?php namespace Illuminate\Validation; use Exception; class ValidationException extends Exception { /** * The validator instance. * * @var \Illuminate\Validation\Validator */ public $validator; /** * The recommended response to send to the client. * * @var \Illuminate\Http\Response|null */ public $response; /** * Create a new exception instance. * * @param \Illuminate\Validation\Validator $validator * @param \Illuminate\Http\Response $response * @return void */ public function __construct($validator, $response = null) { parent::__construct('The given data failed to pass validation.'); $this->response = $response; $this->validator = $validator; } /** * Get the underlying response instance. * * @return \Symfony\Component\HttpFoundation\Response */ public function getResponse() { return $this->response; } }
DELETE FROM `<API key>` WHERE `criteria_id` IN (6343, 6344, 6345, 6346, 6347); INSERT INTO `<API key>` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES (6343,6,4197,0,''), -- Wintergrasp (6343,1,16111,0,''), -- target Love Fool (6344,6,2177,0,''), -- Battle Ring (6344,1,16111,0,''), -- target Love Fool (6345,6,3421,0,''), -- Blacksmith (6345,1,16111,0,''), -- target Love Fool (6346,6,4100,0,''), -- The Culling of Stratholme (6346,1,16111,0,''), -- target Love Fool (6347,6,3456,0,''), -- Naxxramas (6347,1,16111,0,''); -- target Love Fool
#include <linux/init.h> #include <linux/export.h> #include <linux/timer.h> #include <linux/slab.h> #include <asm/facility.h> #include <asm/sysinfo.h> #include <asm/ebcdic.h> #include <asm/debug.h> #include <asm/ipl.h> #define <API key> (30 * 60) #define VM_LEVEL_MAX 2 /* Maximum is 8, but we only record two levels */ /* * LGR info: Contains stfle and stsi data */ struct lgr_info { /* Bit field with facility information: 4 DWORDs are stored */ u64 stfle_fac_list[4]; /* Level of system (1 = CEC, 2 = LPAR, 3 = z/VM */ u32 level; /* Level 1: CEC info (stsi 1.1.1) */ char manufacturer[16]; char type[4]; char sequence[16]; char plant[4]; char model[16]; /* Level 2: LPAR info (stsi 2.2.2) */ u16 lpar_number; char name[8]; /* Level 3: VM info (stsi 3.2.2) */ u8 vm_count; struct { char name[8]; char cpi[16]; } vm[VM_LEVEL_MAX]; } __packed __aligned(8); /* * LGR globals */ static char lgr_page[PAGE_SIZE] __aligned(PAGE_SIZE); static struct lgr_info lgr_info_last; static struct lgr_info lgr_info_cur; static struct debug_info *lgr_dbf; /* * Copy buffer and then convert it to ASCII */ static void cpascii(char *dst, char *src, int size) { memcpy(dst, src, size); EBCASC(dst, size); } /* * Fill LGR info with 1.1.1 stsi data */ static void lgr_stsi_1_1_1(struct lgr_info *lgr_info) { struct sysinfo_1_1_1 *si = (void *) lgr_page; if (stsi(si, 1, 1, 1)) return; cpascii(lgr_info->manufacturer, si->manufacturer, sizeof(si->manufacturer)); cpascii(lgr_info->type, si->type, sizeof(si->type)); cpascii(lgr_info->model, si->model, sizeof(si->model)); cpascii(lgr_info->sequence, si->sequence, sizeof(si->sequence)); cpascii(lgr_info->plant, si->plant, sizeof(si->plant)); } /* * Fill LGR info with 2.2.2 stsi data */ static void lgr_stsi_2_2_2(struct lgr_info *lgr_info) { struct sysinfo_2_2_2 *si = (void *) lgr_page; if (stsi(si, 2, 2, 2)) return; cpascii(lgr_info->name, si->name, sizeof(si->name)); memcpy(&lgr_info->lpar_number, &si->lpar_number, sizeof(lgr_info->lpar_number)); } /* * Fill LGR info with 3.2.2 stsi data */ static void lgr_stsi_3_2_2(struct lgr_info *lgr_info) { struct sysinfo_3_2_2 *si = (void *) lgr_page; int i; if (stsi(si, 3, 2, 2)) return; for (i = 0; i < min_t(u8, si->count, VM_LEVEL_MAX); i++) { cpascii(lgr_info->vm[i].name, si->vm[i].name, sizeof(si->vm[i].name)); cpascii(lgr_info->vm[i].cpi, si->vm[i].cpi, sizeof(si->vm[i].cpi)); } lgr_info->vm_count = si->count; } /* * Fill LGR info with current data */ static void lgr_info_get(struct lgr_info *lgr_info) { int level; memset(lgr_info, 0, sizeof(*lgr_info)); stfle(lgr_info->stfle_fac_list, ARRAY_SIZE(lgr_info->stfle_fac_list)); level = stsi(NULL, 0, 0, 0); lgr_info->level = level; if (level >= 1) lgr_stsi_1_1_1(lgr_info); if (level >= 2) lgr_stsi_2_2_2(lgr_info); if (level >= 3) lgr_stsi_3_2_2(lgr_info); } /* * Check if LGR info has changed and if yes log new LGR info to s390dbf */ void lgr_info_log(void) { static DEFINE_SPINLOCK(lgr_info_lock); unsigned long flags; if (!<API key>(&lgr_info_lock, flags)) return; lgr_info_get(&lgr_info_cur); if (memcmp(&lgr_info_last, &lgr_info_cur, sizeof(lgr_info_cur)) != 0) { debug_event(lgr_dbf, 1, &lgr_info_cur, sizeof(lgr_info_cur)); lgr_info_last = lgr_info_cur; } <API key>(&lgr_info_lock, flags); } EXPORT_SYMBOL_GPL(lgr_info_log); static void lgr_timer_set(void); /* * LGR timer callback */ static void lgr_timer_fn(unsigned long ignored) { lgr_info_log(); lgr_timer_set(); } static struct timer_list lgr_timer = <API key>(lgr_timer_fn, 0, 0); /* * Setup next LGR timer */ static void lgr_timer_set(void) { mod_timer(&lgr_timer, jiffies + <API key> * HZ); } /* * Initialize LGR: Add s390dbf, write initial lgr_info and setup timer */ static int __init lgr_init(void) { lgr_dbf = debug_register("lgr", 1, 1, sizeof(struct lgr_info)); if (!lgr_dbf) return -ENOMEM; debug_register_view(lgr_dbf, &<API key>); lgr_info_get(&lgr_info_last); debug_event(lgr_dbf, 1, &lgr_info_last, sizeof(lgr_info_last)); lgr_timer_set(); return 0; } device_initcall(lgr_init);
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef <API key> #define <API key> #pragma interface #include <gnu/xml/validation/relaxng/Pattern.h> extern "Java" { namespace gnu { namespace xml { namespace validation { namespace relaxng { class InterleavePattern; class Pattern; } } } } } class gnu::xml::validation::relaxng::InterleavePattern : public ::gnu::xml::validation::relaxng::Pattern { public: // actually package-private InterleavePattern(); ::gnu::xml::validation::relaxng::Pattern * __attribute__((aligned(__alignof__( ::gnu::xml::validation::relaxng::Pattern)))) pattern1; ::gnu::xml::validation::relaxng::Pattern * pattern2; public: static ::java::lang::Class class$; }; #endif // <API key>
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef <API key>$<API key> #define <API key>$<API key> #pragma interface #include <javax/swing/border/AbstractBorder.h> extern "Java" { namespace java { namespace awt { class Component; class Insets; } } namespace javax { namespace swing { namespace plaf { namespace metal { class MetalBorders$<API key>; } } } } } class javax::swing::plaf::metal::MetalBorders$<API key> : public ::javax::swing::border::AbstractBorder { public: MetalBorders$<API key>(); virtual ::java::awt::Insets * getBorderInsets(::java::awt::Component *); virtual ::java::awt::Insets * getBorderInsets(::java::awt::Component *, ::java::awt::Insets *); public: // actually protected static ::java::awt::Insets * borderInsets; public: static ::java::lang::Class class$; }; #endif // <API key>$<API key>
#include <linux/export.h> #include <linux/uts.h> #include <linux/utsname.h> #include <linux/err.h> #include <linux/slab.h> #include <linux/cred.h> #include <linux/user_namespace.h> #include <linux/proc_ns.h> #include <linux/sched/task.h> static struct ucounts *inc_uts_namespaces(struct user_namespace *ns) { return inc_ucount(ns, current_euid(), <API key>); } static void dec_uts_namespaces(struct ucounts *ucounts) { dec_ucount(ucounts, <API key>); } static struct uts_namespace *create_uts_ns(void) { struct uts_namespace *uts_ns; uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL); if (uts_ns) kref_init(&uts_ns->kref); return uts_ns; } /* * Clone a new ns copying an original utsname, setting refcount to 1 * @old_ns: namespace to clone * Return ERR_PTR(-ENOMEM) on error (failure to kmalloc), new ns otherwise */ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, struct uts_namespace *old_ns) { struct uts_namespace *ns; struct ucounts *ucounts; int err; err = -ENOSPC; ucounts = inc_uts_namespaces(user_ns); if (!ucounts) goto fail; err = -ENOMEM; ns = create_uts_ns(); if (!ns) goto fail_dec; err = ns_alloc_inum(&ns->ns); if (err) goto fail_free; ns->ucounts = ucounts; ns->ns.ops = &utsns_operations; down_read(&uts_sem); memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); ns->user_ns = get_user_ns(user_ns); up_read(&uts_sem); return ns; fail_free: kfree(ns); fail_dec: dec_uts_namespaces(ucounts); fail: return ERR_PTR(err); } /* * Copy task tsk's utsname namespace, or clone it if flags * specifies CLONE_NEWUTS. In latter case, changes to the * utsname of this process won't be seen by parent, and vice * versa. */ struct uts_namespace *copy_utsname(unsigned long flags, struct user_namespace *user_ns, struct uts_namespace *old_ns) { struct uts_namespace *new_ns; BUG_ON(!old_ns); get_uts_ns(old_ns); if (!(flags & CLONE_NEWUTS)) return old_ns; new_ns = clone_uts_ns(user_ns, old_ns); put_uts_ns(old_ns); return new_ns; } void free_uts_ns(struct kref *kref) { struct uts_namespace *ns; ns = container_of(kref, struct uts_namespace, kref); dec_uts_namespaces(ns->ucounts); put_user_ns(ns->user_ns); ns_free_inum(&ns->ns); kfree(ns); } static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) { return container_of(ns, struct uts_namespace, ns); } static struct ns_common *utsns_get(struct task_struct *task) { struct uts_namespace *ns = NULL; struct nsproxy *nsproxy; task_lock(task); nsproxy = task->nsproxy; if (nsproxy) { ns = nsproxy->uts_ns; get_uts_ns(ns); } task_unlock(task); return ns ? &ns->ns : NULL; } static void utsns_put(struct ns_common *ns) { put_uts_ns(to_uts_ns(ns)); } static int utsns_install(struct nsproxy *nsproxy, struct ns_common *new) { struct uts_namespace *ns = to_uts_ns(new); if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) return -EPERM; get_uts_ns(ns); put_uts_ns(nsproxy->uts_ns); nsproxy->uts_ns = ns; return 0; } static struct user_namespace *utsns_owner(struct ns_common *ns) { return to_uts_ns(ns)->user_ns; } const struct proc_ns_operations utsns_operations = { .name = "uts", .type = CLONE_NEWUTS, .get = utsns_get, .put = utsns_put, .install = utsns_install, .owner = utsns_owner, };
/* jshint -W100 */ /* jslint maxlen: 86 */ define(function () { // Farsi (Persian) return { errorLoading: function () { return 'امکان بارگذاری نتایج وجود ندارد.'; }, inputTooLong: function (args) { var overChars = args.input.length - args.maximum; var message = 'لطفاً ' + overChars + ' کاراکتر را حذف نمایید'; return message; }, inputTooShort: function (args) { var remainingChars = args.minimum - args.input.length; var message = 'لطفاً تعداد ' + remainingChars + ' کاراکتر یا بیشتر وارد نمایید'; return message; }, loadingMore: function () { return 'در حال بارگذاری نتایج بیشتر...'; }, maximumSelected: function (args) { var message = 'شما تنها می‌توانید ' + args.maximum + ' آیتم را انتخاب نمایید'; return message; }, noResults: function () { return 'هیچ نتیجه‌ای یافت نشد'; }, searching: function () { return 'در حال جستجو...'; } }; });
#include <linux/types.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/delay.h> #include <linux/ide.h> #include <linux/init.h> #define <API key> 0x01b4 #define SCC_PATA_NAME "scc IDE" #define TDVHSEL_MASTER 0x00000001 #define TDVHSEL_SLAVE 0x00000004 #define MODE_JCUSFEN 0x00000080 #define CCKCTRL_ATARESET 0x00040000 #define CCKCTRL_BUFCNT 0x00020000 #define CCKCTRL_CRST 0x00010000 #define CCKCTRL_OCLKEN 0x00000100 #define CCKCTRL_ATACLKOEN 0x00000002 #define CCKCTRL_LCLKEN 0x00000001 #define QCHCD_IOS_SS 0x00000001 #define QCHSD_STPDIAG 0x00020000 #define INTMASK_MSK 0xD1000012 #define INTSTS_SERROR 0x80000000 #define INTSTS_PRERR 0x40000000 #define INTSTS_RERR 0x10000000 #define INTSTS_ICERR 0x01000000 #define INTSTS_BMSINT 0x00000010 #define INTSTS_BMHE 0x00000008 #define INTSTS_IOIRQS 0x00000004 #define INTSTS_INTRQ 0x00000002 #define INTSTS_ACTEINT 0x00000001 #define ECMODE_VALUE 0x01 static struct scc_ports { unsigned long ctl, dma; struct ide_host *host; /* for removing port from system */ } scc_ports[MAX_HWIFS]; /* PIO transfer mode table */ /* JCHST */ static unsigned long JCHSTtbl[2][7] = { {0x0E, 0x05, 0x02, 0x03, 0x02, 0x00, 0x00}, /* 100MHz */ {0x13, 0x07, 0x04, 0x04, 0x03, 0x00, 0x00} /* 133MHz */ }; /* JCHHT */ static unsigned long JCHHTtbl[2][7] = { {0x0E, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00}, /* 100MHz */ {0x13, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00} /* 133MHz */ }; /* JCHCT */ static unsigned long JCHCTtbl[2][7] = { {0x1D, 0x1D, 0x1C, 0x0B, 0x06, 0x00, 0x00}, /* 100MHz */ {0x27, 0x26, 0x26, 0x0E, 0x09, 0x00, 0x00} /* 133MHz */ }; /* DMA transfer mode table */ /* JCHDCTM/JCHDCTS */ static unsigned long JCHDCTxtbl[2][7] = { {0x0A, 0x06, 0x04, 0x03, 0x01, 0x00, 0x00}, /* 100MHz */ {0x0E, 0x09, 0x06, 0x04, 0x02, 0x01, 0x00} /* 133MHz */ }; /* JCSTWTM/JCSTWTS */ static unsigned long JCSTWTxtbl[2][7] = { {0x06, 0x04, 0x03, 0x02, 0x02, 0x02, 0x00}, /* 100MHz */ {0x09, 0x06, 0x04, 0x02, 0x02, 0x02, 0x02} /* 133MHz */ }; /* JCTSS */ static unsigned long JCTSStbl[2][7] = { {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00}, /* 100MHz */ {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05} /* 133MHz */ }; /* JCENVT */ static unsigned long JCENVTtbl[2][7] = { {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}, /* 100MHz */ {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02} /* 133MHz */ }; /* JCACTSELS/JCACTSELM */ static unsigned long JCACTSELtbl[2][7] = { {0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00}, /* 100MHz */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} /* 133MHz */ }; static u8 scc_ide_inb(unsigned long port) { u32 data = in_be32((void*)port); return (u8)data; } static void scc_exec_command(ide_hwif_t *hwif, u8 cmd) { out_be32((void *)hwif->io_ports.command_addr, cmd); eieio(); in_be32((void *)(hwif->dma_base + 0x01c)); eieio(); } static u8 scc_read_status(ide_hwif_t *hwif) { return (u8)in_be32((void *)hwif->io_ports.status_addr); } static u8 scc_read_altstatus(ide_hwif_t *hwif) { return (u8)in_be32((void *)hwif->io_ports.ctl_addr); } static u8 <API key>(ide_hwif_t *hwif) { return (u8)in_be32((void *)(hwif->dma_base + 4)); } static void scc_write_devctl(ide_hwif_t *hwif, u8 ctl) { out_be32((void *)hwif->io_ports.ctl_addr, ctl); eieio(); in_be32((void *)(hwif->dma_base + 0x01c)); eieio(); } static void scc_ide_insw(unsigned long port, void *addr, u32 count) { u16 *ptr = (u16 *)addr; while (count *ptr++ = le16_to_cpu(in_be32((void*)port)); } } static void scc_ide_insl(unsigned long port, void *addr, u32 count) { u16 *ptr = (u16 *)addr; while (count *ptr++ = le16_to_cpu(in_be32((void*)port)); *ptr++ = le16_to_cpu(in_be32((void*)port)); } } static void scc_ide_outb(u8 addr, unsigned long port) { out_be32((void*)port, addr); } static void scc_ide_outsw(unsigned long port, void *addr, u32 count) { u16 *ptr = (u16 *)addr; while (count out_be32((void*)port, cpu_to_le16(*ptr++)); } } static void scc_ide_outsl(unsigned long port, void *addr, u32 count) { u16 *ptr = (u16 *)addr; while (count out_be32((void*)port, cpu_to_le16(*ptr++)); out_be32((void*)port, cpu_to_le16(*ptr++)); } } /** * scc_set_pio_mode - set host controller for PIO mode * @hwif: port * @drive: drive * * Load the timing settings for this device mode into the * controller. */ static void scc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) { struct scc_ports *ports = ide_get_hwifdata(hwif); unsigned long ctl_base = ports->ctl; unsigned long cckctrl_port = ctl_base + 0xff0; unsigned long piosht_port = ctl_base + 0x000; unsigned long pioct_port = ctl_base + 0x004; unsigned long reg; int offset; const u8 pio = drive->pio_mode - XFER_PIO_0; reg = in_be32((void __iomem *)cckctrl_port); if (reg & CCKCTRL_ATACLKOEN) { offset = 1; /* 133MHz */ } else { offset = 0; /* 100MHz */ } reg = JCHSTtbl[offset][pio] << 16 | JCHHTtbl[offset][pio]; out_be32((void __iomem *)piosht_port, reg); reg = JCHCTtbl[offset][pio]; out_be32((void __iomem *)pioct_port, reg); } /** * scc_set_dma_mode - set host controller for DMA mode * @hwif: port * @drive: drive * * Load the timing settings for this device mode into the * controller. */ static void scc_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) { struct scc_ports *ports = ide_get_hwifdata(hwif); unsigned long ctl_base = ports->ctl; unsigned long cckctrl_port = ctl_base + 0xff0; unsigned long mdmact_port = ctl_base + 0x008; unsigned long mcrcst_port = ctl_base + 0x00c; unsigned long sdmact_port = ctl_base + 0x010; unsigned long scrcst_port = ctl_base + 0x014; unsigned long udenvt_port = ctl_base + 0x018; unsigned long tdvhsel_port = ctl_base + 0x020; int is_slave = drive->dn & 1; int offset, idx; unsigned long reg; unsigned long jcactsel; const u8 speed = drive->dma_mode; reg = in_be32((void __iomem *)cckctrl_port); if (reg & CCKCTRL_ATACLKOEN) { offset = 1; /* 133MHz */ } else { offset = 0; /* 100MHz */ } idx = speed - XFER_UDMA_0; jcactsel = JCACTSELtbl[offset][idx]; if (is_slave) { out_be32((void __iomem *)sdmact_port, JCHDCTxtbl[offset][idx]); out_be32((void __iomem *)scrcst_port, JCSTWTxtbl[offset][idx]); jcactsel = jcactsel << 2; out_be32((void __iomem *)tdvhsel_port, (in_be32((void __iomem *)tdvhsel_port) & ~TDVHSEL_SLAVE) | jcactsel); } else { out_be32((void __iomem *)mdmact_port, JCHDCTxtbl[offset][idx]); out_be32((void __iomem *)mcrcst_port, JCSTWTxtbl[offset][idx]); out_be32((void __iomem *)tdvhsel_port, (in_be32((void __iomem *)tdvhsel_port) & ~TDVHSEL_MASTER) | jcactsel); } reg = JCTSStbl[offset][idx] << 16 | JCENVTtbl[offset][idx]; out_be32((void __iomem *)udenvt_port, reg); } static void scc_dma_host_set(ide_drive_t *drive, int on) { ide_hwif_t *hwif = drive->hwif; u8 unit = drive->dn & 1; u8 dma_stat = <API key>(hwif); if (on) dma_stat |= (1 << (5 + unit)); else dma_stat &= ~(1 << (5 + unit)); scc_ide_outb(dma_stat, hwif->dma_base + 4); } /** * scc_dma_setup - begin a DMA phase * @drive: target device * @cmd: command * * Build an IDE DMA PRD (IDE speak for scatter gather table) * and then set up the DMA transfer registers. * * Returns 0 on success. If a PIO fallback is required then 1 * is returned. */ static int scc_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) { ide_hwif_t *hwif = drive->hwif; u32 rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 0 : ATA_DMA_WR; u8 dma_stat; /* fall back to pio! */ if (ide_build_dmatable(drive, cmd) == 0) return 1; /* PRD table */ out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma); /* specify r/w */ out_be32((void __iomem *)hwif->dma_base, rw); /* read DMA status for INTR & ERROR flags */ dma_stat = <API key>(hwif); /* clear INTR & ERROR flags */ out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); return 0; } static void scc_dma_start(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; u8 dma_cmd = scc_ide_inb(hwif->dma_base); /* start DMA */ scc_ide_outb(dma_cmd | 1, hwif->dma_base); } static int __scc_dma_end(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; u8 dma_stat, dma_cmd; /* get DMA command mode */ dma_cmd = scc_ide_inb(hwif->dma_base); /* stop DMA */ scc_ide_outb(dma_cmd & ~1, hwif->dma_base); /* get DMA status */ dma_stat = <API key>(hwif); /* clear the INTR & ERROR bits */ scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); /* verify good DMA status */ return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; } /** * scc_dma_end - Stop DMA * @drive: IDE drive * * Check and clear INT Status register. * Then call __scc_dma_end(). */ static int scc_dma_end(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; void __iomem *dma_base = (void __iomem *)hwif->dma_base; unsigned long intsts_port = hwif->dma_base + 0x014; u32 reg; int dma_stat, data_loss = 0; static int retry = 0; /* errata A308 workaround: Step5 (check data loss) */ /* We don't check non ide_disk because it is limited to UDMA4 */ if (!(in_be32((void __iomem *)hwif->io_ports.ctl_addr) & ATA_ERR) && drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { reg = in_be32((void __iomem *)intsts_port); if (!(reg & INTSTS_ACTEINT)) { printk(KERN_WARNING "%s: operation failed (transfer data loss)\n", drive->name); data_loss = 1; if (retry++) { struct request *rq = hwif->rq; ide_drive_t *drive; int i; /* ERROR_RESET and drive->crc_count are needed * to reduce DMA transfer mode in retry process. */ if (rq) rq->errors |= ERROR_RESET; <API key>(i, drive, hwif) drive->crc_count++; } } } while (1) { reg = in_be32((void __iomem *)intsts_port); if (reg & INTSTS_SERROR) { printk(KERN_WARNING "%s: SERROR\n", SCC_PATA_NAME); out_be32((void __iomem *)intsts_port, INTSTS_SERROR|INTSTS_BMSINT); out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); continue; } if (reg & INTSTS_PRERR) { u32 maea0, maec0; unsigned long ctl_base = hwif->config_data; maea0 = in_be32((void __iomem *)(ctl_base + 0xF50)); maec0 = in_be32((void __iomem *)(ctl_base + 0xF54)); printk(KERN_WARNING "%s: PRERR [addr:%x cmd:%x]\n", SCC_PATA_NAME, maea0, maec0); out_be32((void __iomem *)intsts_port, INTSTS_PRERR|INTSTS_BMSINT); out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); continue; } if (reg & INTSTS_RERR) { printk(KERN_WARNING "%s: Response Error\n", SCC_PATA_NAME); out_be32((void __iomem *)intsts_port, INTSTS_RERR|INTSTS_BMSINT); out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); continue; } if (reg & INTSTS_ICERR) { out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); printk(KERN_WARNING "%s: Illegal Configuration\n", SCC_PATA_NAME); out_be32((void __iomem *)intsts_port, INTSTS_ICERR|INTSTS_BMSINT); continue; } if (reg & INTSTS_BMSINT) { printk(KERN_WARNING "%s: Internal Bus Error\n", SCC_PATA_NAME); out_be32((void __iomem *)intsts_port, INTSTS_BMSINT); ide_do_reset(drive); continue; } if (reg & INTSTS_BMHE) { out_be32((void __iomem *)intsts_port, INTSTS_BMHE); continue; } if (reg & INTSTS_ACTEINT) { out_be32((void __iomem *)intsts_port, INTSTS_ACTEINT); continue; } if (reg & INTSTS_IOIRQS) { out_be32((void __iomem *)intsts_port, INTSTS_IOIRQS); continue; } break; } dma_stat = __scc_dma_end(drive); if (data_loss) dma_stat |= 2; /* emulate DMA error (to retry command) */ return dma_stat; } /* returns 1 if dma irq issued, 0 otherwise */ static int scc_dma_test_irq(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); /* SCC errata A252,A308 workaround: Step4 */ if ((in_be32((void __iomem *)hwif->io_ports.ctl_addr) & ATA_ERR) && (int_stat & INTSTS_INTRQ)) return 1; /* SCC errata A308 workaround: Step5 (polling IOIRQS) */ if (int_stat & INTSTS_IOIRQS) return 1; return 0; } static u8 scc_udma_filter(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; u8 mask = hwif->ultra_mask; /* errata A308 workaround: limit non ide_disk drive to UDMA4 */ if ((drive->media != ide_disk) && (mask & 0xE0)) { printk(KERN_INFO "%s: limit %s to UDMA4\n", SCC_PATA_NAME, drive->name); mask = ATA_UDMA4; } return mask; } /** * setup_mmio_scc - map CTRL/BMID region * @dev: PCI device we are configuring * @name: device name * */ static int setup_mmio_scc (struct pci_dev *dev, const char *name) { void __iomem *ctl_addr; void __iomem *dma_addr; int i, ret; for (i = 0; i < MAX_HWIFS; i++) { if (scc_ports[i].ctl == 0) break; } if (i >= MAX_HWIFS) return -ENOMEM; ret = <API key>(dev, (1 << 2) - 1, name); if (ret < 0) { printk(KERN_ERR "%s: can't reserve resources\n", name); return ret; } ctl_addr = pci_ioremap_bar(dev, 0); if (!ctl_addr) goto fail_0; dma_addr = pci_ioremap_bar(dev, 1); if (!dma_addr) goto fail_1; pci_set_master(dev); scc_ports[i].ctl = (unsigned long)ctl_addr; scc_ports[i].dma = (unsigned long)dma_addr; pci_set_drvdata(dev, (void *) &scc_ports[i]); return 1; fail_1: iounmap(ctl_addr); fail_0: return -ENOMEM; } static int <API key>(struct pci_dev *dev, const struct ide_port_info *d) { struct scc_ports *ports = pci_get_drvdata(dev); struct ide_host *host; struct ide_hw hw, *hws[] = { &hw }; int i, rc; memset(&hw, 0, sizeof(hw)); for (i = 0; i <= 8; i++) hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; hw.irq = dev->irq; hw.dev = &dev->dev; rc = ide_host_add(d, hws, 1, &host); if (rc) return rc; ports->host = host; return 0; } /** * init_setup_scc - set up an SCC PATA Controller * @dev: PCI device * @d: IDE port info * * Perform the initial set up for this device. */ static int init_setup_scc(struct pci_dev *dev, const struct ide_port_info *d) { unsigned long ctl_base; unsigned long dma_base; unsigned long cckctrl_port; unsigned long intmask_port; unsigned long mode_port; unsigned long ecmode_port; u32 reg = 0; struct scc_ports *ports; int rc; rc = pci_enable_device(dev); if (rc) goto end; rc = setup_mmio_scc(dev, d->name); if (rc < 0) goto end; ports = pci_get_drvdata(dev); ctl_base = ports->ctl; dma_base = ports->dma; cckctrl_port = ctl_base + 0xff0; intmask_port = dma_base + 0x010; mode_port = ctl_base + 0x024; ecmode_port = ctl_base + 0xf00; /* controller initialization */ reg = 0; out_be32((void*)cckctrl_port, reg); reg |= CCKCTRL_ATACLKOEN; out_be32((void*)cckctrl_port, reg); reg |= CCKCTRL_LCLKEN | CCKCTRL_OCLKEN; out_be32((void*)cckctrl_port, reg); reg |= CCKCTRL_CRST; out_be32((void*)cckctrl_port, reg); for (;;) { reg = in_be32((void*)cckctrl_port); if (reg & CCKCTRL_CRST) break; udelay(5000); } reg |= CCKCTRL_ATARESET; out_be32((void*)cckctrl_port, reg); out_be32((void*)ecmode_port, ECMODE_VALUE); out_be32((void*)mode_port, MODE_JCUSFEN); out_be32((void*)intmask_port, INTMASK_MSK); rc = <API key>(dev, d); end: return rc; } static void scc_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; if (valid & IDE_VALID_FEATURE) scc_ide_outb(tf->feature, io_ports->feature_addr); if (valid & IDE_VALID_NSECT) scc_ide_outb(tf->nsect, io_ports->nsect_addr); if (valid & IDE_VALID_LBAL) scc_ide_outb(tf->lbal, io_ports->lbal_addr); if (valid & IDE_VALID_LBAM) scc_ide_outb(tf->lbam, io_ports->lbam_addr); if (valid & IDE_VALID_LBAH) scc_ide_outb(tf->lbah, io_ports->lbah_addr); if (valid & IDE_VALID_DEVICE) scc_ide_outb(tf->device, io_ports->device_addr); } static void scc_tf_read(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; if (valid & IDE_VALID_ERROR) tf->error = scc_ide_inb(io_ports->feature_addr); if (valid & IDE_VALID_NSECT) tf->nsect = scc_ide_inb(io_ports->nsect_addr); if (valid & IDE_VALID_LBAL) tf->lbal = scc_ide_inb(io_ports->lbal_addr); if (valid & IDE_VALID_LBAM) tf->lbam = scc_ide_inb(io_ports->lbam_addr); if (valid & IDE_VALID_LBAH) tf->lbah = scc_ide_inb(io_ports->lbah_addr); if (valid & IDE_VALID_DEVICE) tf->device = scc_ide_inb(io_ports->device_addr); } static void scc_input_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf, unsigned int len) { unsigned long data_addr = drive->hwif->io_ports.data_addr; len++; if (drive->io_32bit) { scc_ide_insl(data_addr, buf, len / 4); if ((len & 3) >= 2) scc_ide_insw(data_addr, (u8 *)buf + (len & ~3), 1); } else scc_ide_insw(data_addr, buf, len / 2); } static void scc_output_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf, unsigned int len) { unsigned long data_addr = drive->hwif->io_ports.data_addr; len++; if (drive->io_32bit) { scc_ide_outsl(data_addr, buf, len / 4); if ((len & 3) >= 2) scc_ide_outsw(data_addr, (u8 *)buf + (len & ~3), 1); } else scc_ide_outsw(data_addr, buf, len / 2); } /** * init_mmio_iops_scc - set up the iops for MMIO * @hwif: interface to set up * */ static void init_mmio_iops_scc(ide_hwif_t *hwif) { struct pci_dev *dev = to_pci_dev(hwif->dev); struct scc_ports *ports = pci_get_drvdata(dev); unsigned long dma_base = ports->dma; ide_set_hwifdata(hwif, ports); hwif->dma_base = dma_base; hwif->config_data = ports->ctl; } /** * init_iops_scc - set up iops * @hwif: interface to set up * * Do the basic setup for the SCC hardware interface * and then do the MMIO setup. */ static void init_iops_scc(ide_hwif_t *hwif) { struct pci_dev *dev = to_pci_dev(hwif->dev); hwif->hwif_data = NULL; if (pci_get_drvdata(dev) == NULL) return; init_mmio_iops_scc(hwif); } static int scc_init_dma(ide_hwif_t *hwif, const struct ide_port_info *d) { return <API key>(hwif); } static u8 scc_cable_detect(ide_hwif_t *hwif) { return ATA_CBL_PATA80; } /** * init_hwif_scc - set up hwif * @hwif: interface to set up * * We do the basic set up of the interface structure. The SCC * requires several custom handlers so we override the default * ide DMA handlers appropriately. */ static void init_hwif_scc(ide_hwif_t *hwif) { /* PTERADD */ out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ else hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ } static const struct ide_tp_ops scc_tp_ops = { .exec_command = scc_exec_command, .read_status = scc_read_status, .read_altstatus = scc_read_altstatus, .write_devctl = scc_write_devctl, .dev_select = ide_dev_select, .tf_load = scc_tf_load, .tf_read = scc_tf_read, .input_data = scc_input_data, .output_data = scc_output_data, }; static const struct ide_port_ops scc_port_ops = { .set_pio_mode = scc_set_pio_mode, .set_dma_mode = scc_set_dma_mode, .udma_filter = scc_udma_filter, .cable_detect = scc_cable_detect, }; static const struct ide_dma_ops scc_dma_ops = { .dma_host_set = scc_dma_host_set, .dma_setup = scc_dma_setup, .dma_start = scc_dma_start, .dma_end = scc_dma_end, .dma_test_irq = scc_dma_test_irq, .dma_lost_irq = ide_dma_lost_irq, .dma_timer_expiry = <API key>, .dma_sff_read_status = <API key>, }; static const struct ide_port_info scc_chipset = { .name = "sccIDE", .init_iops = init_iops_scc, .init_dma = scc_init_dma, .init_hwif = init_hwif_scc, .tp_ops = &scc_tp_ops, .port_ops = &scc_port_ops, .dma_ops = &scc_dma_ops, .host_flags = IDE_HFLAG_SINGLE, .irq_flags = IRQF_SHARED, .pio_mask = ATA_PIO4, .chipset = ide_pci, }; /** * scc_init_one - pci layer discovery entry * @dev: PCI device * @id: ident table entry * * Called by the PCI code when it finds an SCC PATA controller. * We then use the IDE PCI generic helper to do most of the work. */ static int scc_init_one(struct pci_dev *dev, const struct pci_device_id *id) { return init_setup_scc(dev, &scc_chipset); } /** * scc_remove - pci layer remove entry * @dev: PCI device * * Called by the PCI code when it removes an SCC PATA controller. */ static void scc_remove(struct pci_dev *dev) { struct scc_ports *ports = pci_get_drvdata(dev); struct ide_host *host = ports->host; ide_host_remove(host); iounmap((void*)ports->dma); iounmap((void*)ports->ctl); <API key>(dev, (1 << 2) - 1); memset(ports, 0, sizeof(*ports)); } static const struct pci_device_id scc_pci_tbl[] = { { PCI_VDEVICE(TOSHIBA_2, <API key>), 0 }, { 0, }, }; MODULE_DEVICE_TABLE(pci, scc_pci_tbl); static struct pci_driver scc_pci_driver = { .name = "SCC IDE", .id_table = scc_pci_tbl, .probe = scc_init_one, .remove = scc_remove, }; static int __init scc_ide_init(void) { return <API key>(&scc_pci_driver); } static void __exit scc_ide_exit(void) { <API key>(&scc_pci_driver); } module_init(scc_ide_init); module_exit(scc_ide_exit); MODULE_DESCRIPTION("PCI driver module for Toshiba SCC IDE"); MODULE_LICENSE("GPL");
#include "<API key>.h" #include "QueryParams.h" #include "music/MusicDatabase.h" using namespace XFILE::<API key>; <API key>::<API key>(const std::string& strName, CDirectoryNode* pParent) : CDirectoryNode(<API key>, strName, pParent) { } NODE_TYPE <API key>::GetChildType() const { if (GetName()=="-1") return <API key>; return NODE_TYPE_SONG; } std::string <API key>::GetLocalizedName() const { if (GetID() == -1) return g_localizeStrings.Get(15102); // All Albums CMusicDatabase db; if (db.Open()) return db.GetAlbumById(GetID()); return ""; } bool <API key>::GetContent(CFileItemList& items) const { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; CQueryParams params; CollectQueryParams(params); bool bSuccess=musicdatabase.<API key>(BuildPath(), items); musicdatabase.Close(); return bSuccess; }
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef <API key> #define <API key> #pragma interface #include <javax/swing/JToggleButton.h> extern "Java" { namespace javax { namespace accessibility { class AccessibleContext; } namespace swing { class Action; class Icon; class JRadioButton; } } } class javax::swing::JRadioButton : public ::javax::swing::JToggleButton { public: JRadioButton(); JRadioButton(::javax::swing::Action *); JRadioButton(::javax::swing::Icon *); JRadioButton(::javax::swing::Icon *, jboolean); JRadioButton(::java::lang::String *); JRadioButton(::java::lang::String *, jboolean); JRadioButton(::java::lang::String *, ::javax::swing::Icon *); JRadioButton(::java::lang::String *, ::javax::swing::Icon *, jboolean); virtual ::javax::accessibility::AccessibleContext * <API key>(); virtual ::java::lang::String * getUIClassID(); public: // actually protected virtual ::java::lang::String * paramString(); public: virtual void updateUI(); private: static const jlong serialVersionUID = <API key>; public: static ::java::lang::Class class$; }; #endif // <API key>
/* <API key>: MIT */ #ifndef __I915_SUSPEND_H__ #define __I915_SUSPEND_H__ struct drm_i915_private; int i915_save_state(struct drm_i915_private *i915); int i915_restore_state(struct drm_i915_private *i915); #endif /* __I915_SUSPEND_H__ */
#ifndef _HW_PAL_C_ #define _HW_PAL_C_ #ifndef <API key> #define <API key> STATIC_INLINE #endif #include "device_table.h" #include "cpu.h" #ifdef HAVE_STRING_H #include <string.h> #else #ifdef HAVE_STRINGS_H #include <strings.h> #endif #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif /* DEVICE pal - glue logic device containing assorted junk DESCRIPTION Typical hardware dependant hack. This device allows the firmware to gain access to all the things the firmware needs (but the OS doesn't). The pal contains the following registers. Except for the interrupt level register, each of the below is 8 bytes in size and must be accessed using correct alignment. For 16 and 32 bit accesses the bytes not directed to the register are ignored: |0 reset register (write) |4 processor id register (read) |8 interrupt port (write) |9 interrupt level (write) |12 processor count register (read) |16 tty input fifo register (read) |20 tty input status register (read) |24 tty output fifo register (write) |28 tty output status register (read) Reset register (write) halts the simulator exiting with the value written. Processor id register (read) returns the processor number (0 .. N-1) of the processor performing the read. The interrupt registers should be accessed as a pair (using a 16 or 32 bit store). The low byte specifies the interrupt port while the high byte specifies the level to drive that port at. By convention, the pal's interrupt ports (int0, int1, ...) are wired up to the corresponding processor's level sensative external interrupt pin. Eg: A two byte write to address 8 of 0x0102 (big-endian) will result in processor 2's external interrupt pin to be asserted. Processor count register (read) returns the total number of processors active in the current simulation. TTY input fifo register (read), if the TTY input status register indicates a character is available by being nonzero, returns the next available character from the pal's tty input port. Similarly, the TTY output fifo register (write), if the TTY output status register indicates the output fifo is not full by being nonzero, outputs the character written to the tty's output port. PROPERTIES reg = <address> <size> (required) Specify the address (within the parent bus) that this device is to live. */ enum { <API key> = 0x0, <API key> = 0x4, hw_pal_int_register = 0x8, <API key> = 0xa, hw_pal_read_fifo = 0x10, hw_pal_read_status = 0x14, hw_pal_write_fifo = 0x18, hw_pal_write_status = 0x1a, hw_pal_address_mask = 0x1f, }; typedef struct <API key> { char buffer; int status; } <API key>; typedef struct _hw_pal_device { <API key> input; <API key> output; device *disk; } hw_pal_device; /* check the console for an available character */ static void scan_hw_pal(hw_pal_device *hw_pal) { char c; int count; count = sim_io_read_stdin(&c, sizeof(c)); switch (count) { case sim_io_not_ready: case sim_io_eof: hw_pal->input.buffer = 0; hw_pal->input.status = 0; break; default: hw_pal->input.buffer = c; hw_pal->input.status = 1; } } /* write the character to the hw_pal */ static void write_hw_pal(hw_pal_device *hw_pal, char val) { sim_io_write_stdout(&val, 1); hw_pal->output.buffer = val; hw_pal->output.status = 1; } static unsigned <API key>(device *me, void *dest, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_pal_device *hw_pal = (hw_pal_device*)device_data(me); unsigned_1 val; switch (addr & hw_pal_address_mask) { case <API key>: val = cpu_nr(processor); DTRACE(pal, ("read - cpu-nr %d\n", val)); break; case <API key>: val = <API key>(me, "/openprom/options/smp"); DTRACE(pal, ("read - nr-cpu %d\n", val)); break; case hw_pal_read_fifo: val = hw_pal->input.buffer; DTRACE(pal, ("read - input-fifo %d\n", val)); break; case hw_pal_read_status: scan_hw_pal(hw_pal); val = hw_pal->input.status; DTRACE(pal, ("read - input-status %d\n", val)); break; case hw_pal_write_fifo: val = hw_pal->output.buffer; DTRACE(pal, ("read - output-fifo %d\n", val)); break; case hw_pal_write_status: val = hw_pal->output.status; DTRACE(pal, ("read - output-status %d\n", val)); break; default: val = 0; DTRACE(pal, ("read - ???\n")); } memset(dest, 0, nr_bytes); *(unsigned_1*)dest = val; return nr_bytes; } static unsigned <API key>(device *me, const void *source, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_pal_device *hw_pal = (hw_pal_device*)device_data(me); unsigned_1 *byte = (unsigned_1*)source; switch (addr & hw_pal_address_mask) { case <API key>: cpu_halt(processor, cia, was_exited, byte[0]); break; case hw_pal_int_register: <API key>(me, byte[0], /*port*/ (nr_bytes > 1 ? byte[1] : 0), /* val */ processor, cia); break; case hw_pal_read_fifo: hw_pal->input.buffer = byte[0]; DTRACE(pal, ("write - input-fifo %d\n", byte[0])); break; case hw_pal_read_status: hw_pal->input.status = byte[0]; DTRACE(pal, ("write - input-status %d\n", byte[0])); break; case hw_pal_write_fifo: write_hw_pal(hw_pal, byte[0]); DTRACE(pal, ("write - output-fifo %d\n", byte[0])); break; case hw_pal_write_status: hw_pal->output.status = byte[0]; DTRACE(pal, ("write - output-status %d\n", byte[0])); break; } return nr_bytes; } /* instances of the hw_pal device */ static void <API key>(device_instance *instance) { /* nothing to delete, the hw_pal is attached to the device */ return; } static int <API key>(device_instance *instance, void *buf, unsigned_word len) { DITRACE(pal, ("read - %s (%ld)", (const char*)buf, (long int)len)); return sim_io_read_stdin(buf, len); } static int <API key>(device_instance *instance, const void *buf, unsigned_word len) { int i; const char *chp = buf; hw_pal_device *hw_pal = <API key>(instance); DITRACE(pal, ("write - %s (%ld)", (const char*)buf, (long int)len)); for (i = 0; i < len; i++) write_hw_pal(hw_pal, chp[i]); <API key>(); return i; } static const <API key> <API key> = { <API key>, <API key>, <API key>, }; static device_instance * <API key>(device *me, const char *path, const char *args) { return <API key>(me, NULL, device_data(me), path, args, &<API key>); } static const <API key> <API key>[] = { { "int", 0, MAX_NR_PROCESSORS }, { NULL } }; static void <API key>(device *me, attach_type attach, int space, unsigned_word addr, unsigned nr_bytes, access_type access, device *client) { hw_pal_device *pal = (hw_pal_device*)device_data(me); pal->disk = client; } static device_callbacks const hw_pal_callbacks = { { <API key>, }, { <API key>, }, /* address */ { <API key>, <API key>, }, { NULL, }, /* DMA */ { NULL, NULL, <API key> }, /* interrupt */ { <API key>, <API key>, <API key>, <API key> }, <API key>, }; static void * hw_pal_create(const char *name, const device_unit *unit_address, const char *args) { /* create the descriptor */ hw_pal_device *hw_pal = ZALLOC(hw_pal_device); hw_pal->output.status = 1; hw_pal->output.buffer = '\0'; hw_pal->input.status = 0; hw_pal->input.buffer = '\0'; return hw_pal; } const device_descriptor <API key>[] = { { "pal", hw_pal_create, &hw_pal_callbacks }, { NULL }, }; #endif /* _HW_PAL_C_ */
using System; using System.Runtime.ExceptionServices; using System.Threading; namespace System.Threading.Tasks { internal static class <API key> { internal static void ThrowAsync(Exception exception, <API key> targetContext) { if (exception == null) return; // TODO - decide how to cleanly do it so it lights up if TA is defined //if (exception is <API key>) // return; <API key> <API key> = <API key>.Capture(exception); if (targetContext != null) { try { targetContext.Post((edi) => ((<API key>)edi).Throw(), <API key>); } catch { // Something went wrong in the Post; let's try using the thread pool instead: ThrowAsync(exception, null); } return; } bool scheduled = true; try { new <API key>().Post((edi) => ((<API key>)edi).Throw(), <API key>); } catch { // Something went wrong when scheduling the thrower; we do our best by throwing the exception here: scheduled = false; } if (!scheduled) <API key>.Throw(); } } // <API key> } // namespace // <API key>.cs
#define DATABASE_NAME publickey #define DEFAULT_CONFIG "nis nisplus" #include "XXX-lookup.c"
<?php require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); class FormFormatterStub extends <API key> { public function __construct() {} public function translate($subject, $parameters = array()) { return sprintf('translation[%s]', $subject); } } $t = new lime_test(13); $dom = new DomDocument('1.0', 'utf-8'); $dom->validateOnParse = true; // ->render() $t->diag('->render()'); $w = new <API key>(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'), 'separator' => '')); $output = '<ul class="checkbox_list">'. '<li><input name="foo[]" type="checkbox" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li>'. '<li><input name="foo[]" type="checkbox" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">foo</label></li>'. '</ul>'; $t->is($w->render('foo', array('foobar')), $output, '->render() renders a checkbox tag with the value checked'); // attributes $onChange = '<ul class="checkbox_list">'. '<li><input name="foo[]" type="checkbox" value="foo" id="foo_foo" onChange="alert(42)" />'. '&nbsp;<label for="foo_foo">bar</label></li>'. '<li><input name="foo[]" type="checkbox" value="foobar" id="foo_foobar" checked="checked" onChange="alert(42)" />'. '&nbsp;<label for="foo_foobar">foo</label></li>'. '</ul>'; $t->is($w->render('foo', array('foobar'), array('onChange' => 'alert(42)')), $onChange, '->render() renders a checkbox tag using extra attributes'); $w = new <API key>(array('choices' => array('0' => 'bar', '1' => 'foo'))); $output = <<< EOF <ul class="checkbox_list"><li><input name="myname[]" type="checkbox" value="0" id="myname_0" checked="checked" />&nbsp;<label for="myname_0">bar</label></li> <li><input name="myname[]" type="checkbox" value="1" id="myname_1" />&nbsp;<label for="myname_1">foo</label></li></ul> EOF; $t->is($w->render('myname', array(false)), fix_linebreaks($output), '->render() considers false to be an integer 0'); $w = new <API key>(array('choices' => array('0' => 'bar', '1' => 'foo'))); $output = <<< EOF <ul class="checkbox_list"><li><input name="myname[]" type="checkbox" value="0" id="myname_0" />&nbsp;<label for="myname_0">bar</label></li> <li><input name="myname[]" type="checkbox" value="1" id="myname_1" checked="checked" />&nbsp;<label for="myname_1">foo</label></li></ul> EOF; $t->is($w->render('myname', array(true)), fix_linebreaks($output), '->render() considers true to be an integer 1'); $w = new <API key>(array('choices' => array())); $t->is($w->render('myname', array()), '', '->render() returns an empty HTML string if no choices'); // group support $t->diag('group support'); $w = new <API key>(array('choices' => array('foo' => array('foo' => 'bar', 'bar' => 'foo'), 'bar' => array('foobar' => 'barfoo')))); $output = <<<EOF foo <ul class="checkbox_list"><li><input name="foo[]" type="checkbox" value="foo" id="foo_foo" checked="checked" />&nbsp;<label for="foo_foo">bar</label></li> <li><input name="foo[]" type="checkbox" value="bar" id="foo_bar" />&nbsp;<label for="foo_bar">foo</label></li></ul> bar <ul class="checkbox_list"><li><input name="foo[]" type="checkbox" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">barfoo</label></li></ul> EOF; $t->is($w->render('foo', array('foo', 'foobar')), fix_linebreaks($output), '->render() has support for groups'); $w->setOption('choices', array('foo' => array('foo' => 'bar', 'bar' => 'foo'))); $output = <<<EOF foo <ul class="checkbox_list"><li><input name="foo[]" type="checkbox" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li> <li><input name="foo[]" type="checkbox" value="bar" id="foo_bar" checked="checked" />&nbsp;<label for="foo_bar">foo</label></li></ul> EOF; $t->is($w->render('foo', array('bar')), fix_linebreaks($output), '->render() accepts a single group'); try { $w = new <API key>(); $t->fail('__construct() throws an RuntimeException if you don\'t pass a choices option'); } catch (RuntimeException $e) { $t->pass('__construct() throws an RuntimeException if you don\'t pass a choices option'); } // choices as a callable $t->diag('choices as a callable'); function choice_callable() { return array(1, 2, 3); } $w = new <API key>(array('choices' => new sfCallable('choice_callable'))); $dom->loadHTML($w->render('foo')); $css = new sfDomCssSelector($dom); $t->is(count($css->matchAll('input[type="checkbox"]')->getNodes()), 3, '->render() accepts a sfCallable as a choices option'); // choices are translated $t->diag('choices are translated'); $ws = new sfWidgetFormSchema(); $ws->addFormFormatter('stub', new FormFormatterStub()); $ws-><API key>('stub'); $w = new <API key>(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'), 'separator' => '')); $w->setParent($ws); $output = '<ul class="checkbox_list">'. '<li><input name="foo[]" type="checkbox" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">translation[bar]</label></li>'. '<li><input name="foo[]" type="checkbox" value="foobar" id="foo_foobar" />&nbsp;<label for="foo_foobar">translation[foo]</label></li>'. '</ul>'; $t->is($w->render('foo'), $output, '->render() translates the options'); // choices are escaped $t->diag('choices are escaped'); $w = new <API key>(array('choices' => array('<b>Hello world</b>'))); $t->is($w->render('foo'), '<ul class="checkbox_list"><li><input name="foo[]" type="checkbox" value="0" id="foo_0" />&nbsp;<label for="foo_0">&lt;b&gt;Hello world&lt;/b&gt;</label></li></ul>', '->render() escapes the choices'); // __clone() $t->diag('__clone()'); $w = new <API key>(array('choices' => new sfCallable(array($w, 'foo')))); $w1 = clone $w; $callable = $w1->getOption('choices')->getCallable(); $t->is(spl_object_hash($callable[0]), spl_object_hash($w1), '__clone() changes the choices is a callable and the object is an instance of the current object'); $w = new <API key>(array('choices' => new sfCallable(array($a = new stdClass(), 'foo')))); $w1 = clone $w; $callable = $w1->getOption('choices')->getCallable(); $t->is(spl_object_hash($callable[0]), spl_object_hash($a), '__clone() changes nothing if the choices is a callable and the object is not an instance of the current object');
#import "GPUImage.h" #import <UIKit/UIKit.h> @interface <API key> : UIResponder <<API key>> @property (strong, nonatomic) UIWindow *window; @end
// purpose with or without fee is hereby granted, provided that the above // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // Author(s): ="Atheros" #ifdef THREAD_X #include <string.h> #endif #include "hif.h" #include "bmi.h" #include "htc_api.h" #include "bmi_internal.h" #ifdef ATH_DEBUG_MODULE static <API key> bmi_debug_desc[] = { { ATH_DEBUG_BMI , "BMI Tracing"}, }; <API key>(bmi, "bmi", "Boot Manager Interface", <API key>, <API key>(bmi_debug_desc), bmi_debug_desc); #endif /* Although we had envisioned BMI to run on top of HTC, this is not how the final implementation ended up. On the Target side, BMI is a part of the BSP and does not use the HTC protocol nor even DMA -- it is intentionally kept very simple. */ static A_BOOL <API key> = FALSE; static A_UINT32 *pBMICmdCredits; static A_UCHAR *pBMICmdBuf; #define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \ sizeof(A_UINT32) /* cmd */ + \ sizeof(A_UINT32) /* addr */ + \ sizeof(A_UINT32))/* length */ #define BMI_COMMAND_FITS(sz) ((sz) <= MAX_BMI_CMDBUF_SZ) /* APIs visible to the driver */ void BMIInit(void) { bmiDone = FALSE; <API key> = FALSE; /* * On some platforms, it's not possible to DMA to a static variable * in a device driver (e.g. Linux loadable driver module). * So we need to A_MALLOC space for "command credits" and for commands. * * Note: implicitly relies on A_MALLOC to provide a buffer that is * suitable for DMA (or PIO). This buffer will be passed down the * bus stack. */ if (!pBMICmdCredits) { pBMICmdCredits = (A_UINT32 *)A_MALLOC_NOWAIT(4); A_ASSERT(pBMICmdCredits); } if (!pBMICmdBuf) { pBMICmdBuf = (A_UCHAR *)A_MALLOC_NOWAIT(MAX_BMI_CMDBUF_SZ); A_ASSERT(pBMICmdBuf); } <API key>(bmi); } void BMICleanup(void) { if (pBMICmdCredits) { A_FREE(pBMICmdCredits); pBMICmdCredits = NULL; } if (pBMICmdBuf) { A_FREE(pBMICmdBuf); pBMICmdBuf = NULL; } } A_STATUS BMIDone(HIF_DEVICE *device) { A_STATUS status; A_UINT32 cid; if (bmiDone) { AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n")); return A_OK; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device)); bmiDone = TRUE; cid = BMI_DONE; status = bmiBufferSend(device, (A_UCHAR *)&cid, sizeof(cid)); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } if (pBMICmdCredits) { A_FREE(pBMICmdCredits); pBMICmdCredits = NULL; } if (pBMICmdBuf) { A_FREE(pBMICmdBuf); pBMICmdBuf = NULL; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n")); return A_OK; } A_STATUS BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info) { A_STATUS status; A_UINT32 cid; if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Enter (device: 0x%p)\n", device)); cid = BMI_GET_TARGET_INFO; status = bmiBufferSend(device, (A_UCHAR *)&cid, sizeof(cid)); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, (A_UCHAR *)&targ_info->target_ver, sizeof(targ_info->target_ver), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Version from the device\n")); return A_ERROR; } if (targ_info->target_ver == <API key>) { /* Determine how many bytes are in the Target's targ_info */ status = bmiBufferReceive(device, (A_UCHAR *)&targ_info-><API key>, sizeof(targ_info-><API key>), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info Byte Count from the device\n")); return A_ERROR; } /* * The Target's targ_info doesn't match the Host's targ_info. * We need to do some backwards compatibility work to make this OK. */ A_ASSERT(targ_info-><API key> == sizeof(*targ_info)); /* Read the remainder of the targ_info */ status = bmiBufferReceive(device, ((A_UCHAR *)targ_info)+sizeof(targ_info-><API key>), sizeof(*targ_info)-sizeof(targ_info-><API key>), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info (%d bytes) from the device\n", targ_info-><API key>)); return A_ERROR; } } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n", targ_info->target_ver, targ_info->target_type)); return A_OK; } A_STATUS BMIReadMemory(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, rxlen; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length))); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); cid = BMI_READ_MEMORY; remaining = length; while (remaining) { rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), &rxlen, sizeof(rxlen)); offset += sizeof(length); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, rxlen, TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(&buffer[length - remaining], pBMICmdBuf, rxlen); remaining -= rxlen; address += rxlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n")); return A_OK; } A_STATUS BMIWriteMemory(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, txlen; const A_UINT32 header = sizeof(cid) + sizeof(address) + sizeof(length); A_UCHAR alignedBuffer[BMI_DATASZ_MAX]; A_UCHAR *src; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header)); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + header); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); cid = BMI_WRITE_MEMORY; remaining = length; while (remaining) { src = &buffer[length - remaining]; if (remaining < (BMI_DATASZ_MAX - header)) { if (remaining & 3) { /* align it with 4 bytes */ remaining = remaining + (4 - (remaining & 3)); memcpy(alignedBuffer, src, remaining); src = alignedBuffer; } txlen = remaining; } else { txlen = (BMI_DATASZ_MAX - header); } offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&(pBMICmdBuf[offset]), src, txlen); offset += txlen; status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; address += txlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write Memory: Exit\n")); return A_OK; } A_STATUS BMIExecute(HIF_DEVICE *device, A_UINT32 address, A_UINT32 *param) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n", device, address, *param)); cid = BMI_EXECUTE; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), param, sizeof(*param)); offset += sizeof(*param); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*param), FALSE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(param, pBMICmdBuf, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); return A_OK; } A_STATUS BMISetAppStart(HIF_DEVICE *device, A_UINT32 address) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Set App Start: Enter (device: 0x%p, address: 0x%x)\n", device, address)); cid = BMI_SET_APP_START; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Set App Start: Exit\n")); return A_OK; } A_STATUS BMIReadSOCRegister(HIF_DEVICE *device, A_UINT32 address, A_UINT32 *param) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n", device, address)); cid = <API key>; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*param), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(param, pBMICmdBuf, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit (value: %d)\n", *param)); return A_OK; } A_STATUS BMIWriteSOCRegister(HIF_DEVICE *device, A_UINT32 address, A_UINT32 param) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write SOC Register: Enter (device: 0x%p, address: 0x%x, param: %d)\n", device, address, param)); cid = <API key>; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), &param, sizeof(param)); offset += sizeof(param); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit\n")); return A_OK; } A_STATUS BMIrompatchInstall(HIF_DEVICE *device, A_UINT32 ROM_addr, A_UINT32 RAM_addr, A_UINT32 nbytes, A_UINT32 do_activate, A_UINT32 *rompatch_id) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + sizeof(nbytes) + sizeof(do_activate))); memset(pBMICmdBuf, 0, sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + sizeof(nbytes) + sizeof(do_activate)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: Enter (device: 0x%p, ROMaddr: 0x%x, RAMaddr: 0x%x length: %d activate: %d)\n", device, ROM_addr, RAM_addr, nbytes, do_activate)); cid = <API key>; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &ROM_addr, sizeof(ROM_addr)); offset += sizeof(ROM_addr); A_MEMCPY(&(pBMICmdBuf[offset]), &RAM_addr, sizeof(RAM_addr)); offset += sizeof(RAM_addr); A_MEMCPY(&(pBMICmdBuf[offset]), &nbytes, sizeof(nbytes)); offset += sizeof(nbytes); A_MEMCPY(&(pBMICmdBuf[offset]), &do_activate, sizeof(do_activate)); offset += sizeof(do_activate); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*rompatch_id), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(rompatch_id, pBMICmdBuf, sizeof(*rompatch_id)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id)); return A_OK; } A_STATUS <API key>(HIF_DEVICE *device, A_UINT32 rompatch_id) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(rompatch_id))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(rompatch_id)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Uninstall: Enter (device: 0x%p, rompatch_id: %d)\n", device, rompatch_id)); cid = <API key>; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &rompatch_id, sizeof(rompatch_id)); offset += sizeof(rompatch_id); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch UNinstall: (rompatch_id=0x%x)\n", rompatch_id)); return A_OK; } static A_STATUS <API key>(HIF_DEVICE *device, A_UINT32 rompatch_count, A_UINT32 *rompatch_list, A_UINT32 do_activate) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 length; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count))); memset(pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n", device, rompatch_count)); cid = do_activate ? <API key> : <API key>; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &rompatch_count, sizeof(rompatch_count)); offset += sizeof(rompatch_count); length = rompatch_count * sizeof(*rompatch_list); A_MEMCPY(&(pBMICmdBuf[offset]), rompatch_list, length); offset += length; status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n")); return A_OK; } A_STATUS BMIrompatchActivate(HIF_DEVICE *device, A_UINT32 rompatch_count, A_UINT32 *rompatch_list) { return <API key>(device, rompatch_count, rompatch_list, 1); } A_STATUS <API key>(HIF_DEVICE *device, A_UINT32 rompatch_count, A_UINT32 *rompatch_list) { return <API key>(device, rompatch_count, rompatch_list, 0); } A_STATUS BMILZData(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, txlen; const A_UINT32 header = sizeof(cid) + sizeof(length); A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX+header)); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX+header); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Send LZ Data: Enter (device: 0x%p, length: %d)\n", device, length)); cid = BMI_LZ_DATA; remaining = length; while (remaining) { txlen = (remaining < (BMI_DATASZ_MAX - header)) ? remaining : (BMI_DATASZ_MAX - header); offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&(pBMICmdBuf[offset]), &buffer[length - remaining], txlen); offset += txlen; status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Data: Exit\n")); return A_OK; } A_STATUS BMILZStreamStart(HIF_DEVICE *device, A_UINT32 address) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Stream Start: Enter (device: 0x%p, address: 0x%x)\n", device, address)); cid = BMI_LZ_STREAM_START; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to Start LZ Stream to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Stream Start: Exit\n")); return A_OK; } /* BMI Access routines */ A_STATUS bmiBufferSend(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length) { A_STATUS status; A_UINT32 timeout; A_UINT32 address; A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX]; HIFConfigureDevice(device, <API key>, &mboxAddress[0], sizeof(mboxAddress)); *pBMICmdCredits = 0; timeout = <API key>; while(timeout-- && !(*pBMICmdCredits)) { /* Read the counter register to get the command credits */ address = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4; /* hit the credit counter with a 4-byte access, the first byte read will hit the counter and cause * a decrement, while the remaining 3 bytes has no effect. The rationale behind this is to * make all HIF accesses 4-byte aligned */ status = HIFReadWrite(device, address, (A_UINT8 *)pBMICmdCredits, 4, <API key>, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to decrement the command credit count register\n")); return A_ERROR; } /* the counter is only 8=bits, ignore anything in the upper 3 bytes */ (*pBMICmdCredits) &= 0xFF; } if (*pBMICmdCredits) { address = mboxAddress[ENDPOINT1]; status = HIFReadWrite(device, address, buffer, length, <API key>, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to send the BMI data to the device\n")); return A_ERROR; } } else { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout - bmiBufferSend\n")); return A_ERROR; } return status; } A_STATUS bmiBufferReceive(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length, A_BOOL want_timeout) { A_STATUS status; A_UINT32 address; A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX]; <API key> hifPendingEvents; static <API key> <API key> = NULL; if (!<API key>) { /* see if the HIF layer implements an alternative function to get pending events * do this only once! */ HIFConfigureDevice(device, <API key>, &<API key>, sizeof(<API key>)); <API key> = TRUE; } HIFConfigureDevice(device, <API key>, &mboxAddress[0], sizeof(mboxAddress)); /* * During normal bootup, small reads may be required. * Rather than issue an HIF Read and then wait as the Target * adds successive bytes to the FIFO, we wait here until * we know that response data is available. * * This allows us to cleanly timeout on an unexpected * Target failure rather than risk problems at the HIF level. In * particular, this avoids SDIO timeouts and possibly garbage * data on some host controllers. And on an interconnect * such as Compact Flash (as well as some SDIO masters) which * does not provide any indication on data timeout, it avoids * a potential hang or garbage response. * * Synchronization is more difficult for reads larger than the * size of the MBOX FIFO (128B), because the Target is unable * to push the 129th byte of data until AFTER the Host posts an * HIF Read and removes some FIFO data. So for large reads the * Host proceeds to post an HIF Read BEFORE all the data is * actually available to read. Fortunately, large BMI reads do * not occur in practice -- they're supported for debug/development. * * So Host/Target BMI synchronization is divided into these cases: * CASE 1: length < 4 * Should not happen * * CASE 2: 4 <= length <= 128 * Wait for first 4 bytes to be in FIFO * If <API key> is enabled, also wait for * a BMI command credit, which indicates that the ENTIRE * response is available in the the FIFO * * CASE 3: length > 128 * Wait for the first 4 bytes to be in FIFO * * For most uses, a small timeout should be sufficient and we will * usually see a response quickly; but there may be some unusual * (debug) cases of BMI_EXECUTE where we want an larger timeout. * For now, we use an unbounded busy loop while waiting for * BMI_EXECUTE. * * If BMI_EXECUTE ever needs to support longer-latency execution, * especially in production, this code needs to be enhanced to sleep * and yield. Also note that <API key> is currently * a function of Host processor speed. */ if (length >= 4) { /* NB: Currently, always true */ /* * NB: word_available is declared static for esoteric reasons * having to do with protection on some OSes. */ static A_UINT32 word_available; A_UINT32 timeout; word_available = 0; timeout = <API key>; while((!want_timeout || timeout--) && !word_available) { if (<API key> != NULL) { status = <API key>(device, &hifPendingEvents, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMI: Failed to get pending events \n")); break; } if (hifPendingEvents.AvailableRecvBytes >= sizeof(A_UINT32)) { word_available = 1; } continue; } status = HIFReadWrite(device, <API key>, (A_UINT8 *)&word_available, sizeof(word_available), <API key>, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read RX_LOOKAHEAD_VALID register\n")); return A_ERROR; } /* We did a 4-byte read to the same register; all we really want is one bit */ word_available &= (1 << ENDPOINT1); } if (!word_available) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout - bmiBufferReceive FIFO empty\n")); return A_ERROR; } } #define <API key> 0 #if <API key> /* * This is an extra-conservative CREDIT check. It guarantees * that ALL data is available in the FIFO before we start to * read from the interconnect. * * This credit check is useless when firmware chooses to * allow multiple outstanding BMI Command Credits, since the next * credit will already be present. To restrict the Target to one * BMI Command Credit, see <API key>. * * And for large reads (when <API key> is set) * we cannot wait for the next credit because the Target's FIFO * will not hold the entire response. So we need the Host to * start to empty the FIFO sooner. (And again, large reads are * not used in practice; they are for debug/development only.) * * For a more conservative Host implementation (which would be * safer for a Compact Flash interconnect): * Set <API key> (above) to 1 * Set <API key> and * reduce BMI_DATASZ_MAX to 32 or 64 */ if ((length > 4) && (length < 128)) { /* check against MBOX FIFO size */ A_UINT32 timeout; *pBMICmdCredits = 0; timeout = <API key>; while((!want_timeout || timeout--) && !(*pBMICmdCredits) { /* Read the counter register to get the command credits */ address = COUNT_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 1; /* read the counter using a 4-byte read. Since the counter is NOT auto-decrementing, * we can read this counter multiple times using a non-incrementing address mode. * The rationale here is to make all HIF accesses a multiple of 4 bytes */ status = HIFReadWrite(device, address, (A_UINT8 *)pBMICmdCredits, sizeof(*pBMICmdCredits), <API key>, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the command credit count register\n")); return A_ERROR; } /* we did a 4-byte read to the same count register so mask off upper bytes */ (*pBMICmdCredits) &= 0xFF; } if (!(*pBMICmdCredits)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout- bmiBufferReceive no credit\n")); return A_ERROR; } } #endif address = mboxAddress[ENDPOINT1]; status = HIFReadWrite(device, address, buffer, length, <API key>, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the BMI data from the device\n")); return A_ERROR; } return A_OK; } A_STATUS BMIFastDownload(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_STATUS status = A_ERROR; A_UINT32 lastWord = 0; A_UINT32 lastWordOffset = length & ~0x3; A_UINT32 unalignedBytes = length & 0x3; status = BMILZStreamStart (device, address); if (A_FAILED(status)) { return A_ERROR; } if (unalignedBytes) { /* copy the last word into a zero padded buffer */ A_MEMCPY(&lastWord, &buffer[lastWordOffset], unalignedBytes); } status = BMILZData(device, buffer, lastWordOffset); if (A_FAILED(status)) { return A_ERROR; } if (unalignedBytes) { status = BMILZData(device, (A_UINT8 *)&lastWord, 4); } if (A_SUCCESS(status)) { // Close compressed stream and open a new (fake) one. This serves mainly to flush Target caches. status = BMILZStreamStart (device, 0x00); if (A_FAILED(status)) { return A_ERROR; } } return status; } A_STATUS BMIRawWrite(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length) { return bmiBufferSend(device, buffer, length); } A_STATUS BMIRawRead(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length, A_BOOL want_timeout) { return bmiBufferReceive(device, buffer, length, want_timeout); }
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include "htc.h" MODULE_AUTHOR("Atheros Communications"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("Atheros driver 802.11n HTC based wireless devices"); static unsigned int ath9k_debug = ATH_DBG_DEFAULT; module_param_named(debug, ath9k_debug, uint, 0); MODULE_PARM_DESC(debug, "Debugging mask"); int <API key>; module_param_named(nohwcrypt, <API key>, int, 0444); MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); static int <API key>; module_param_named(btcoex_enable, <API key>, int, 0444); MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); #define CHAN2G(_freq, _idx) { \ .center_freq = (_freq), \ .hw_value = (_idx), \ .max_power = 20, \ } #define CHAN5G(_freq, _idx) { \ .band = IEEE80211_BAND_5GHZ, \ .center_freq = (_freq), \ .hw_value = (_idx), \ .max_power = 20, \ } static struct ieee80211_channel ath9k_2ghz_channels[] = { CHAN2G(2412, 0), /* Channel 1 */ CHAN2G(2417, 1), /* Channel 2 */ CHAN2G(2422, 2), /* Channel 3 */ CHAN2G(2427, 3), /* Channel 4 */ CHAN2G(2432, 4), /* Channel 5 */ CHAN2G(2437, 5), /* Channel 6 */ CHAN2G(2442, 6), /* Channel 7 */ CHAN2G(2447, 7), /* Channel 8 */ CHAN2G(2452, 8), /* Channel 9 */ CHAN2G(2457, 9), /* Channel 10 */ CHAN2G(2462, 10), /* Channel 11 */ CHAN2G(2467, 11), /* Channel 12 */ CHAN2G(2472, 12), /* Channel 13 */ CHAN2G(2484, 13), /* Channel 14 */ }; static struct ieee80211_channel ath9k_5ghz_channels[] = { /* _We_ call this UNII 1 */ CHAN5G(5180, 14), /* Channel 36 */ CHAN5G(5200, 15), /* Channel 40 */ CHAN5G(5220, 16), /* Channel 44 */ CHAN5G(5240, 17), /* Channel 48 */ /* _We_ call this UNII 2 */ CHAN5G(5260, 18), /* Channel 52 */ CHAN5G(5280, 19), /* Channel 56 */ CHAN5G(5300, 20), /* Channel 60 */ CHAN5G(5320, 21), /* Channel 64 */ /* _We_ call this "Middle band" */ CHAN5G(5500, 22), /* Channel 100 */ CHAN5G(5520, 23), /* Channel 104 */ CHAN5G(5540, 24), /* Channel 108 */ CHAN5G(5560, 25), /* Channel 112 */ CHAN5G(5580, 26), /* Channel 116 */ CHAN5G(5600, 27), /* Channel 120 */ CHAN5G(5620, 28), /* Channel 124 */ CHAN5G(5640, 29), /* Channel 128 */ CHAN5G(5660, 30), /* Channel 132 */ CHAN5G(5680, 31), /* Channel 136 */ CHAN5G(5700, 32), /* Channel 140 */ /* _We_ call this UNII 3 */ CHAN5G(5745, 33), /* Channel 149 */ CHAN5G(5765, 34), /* Channel 153 */ CHAN5G(5785, 35), /* Channel 157 */ CHAN5G(5805, 36), /* Channel 161 */ CHAN5G(5825, 37), /* Channel 165 */ }; /* Atheros hardware rate code addition for short premble */ #define SHPCHECK(__hw_rate, __flags) \ ((__flags & <API key>) ? (__hw_rate | 0x04) : 0) #define RATE(_bitrate, _hw_rate, _flags) { \ .bitrate = (_bitrate), \ .flags = (_flags), \ .hw_value = (_hw_rate), \ .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \ } static struct ieee80211_rate ath9k_legacy_rates[] = { RATE(10, 0x1b, 0), RATE(20, 0x1a, <API key>), /* shortp : 0x1e */ RATE(55, 0x19, <API key>), /* shortp: 0x1d */ RATE(110, 0x18, <API key>), /* short: 0x1c */ RATE(60, 0x0b, 0), RATE(90, 0x0f, 0), RATE(120, 0x0a, 0), RATE(180, 0x0e, 0), RATE(240, 0x09, 0), RATE(360, 0x0d, 0), RATE(480, 0x08, 0), RATE(540, 0x0c, 0), }; #ifdef <API key> static const struct ieee80211_tpt_blink ath9k_htc_tpt_blink[] = { { .throughput = 0 * 1024, .blink_time = 334 }, { .throughput = 1 * 1024, .blink_time = 260 }, { .throughput = 5 * 1024, .blink_time = 220 }, { .throughput = 10 * 1024, .blink_time = 190 }, { .throughput = 20 * 1024, .blink_time = 170 }, { .throughput = 50 * 1024, .blink_time = 150 }, { .throughput = 70 * 1024, .blink_time = 130 }, { .throughput = 100 * 1024, .blink_time = 110 }, { .throughput = 200 * 1024, .blink_time = 80 }, { .throughput = 300 * 1024, .blink_time = 50 }, }; #endif static int <API key>(struct ath9k_htc_priv *priv) { int time_left; if (atomic_read(&priv->htc->tgt_ready) > 0) { atomic_dec(&priv->htc->tgt_ready); return 0; } /* Firmware can take up to 50ms to get ready, to be safe use 1 second */ time_left = <API key>(&priv->htc->target_wait, HZ); if (!time_left) { dev_err(priv->dev, "ath9k_htc: Target is unresponsive\n"); return -ETIMEDOUT; } atomic_dec(&priv->htc->tgt_ready); return 0; } static void ath9k_deinit_priv(struct ath9k_htc_priv *priv) { ath9k_hw_deinit(priv->ah); kfree(priv->ah); priv->ah = NULL; } static void ath9k_deinit_device(struct ath9k_htc_priv *priv) { struct ieee80211_hw *hw = priv->hw; <API key>(hw->wiphy); ath9k_deinit_leds(priv); <API key>(hw); ath9k_rx_cleanup(priv); ath9k_tx_cleanup(priv); ath9k_deinit_priv(priv); } static inline int <API key>(struct ath9k_htc_priv *priv, u16 service_id, void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok), enum htc_endpoint_id *ep_id) { struct htc_service_connreq req; memset(&req, 0, sizeof(struct htc_service_connreq)); req.service_id = service_id; req.ep_callbacks.priv = priv; req.ep_callbacks.rx = ath9k_htc_rxep; req.ep_callbacks.tx = tx; return htc_connect_service(priv->htc, &req, ep_id); } static int <API key>(struct ath9k_htc_priv *priv, u16 devid, u32 drv_info) { int ret; /* WMI CMD*/ ret = ath9k_wmi_connect(priv->htc, priv->wmi, &priv->wmi_cmd_ep); if (ret) goto err; /* Beacon */ ret = <API key>(priv, WMI_BEACON_SVC, ath9k_htc_beaconep, &priv->beacon_ep); if (ret) goto err; /* CAB */ ret = <API key>(priv, WMI_CAB_SVC, ath9k_htc_txep, &priv->cab_ep); if (ret) goto err; /* UAPSD */ ret = <API key>(priv, WMI_UAPSD_SVC, ath9k_htc_txep, &priv->uapsd_ep); if (ret) goto err; /* MGMT */ ret = <API key>(priv, WMI_MGMT_SVC, ath9k_htc_txep, &priv->mgmt_ep); if (ret) goto err; /* DATA BE */ ret = <API key>(priv, WMI_DATA_BE_SVC, ath9k_htc_txep, &priv->data_be_ep); if (ret) goto err; /* DATA BK */ ret = <API key>(priv, WMI_DATA_BK_SVC, ath9k_htc_txep, &priv->data_bk_ep); if (ret) goto err; /* DATA VI */ ret = <API key>(priv, WMI_DATA_VI_SVC, ath9k_htc_txep, &priv->data_vi_ep); if (ret) goto err; /* DATA VO */ ret = <API key>(priv, WMI_DATA_VO_SVC, ath9k_htc_txep, &priv->data_vo_ep); if (ret) goto err; /* * Setup required credits before initializing HTC. * This is a bit hacky, but, since queuing is done in * the HIF layer, shouldn't matter much. */ if (IS_AR7010_DEVICE(drv_info)) priv->htc->credits = 45; else priv->htc->credits = 33; ret = htc_init(priv->htc); if (ret) goto err; dev_info(priv->dev, "ath9k_htc: HTC initialized with %d credits\n", priv->htc->credits); return 0; err: dev_err(priv->dev, "ath9k_htc: Unable to initialize HTC services\n"); return ret; } static void ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) { struct ieee80211_hw *hw = <API key>(wiphy); struct ath9k_htc_priv *priv = hw->priv; <API key>(wiphy, request, ath9k_hw_regulatory(priv->ah)); } static unsigned int ath9k_regread(void *hw_priv, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; __be32 val, reg = cpu_to_be32(reg_offset); int r; r = ath9k_wmi_cmd(priv->wmi, WMI_REG_READ_CMDID, (u8 *) &reg, sizeof(reg), (u8 *) &val, sizeof(val), 100); if (unlikely(r)) { ath_dbg(common, WMI, "REGISTER READ FAILED: (0x%04x, %d)\n", reg_offset, r); return -EIO; } return be32_to_cpu(val); } static void ath9k_multi_regread(void *hw_priv, u32 *addr, u32 *val, u16 count) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; __be32 tmpaddr[8]; __be32 tmpval[8]; int i, ret; for (i = 0; i < count; i++) { tmpaddr[i] = cpu_to_be32(addr[i]); } ret = ath9k_wmi_cmd(priv->wmi, WMI_REG_READ_CMDID, (u8 *)tmpaddr , sizeof(u32) * count, (u8 *)tmpval, sizeof(u32) * count, 100); if (unlikely(ret)) { ath_dbg(common, WMI, "Multiple REGISTER READ FAILED (count: %d)\n", count); } for (i = 0; i < count; i++) { val[i] = be32_to_cpu(tmpval[i]); } } static void <API key>(void *hw_priv, u32 val, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; const __be32 buf[2] = { cpu_to_be32(reg_offset), cpu_to_be32(val), }; int r; r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, (u8 *) &buf, sizeof(buf), (u8 *) &val, sizeof(val), 100); if (unlikely(r)) { ath_dbg(common, WMI, "REGISTER WRITE FAILED:(0x%04x, %d)\n", reg_offset, r); } } static void <API key>(void *hw_priv, u32 val, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; u32 rsp_status; int r; mutex_lock(&priv->wmi->multi_write_mutex); /* Store the register/value */ priv->wmi->multi_write[priv->wmi->multi_write_idx].reg = cpu_to_be32(reg_offset); priv->wmi->multi_write[priv->wmi->multi_write_idx].val = cpu_to_be32(val); priv->wmi->multi_write_idx++; /* If the buffer is full, send it out. */ if (priv->wmi->multi_write_idx == MAX_CMD_NUMBER) { r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, (u8 *) &priv->wmi->multi_write, sizeof(struct register_write) * priv->wmi->multi_write_idx, (u8 *) &rsp_status, sizeof(rsp_status), 100); if (unlikely(r)) { ath_dbg(common, WMI, "REGISTER WRITE FAILED, multi len: %d\n", priv->wmi->multi_write_idx); } priv->wmi->multi_write_idx = 0; } mutex_unlock(&priv->wmi->multi_write_mutex); } static void ath9k_regwrite(void *hw_priv, u32 val, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; if (atomic_read(&priv->wmi->mwrite_cnt)) <API key>(hw_priv, val, reg_offset); else <API key>(hw_priv, val, reg_offset); } static void <API key>(void *hw_priv) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; atomic_inc(&priv->wmi->mwrite_cnt); } static void <API key>(void *hw_priv) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; u32 rsp_status; int r; atomic_dec(&priv->wmi->mwrite_cnt); mutex_lock(&priv->wmi->multi_write_mutex); if (priv->wmi->multi_write_idx) { r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, (u8 *) &priv->wmi->multi_write, sizeof(struct register_write) * priv->wmi->multi_write_idx, (u8 *) &rsp_status, sizeof(rsp_status), 100); if (unlikely(r)) { ath_dbg(common, WMI, "REGISTER WRITE FAILED, multi len: %d\n", priv->wmi->multi_write_idx); } priv->wmi->multi_write_idx = 0; } mutex_unlock(&priv->wmi->multi_write_mutex); } static u32 ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr) { u32 val; val = ath9k_regread(hw_priv, reg_offset); val &= ~clr; val |= set; ath9k_regwrite(hw_priv, val, reg_offset); return val; } static void <API key>(struct ath_common *common, int *csz) { *csz = L1_CACHE_BYTES >> 2; } static bool ath_usb_eeprom_read(struct ath_common *common, u32 off, u16 *data) { struct ath_hw *ah = (struct ath_hw *) common->ah; (void)REG_READ(ah, <API key> + (off << AR5416_EEPROM_S)); if (!ath9k_hw_wait(ah, <API key>, <API key> | <API key>, 0, AH_WAIT_TIMEOUT)) return false; *data = MS(REG_READ(ah, <API key>), <API key>); return true; } static const struct ath_bus_ops ath9k_usb_bus_ops = { .ath_bus_type = ATH_USB, .read_cachesize = <API key>, .eeprom_read = ath_usb_eeprom_read, }; static void setup_ht_cap(struct ath9k_htc_priv *priv, struct <API key> *ht_info) { struct ath_common *common = ath9k_hw_common(priv->ah); u8 tx_streams, rx_streams; int i; ht_info->ht_supported = true; ht_info->cap = <API key> | <API key> | <API key> | <API key>; if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20) ht_info->cap |= <API key>; ht_info->cap |= (1 << <API key>); ht_info->ampdu_factor = <API key>; ht_info->ampdu_density = <API key>; memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); /* ath9k_htc supports only 1 or 2 stream devices */ tx_streams = <API key>(priv->ah->txchainmask, 2); rx_streams = <API key>(priv->ah->rxchainmask, 2); ath_dbg(common, CONFIG, "TX streams %d, RX streams: %d\n", tx_streams, rx_streams); if (tx_streams != rx_streams) { ht_info->mcs.tx_params |= <API key>; ht_info->mcs.tx_params |= ((tx_streams - 1) << <API key>); } for (i = 0; i < rx_streams; i++) ht_info->mcs.rx_mask[i] = 0xff; ht_info->mcs.tx_params |= <API key>; } static int ath9k_init_queues(struct ath9k_htc_priv *priv) { struct ath_common *common = ath9k_hw_common(priv->ah); int i; for (i = 0; i < ARRAY_SIZE(priv->hwq_map); i++) priv->hwq_map[i] = -1; priv->beaconq = <API key>(priv->ah); if (priv->beaconq == -1) { ath_err(common, "Unable to setup BEACON xmit queue\n"); goto err; } priv->cabq = <API key>(priv); if (priv->cabq == -1) { ath_err(common, "Unable to setup CAB xmit queue\n"); goto err; } if (!ath9k_htc_txq_setup(priv, IEEE80211_AC_BE)) { ath_err(common, "Unable to setup xmit queue for BE traffic\n"); goto err; } if (!ath9k_htc_txq_setup(priv, IEEE80211_AC_BK)) { ath_err(common, "Unable to setup xmit queue for BK traffic\n"); goto err; } if (!ath9k_htc_txq_setup(priv, IEEE80211_AC_VI)) { ath_err(common, "Unable to setup xmit queue for VI traffic\n"); goto err; } if (!ath9k_htc_txq_setup(priv, IEEE80211_AC_VO)) { ath_err(common, "Unable to setup xmit queue for VO traffic\n"); goto err; } return 0; err: return -EINVAL; } static void <API key>(struct ath9k_htc_priv *priv) { if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) { priv->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_channels; priv->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; priv->sbands[IEEE80211_BAND_2GHZ].n_channels = ARRAY_SIZE(ath9k_2ghz_channels); priv->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates; priv->sbands[IEEE80211_BAND_2GHZ].n_bitrates = ARRAY_SIZE(ath9k_legacy_rates); } if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) { priv->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_channels; priv->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; priv->sbands[IEEE80211_BAND_5GHZ].n_channels = ARRAY_SIZE(ath9k_5ghz_channels); priv->sbands[IEEE80211_BAND_5GHZ].bitrates = ath9k_legacy_rates + 4; priv->sbands[IEEE80211_BAND_5GHZ].n_bitrates = ARRAY_SIZE(ath9k_legacy_rates) - 4; } } static void ath9k_init_misc(struct ath9k_htc_priv *priv) { struct ath_common *common = ath9k_hw_common(priv->ah); memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); priv->ah->opmode = <API key>; } static int ath9k_init_priv(struct ath9k_htc_priv *priv, u16 devid, char *product, u32 drv_info) { struct ath_hw *ah = NULL; struct ath_common *common; int i, ret = 0, csz = 0; set_bit(OP_INVALID, &priv->op_flags); ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); if (!ah) return -ENOMEM; ah->hw_version.devid = devid; ah->hw_version.usbdev = drv_info; ah->ah_flags |= AH_USE_EEPROM; ah->reg_ops.read = ath9k_regread; ah->reg_ops.multi_read = ath9k_multi_regread; ah->reg_ops.write = ath9k_regwrite; ah->reg_ops.enable_write_buffer = <API key>; ah->reg_ops.write_flush = <API key>; ah->reg_ops.rmw = ath9k_reg_rmw; priv->ah = ah; common = ath9k_hw_common(ah); common->ops = &ah->reg_ops; common->bus_ops = &ath9k_usb_bus_ops; common->ah = ah; common->hw = priv->hw; common->priv = priv; common->debug_mask = ath9k_debug; common->btcoex_enabled = <API key> == 1; spin_lock_init(&priv->beacon_lock); spin_lock_init(&priv->tx.tx_lock); mutex_init(&priv->mutex); mutex_init(&priv->htc_pm_lock); tasklet_init(&priv->rx_tasklet, ath9k_rx_tasklet, (unsigned long)priv); tasklet_init(&priv->tx_failed_tasklet, <API key>, (unsigned long)priv); INIT_DELAYED_WORK(&priv->ani_work, ath9k_htc_ani_work); INIT_WORK(&priv->ps_work, ath9k_ps_work); INIT_WORK(&priv->fatal_work, ath9k_fatal_work); setup_timer(&priv->tx.cleanup_timer, <API key>, (unsigned long)priv); /* * Cache line size is used to size and align various * structures used to communicate with the hardware. */ ath_read_cachesize(common, &csz); common->cachelsz = csz << 2; /* convert to bytes */ ret = ath9k_hw_init(ah); if (ret) { ath_err(common, "Unable to initialize hardware; initialization status: %d\n", ret); goto err_hw; } ret = ath9k_init_queues(priv); if (ret) goto err_queues; for (i = 0; i < <API key>; i++) priv->cur_beacon_conf.bslot[i] = NULL; <API key>(ah); <API key>(priv); ath9k_init_misc(priv); <API key>(priv, product); return 0; err_queues: ath9k_hw_deinit(ah); err_hw: kfree(ah); priv->ah = NULL; return ret; } static const struct <API key> if_limits[] = { { .max = 2, .types = BIT(<API key>) | BIT(<API key>) }, { .max = 2, .types = BIT(NL80211_IFTYPE_AP) | BIT(<API key>) }, }; static const struct <API key> if_comb = { .limits = if_limits, .n_limits = ARRAY_SIZE(if_limits), .max_interfaces = 2, .<API key> = 1, }; static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv, struct ieee80211_hw *hw) { struct ath_common *common = ath9k_hw_common(priv->ah); hw->flags = <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>; hw->wiphy->interface_modes = BIT(<API key>) | BIT(<API key>) | BIT(NL80211_IFTYPE_AP) | BIT(<API key>) | BIT(<API key>); hw->wiphy->iface_combinations = &if_comb; hw->wiphy-><API key> = 1; hw->wiphy->flags &= ~<API key>; hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN | <API key>; hw->queues = 4; hw->channel_change_time = 5000; hw->max_listen_interval = 1; hw->vif_data_size = sizeof(struct ath9k_htc_vif); hw->sta_data_size = sizeof(struct ath9k_htc_sta); /* tx_frame_hdr is larger than tx_mgmt_hdr anyway */ hw->extra_tx_headroom = sizeof(struct tx_frame_hdr) + sizeof(struct htc_frame_hdr) + 4; if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->sbands[IEEE80211_BAND_2GHZ]; if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->sbands[IEEE80211_BAND_5GHZ]; if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_HT) { if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) setup_ht_cap(priv, &priv->sbands[IEEE80211_BAND_2GHZ].ht_cap); if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) setup_ht_cap(priv, &priv->sbands[IEEE80211_BAND_5GHZ].ht_cap); } <API key>(hw, common->macaddr); } static int <API key>(struct ath9k_htc_priv *priv) { struct ieee80211_hw *hw = priv->hw; struct wmi_fw_version cmd_rsp; int ret; memset(&cmd_rsp, 0, sizeof(cmd_rsp)); WMI_CMD(WMI_GET_FW_VERSION); if (ret) return -EINVAL; priv->fw_version_major = be16_to_cpu(cmd_rsp.major); priv->fw_version_minor = be16_to_cpu(cmd_rsp.minor); snprintf(hw->wiphy->fw_version, sizeof(hw->wiphy->fw_version), "%d.%d", priv->fw_version_major, priv->fw_version_minor); dev_info(priv->dev, "ath9k_htc: FW Version: %d.%d\n", priv->fw_version_major, priv->fw_version_minor); /* * Check if the available FW matches the driver's * required version. */ if (priv->fw_version_major != MAJOR_VERSION_REQ || priv->fw_version_minor < MINOR_VERSION_REQ) { dev_err(priv->dev, "ath9k_htc: Please upgrade to FW version %d.%d\n", MAJOR_VERSION_REQ, MINOR_VERSION_REQ); return -EINVAL; } return 0; } static int ath9k_init_device(struct ath9k_htc_priv *priv, u16 devid, char *product, u32 drv_info) { struct ieee80211_hw *hw = priv->hw; struct ath_common *common; struct ath_hw *ah; int error = 0; struct ath_regulatory *reg; char hw_name[64]; /* Bring up device */ error = ath9k_init_priv(priv, devid, product, drv_info); if (error != 0) goto err_init; ah = priv->ah; common = ath9k_hw_common(ah); ath9k_set_hw_capab(priv, hw); error = <API key>(priv); if (error != 0) goto err_fw; /* Initialize regulatory */ error = ath_regd_init(&common->regulatory, priv->hw->wiphy, ath9k_reg_notifier); if (error) goto err_regd; reg = &common->regulatory; /* Setup TX */ error = ath9k_tx_init(priv); if (error != 0) goto err_tx; /* Setup RX */ error = ath9k_rx_init(priv); if (error != 0) goto err_rx; ath9k_hw_disable(priv->ah); #ifdef <API key> /* must be initialized before <API key> */ priv->led_cdev.default_trigger = <API key>(priv->hw, <API key>, ath9k_htc_tpt_blink, ARRAY_SIZE(ath9k_htc_tpt_blink)); #endif /* Register with mac80211 */ error = <API key>(hw); if (error) goto err_register; /* Handle world regulatory */ if (!ath_is_world_regd(reg)) { error = regulatory_hint(hw->wiphy, reg->alpha2); if (error) goto err_world; } error = <API key>(priv->ah); if (error) { ath_err(common, "Unable to create debugfs files\n"); goto err_world; } ath_dbg(common, CONFIG, "WMI:%d, BCN:%d, CAB:%d, UAPSD:%d, MGMT:%d, BE:%d, BK:%d, VI:%d, VO:%d\n", priv->wmi_cmd_ep, priv->beacon_ep, priv->cab_ep, priv->uapsd_ep, priv->mgmt_ep, priv->data_be_ep, priv->data_bk_ep, priv->data_vi_ep, priv->data_vo_ep); ath9k_hw_name(priv->ah, hw_name, sizeof(hw_name)); wiphy_info(hw->wiphy, "%s\n", hw_name); ath9k_init_leds(priv); <API key>(priv); return 0; err_world: <API key>(hw); err_register: ath9k_rx_cleanup(priv); err_rx: ath9k_tx_cleanup(priv); err_tx: /* Nothing */ err_regd: /* Nothing */ err_fw: ath9k_deinit_priv(priv); err_init: return error; } int <API key>(struct htc_target *htc_handle, struct device *dev, u16 devid, char *product, u32 drv_info) { struct ieee80211_hw *hw; struct ath9k_htc_priv *priv; int ret; hw = ieee80211_alloc_hw(sizeof(struct ath9k_htc_priv), &ath9k_htc_ops); if (!hw) return -ENOMEM; priv = hw->priv; priv->hw = hw; priv->htc = htc_handle; priv->dev = dev; htc_handle->drv_priv = priv; SET_IEEE80211_DEV(hw, priv->dev); ret = <API key>(priv); if (ret) goto err_free; priv->wmi = ath9k_init_wmi(priv); if (!priv->wmi) { ret = -EINVAL; goto err_free; } ret = <API key>(priv, devid, drv_info); if (ret) goto err_init; ret = ath9k_init_device(priv, devid, product, drv_info); if (ret) goto err_init; return 0; err_init: ath9k_deinit_wmi(priv); err_free: ieee80211_free_hw(hw); return ret; } void <API key>(struct htc_target *htc_handle, bool hotunplug) { if (htc_handle->drv_priv) { /* Check if the device has been yanked out. */ if (hotunplug) htc_handle->drv_priv->ah->ah_flags |= AH_UNPLUGGED; ath9k_deinit_device(htc_handle->drv_priv); ath9k_deinit_wmi(htc_handle->drv_priv); ieee80211_free_hw(htc_handle->drv_priv->hw); } } #ifdef CONFIG_PM void ath9k_htc_suspend(struct htc_target *htc_handle) { ath9k_htc_setpower(htc_handle->drv_priv, ATH9K_PM_FULL_SLEEP); } int ath9k_htc_resume(struct htc_target *htc_handle) { struct ath9k_htc_priv *priv = htc_handle->drv_priv; int ret; ret = <API key>(priv); if (ret) return ret; ret = <API key>(priv, priv->ah->hw_version.devid, priv->ah->hw_version.usbdev); return ret; } #endif static int __init ath9k_htc_init(void) { if (ath9k_hif_usb_init() < 0) { pr_err("No USB devices found, driver not installed\n"); return -ENODEV; } return 0; } module_init(ath9k_htc_init); static void __exit ath9k_htc_exit(void) { ath9k_hif_usb_exit(); pr_info("Driver unloaded\n"); } module_exit(ath9k_htc_exit);
.<API key> .leaflet-marker-icon, .<API key> .<API key> { -webkit-transition: -webkit-transform 0.2s ease-out, opacity 0.2s ease-in; -moz-transition: -moz-transform 0.2s ease-out, opacity 0.2s ease-in; -o-transition: -o-transform 0.2s ease-out, opacity 0.2s ease-in; transition: transform 0.2s ease-out, opacity 0.2s ease-in; }
-- Dragonblight Pathing - Moa'ki Harbor + Azure Dragonshrine -- 1. rndmmovement UPDATE `creature` SET `spawndist`=20 WHERE `guid` IN (106644, 106699, 106698, 106714, 106736, 131071, 106695, 106720); -- 2. emotes DELETE FROM `creature_addon` WHERE `guid` IN (109020, 109041); INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (109020,0,0,0,1,51, ''), (109041,0,0,0,1,51, ''); SET @NPC := 106347; SET @PATH := @NPC * 10; UPDATE `creature` SET `spawndist`=0,`MovementType`=2,`position_x`=3328.549,`position_y`=35.32029,`position_z`=68.77303 WHERE `guid`=@NPC; DELETE FROM `creature_addon` WHERE `guid`=@NPC; INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); DELETE FROM `waypoint_data` WHERE `id`=@PATH; INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES (@PATH,1,3328.549,35.32029,68.77303,0,0,0,0,100,0), (@PATH,2,3328.281,35.21631,68.51276,0,0,0,0,100,0), (@PATH,3,3328.231,35.3801,68.81226,0,0,0,0,100,0), (@PATH,4,3326.481,39.1301,69.56226,0,0,0,0,100,0), (@PATH,5,3324.981,42.3801,70.06226,0,0,0,0,100,0), (@PATH,6,3323.481,44.8801,70.56226,0,0,0,0,100,0), (@PATH,7,3323.24,45.35506,70.7541,0,0,0,0,100,0), (@PATH,8,3322.99,45.85506,70.7541,0,0,0,0,100,0), (@PATH,9,3321.24,48.35506,71.2541,0,0,0,0,100,0), (@PATH,10,3321.963,47.37666,71.00128,0,0,0,0,100,0), (@PATH,11,3322.048,47.26694,71.02554,0,0,0,0,100,0), (@PATH,12,3323.298,45.51694,70.77554,0,0,0,0,100,0), (@PATH,13,3324.798,42.01694,70.02554,0,0,0,0,100,0), (@PATH,14,3326.298,39.51694,69.52554,0,0,0,0,100,0); -- 4. foxus warlock emotes DELETE FROM `creature_addon` WHERE `guid` IN (114036, 114035, 114040, 114039, 114041, 114002, 114005, 114003, 113973, 113995, 114000, 113996, 113998, 114038, 113999); INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (114036,0,0,0,1,69, ''), (114035,0,0,0,1,69, ''), (114040,0,0,0,1,69, ''), (114039,0,0,0,1,69, ''), (114041,0,0,0,1,69, ''), (114002,0,0,0,1,69, ''), (114005,0,0,0,1,69, ''), (114003,0,0,0,1,69, ''), (113973,0,0,0,1,69, ''), (113995,0,0,0,1,69, ''), (114000,0,0,0,1,69, ''), (113996,0,0,0,1,69, ''), (113998,0,0,0,1,69, ''), (114038,0,0,0,1,69, ''), (113999,0,0,0,1,69, ''); -- 5. mage hunter emotes DELETE FROM `creature_addon` WHERE `guid` IN (111759, 111757, 111756, 111758, 111760, 111761, 111802, 111801, 111800); INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (111759,0,0,0,1,27, ''), (111757,0,0,0,1,27, ''), (111756,0,0,0,1,27, ''), (111758,0,0,0,1,27, ''), (111760,0,0,0,1,27, ''), (111761,0,0,0,1,27, ''), (111802,0,0,0,1,27, ''), (111801,0,0,0,1,27, ''), (111800,0,0,0,1,27, ''); -- 6. Beefwps SET @NPC := 111043; SET @PATH := @NPC * 10; UPDATE `creature` SET `spawndist`=0,`MovementType`=2,`position_x`=3357.819,`position_y`=518.5552,`position_z`=78.31688 WHERE `guid`=@NPC; UPDATE `creature` SET `spawndist`=0,`MovementType`=0,`position_x`=3357.819,`position_y`=518.5552,`position_z`=78.31688 WHERE `guid`=111211; DELETE FROM `creature_addon` WHERE `guid`=@NPC; INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); DELETE FROM `waypoint_data` WHERE `id`=@PATH; INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES (@PATH,1,3357.819,518.5552,78.31688,0,0,0,0,100,0), (@PATH,2,3364.319,524.5552,78.81688,0,0,0,0,100,0), (@PATH,3,3368.569,528.3052,79.31688,0,0,0,0,100,0), (@PATH,4,3375.445,534.399,79.33154,0,0,0,0,100,0), (@PATH,5,3391.695,551.649,78.83154,0,0,0,0,100,0), (@PATH,6,3395.945,555.899,78.08154,0,0,0,0,100,0), (@PATH,7,3406.195,566.649,77.58154,0,0,0,0,100,0), (@PATH,8,3407.308,568.47,77.32245,0,0,0,0,100,0), (@PATH,9,3395.808,585.72,78.07245,0,0,0,0,100,0), (@PATH,10,3393.808,588.97,78.32245,0,0,0,0,100,0), (@PATH,11,3388.808,596.47,79.07245,0,0,0,0,100,0), (@PATH,12,3384.558,603.22,79.57245,0,0,0,0,100,0), (@PATH,13,3384.328,603.3331,79.72012,0,0,0,0,100,0), (@PATH,14,3383.578,604.5831,79.97012,0,0,0,0,100,0), (@PATH,15,3372.078,617.0831,80.47012,0,0,0,0,100,0), (@PATH,16,3369.578,619.8331,80.97012,0,0,0,0,100,0), (@PATH,17,3354.531,636.454,81.09949,0,0,0,0,100,0), (@PATH,18,3352.031,648.204,81.84949,0,0,0,0,100,0), (@PATH,19,3351.031,654.954,82.09949,0,0,0,0,100,0), (@PATH,20,3347.781,671.454,82.84949,0,0,0,0,100,0), (@PATH,21,3347.66,671.6125,82.84419,0,0,0,0,100,0), (@PATH,22,3348.41,668.6125,82.09419,0,0,0,0,100,0), (@PATH,23,3350.16,658.8625,82.59419,0,0,0,0,100,0), (@PATH,24,3351.16,653.1125,82.09419,0,0,0,0,100,0), (@PATH,25,3352.91,644.3625,81.59419,0,0,0,0,100,0), (@PATH,26,3354.698,636.1382,80.88446,0,0,0,0,100,0), (@PATH,27,3371.948,617.3882,80.38446,0,0,0,0,100,0), (@PATH,28,3374.698,614.3882,79.88446,0,0,0,0,100,0), (@PATH,29,3383.664,604.2737,79.74067,0,0,0,0,100,0), (@PATH,30,3387.164,599.2737,79.24067,0,0,0,0,100,0), (@PATH,31,3393.164,590.0237,78.49067,0,0,0,0,100,0), (@PATH,32,3395.664,586.0237,77.99067,0,0,0,0,100,0), (@PATH,33,3398.414,582.0237,77.49067,0,0,0,0,100,0), (@PATH,34,3407.336,568.2035,77.34898,0,0,0,0,100,0), (@PATH,35,3404.086,564.4535,78.09898,0,0,0,0,100,0), (@PATH,36,3394.336,554.4535,78.59898,0,0,0,0,100,0), (@PATH,37,3389.836,549.4535,79.09898,0,0,0,0,100,0), (@PATH,38,3375.294,534.2694,79.25139,0,0,0,0,100,0), (@PATH,39,3365.794,525.7694,78.75139,0,0,0,0,100,0), (@PATH,40,3361.294,521.7694,78.25139,0,0,0,0,100,0), (@PATH,41,3357.338,518.4061,78.19955,0,0,0,0,100,0), (@PATH,42,3353.588,514.9061,78.94955,0,0,0,0,100,0), (@PATH,43,3349.838,511.6561,79.44955,0,0,0,0,100,0), (@PATH,44,3346.088,508.4061,80.19955,0,0,0,0,100,0), (@PATH,45,3343.338,505.9061,80.69955,0,0,0,0,100,0), (@PATH,46,3336.588,500.1561,81.19955,0,0,0,0,100,0), (@PATH,47,3331.361,495.4106,81.15448,0,0,0,0,100,0), (@PATH,48,3311.611,470.6606,80.40448,0,0,0,0,100,0), (@PATH,49,3308.507,466.9263,79.84391,0,0,0,0,100,0), (@PATH,50,3307.007,463.1763,79.34391,0,0,0,0,100,0), (@PATH,51,3304.757,457.6763,78.59391,0,0,0,0,100,0), (@PATH,52,3303.257,453.4263,78.09391,0,0,0,0,100,0), (@PATH,53,3300.507,446.9263,77.59391,0,0,0,0,100,0), (@PATH,54,3298.613,441.5379,76.93367,0,0,0,0,100,0), (@PATH,55,3303.113,424.2879,77.43367,0,0,0,0,100,0), (@PATH,56,3306.613,411.0379,76.93367,0,0,0,0,100,0), (@PATH,57,3307.363,408.0379,76.18367,0,0,0,0,100,0), (@PATH,58,3308.363,404.2879,75.93367,0,0,0,0,100,0), (@PATH,59,3307.172,408.4494,76.61504,0,0,0,0,100,0), (@PATH,60,3306.172,412.1994,77.36504,0,0,0,0,100,0), (@PATH,61,3298.596,441.697,77.28619,0,0,0,0,100,0), (@PATH,62,3301.596,449.197,77.78619,0,0,0,0,100,0), (@PATH,63,3303.596,454.447,78.28619,0,0,0,0,100,0), (@PATH,64,3305.346,459.197,78.78619,0,0,0,0,100,0), (@PATH,65,3307.346,463.947,79.53619,0,0,0,0,100,0), (@PATH,66,3308.805,467.3031,80.26054,0,0,0,0,100,0), (@PATH,67,3312.055,471.0531,80.76054,0,0,0,0,100,0), (@PATH,68,3318.305,479.0531,81.26054,0,0,0,0,100,0); DELETE FROM `creature_formations` WHERE `leaderGUID`=111043; INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`, `point_1`, `point_2`) VALUES (111043, 111043, 0, 0, 2, 0, 0), (111043, 111211, 7, 0, 0, 0, 0); -- 7. casting emotes gnomes DELETE FROM `creature_addon` WHERE `guid` IN (109040, 109039); INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (109040,0,0,0,1,51, ''), (109039,0,0,0,1,51, ''); -- 8. Attackemotes for hunter + warlocks (all 3 caves) DELETE FROM `creature_addon` WHERE `guid` IN (111789, 111827, 114030, 111796, 111811, 111813, 114029, 111834, 114069, 111812, 114049, 111750, 113966, 111768, 111766, 114010, 111770, 114008, 111769, 111767, 114009, 111734, 111779, 114020, 111776, 111774, 111775, 111747, 111754, 111755, 111753, 113951, 113968, 113969, 113964, 111717, 113967, 111735, 113970, 111728, 113940, 113965, 114006, 111727, 111743, 111763, 111764); INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (111789, 0,0,0,1,27, ''), (111827, 0,0,0,1,27, ''), (114030, 0,0,0,1,27, ''), (111796, 0,0,0,1,27, ''), (111811, 0,0,0,1,27, ''), (111813, 0,0,0,1,27, ''), (114029, 0,0,0,1,27, ''), (111834, 0,0,0,1,27, ''), (114069, 0,0,0,1,27, ''), (111812, 0,0,0,1,27, ''), (114049, 0,0,0,1,27, ''), (111750, 0,0,0,1,27, ''), (113966, 0,0,0,1,27, ''), (111768, 0,0,0,1,27, ''), (111766, 0,0,0,1,27, ''), (114010, 0,0,0,1,27, ''), (111770, 0,0,0,1,27, ''), (114008, 0,0,0,1,27, ''), (111769, 0,0,0,1,27, ''), (111767, 0,0,0,1,27, ''), (114009, 0,0,0,1,27, ''), (111734, 0,0,0,1,27, ''), (111779, 0,0,0,1,27, ''), (114020, 0,0,0,1,27, ''), (111776, 0,0,0,1,27, ''), (111774, 0,0,0,1,27, ''), (111775, 0,0,0,1,27, ''), (111747, 0,0,0,1,27, ''), (111754, 0,0,0,1,27, ''), (111755, 0,0,0,1,27, ''), (111753, 0,0,0,1,27, ''), (113951, 0,0,0,1,27, ''), (113968, 0,0,0,1,27, ''), (113969, 0,0,0,1,27, ''), (113964, 0,0,0,1,27, ''), (111717, 0,0,0,1,27, ''), (113967, 0,0,0,1,27, ''), (111735, 0,0,0,1,27, ''), (113970, 0,0,0,1,27, ''), (111728, 0,0,0,1,27, ''), (113940, 0,0,0,1,27, ''), (113965, 0,0,0,1,27, ''), (114006, 0,0,0,1,27, ''), (111727, 0,0,0,1,27, ''), (111743, 0,0,0,1,27, ''), (111763, 0,0,0,1,27, ''), (111764,0,0,0,1,27, ''); -- 9. Moa'ki Warrior SET @NPC := 99801; SET @PATH := @NPC * 10; UPDATE `creature` SET `spawndist`=0,`MovementType`=2,`position_x`=2942.45,`position_y`=874.4968,`position_z`=35.30196 WHERE `guid`=@NPC; UPDATE `creature` SET `spawndist`=0,`MovementType`=0,`position_x`=2942.45,`position_y`=874.4968,`position_z`=35.30196 WHERE `guid`=99802; DELETE FROM `creature_addon` WHERE `guid`=@NPC; INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); DELETE FROM `waypoint_data` WHERE `id`=@PATH; INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES (@PATH,1,2942.45,874.4968,35.30196,0,0,0,0,100,0), (@PATH,2,2940.95,874.7468,35.05196,0,0,0,0,100,0), (@PATH,3,2938.95,874.4968,34.55196,0,0,0,0,100,0), (@PATH,4,2935.95,873.9968,33.55196,0,0,0,0,100,0), (@PATH,5,2934.2,873.7468,33.05196,0,0,0,0,100,0), (@PATH,6,2932.45,873.4968,32.55196,0,0,0,0,100,0), (@PATH,7,2929.45,873.2468,31.80196,0,0,0,0,100,0), (@PATH,8,2926.45,872.9968,31.05196,0,0,0,0,100,0), (@PATH,9,2923.45,872.4968,30.05196,0,0,0,0,100,0), (@PATH,10,2923.197,872.4724,29.89659,0,0,0,0,100,0), (@PATH,11,2921.197,872.2224,29.39659,0,0,0,0,100,0), (@PATH,12,2919.197,871.7224,28.89659,0,0,0,0,100,0), (@PATH,13,2916.447,870.9724,28.14659,0,0,0,0,100,0), (@PATH,14,2914.447,870.4724,27.39659,0,0,0,0,100,0), (@PATH,15,2910.697,869.9724,26.89659,0,0,0,0,100,0), (@PATH,16,2907.697,869.2224,26.14659,0,0,0,0,100,0), (@PATH,17,2904.947,868.4724,25.64659,0,0,0,0,100,0), (@PATH,18,2902.995,868.2098,24.81467,0,0,0,0,100,0), (@PATH,19,2899.995,868.9598,24.31467,0,0,0,0,100,0), (@PATH,20,2896.245,869.9598,23.56467,0,0,0,0,100,0), (@PATH,21,2893.495,870.7098,23.06467,0,0,0,0,100,0), (@PATH,22,2890.495,871.4598,22.56467,0,0,0,0,100,0), (@PATH,23,2885.745,872.7098,21.81467,0,0,0,0,100,0), (@PATH,24,2885.609,872.7776,21.46217,0,0,0,0,100,0), (@PATH,25,2884.109,873.2776,21.21217,0,0,0,0,100,0), (@PATH,26,2880.109,873.2776,20.71217,0,0,0,0,100,0), (@PATH,27,2873.359,873.2776,20.21217,0,0,0,0,100,0), (@PATH,28,2868.175,873.5178,19.47064,0,0,0,0,100,0), (@PATH,29,2860.175,880.7678,18.97064,0,0,0,0,100,0), (@PATH,30,2857.271,883.4542,18.24871,0,0,0,0,100,0), (@PATH,31,2851.021,886.2042,17.74871,0,0,0,0,100,0), (@PATH,32,2843.771,889.4542,17.24871,0,0,0,0,100,0), (@PATH,33,2843.393,889.6986,17.05721,0,0,0,0,100,0), (@PATH,34,2842.643,889.9486,17.05721,0,0,0,0,100,0), (@PATH,35,2836.893,892.1986,16.30721,0,0,0,0,100,0), (@PATH,36,2829.259,895.6682,16.03611,0,0,0,0,100,0), (@PATH,37,2826.259,899.6682,16.78611,0,0,0,0,100,0), (@PATH,38,2824.759,901.9182,17.28611,0,0,0,0,100,0), (@PATH,39,2823.009,904.1682,18.03611,0,0,0,0,100,0), (@PATH,40,2820.759,907.4182,18.78611,0,0,0,0,100,0), (@PATH,41,2818.548,910.2606,19.6723,0,0,0,0,100,0), (@PATH,42,2815.048,912.5106,20.1723,0,0,0,0,100,0), (@PATH,43,2811.798,914.5106,20.4223,0,0,0,0,100,0), (@PATH,44,2807.798,917.0106,21.1723,0,0,0,0,100,0), (@PATH,45,2804.548,919.2606,21.9223,0,0,0,0,100,0), (@PATH,46,2804.113,919.4464,22.19062,0,0,0,0,100,0), (@PATH,47,2802.863,920.4464,22.19062,0,0,0,0,100,0), (@PATH,48,2802.113,936.1964,22.69062,0,0,0,0,100,0), (@PATH,49,2801.614,942.2058,22.90605,0,0,0,0,100,0), (@PATH,50,2794.46,955.9167,22.82833,0,0,0,0,100,0), (@PATH,51,2789.868,969.0771,22.71787,0,0,0,0,100,0), (@PATH,52,2789.86,968.7522,22.44791,0,0,0,0,100,0), (@PATH,53,2790.052,968.7579,22.57249,0,0,0,0,100,0), (@PATH,54,2794.692,955.4985,22.95527,0,0,0,0,100,0), (@PATH,55,2801.604,942.0818,22.84189,0,0,0,0,100,0), (@PATH,56,2802.354,929.3318,22.34189,0,0,0,0,100,0), (@PATH,57,2803.029,920.1268,22.10619,0,0,0,0,100,0), (@PATH,58,2807.279,917.3768,21.60619,0,0,0,0,100,0), (@PATH,59,2809.779,916.1268,20.85619,0,0,0,0,100,0), (@PATH,60,2813.779,913.3768,20.35619,0,0,0,0,100,0), (@PATH,61,2817.029,911.3768,19.85619,0,0,0,0,100,0), (@PATH,62,2817.245,910.9927,19.40564,0,0,0,0,100,0), (@PATH,63,2818.745,909.9927,19.40564,0,0,0,0,100,0), (@PATH,64,2820.995,906.7427,18.40564,0,0,0,0,100,0), (@PATH,65,2823.245,903.7427,17.65564,0,0,0,0,100,0), (@PATH,66,2825.495,900.7427,17.15564,0,0,0,0,100,0), (@PATH,67,2827.245,898.2427,16.65564,0,0,0,0,100,0), (@PATH,68,2827.63,897.9916,16.59999,0,0,0,0,100,0), (@PATH,69,2829.38,895.2416,16.09999,0,0,0,0,100,0), (@PATH,70,2839.38,891.2416,16.59999,0,0,0,0,100,0), (@PATH,71,2842.658,889.7286,17.27651,0,0,0,0,100,0), (@PATH,72,2849.908,886.7286,17.52651,0,0,0,0,100,0), (@PATH,73,2855.408,884.2286,18.27651,0,0,0,0,100,0), (@PATH,74,2857.304,883.3358,18.64834,0,0,0,0,100,0), (@PATH,75,2861.054,879.8358,18.89834,0,0,0,0,100,0), (@PATH,76,2868.077,873.4034,19.59505,0,0,0,0,100,0), (@PATH,77,2874.077,873.4034,20.09505,0,0,0,0,100,0), (@PATH,78,2879.827,873.4034,20.59505,0,0,0,0,100,0), (@PATH,79,2884.046,873.29,21.49246,0,0,0,0,100,0), (@PATH,80,2888.046,872.04,22.24246,0,0,0,0,100,0), (@PATH,81,2892.546,870.79,22.74246,0,0,0,0,100,0), (@PATH,82,2895.546,870.29,23.24246,0,0,0,0,100,0), (@PATH,83,2898.296,869.54,23.99246,0,0,0,0,100,0), (@PATH,84,2901.296,868.54,24.49246,0,0,0,0,100,0), (@PATH,85,2901.368,868.5389,24.78852,0,0,0,0,100,0), (@PATH,86,2903.118,868.0389,25.03852,0,0,0,0,100,0), (@PATH,87,2906.118,868.7889,25.53852,0,0,0,0,100,0), (@PATH,88,2908.868,869.5389,26.28852,0,0,0,0,100,0), (@PATH,89,2911.618,870.2889,26.78852,0,0,0,0,100,0), (@PATH,90,2915.618,870.7889,27.53852,0,0,0,0,100,0), (@PATH,91,2917.618,871.2889,28.28852,0,0,0,0,100,0), (@PATH,92,2920.368,872.0389,29.03852,0,0,0,0,100,0), (@PATH,93,2920.589,872.1874,29.30408,0,0,0,0,100,0), (@PATH,94,2921.339,872.4374,29.55408,0,0,0,0,100,0), (@PATH,95,2924.339,872.6874,30.55408,0,0,0,0,100,0), (@PATH,96,2927.339,873.1874,31.30408,0,0,0,0,100,0), (@PATH,97,2930.089,873.1874,31.80408,0,0,0,0,100,0), (@PATH,98,2933.089,873.6874,32.80408,0,0,0,0,100,0), (@PATH,99,2935.089,873.9374,33.30408,0,0,0,0,100,0), (@PATH,100,2937.089,874.1874,34.05408,0,0,0,0,100,0), (@PATH,101,2940.089,874.6874,34.80408,0,0,0,0,100,0), (@PATH,102,2940.357,874.6572,35.2282,0,0,0,0,100,0), (@PATH,103,2941.357,874.6572,35.4782,0,0,0,0,100,0), (@PATH,104,2944.357,874.4072,36.2282,0,0,0,0,100,0), (@PATH,105,2947.357,874.1572,36.7282,0,0,0,0,100,0), (@PATH,106,2949.107,873.9072,37.4782,0,0,0,0,100,0), (@PATH,107,2953.107,873.9072,38.2282,0,0,0,0,100,0), (@PATH,108,2955.857,873.6572,38.9782,0,0,0,0,100,0), (@PATH,109,2953.459,873.7681,38.4597,0,0,0,0,100,0); DELETE FROM `creature_formations` WHERE `leaderGUID`=99801; INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`, `point_1`, `point_2`) VALUES (99801, 99801, 0, 0, 2, 0, 0), (99801, 99802, 3, 90, 2, 0, 0); UPDATE `smart_scripts` SET `action_param1`=1 WHERE `entryorguid`=27178 AND `source_type`=0 AND `id`=0 AND `link`=1; -- 10. Moa'ki Warrior SET @NPC := 99815; SET @PATH := @NPC * 10; UPDATE `creature` SET `spawndist`=0,`MovementType`=2,`position_x`=2734.04,`position_y`=908.0725,`position_z`=3.249194 WHERE `guid`=@NPC; UPDATE `creature` SET `spawndist`=0,`MovementType`=0,`position_x`=2734.04,`position_y`=908.0725,`position_z`=3.249194 WHERE `guid`=99814; DELETE FROM `creature_addon` WHERE `guid`=@NPC; INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); DELETE FROM `waypoint_data` WHERE `id`=@PATH; INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES (@PATH,1,2734.04,908.0725,3.249194,0,0,0,0,100,0), (@PATH,2,2736.54,905.0725,3.749194,0,0,0,0,100,0), (@PATH,3,2739.04,901.8225,4.249194,0,0,0,0,100,0), (@PATH,4,2740.54,899.8225,4.749194,0,0,0,0,100,0), (@PATH,5,2743.79,895.8225,5.249194,0,0,0,0,100,0), (@PATH,6,2746.789,892.0921,5.316426,0,0,0,0,100,0), (@PATH,7,2765.288,879.248,5.514341,0,0,0,0,100,0), (@PATH,8,2788.071,876.0192,5.926539,0,0,0,0,100,0), (@PATH,9,2796.821,876.0192,6.676539,0,0,0,0,100,0), (@PATH,10,2802.821,876.0192,6.926539,0,0,0,0,100,0), (@PATH,11,2806.821,875.7692,7.676539,0,0,0,0,100,0), (@PATH,12,2806.909,875.7591,7.908364,0,0,0,0,100,0), (@PATH,13,2807.659,875.7591,8.158364,0,0,0,0,100,0), (@PATH,14,2810.159,877.7591,8.658364,0,0,0,0,100,0), (@PATH,15,2812.159,879.5091,9.158364,0,0,0,0,100,0), (@PATH,16,2813.909,880.5091,9.908364,0,0,0,0,100,0), (@PATH,17,2816.159,882.2591,10.65836,0,0,0,0,100,0), (@PATH,18,2817.659,883.5091,11.40836,0,0,0,0,100,0), (@PATH,19,2816.375,882.6917,10.97033,0,0,0,0,100,0), (@PATH,20,2818.125,883.9417,11.72033,0,0,0,0,100,0), (@PATH,21,2818.875,884.6917,11.72033,0,0,0,0,100,0), (@PATH,22,2820.375,885.9417,12.72033,0,0,0,0,100,0), (@PATH,23,2821.375,887.4417,12.97033,0,0,0,0,100,0), (@PATH,24,2822.875,888.6917,13.72033,0,0,0,0,100,0), (@PATH,25,2824.125,890.1917,14.47033,0,0,0,0,100,0), (@PATH,26,2825.375,891.6917,15.22033,0,0,0,0,100,0), (@PATH,27,2824.66,890.6411,14.79578,0,0,0,0,100,0), (@PATH,28,2823.16,889.3911,14.04578,0,0,0,0,100,0), (@PATH,29,2821.41,887.3911,13.29578,0,0,0,0,100,0), (@PATH,30,2818.638,884.2707,11.69823,0,0,0,0,100,0), (@PATH,31,2816.388,882.5207,10.69823,0,0,0,0,100,0), (@PATH,32,2813.888,880.7707,9.948226,0,0,0,0,100,0), (@PATH,33,2812.638,879.5207,9.448226,0,0,0,0,100,0), (@PATH,34,2810.388,877.7707,8.698226,0,0,0,0,100,0), (@PATH,35,2807.556,875.8849,7.826558,0,0,0,0,100,0), (@PATH,36,2803.556,876.1349,7.076558,0,0,0,0,100,0), (@PATH,37,2798.556,876.1349,6.826558,0,0,0,0,100,0), (@PATH,38,2790.806,876.3849,6.076558,0,0,0,0,100,0), (@PATH,39,2790.671,876.3419,5.86481,0,0,0,0,100,0), (@PATH,40,2787.671,876.3419,5.86481,0,0,0,0,100,0), (@PATH,41,2764.954,879.5082,5.60566,0,0,0,0,100,0), (@PATH,42,2746.52,892.532,5.507929,0,0,0,0,100,0), (@PATH,43,2741.77,898.782,4.757929,0,0,0,0,100,0), (@PATH,44,2739.27,901.532,4.257929,0,0,0,0,100,0), (@PATH,45,2736.77,904.782,3.757929,0,0,0,0,100,0), (@PATH,46,2734.27,907.782,3.257929,0,0,0,0,100,0), (@PATH,47,2733.933,908.0688,3.006025,0,0,0,0,100,0), (@PATH,48,2733.683,908.3188,3.006025,0,0,0,0,100,0), (@PATH,49,2732.933,911.3188,2.256025,0,0,0,0,100,0), (@PATH,50,2732.183,914.3188,1.756025,0,0,0,0,100,0), (@PATH,51,2731.183,918.8188,1.256025,0,0,0,0,100,0), (@PATH,52,2728.75,928.4617,0.6681505,0,0,0,0,100,0), (@PATH,53,2731.75,918.9617,1.418151,0,0,0,0,100,0), (@PATH,54,2732.5,915.2117,1.668151,0,0,0,0,100,0); DELETE FROM `creature_formations` WHERE `leaderGUID`=99815; INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`, `point_1`, `point_2`) VALUES (99815, 99815, 0, 0, 2, 0, 0), (99815, 99814, 3, 90, 2, 0, 0);
// MESSAGE RADIO_STATUS PACKING #define <API key> 109 typedef struct <API key> { uint16_t rxerrors; ///< Receive errors uint16_t fixed; ///< Count of error corrected packets uint8_t rssi; ///< Local signal strength uint8_t remrssi; ///< Remote signal strength uint8_t txbuf; ///< Remaining free buffer space in percent. uint8_t noise; ///< Background noise level uint8_t remnoise; ///< Remote background noise level } <API key>; #define <API key> 9 #define <API key> 9 #define <API key> 185 #define <API key> 185 #define <API key> { \ "RADIO_STATUS", \ 7, \ { { "rxerrors", NULL, <API key>, 0, 0, offsetof(<API key>, rxerrors) }, \ { "fixed", NULL, <API key>, 0, 2, offsetof(<API key>, fixed) }, \ { "rssi", NULL, <API key>, 0, 4, offsetof(<API key>, rssi) }, \ { "remrssi", NULL, <API key>, 0, 5, offsetof(<API key>, remrssi) }, \ { "txbuf", NULL, <API key>, 0, 6, offsetof(<API key>, txbuf) }, \ { "noise", NULL, <API key>, 0, 7, offsetof(<API key>, noise) }, \ { "remnoise", NULL, <API key>, 0, 8, offsetof(<API key>, remnoise) }, \ } \ } /** * @brief Pack a radio_status message * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * * @param rssi Local signal strength * @param remrssi Remote signal strength * @param txbuf Remaining free buffer space in percent. * @param noise Background noise level * @param remnoise Remote background noise level * @param rxerrors Receive errors * @param fixed Count of error corrected packets * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t <API key>(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) { #if <API key> || !<API key> char buf[<API key>]; _mav_put_uint16_t(buf, 0, rxerrors); _mav_put_uint16_t(buf, 2, fixed); _mav_put_uint8_t(buf, 4, rssi); _mav_put_uint8_t(buf, 5, remrssi); _mav_put_uint8_t(buf, 6, txbuf); _mav_put_uint8_t(buf, 7, noise); _mav_put_uint8_t(buf, 8, remnoise); memcpy(<API key>(msg), buf, <API key>); #else <API key> packet; packet.rxerrors = rxerrors; packet.fixed = fixed; packet.rssi = rssi; packet.remrssi = remrssi; packet.txbuf = txbuf; packet.noise = noise; packet.remnoise = remnoise; memcpy(<API key>(msg), &packet, <API key>); #endif msg->msgid = <API key>; #if MAVLINK_CRC_EXTRA return <API key>(msg, system_id, component_id, <API key>, <API key>); #else return <API key>(msg, system_id, component_id, <API key>); #endif } /** * @brief Pack a radio_status message on a channel * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message will be sent over * @param msg The MAVLink message to compress the data into * @param rssi Local signal strength * @param remrssi Remote signal strength * @param txbuf Remaining free buffer space in percent. * @param noise Background noise level * @param remnoise Remote background noise level * @param rxerrors Receive errors * @param fixed Count of error corrected packets * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t <API key>(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t rssi,uint8_t remrssi,uint8_t txbuf,uint8_t noise,uint8_t remnoise,uint16_t rxerrors,uint16_t fixed) { #if <API key> || !<API key> char buf[<API key>]; _mav_put_uint16_t(buf, 0, rxerrors); _mav_put_uint16_t(buf, 2, fixed); _mav_put_uint8_t(buf, 4, rssi); _mav_put_uint8_t(buf, 5, remrssi); _mav_put_uint8_t(buf, 6, txbuf); _mav_put_uint8_t(buf, 7, noise); _mav_put_uint8_t(buf, 8, remnoise); memcpy(<API key>(msg), buf, <API key>); #else <API key> packet; packet.rxerrors = rxerrors; packet.fixed = fixed; packet.rssi = rssi; packet.remrssi = remrssi; packet.txbuf = txbuf; packet.noise = noise; packet.remnoise = remnoise; memcpy(<API key>(msg), &packet, <API key>); #endif msg->msgid = <API key>; #if MAVLINK_CRC_EXTRA return <API key>(msg, system_id, component_id, chan, <API key>, <API key>); #else return <API key>(msg, system_id, component_id, chan, <API key>); #endif } /** * @brief Encode a radio_status struct * * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * @param radio_status C-struct to read the message contents from */ static inline uint16_t <API key>(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const <API key>* radio_status) { return <API key>(system_id, component_id, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed); } /** * @brief Encode a radio_status struct on a channel * * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message will be sent over * @param msg The MAVLink message to compress the data into * @param radio_status C-struct to read the message contents from */ static inline uint16_t <API key>(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const <API key>* radio_status) { return <API key>(system_id, component_id, chan, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed); } /** * @brief Send a radio_status message * @param chan MAVLink channel to send the message * * @param rssi Local signal strength * @param remrssi Remote signal strength * @param txbuf Remaining free buffer space in percent. * @param noise Background noise level * @param remnoise Remote background noise level * @param rxerrors Receive errors * @param fixed Count of error corrected packets */ #ifdef <API key> static inline void <API key>(mavlink_channel_t chan, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) { #if <API key> || !<API key> char buf[<API key>]; _mav_put_uint16_t(buf, 0, rxerrors); _mav_put_uint16_t(buf, 2, fixed); _mav_put_uint8_t(buf, 4, rssi); _mav_put_uint8_t(buf, 5, remrssi); _mav_put_uint8_t(buf, 6, txbuf); _mav_put_uint8_t(buf, 7, noise); _mav_put_uint8_t(buf, 8, remnoise); #if MAVLINK_CRC_EXTRA <API key>(chan, <API key>, buf, <API key>, <API key>); #else <API key>(chan, <API key>, buf, <API key>); #endif #else <API key> packet; packet.rxerrors = rxerrors; packet.fixed = fixed; packet.rssi = rssi; packet.remrssi = remrssi; packet.txbuf = txbuf; packet.noise = noise; packet.remnoise = remnoise; #if MAVLINK_CRC_EXTRA <API key>(chan, <API key>, (const char *)&packet, <API key>, <API key>); #else <API key>(chan, <API key>, (const char *)&packet, <API key>); #endif #endif } #if <API key> <= <API key> /* This varient of _send() can be used to save stack space by re-using memory from the receive buffer. The caller provides a mavlink_message_t which is the size of a full mavlink message. This is usually the receive buffer for the channel, and allows a reply to an incoming message with minimum stack space usage. */ static inline void <API key>(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) { #if <API key> || !<API key> char *buf = (char *)msgbuf; _mav_put_uint16_t(buf, 0, rxerrors); _mav_put_uint16_t(buf, 2, fixed); _mav_put_uint8_t(buf, 4, rssi); _mav_put_uint8_t(buf, 5, remrssi); _mav_put_uint8_t(buf, 6, txbuf); _mav_put_uint8_t(buf, 7, noise); _mav_put_uint8_t(buf, 8, remnoise); #if MAVLINK_CRC_EXTRA <API key>(chan, <API key>, buf, <API key>, <API key>); #else <API key>(chan, <API key>, buf, <API key>); #endif #else <API key> *packet = (<API key> *)msgbuf; packet->rxerrors = rxerrors; packet->fixed = fixed; packet->rssi = rssi; packet->remrssi = remrssi; packet->txbuf = txbuf; packet->noise = noise; packet->remnoise = remnoise; #if MAVLINK_CRC_EXTRA <API key>(chan, <API key>, (const char *)packet, <API key>, <API key>); #else <API key>(chan, <API key>, (const char *)packet, <API key>); #endif #endif } #endif #endif // MESSAGE RADIO_STATUS UNPACKING /** * @brief Get field rssi from radio_status message * * @return Local signal strength */ static inline uint8_t <API key>(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 4); } /** * @brief Get field remrssi from radio_status message * * @return Remote signal strength */ static inline uint8_t <API key>(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 5); } /** * @brief Get field txbuf from radio_status message * * @return Remaining free buffer space in percent. */ static inline uint8_t <API key>(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 6); } /** * @brief Get field noise from radio_status message * * @return Background noise level */ static inline uint8_t <API key>(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 7); } /** * @brief Get field remnoise from radio_status message * * @return Remote background noise level */ static inline uint8_t <API key>(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 8); } /** * @brief Get field rxerrors from radio_status message * * @return Receive errors */ static inline uint16_t <API key>(const mavlink_message_t* msg) { return <API key>(msg, 0); } /** * @brief Get field fixed from radio_status message * * @return Count of error corrected packets */ static inline uint16_t <API key>(const mavlink_message_t* msg) { return <API key>(msg, 2); } /** * @brief Decode a radio_status message into a struct * * @param msg The message to decode * @param radio_status C-struct to decode the message contents into */ static inline void <API key>(const mavlink_message_t* msg, <API key>* radio_status) { #if <API key> radio_status->rxerrors = <API key>(msg); radio_status->fixed = <API key>(msg); radio_status->rssi = <API key>(msg); radio_status->remrssi = <API key>(msg); radio_status->txbuf = <API key>(msg); radio_status->noise = <API key>(msg); radio_status->remnoise = <API key>(msg); #else memcpy(radio_status, _MAV_PAYLOAD(msg), <API key>); #endif }
extern "C" { #include <stdlib.h> #include <string.h> #include <inttypes.h> #include "twi.h" } #include "Wire.h" // Initialize Class Variables ////////////////////////////////////////////////// uint8_t TwoWire::rxBuffer[BUFFER_LENGTH]; uint8_t TwoWire::rxBufferIndex = 0; uint8_t TwoWire::rxBufferLength = 0; uint8_t TwoWire::txAddress = 0; uint8_t TwoWire::txBuffer[BUFFER_LENGTH]; uint8_t TwoWire::txBufferIndex = 0; uint8_t TwoWire::txBufferLength = 0; uint8_t TwoWire::transmitting = 0; void (*TwoWire::user_onRequest)(void); void (*TwoWire::user_onReceive)(int); // Constructors //////////////////////////////////////////////////////////////// TwoWire::TwoWire() { } // Public Methods ////////////////////////////////////////////////////////////// void TwoWire::begin(void) { rxBufferIndex = 0; rxBufferLength = 0; txBufferIndex = 0; txBufferLength = 0; twi_init(); } void TwoWire::begin(uint8_t address) { twi_setAddress(address); <API key>(onRequestService); <API key>(onReceiveService); begin(); } void TwoWire::begin(int address) { begin((uint8_t)address); } uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) { // clamp to buffer length if(quantity > BUFFER_LENGTH){ quantity = BUFFER_LENGTH; } // perform blocking read into buffer uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop); // set rx buffer iterator vars rxBufferIndex = 0; rxBufferLength = read; return read; } uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) { return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true); } uint8_t TwoWire::requestFrom(int address, int quantity) { return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true); } uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) { return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop); } void TwoWire::beginTransmission(uint8_t address) { // indicate that we are transmitting transmitting = 1; // set address of targeted slave txAddress = address; // reset tx buffer iterator vars txBufferIndex = 0; txBufferLength = 0; } void TwoWire::beginTransmission(int address) { beginTransmission((uint8_t)address); } // Originally, 'endTransmission' was an f(void) function. // It has been modified to take one parameter indicating // whether or not a STOP should be performed on the bus. // Calling endTransmission(false) allows a sketch to // perform a repeated start. // WARNING: Nothing in the library keeps track of whether // the bus tenure has been properly ended with a STOP. It // is very possible to leave the bus in a hung state if // no call to endTransmission(true) is made. Some I2C // devices will behave oddly if they do not see a STOP. uint8_t TwoWire::endTransmission(uint8_t sendStop) { // transmit buffer (blocking) int8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1, sendStop); // reset tx buffer iterator vars txBufferIndex = 0; txBufferLength = 0; // indicate that we are done transmitting transmitting = 0; return ret; } // This provides backwards compatibility with the original // definition, and expected behaviour, of endTransmission uint8_t TwoWire::endTransmission(void) { return endTransmission(true); } // must be called in: // slave tx event callback // or after beginTransmission(address) size_t TwoWire::write(uint8_t data) { if(transmitting){ // in master transmitter mode // don't bother if buffer is full if(txBufferLength >= BUFFER_LENGTH){ setWriteError(); return 0; } // put byte in tx buffer txBuffer[txBufferIndex] = data; ++txBufferIndex; // update amount in buffer txBufferLength = txBufferIndex; }else{ // in slave send mode // reply to master twi_transmit(&data, 1); } return 1; } // must be called in: // slave tx event callback // or after beginTransmission(address) size_t TwoWire::write(const uint8_t *data, size_t quantity) { if(transmitting){ // in master transmitter mode for(size_t i = 0; i < quantity; ++i){ write(data[i]); } }else{ // in slave send mode // reply to master twi_transmit(data, quantity); } return quantity; } // must be called in: // slave rx event callback // or after requestFrom(address, numBytes) int TwoWire::available(void) { return rxBufferLength - rxBufferIndex; } // must be called in: // slave rx event callback // or after requestFrom(address, numBytes) int TwoWire::read(void) { int value = -1; // get each successive byte on each call if(rxBufferIndex < rxBufferLength){ value = rxBuffer[rxBufferIndex]; ++rxBufferIndex; } return value; } // must be called in: // slave rx event callback // or after requestFrom(address, numBytes) int TwoWire::peek(void) { int value = -1; if(rxBufferIndex < rxBufferLength){ value = rxBuffer[rxBufferIndex]; } return value; } void TwoWire::flush(void) { // XXX: to be implemented. } // behind the scenes function that is called when data is received void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes) { // don't bother if user hasn't registered a callback if(!user_onReceive){ return; } // don't bother if rx buffer is in use by a master requestFrom() op // i know this drops data, but it allows for slight stupidity // meaning, they may not have read all the master requestFrom() data yet if(rxBufferIndex < rxBufferLength){ return; } // copy twi rx buffer into local read buffer // this enables new reads to happen in parallel for(uint8_t i = 0; i < numBytes; ++i){ rxBuffer[i] = inBytes[i]; } // set rx iterator vars rxBufferIndex = 0; rxBufferLength = numBytes; // alert user program user_onReceive(numBytes); } // behind the scenes function that is called when data is requested void TwoWire::onRequestService(void) { // don't bother if user hasn't registered a callback if(!user_onRequest){ return; } // reset tx buffer iterator vars // !!! this will kill any pending pre-master sendTo() activity txBufferIndex = 0; txBufferLength = 0; // alert user program user_onRequest(); } // sets function called on slave write void TwoWire::onReceive( void (*function)(int) ) { user_onReceive = function; } // sets function called on slave read void TwoWire::onRequest( void (*function)(void) ) { user_onRequest = function; } // Preinstantiate Objects ////////////////////////////////////////////////////// TwoWire Wire = TwoWire();
#ifndef <API key> #define <API key> extern struct sys_timer shmobile_timer; extern void <API key>(void); struct clk; extern int clk_init(void); extern void sh7367_init_irq(void); extern void <API key>(void); extern void <API key>(void); extern void sh7367_clock_init(void); extern void sh7367_pinmux_init(void); extern struct clk sh7367_extalb1_clk; extern struct clk sh7367_extal2_clk; extern void sh7377_init_irq(void); extern void <API key>(void); extern void <API key>(void); extern void sh7377_clock_init(void); extern void sh7377_pinmux_init(void); extern struct clk sh7377_extalc1_clk; extern struct clk sh7377_extal2_clk; extern void sh7372_init_irq(void); extern void <API key>(void); extern void <API key>(void); extern void sh7372_clock_init(void); extern void sh7372_pinmux_init(void); extern struct clk sh7372_extal1_clk; extern struct clk sh7372_extal2_clk; #endif /* <API key> */
<!DOCTYPE HTML PUBLIC "- <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>amCharts Data Loader Example</title> <script src="http: <script src="http: <script src="../dataloader.min.js"></script> <style> body, html { font-family: Verdana; font-size: 12px; } #chartdiv { width: 100%; height: 500px; } </style> <script> AmCharts.makeChart("chartdiv", { "type": "pie", "dataLoader": { "url": "data/pie.csv", "format": "csv", "delimiter": ",", "useColumnNames": true }, "titleField": "country", "valueField": "litres", "balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>", "innerRadius": "30%", "legend": { "align": "center", "markerType": "circle" }, "responsive": { "enabled": true, "addDefaultRules": true, "rules": [ { "minWidth": 500, "overrides": { "innerRadius": "50%", } } ] } }); </script> </head> <body> <div id="chartdiv"></div> </body> </html>
#ifndef __NET_TC_MIR_H #define __NET_TC_MIR_H #include <net/act_api.h> struct tcf_mirred { struct tcf_common common; int tcfm_eaction; int tcfm_ifindex; int tcfm_ok_push; struct net_device *tcfm_dev; struct list_head tcfm_list; }; #define to_mirred(pc) \ container_of(pc, struct tcf_mirred, common) #endif /* __NET_TC_MIR_H */
// Use of this source code is governed by a BSD-style package main import ( "go/ast" "go/parser" "go/token" "os" "path" "runtime" "strings" ) func isGoFile(dir os.FileInfo) bool { return !dir.IsDir() && !strings.HasPrefix(dir.Name(), ".") && // ignore .files path.Ext(dir.Name()) == ".go" } func isPkgFile(dir os.FileInfo) bool { return isGoFile(dir) && !strings.HasSuffix(dir.Name(), "_test.go") // ignore test files } func pkgName(filename string) string { file, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.PackageClauseOnly) if err != nil || file == nil { return "" } return file.Name.Name } func parseDir(dirpath string) map[string]*ast.Package { // the package name is the directory name within its parent. // (use dirname instead of path because dirname is clean; it // has no trailing '/') _, pkgname := path.Split(dirpath) // filter function to select the desired .go files filter := func(d os.FileInfo) bool { if isPkgFile(d) { // Some directories contain main packages: Only accept // files that belong to the expected package so that // parser.ParsePackage doesn't return "multiple packages // found" errors. // Additionally, accept the special package name // fakePkgName if we are looking at cmd documentation. name := pkgName(dirpath + "/" + d.Name()) return name == pkgname } return false } // get package AST pkgs, err := parser.ParseDir(token.NewFileSet(), dirpath, filter, parser.ParseComments) if err != nil { println("parse", dirpath, err.Error()) panic("go ParseDir fail: " + err.Error()) } return pkgs } func stressParseGo() { pkgroot := runtime.GOROOT() + "/src/" for { m := make(map[string]map[string]*ast.Package) for _, pkg := range packages { m[pkg] = parseDir(pkgroot + pkg) Println("parsed go package", pkg) } } }
<?php // No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Messages Component Messages Model * * @package Joomla.Administrator * @subpackage com_messages * @since 1.6 */ class <API key> extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'message_id', 'a.id', 'subject', 'a.subject', 'state', 'a.state', 'user_id_from', 'a.user_id_from', 'user_id_to', 'a.user_id_to', 'date_time', 'a.date_time', 'priority', 'a.priority', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this-><API key>($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $state = $this-><API key>($this->context.'.filter.state', 'filter_state', '', 'string'); $this->setState('filter.state', $state); // List state information. parent::populateState('a.date_time', 'desc'); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.state'); return parent::getStoreId($id); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.*, '. 'u.name AS user_from' ) ); $query->from('#__messages AS a'); // Join over the users for message owner. $query->join('INNER', '#__users AS u ON u.id = a.user_id_from'); $query->where('a.user_id_to = '.(int) $user->get('id')); // Filter by published state. $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = '.(int) $state); } elseif ($state === '') { $query->where('(a.state IN (0, 1))'); } // Filter by search in subject or message. $search = $this->getState('filter.search'); if (!empty($search)) { $search = $db->Quote('%'.$db->escape($search, true).'%', false); $query->where('a.subject LIKE '.$search.' OR a.message LIKE '.$search); } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.date_time')).' '.$db->escape($this->getState('list.direction', 'DESC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; } }
#!/usr/bin/env node require("./bin/npm-cli.js")
package client import ( "bufio" "crypto/tls" "fmt" "net" "net/http" "net/http/httputil" "net/url" "strings" "time" "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/tlsconfig" "github.com/docker/go-connections/sockets" "github.com/pkg/errors" "golang.org/x/net/context" ) // tlsClientCon holds tls information and a dialed connection. type tlsClientCon struct { *tls.Conn rawConn net.Conn } func (c *tlsClientCon) CloseWrite() error { // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it // on its underlying connection. if conn, ok := c.rawConn.(types.CloseWriter); ok { return conn.CloseWrite() } return nil } // postHijacked sends a POST request and hijacks the connection. func (cli *Client) postHijacked(ctx context.Context, path string, query url.Values, body interface{}, headers map[string][]string) (types.HijackedResponse, error) { bodyEncoded, err := encodeData(body) if err != nil { return types.HijackedResponse{}, err } apiPath := cli.getAPIPath(path, query) req, err := http.NewRequest("POST", apiPath, bodyEncoded) if err != nil { return types.HijackedResponse{}, err } req = cli.addHeaders(req, headers) conn, err := cli.setupHijackConn(req, "tcp") if err != nil { return types.HijackedResponse{}, err } return types.HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn)}, err } func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) { return tlsDialWithDialer(new(net.Dialer), network, addr, config) } // We need to copy Go's implementation of tls.Dial (pkg/cryptor/tls/tls.go) in // order to return our custom tlsClientCon struct which holds both the tls.Conn // object _and_ its underlying raw connection. The rationale for this is that // we need to be able to close the write end of the connection when attaching, // which tls.Conn does not provide. func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { // We want the Timeout and Deadline values from dialer to cover the // whole process: TCP connection and TLS handshake. This means that we // also need to start our own timers now. timeout := dialer.Timeout if !dialer.Deadline.IsZero() { deadlineTimeout := dialer.Deadline.Sub(time.Now()) if timeout == 0 || deadlineTimeout < timeout { timeout = deadlineTimeout } } var errChannel chan error if timeout != 0 { errChannel = make(chan error, 2) time.AfterFunc(timeout, func() { errChannel <- errors.New("") }) } proxyDialer, err := sockets.<API key>(dialer) if err != nil { return nil, err } rawConn, err := proxyDialer.Dial(network, addr) if err != nil { return nil, err } // When we set up a TCP connection for hijack, there could be long periods // of inactivity (a long running command with no output) that in certain // network setups may cause ECONNTIMEOUT, leaving the client in an unknown // state. Setting TCP KeepAlive on the socket connection will prohibit // ECONNTIMEOUT unless the socket connection truly is broken if tcpConn, ok := rawConn.(*net.TCPConn); ok { tcpConn.SetKeepAlive(true) tcpConn.SetKeepAlivePeriod(30 * time.Second) } colonPos := strings.LastIndex(addr, ":") if colonPos == -1 { colonPos = len(addr) } hostname := addr[:colonPos] // If no ServerName is set, infer the ServerName // from the hostname we're connecting to. if config.ServerName == "" { // Make a copy to avoid polluting argument or default. config = tlsconfig.Clone(config) config.ServerName = hostname } conn := tls.Client(rawConn, config) if timeout == 0 { err = conn.Handshake() } else { go func() { errChannel <- conn.Handshake() }() err = <-errChannel } if err != nil { rawConn.Close() return nil, err } // This is Docker difference with standard's crypto/tls package: returned a // wrapper which holds both the TLS and raw connections. return &tlsClientCon{conn, rawConn}, nil } func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { if tlsConfig != nil && proto != "unix" && proto != "npipe" { // Notice this isn't Go standard's tls.Dial function return tlsDial(proto, addr, tlsConfig) } if proto == "npipe" { return sockets.DialPipe(addr, 32*time.Second) } return net.Dial(proto, addr) } func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, error) { req.Host = cli.addr req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", proto) conn, err := dial(cli.proto, cli.addr, resolveTLSConfig(cli.client.Transport)) if err != nil { return nil, errors.Wrap(err, "cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") } // When we set up a TCP connection for hijack, there could be long periods // of inactivity (a long running command with no output) that in certain // network setups may cause ECONNTIMEOUT, leaving the client in an unknown // state. Setting TCP KeepAlive on the socket connection will prohibit // ECONNTIMEOUT unless the socket connection truly is broken if tcpConn, ok := conn.(*net.TCPConn); ok { tcpConn.SetKeepAlive(true) tcpConn.SetKeepAlivePeriod(30 * time.Second) } clientconn := httputil.NewClientConn(conn, nil) defer clientconn.Close() // Server hijacks the connection, error 'connection closed' expected resp, err := clientconn.Do(req) if err != httputil.ErrPersistEOF { if err != nil { return nil, err } if resp.StatusCode != http.<API key> { resp.Body.Close() return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) } } c, br := clientconn.Hijack() if br.Buffered() > 0 { // If there is buffered content, wrap the connection c = &hijackedConn{c, br} } else { br.Reset(nil) } return c, nil } type hijackedConn struct { net.Conn r *bufio.Reader } func (c *hijackedConn) Read(b []byte) (int, error) { return c.r.Read(b) }
<?php namespace Zend\Filter; use Traversable; class StringToUpper extends AbstractUnicode { /** * @var array */ protected $options = array( 'encoding' => null, ); /** * Constructor * * @param string|array|Traversable $encodingOrOptions OPTIONAL */ public function __construct($encodingOrOptions = null) { if ($encodingOrOptions !== null) { if (!static::isOptions($encodingOrOptions)) { $this->setEncoding($encodingOrOptions); } else { $this->setOptions($encodingOrOptions); } } } /** * Defined by Zend\Filter\FilterInterface * * Returns the string $value, converting characters to uppercase as necessary * * If the value provided is non-scalar, the value will remain unfiltered * * @param string $value * @return string|mixed */ public function filter($value) { if (!is_scalar($value)) { return $value; } $value = (string) $value; if ($this->options['encoding'] !== null) { return mb_strtoupper($value, $this->options['encoding']); } return strtoupper($value); } }
<?php defined('_JEXEC') or die; jimport('joomla.application.categories'); /** * Build the route for the com_contact component * * @param array An array of URL arguments * * @return array The URL arguments to use to assemble the subsequent URL. */ function ContactBuildRoute(&$query){ $segments = array(); // get a menu item based on Itemid or currently active $app = JFactory::getApplication(); $menu = $app->getMenu(); $params = JComponentHelper::getParams('com_contact'); $advanced = $params->get('sef_advanced_link', 0); if (empty($query['Itemid'])) { $menuItem = $menu->getActive(); } else { $menuItem = $menu->getItem($query['Itemid']); } $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view']; $mCatid = (empty($menuItem->query['catid'])) ? null : $menuItem->query['catid']; $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id']; if (isset($query['view'])) { $view = $query['view']; if (empty($query['Itemid'])) { $segments[] = $query['view']; } unset($query['view']); }; // are we dealing with a contact that is attached to a menu item? if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == intval($query['id']))) { unset($query['view']); unset($query['catid']); unset($query['id']); return $segments; } if (isset($view) and ($view == 'category' or $view == 'contact')) { if ($mId != intval($query['id']) || $mView != $view) { if($view == 'contact' && isset($query['catid'])) { $catid = $query['catid']; } elseif(isset($query['id'])) { $catid = $query['id']; } $menuCatid = $mId; $categories = JCategories::getInstance('Contact'); $category = $categories->get($catid); if($category) { //TODO Throw error that the category either not exists or is unpublished $path = array_reverse($category->getPath()); $array = array(); foreach($path as $id) { if((int) $id == (int)$menuCatid) { break; } if($advanced) { list($tmp, $id) = explode(':', $id, 2); } $array[] = $id; } $segments = array_merge($segments, array_reverse($array)); } if($view == 'contact') { if($advanced) { list($tmp, $id) = explode(':', $query['id'], 2); } else { $id = $query['id']; } $segments[] = $id; } } unset($query['id']); unset($query['catid']); } if (isset($query['layout'])) { if (!empty($query['Itemid']) && isset($menuItem->query['layout'])) { if ($query['layout'] == $menuItem->query['layout']) { unset($query['layout']); } } else { if ($query['layout'] == 'default') { unset($query['layout']); } } }; return $segments; } /** * Parse the segments of a URL. * * @param array The segments of the URL to parse. * * @return array The URL attributes to be used by the application. */ function ContactParseRoute($segments) { $vars = array(); //Get the active menu item. $app = JFactory::getApplication(); $menu = $app->getMenu(); $item = $menu->getActive(); $params = JComponentHelper::getParams('com_contact'); $advanced = $params->get('sef_advanced_link', 0); // Count route segments $count = count($segments); // Standard routing for newsfeeds. if (!isset($item)) { $vars['view'] = $segments[0]; $vars['id'] = $segments[$count - 1]; return $vars; } // From the categories view, we can only jump to a category. $id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root'; $contactCategory = JCategories::getInstance('Contact')->get($id); $categories = ($contactCategory) ? $contactCategory->getChildren() : array(); $vars['catid'] = $id; $vars['id'] = $id; $found = 0; foreach($segments as $segment) { $segment = $advanced ? str_replace(':', '-', $segment) : $segment; foreach($categories as $category) { if ($category->slug == $segment || $category->alias == $segment) { $vars['id'] = $category->id; $vars['catid'] = $category->id; $vars['view'] = 'category'; $categories = $category->getChildren(); $found = 1; break; } } if ($found == 0) { if($advanced) { $db = JFactory::getDBO(); $query = 'SELECT id FROM #__contact_details WHERE catid = '.$vars['catid'].' AND alias = '.$db->Quote($segment); $db->setQuery($query); $nid = $db->loadResult(); } else { $nid = $segment; } $vars['id'] = $nid; $vars['view'] = 'contact'; } $found = 0; } return $vars; }
var vows = require("vows"), _ = require("../../"), load = require("../load"), assert = require("../assert"); var suite = vows.describe("d3.max"); suite.addBatch({ "max": { topic: load("arrays/max").expression("d3.max"), "returns the greatest numeric value for numbers": function(max) { assert.equal(max([1]), 1); assert.equal(max([5, 1, 2, 3, 4]), 5); assert.equal(max([20, 3]), 20); assert.equal(max([3, 20]), 20); }, "returns the greatest lexicographic value for strings": function(max) { assert.equal(max(["c", "a", "b"]), "c"); assert.equal(max(["20", "3"]), "3"); assert.equal(max(["3", "20"]), "3"); }, "ignores null, undefined and NaN": function(max) { var o = {valueOf: function() { return NaN; }}; assert.equal(max([NaN, 1, 2, 3, 4, 5]), 5); assert.equal(max([o, 1, 2, 3, 4, 5]), 5); assert.equal(max([1, 2, 3, 4, 5, NaN]), 5); assert.equal(max([1, 2, 3, 4, 5, o]), 5); assert.equal(max([10, null, 3, undefined, 5, NaN]), 10); assert.equal(max([-1, null, -3, undefined, -5, NaN]), -1); }, "compares heterogenous types as numbers": function(max) { assert.strictEqual(max([20, "3"]), 20); assert.strictEqual(max(["20", 3]), "20"); assert.strictEqual(max([3, "20"]), "20"); assert.strictEqual(max(["3", 20]), 20); }, "returns undefined for empty array": function(max) { assert.isUndefined(max([])); assert.isUndefined(max([null])); assert.isUndefined(max([undefined])); assert.isUndefined(max([NaN])); assert.isUndefined(max([NaN, NaN])); }, "applies the optional accessor function": function(max) { assert.equal(max([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return _.min(d); }), 2); assert.equal(max([1, 2, 3, 4, 5], function(d, i) { return i; }), 4); } } }); suite.export(module);
#ifndef _ADMA_H #define _ADMA_H #include <linux/types.h> #include <linux/io.h> #include <mach/hardware.h> #include <asm/hardware/iop_adma.h> #define ADMA_ACCR(chan) (chan->mmr_base + 0x0) #define ADMA_ACSR(chan) (chan->mmr_base + 0x4) #define ADMA_ADAR(chan) (chan->mmr_base + 0x8) #define ADMA_IIPCR(chan) (chan->mmr_base + 0x18) #define ADMA_IIPAR(chan) (chan->mmr_base + 0x1c) #define ADMA_IIPUAR(chan) (chan->mmr_base + 0x20) #define ADMA_ANDAR(chan) (chan->mmr_base + 0x24) #define ADMA_ADCR(chan) (chan->mmr_base + 0x28) #define ADMA_CARMD(chan) (chan->mmr_base + 0x2c) #define ADMA_ABCR(chan) (chan->mmr_base + 0x30) #define ADMA_DLADR(chan) (chan->mmr_base + 0x34) #define ADMA_DUADR(chan) (chan->mmr_base + 0x38) #define ADMA_SLAR(src, chan) (chan->mmr_base + (0x3c + (src << 3))) #define ADMA_SUAR(src, chan) (chan->mmr_base + (0x40 + (src << 3))) struct iop13xx_adma_src { u32 src_addr; union { u32 upper_src_addr; struct { unsigned int pq_upper_src_addr:24; unsigned int pq_dmlt:8; }; }; }; struct <API key> { unsigned int int_en:1; unsigned int xfer_dir:2; unsigned int src_select:4; unsigned int zero_result:1; unsigned int block_fill_en:1; unsigned int crc_gen_en:1; unsigned int crc_xfer_dis:1; unsigned int crc_seed_fetch_dis:1; unsigned int <API key>:1; unsigned int endian_swap_en:1; unsigned int reserved0:2; unsigned int pq_update_xfer_en:1; unsigned int dual_xor_en:1; unsigned int pq_xfer_en:1; unsigned int p_xfer_dis:1; unsigned int reserved1:10; unsigned int relax_order_en:1; unsigned int no_snoop_en:1; }; struct <API key> { unsigned int byte_count:24; unsigned int host_if:3; unsigned int reserved:2; unsigned int zero_result_err_q:1; unsigned int zero_result_err:1; unsigned int tx_complete:1; }; struct <API key> { u32 next_desc; union { u32 desc_ctrl; struct <API key> desc_ctrl_field; }; union { u32 crc_addr; u32 block_fill_data; u32 q_dest_addr; }; union { u32 byte_count; struct <API key> byte_count_field; }; union { u32 dest_addr; u32 p_dest_addr; }; union { u32 upper_dest_addr; u32 pq_upper_dest_addr; }; struct iop13xx_adma_src src[1]; }; struct <API key> { u32 next_desc; u32 desc_ctrl; u32 reserved; u32 byte_count; u32 h_dest_addr; u32 h_upper_dest_addr; u32 src0_addr; u32 upper_src0_addr; u32 src1_addr; u32 upper_src1_addr; u32 h_src_addr; u32 h_upper_src_addr; u32 d_src_addr; u32 d_upper_src_addr; u32 d_dest_addr; u32 d_upper_dest_addr; }; struct <API key> { u32 next_desc; u32 desc_ctrl; u32 reserved; u32 byte_count; u32 p_dest_addr; u32 p_upper_dest_addr; u32 src0_addr; u32 upper_src0_addr; u32 src1_addr; u32 upper_src1_addr; u32 p_src_addr; u32 p_upper_src_addr; u32 q_src_addr; struct { unsigned int q_upper_src_addr:24; unsigned int q_dmlt:8; }; u32 q_dest_addr; u32 q_upper_dest_addr; }; static inline int <API key>(void) { return 16; } #define iop_adma_get_max_pq <API key> static inline u32 <API key>(struct iop_adma_chan *chan) { return __raw_readl(ADMA_ADAR(chan)); } static inline void <API key>(struct iop_adma_chan *chan, u32 next_desc_addr) { __raw_writel(next_desc_addr, ADMA_ANDAR(chan)); } #define ADMA_STATUS_BUSY (1 << 13) static inline char iop_chan_is_busy(struct iop_adma_chan *chan) { if (__raw_readl(ADMA_ACSR(chan)) & ADMA_STATUS_BUSY) return 1; else return 0; } static inline int <API key>(struct iop_adma_chan *chan, int num_slots) { return 1; } #define iop_desc_is_aligned(x, y) 1 static inline int <API key>(size_t len, int *slots_per_op) { *slots_per_op = 1; return 1; } #define <API key>(s, c) <API key>(0, s) static inline int <API key>(size_t len, int *slots_per_op) { *slots_per_op = 1; return 1; } static inline int <API key>(size_t len, int src_cnt, int *slots_per_op) { static const char slot_count_table[] = { 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, }; *slots_per_op = slot_count_table[src_cnt - 1]; return *slots_per_op; } #define ADMA_MAX_BYTE_COUNT (16 * 1024 * 1024) #define <API key> ADMA_MAX_BYTE_COUNT #define <API key> ADMA_MAX_BYTE_COUNT #define <API key> ADMA_MAX_BYTE_COUNT #define <API key> ADMA_MAX_BYTE_COUNT #define <API key>(l, s, o) <API key>(l, s, o) #define <API key> <API key> #define <API key> <API key> static inline u32 <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->dest_addr; } static inline u32 <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->q_dest_addr; } static inline u32 <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->byte_count_field.byte_count; } static inline u32 <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan, int src_idx) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->src[src_idx].src_addr; } static inline u32 <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->desc_ctrl_field.src_select + 1; } static inline void <API key>(struct iop_adma_desc_slot *desc, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; hw_desc->crc_addr = 0; } static inline void <API key>(struct iop_adma_desc_slot *desc, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.block_fill_en = 1; u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; hw_desc->crc_addr = 0; } /* to do: support buffers larger than ADMA_MAX_BYTE_COUNT */ static inline void iop_desc_init_xor(struct iop_adma_desc_slot *desc, int src_cnt, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.src_select = src_cnt - 1; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; hw_desc->crc_addr = 0; } #define <API key>(d, s, i) iop_desc_init_xor(d, s, i) /* to do: support buffers larger than ADMA_MAX_BYTE_COUNT */ static inline int <API key>(struct iop_adma_desc_slot *desc, int src_cnt, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.src_select = src_cnt - 1; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.zero_result = 1; u_desc_ctrl.field.<API key> = 1; u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; hw_desc->crc_addr = 0; return 1; } static inline void iop_desc_init_pq(struct iop_adma_desc_slot *desc, int src_cnt, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.src_select = src_cnt - 1; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.pq_xfer_en = 1; u_desc_ctrl.field.p_xfer_dis = !!(flags & <API key>); u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; } static inline int iop_desc_is_pq(struct iop_adma_desc_slot *desc) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = hw_desc->desc_ctrl; return u_desc_ctrl.field.pq_xfer_en; } static inline void <API key>(struct iop_adma_desc_slot *desc, int src_cnt, unsigned long flags) { struct <API key> *hw_desc = desc->hw_desc; union { u32 value; struct <API key> field; } u_desc_ctrl; u_desc_ctrl.value = 0; u_desc_ctrl.field.src_select = src_cnt - 1; u_desc_ctrl.field.xfer_dir = 3; /* local to internal bus */ u_desc_ctrl.field.zero_result = 1; u_desc_ctrl.field.<API key> = 1; u_desc_ctrl.field.pq_xfer_en = 1; u_desc_ctrl.field.p_xfer_dis = !!(flags & <API key>); u_desc_ctrl.field.int_en = flags & DMA_PREP_INTERRUPT; hw_desc->desc_ctrl = u_desc_ctrl.value; } static inline void <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan, u32 byte_count) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->byte_count = byte_count; } static inline void <API key>(struct iop_adma_desc_slot *desc, u32 len) { int slots_per_op = desc->slots_per_op; struct <API key> *hw_desc = desc->hw_desc, *iter; int i = 0; if (len <= <API key>) { hw_desc->byte_count = len; } else { do { iter = <API key>(hw_desc, i); iter->byte_count = <API key>; len -= <API key>; i += slots_per_op; } while (len > <API key>); if (len) { iter = <API key>(hw_desc, i); iter->byte_count = len; } } } #define <API key> <API key> static inline void <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan, dma_addr_t addr) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->dest_addr = addr; hw_desc->upper_dest_addr = 0; } static inline void <API key>(struct iop_adma_desc_slot *desc, dma_addr_t *addr) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->dest_addr = addr[0]; hw_desc->q_dest_addr = addr[1]; hw_desc->upper_dest_addr = 0; } static inline void <API key>(struct iop_adma_desc_slot *desc, dma_addr_t addr) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->src[0].src_addr = addr; hw_desc->src[0].upper_src_addr = 0; } static inline void <API key>(struct iop_adma_desc_slot *desc, int src_idx, dma_addr_t addr) { int slot_cnt = desc->slot_cnt, slots_per_op = desc->slots_per_op; struct <API key> *hw_desc = desc->hw_desc, *iter; int i = 0; do { iter = <API key>(hw_desc, i); iter->src[src_idx].src_addr = addr; iter->src[src_idx].upper_src_addr = 0; slot_cnt -= slots_per_op; if (slot_cnt) { i += slots_per_op; addr += <API key>; } } while (slot_cnt); } static inline void <API key>(struct iop_adma_desc_slot *desc, int src_idx, dma_addr_t addr, unsigned char coef) { int slot_cnt = desc->slot_cnt, slots_per_op = desc->slots_per_op; struct <API key> *hw_desc = desc->hw_desc, *iter; struct iop13xx_adma_src *src; int i = 0; do { iter = <API key>(hw_desc, i); src = &iter->src[src_idx]; src->src_addr = addr; src->pq_upper_src_addr = 0; src->pq_dmlt = coef; slot_cnt -= slots_per_op; if (slot_cnt) { i += slots_per_op; addr += <API key>; } } while (slot_cnt); } static inline void <API key>(struct iop_adma_desc_slot *desc, struct iop_adma_chan *chan) { <API key>(desc, 1); <API key>(desc, chan, 0); <API key>(desc, chan, 0); <API key>(desc, 0); } #define <API key> <API key> #define <API key> <API key> static inline void <API key>(struct iop_adma_desc_slot *desc, int pq_idx, dma_addr_t *src) { <API key>(desc, pq_idx, src[pq_idx]); <API key>(desc, pq_idx+1, src[pq_idx+1]); } static inline void <API key>(struct iop_adma_desc_slot *desc, u32 next_desc_addr) { struct <API key> *hw_desc = desc->hw_desc; iop_paranoia(hw_desc->next_desc); hw_desc->next_desc = next_desc_addr; } static inline u32 <API key>(struct iop_adma_desc_slot *desc) { struct <API key> *hw_desc = desc->hw_desc; return hw_desc->next_desc; } static inline void <API key>(struct iop_adma_desc_slot *desc) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->next_desc = 0; } static inline void <API key>(struct iop_adma_desc_slot *desc, u32 val) { struct <API key> *hw_desc = desc->hw_desc; hw_desc->block_fill_data = val; } static inline enum sum_check_flags <API key>(struct iop_adma_desc_slot *desc) { struct <API key> *hw_desc = desc->hw_desc; struct <API key> desc_ctrl = hw_desc->desc_ctrl_field; struct <API key> byte_count = hw_desc->byte_count_field; enum sum_check_flags flags; BUG_ON(!(byte_count.tx_complete && desc_ctrl.zero_result)); flags = byte_count.zero_result_err_q << SUM_CHECK_Q; flags |= byte_count.zero_result_err << SUM_CHECK_P; return flags; } static inline void iop_chan_append(struct iop_adma_chan *chan) { u32 adma_accr; adma_accr = __raw_readl(ADMA_ACCR(chan)); adma_accr |= 0x2; __raw_writel(adma_accr, ADMA_ACCR(chan)); } static inline u32 iop_chan_get_status(struct iop_adma_chan *chan) { return __raw_readl(ADMA_ACSR(chan)); } static inline void iop_chan_disable(struct iop_adma_chan *chan) { u32 adma_chan_ctrl = __raw_readl(ADMA_ACCR(chan)); adma_chan_ctrl &= ~0x1; __raw_writel(adma_chan_ctrl, ADMA_ACCR(chan)); } static inline void iop_chan_enable(struct iop_adma_chan *chan) { u32 adma_chan_ctrl; adma_chan_ctrl = __raw_readl(ADMA_ACCR(chan)); adma_chan_ctrl |= 0x1; __raw_writel(adma_chan_ctrl, ADMA_ACCR(chan)); } static inline void <API key>(struct iop_adma_chan *chan) { u32 status = __raw_readl(ADMA_ACSR(chan)); status &= (1 << 12); __raw_writel(status, ADMA_ACSR(chan)); } static inline void <API key>(struct iop_adma_chan *chan) { u32 status = __raw_readl(ADMA_ACSR(chan)); status &= (1 << 11); __raw_writel(status, ADMA_ACSR(chan)); } static inline void <API key>(struct iop_adma_chan *chan) { u32 status = __raw_readl(ADMA_ACSR(chan)); status &= (1 << 9) | (1 << 5) | (1 << 4) | (1 << 3); __raw_writel(status, ADMA_ACSR(chan)); } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return test_bit(9, &status); } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return test_bit(5, &status); } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return test_bit(4, &status); } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return test_bit(3, &status); } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return 0; } static inline int <API key>(unsigned long status, struct iop_adma_chan *chan) { return 0; } static inline int iop_is_err_split_tx(unsigned long status, struct iop_adma_chan *chan) { return 0; } #endif /* _ADMA_H */
/* <API key>: GPL-2.0+ */ #ifndef FUSB302_REG_H #define FUSB302_REG_H #define FUSB_REG_DEVICE_ID 0x01 #define FUSB_REG_SWITCHES0 0x02 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_SWITCHES1 0x03 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_MEASURE 0x04 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_CONTROL0 0x06 #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> (0xC) #define <API key> (0xC) #define <API key> (0x8) #define <API key> (0x4) #define <API key> BIT(0) #define FUSB_REG_CONTROL1 0x07 #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_CONTROL2 0x08 #define <API key> BIT(1) #define <API key> (0x6) #define <API key> (0x6) #define <API key> (0x4) #define <API key> (0x2) #define <API key> (0x0) #define <API key> BIT(0) #define FUSB_REG_CONTROL3 0x09 #define <API key> BIT(6) #define <API key> BIT(5) /* 302B Only */ #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(1) #define <API key> (0x6) #define <API key> (0x6) #define <API key> (0x4) #define <API key> (0x2) #define <API key> BIT(0) #define FUSB_REG_MASK 0x0A #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define FUSB_REG_MASK_ALERT BIT(3) #define FUSB_REG_MASK_WAKE BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_POWER 0x0B #define FUSB_REG_POWER_PWR BIT(0) #define <API key> 0x1 #define <API key> 0x3 #define <API key> 0x7 #define <API key> 0xF #define FUSB_REG_RESET 0x0C #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_MASKA 0x0E #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_MASKB 0x0F #define <API key> BIT(0) #define FUSB_REG_STATUS0A 0x3C #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_STATUS1A 0x3D #define <API key> BIT(3) #define <API key> 0x0 #define <API key> 0x1 #define <API key> 0x2 #define <API key> 0x5 #define <API key> 0x6 #define <API key> 0x7 #define <API key> (3) #define <API key> (0x7) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_INTERRUPTA 0x3E #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_INTERRUPTB 0x3F #define <API key> BIT(0) #define FUSB_REG_STATUS0 0x40 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> 0x03 #define <API key> 0x0 #define <API key> 0x1 #define <API key> 0x2 #define <API key> 0x3 #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_STATUS1 0x41 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define FUSB_REG_INTERRUPT 0x42 #define <API key> BIT(7) #define <API key> BIT(6) #define <API key> BIT(5) #define <API key> BIT(4) #define <API key> BIT(3) #define <API key> BIT(2) #define <API key> BIT(1) #define <API key> BIT(0) #define FUSB_REG_FIFOS 0x43 /* Tokens defined for the FUSB302 TX FIFO */ enum <API key> { FUSB302_TKN_TXON = 0xA1, FUSB302_TKN_SYNC1 = 0x12, FUSB302_TKN_SYNC2 = 0x13, FUSB302_TKN_SYNC3 = 0x1B, FUSB302_TKN_RST1 = 0x15, FUSB302_TKN_RST2 = 0x16, FUSB302_TKN_PACKSYM = 0x80, FUSB302_TKN_JAMCRC = 0xFF, FUSB302_TKN_EOP = 0x14, FUSB302_TKN_TXOFF = 0xFE, }; #endif
// Must not be included from any .h files to avoid polluting the namespace // with macros. #ifndef <API key> #define <API key> #include <stdio.h> #include <stdint.h> #include <string> #include "port/port.h" namespace leveldb { class Slice; class WritableFile; // Append a human-readable printout of "num" to *str extern void AppendNumberTo(std::string* str, uint64_t num); // Append a human-readable printout of "value" to *str. // Escapes any non-printable characters found in "value". extern void <API key>(std::string* str, const Slice& value); // Return a human-readable printout of "num" extern std::string NumberToString(uint64_t num); // Return a human-readable version of "value". // Escapes any non-printable characters found in "value". extern std::string EscapeString(const Slice& value); // If *in starts with "c", advances *in past the first character and // returns true. Otherwise, returns false. extern bool ConsumeChar(Slice* in, char c); // Parse a human-readable number from "*in" into *value. On success, // advances "*in" past the consumed number and sets "*val" to the // numeric value. Otherwise, returns false and leaves *in in an // unspecified state. extern bool <API key>(Slice* in, uint64_t* val); } // namespace leveldb #endif // <API key>
require "openssl" module ActiveMerchant #:nodoc: module Billing #:nodoc: module Integrations #:nodoc: module Dwolla module Common def verify_signature(checkoutId, amount, <API key>, secret) if secret.nil? raise ArgumentError, "You need to provide the Application secret as the option :credential3 to verify that the notification originated from Dwolla" end expected_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "%s&%.2f" % [checkoutId, amount]) if <API key> != expected_signature raise StandardError, "Dwolla signature verification failed." end end end end end end end
var name; switch (name) { case "Kamol": doSomething(); default: doSomethingElse(); } switch (name) { default: doSomethingElse(); break; case "Kamol": doSomething(); }
require "language/java" class JavaRequirement < Requirement fatal true cask "java" download "http: satisfy :build_env => false do args = %w[--failfast] args << "--version" << "#{@version}" if @version @java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp $?.success? end env do java_home = Pathname.new(@java_home) ENV["JAVA_HOME"] = java_home ENV.prepend_path "PATH", java_home/"bin" if (java_home/"include").exist? # Oracle JVM ENV.append_to_cflags "-I#{java_home}/include" ENV.append_to_cflags "-I#{java_home}/include/darwin" else # Apple JVM ENV.append_to_cflags "-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/" end end def initialize(tags) @version = tags.shift if /(\d\.)+\d/ === tags.first super end def message version_string = " #{@version}" if @version s = "Java#{version_string} is required to install this formula." s += super s end def inspect "#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>" end end
#include <linux/module.h> #include <linux/pm.h> #include <linux/i2c/twl.h> #include <linux/platform_device.h> #include <linux/of.h> #include <linux/of_device.h> #include <asm/mach-types.h> static u8 <API key> = 0x2b; /* Register bits for P1, P2 and P3_SW_EVENTS */ #define PWR_STOPON_PRWON BIT(6) #define PWR_STOPON_SYSEN BIT(5) #define <API key> BIT(4) #define PWR_LVL_WAKEUP BIT(3) #define PWR_DEVACT BIT(2) #define PWR_DEVSLP BIT(1) #define PWR_DEVOFF BIT(0) /* Register bits for CFG_P1_TRANSITION (also for P2 and P3) */ #define STARTON_SWBUG BIT(7) /* Start on watchdog */ #define STARTON_VBUS BIT(5) /* Start on VBUS */ #define STARTON_VBAT BIT(4) /* Start on battery insert */ #define STARTON_RTC BIT(3) /* Start on RTC */ #define STARTON_USB BIT(2) /* Start on USB host */ #define STARTON_CHG BIT(1) /* Start on charger */ #define STARTON_PWON BIT(0) /* Start on PWRON button */ #define SEQ_OFFSYNC (1 << 0) #define <API key>(p) (p - 0x36) #define <API key>(p) (p - 0x5b) /* resource - hfclk */ #define R_HFCLKOUT_DEV_GRP <API key>(0xe6) /* PM events */ #define R_P1_SW_EVENTS <API key>(0x46) #define R_P2_SW_EVENTS <API key>(0x47) #define R_P3_SW_EVENTS <API key>(0x48) #define R_CFG_P1_TRANSITION <API key>(0x36) #define R_CFG_P2_TRANSITION <API key>(0x37) #define R_CFG_P3_TRANSITION <API key>(0x38) #define END_OF_SCRIPT 0x3f #define R_SEQ_ADD_A2S <API key>(0x55) #define R_SEQ_ADD_S2A12 <API key>(0x56) #define R_SEQ_ADD_S2A3 <API key>(0x57) #define R_SEQ_ADD_WARM <API key>(0x58) #define R_MEMORY_ADDRESS <API key>(0x59) #define R_MEMORY_DATA <API key>(0x5a) /* resource configuration registers <RESOURCE>_DEV_GRP at address 'n+0' <RESOURCE>_TYPE at address 'n+1' <RESOURCE>_REMAP at address 'n+2' <RESOURCE>_DEDICATED at address 'n+3' */ #define DEV_GRP_OFFSET 0 #define TYPE_OFFSET 1 #define REMAP_OFFSET 2 #define DEDICATED_OFFSET 3 /* Bit positions in the registers */ /* <RESOURCE>_DEV_GRP */ #define DEV_GRP_SHIFT 5 #define DEV_GRP_MASK (7 << DEV_GRP_SHIFT) /* <RESOURCE>_TYPE */ #define TYPE_SHIFT 0 #define TYPE_MASK (7 << TYPE_SHIFT) #define TYPE2_SHIFT 3 #define TYPE2_MASK (3 << TYPE2_SHIFT) /* <RESOURCE>_REMAP */ #define SLEEP_STATE_SHIFT 0 #define SLEEP_STATE_MASK (0xf << SLEEP_STATE_SHIFT) #define OFF_STATE_SHIFT 4 #define OFF_STATE_MASK (0xf << OFF_STATE_SHIFT) static u8 res_config_addrs[] = { [RES_VAUX1] = 0x17, [RES_VAUX2] = 0x1b, [RES_VAUX3] = 0x1f, [RES_VAUX4] = 0x23, [RES_VMMC1] = 0x27, [RES_VMMC2] = 0x2b, [RES_VPLL1] = 0x2f, [RES_VPLL2] = 0x33, [RES_VSIM] = 0x37, [RES_VDAC] = 0x3b, [RES_VINTANA1] = 0x3f, [RES_VINTANA2] = 0x43, [RES_VINTDIG] = 0x47, [RES_VIO] = 0x4b, [RES_VDD1] = 0x55, [RES_VDD2] = 0x63, [RES_VUSB_1V5] = 0x71, [RES_VUSB_1V8] = 0x74, [RES_VUSB_3V1] = 0x77, [RES_VUSBCP] = 0x7a, [RES_REGEN] = 0x7f, [RES_NRES_PWRON] = 0x82, [RES_CLKEN] = 0x85, [RES_SYSEN] = 0x88, [RES_HFCLKOUT] = 0x8b, [RES_32KCLKOUT] = 0x8e, [RES_RESET] = 0x91, [RES_MAIN_REF] = 0x94, }; /* * Usable values for .remap_sleep and .remap_off * Based on table "5.3.3 Resource Operating modes" */ enum { TWL_REMAP_OFF = 0, TWL_REMAP_SLEEP = 8, TWL_REMAP_ACTIVE = 9, }; /* * Macros to configure the PM register states for various resources. * Note that we can make MSG_SINGULAR etc private to this driver once * omap3 has been made DT only. */ #define TWL_DFLT_DELAY 2 /* typically 2 32 KiHz cycles */ #define TWL_DEV_GRP_P123 (DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3) #define TWL_RESOURCE_SET(res, state) \ { MSG_SINGULAR(DEV_GRP_NULL, (res), (state)), TWL_DFLT_DELAY } #define TWL_RESOURCE_ON(res) TWL_RESOURCE_SET(res, RES_STATE_ACTIVE) #define TWL_RESOURCE_OFF(res) TWL_RESOURCE_SET(res, RES_STATE_OFF) #define TWL_RESOURCE_RESET(res) TWL_RESOURCE_SET(res, RES_STATE_WRST) /* * It seems that type1 and type2 is just the resource init order * number for the type1 and type2 group. */ #define <API key>(res, state) \ { MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_ACTIVE), (state) } #define <API key>(group, type1, type2) \ { MSG_BROADCAST(DEV_GRP_NULL, (group), (type1), (type2), \ RES_STATE_WRST), TWL_DFLT_DELAY } #define <API key>(group, type, type2) \ { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \ RES_STATE_SLEEP), TWL_DFLT_DELAY } #define <API key>(group, type, type2) \ { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \ RES_STATE_ACTIVE), TWL_DFLT_DELAY } #define TWL_REMAP_SLEEP(res, devgrp, typ, typ2) \ { .resource = (res), .devgroup = (devgrp), \ .type = (typ), .type2 = (typ2), \ .remap_off = TWL_REMAP_OFF, \ .remap_sleep = TWL_REMAP_SLEEP, } #define TWL_REMAP_OFF(res, devgrp, typ, typ2) \ { .resource = (res), .devgroup = (devgrp), \ .type = (typ), .type2 = (typ2), \ .remap_off = TWL_REMAP_OFF, .remap_sleep = TWL_REMAP_OFF, } static int <API key>(u8 address, u8 byte) { int err; err = twl_i2c_write_u8(<API key>, address, R_MEMORY_ADDRESS); if (err) goto out; err = twl_i2c_write_u8(<API key>, byte, R_MEMORY_DATA); out: return err; } static int <API key>(u8 address, u16 pmb_message, u8 delay, u8 next) { int err; address *= 4; err = <API key>(address++, pmb_message >> 8); if (err) goto out; err = <API key>(address++, pmb_message & 0xff); if (err) goto out; err = <API key>(address++, delay); if (err) goto out; err = <API key>(address++, next); out: return err; } static int <API key>(u8 address, struct twl4030_ins *script, int len) { int err = -EINVAL; for (; len; len--, address++, script++) { if (len == 1) { err = <API key>(address, script->pmb_message, script->delay, END_OF_SCRIPT); if (err) break; } else { err = <API key>(address, script->pmb_message, script->delay, address + 1); if (err) break; } } return err; } static int <API key>(u8 address) { int err; u8 data; /* Set SLEEP to ACTIVE SEQ address for P3 */ err = twl_i2c_write_u8(<API key>, address, R_SEQ_ADD_S2A3); if (err) goto out; /* P3 LVL_WAKEUP should be on LEVEL */ err = twl_i2c_read_u8(<API key>, &data, R_P3_SW_EVENTS); if (err) goto out; data |= PWR_LVL_WAKEUP; err = twl_i2c_write_u8(<API key>, data, R_P3_SW_EVENTS); out: if (err) pr_err("TWL4030 wakeup sequence for P3 config error\n"); return err; } static int <API key>(u8 address) { int err = 0; u8 data; /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */ err = twl_i2c_write_u8(<API key>, address, R_SEQ_ADD_S2A12); if (err) goto out; /* P1/P2 LVL_WAKEUP should be on LEVEL */ err = twl_i2c_read_u8(<API key>, &data, R_P1_SW_EVENTS); if (err) goto out; data |= PWR_LVL_WAKEUP; err = twl_i2c_write_u8(<API key>, data, R_P1_SW_EVENTS); if (err) goto out; err = twl_i2c_read_u8(<API key>, &data, R_P2_SW_EVENTS); if (err) goto out; data |= PWR_LVL_WAKEUP; err = twl_i2c_write_u8(<API key>, data, R_P2_SW_EVENTS); if (err) goto out; if (<API key>() || machine_is_omap_ldp()) { /* Disabling AC charger effect on sleep-active transitions */ err = twl_i2c_read_u8(<API key>, &data, R_CFG_P1_TRANSITION); if (err) goto out; data &= ~(1<<1); err = twl_i2c_write_u8(<API key>, data, R_CFG_P1_TRANSITION); if (err) goto out; } out: if (err) pr_err("TWL4030 wakeup sequence for P1 and P2" \ "config error\n"); return err; } static int <API key>(u8 address) { int err; /* Set ACTIVE to SLEEP SEQ address in T2 memory*/ err = twl_i2c_write_u8(<API key>, address, R_SEQ_ADD_A2S); if (err) pr_err("TWL4030 sleep sequence config error\n"); return err; } static int <API key>(u8 address) { int err; u8 rd_data; /* Set WARM RESET SEQ address for P1 */ err = twl_i2c_write_u8(<API key>, address, R_SEQ_ADD_WARM); if (err) goto out; /* P1/P2/P3 enable WARMRESET */ err = twl_i2c_read_u8(<API key>, &rd_data, R_P1_SW_EVENTS); if (err) goto out; rd_data |= <API key>; err = twl_i2c_write_u8(<API key>, rd_data, R_P1_SW_EVENTS); if (err) goto out; err = twl_i2c_read_u8(<API key>, &rd_data, R_P2_SW_EVENTS); if (err) goto out; rd_data |= <API key>; err = twl_i2c_write_u8(<API key>, rd_data, R_P2_SW_EVENTS); if (err) goto out; err = twl_i2c_read_u8(<API key>, &rd_data, R_P3_SW_EVENTS); if (err) goto out; rd_data |= <API key>; err = twl_i2c_write_u8(<API key>, rd_data, R_P3_SW_EVENTS); out: if (err) pr_err("TWL4030 warmreset seq config error\n"); return err; } static int <API key>(struct twl4030_resconfig *rconfig) { int rconfig_addr; int err; u8 type; u8 grp; u8 remap; if (rconfig->resource > TOTAL_RESOURCES) { pr_err("TWL4030 Resource %d does not exist\n", rconfig->resource); return -EINVAL; } rconfig_addr = res_config_addrs[rconfig->resource]; /* Set resource group */ err = twl_i2c_read_u8(<API key>, &grp, rconfig_addr + DEV_GRP_OFFSET); if (err) { pr_err("TWL4030 Resource %d group could not be read\n", rconfig->resource); return err; } if (rconfig->devgroup != <API key>) { grp &= ~DEV_GRP_MASK; grp |= rconfig->devgroup << DEV_GRP_SHIFT; err = twl_i2c_write_u8(<API key>, grp, rconfig_addr + DEV_GRP_OFFSET); if (err < 0) { pr_err("TWL4030 failed to program devgroup\n"); return err; } } /* Set resource types */ err = twl_i2c_read_u8(<API key>, &type, rconfig_addr + TYPE_OFFSET); if (err < 0) { pr_err("TWL4030 Resource %d type could not be read\n", rconfig->resource); return err; } if (rconfig->type != <API key>) { type &= ~TYPE_MASK; type |= rconfig->type << TYPE_SHIFT; } if (rconfig->type2 != <API key>) { type &= ~TYPE2_MASK; type |= rconfig->type2 << TYPE2_SHIFT; } err = twl_i2c_write_u8(<API key>, type, rconfig_addr + TYPE_OFFSET); if (err < 0) { pr_err("TWL4030 failed to program resource type\n"); return err; } /* Set remap states */ err = twl_i2c_read_u8(<API key>, &remap, rconfig_addr + REMAP_OFFSET); if (err < 0) { pr_err("TWL4030 Resource %d remap could not be read\n", rconfig->resource); return err; } if (rconfig->remap_off != <API key>) { remap &= ~OFF_STATE_MASK; remap |= rconfig->remap_off << OFF_STATE_SHIFT; } if (rconfig->remap_sleep != <API key>) { remap &= ~SLEEP_STATE_MASK; remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT; } err = twl_i2c_write_u8(<API key>, remap, rconfig_addr + REMAP_OFFSET); if (err < 0) { pr_err("TWL4030 failed to program remap\n"); return err; } return 0; } static int load_twl4030_script(struct twl4030_script *tscript, u8 address) { int err; static int order; /* Make sure the script isn't going beyond last valid address (0x3f) */ if ((address + tscript->size) > END_OF_SCRIPT) { pr_err("TWL4030 scripts too big error\n"); return -EINVAL; } err = <API key>(address, tscript->script, tscript->size); if (err) goto out; if (tscript->flags & TWL4030_WRST_SCRIPT) { err = <API key>(address); if (err) goto out; } if (tscript->flags & <API key>) { /* Reset any existing sleep script to avoid hangs on reboot */ err = twl_i2c_write_u8(<API key>, END_OF_SCRIPT, R_SEQ_ADD_A2S); if (err) goto out; err = <API key>(address); if (err) goto out; order = 1; } if (tscript->flags & <API key>) { err = <API key>(address); if (err) goto out; } if (tscript->flags & <API key>) { if (!order) pr_warning("TWL4030: Bad order of scripts (sleep "\ "script before wakeup) Leads to boot"\ "failure on some boards\n"); err = <API key>(address); } out: return err; } int <API key>(u8 flags) { int err = 0; err = twl_i2c_write_u8(<API key>, <API key>, <API key>); if (err) { pr_err("twl4030: unable to unlock PROTECT_KEY\n"); return err; } err = twl_i2c_write_u8(<API key>, <API key>, <API key>); if (err) { pr_err("twl4030: unable to unlock PROTECT_KEY\n"); return err; } if (flags & TWL4030_WRST_SCRIPT) { err = twl_i2c_write_u8(<API key>, END_OF_SCRIPT, R_SEQ_ADD_WARM); if (err) return err; } if (flags & <API key>) { err = twl_i2c_write_u8(<API key>, END_OF_SCRIPT, R_SEQ_ADD_S2A12); if (err) return err; } if (flags & <API key>) { err = twl_i2c_write_u8(<API key>, END_OF_SCRIPT, R_SEQ_ADD_S2A3); if (err) return err; } if (flags & <API key>) { err = twl_i2c_write_u8(<API key>, END_OF_SCRIPT, R_SEQ_ADD_A2S); if (err) return err; } err = twl_i2c_write_u8(<API key>, 0, <API key>); if (err) pr_err("TWL4030 Unable to relock registers\n"); return err; } static int <API key>(const struct twl4030_power_data *pdata) { int err; int i; u8 address = <API key>; for (i = 0; i < pdata->num; i++) { err = load_twl4030_script(pdata->scripts[i], address); if (err) return err; address += pdata->scripts[i]->size; } return 0; } static void <API key>(struct twl4030_resconfig *common, struct twl4030_resconfig *board) { while (common->resource) { struct twl4030_resconfig *b = board; while (b->resource) { if (b->resource == common->resource) { *common = *b; break; } b++; } common++; } } static int <API key>(const struct twl4030_power_data *pdata) { struct twl4030_resconfig *resconfig = pdata->resource_config; struct twl4030_resconfig *boardconf = pdata->board_config; int err; if (resconfig) { if (boardconf) <API key>(resconfig, boardconf); while (resconfig->resource) { err = <API key>(resconfig); if (err) return err; resconfig++; } } return 0; } static int <API key>(u8 bitmask, u8 bitvalues) { u8 regs[3] = { <API key>, <API key>, <API key>, }; u8 val; int i, err; err = twl_i2c_write_u8(<API key>, <API key>, <API key>); if (err) goto relock; err = twl_i2c_write_u8(<API key>, <API key>, <API key>); if (err) goto relock; for (i = 0; i < sizeof(regs); i++) { err = twl_i2c_read_u8(<API key>, &val, regs[i]); if (err) break; val = (~bitmask & val) | (bitmask & bitvalues); err = twl_i2c_write_u8(<API key>, val, regs[i]); if (err) break; } if (err) pr_err("TWL4030 Register access failed: %i\n", err); relock: return twl_i2c_write_u8(<API key>, 0, <API key>); } /* * In master mode, start the power off sequence. * After a successful execution, TWL shuts down the power to the SoC * and all peripherals connected to it. */ void twl4030_power_off(void) { int err; /* Disable start on charger or VBUS as it can break poweroff */ err = <API key>(STARTON_VBUS | STARTON_CHG, 0); if (err) pr_err("TWL4030 Unable to configure start-up\n"); err = twl_i2c_write_u8(<API key>, PWR_DEVOFF, <API key>); if (err) pr_err("TWL4030 Unable to power off\n"); } static bool <API key>(const struct twl4030_power_data *pdata, struct device_node *node) { if (pdata && pdata->use_poweroff) return true; if (<API key>(node, "ti,<API key>")) return true; if (<API key>(node, "ti,use_poweroff")) return true; return false; } #ifdef CONFIG_OF /* Generic warm reset configuration for omap3 */ static struct twl4030_ins omap3_wrst_seq[] = { TWL_RESOURCE_OFF(RES_NRES_PWRON), TWL_RESOURCE_OFF(RES_RESET), TWL_RESOURCE_RESET(RES_MAIN_REF), <API key>(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2), TWL_RESOURCE_RESET(RES_VUSB_3V1), <API key>(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1), <API key>(RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0), TWL_RESOURCE_ON(RES_RESET), TWL_RESOURCE_ON(RES_NRES_PWRON), }; static struct twl4030_script omap3_wrst_script = { .script = omap3_wrst_seq, .size = ARRAY_SIZE(omap3_wrst_seq), .flags = TWL4030_WRST_SCRIPT, }; static struct twl4030_script *omap3_reset_scripts[] = { &omap3_wrst_script, }; static struct twl4030_resconfig omap3_rconfig[] = { TWL_REMAP_SLEEP(RES_HFCLKOUT, DEV_GRP_P3, -1, -1), TWL_REMAP_SLEEP(RES_VDD1, DEV_GRP_P1, -1, -1), TWL_REMAP_SLEEP(RES_VDD2, DEV_GRP_P1, -1, -1), { 0, 0 }, }; static struct twl4030_power_data omap3_reset = { .scripts = omap3_reset_scripts, .num = ARRAY_SIZE(omap3_reset_scripts), .resource_config = omap3_rconfig, }; /* Recommended generic default idle configuration for off-idle */ /* Broadcast message to put res to sleep */ static struct twl4030_ins <API key>[] = { <API key>(RES_GRP_ALL, RES_TYPE_ALL, 0), }; static struct twl4030_script <API key> = { .script = <API key>, .size = ARRAY_SIZE(<API key>), .flags = <API key>, }; /* Broadcast message to put res to active */ static struct twl4030_ins <API key>[] = { <API key>(RES_GRP_ALL, RES_TYPE_ALL, 0), }; static struct twl4030_script <API key> = { .script = <API key>, .size = ARRAY_SIZE(<API key>), .flags = <API key>, }; /* Broadcast message to put res to active */ static struct twl4030_ins <API key>[] = { <API key>(RES_CLKEN, 0x37), <API key>(RES_GRP_ALL, RES_TYPE_ALL, 0), }; static struct twl4030_script <API key> = { .script = <API key>, .size = ARRAY_SIZE(<API key>), .flags = <API key>, }; static struct twl4030_script *omap3_idle_scripts[] = { &<API key>, &<API key>, &omap3_wrst_script, &<API key>, }; static struct twl4030_resconfig omap3_idle_rconfig[] = { TWL_REMAP_SLEEP(RES_VAUX1, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VAUX2, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VAUX3, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VAUX4, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VMMC1, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VMMC2, <API key>, 0, 0), TWL_REMAP_OFF(RES_VPLL1, DEV_GRP_P1, 3, 1), TWL_REMAP_SLEEP(RES_VPLL2, DEV_GRP_P1, 0, 0), TWL_REMAP_SLEEP(RES_VSIM, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VDAC, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VINTANA1, TWL_DEV_GRP_P123, 1, 2), TWL_REMAP_SLEEP(RES_VINTANA2, TWL_DEV_GRP_P123, 0, 2), TWL_REMAP_SLEEP(RES_VINTDIG, TWL_DEV_GRP_P123, 1, 2), TWL_REMAP_SLEEP(RES_VIO, TWL_DEV_GRP_P123, 2, 2), TWL_REMAP_OFF(RES_VDD1, DEV_GRP_P1, 4, 1), TWL_REMAP_OFF(RES_VDD2, DEV_GRP_P1, 3, 1), TWL_REMAP_SLEEP(RES_VUSB_1V5, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VUSB_1V8, <API key>, 0, 0), TWL_REMAP_SLEEP(RES_VUSB_3V1, TWL_DEV_GRP_P123, 0, 0), /* Resource #20 USB charge pump skipped */ TWL_REMAP_SLEEP(RES_REGEN, TWL_DEV_GRP_P123, 2, 1), TWL_REMAP_SLEEP(RES_NRES_PWRON, TWL_DEV_GRP_P123, 0, 1), TWL_REMAP_SLEEP(RES_CLKEN, TWL_DEV_GRP_P123, 3, 2), TWL_REMAP_SLEEP(RES_SYSEN, TWL_DEV_GRP_P123, 6, 1), TWL_REMAP_SLEEP(RES_HFCLKOUT, DEV_GRP_P3, 0, 2), TWL_REMAP_SLEEP(RES_32KCLKOUT, TWL_DEV_GRP_P123, 0, 0), TWL_REMAP_SLEEP(RES_RESET, TWL_DEV_GRP_P123, 6, 0), TWL_REMAP_SLEEP(RES_MAIN_REF, TWL_DEV_GRP_P123, 0, 0), { /* Terminator */ }, }; static struct twl4030_power_data omap3_idle = { .scripts = omap3_idle_scripts, .num = ARRAY_SIZE(omap3_idle_scripts), .resource_config = omap3_idle_rconfig, }; /* Disable 32 KiHz oscillator during idle */ static struct twl4030_resconfig osc_off_rconfig[] = { TWL_REMAP_OFF(RES_CLKEN, DEV_GRP_P1 | DEV_GRP_P3, 3, 2), { /* Terminator */ }, }; static struct twl4030_power_data osc_off_idle = { .scripts = omap3_idle_scripts, .num = ARRAY_SIZE(omap3_idle_scripts), .resource_config = omap3_idle_rconfig, .board_config = osc_off_rconfig, }; static struct of_device_id <API key>[] = { { .compatible = "ti,twl4030-power", }, { .compatible = "ti,twl4030-power-reset", .data = &omap3_reset, }, { .compatible = "ti,twl4030-power-idle", .data = &omap3_idle, }, { .compatible = "ti,<API key>", .data = &osc_off_idle, }, { }, }; MODULE_DEVICE_TABLE(of, <API key>); #endif /* CONFIG_OF */ static int twl4030_power_probe(struct platform_device *pdev) { const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev); struct device_node *node = pdev->dev.of_node; const struct of_device_id *match; int err = 0; int err2 = 0; u8 val; if (!pdata && !node) { dev_err(&pdev->dev, "Platform data is missing\n"); return -EINVAL; } err = twl_i2c_write_u8(<API key>, <API key>, <API key>); err |= twl_i2c_write_u8(<API key>, <API key>, <API key>); if (err) { pr_err("TWL4030 Unable to unlock registers\n"); return err; } match = of_match_device(of_match_ptr(<API key>), &pdev->dev); if (match && match->data) pdata = match->data; if (pdata) { err = <API key>(pdata); if (err) { pr_err("TWL4030 failed to load scripts\n"); goto relock; } err = <API key>(pdata); if (err) { pr_err("TWL4030 failed to configure resource\n"); goto relock; } } /* Board has to be wired properly to use this feature */ if (<API key>(pdata, node) && !pm_power_off) { /* Default for SEQ_OFFSYNC is set, lets ensure this */ err = twl_i2c_read_u8(<API key>, &val, <API key>); if (err) { pr_warning("TWL4030 Unable to read registers\n"); } else if (!(val & SEQ_OFFSYNC)) { val |= SEQ_OFFSYNC; err = twl_i2c_write_u8(<API key>, val, <API key>); if (err) { pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n"); goto relock; } } pm_power_off = twl4030_power_off; } relock: err2 = twl_i2c_write_u8(<API key>, 0, <API key>); if (err2) { pr_err("TWL4030 Unable to relock registers\n"); return err2; } return err; } static int <API key>(struct platform_device *pdev) { return 0; } static struct platform_driver <API key> = { .driver = { .name = "twl4030_power", .of_match_table = of_match_ptr(<API key>), }, .probe = twl4030_power_probe, .remove = <API key>, }; <API key>(<API key>); MODULE_AUTHOR("Nokia Corporation"); MODULE_AUTHOR("Texas Instruments, Inc."); MODULE_DESCRIPTION("Power management for TWL4030"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:twl4030_power");
// { dg-do assemble } // by Alexandre Oliva <aoliva@cygnus.com> // distilled from libg++'s Fix.cc struct Integer { ~Integer () {} }; void foo (const Integer& y); Integer bar (const Integer& x); void show (const Integer& x) { foo (bar (x)); }
/* <API key>: GPL-2.0 or BSD-3-Clause */ /* Authors: Bernard Metzler <bmt@zurich.ibm.com> */ #ifndef _SIW_MEM_H #define _SIW_MEM_H struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable); void siw_umem_release(struct siw_umem *umem, bool dirty); struct siw_pbl *siw_pbl_alloc(u32 num_buf); dma_addr_t siw_pbl_get_buffer(struct siw_pbl *pbl, u64 off, int *len, int *idx); struct siw_mem *siw_mem_id2obj(struct siw_device *sdev, int stag_index); int siw_mem_add(struct siw_device *sdev, struct siw_mem *m); int siw_invalidate_stag(struct ib_pd *pd, u32 stag); int siw_check_mem(struct ib_pd *pd, struct siw_mem *mem, u64 addr, enum ib_access_flags perms, int len); int siw_check_sge(struct ib_pd *pd, struct siw_sge *sge, struct siw_mem *mem[], enum ib_access_flags perms, u32 off, int len); void siw_wqe_put_mem(struct siw_wqe *wqe, enum siw_opcode op); int siw_mr_add_mem(struct siw_mr *mr, struct ib_pd *pd, void *mem_obj, u64 start, u64 len, int rights); void siw_mr_drop_mem(struct siw_mr *mr); void siw_free_mem(struct kref *ref); static inline void siw_mem_put(struct siw_mem *mem) { kref_put(&mem->ref, siw_free_mem); } static inline struct siw_mr *siw_mem2mr(struct siw_mem *m) { return container_of(m, struct siw_mr, mem); } static inline void siw_unref_mem_sgl(struct siw_mem **mem, unsigned int num_sge) { while (num_sge) { if (*mem == NULL) break; siw_mem_put(*mem); *mem = NULL; mem++; num_sge } } #define CHUNK_SHIFT 9 /* sets number of pages per chunk */ #define PAGES_PER_CHUNK (_AC(1, UL) << CHUNK_SHIFT) #define CHUNK_MASK (~(PAGES_PER_CHUNK - 1)) #define PAGE_CHUNK_SIZE (PAGES_PER_CHUNK * sizeof(struct page *)) /* * siw_get_upage() * * Get page pointer for address on given umem. * * @umem: two dimensional list of page pointers * @addr: user virtual address */ static inline struct page *siw_get_upage(struct siw_umem *umem, u64 addr) { unsigned int page_idx = (addr - umem->fp_addr) >> PAGE_SHIFT, chunk_idx = page_idx >> CHUNK_SHIFT, page_in_chunk = page_idx & ~CHUNK_MASK; if (likely(page_idx < umem->num_pages)) return umem->page_chunk[chunk_idx].plist[page_in_chunk]; return NULL; } #endif
// { dg-do assemble } // GROUPS passed patches // patches file // From: david.binderman@pmsr.philips.co.uk // Subject: Reno 1.2 bug fix // Message-ID: <9310061605.AA04160@pmsr.philips.co.uk> int type(float) { return 1; } int type(double) { return 2; } int type(long double) { return 3; } extern "C" int printf( const char *, ...); int main() { int i = 0; if (type(0.0) != 2) ++i; if (i > 0) { printf ("FAIL\n"); return 1; } else printf ("PASS\n"); }
<?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 class <API key> extends restore_subplugin { /** * Returns the paths to be handled by the subplugin at workshop level * @return array */ protected function <API key>() { $paths = array(); $elename = $this->get_namefor('submission'); $elepath = $this->get_pathfor('/submission_file'); // We used <API key>() so this works. $paths[] = new <API key>($elename, $elepath); return $paths; } /** * Processes one submission_file element * @param mixed $data * @return void */ public function <API key>($data) { global $DB; $data = (object)$data; $data->assignment = $this->get_new_parentid('assign'); $oldsubmissionid = $data->submission; // The mapping is set in the restore for the core assign activity // when a submission node is processed. $data->submission = $this->get_mappingid('submission', $data->submission); $DB->insert_record('<API key>', $data); $this->add_related_files('<API key>', 'submission_files', 'submission', null, $oldsubmissionid); } }
<?php namespace Assetic\Factory\Resource; /** * A resource is something formulae can be loaded from. * * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ interface <API key> extends ResourceInterface, \IteratorAggregate { }
#include "db/log_writer.h" #include <stdint.h> #include "leveldb/env.h" #include "util/coding.h" #include "util/crc32c.h" namespace leveldb { namespace log { Writer::Writer(WritableFile* dest) : dest_(dest), block_offset_(0) { for (int i = 0; i <= kMaxRecordType; i++) { char t = static_cast<char>(i); type_crc_[i] = crc32c::Value(&t, 1); } } Writer::~Writer() { } Status Writer::AddRecord(const Slice& slice) { const char* ptr = slice.data(); size_t left = slice.size(); // Fragment the record if necessary and emit it. Note that if slice // is empty, we still want to iterate once to emit a single // zero-length record Status s; bool begin = true; do { const int leftover = kBlockSize - block_offset_; assert(leftover >= 0); if (leftover < kHeaderSize) { // Switch to a new block if (leftover > 0) { // Fill the trailer (literal below relies on kHeaderSize being 7) assert(kHeaderSize == 7); dest_->Append(Slice("\x00\x00\x00\x00\x00\x00", leftover)); } block_offset_ = 0; } // Invariant: we never leave < kHeaderSize bytes in a block. assert(kBlockSize - block_offset_ - kHeaderSize >= 0); const size_t avail = kBlockSize - block_offset_ - kHeaderSize; const size_t fragment_length = (left < avail) ? left : avail; RecordType type; const bool end = (left == fragment_length); if (begin && end) { type = kFullType; } else if (begin) { type = kFirstType; } else if (end) { type = kLastType; } else { type = kMiddleType; } s = EmitPhysicalRecord(type, ptr, fragment_length); ptr += fragment_length; left -= fragment_length; begin = false; } while (s.ok() && left > 0); return s; } Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) { assert(n <= 0xffff); // Must fit in two bytes assert(block_offset_ + kHeaderSize + n <= kBlockSize); // Format the header char buf[kHeaderSize]; buf[4] = static_cast<char>(n & 0xff); buf[5] = static_cast<char>(n >> 8); buf[6] = static_cast<char>(t); // Compute the crc of the record type and the payload. uint32_t crc = crc32c::Extend(type_crc_[t], ptr, n); crc = crc32c::Mask(crc); // Adjust for storage EncodeFixed32(buf, crc); // Write the header and the payload Status s = dest_->Append(Slice(buf, kHeaderSize)); if (s.ok()) { s = dest_->Append(Slice(ptr, n)); if (s.ok()) { s = dest_->Flush(); } } block_offset_ += kHeaderSize + n; return s; } } // namespace log } // namespace leveldb
#ifndef __ASM_SH_CACHE_H #define __ASM_SH_CACHE_H #ifdef __KERNEL__ #include <linux/init.h> #include <cpu/cache.h> #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) #define __read_mostly __attribute__((__section__(".data..read_mostly"))) #ifndef __ASSEMBLY__ struct cache_info { unsigned int ways; /* Number of cache ways */ unsigned int sets; /* Number of cache sets */ unsigned int linesz; /* Cache line size (bytes) */ unsigned int way_size; /* sets * line size */ /* * way_incr is the address offset for accessing the next way * in memory mapped cache array ops. */ unsigned int way_incr; unsigned int entry_shift; unsigned int entry_mask; /* * Compute a mask which selects the address bits which overlap between * 1. those used to select the cache set during indexing * 2. those in the physical page number. */ unsigned int alias_mask; unsigned int n_aliases; /* Number of aliases */ unsigned long flags; }; #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* __ASM_SH_CACHE_H */
-- Vazruden the herald DELETE FROM `creature_text` WHERE `entry`=17307; INSERT INTO `creature_text`(`entry`,`groupid`,`id`,`type`,`probability`,`sound`,`comment`,`text`) VALUES (17307,0,0,14,100,10292,"vazruden the herald SAY_INTRO","You have faced many challenges, pity they were all in vain. Soon your people will kneel to my lord!"); -- Nazan DELETE FROM `creature_text` WHERE `entry`=17536; INSERT INTO `creature_text`(`entry`,`groupid`,`id`,`type`,`probability`,`comment`,`text`) VALUE (17536,0,0,41,100,"nazan EMOTE","%s descends from the sky"); -- Vazruden DELETE FROM `creature_text` WHERE `entry`=17537; INSERT INTO `creature_text`(`entry`,`groupid`,`id`,`type`,`probability`,`sound`,`comment`,`text`) VALUES (17537,0,0,14,100,10293,"vazruden SAY_WIPE","Is there no one left to test me?"), (17537,1,0,14,100,10294,"vazruden SAY_AGGRO_1","Your time is running out!"), (17537,1,1,14,100,10295,"vazruden SAY_AGGRO_2","You are nothing, I answer a higher call!"), (17537,1,2,14,100,10296,"vazruden SAY_AGGRO_3","The Dark Lord laughs at you!"), (17537,2,0,14,100,10297,"vazruden SAY_KILL_1","It is over. Finished!"), (17537,2,1,14,100,10298,"vazruden SAY_KILL_2","Your days are done!"), (17537,3,0,14,100,10299,"vazruden SAY_DIE","My lord will be the end you all..."); -- Talbot aka Prince Valanar (There's an UpdateEntry() call in the script which I did not see) UPDATE `creature_text` SET `entry`=28189 WHERE `entry`=25301; -- Darion Mograine UPDATE `creature_text` SET `entry`=29228 WHERE `entry`=29173 AND `groupid`=74; -- Core rager UPDATE `creature_text` SET `entry`=11672 WHERE `entry`=11988; DELETE FROM `creature_text` WHERE `entry` IN (15550,16151); INSERT INTO `creature_text`(`entry`,`groupid`,`id`,`type`,`probability`,`sound`,`comment`,`text`) VALUES -- Attumen (15550,0,0,14,100,9169,"attumen SAY_KILL1","It was... inevitable."), (15550,0,1,14,100,9300,"attumen SAY_KILL2","Another trophy to add to my collection!"), (15550,1,0,14,100,9166,"attumen SAY_DISARMED","Weapons are merely a convenience for a warrior of my skill!"), (15550,2,0,14,100,9165,"attumen SAY_DEATH","I always knew... someday I would become... the hunted."), (15550,3,0,14,100,9170,"attumen SAY_RANDOM1","Such easy sport."), (15550,3,1,14,100,9304,"attumen SAY_RANDOM2","Amateurs! Do not think you can best me! I kill for a living."), -- Midnight (16151,0,0,14,100,9173,"attumen SAY_MIDNIGHT_KILL","Well done Midnight!"), (16151,1,0,14,100,9167,"attumen SAY_APPEAR1","Cowards! Wretches!"), (16151,1,1,14,100,9298,"attumen SAY_APPEAR2","Who dares attack the steed of the Huntsman?"), (16151,1,2,14,100,9299,"attumen SAY_APPEAR3","Perhaps you would rather test yourselves against a more formidable opponent?!"), (16151,2,0,14,100,9168,"attumen SAY_MOUNT","Come, Midnight, let\'s disperse this petty rabble!"); -- Creature text preparation for rajaxx DELETE FROM `creature_text` WHERE `entry` IN (15471,15341); INSERT INTO `creature_text`(`entry`,`groupid`,`sound`,`type`,`probability`,`comment`,`text`) VALUES (15471,0,0,14,100,"andorov SAY_ANDOROV_INTRO","They come now. Try not to get yourself killed, young blood."), (15471,1,0,14,100,"andorov SAY_ANDOROV_ATTACK","Remember, Rajaxx, when I said I\'d kill you last? I lied..."), (15341,0,8612,14,100,"rajaxx SAY_WAVE3","The time of our retribution is at hand! Let darkness reign in the hearts of our enemies!"), (15341,1,8610,14,100,"rajaxx SAY_WAVE4","No longer will we wait behind barred doors and walls of stone! No longer will our vengeance be denied! The dragons themselves will tremble before our wrath!"), (15341,2,8608,14,100,"rajaxx SAY_WAVE5","Fear is for the enemy! Fear and death!"), (15341,3,8611,14,100,"rajaxx SAY_WAVE6","Staghelm will whimper and beg for his life, just as his whelp of a son did! One thousand years of injustice will end this day!"), (15341,4,8607,14,100,"rajaxx SAY_WAVE7","Fandral! Your time has come! Go and hide in the Emerald Dream and pray we never find you!"), (15341,5,8609,14,100,"rajaxx SAY_INTRO","Impudent fool! I will kill you myself!"), (15341,6,8603,14,100,"rajaxx SAY_UNK1","Attack and make them pay dearly!"), (15341,7,8605,14,100,"rajaxx SAY_UNK2","Crush them! Drive them out!"), (15341,8,8606,14,100,"rajaxx SAY_UNK3","Do not hesitate! Destroy them!"), (15341,9,8613,14,100,"rajaxx SAY_UNK4","Warriors! Captains! Continue the fight!"), (15341,10,8614,14,100,"rajaxx SAY_DEAGGRO","You are not worth my time $N!"), (15341,11,8604,14,100,"rajaxx SAY_KILLS_ANDOROV","Breath your last!"), (15341,12,0,14,100,"rajaxx SAY_COMPLETE_QUEST","Soon you will know the price of your meddling, mortals... The master is nearly whole... And when he rises, your world will be cease!"); -- moam DELETE FROM `creature_text` WHERE `entry`=15340; INSERT INTO `creature_text`(`entry`,`groupid`,`type`,`probability`,`comment`,`text`) VALUES (15340,0,16,100,"moam EMOTE_AGGRO","%s senses your fear."), (15340,1,16,100,"moan EMOTE_MANA_FULL","%s bristles with energy!"); -- buru DELETE FROM `creature_text` WHERE `entry`=15370; INSERT INTO `creature_text`(`entry`,`groupid`,`type`,`probability`,`comment`,`text`) VALUES (15370,0,16,100,"buru EMOTE_TARGET","%s sets eyes on $N!");
(function() { "use strict"; var WORD = /[\w$]+/, RANGE = 500; CodeMirror.registerHelper("hint", "anyword", function(editor, options) { var word = options && options.word || WORD; var range = options && options.range || RANGE; var cur = editor.getCursor(), curLine = editor.getLine(cur.line); var start = cur.ch, end = start; while (end < curLine.length && word.test(curLine.charAt(end))) ++end; while (start && word.test(curLine.charAt(start - 1))) --start; var curWord = start != end && curLine.slice(start, end); var list = [], seen = {}; var re = new RegExp(word.source, "g"); for (var dir = -1; dir <= 1; dir += 2) { var line = cur.line, end = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; for (; line != end; line += dir) { var text = editor.getLine(line), m; while (m = re.exec(text)) { if (line == cur.line && m[0] === curWord) continue; if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) { seen[m[0]] = true; list.push(m[0]); } } } } return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; }); })();
DROP TABLE IF EXISTS `character_tutorial`; CREATE TABLE `character_tutorial` ( `account` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Account Identifier', `realmid` int(11) unsigned NOT NULL default '0' COMMENT 'Realm Identifier', `tut0` int(11) unsigned NOT NULL default '0', `tut1` int(11) unsigned NOT NULL default '0', `tut2` int(11) unsigned NOT NULL default '0', `tut3` int(11) unsigned NOT NULL default '0', `tut4` int(11) unsigned NOT NULL default '0', `tut5` int(11) unsigned NOT NULL default '0', `tut6` int(11) unsigned NOT NULL default '0', `tut7` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`account`,`realmid`), KEY acc_key (`account`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System';
/* 'aes_xcbc.c' Obfuscated by COBF (Version 1.06 2006-01-07 by BB) at Fri Oct 12 22:15:16 2012 */ #include"cobf.h" #ifdef _WIN32 #if defined( UNDER_CE) && defined( bb337) || ! defined( bb329) #define bb355 1 #define bb332 1 #else #define bb351 bb343 #define bb333 1 #define bb331 1 #endif #define bb348 1 #include"uncobf.h" #include<ndis.h> #include"cobf.h" #ifdef UNDER_CE #include"uncobf.h" #include<ndiswan.h> #include"cobf.h" #endif #include"uncobf.h" #include<stdio.h> #include<basetsd.h> #include"cobf.h" bba bbs bbl bbf, *bb1;bba bbs bbe bbq, *bb93;bba bb135 bb124, *bb334; bba bbs bbl bb40, *bb72;bba bbs bb135 bbk, *bb59;bba bbe bbu, *bb133; bba bbh bbf*bb89; #ifdef bb311 bba bbd bb60, *bb122; #endif #else #include"uncobf.h" #include<linux/module.h> #include<linux/ctype.h> #include<linux/time.h> #include<linux/slab.h> #include"cobf.h" #ifndef bb116 #define bb116 #ifdef _WIN32 #include"uncobf.h" #include<wtypes.h> #include"cobf.h" #else #ifdef bb120 #include"uncobf.h" #include<linux/types.h> #include"cobf.h" #else #include"uncobf.h" #include<stddef.h> #include<sys/types.h> #include"cobf.h" #endif #endif #ifdef _WIN32 bba bb119 bb215; #else bba bbe bbu, *bb133, *bb246; #define bb201 1 #define bb202 0 bba bb251 bb205, *bb240, *bb208;bba bbe bb285, *bb283, *bb262;bba bbs bbq, *bb93, *bb270;bba bb6 bb238, *bb216;bba bbs bb6 bb263, *bb250; bba bb6 bb111, *bb222;bba bbs bb6 bb63, *bb289;bba bb63 bb264, *bb207 ;bba bb63 bb219, *bb254;bba bb111 bb119, *bb226;bba bb243 bb247;bba bb279 bb124;bba bb230 bb83;bba bb118 bb112;bba bb118 bb253; #ifdef bb211 bba bb282 bb40, *bb72;bba bb258 bbk, *bb59;bba bb232 bbd, *bb28;bba bb256 bb56, *bb113; #else bba bb271 bb40, *bb72;bba bb229 bbk, *bb59;bba bb233 bbd, *bb28;bba bb277 bb56, *bb113; #endif bba bb40 bbf, *bb1, *bb214;bba bbk bb237, *bb245, *bb224;bba bbk bb255 , *bb220, *bb248;bba bbd bb60, *bb122, *bb206;bba bb83 bb37, *bb274, * bb252;bba bbd bb290, *bb275, *bb210;bba bb112 bb265, *bb291, *bb269; bba bb56 bb227, *bb261, *bb223; #define bb140 bbb bba bbb*bb221, *bb77;bba bbh bbb*bb225;bba bbl bb287;bba bbl*bb276; bba bbh bbl*bb82; #if defined( bb120) bba bbe bb115; #endif bba bb115 bb20;bba bb20*bb218;bba bbh bb20*bb187; #if defined( bb213) || defined( bb266) bba bb20 bb36;bba bb20 bb114; #else bba bbl bb36;bba bbs bbl bb114; #endif bba bbh bb36*bb257;bba bb36*bb244;bba bb60 bb212, *bb239;bba bbb* bb106;bba bb106*bb241; #define bb281( bb34) bbi bb34##__ { bbe bb228; }; bba bbi bb34##__ * \ bb34 bba bbi{bb37 bb188,bb242,bb231,bb260;}bb286, *bb234, *bb278;bba bbi{ bb37 bb8,bb193;}bb280, *bb235, *bb259;bba bbi{bb37 bb267,bb249;}bb236 , *bb217, *bb284; #endif bba bbh bbf*bb89; #endif bba bbf bb100; #define IN #define OUT #ifdef _DEBUG #define bb139( bbc) bb31( bbc) #else #define bb139( bbc) ( bbb)( bbc) #endif bba bbe bb161, *bb173; #define bb209 0 #define bb314 1 #define bb298 2 #define bb324 3 #define bb346 4 bba bbe bb349;bba bbb*bb121; #endif #ifdef _WIN32 #ifndef UNDER_CE #define bb30 bb344 #define bb43 bb335 bba bbs bb6 bb30;bba bb6 bb43; #endif #else #endif #ifdef _WIN32 bbb*bb128(bb30 bb47);bbb bb105(bbb* );bbb*bb137(bb30 bb159,bb30 bb47); #else #define bb128( bbc) bb146(1, bbc, bb142) #define bb105( bbc) bb342( bbc) #define bb137( bbc, bbn) bb146( bbc, bbn, bb142) #endif #ifdef _WIN32 #define bb31( bbc) bb358( bbc) #else #ifdef _DEBUG bbe bb145(bbh bbl*bb95,bbh bbl*bb25,bbs bb272); #define bb31( bbc) ( bbb)(( bbc) || ( bb145(# bbc, __FILE__, __LINE__ \ ))) #else #define bb31( bbc) (( bbb)0) #endif #endif bb43 bb301(bb43*bb320); #ifndef _WIN32 bbe bb328(bbh bbl*bbg);bbe bb322(bbh bbl*bb19,...); #endif #ifdef _WIN32 bba bb353 bb96; #define bb141( bbc) bb356( bbc) #define bb144( bbc) bb345( bbc) #define bb134( bbc) bb350( bbc) #define bb132( bbc) bb339( bbc) #else bba bb347 bb96; #define bb141( bbc) ( bbb)( * bbc = bb330( bbc)) #define bb144( bbc) (( bbb)0) #define bb134( bbc) bb352( bbc) #define bb132( bbc) bb354( bbc) #endif #ifdef __cplusplus bbr"\x43"{ #endif #ifdef __cplusplus bbr"\x43"{ #endif bba bbi{bbq bb456;bbd bb417[4 * (14 +1 )];}bb363;bbb bb1098(bb363*bbj, bbh bbb*bb71,bbq bb143);bbb bb1736(bb363*bbj,bbh bbb*bb71,bbq bb143); bbb bb1034(bb363*bbj,bbb*bb14,bbh bbb*bb5);bbb bb1779(bb363*bbj,bbb* bb14,bbh bbb*bb5); #ifdef __cplusplus } #endif bba bbi{bb363 bb2116;bbq bb10;bbf bb101[16 ];bbf bb1927[16 ];bbf bb1926 [16 ];bbf bb1842[16 ];}bb944;bbb bb2041(bb944*bbj,bbh bbb*bb71,bbq bb143 );bbb bb2092(bb944*bbj,bbh bbb*bb5,bbq bb10);bbb bb2102(bb944*bbj,bbb *bb14); #ifdef __cplusplus } #endif bbb bb2041(bb944*bbj,bbh bbb*bb71,bbq bb143){bb363 bb2148;bbf bb2179[ 16 ];bbj->bb10=0 ;bb31(bb143==16 );bb1098(&bb2148,bb71,bb143);bb996(bbj ->bb1842,0 ,16 );bb996(bb2179,1 ,16 );bb1034(&bb2148,bb2179,bb2179);bb996 (bbj->bb1927,2 ,16 );bb1034(&bb2148,bbj->bb1927,bbj->bb1927);bb996(bbj ->bb1926,3 ,16 );bb1034(&bb2148,bbj->bb1926,bbj->bb1926);bb1098(&bbj-> bb2116,bb2179,bb143);}bb41 bbb bb1252(bb944*bbj,bbh bbf*bb5){bbq bbz; bb90(bbz=0 ;bbz<16 ;bbz++)bbj->bb1842[bbz]^=bb5[bbz];bb1034(&bbj-> bb2116,bbj->bb1842,bbj->bb1842);}bbb bb2092(bb944*bbj,bbh bbb*bb498, bbq bb10){bbh bbf*bb5=(bbh bbf* )bb498;bbq bb384=bbj->bb10?(bbj->bb10 -1 )%16 +1 :0 ;bbj->bb10+=bb10;bbm(bb384){bbq bb11=16 -bb384;bb81(bbj-> bb101+bb384,bb5,((bb10)<(bb11)?(bb10):(bb11)));bbm(bb10<=bb11)bb2;bb5 +=bb11;bb10-=bb11;bb1252(bbj,bbj->bb101);}bb90(;bb10>16 ;bb10-=16 ,bb5 +=16 )bb1252(bbj,bb5);bb81(bbj->bb101,bb5,bb10);}bbb bb2102(bb944*bbj, bbb*bb14){bb1 bb3;bbq bbz,bb384=bbj->bb10?(bbj->bb10-1 )%16 +1 :0 ;bbm( bb384<16 ){bbj->bb101[bb384++]=0x80 ;bb996(bbj->bb101+bb384,0 ,16 -bb384); bb3=bbj->bb1926;}bb54 bb3=bbj->bb1927;bb90(bbz=0 ;bbz<16 ;bbz++)bbj-> bb101[bbz]^=bb3[bbz];bb1252(bbj,bbj->bb101);bb81(bb14,bbj->bb1842,16 ); }
import { addFormatToken } from '../format/format'; import { addUnitAlias } from './aliases'; import { addUnitPriority } from './priorities'; import { addRegexToken, match1to2, matchWord, regexEscape } from '../parse/regex'; import { addWeekParseToken } from '../parse/token'; import toInt from '../utils/to-int'; import isArray from '../utils/is-array'; import indexOf from '../utils/index-of'; import hasOwnProp from '../utils/has-own-prop'; import { createUTC } from '../create/utc'; import getParsingFlags from '../create/parsing-flags'; // FORMATTING addFormatToken('d', 0, 'do', 'day'); addFormatToken('dd', 0, 0, function (format) { return this.localeData().weekdaysMin(this, format); }); addFormatToken('ddd', 0, 0, function (format) { return this.localeData().weekdaysShort(this, format); }); addFormatToken('dddd', 0, 0, function (format) { return this.localeData().weekdays(this, format); }); addFormatToken('e', 0, 0, 'weekday'); addFormatToken('E', 0, 0, 'isoWeekday'); // ALIASES addUnitAlias('day', 'd'); addUnitAlias('weekday', 'e'); addUnitAlias('isoWeekday', 'E'); // PRIORITY addUnitPriority('day', 11); addUnitPriority('weekday', 11); addUnitPriority('isoWeekday', 11); // PARSING addRegexToken('d', match1to2); addRegexToken('e', match1to2); addRegexToken('E', match1to2); addRegexToken('dd', function (isStrict, locale) { return locale.weekdaysMinRegex(isStrict); }); addRegexToken('ddd', function (isStrict, locale) { return locale.weekdaysShortRegex(isStrict); }); addRegexToken('dddd', function (isStrict, locale) { return locale.weekdaysRegex(isStrict); }); addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { var weekday = config._locale.weekdaysParse(input, token, config._strict); // if we didn't get a weekday name, mark the date as invalid if (weekday != null) { week.d = weekday; } else { getParsingFlags(config).invalidWeekday = input; } }); addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { week[token] = toInt(input); }); // HELPERS function parseWeekday(input, locale) { if (typeof input !== 'string') { return input; } if (!isNaN(input)) { return parseInt(input, 10); } input = locale.weekdaysParse(input); if (typeof input === 'number') { return input; } return null; } function parseIsoWeekday(input, locale) { if (typeof input === 'string') { return locale.weekdaysParse(input) % 7 || 7; } return isNaN(input) ? null : input; } // LOCALES export var <API key> = '<API key>'.split('_'); export function localeWeekdays (m, format) { return isArray(this._weekdays) ? this._weekdays[m.day()] : this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()]; } export var <API key> = '<API key>'.split('_'); export function localeWeekdaysShort (m) { return this._weekdaysShort[m.day()]; } export var <API key> = '<API key>'.split('_'); export function localeWeekdaysMin (m) { return this._weekdaysMin[m.day()]; } function handleStrictParse(weekdayName, format, strict) { var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); if (!this._weekdaysParse) { this._weekdaysParse = []; this._shortWeekdaysParse = []; this._minWeekdaysParse = []; for (i = 0; i < 7; ++i) { mom = createUTC([2000, 1]).day(i); this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase(); this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase(); this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); } } if (strict) { if (format === 'dddd') { ii = indexOf.call(this._weekdaysParse, llc); return ii !== -1 ? ii : null; } else if (format === 'ddd') { ii = indexOf.call(this._shortWeekdaysParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } } else { if (format === 'dddd') { ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._shortWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } else if (format === 'ddd') { ii = indexOf.call(this._shortWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._minWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._shortWeekdaysParse, llc); return ii !== -1 ? ii : null; } } } export function localeWeekdaysParse (weekdayName, format, strict) { var i, mom, regex; if (this._weekdaysParseExact) { return handleStrictParse.call(this, weekdayName, format, strict); } if (!this._weekdaysParse) { this._weekdaysParse = []; this._minWeekdaysParse = []; this._shortWeekdaysParse = []; this._fullWeekdaysParse = []; } for (i = 0; i < 7; i++) { // make the regex if we don't have it already mom = createUTC([2000, 1]).day(i); if (strict && !this._fullWeekdaysParse[i]) { this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i'); this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i'); this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i'); } if (!this._weekdaysParse[i]) { regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); } // test the regex if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { return i; } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { return i; } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) { return i; } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { return i; } } } // MOMENTS export function getSetDayOfWeek (input) { if (!this.isValid()) { return input != null ? this : NaN; } var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); if (input != null) { input = parseWeekday(input, this.localeData()); return this.add(input - day, 'd'); } else { return day; } } export function <API key> (input) { if (!this.isValid()) { return input != null ? this : NaN; } var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; return input == null ? weekday : this.add(input - weekday, 'd'); } export function getSetISODayOfWeek (input) { if (!this.isValid()) { return input != null ? this : NaN; } // behaves the same as moment#day except // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) // as a setter, sunday should belong to the previous week. if (input != null) { var weekday = parseIsoWeekday(input, this.localeData()); return this.day(this.day() % 7 ? weekday : weekday - 7); } else { return this.day() || 7; } } var <API key> = matchWord; export function weekdaysRegex (isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { <API key>.call(this); } if (isStrict) { return this.<API key>; } else { return this._weekdaysRegex; } } else { if (!hasOwnProp(this, '_weekdaysRegex')) { this._weekdaysRegex = <API key>; } return this.<API key> && isStrict ? this.<API key> : this._weekdaysRegex; } } var <API key> = matchWord; export function weekdaysShortRegex (isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { <API key>.call(this); } if (isStrict) { return this.<API key>; } else { return this._weekdaysShortRegex; } } else { if (!hasOwnProp(this, '_weekdaysShortRegex')) { this._weekdaysShortRegex = <API key>; } return this.<API key> && isStrict ? this.<API key> : this._weekdaysShortRegex; } } var <API key> = matchWord; export function weekdaysMinRegex (isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { <API key>.call(this); } if (isStrict) { return this.<API key>; } else { return this._weekdaysMinRegex; } } else { if (!hasOwnProp(this, '_weekdaysMinRegex')) { this._weekdaysMinRegex = <API key>; } return this.<API key> && isStrict ? this.<API key> : this._weekdaysMinRegex; } } function <API key> () { function cmpLenRev(a, b) { return b.length - a.length; } var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], i, mom, minp, shortp, longp; for (i = 0; i < 7; i++) { // make the regex if we don't have it already mom = createUTC([2000, 1]).day(i); minp = this.weekdaysMin(mom, ''); shortp = this.weekdaysShort(mom, ''); longp = this.weekdays(mom, ''); minPieces.push(minp); shortPieces.push(shortp); longPieces.push(longp); mixedPieces.push(minp); mixedPieces.push(shortp); mixedPieces.push(longp); } // Sorting makes sure if one weekday (or abbr) is a prefix of another it // will match the longer piece. minPieces.sort(cmpLenRev); shortPieces.sort(cmpLenRev); longPieces.sort(cmpLenRev); mixedPieces.sort(cmpLenRev); for (i = 0; i < 7; i++) { shortPieces[i] = regexEscape(shortPieces[i]); longPieces[i] = regexEscape(longPieces[i]); mixedPieces[i] = regexEscape(mixedPieces[i]); } this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); this._weekdaysShortRegex = this._weekdaysRegex; this._weekdaysMinRegex = this._weekdaysRegex; this.<API key> = new RegExp('^(' + longPieces.join('|') + ')', 'i'); this.<API key> = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); this.<API key> = new RegExp('^(' + minPieces.join('|') + ')', 'i'); }
DELETE FROM `script_texts` WHERE `entry` IN (-1000472,-1000473); INSERT INTO `script_texts` (`npc_entry`,`entry`,`content_default`,`content_loc1`,`content_loc2`,`content_loc3`,`content_loc4`,`content_loc5`,`content_loc6`,`content_loc7`,`content_loc8`,`sound`,`type`,`language`,`emote`,`comment`) VALUES (23864,-1000472,'This land was mine long before your wretched kind set foot here.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,0,0,''), (23864,-1000473,'All who venture here belong to me, including you!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,0,0,'');
//! moment.js locale configuration //! locale : Chinese (Hong Kong) [zh-hk] ;(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' && typeof require === 'function' ? factory(require('../moment')) : typeof define === 'function' && define.amd ? define(['../moment'], factory) : factory(global.moment) }(this, (function (moment) { 'use strict'; var zhHk = moment.defineLocale('zh-hk', { months : '___________'.split('_'), monthsShort : '1_2_3_4_5_6_7_8_9_10_11_12'.split('_'), weekdays : '______'.split('_'), weekdaysShort : '______'.split('_'), weekdaysMin : '______'.split('_'), longDateFormat : { LT : 'HH:mm', LTS : 'HH:mm:ss', L : 'YYYYMMMD', LL : 'YYYYMMMD', LLL : 'YYYYMMMD HH:mm', LLLL : 'YYYYMMMDdddd HH:mm', l : 'YYYYMMMD', ll : 'YYYYMMMD', lll : 'YYYYMMMD HH:mm', llll : 'YYYYMMMDdddd HH:mm' }, meridiemParse: /|||||/, meridiemHour : function (hour, meridiem) { if (hour === 12) { hour = 0; } if (meridiem === '' || meridiem === '' || meridiem === '') { return hour; } else if (meridiem === '') { return hour >= 11 ? hour : hour + 12; } else if (meridiem === '' || meridiem === '') { return hour + 12; } }, meridiem : function (hour, minute, isLower) { var hm = hour * 100 + minute; if (hm < 600) { return ''; } else if (hm < 900) { return ''; } else if (hm < 1130) { return ''; } else if (hm < 1230) { return ''; } else if (hm < 1800) { return ''; } else { return ''; } }, calendar : { sameDay : '[]LT', nextDay : '[]LT', nextWeek : '[]ddddLT', lastDay : '[]LT', lastWeek : '[]ddddLT', sameElse : 'L' }, <API key>: /\d{1,2}(||)/, ordinal : function (number, period) { switch (period) { case 'd' : case 'D' : case 'DDD' : return number + ''; case 'M' : return number + ''; case 'w' : case 'W' : return number + ''; default : return number; } }, relativeTime : { future : '%s', past : '%s', s : '', m : '1 ', mm : '%d ', h : '1 ', hh : '%d ', d : '1 ', dd : '%d ', M : '1 ', MM : '%d ', y : '1 ', yy : '%d ' } }); return zhHk; })));
var assert = require('assert'); var cookie = require('..'); suite('parse'); test('basic', function() { assert.deepEqual({ foo: 'bar' }, cookie.parse('foo=bar')); assert.deepEqual({ foo: '123' }, cookie.parse('foo=123')); }); test('ignore spaces', function() { assert.deepEqual({ FOO: 'bar', baz: 'raz' }, cookie.parse('FOO = bar; baz = raz')); }); test('escaping', function() { assert.deepEqual({ foo: 'bar=123456789&name=Magic+Mouse' }, cookie.parse('foo="bar=123456789&name=Magic+Mouse"')); assert.deepEqual({ email: ' ",;/' }, cookie.parse('email=%20%22%2c%3b%2f')); }); test('ignore escaping error and return original value', function() { assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar')); });
#include <linux/interrupt.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/irq.h> #include <linux/miscdevice.h> #include <linux/gpio.h> #include <linux/uaccess.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/workqueue.h> #include <linux/freezer.h> #include <linux/kthread.h> #include <linux/i2c/fm34_we395.h> #include "2mic/fm34_we395.h" #define MODULE_NAME "[FM34_WE395] :" #define DEBUG 0 static struct i2c_client *this_client; static struct fm34_platform_data *pdata; #if defined(<API key>) || defined(<API key>) unsigned char bypass_cmd[] = { /*0xC0,*/ 0xFC, 0xF3, 0x3B, 0x22, 0xC0, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xC1, 0x00, 0x01, 0xFC, 0xF3, 0x3B, 0x22, 0xC2, 0x00, 0x02, 0xFC, 0xF3, 0x3B, 0x22, 0xC3, 0x00, 0x02, 0xFC, 0xF3, 0x3B, 0x22, 0xC6, 0x00, 0x7D, 0xFC, 0xF3, 0x3B, 0x22, 0xC7, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xC8, 0x00, 0x18, 0xFC, 0xF3, 0x3B, 0x22, 0xD2, 0x82, 0x94, 0xFC, 0xF3, 0x3B, 0x22, 0xEE, 0x00, 0x01, 0xFC, 0xF3, 0x3B, 0x22, 0xF5, 0x00, 0x03, 0xFC, 0xF3, 0x3B, 0x22, 0xF6, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xF8, 0x80, 0x01, 0xFC, 0xF3, 0x3B, 0x22, 0xF9, 0x08, 0x7F, 0xFC, 0xF3, 0x3B, 0x22, 0xFA, 0x24, 0x8B, 0xFC, 0xF3, 0x3B, 0x23, 0x07, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x23, 0x0A, 0x1A, 0x00, 0xFC, 0xF3, 0x3B, 0x23, 0x0C, 0x00, 0xB8, 0xFC, 0xF3, 0x3B, 0x23, 0x0D, 0x02, 0x00, 0xFC, 0xF3, 0x3B, 0x23, 0x65, 0x08, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xFB, 0x00, 0x00 }; #else unsigned char bypass_cmd[] = { /*0xC0,*/ 0xFC, 0xF3, 0x3B, 0x22, 0xF5, 0x00, 0x03, 0xFC, 0xF3, 0x3B, 0x22, 0xF8, 0x80, 0x03, 0xFC, 0xF3, 0x3B, 0x22, 0xC6, 0x00, 0x7D, 0xFC, 0xF3, 0x3B, 0x22, 0xC7, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xC8, 0x00, 0x18, 0xFC, 0xF3, 0x3B, 0x23, 0x0A, 0x1A, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xFA, 0x24, 0x8B, 0xFC, 0xF3, 0x3B, 0x22, 0xF9, 0x00, 0x7F, 0xFC, 0xF3, 0x3B, 0x22, 0xF6, 0x00, 0x00, 0xFC, 0xF3, 0x3B, 0x22, 0xD2, 0x82, 0x94, 0xFC, 0xF3, 0x3B, 0x22, 0xEE, 0x00, 0x01, 0xFC, 0xF3, 0x3B, 0x22, 0xFB, 0x00, 0x00, }; #endif static int fm34_i2c_read(char *rxData, int length) { int rc; struct i2c_msg msgs[] = { { .addr = this_client->addr, .flags = I2C_M_RD, .len = length, .buf = rxData, }, }; rc = i2c_transfer(this_client->adapter, msgs, 1); if (rc < 0) { pr_err("%s: transfer error %d\n", __func__, rc); return rc; } return 0; } static int fm34_i2c_write(char *txData, int length) { int rc; struct i2c_msg msg[] = { { .addr = this_client->addr, .flags = 0, .len = length, .buf = txData, }, }; rc = i2c_transfer(this_client->adapter, msg, 1); if (rc < 0) { pr_err("%s: transfer error %d\n", __func__, rc); return rc; } return 0; } #if defined(<API key>) || defined(<API key>) void <API key>(void) { pr_info(MODULE_NAME "%s\n", __func__); if (pdata->gpio_rst) { gpio_set_value(pdata->gpio_rst, 0); usleep_range(5000, 5000); gpio_set_value(pdata->gpio_rst, 1); } usleep_range(5000, 5000); } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; pr_info(MODULE_NAME "%s\n", __func__); <API key>(); i2c_cmds = bypass_cmd; size = sizeof(bypass_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; pr_info(MODULE_NAME "%s\n", __func__); usleep_range(20000, 20000); gpio_set_value(pdata->gpio_pwdn, 0); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = loopback_cmd; size = sizeof(loopback_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_HS_mode(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_cmd; size = sizeof(HS_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_SPK_mode(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HF_cmd; size = sizeof(HF_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_HS_NS_mode(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_NS_cmd; size = sizeof(HS_NS_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_ExtraVol_cmd; size = sizeof(HS_ExtraVol_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HF_ExtraVol_cmd; size = sizeof(HF_ExtraVol_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_ExtraVol_NS_cmd; size = sizeof(HS_ExtraVol_NS_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_EP_mode(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = EP_cmd; size = sizeof(EP_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_BTSCO_mode(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = BT_SCO_cmd; size = sizeof(BT_SCO_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_FACTORY_RCV_cmd; size = sizeof(HS_FACTORY_RCV_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; int val = gpio_get_value(pdata->gpio_pwdn); pr_info(MODULE_NAME "%s\n", __func__); if (val == 0) gpio_set_value(pdata->gpio_pwdn, 1); <API key>(); i2c_cmds = HS_FACTORY_SPK_cmd; size = sizeof(HS_FACTORY_SPK_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); return rc; } int fm34_set_mode(int mode) { int ret = 0; pr_info(MODULE_NAME "%s : fm34_set_mode mode[%d]\n", __func__, mode); if (mode == 0) ret = <API key>(); /* OFF,Bypass */ else if (mode == 1) ret = fm34_set_HS_mode(); /* Receiver */ else if (mode == 2) ret = <API key>(); /* S/W Bypass */ else if (mode == 3) ret = fm34_set_SPK_mode(); /* Speaker */ else if (mode == 4) ret = <API key>(); /* PwrDn H/W Bypass */ else if (mode == 5) ret = fm34_set_HS_NS_mode(); /* Receiver+NS */ else if (mode == 6) ret = <API key>(); /* Receiver+ExtraVol */ else if (mode == 7) ret = <API key>(); /* Speaker+ExtraVol */ else if (mode == 8) ret = fm34_set_EP_mode(); /* Headset */ else if (mode == 9) ret = fm34_set_BTSCO_mode(); /* BT SCO */ else if (mode == 11) ret = <API key>(); /* Factory Mode RCV */ else if (mode == 12) ret = <API key>(); /* Factory Mode SPK */ else if (mode == 13) ret = <API key>(); /* Receiver+ExtraVol+NS */ else pr_err(MODULE_NAME"fm34_set_mode : INVALID mode[%d]\n", mode); return ret; } EXPORT_SYMBOL_GPL(fm34_set_mode); #else int <API key>(void) { int i = 0, rc = 0, size = 0; unsigned char *i2c_cmds; pr_info(MODULE_NAME "%s\n", __func__); i2c_cmds = bypass_cmd; size = sizeof(bypass_cmd); #if DEBUG for (i = 0; i < size; i += 1) pr_info(MODULE_NAME "%s : i2c_cmds[%d/%d] = 0x%x\n", __func__, i, size, i2c_cmds[i]); #endif rc = fm34_i2c_write(i2c_cmds, size); if (rc < 0) { pr_err(MODULE_NAME "%s failed return %d\n", __func__, rc); } else if (pdata->gpio_pwdn) { msleep(20); gpio_set_value(pdata->gpio_pwdn, 0); } return rc; } #endif static struct miscdevice fm34_device = { .minor = MISC_DYNAMIC_MINOR, .name = "fm34_we395", }; static void fm34_gpio_init(void) { if (pdata->gpio_rst) { gpio_request(pdata->gpio_rst, "FM34_RESET"); <API key>(pdata->gpio_rst, 1); gpio_free(pdata->gpio_rst); gpio_set_value(pdata->gpio_rst, 0); } usleep_range(10000, 10000); if (pdata->gpio_pwdn) { gpio_request(pdata->gpio_pwdn, "FM34_PWDN"); <API key>(pdata->gpio_pwdn, 1); gpio_free(pdata->gpio_pwdn); gpio_set_value(pdata->gpio_pwdn, 1); } if (pdata->gpio_bp) { gpio_request(pdata->gpio_bp, "FM34_BYPASS"); <API key>(pdata->gpio_bp, 1); gpio_free(pdata->gpio_bp); gpio_set_value(pdata->gpio_bp, 1); } } static void fm34_bootup_init(void) { if (pdata->set_mclk != NULL) pdata->set_mclk(true, false); msleep(20); if (pdata->gpio_rst) { gpio_set_value(pdata->gpio_rst, 0); msleep(20); gpio_set_value(pdata->gpio_rst, 1); } msleep(50); } static int fm34_probe( struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; pdata = client->dev.platform_data; pr_info(MODULE_NAME "%s : start\n", __func__); if (pdata == NULL) { pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) { rc = -ENOMEM; pr_err(MODULE_NAME "%s: platform data is NULL\n", __func__); } } this_client = client; fm34_gpio_init(); fm34_bootup_init(); if (<API key>() < 0) pr_err(MODULE_NAME "bypass setting failed %d\n", rc); pr_info(MODULE_NAME "%s : finish\n", __func__); return rc; } static int fm34_remove(struct i2c_client *client) { struct fm34_platform_data *pfm34data = i2c_get_clientdata(client); kfree(pfm34data); return 0; } static int fm34_suspend(struct i2c_client *client, pm_message_t mesg) { return 0; } static int fm34_resume(struct i2c_client *client) { return 0; } static const struct i2c_device_id fm34_id[] = { { "fm34_we395", 0 }, { } }; static struct i2c_driver fm34_driver = { .probe = fm34_probe, .remove = fm34_remove, .suspend = fm34_suspend, .resume = fm34_resume, .id_table = fm34_id, .driver = { .name = "fm34_we395", }, }; static int __init fm34_init(void) { pr_info("%s\n", __func__); return i2c_add_driver(&fm34_driver); } static void __exit fm34_exit(void) { i2c_del_driver(&fm34_driver); } module_init(fm34_init); module_exit(fm34_exit); MODULE_DESCRIPTION("fm34 voice processor driver"); MODULE_LICENSE("GPL");
# arch/score/boot/Makefile # This file is subject to the terms and conditions of the GNU General Public # for more details. targets := vmlinux.bin $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy) @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' clean-files += vmlinux.bin
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> /* For EXPORT_SYMBOL/module stuff/... */ #include <linux/types.h> /* For standard types */ #include <linux/errno.h> /* For the -ENODEV/... values */ #include <linux/kernel.h> /* For printk/panic/... */ #include <linux/watchdog.h> /* For watchdog specific items */ #include <linux/init.h> /* For __init/__exit/... */ #include <linux/idr.h> /* For ida_* macros */ #include <linux/err.h> /* For IS_ERR macros */ #include "watchdog_core.h" /* For <API key>/... */ static DEFINE_IDA(watchdog_ida); static struct class *watchdog_class; /** * <API key>() - register a watchdog device * @wdd: watchdog device * * Register a watchdog device with the kernel so that the * watchdog timer can be accessed from userspace. * * A zero is returned on success and a negative errno code for * failure. */ int <API key>(struct watchdog_device *wdd) { int ret, id, devno; if (wdd == NULL || wdd->info == NULL || wdd->ops == NULL) return -EINVAL; /* Mandatory operations need to be supported */ if (wdd->ops->start == NULL || wdd->ops->stop == NULL) return -EINVAL; /* * Check that we have valid min and max timeout values, if * not reset them both to 0 (=not used or unknown) */ if (wdd->min_timeout > wdd->max_timeout) { pr_info("Invalid min and max timeout values, resetting to 0!\n"); wdd->min_timeout = 0; wdd->max_timeout = 0; } /* * Note: now that all watchdog_device data has been verified, we * will not check this anymore in other functions. If data gets * corrupted in a later stage then we expect a kernel panic! */ mutex_init(&wdd->lock); id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL); if (id < 0) return id; wdd->id = id; ret = <API key>(wdd); if (ret) { ida_simple_remove(&watchdog_ida, id); if (!(id == 0 && ret == -EBUSY)) return ret; /* Retry in case a legacy watchdog module exists */ id = ida_simple_get(&watchdog_ida, 1, MAX_DOGS, GFP_KERNEL); if (id < 0) return id; wdd->id = id; ret = <API key>(wdd); if (ret) { ida_simple_remove(&watchdog_ida, id); return ret; } } devno = wdd->cdev.dev; wdd->dev = device_create(watchdog_class, wdd->parent, devno, NULL, "watchdog%d", wdd->id); if (IS_ERR(wdd->dev)) { <API key>(wdd); ida_simple_remove(&watchdog_ida, id); ret = PTR_ERR(wdd->dev); return ret; } return 0; } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - unregister a watchdog device * @wdd: watchdog device to unregister * * Unregister a watchdog device that was previously successfully * registered with <API key>(). */ void <API key>(struct watchdog_device *wdd) { int ret; int devno; if (wdd == NULL) return; devno = wdd->cdev.dev; ret = <API key>(wdd); if (ret) pr_err("error unregistering /dev/watchdog (err=%d)\n", ret); device_destroy(watchdog_class, devno); ida_simple_remove(&watchdog_ida, wdd->id); wdd->dev = NULL; } EXPORT_SYMBOL_GPL(<API key>); static int __init watchdog_init(void) { int err; watchdog_class = class_create(THIS_MODULE, "watchdog"); if (IS_ERR(watchdog_class)) { pr_err("couldn't create class\n"); return PTR_ERR(watchdog_class); } err = watchdog_dev_init(); if (err < 0) { class_destroy(watchdog_class); return err; } return 0; } static void __exit watchdog_exit(void) { watchdog_dev_exit(); class_destroy(watchdog_class); ida_destroy(&watchdog_ida); } subsys_initcall(watchdog_init); module_exit(watchdog_exit); MODULE_AUTHOR("Alan Cox <alan@lxorguk.ukuu.org.uk>"); MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); MODULE_DESCRIPTION("WatchDog Timer Driver Core"); MODULE_LICENSE("GPL");
// <API key>: GPL-2.0-or-later #include <linux/types.h> #include <linux/kernel.h> #include <linux/irq.h> #include <linux/smp.h> #include <linux/interrupt.h> #include <linux/cpu.h> #include <linux/of.h> #include <asm/smp.h> #include <asm/irq.h> #include <asm/errno.h> #include <asm/xics.h> #include <asm/io.h> #include <asm/opal.h> #include <asm/kvm_ppc.h> static void <API key>(void) { int hw_cpu = <API key>(); /* Clear any pending IPI */ opal_int_set_mfrr(hw_cpu, 0xff); } static void icp_opal_flush_ipi(void) { /* * We take the ipi irq but and never return so we need to EOI the IPI, * but want to leave our priority 0. * * Should we check all the other interrupts too? * Should we be flagging idle loop instead? * Or creating some task to be scheduled? */ if (opal_int_eoi((0x00 << 24) | XICS_IPI) > 0) <API key>(); } static unsigned int icp_opal_get_xirr(void) { unsigned int kvm_xirr; __be32 hw_xirr; int64_t rc; /* Handle an interrupt latched by KVM first */ kvm_xirr = <API key>(); if (kvm_xirr) return kvm_xirr; /* Then ask OPAL */ rc = opal_int_get_xirr(&hw_xirr, false); if (rc < 0) return 0; return be32_to_cpu(hw_xirr); } static unsigned int icp_opal_get_irq(void) { unsigned int xirr; unsigned int vec; unsigned int irq; xirr = icp_opal_get_xirr(); vec = xirr & 0x00ffffff; if (vec == XICS_IRQ_SPURIOUS) return 0; irq = irq_find_mapping(xics_host, vec); if (likely(irq)) { xics_push_cppr(vec); return irq; } /* We don't have a linux mapping, so have rtas mask it. */ <API key>(vec); /* We might learn about it later, so EOI it */ if (opal_int_eoi(xirr) > 0) <API key>(); return 0; } static void <API key>(unsigned char cppr) { /* * Here be dragons. The caller has asked to allow only IPI's and not * external interrupts. But OPAL XIVE doesn't support that. So instead * of allowing no interrupts allow all. That's still not right, but * currently the only caller who does this is <API key>() * and it works in that case. */ if (cppr >= DEFAULT_PRIORITY) cppr = LOWEST_PRIORITY; xics_set_base_cppr(cppr); opal_int_set_cppr(cppr); iosync(); } static void icp_opal_eoi(struct irq_data *d) { unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d); int64_t rc; iosync(); rc = opal_int_eoi((xics_pop_cppr() << 24) | hw_irq); /* * EOI tells us whether there are more interrupts to fetch. * * Some HW implementations might not be able to send us another * external interrupt in that case, so we force a replay. */ if (rc > 0) <API key>(); } #ifdef CONFIG_SMP static void icp_opal_cause_ipi(int cpu) { int hw_cpu = <API key>(cpu); kvmppc_set_host_ipi(cpu); opal_int_set_mfrr(hw_cpu, IPI_PRIORITY); } static irqreturn_t icp_opal_ipi_action(int irq, void *dev_id) { int cpu = smp_processor_id(); <API key>(cpu); opal_int_set_mfrr(<API key>(cpu), 0xff); return smp_ipi_demux(); } /* * Called when an interrupt is received on an off-line CPU to * clear the interrupt, so that the CPU can go back to nap mode. */ void <API key>(void) { unsigned int xirr; unsigned int vec; do { xirr = icp_opal_get_xirr(); vec = xirr & 0x00ffffff; if (vec == XICS_IRQ_SPURIOUS) break; if (vec == XICS_IPI) { /* Clear pending IPI */ int cpu = smp_processor_id(); <API key>(cpu); opal_int_set_mfrr(<API key>(cpu), 0xff); } else { pr_err("XICS: hw interrupt 0x%x to offline cpu, " "disabling\n", vec); <API key>(vec); } /* EOI the interrupt */ } while (opal_int_eoi(xirr) > 0); } #endif /* CONFIG_SMP */ static const struct icp_ops icp_opal_ops = { .get_irq = icp_opal_get_irq, .eoi = icp_opal_eoi, .set_priority = <API key>, .teardown_cpu = <API key>, .flush_ipi = icp_opal_flush_ipi, #ifdef CONFIG_SMP .ipi_action = icp_opal_ipi_action, .cause_ipi = icp_opal_cause_ipi, #endif }; int icp_opal_init(void) { struct device_node *np; np = <API key>(NULL, NULL, "ibm,opal-intc"); if (!np) return -ENODEV; icp_ops = &icp_opal_ops; printk("XICS: Using OPAL ICP fallbacks\n"); return 0; }
// Boost.Assign library #ifndef <API key> #define <API key> #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include <boost/assign/list_inserter.hpp> #include <boost/config.hpp> #include <map> namespace boost { namespace assign { template< class K, class V, class C, class A, class P > inline list_inserter< assign_detail::call_insert< std::map<K,V,C,A> >, P > operator+=( std::map<K,V,C,A>& m, const P& p ) { return insert( m )( p ); } template< class K, class V, class C, class A, class P > inline list_inserter< assign_detail::call_insert< std::multimap<K,V,C,A> >, P > operator+=( std::multimap<K,V,C,A>& m, const P& p ) { return insert( m )( p ); } } } #endif
#include <linux/platform_device.h> #include <linux/io.h> #include <linux/i2c.h> #include <linux/i2c/at24.h> #include <linux/dma-mapping.h> #include <linux/spi/spi.h> #include <linux/spi/eeprom.h> #include <linux/irq.h> #include <linux/delay.h> #include <linux/gpio.h> #include <linux/usb/otg.h> #include <linux/usb/ulpi.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> #include <mach/common.h> #include <mach/hardware.h> #include <mach/iomux-mx27.h> #include <asm/mach/time.h> #include <mach/audmux.h> #include <mach/irqs.h> #include <mach/ulpi.h> #include "devices-imx27.h" #define OTG_PHY_CS_GPIO (GPIO_PORTB + 23) #define USBH2_PHY_CS_GPIO (GPIO_PORTB + 24) #define SPI1_SS0 (GPIO_PORTD + 28) #define SPI1_SS1 (GPIO_PORTD + 27) #define SD2_CD (GPIO_PORTC + 29) static const int pca100_pins[] __initconst = { /* UART1 */ PE12_PF_UART1_TXD, PE13_PF_UART1_RXD, PE14_PF_UART1_CTS, PE15_PF_UART1_RTS, /* SDHC */ PB4_PF_SD2_D0, PB5_PF_SD2_D1, PB6_PF_SD2_D2, PB7_PF_SD2_D3, PB8_PF_SD2_CMD, PB9_PF_SD2_CLK, SD2_CD | GPIO_GPIO | GPIO_IN, /* FEC */ PD0_AIN_FEC_TXD0, PD1_AIN_FEC_TXD1, PD2_AIN_FEC_TXD2, PD3_AIN_FEC_TXD3, PD4_AOUT_FEC_RX_ER, PD5_AOUT_FEC_RXD1, PD6_AOUT_FEC_RXD2, PD7_AOUT_FEC_RXD3, PD8_AF_FEC_MDIO, PD9_AIN_FEC_MDC, PD10_AOUT_FEC_CRS, <API key>, PD12_AOUT_FEC_RXD0, PD13_AOUT_FEC_RX_DV, <API key>, PD15_AOUT_FEC_COL, PD16_AIN_FEC_TX_ER, PF23_AIN_FEC_TX_EN, /* SSI1 */ PC20_PF_SSI1_FS, PC21_PF_SSI1_RXD, PC22_PF_SSI1_TXD, PC23_PF_SSI1_CLK, /* onboard I2C */ PC5_PF_I2C2_SDA, PC6_PF_I2C2_SCL, /* external I2C */ PD17_PF_I2C_DATA, PD18_PF_I2C_CLK, /* SPI1 */ PD25_PF_CSPI1_RDY, PD29_PF_CSPI1_SCLK, PD30_PF_CSPI1_MISO, PD31_PF_CSPI1_MOSI, /* OTG */ OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT, PC7_PF_USBOTG_DATA5, PC8_PF_USBOTG_DATA6, PC9_PF_USBOTG_DATA0, <API key>, <API key>, <API key>, <API key>, PE0_PF_USBOTG_NXT, PE1_PF_USBOTG_STP, PE2_PF_USBOTG_DIR, PE24_PF_USBOTG_CLK, <API key>, /* USBH2 */ USBH2_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT, PA0_PF_USBH2_CLK, PA1_PF_USBH2_DIR, PA2_PF_USBH2_DATA7, PA3_PF_USBH2_NXT, PA4_PF_USBH2_STP, PD19_AF_USBH2_DATA4, PD20_AF_USBH2_DATA3, PD21_AF_USBH2_DATA6, PD22_AF_USBH2_DATA0, PD23_AF_USBH2_DATA2, PD24_AF_USBH2_DATA1, PD26_AF_USBH2_DATA5, /* display */ PA5_PF_LSCLK, PA6_PF_LD0, PA7_PF_LD1, PA8_PF_LD2, PA9_PF_LD3, PA10_PF_LD4, PA11_PF_LD5, PA12_PF_LD6, PA13_PF_LD7, PA14_PF_LD8, PA15_PF_LD9, PA16_PF_LD10, PA17_PF_LD11, PA18_PF_LD12, PA19_PF_LD13, PA20_PF_LD14, PA21_PF_LD15, PA22_PF_LD16, PA23_PF_LD17, PA26_PF_PS, PA28_PF_HSYNC, PA29_PF_VSYNC, PA31_PF_OE_ACD, /* free GPIO */ GPIO_PORTC | 31 | GPIO_GPIO | GPIO_IN, /* GPIO0_IRQ */ GPIO_PORTC | 25 | GPIO_GPIO | GPIO_IN, /* GPIO1_IRQ */ GPIO_PORTE | 5 | GPIO_GPIO | GPIO_IN, /* GPIO2_IRQ */ }; static const struct <API key> uart_pdata __initconst = { .flags = IMXUART_HAVE_RTSCTS, }; static const struct <API key> <API key> __initconst = { .width = 1, .hw_ecc = 1, }; static const struct <API key> pca100_i2c1_data __initconst = { .bitrate = 100000, }; static struct at24_platform_data board_eeprom = { .byte_len = 4096, .page_size = 32, .flags = AT24_FLAG_ADDR16, }; static struct i2c_board_info pca100_i2c_devices[] = { { I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ .platform_data = &board_eeprom, }, { I2C_BOARD_INFO("pcf8563", 0x51), }, { I2C_BOARD_INFO("lm75", 0x4a), } }; static struct spi_eeprom at25320 = { .name = "at25320an", .byte_len = 4096, .page_size = 32, .flags = EE_ADDR2, }; static struct spi_board_info <API key>[] __initdata = { { .modalias = "at25", .max_speed_hz = 30000, .bus_num = 0, .chip_select = 1, .platform_data = &at25320, }, }; static int pca100_spi_cs[] = {SPI1_SS0, SPI1_SS1}; static const struct spi_imx_master pca100_spi0_data __initconst = { .chipselect = pca100_spi_cs, .num_chipselect = ARRAY_SIZE(pca100_spi_cs), }; static void <API key>(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); gpio_set_value(GPIO_PORTC + 20, 1); udelay(2); gpio_set_value(GPIO_PORTC + 20, 0); mxc_gpio_mode(PC20_PF_SSI1_FS); msleep(2); } static void <API key>(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); gpio_set_value(GPIO_PORTC + 20, 0); mxc_gpio_mode(GPIO_PORTC | 22 | GPIO_GPIO | GPIO_OUT); gpio_set_value(GPIO_PORTC + 22, 0); mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_OUT); /* reset */ gpio_set_value(GPIO_PORTC + 28, 0); udelay(10); gpio_set_value(GPIO_PORTC + 28, 1); mxc_gpio_mode(PC20_PF_SSI1_FS); mxc_gpio_mode(PC22_PF_SSI1_TXD); msleep(2); } static const struct <API key> pca100_ssi_pdata __initconst = { .ac97_reset = <API key>, .ac97_warm_reset = <API key>, .flags = IMX_SSI_USE_AC97, }; static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data) { int ret; ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_DISABLED | <API key>, "imx-mmc-detect", data); if (ret) printk(KERN_ERR "pca100: Failed to reuest irq for sd/mmc detection\n"); return ret; } static void pca100_sdhc2_exit(struct device *dev, void *data) { free_irq(IRQ_GPIOC(29), data); } static const struct <API key> sdhc_pdata __initconst = { .init = pca100_sdhc2_init, .exit = pca100_sdhc2_exit, }; static int otg_phy_init(struct platform_device *pdev) { gpio_set_value(OTG_PHY_CS_GPIO, 0); mdelay(10); return <API key>(pdev->id, <API key>); } static struct <API key> otg_pdata __initdata = { .init = otg_phy_init, .portsc = MXC_EHCI_MODE_ULPI, }; static int usbh2_phy_init(struct platform_device *pdev) { gpio_set_value(USBH2_PHY_CS_GPIO, 0); mdelay(10); return <API key>(pdev->id, <API key>); } static struct <API key> usbh2_pdata __initdata = { .init = usbh2_phy_init, .portsc = MXC_EHCI_MODE_ULPI, }; static const struct <API key> otg_device_pdata __initconst = { .operating_mode = FSL_USB2_DR_DEVICE, .phy_mode = FSL_USB2_PHY_ULPI, }; static int otg_mode_host; static int __init pca100_otg_mode(char *options) { if (!strcmp(options, "host")) otg_mode_host = 1; else if (!strcmp(options, "device")) otg_mode_host = 0; else pr_info("otg_mode neither \"host\" nor \"device\". " "Defaulting to device\n"); return 0; } __setup("otg_mode=", pca100_otg_mode); /* framebuffer info */ static struct imx_fb_videomode pca100_fb_modes[] = { { .mode = { .name = "<API key>", .refresh = 60, .xres = 640, .yres = 480, .pixclock = 39722, /* in ps (25.175 MHz) */ .hsync_len = 30, .left_margin = 114, .right_margin = 16, .vsync_len = 3, .upper_margin = 32, .lower_margin = 0, }, /* * TFT * Pixel pol active high * HSYNC active low * VSYNC active low * use HSYNC for ACD count * line clock disable while idle * always enable line clock even if no data */ .pcr = 0xf0c08080, .bpp = 16, }, }; static const struct <API key> pca100_fb_data __initconst = { .mode = pca100_fb_modes, .num_modes = ARRAY_SIZE(pca100_fb_modes), .pwmr = 0x00A903FF, .lscr1 = 0x00120300, .dmacr = 0x00020010, }; static void __init pca100_init(void) { int ret; /* SSI unit */ <API key>(<API key>, <API key> | /* 4wire mode */ <API key>(3) | <API key> | /* clock is output */ <API key>(3)); <API key>(3, <API key> | /* 4wire mode */ <API key>(0) | <API key> | <API key>(0)); ret = <API key>(pca100_pins, ARRAY_SIZE(pca100_pins), "PCA100"); if (ret) printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret); imx27_add_imx_ssi(0, &pca100_ssi_pdata); imx27_add_imx_uart0(&uart_pdata); imx27_add_mxc_mmc(1, &sdhc_pdata); imx27_add_mxc_nand(&<API key>); /* only the i2c master 1 is used on this CPU card */ <API key>(1, pca100_i2c_devices, ARRAY_SIZE(pca100_i2c_devices)); imx27_add_imx_i2c(1, &pca100_i2c1_data); mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_IN); mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN); <API key>(<API key>, ARRAY_SIZE(<API key>)); imx27_add_spi_imx0(&pca100_spi0_data); gpio_request(OTG_PHY_CS_GPIO, "usb-otg-cs"); <API key>(OTG_PHY_CS_GPIO, 1); gpio_request(USBH2_PHY_CS_GPIO, "usb-host2-cs"); <API key>(USBH2_PHY_CS_GPIO, 1); if (otg_mode_host) { otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS | <API key>); if (otg_pdata.otg) <API key>(&otg_pdata); } else { gpio_set_value(OTG_PHY_CS_GPIO, 0); <API key>(&otg_device_pdata); } usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, ULPI_OTG_DRVVBUS | <API key>); if (usbh2_pdata.otg) <API key>(2, &usbh2_pdata); imx27_add_imx_fb(&pca100_fb_data); imx27_add_fec(NULL); imx27_add_imx2_wdt(NULL); imx27_add_mxc_w1(NULL); } static void __init pca100_timer_init(void) { mx27_clocks_init(26000000); } static struct sys_timer pca100_timer = { .init = pca100_timer_init, }; MACHINE_START(PCA100, "phyCARD-i.MX27") .boot_params = MX27_PHYS_OFFSET + 0x100, .map_io = mx27_map_io, .init_early = imx27_init_early, .init_irq = mx27_init_irq, .init_machine = pca100_init, .timer = &pca100_timer, MACHINE_END
#include <linux/init.h> #include <linux/list.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kmod.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/kthread.h> #include <asm/div64.h> #include "cx23885.h" #include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> #include "cx23885-ioctl.h" #include "tuner-xc2028.h" MODULE_DESCRIPTION("v4l2 driver module for cx23885 based TV cards"); MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); MODULE_LICENSE("GPL"); static unsigned int video_nr[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; static unsigned int vbi_nr[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; static unsigned int radio_nr[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; module_param_array(video_nr, int, NULL, 0444); module_param_array(vbi_nr, int, NULL, 0444); module_param_array(radio_nr, int, NULL, 0444); MODULE_PARM_DESC(video_nr, "video device numbers"); MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); MODULE_PARM_DESC(radio_nr, "radio device numbers"); static unsigned int video_debug; module_param(video_debug, int, 0644); MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); static unsigned int irq_debug; module_param(irq_debug, int, 0644); MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]"); static unsigned int vid_limit = 16; module_param(vid_limit, int, 0644); MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes"); #define dprintk(level, fmt, arg...)\ do { if (video_debug >= level)\ printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ } while (0) /* static data */ #define FORMAT_FLAGS_PACKED 0x01 static struct cx23885_fmt formats[] = { { .name = "8 bpp, gray", .fourcc = V4L2_PIX_FMT_GREY, .depth = 8, .flags = FORMAT_FLAGS_PACKED, }, { .name = "15 bpp RGB, le", .fourcc = V4L2_PIX_FMT_RGB555, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, { .name = "15 bpp RGB, be", .fourcc = <API key>, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, { .name = "16 bpp RGB, le", .fourcc = V4L2_PIX_FMT_RGB565, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, { .name = "16 bpp RGB, be", .fourcc = <API key>, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, { .name = "24 bpp RGB, le", .fourcc = V4L2_PIX_FMT_BGR24, .depth = 24, .flags = FORMAT_FLAGS_PACKED, }, { .name = "32 bpp RGB, le", .fourcc = V4L2_PIX_FMT_BGR32, .depth = 32, .flags = FORMAT_FLAGS_PACKED, }, { .name = "32 bpp RGB, be", .fourcc = V4L2_PIX_FMT_RGB32, .depth = 32, .flags = FORMAT_FLAGS_PACKED, }, { .name = "4:2:2, packed, YUYV", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, { .name = "4:2:2, packed, UYVY", .fourcc = V4L2_PIX_FMT_UYVY, .depth = 16, .flags = FORMAT_FLAGS_PACKED, }, }; static struct cx23885_fmt *format_by_fourcc(unsigned int fourcc) { unsigned int i; for (i = 0; i < ARRAY_SIZE(formats); i++) if (formats[i].fourcc == fourcc) return formats+i; printk(KERN_ERR "%s(0x%08x) NOT FOUND\n", __func__, fourcc); return NULL; } static const struct v4l2_queryctrl no_ctl = { .name = "42", .flags = <API key>, }; static struct cx23885_ctrl cx23885_ctls[] = { { .v = { .id = V4L2_CID_BRIGHTNESS, .name = "Brightness", .minimum = 0x00, .maximum = 0xff, .step = 1, .default_value = 0x7f, .type = <API key>, }, .off = 128, .reg = LUMA_CTRL, .mask = 0x00ff, .shift = 0, }, { .v = { .id = V4L2_CID_CONTRAST, .name = "Contrast", .minimum = 0, .maximum = 0xff, .step = 1, .default_value = 0x3f, .type = <API key>, }, .off = 0, .reg = LUMA_CTRL, .mask = 0xff00, .shift = 8, }, { .v = { .id = V4L2_CID_HUE, .name = "Hue", .minimum = 0, .maximum = 0xff, .step = 1, .default_value = 0x7f, .type = <API key>, }, .off = 128, .reg = CHROMA_CTRL, .mask = 0xff0000, .shift = 16, }, { /* strictly, this only describes only U saturation. * V saturation is handled specially through code. */ .v = { .id = V4L2_CID_SATURATION, .name = "Saturation", .minimum = 0, .maximum = 0xff, .step = 1, .default_value = 0x7f, .type = <API key>, }, .off = 0, .reg = CHROMA_CTRL, .mask = 0x00ff, .shift = 0, }, { .v = { .id = V4L2_CID_AUDIO_MUTE, .name = "Mute", .minimum = 0, .maximum = 1, .default_value = 1, .type = <API key>, }, .reg = PATH1_CTL1, .mask = (0x1f << 24), .shift = 24, }, { .v = { .id = <API key>, .name = "Volume", .minimum = 0, .maximum = 0x3f, .step = 1, .default_value = 0x3f, .type = <API key>, }, .reg = PATH1_VOL_CTL, .mask = 0xff, .shift = 0, } }; static const int CX23885_CTLS = ARRAY_SIZE(cx23885_ctls); /* Must be sorted from low to high control ID! */ static const u32 cx23885_user_ctrls[] = { V4L2_CID_USER_CLASS, V4L2_CID_BRIGHTNESS, V4L2_CID_CONTRAST, V4L2_CID_SATURATION, V4L2_CID_HUE, <API key>, V4L2_CID_AUDIO_MUTE, 0 }; static const u32 *ctrl_classes[] = { cx23885_user_ctrls, NULL }; static void <API key>(struct cx23885_dev *dev, struct cx23885_dmaqueue *q, u32 count) { struct cx23885_buffer *buf; int bc; for (bc = 0;; bc++) { if (list_empty(&q->active)) break; buf = list_entry(q->active.next, struct cx23885_buffer, vb.queue); /* count comes from the hw and is is 16bit wide -- * this trick handles wrap-arounds correctly for * up to 32767 buffers in flight... */ if ((s16) (count - buf->count) < 0) break; do_gettimeofday(&buf->vb.ts); dprintk(2, "[%p/%d] wakeup reg=%d buf=%d\n", buf, buf->vb.i, count, buf->count); buf->vb.state = VIDEOBUF_DONE; list_del(&buf->vb.queue); wake_up(&buf->vb.done); } if (list_empty(&q->active)) del_timer(&q->timeout); else mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); if (bc != 1) printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", __func__, bc); } static int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) { dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", __func__, (unsigned int)norm, v4l2_norm_to_name(norm)); dev->tvnorm = norm; call_all(dev, core, s_std, norm); return 0; } static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, struct pci_dev *pci, struct video_device *template, char *type) { struct video_device *vfd; dprintk(1, "%s()\n", __func__); vfd = video_device_alloc(); if (NULL == vfd) return NULL; *vfd = *template; vfd->v4l2_dev = &dev->v4l2_dev; vfd->release = <API key>; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, cx23885_boards[dev->board].name); video_set_drvdata(vfd, dev); return vfd; } static int cx23885_ctrl_query(struct v4l2_queryctrl *qctrl) { int i; if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1) return -EINVAL; for (i = 0; i < CX23885_CTLS; i++) if (cx23885_ctls[i].v.id == qctrl->id) break; if (i == CX23885_CTLS) { *qctrl = no_ctl; return 0; } *qctrl = cx23885_ctls[i].v; return 0; } /* resource management */ static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, unsigned int bit) { dprintk(1, "%s()\n", __func__); if (fh->resources & bit) /* have it already allocated */ return 1; /* is it free? */ mutex_lock(&dev->lock); if (dev->resources & bit) { /* no, someone else uses it */ mutex_unlock(&dev->lock); return 0; } /* it's free, grab it */ fh->resources |= bit; dev->resources |= bit; dprintk(1, "res: get %d\n", bit); mutex_unlock(&dev->lock); return 1; } static int res_check(struct cx23885_fh *fh, unsigned int bit) { return fh->resources & bit; } static int res_locked(struct cx23885_dev *dev, unsigned int bit) { return dev->resources & bit; } static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, unsigned int bits) { BUG_ON((fh->resources & bits) != bits); dprintk(1, "%s()\n", __func__); mutex_lock(&dev->lock); fh->resources &= ~bits; dev->resources &= ~bits; dprintk(1, "res: put %d\n", bits); mutex_unlock(&dev->lock); } static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) { dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", __func__, input, INPUT(input)->vmux, INPUT(input)->gpio0, INPUT(input)->gpio1, INPUT(input)->gpio2, INPUT(input)->gpio3); dev->input = input; if (dev->board == <API key> || dev->board == <API key>) { /* Select Analog TV */ if (INPUT(input)->type == <API key>) cx23885_gpio_clear(dev, GPIO_0); } /* Tell the internal A/V decoder */ v4l2_subdev_call(dev->sd_cx25840, video, s_routing, INPUT(input)->vmux, 0, 0); return 0; } static int cx23885_set_scale(struct cx23885_dev *dev, unsigned int width, unsigned int height, enum v4l2_field field) { dprintk(1, "%s()\n", __func__); return 0; } static int <API key>(struct cx23885_dev *dev, struct cx23885_dmaqueue *q, struct cx23885_buffer *buf) { dprintk(1, "%s()\n", __func__); /* setup fifo + format */ <API key>(dev, &dev->sram_channels[SRAM_CH01], buf->bpl, buf->risc.dma); cx23885_set_scale(dev, buf->vb.width, buf->vb.height, buf->vb.field); /* reset counter */ cx_write(VID_A_GPCNT_CTL, 3); q->count = 1; /* enable irq */ <API key>(dev, 0x01); cx_set(VID_A_INT_MSK, 0x000011); /* start dma */ cx_set(DEV_CNTRL2, (1<<5)); cx_set(VID_A_DMA_CTL, 0x11); /* FIFO and RISC enable */ return 0; } static int <API key>(struct cx23885_dev *dev, struct cx23885_dmaqueue *q) { struct cx23885_buffer *buf, *prev; struct list_head *item; dprintk(1, "%s()\n", __func__); if (!list_empty(&q->active)) { buf = list_entry(q->active.next, struct cx23885_buffer, vb.queue); dprintk(2, "restart_queue [%p/%d]: restart dma\n", buf, buf->vb.i); <API key>(dev, q, buf); list_for_each(item, &q->active) { buf = list_entry(item, struct cx23885_buffer, vb.queue); buf->count = q->count++; } mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); return 0; } prev = NULL; for (;;) { if (list_empty(&q->queued)) return 0; buf = list_entry(q->queued.next, struct cx23885_buffer, vb.queue); if (NULL == prev) { list_move_tail(&buf->vb.queue, &q->active); <API key>(dev, q, buf); buf->vb.state = VIDEOBUF_ACTIVE; buf->count = q->count++; mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); dprintk(2, "[%p/%d] restart_queue - first active\n", buf, buf->vb.i); } else if (prev->vb.width == buf->vb.width && prev->vb.height == buf->vb.height && prev->fmt == buf->fmt) { list_move_tail(&buf->vb.queue, &q->active); buf->vb.state = VIDEOBUF_ACTIVE; buf->count = q->count++; prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[2] = cpu_to_le32(0); /* Bits 63 - 32 */ dprintk(2, "[%p/%d] restart_queue - move to active\n", buf, buf->vb.i); } else { return 0; } prev = buf; } } static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) { struct cx23885_fh *fh = q->priv_data; *size = fh->fmt->depth*fh->width*fh->height >> 3; if (0 == *count) *count = 32; if (*size * *count > vid_limit * 1024 * 1024) *count = (vid_limit * 1024 * 1024) / *size; return 0; } static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, enum v4l2_field field) { struct cx23885_fh *fh = q->priv_data; struct cx23885_dev *dev = fh->dev; struct cx23885_buffer *buf = container_of(vb, struct cx23885_buffer, vb); int rc, init_buffer = 0; u32 line0_offset, line1_offset; struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb); BUG_ON(NULL == fh->fmt); if (fh->width < 48 || fh->width > norm_maxw(dev->tvnorm) || fh->height < 32 || fh->height > norm_maxh(dev->tvnorm)) return -EINVAL; buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) return -EINVAL; if (buf->fmt != fh->fmt || buf->vb.width != fh->width || buf->vb.height != fh->height || buf->vb.field != field) { buf->fmt = fh->fmt; buf->vb.width = fh->width; buf->vb.height = fh->height; buf->vb.field = field; init_buffer = 1; } if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { init_buffer = 1; rc = videobuf_iolock(q, &buf->vb, NULL); if (0 != rc) goto fail; } if (init_buffer) { buf->bpl = buf->vb.width * buf->fmt->depth >> 3; switch (buf->vb.field) { case V4L2_FIELD_TOP: cx23885_risc_buffer(dev->pci, &buf->risc, dma->sglist, 0, UNSET, buf->bpl, 0, buf->vb.height); break; case V4L2_FIELD_BOTTOM: cx23885_risc_buffer(dev->pci, &buf->risc, dma->sglist, UNSET, 0, buf->bpl, 0, buf->vb.height); break; case <API key>: if (dev->tvnorm & V4L2_STD_NTSC) { /* cx25840 transmits NTSC bottom field first */ dprintk(1, "%s() Creating NTSC risc\n", __func__); line0_offset = buf->bpl; line1_offset = 0; } else { /* All other formats are top field first */ dprintk(1, "%s() Creating PAL/SECAM risc\n", __func__); line0_offset = 0; line1_offset = buf->bpl; } cx23885_risc_buffer(dev->pci, &buf->risc, dma->sglist, line0_offset, line1_offset, buf->bpl, buf->bpl, buf->vb.height >> 1); break; case V4L2_FIELD_SEQ_TB: cx23885_risc_buffer(dev->pci, &buf->risc, dma->sglist, 0, buf->bpl * (buf->vb.height >> 1), buf->bpl, 0, buf->vb.height >> 1); break; case V4L2_FIELD_SEQ_BT: cx23885_risc_buffer(dev->pci, &buf->risc, dma->sglist, buf->bpl * (buf->vb.height >> 1), 0, buf->bpl, 0, buf->vb.height >> 1); break; default: BUG(); } } dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", buf, buf->vb.i, fh->width, fh->height, fh->fmt->depth, fh->fmt->name, (unsigned long)buf->risc.dma); buf->vb.state = VIDEOBUF_PREPARED; return 0; fail: cx23885_free_buffer(q, buf); return rc; } static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) { struct cx23885_buffer *buf = container_of(vb, struct cx23885_buffer, vb); struct cx23885_buffer *prev; struct cx23885_fh *fh = vq->priv_data; struct cx23885_dev *dev = fh->dev; struct cx23885_dmaqueue *q = &dev->vidq; /* add jump to stopper */ buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ if (!list_empty(&q->queued)) { list_add_tail(&buf->vb.queue, &q->queued); buf->vb.state = VIDEOBUF_QUEUED; dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); } else if (list_empty(&q->active)) { list_add_tail(&buf->vb.queue, &q->active); <API key>(dev, q, buf); buf->vb.state = VIDEOBUF_ACTIVE; buf->count = q->count++; mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); dprintk(2, "[%p/%d] buffer_queue - first active\n", buf, buf->vb.i); } else { prev = list_entry(q->active.prev, struct cx23885_buffer, vb.queue); if (prev->vb.width == buf->vb.width && prev->vb.height == buf->vb.height && prev->fmt == buf->fmt) { list_add_tail(&buf->vb.queue, &q->active); buf->vb.state = VIDEOBUF_ACTIVE; buf->count = q->count++; prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); /* 64 bit bits 63-32 */ prev->risc.jmp[2] = cpu_to_le32(0); dprintk(2, "[%p/%d] buffer_queue - append to active\n", buf, buf->vb.i); } else { list_add_tail(&buf->vb.queue, &q->queued); buf->vb.state = VIDEOBUF_QUEUED; dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); } } } static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct cx23885_buffer *buf = container_of(vb, struct cx23885_buffer, vb); cx23885_free_buffer(q, buf); } static struct videobuf_queue_ops cx23885_video_qops = { .buf_setup = buffer_setup, .buf_prepare = buffer_prepare, .buf_queue = buffer_queue, .buf_release = buffer_release, }; static struct videobuf_queue *get_queue(struct cx23885_fh *fh) { switch (fh->type) { case <API key>: return &fh->vidq; case <API key>: return &fh->vbiq; default: BUG(); return NULL; } } static int get_resource(struct cx23885_fh *fh) { switch (fh->type) { case <API key>: return RESOURCE_VIDEO; case <API key>: return RESOURCE_VBI; default: BUG(); return 0; } } static int video_open(struct file *file) { struct video_device *vdev = video_devdata(file); struct cx23885_dev *dev = video_drvdata(file); struct cx23885_fh *fh; enum v4l2_buf_type type = 0; int radio = 0; switch (vdev->vfl_type) { case VFL_TYPE_GRABBER: type = <API key>; break; case VFL_TYPE_VBI: type = <API key>; break; case VFL_TYPE_RADIO: radio = 1; break; } dprintk(1, "open dev=%s radio=%d type=%s\n", <API key>(vdev), radio, v4l2_type_names[type]); /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh), GFP_KERNEL); if (NULL == fh) return -ENOMEM; file->private_data = fh; fh->dev = dev; fh->radio = radio; fh->type = type; fh->width = 320; fh->height = 240; fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); <API key>(&fh->vidq, &cx23885_video_qops, &dev->pci->dev, &dev->slock, <API key>, <API key>, sizeof(struct cx23885_buffer), fh, NULL); dprintk(1, "post videobuf_queue_init()\n"); return 0; } static ssize_t video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { struct cx23885_fh *fh = file->private_data; switch (fh->type) { case <API key>: if (res_locked(fh->dev, RESOURCE_VIDEO)) return -EBUSY; return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); case <API key>: if (!res_get(fh->dev, fh, RESOURCE_VBI)) return -EBUSY; return <API key>(&fh->vbiq, data, count, ppos, 1, file->f_flags & O_NONBLOCK); default: BUG(); return 0; } } static unsigned int video_poll(struct file *file, struct poll_table_struct *wait) { struct cx23885_fh *fh = file->private_data; struct cx23885_buffer *buf; unsigned int rc = POLLERR; if (<API key> == fh->type) { if (!res_get(fh->dev, fh, RESOURCE_VBI)) return POLLERR; return <API key>(file, &fh->vbiq, wait); } mutex_lock(&fh->vidq.vb_lock); if (res_check(fh, RESOURCE_VIDEO)) { /* streaming capture */ if (list_empty(&fh->vidq.stream)) goto done; buf = list_entry(fh->vidq.stream.next, struct cx23885_buffer, vb.stream); } else { /* read() capture */ buf = (struct cx23885_buffer *)fh->vidq.read_buf; if (NULL == buf) goto done; } poll_wait(file, &buf->vb.done, wait); if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) rc = POLLIN|POLLRDNORM; else rc = 0; done: mutex_unlock(&fh->vidq.vb_lock); return rc; } static int video_release(struct file *file) { struct cx23885_fh *fh = file->private_data; struct cx23885_dev *dev = fh->dev; /* turn off overlay */ if (res_check(fh, RESOURCE_OVERLAY)) { /* FIXME */ res_free(dev, fh, RESOURCE_OVERLAY); } /* stop video capture */ if (res_check(fh, RESOURCE_VIDEO)) { <API key>(&fh->vidq); res_free(dev, fh, RESOURCE_VIDEO); } if (fh->vidq.read_buf) { buffer_release(&fh->vidq, fh->vidq.read_buf); kfree(fh->vidq.read_buf); } /* stop vbi capture */ if (res_check(fh, RESOURCE_VBI)) { if (fh->vbiq.streaming) videobuf_streamoff(&fh->vbiq); if (fh->vbiq.reading) videobuf_read_stop(&fh->vbiq); res_free(dev, fh, RESOURCE_VBI); } videobuf_mmap_free(&fh->vidq); file->private_data = NULL; kfree(fh); /* We are not putting the tuner to sleep here on exit, because * we want to use the mpeg encoder in another session to capture * tuner video. Closing this will result in no video to the encoder. */ return 0; } static int video_mmap(struct file *file, struct vm_area_struct *vma) { struct cx23885_fh *fh = file->private_data; return <API key>(get_queue(fh), vma); } /* VIDEO CTRL IOCTLS */ static int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) { dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); call_all(dev, core, g_ctrl, ctl); return 0; } static int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) { dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" " (disabled - no action)\n", __func__); return 0; } static void init_controls(struct cx23885_dev *dev) { struct v4l2_control ctrl; int i; for (i = 0; i < CX23885_CTLS; i++) { ctrl.id = cx23885_ctls[i].v.id; ctrl.value = cx23885_ctls[i].v.default_value; cx23885_set_control(dev, &ctrl); } } /* VIDEO IOCTLS */ static int <API key>(struct file *file, void *priv, struct v4l2_format *f) { struct cx23885_fh *fh = priv; f->fmt.pix.width = fh->width; f->fmt.pix.height = fh->height; f->fmt.pix.field = fh->vidq.field; f->fmt.pix.pixelformat = fh->fmt->fourcc; f->fmt.pix.bytesperline = (f->fmt.pix.width * fh->fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; return 0; } static int <API key>(struct file *file, void *priv, struct v4l2_format *f) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; struct cx23885_fmt *fmt; enum v4l2_field field; unsigned int maxw, maxh; fmt = format_by_fourcc(f->fmt.pix.pixelformat); if (NULL == fmt) return -EINVAL; field = f->fmt.pix.field; maxw = norm_maxw(dev->tvnorm); maxh = norm_maxh(dev->tvnorm); if (V4L2_FIELD_ANY == field) { field = (f->fmt.pix.height > maxh/2) ? <API key> : V4L2_FIELD_BOTTOM; } switch (field) { case V4L2_FIELD_TOP: case V4L2_FIELD_BOTTOM: maxh = maxh / 2; break; case <API key>: break; default: return -EINVAL; } f->fmt.pix.field = field; <API key>(&f->fmt.pix.width, 48, maxw, 2, &f->fmt.pix.height, 32, maxh, 0, 0); f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; return 0; } static int <API key>(struct file *file, void *priv, struct v4l2_format *f) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; struct v4l2_mbus_framefmt mbus_fmt; int err; dprintk(2, "%s()\n", __func__); err = <API key>(file, priv, f); if (0 != err) return err; fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->width = f->fmt.pix.width; fh->height = f->fmt.pix.height; fh->vidq.field = f->fmt.pix.field; dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); <API key>(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); call_all(dev, video, s_mbus_fmt, &mbus_fmt); <API key>(&f->fmt.pix, &mbus_fmt); return 0; } static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; strcpy(cap->driver, "cx23885"); strlcpy(cap->card, cx23885_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); cap->version = <API key>; cap->capabilities = <API key> | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | <API key>; if (UNSET != dev->tuner_type) cap->capabilities |= V4L2_CAP_TUNER; return 0; } static int <API key>(struct file *file, void *priv, struct v4l2_fmtdesc *f) { if (unlikely(f->index >= ARRAY_SIZE(formats))) return -EINVAL; strlcpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; return 0; } static int vidioc_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { struct cx23885_fh *fh = priv; return videobuf_reqbufs(get_queue(fh), p); } static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct cx23885_fh *fh = priv; return videobuf_querybuf(get_queue(fh), p); } static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct cx23885_fh *fh = priv; return videobuf_qbuf(get_queue(fh), p); } static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct cx23885_fh *fh = priv; return videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); } static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = fh->dev; dprintk(1, "%s()\n", __func__); if (unlikely(fh->type != <API key>)) return -EINVAL; if (unlikely(i != fh->type)) return -EINVAL; if (unlikely(!res_get(dev, fh, get_resource(fh)))) return -EBUSY; return videobuf_streamon(get_queue(fh)); } static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = fh->dev; int err, res; dprintk(1, "%s()\n", __func__); if (fh->type != <API key>) return -EINVAL; if (i != fh->type) return -EINVAL; res = get_resource(fh); err = videobuf_streamoff(get_queue(fh)); if (err < 0) return err; res_free(dev, fh, res); return 0; } static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *tvnorms) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; dprintk(1, "%s()\n", __func__); mutex_lock(&dev->lock); cx23885_set_tvnorm(dev, *tvnorms); mutex_unlock(&dev->lock); return 0; } static int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i) { static const char *iname[] = { [<API key>] = "Composite1", [<API key>] = "Composite2", [<API key>] = "Composite3", [<API key>] = "Composite4", [CX23885_VMUX_SVIDEO] = "S-Video", [<API key>] = "Component", [<API key>] = "Television", [CX23885_VMUX_CABLE] = "Cable TV", [CX23885_VMUX_DVB] = "DVB", [CX23885_VMUX_DEBUG] = "for debug only", }; unsigned int n; dprintk(1, "%s()\n", __func__); n = i->index; if (n >= 4) return -EINVAL; if (0 == INPUT(n)->type) return -EINVAL; i->index = n; i->type = <API key>; strcpy(i->name, iname[INPUT(n)->type]); if ((<API key> == INPUT(n)->type) || (CX23885_VMUX_CABLE == INPUT(n)->type)) { i->type = <API key>; i->std = CX23885_NORMS; } return 0; } static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; dprintk(1, "%s()\n", __func__); return cx23885_enum_input(dev, i); } static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; *i = dev->input; dprintk(1, "%s() returns %d\n", __func__, *i); return 0; } static int vidioc_s_input(struct file *file, void *priv, unsigned int i) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; dprintk(1, "%s(%d)\n", __func__, i); if (i >= 4) { dprintk(1, "%s() -EINVAL\n", __func__); return -EINVAL; } mutex_lock(&dev->lock); cx23885_video_mux(dev, i); mutex_unlock(&dev->lock); return 0; } static int vidioc_log_status(struct file *file, void *priv) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = fh->dev; printk(KERN_INFO "%s/0: ============ START LOG STATUS ============\n", dev->name); call_all(dev, core, log_status); printk(KERN_INFO "%s/0: ============= END LOG STATUS =============\n", dev->name); return 0; } static int vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *qctrl) { qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); if (unlikely(qctrl->id == 0)) return -EINVAL; return cx23885_ctrl_query(qctrl); } static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctl) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; return cx23885_get_control(dev, ctl); } static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctl) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; return cx23885_set_control(dev, ctl); } static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; if (unlikely(UNSET == dev->tuner_type)) return -EINVAL; if (0 != t->index) return -EINVAL; strcpy(t->name, "Television"); t->type = <API key>; t->capability = V4L2_TUNER_CAP_NORM; t->rangehigh = 0xffffffffUL; t->signal = 0xffff ; /* LOCKED */ return 0; } static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) { struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; if (UNSET == dev->tuner_type) return -EINVAL; if (0 != t->index) return -EINVAL; return 0; } static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = fh->dev; if (unlikely(UNSET == dev->tuner_type)) return -EINVAL; /* f->type = fh->radio ? V4L2_TUNER_RADIO : <API key>; */ f->type = fh->radio ? V4L2_TUNER_RADIO : <API key>; f->frequency = dev->freq; call_all(dev, tuner, g_frequency, f); return 0; } static int cx23885_set_freq(struct cx23885_dev *dev, struct v4l2_frequency *f) { if (unlikely(UNSET == dev->tuner_type)) return -EINVAL; if (unlikely(f->tuner != 0)) return -EINVAL; mutex_lock(&dev->lock); dev->freq = f->frequency; call_all(dev, tuner, s_frequency, f); /* When changing channels it is required to reset TVAUDIO */ msleep(10); mutex_unlock(&dev->lock); return 0; } static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { struct cx23885_fh *fh = priv; struct cx23885_dev *dev = fh->dev; if (unlikely(0 == fh->radio && f->type != <API key>)) return -EINVAL; if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) return -EINVAL; return cx23885_set_freq(dev, f); } static void cx23885_vid_timeout(unsigned long data) { struct cx23885_dev *dev = (struct cx23885_dev *)data; struct cx23885_dmaqueue *q = &dev->vidq; struct cx23885_buffer *buf; unsigned long flags; <API key>(dev, &dev->sram_channels[SRAM_CH01]); cx_clear(VID_A_DMA_CTL, 0x11); spin_lock_irqsave(&dev->slock, flags); while (!list_empty(&q->active)) { buf = list_entry(q->active.next, struct cx23885_buffer, vb.queue); list_del(&buf->vb.queue); buf->vb.state = VIDEOBUF_ERROR; wake_up(&buf->vb.done); printk(KERN_ERR "%s/0: [%p/%d] timeout - dma=0x%08lx\n", dev->name, buf, buf->vb.i, (unsigned long)buf->risc.dma); } <API key>(dev, q); <API key>(&dev->slock, flags); } int cx23885_video_irq(struct cx23885_dev *dev, u32 status) { u32 mask, count; int handled = 0; mask = cx_read(VID_A_INT_MSK); if (0 == (status & mask)) return handled; cx_write(VID_A_INT_STAT, status); dprintk(2, "%s() status = 0x%08x\n", __func__, status); /* risc op code error */ if (status & (1 << 16)) { printk(KERN_WARNING "%s/0: video risc op code error\n", dev->name); cx_clear(VID_A_DMA_CTL, 0x11); <API key>(dev, &dev->sram_channels[SRAM_CH01]); } /* risc1 y */ if (status & 0x01) { spin_lock(&dev->slock); count = cx_read(VID_A_GPCNT); <API key>(dev, &dev->vidq, count); spin_unlock(&dev->slock); handled++; } /* risc2 y */ if (status & 0x10) { dprintk(2, "stopper video\n"); spin_lock(&dev->slock); <API key>(dev, &dev->vidq); spin_unlock(&dev->slock); handled++; } return handled; } /* exported stuff */ static const struct <API key> video_fops = { .owner = THIS_MODULE, .open = video_open, .release = video_release, .read = video_read, .poll = video_poll, .mmap = video_mmap, .ioctl = video_ioctl2, }; static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .<API key> = <API key>, .<API key> = <API key>, .<API key> = <API key>, .<API key> = <API key>, .<API key> = cx23885_vbi_fmt, .<API key> = cx23885_vbi_fmt, .<API key> = cx23885_vbi_fmt, .vidioc_reqbufs = vidioc_reqbufs, .vidioc_querybuf = vidioc_querybuf, .vidioc_qbuf = vidioc_qbuf, .vidioc_dqbuf = vidioc_dqbuf, .vidioc_s_std = vidioc_s_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, .vidioc_log_status = vidioc_log_status, .vidioc_queryctrl = vidioc_queryctrl, .vidioc_g_ctrl = vidioc_g_ctrl, .vidioc_s_ctrl = vidioc_s_ctrl, .vidioc_streamon = vidioc_streamon, .vidioc_streamoff = vidioc_streamoff, .vidioc_g_tuner = vidioc_g_tuner, .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, .vidioc_g_chip_ident = <API key>, #ifdef <API key> .vidioc_g_register = cx23885_g_register, .vidioc_s_register = cx23885_s_register, #endif }; static struct video_device <API key>; static struct video_device <API key> = { .name = "cx23885-video", .fops = &video_fops, .ioctl_ops = &video_ioctl_ops, .tvnorms = CX23885_NORMS, .current_norm = V4L2_STD_NTSC_M, }; static const struct <API key> radio_fops = { .owner = THIS_MODULE, .open = video_open, .release = video_release, .ioctl = video_ioctl2, }; void <API key>(struct cx23885_dev *dev) { dprintk(1, "%s()\n", __func__); cx23885_irq_remove(dev, 0x01); if (dev->video_dev) { if (video_is_registered(dev->video_dev)) <API key>(dev->video_dev); else <API key>(dev->video_dev); dev->video_dev = NULL; btcx_riscmem_free(dev->pci, &dev->vidq.stopper); } } int <API key>(struct cx23885_dev *dev) { int err; dprintk(1, "%s()\n", __func__); spin_lock_init(&dev->slock); /* Initialize VBI template */ memcpy(&<API key>, &<API key>, sizeof(<API key>)); strcpy(<API key>.name, "cx23885-vbi"); dev->tvnorm = <API key>.current_norm; /* init video dma queues */ INIT_LIST_HEAD(&dev->vidq.active); INIT_LIST_HEAD(&dev->vidq.queued); dev->vidq.timeout.function = cx23885_vid_timeout; dev->vidq.timeout.data = (unsigned long)dev; init_timer(&dev->vidq.timeout); <API key>(dev->pci, &dev->vidq.stopper, VID_A_DMA_CTL, 0x11, 0x00); /* Don't enable VBI yet */ <API key>(dev, 0x01); if ((TUNER_ABSENT != dev->tuner_type) && ((dev->tuner_bus == 0) || (dev->tuner_bus == 1))) { struct v4l2_subdev *sd = NULL; if (dev->tuner_addr) sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_bus[dev->tuner_bus].i2c_adap, "tuner", dev->tuner_addr, NULL); else sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_bus[dev->tuner_bus].i2c_adap, "tuner", 0, <API key>(ADDRS_TV)); if (sd) { struct tuner_setup tun_setup; memset(&tun_setup, 0, sizeof(tun_setup)); tun_setup.mode_mask = T_ANALOG_TV; tun_setup.type = dev->tuner_type; tun_setup.addr = <API key>(sd); tun_setup.tuner_callback = <API key>; v4l2_subdev_call(sd, tuner, s_type_addr, &tun_setup); if (dev->board == <API key>) { struct xc2028_ctrl ctrl = { .fname = <API key>, .max_len = 64 }; struct <API key> cfg = { .tuner = dev->tuner_type, .priv = &ctrl }; v4l2_subdev_call(sd, tuner, s_config, &cfg); } } } /* register v4l devices */ dev->video_dev = cx23885_vdev_init(dev, dev->pci, &<API key>, "video"); err = <API key>(dev->video_dev, VFL_TYPE_GRABBER, video_nr[dev->nr]); if (err < 0) { printk(KERN_INFO "%s: can't register video device\n", dev->name); goto fail_unreg; } printk(KERN_INFO "%s/0: registered device %s [v4l2]\n", dev->name, <API key>(dev->video_dev)); /* initial device configuration */ mutex_lock(&dev->lock); cx23885_set_tvnorm(dev, dev->tvnorm); init_controls(dev); cx23885_video_mux(dev, 0); mutex_unlock(&dev->lock); return 0; fail_unreg: <API key>(dev); return err; }
#ifndef THUNDER_BGX_H #define THUNDER_BGX_H #define MAX_BGX_THUNDER 8 /* Max 4 nodes, 2 per node */ #define MAX_BGX_PER_CN88XX 2 #define MAX_LMAC_PER_BGX 4 #define <API key> 16 #define MAX_DMAC_PER_LMAC 8 #define MAX_FRAME_SIZE 9216 #define <API key> 2 #define MAX_LMAC (MAX_BGX_PER_CN88XX * MAX_LMAC_PER_BGX) /* Registers */ #define BGX_CMRX_CFG 0x00 #define CMR_PKT_TX_EN BIT_ULL(13) #define CMR_PKT_RX_EN BIT_ULL(14) #define CMR_EN BIT_ULL(15) #define BGX_CMR_GLOBAL_CFG 0x08 #define <API key> BIT_ULL(6) #define BGX_CMRX_RX_ID_MAP 0x60 #define BGX_CMRX_RX_STAT0 0x70 #define BGX_CMRX_RX_STAT1 0x78 #define BGX_CMRX_RX_STAT2 0x80 #define BGX_CMRX_RX_STAT3 0x88 #define BGX_CMRX_RX_STAT4 0x90 #define BGX_CMRX_RX_STAT5 0x98 #define BGX_CMRX_RX_STAT6 0xA0 #define BGX_CMRX_RX_STAT7 0xA8 #define BGX_CMRX_RX_STAT8 0xB0 #define BGX_CMRX_RX_STAT9 0xB8 #define BGX_CMRX_RX_STAT10 0xC0 #define BGX_CMRX_RX_BP_DROP 0xC8 #define <API key> 0x0E8 #define <API key> 0x200 #define RX_DMACX_CAM_EN BIT_ULL(48) #define RX_DMACX_CAM_LMACID(x) (x << 49) #define RX_DMAC_COUNT 32 #define <API key> 0x300 #define <API key> 8 #define <API key> 0x450 #define BGX_CMR_BIST_STATUS 0x460 #define BGX_CMR_RX_LMACS 0x468 #define BGX_CMRX_TX_STAT0 0x600 #define BGX_CMRX_TX_STAT1 0x608 #define BGX_CMRX_TX_STAT2 0x610 #define BGX_CMRX_TX_STAT3 0x618 #define BGX_CMRX_TX_STAT4 0x620 #define BGX_CMRX_TX_STAT5 0x628 #define BGX_CMRX_TX_STAT6 0x630 #define BGX_CMRX_TX_STAT7 0x638 #define BGX_CMRX_TX_STAT8 0x640 #define BGX_CMRX_TX_STAT9 0x648 #define BGX_CMRX_TX_STAT10 0x650 #define BGX_CMRX_TX_STAT11 0x658 #define BGX_CMRX_TX_STAT12 0x660 #define BGX_CMRX_TX_STAT13 0x668 #define BGX_CMRX_TX_STAT14 0x670 #define BGX_CMRX_TX_STAT15 0x678 #define BGX_CMRX_TX_STAT16 0x680 #define BGX_CMRX_TX_STAT17 0x688 #define BGX_CMR_TX_LMACS 0x1000 #define BGX_SPUX_CONTROL1 0x10000 #define SPU_CTL_LOW_POWER BIT_ULL(11) #define SPU_CTL_LOOPBACK BIT_ULL(14) #define SPU_CTL_RESET BIT_ULL(15) #define BGX_SPUX_STATUS1 0x10008 #define SPU_STATUS1_RCV_LNK BIT_ULL(2) #define BGX_SPUX_STATUS2 0x10020 #define SPU_STATUS2_RCVFLT BIT_ULL(10) #define BGX_SPUX_BX_STATUS 0x10028 #define <API key> BIT_ULL(12) #define BGX_SPUX_BR_STATUS1 0x10030 #define <API key> BIT_ULL(0) #define <API key> BIT_ULL(12) #define <API key> 0x10068 #define <API key> BIT_ULL(1) #define <API key> 0x10078 #define <API key> 0x10088 #define <API key> 0x10090 #define <API key> 0x100A0 #define SPU_FEC_CTL_FEC_EN BIT_ULL(0) #define SPU_FEC_CTL_ERR_EN BIT_ULL(1) #define BGX_SPUX_AN_CONTROL 0x100C8 #define SPU_AN_CTL_AN_EN BIT_ULL(12) #define SPU_AN_CTL_XNP_EN BIT_ULL(13) #define BGX_SPUX_AN_ADV 0x100D8 #define <API key> 0x10218 #define <API key> BIT_ULL(10) #define SPU_MISC_CTL_RX_DIS BIT_ULL(12) #define BGX_SPUX_INT 0x10220 /* +(0..3) << 20 */ #define BGX_SPUX_INT_W1S 0x10228 #define <API key> 0x10230 #define <API key> 0x10238 #define BGX_SPU_DBG_CONTROL 0x10300 #define <API key> BIT_ULL(18) #define <API key> BIT_ULL(29) #define BGX_SMUX_RX_INT 0x20000 #define BGX_SMUX_RX_JABBER 0x20030 #define BGX_SMUX_RX_CTL 0x20048 #define SMU_RX_CTL_STATUS (3ull << 0) #define BGX_SMUX_TX_APPEND 0x20100 #define SMU_TX_APPEND_FCS_D BIT_ULL(2) #define BGX_SMUX_TX_MIN_PKT 0x20118 #define BGX_SMUX_TX_INT 0x20140 #define BGX_SMUX_TX_CTL 0x20178 #define SMU_TX_CTL_DIC_EN BIT_ULL(0) #define SMU_TX_CTL_UNI_EN BIT_ULL(1) #define <API key> (3ull << 4) #define BGX_SMUX_TX_THRESH 0x20180 #define BGX_SMUX_CTL 0x20200 #define SMU_CTL_RX_IDLE BIT_ULL(0) #define SMU_CTL_TX_IDLE BIT_ULL(1) #define BGX_GMP_PCS_MRX_CTL 0x30000 #define PCS_MRX_CTL_RST_AN BIT_ULL(9) #define PCS_MRX_CTL_PWR_DN BIT_ULL(11) #define PCS_MRX_CTL_AN_EN BIT_ULL(12) #define <API key> BIT_ULL(14) #define PCS_MRX_CTL_RESET BIT_ULL(15) #define <API key> 0x30008 #define <API key> BIT_ULL(5) #define <API key> 0x30020 #define <API key> 0x30068 #define <API key> 0x30078 #define <API key> BIT_ULL(11) #define <API key> 0x7Full #define <API key> 0x38020 #define GMI_PORT_CFG_SPEED BIT_ULL(1) #define GMI_PORT_CFG_DUPLEX BIT_ULL(2) #define <API key> BIT_ULL(3) #define <API key> BIT_ULL(8) #define <API key> 0x38038 #define <API key> 0x38210 #define <API key> 0x38218 #define <API key> 0x38220 #define <API key> 0x38228 #define <API key> 0x38240 #define <API key> 0x38300 #define <API key> 0x400000 /* +(0..29) << 4 */ #define <API key> 0x400008 #define BGX_MSIX_PBA_0 0x4F0000 /* MSI-X interrupts */ #define BGX_MSIX_VECTORS 30 #define BGX_LMAC_VEC_OFFSET 7 #define BGX_MSIX_VEC_SHIFT 4 #define CMRX_INT 0 #define SPUX_INT 1 #define SMUX_RX_INT 2 #define SMUX_TX_INT 3 #define GMPX_PCS_INT 4 #define GMPX_GMI_RX_INT 5 #define GMPX_GMI_TX_INT 6 #define CMR_MEM_INT 28 #define SPU_MEM_INT 29 #define LMAC_INTR_LINK_UP BIT(0) #define LMAC_INTR_LINK_DOWN BIT(1) /* RX_DMAC_CTL configuration*/ enum MCAST_MODE { MCAST_MODE_REJECT, MCAST_MODE_ACCEPT, <API key>, RSVD }; #define BCAST_ACCEPT 1 #define CAM_ACCEPT 1 void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac); unsigned bgx_get_map(int node); int bgx_get_lmac_count(int node, int bgx); const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid); void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac); void <API key>(int node, int bgx_idx, int lmacid, void *status); void <API key>(int node, int bgx_idx, int lmac_idx, bool enable); u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx); u64 bgx_get_tx_stats(int node, int bgx_idx, int lmac, int idx); #define BGX_RX_STATS_COUNT 11 #define BGX_TX_STATS_COUNT 18 struct bgx_stats { u64 rx_stats[BGX_RX_STATS_COUNT]; u64 tx_stats[BGX_TX_STATS_COUNT]; }; enum LMAC_TYPE { BGX_MODE_SGMII = 0, /* 1 lane, 1.250 Gbaud */ BGX_MODE_XAUI = 1, /* 4 lanes, 3.125 Gbaud */ BGX_MODE_DXAUI = 1, /* 4 lanes, 6.250 Gbaud */ BGX_MODE_RXAUI = 2, /* 2 lanes, 6.250 Gbaud */ BGX_MODE_XFI = 3, /* 1 lane, 10.3125 Gbaud */ BGX_MODE_XLAUI = 4, /* 4 lanes, 10.3125 Gbaud */ BGX_MODE_10G_KR = 3,/* 1 lane, 10.3125 Gbaud */ BGX_MODE_40G_KR = 4,/* 4 lanes, 10.3125 Gbaud */ }; enum qlm_mode { QLM_MODE_SGMII, /* SGMII, each lane independent */ QLM_MODE_XAUI_1X4, /* 1 XAUI or DXAUI, 4 lanes */ QLM_MODE_RXAUI_2X2, /* 2 RXAUI, 2 lanes each */ QLM_MODE_XFI_4X1, /* 4 XFI, 1 lane each */ QLM_MODE_XLAUI_1X4, /* 1 XLAUI, 4 lanes each */ QLM_MODE_10G_KR_4X1, /* 4 10GBASE-KR, 1 lane each */ <API key>, /* 1 40GBASE-KR4, 4 lanes each */ }; #endif /* THUNDER_BGX_H */
#include "ubi.h" #include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/module.h> /** * ubi_dump_flash - dump a region of flash. * @ubi: UBI device description object * @pnum: the physical eraseblock number to dump * @offset: the starting offset within the physical eraseblock to dump * @len: the length of the region to dump */ void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len) { int err; size_t read; void *buf; loff_t addr = (loff_t)pnum * ubi->peb_size + offset; buf = vmalloc(len); if (!buf) return; err = mtd_read(ubi->mtd, addr, len, &read, buf); if (err && err != -EUCLEAN) { ubi_err(ubi, "err %d while reading %d bytes from PEB %d:%d, read %zd bytes", err, len, pnum, offset, read); goto out; } ubi_msg(ubi, "dumping %d bytes of data from PEB %d, offset %d", len, pnum, offset); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); out: vfree(buf); return; } /** * ubi_dump_ec_hdr - dump an erase counter header. * @ec_hdr: the erase counter header to dump */ void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { pr_err("Erase counter header dump:\n"); pr_err("\tmagic %#08x\n", be32_to_cpu(ec_hdr->magic)); pr_err("\tversion %d\n", (int)ec_hdr->version); pr_err("\tec %llu\n", (long long)be64_to_cpu(ec_hdr->ec)); pr_err("\tvid_hdr_offset %d\n", be32_to_cpu(ec_hdr->vid_hdr_offset)); pr_err("\tdata_offset %d\n", be32_to_cpu(ec_hdr->data_offset)); pr_err("\timage_seq %d\n", be32_to_cpu(ec_hdr->image_seq)); pr_err("\thdr_crc %#08x\n", be32_to_cpu(ec_hdr->hdr_crc)); pr_err("erase counter header hexdump:\n"); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, ec_hdr, UBI_EC_HDR_SIZE, 1); } /** * ubi_dump_vid_hdr - dump a volume identifier header. * @vid_hdr: the volume identifier header to dump */ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) { pr_err("Volume identifier header dump:\n"); pr_err("\tmagic %08x\n", be32_to_cpu(vid_hdr->magic)); pr_err("\tversion %d\n", (int)vid_hdr->version); pr_err("\tvol_type %d\n", (int)vid_hdr->vol_type); pr_err("\tcopy_flag %d\n", (int)vid_hdr->copy_flag); pr_err("\tcompat %d\n", (int)vid_hdr->compat); pr_err("\tvol_id %d\n", be32_to_cpu(vid_hdr->vol_id)); pr_err("\tlnum %d\n", be32_to_cpu(vid_hdr->lnum)); pr_err("\tdata_size %d\n", be32_to_cpu(vid_hdr->data_size)); pr_err("\tused_ebs %d\n", be32_to_cpu(vid_hdr->used_ebs)); pr_err("\tdata_pad %d\n", be32_to_cpu(vid_hdr->data_pad)); pr_err("\tsqnum %llu\n", (unsigned long long)be64_to_cpu(vid_hdr->sqnum)); pr_err("\thdr_crc %08x\n", be32_to_cpu(vid_hdr->hdr_crc)); pr_err("Volume identifier header hexdump:\n"); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, vid_hdr, UBI_VID_HDR_SIZE, 1); } /** * ubi_dump_vol_info - dump volume information. * @vol: UBI volume description object */ void ubi_dump_vol_info(const struct ubi_volume *vol) { pr_err("Volume information dump:\n"); pr_err("\tvol_id %d\n", vol->vol_id); pr_err("\treserved_pebs %d\n", vol->reserved_pebs); pr_err("\talignment %d\n", vol->alignment); pr_err("\tdata_pad %d\n", vol->data_pad); pr_err("\tvol_type %d\n", vol->vol_type); pr_err("\tname_len %d\n", vol->name_len); pr_err("\tusable_leb_size %d\n", vol->usable_leb_size); pr_err("\tused_ebs %d\n", vol->used_ebs); pr_err("\tused_bytes %lld\n", vol->used_bytes); pr_err("\tlast_eb_bytes %d\n", vol->last_eb_bytes); pr_err("\tcorrupted %d\n", vol->corrupted); pr_err("\tupd_marker %d\n", vol->upd_marker); if (vol->name_len <= UBI_VOL_NAME_MAX && strnlen(vol->name, vol->name_len + 1) == vol->name_len) { pr_err("\tname %s\n", vol->name); } else { pr_err("\t1st 5 characters of name: %c%c%c%c%c\n", vol->name[0], vol->name[1], vol->name[2], vol->name[3], vol->name[4]); } } /** * <API key> - dump a &struct ubi_vtbl_record object. * @r: the object to dump * @idx: volume table index */ void <API key>(const struct ubi_vtbl_record *r, int idx) { int name_len = be16_to_cpu(r->name_len); pr_err("Volume table record %d dump:\n", idx); pr_err("\treserved_pebs %d\n", be32_to_cpu(r->reserved_pebs)); pr_err("\talignment %d\n", be32_to_cpu(r->alignment)); pr_err("\tdata_pad %d\n", be32_to_cpu(r->data_pad)); pr_err("\tvol_type %d\n", (int)r->vol_type); pr_err("\tupd_marker %d\n", (int)r->upd_marker); pr_err("\tname_len %d\n", name_len); if (r->name[0] == '\0') { pr_err("\tname NULL\n"); return; } if (name_len <= UBI_VOL_NAME_MAX && strnlen(&r->name[0], name_len + 1) == name_len) { pr_err("\tname %s\n", &r->name[0]); } else { pr_err("\t1st 5 characters of name: %c%c%c%c%c\n", r->name[0], r->name[1], r->name[2], r->name[3], r->name[4]); } pr_err("\tcrc %#08x\n", be32_to_cpu(r->crc)); } /** * ubi_dump_av - dump a &struct ubi_ainf_volume object. * @av: the object to dump */ void ubi_dump_av(const struct ubi_ainf_volume *av) { pr_err("Volume attaching information dump:\n"); pr_err("\tvol_id %d\n", av->vol_id); pr_err("\thighest_lnum %d\n", av->highest_lnum); pr_err("\tleb_count %d\n", av->leb_count); pr_err("\tcompat %d\n", av->compat); pr_err("\tvol_type %d\n", av->vol_type); pr_err("\tused_ebs %d\n", av->used_ebs); pr_err("\tlast_data_size %d\n", av->last_data_size); pr_err("\tdata_pad %d\n", av->data_pad); } /** * ubi_dump_aeb - dump a &struct ubi_ainf_peb object. * @aeb: the object to dump * @type: object type: 0 - not corrupted, 1 - corrupted */ void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type) { pr_err("eraseblock attaching information dump:\n"); pr_err("\tec %d\n", aeb->ec); pr_err("\tpnum %d\n", aeb->pnum); if (type == 0) { pr_err("\tlnum %d\n", aeb->lnum); pr_err("\tscrub %d\n", aeb->scrub); pr_err("\tsqnum %llu\n", aeb->sqnum); } } /** * ubi_dump_mkvol_req - dump a &struct ubi_mkvol_req object. * @req: the object to dump */ void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req) { char nm[17]; pr_err("Volume creation request dump:\n"); pr_err("\tvol_id %d\n", req->vol_id); pr_err("\talignment %d\n", req->alignment); pr_err("\tbytes %lld\n", (long long)req->bytes); pr_err("\tvol_type %d\n", req->vol_type); pr_err("\tname_len %d\n", req->name_len); memcpy(nm, req->name, 16); nm[16] = 0; pr_err("\t1st 16 characters of name: %s\n", nm); } /* * Root directory for UBI stuff in debugfs. Contains sub-directories which * contain the stuff specific to particular UBI devices. */ static struct dentry *dfs_rootdir; /** * ubi_debugfs_init - create UBI debugfs directory. * * Create UBI debugfs directory. Returns zero in case of success and a negative * error code in case of failure. */ int ubi_debugfs_init(void) { if (!IS_ENABLED(CONFIG_DEBUG_FS)) return 0; dfs_rootdir = debugfs_create_dir("ubi", NULL); if (IS_ERR_OR_NULL(dfs_rootdir)) { int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV; pr_err("UBI error: cannot create \"ubi\" debugfs directory, error %d\n", err); return err; } return 0; } /** * ubi_debugfs_exit - remove UBI debugfs directory. */ void ubi_debugfs_exit(void) { if (IS_ENABLED(CONFIG_DEBUG_FS)) debugfs_remove(dfs_rootdir); } /* Read an UBI debugfs file */ static ssize_t dfs_file_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { unsigned long ubi_num = (unsigned long)file->private_data; struct dentry *dent = file->f_path.dentry; struct ubi_device *ubi; struct ubi_debug_info *d; char buf[8]; int val; ubi = ubi_get_device(ubi_num); if (!ubi) return -ENODEV; d = &ubi->dbg; if (dent == d->dfs_chk_gen) val = d->chk_gen; else if (dent == d->dfs_chk_io) val = d->chk_io; else if (dent == d->dfs_chk_fastmap) val = d->chk_fastmap; else if (dent == d->dfs_disable_bgt) val = d->disable_bgt; else if (dent == d-><API key>) val = d->emulate_bitflips; else if (dent == d-><API key>) val = d->emulate_io_failures; else if (dent == d-><API key>) { snprintf(buf, sizeof(buf), "%u\n", d->emulate_power_cut); count = <API key>(user_buf, count, ppos, buf, strlen(buf)); goto out; } else if (dent == d->dfs_power_cut_min) { snprintf(buf, sizeof(buf), "%u\n", d->power_cut_min); count = <API key>(user_buf, count, ppos, buf, strlen(buf)); goto out; } else if (dent == d->dfs_power_cut_max) { snprintf(buf, sizeof(buf), "%u\n", d->power_cut_max); count = <API key>(user_buf, count, ppos, buf, strlen(buf)); goto out; } else { count = -EINVAL; goto out; } if (val) buf[0] = '1'; else buf[0] = '0'; buf[1] = '\n'; buf[2] = 0x00; count = <API key>(user_buf, count, ppos, buf, 2); out: ubi_put_device(ubi); return count; } /* Write an UBI debugfs file */ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { unsigned long ubi_num = (unsigned long)file->private_data; struct dentry *dent = file->f_path.dentry; struct ubi_device *ubi; struct ubi_debug_info *d; size_t buf_size; char buf[8] = {0}; int val; ubi = ubi_get_device(ubi_num); if (!ubi) return -ENODEV; d = &ubi->dbg; buf_size = min_t(size_t, count, (sizeof(buf) - 1)); if (copy_from_user(buf, user_buf, buf_size)) { count = -EFAULT; goto out; } if (dent == d->dfs_power_cut_min) { if (kstrtouint(buf, 0, &d->power_cut_min) != 0) count = -EINVAL; goto out; } else if (dent == d->dfs_power_cut_max) { if (kstrtouint(buf, 0, &d->power_cut_max) != 0) count = -EINVAL; goto out; } else if (dent == d-><API key>) { if (kstrtoint(buf, 0, &val) != 0) count = -EINVAL; else d->emulate_power_cut = val; goto out; } if (buf[0] == '1') val = 1; else if (buf[0] == '0') val = 0; else { count = -EINVAL; goto out; } if (dent == d->dfs_chk_gen) d->chk_gen = val; else if (dent == d->dfs_chk_io) d->chk_io = val; else if (dent == d->dfs_chk_fastmap) d->chk_fastmap = val; else if (dent == d->dfs_disable_bgt) d->disable_bgt = val; else if (dent == d-><API key>) d->emulate_bitflips = val; else if (dent == d-><API key>) d->emulate_io_failures = val; else count = -EINVAL; out: ubi_put_device(ubi); return count; } /* File operations for all UBI debugfs files */ static const struct file_operations dfs_fops = { .read = dfs_file_read, .write = dfs_file_write, .open = simple_open, .llseek = no_llseek, .owner = THIS_MODULE, }; /** * <API key> - initialize debugfs for an UBI device. * @ubi: UBI device description object * * This function creates all debugfs files for UBI device @ubi. Returns zero in * case of success and a negative error code in case of failure. */ int <API key>(struct ubi_device *ubi) { int err, n; unsigned long ubi_num = ubi->ubi_num; const char *fname; struct dentry *dent; struct ubi_debug_info *d = &ubi->dbg; if (!IS_ENABLED(CONFIG_DEBUG_FS)) return 0; n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME, ubi->ubi_num); if (n == UBI_DFS_DIR_LEN) { /* The array size is too small */ fname = UBI_DFS_DIR_NAME; dent = ERR_PTR(-EINVAL); goto out; } fname = d->dfs_dir_name; dent = debugfs_create_dir(fname, dfs_rootdir); if (IS_ERR_OR_NULL(dent)) goto out; d->dfs_dir = dent; fname = "chk_gen"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_chk_gen = dent; fname = "chk_io"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_chk_io = dent; fname = "chk_fastmap"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_chk_fastmap = dent; fname = "tst_disable_bgt"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_disable_bgt = dent; fname = "<API key>"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d-><API key> = dent; fname = "<API key>"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d-><API key> = dent; fname = "<API key>"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d-><API key> = dent; fname = "<API key>"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_power_cut_min = dent; fname = "<API key>"; dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, &dfs_fops); if (IS_ERR_OR_NULL(dent)) goto out_remove; d->dfs_power_cut_max = dent; return 0; out_remove: <API key>(d->dfs_dir); out: err = dent ? PTR_ERR(dent) : -ENODEV; ubi_err(ubi, "cannot create \"%s\" debugfs file or directory, error %d\n", fname, err); return err; } /** * dbg_debug_exit_dev - free all debugfs files corresponding to device @ubi * @ubi: UBI device description object */ void <API key>(struct ubi_device *ubi) { if (IS_ENABLED(CONFIG_DEBUG_FS)) <API key>(ubi->dbg.dfs_dir); } /** * ubi_dbg_power_cut - emulate a power cut if it is time to do so * @ubi: UBI device description object * @caller: Flags set to indicate from where the function is being called * * Returns non-zero if a power cut was emulated, zero if not. */ int ubi_dbg_power_cut(struct ubi_device *ubi, int caller) { unsigned int range; if ((ubi->dbg.emulate_power_cut & caller) == 0) return 0; if (ubi->dbg.power_cut_counter == 0) { ubi->dbg.power_cut_counter = ubi->dbg.power_cut_min; if (ubi->dbg.power_cut_max > ubi->dbg.power_cut_min) { range = ubi->dbg.power_cut_max - ubi->dbg.power_cut_min; ubi->dbg.power_cut_counter += prandom_u32() % range; } return 0; } ubi->dbg.power_cut_counter if (ubi->dbg.power_cut_counter) return 0; ubi_msg(ubi, "XXXXXXXXXXXXXXX emulating a power cut XXXXXXXXXXXXXXXX"); ubi_ro_mode(ubi); return 1; }
-- Delete redundant data first DELETE FROM `spelldifficulty_dbc` WHERE `id` IN (3042,3043,3044,3045,3046,3047,3048,3053,3055,3056,3057,3058,3059,3060,3061,3063,3073,3074,3075,3076,3077,3078,3079,3080,3081,3082,3083,3084,3085,3086,3087,3088,3089,3090,3091,3092,3093,3094,3095); INSERT INTO `spelldifficulty_dbc` (`id`, `spellid0`, `spellid1`, `spellid2`, `spellid3`) VALUES -- Razorscale spells (3042, 62796, 63815, 0, 0), -- SPELL_FIREBALL_10 / SPELL_FIREBALL_25 (3043, 64709, 64734, 0, 0), -- <API key> / <API key> (3044, 63317, 64021, 0, 0), -- <API key> / <API key> -- Ignis spells (3045, 62680, 63472, 0, 0), -- SPELL_FLAME_JETS_10 / SPELL_FLAME_JETS_25 (3046, 62546, 63474, 0, 0), -- SPELL_SCORCH_10 / SPELL_SCORCH_25 (3047, 62717, 63477, 0, 0), -- SPELL_SLAG_POT_10 / SPELL_SLAG_POT_25 (3048, 62836, 63536, 0, 0), -- <API key> / <API key> (3053, 62548, 63476, 0, 0); -- SPELL_GROUND_10 / SPELL_GROUND_25
(function (global, factory) { if (typeof define === 'function' && define.amd) { define(['exports', 'module', './util'], factory); } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') { factory(exports, module, require('./util')); } else { var mod = { exports: {} }; factory(mod.exports, mod, global.Util); global.modal = mod.exports; } })(this, function (exports, module, _util) { 'use strict'; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function <API key>(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var _Util = <API key>(_util); var Modal = (function ($) { var NAME = 'modal'; var VERSION = '4.0.0'; var DATA_KEY = 'bs.modal'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 300; var <API key> = 150; var Default = { backdrop: true, keyboard: true, focus: true, show: true }; var DefaultType = { backdrop: '(boolean|string)', keyboard: 'boolean', focus: 'boolean', show: 'boolean' }; var Event = { HIDE: 'hide' + EVENT_KEY, HIDDEN: 'hidden' + EVENT_KEY, SHOW: 'show' + EVENT_KEY, SHOWN: 'shown' + EVENT_KEY, FOCUSIN: 'focusin' + EVENT_KEY, RESIZE: 'resize' + EVENT_KEY, CLICK_DISMISS: 'click.dismiss' + EVENT_KEY, KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY, MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY, MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY, CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY }; var ClassName = { SCROLLBAR_MEASURER: '<API key>', BACKDROP: 'modal-backdrop', OPEN: 'modal-open', FADE: 'fade', IN: 'in' }; var Selector = { DIALOG: '.modal-dialog', DATA_TOGGLE: '[data-toggle="modal"]', DATA_DISMISS: '[data-dismiss="modal"]', FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed' }; var Modal = (function () { function Modal(element, config) { _classCallCheck(this, Modal); this._config = this._getConfig(config); this._element = element; this._dialog = $(element).find(Selector.DIALOG)[0]; this._backdrop = null; this._isShown = false; this._isBodyOverflowing = false; this.<API key> = false; this.<API key> = 0; this._scrollbarWidth = 0; } // getters _createClass(Modal, [{ key: 'toggle', // public value: function toggle(relatedTarget) { return this._isShown ? this.hide() : this.show(relatedTarget); } }, { key: 'show', value: function show(relatedTarget) { var _this = this; var showEvent = $.Event(Event.SHOW, { relatedTarget: relatedTarget }); $(this._element).trigger(showEvent); if (this._isShown || showEvent.isDefaultPrevented()) { return; } this._isShown = true; this._checkScrollbar(); this._setScrollbar(); $(document.body).addClass(ClassName.OPEN); this._setEscapeEvent(); this._setResizeEvent(); $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this)); $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { if ($(event.target).is(_this._element)) { that.<API key> = true; } }); }); this._showBackdrop($.proxy(this._showElement, this, relatedTarget)); } }, { key: 'hide', value: function hide(event) { if (event) { event.preventDefault(); } var hideEvent = $.Event(Event.HIDE); $(this._element).trigger(hideEvent); if (!this._isShown || hideEvent.isDefaultPrevented()) { return; } this._isShown = false; this._setEscapeEvent(); this._setResizeEvent(); $(document).off(Event.FOCUSIN); $(this._element).removeClass(ClassName.IN); $(this._element).off(Event.CLICK_DISMISS); $(this._dialog).off(Event.MOUSEDOWN_DISMISS); if (_Util['default'].<API key>() && $(this._element).hasClass(ClassName.FADE)) { $(this._element).one(_Util['default'].TRANSITION_END, $.proxy(this._hideModal, this)).<API key>(TRANSITION_DURATION); } else { this._hideModal(); } } }, { key: 'dispose', value: function dispose() { $.removeData(this._element, DATA_KEY); $(window).off(EVENT_KEY); $(document).off(EVENT_KEY); $(this._element).off(EVENT_KEY); $(this._backdrop).off(EVENT_KEY); this._config = null; this._element = null; this._dialog = null; this._backdrop = null; this._isShown = null; this._isBodyOverflowing = null; this.<API key> = null; this.<API key> = null; this._scrollbarWidth = null; } // private }, { key: '_getConfig', value: function _getConfig(config) { config = $.extend({}, Default, config); _Util['default'].typeCheckConfig(NAME, config, DefaultType); return config; } }, { key: '_showElement', value: function _showElement(relatedTarget) { var _this2 = this; var transition = _Util['default'].<API key>() && $(this._element).hasClass(ClassName.FADE); if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { // don't move modals dom position document.body.appendChild(this._element); } this._element.style.display = 'block'; this._element.scrollTop = 0; if (transition) { _Util['default'].reflow(this._element); } $(this._element).addClass(ClassName.IN); if (this._config.focus) { this._enforceFocus(); } var shownEvent = $.Event(Event.SHOWN, { relatedTarget: relatedTarget }); var transitionComplete = function transitionComplete() { if (_this2._config.focus) { _this2._element.focus(); } $(_this2._element).trigger(shownEvent); }; if (transition) { $(this._dialog).one(_Util['default'].TRANSITION_END, transitionComplete).<API key>(TRANSITION_DURATION); } else { transitionComplete(); } } }, { key: '_enforceFocus', value: function _enforceFocus() { var _this3 = this; $(document).off(Event.FOCUSIN) // guard against infinite focus loop .on(Event.FOCUSIN, function (event) { if (_this3._element !== event.target && !$(_this3._element).has(event.target).length) { _this3._element.focus(); } }); } }, { key: '_setEscapeEvent', value: function _setEscapeEvent() { var _this4 = this; if (this._isShown && this._config.keyboard) { $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { if (event.which === 27) { _this4.hide(); } }); } else if (!this._isShown) { $(this._element).off(Event.KEYDOWN_DISMISS); } } }, { key: '_setResizeEvent', value: function _setResizeEvent() { if (this._isShown) { $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)); } else { $(window).off(Event.RESIZE); } } }, { key: '_hideModal', value: function _hideModal() { var _this5 = this; this._element.style.display = 'none'; this._showBackdrop(function () { $(document.body).removeClass(ClassName.OPEN); _this5._resetAdjustments(); _this5._resetScrollbar(); $(_this5._element).trigger(Event.HIDDEN); }); } }, { key: '_removeBackdrop', value: function _removeBackdrop() { if (this._backdrop) { $(this._backdrop).remove(); this._backdrop = null; } } }, { key: '_showBackdrop', value: function _showBackdrop(callback) { var _this6 = this; var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; if (this._isShown && this._config.backdrop) { var doAnimate = _Util['default'].<API key>() && animate; this._backdrop = document.createElement('div'); this._backdrop.className = ClassName.BACKDROP; if (animate) { $(this._backdrop).addClass(animate); } $(this._backdrop).appendTo(document.body); $(this._element).on(Event.CLICK_DISMISS, function (event) { if (_this6.<API key>) { _this6.<API key> = false; return; } if (event.target !== event.currentTarget) { return; } if (_this6._config.backdrop === 'static') { _this6._element.focus(); } else { _this6.hide(); } }); if (doAnimate) { _Util['default'].reflow(this._backdrop); } $(this._backdrop).addClass(ClassName.IN); if (!callback) { return; } if (!doAnimate) { callback(); return; } $(this._backdrop).one(_Util['default'].TRANSITION_END, callback).<API key>(<API key>); } else if (!this._isShown && this._backdrop) { $(this._backdrop).removeClass(ClassName.IN); var callbackRemove = function callbackRemove() { _this6._removeBackdrop(); if (callback) { callback(); } }; if (_Util['default'].<API key>() && $(this._element).hasClass(ClassName.FADE)) { $(this._backdrop).one(_Util['default'].TRANSITION_END, callbackRemove).<API key>(<API key>); } else { callbackRemove(); } } else if (callback) { callback(); } } // the following methods are used to handle overflowing modals // todo (fat): these should probably be refactored out of modal.js }, { key: '_handleUpdate', value: function _handleUpdate() { this._adjustDialog(); } }, { key: '_adjustDialog', value: function _adjustDialog() { var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; if (!this._isBodyOverflowing && isModalOverflowing) { this._element.style.paddingLeft = this._scrollbarWidth + 'px'; } if (this._isBodyOverflowing && !isModalOverflowing) { this._element.style.paddingRight = this._scrollbarWidth + 'px~'; } } }, { key: '_resetAdjustments', value: function _resetAdjustments() { this._element.style.paddingLeft = ''; this._element.style.paddingRight = ''; } }, { key: '_checkScrollbar', value: function _checkScrollbar() { var fullWindowWidth = window.innerWidth; if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 var documentElementRect = document.documentElement.<API key>(); fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); } this._isBodyOverflowing = document.body.clientWidth < fullWindowWidth; this._scrollbarWidth = this._getScrollbarWidth(); } }, { key: '_setScrollbar', value: function _setScrollbar() { var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10); this.<API key> = document.body.style.paddingRight || ''; if (this._isBodyOverflowing) { document.body.style.paddingRight = bodyPadding + (this._scrollbarWidth + 'px'); } } }, { key: '_resetScrollbar', value: function _resetScrollbar() { document.body.style.paddingRight = this.<API key>; } }, { key: '_getScrollbarWidth', value: function _getScrollbarWidth() { // thx d.walsh var scrollDiv = document.createElement('div'); scrollDiv.className = ClassName.SCROLLBAR_MEASURER; document.body.appendChild(scrollDiv); var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; document.body.removeChild(scrollDiv); return scrollbarWidth; } // static }], [{ key: '_jQueryInterface', value: function _jQueryInterface(config, relatedTarget) { return this.each(function () { var data = $(this).data(DATA_KEY); var _config = $.extend({}, Modal.Default, $(this).data(), typeof config === 'object' && config); if (!data) { data = new Modal(this, _config); $(this).data(DATA_KEY, data); } if (typeof config === 'string') { data[config](relatedTarget); } else if (_config.show) { data.show(relatedTarget); } }); } }, { key: 'VERSION', get: function get() { return VERSION; } }, { key: 'Default', get: function get() { return Default; } }]); return Modal; })(); $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { var _this7 = this; var target = undefined; var selector = _Util['default'].<API key>(this); if (selector) { target = $(selector)[0]; } var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()); if (this.tagName === 'A') { event.preventDefault(); } var $target = $(target).one(Event.SHOW, function (showEvent) { if (showEvent.isDefaultPrevented()) { // only register focus restorer if modal will actually get shown return; } $target.one(Event.HIDDEN, function () { if ($(_this7).is(':visible')) { _this7.focus(); } }); }); Modal._jQueryInterface.call($(target), config, this); }); $.fn[NAME] = Modal._jQueryInterface; $.fn[NAME].Constructor = Modal; $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Modal._jQueryInterface; }; return Modal; })(jQuery); module.exports = Modal; });
#if !defined(<API key>) #define <API key> #include <boost/fusion/support/config.hpp> namespace boost { namespace fusion { // Swallows any assignment (by Doug Gregor) namespace detail { struct swallow_assign { template<typename T> <API key> <API key> swallow_assign const& operator=(const T&) const { return *this; } }; } // "ignore" allows tuple positions to be ignored when using "tie". <API key> detail::swallow_assign ignore = detail::swallow_assign(); }} #endif
/* <API key>: GPL-2.0-or-later */ #ifndef DLMCONVERT_H #define DLMCONVERT_H enum dlm_status dlmconvert_master(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, struct dlm_lock *lock, int flags, int type); enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, struct dlm_lock *lock, int flags, int type); #endif