answer
stringlengths
15
1.25M
package org.eclipse.che.api.core.util; import org.testng.Assert; import org.testng.annotations.Test; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** @author andrew00x */ public class ProcessUtilTest { @Test public void testKill() throws Exception { final Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "sleep 10; echo wake\\ up"}); final List<String> stdout = new ArrayList<>(); final List<String> stderr = new ArrayList<>(); final IOException[] processError = new IOException[1]; final CountDownLatch latch = new CountDownLatch(1); final long start = System.currentTimeMillis(); new Thread() { public void run() { try { ProcessUtil.process(p, new LineConsumer() { @Override public void writeLine(String line) throws IOException { stdout.add(line); } @Override public void close() throws IOException { } }, new LineConsumer() { @Override public void writeLine(String line) throws IOException { stderr.add(line); } @Override public void close() throws IOException { } } ); } catch (IOException e) { processError[0] = e; // throw when kill process } finally { latch.countDown(); } } }.start(); Thread.sleep(1000); // give time to start process Assert.assertTrue(ProcessUtil.isAlive(p), "Process is not started."); ProcessUtil.kill(p); // kill process latch.await(15, TimeUnit.SECONDS); // should not stop here if process killed final long end = System.currentTimeMillis(); // System process sleeps 10 seconds. It is safety to check we done in less then 3 sec. Assert.assertTrue((end - start) < 3000, "Fail kill process"); System.out.println(processError[0]); //processError[0].printStackTrace(); System.out.println(stdout); System.out.println(stderr); } }
package com.python.pydev.refactoring.wizards.rename.visitors; import java.util.Stack; import org.python.pydev.parser.jython.SimpleNode; import org.python.pydev.parser.jython.Visitor; import org.python.pydev.parser.jython.ast.Call; import org.python.pydev.parser.jython.ast.Name; import org.python.pydev.parser.jython.ast.NameTok; /** * This visitor is used to find a call given its ast * * @author Fabio */ public class FindCallVisitor extends Visitor { private Name name; private NameTok nameTok; private Call call; private Stack<Call> lastCall = new Stack<Call>(); public FindCallVisitor(Name name) { this.name = name; } public FindCallVisitor(NameTok nameTok) { this.nameTok = nameTok; } public Call getCall() { return call; } @Override public Object visitCall(Call node) throws Exception { if (this.call != null) { return null; } if (node.func == name) { //check the name (direct) this.call = node; } else if (nameTok != null) { //check the name tok (inside of attribute) lastCall.push(node); Object r = super.visitCall(node); lastCall.pop(); if (this.call != null) { return null; } return r; } if (this.call != null) { return null; } return super.visitCall(node); } @Override public Object visitNameTok(NameTok node) throws Exception { if (node == nameTok) { if (lastCall.size() > 0) { call = lastCall.peek(); } return null; } return super.visitNameTok(node); } public static Call findCall(NameTok nametok, SimpleNode root) { FindCallVisitor visitor = new FindCallVisitor(nametok); try { visitor.traverse(root); } catch (Exception e) { throw new RuntimeException(e); } return visitor.call; } public static Call findCall(Name name, SimpleNode root) { FindCallVisitor visitor = new FindCallVisitor(name); try { visitor.traverse(root); } catch (Exception e) { throw new RuntimeException(e); } return visitor.call; } }
package com.intel.ide.eclipse.mpt.classpath; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Properties; import com.intel.ide.eclipse.mpt.launching.<API key>; public class ContactedClasses extends Resource implements IExternalResource, IClasspathContainer { private String binRelativePath; private List classList; private List externalList; public void load() { File file = getAbsoluteFile(); classList = new ArrayList(); externalList = new ArrayList(); if (file.exists()) { Properties props = PathUtil.loadJZ(file); String[] reses = PathUtil.getResources(props); binRelativePath = props.getProperty(PathUtil.J2S_OUTPUT_PATH); for (int i = 0; i < reses.length; i++) { if (reses[i] != null) { String res = reses[i].trim(); if (res.endsWith(".z.js")) { ContactedClasses jz = new ContactedClasses(); jz.setFolder(this.getAbsoluteFolder()); jz.setRelativePath(res); jz.setParent(this); externalList.add(jz); } else if (res.endsWith(".js")) { ContactedUnitClass unit = new ContactedUnitClass(); unit.setFolder(this.getAbsoluteFolder()); unit.setRelativePath(res); unit.parseClassName(); unit.setParent(this); classList.add(unit); } else if (res.endsWith(".css")) { CSSResource css = new CSSResource(); css.setFolder(this.getAbsoluteFolder()); css.setRelativePath(res); css.setParent(this); externalList.add(css); } } } } } public void store(Properties props) { Resource[] reses = getChildren(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < reses.length; i++) { String str = reses[i].toResourceString(); buf.append(str); if (i != reses.length - 1) { buf.append(","); } } props.setProperty(PathUtil.J2S_RESOURCES_LIST, buf.toString()); props.setProperty(PathUtil.J2S_OUTPUT_PATH, binRelativePath); } public Resource[] getChildren() { if (externalList == null || classList == null) { this.load(); } int size = externalList.size(); Resource[] res = new Resource[classList.size() + size]; for (int i = 0; i < size; i++) { res[i] = (Resource) externalList.get(i); } for (int i = 0; i < classList.size(); i++) { res[i + size] = (Resource) classList.get(i); } return res; } public ContactedUnitClass[] getClasses() { return (ContactedUnitClass[]) classList.toArray(new ContactedClasses[0]); } public IExternalResource[] getExternals() { return (IExternalResource[]) externalList.toArray(new IExternalResource[0]); } public String getBinRelativePath() { return binRelativePath; } public void setBinRelativePath(String binRelativePath) { this.binRelativePath = binRelativePath; } public String toHTMLString() { if (getRelativePath() != null && getRelativePath().endsWith(".j2x")) { return ""; } Resource p = this.getParent(); if (p != null) { if (p instanceof ContactedClasses) { Resource pp = p.getParent(); if (pp != null && pp instanceof ContactedClasses) { return ""; } } } StringBuffer buf = new StringBuffer(); if (externalList == null) { this.load(); } for (Iterator iter = externalList.iterator(); iter.hasNext();) { Resource res = (Resource) iter.next(); if (!<API key>.visit(res)) { continue; } buf.append(res.toHTMLString()); } buf.append("<script type=\"text/javascript\" src=\""); String binFolder = getBinRelativePath(); if (binFolder != null) { String binPath = binFolder.trim(); if (binPath.length() != 0) { buf.append(binPath); if (!binPath.endsWith("/")) { buf.append("/"); } } } if (p != null) { if (p instanceof ContactedClasses) { ContactedClasses cc = (ContactedClasses) p; String path = cc.getRelativePath(); int idx = path.lastIndexOf('/'); if (idx != -1) { buf.append(path.substring(0, idx + 1)); } } else if (p instanceof CompositeResources) { CompositeResources cc = (CompositeResources) p; String binRelative = cc.getBinRelativePath(); if (binRelative != null) { if (binRelative.length() != 0 && getRelativePath().endsWith(".z.js")) { return ""; } buf.append(binRelative); } } } buf.append(getRelativePath()); buf.append("\"></script>\r\n"); return buf.toString(); } public String toJ2XString() { if (getName().endsWith(".j2x")) { try { return getAbsoluteFile().getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); } } return ""; } public int getType() { return CONTAINER; } }
#include "../linux-g++/qplatformdefs.h"
#include <linux/kernel.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/bitops.h> #include <linux/device.h> #include <linux/mm.h> #include <linux/termios.h> #include <linux/dmaengine.h> #include <linux/amba/bus.h> #include <linux/amba/mmci.h> #include <linux/amba/serial.h> #include <linux/platform_device.h> #include <linux/gpio.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/mtd/nand.h> #include <linux/mtd/fsmc.h> #include <linux/pinctrl/machine.h> #include <linux/pinctrl/consumer.h> #include <linux/pinctrl/pinconf-generic.h> #include <linux/dma-mapping.h> #include <asm/types.h> #include <asm/setup.h> #include <asm/memory.h> #include <asm/hardware/vic.h> #include <asm/mach/map.h> #include <asm/mach/irq.h> #include <mach/coh901318.h> #include <mach/hardware.h> #include <mach/syscon.h> #include <mach/dma_channels.h> #include <mach/gpio-u300.h> #include "clock.h" #include "spi.h" #include "i2c.h" #include "u300-gpio.h" /* * Static I/O mappings that are needed for booting the U300 platforms. The * only things we need are the areas where we find the timer, syscon and * intcon, since the remaining device drivers will map their own memory * physical to virtual as the need arise. */ static struct map_desc u300_io_desc[] __initdata = { { .virtual = <API key>, .pfn = __phys_to_pfn(<API key>), .length = SZ_64K, .type = MT_DEVICE, }, { .virtual = <API key>, .pfn = __phys_to_pfn(<API key>), .length = SZ_32K, .type = MT_DEVICE, }, { .virtual = <API key>, .pfn = __phys_to_pfn(<API key>), .length = SZ_32K, .type = MT_DEVICE, }, }; void __init u300_map_io(void) { iotable_init(u300_io_desc, ARRAY_SIZE(u300_io_desc)); /* We enable a real big DMA buffer if need be. */ <API key>(SZ_4M); } /* * Declaration of devices found on the U300 board and * their respective memory locations. */ static struct amba_pl011_data uart0_plat_data = { #ifdef CONFIG_COH901318 .dma_filter = coh901318_filter_id, .dma_rx_param = (void *) U300_DMA_UART0_RX, .dma_tx_param = (void *) U300_DMA_UART0_TX, #endif }; /* Slow device at 0x3000 offset */ static AMBA_APB_DEVICE(uart0, "uart0", 0, U300_UART0_BASE, { IRQ_U300_UART0 }, &uart0_plat_data); /* The U335 have an additional UART1 on the APP CPU */ #ifdef <API key> static struct amba_pl011_data uart1_plat_data = { #ifdef CONFIG_COH901318 .dma_filter = coh901318_filter_id, .dma_rx_param = (void *) U300_DMA_UART1_RX, .dma_tx_param = (void *) U300_DMA_UART1_TX, #endif }; /* Fast device at 0x7000 offset */ static AMBA_APB_DEVICE(uart1, "uart1", 0, U300_UART1_BASE, { IRQ_U300_UART1 }, &uart1_plat_data); #endif /* AHB device at 0x4000 offset */ static AMBA_APB_DEVICE(pl172, "pl172", 0, U300_EMIF_CFG_BASE, { }, NULL); /* Fast device at 0x6000 offset */ static AMBA_APB_DEVICE(pl022, "pl022", 0, U300_SPI_BASE, { IRQ_U300_SPI }, NULL); /* Fast device at 0x1000 offset */ #define U300_MMCSD_IRQS { <API key>, <API key> } static struct mmci_platform_data mmcsd_platform_data = { /* * Do not set ocr_mask or voltage translation function, * we have a regulator we can control instead. */ .f_max = 24000000, .gpio_wp = -1, .gpio_cd = <API key>, .cd_invert = true, .capabilities = <API key> | <API key> | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, #ifdef CONFIG_COH901318 .dma_filter = coh901318_filter_id, .dma_rx_param = (void *) <API key>, /* Don't specify a TX channel, this RX channel is bidirectional */ #endif }; static AMBA_APB_DEVICE(mmcsd, "mmci", 0, U300_MMCSD_BASE, U300_MMCSD_IRQS, &mmcsd_platform_data); /* * The order of device declaration may be important, since some devices * have dependencies on other devices being initialized first. */ static struct amba_device *amba_devs[] __initdata = { &uart0_device, #ifdef <API key> &uart1_device, #endif &pl022_device, &pl172_device, &mmcsd_device, }; /* Here follows a list of all hw resources that the platform devices * allocate. Note, clock dependencies are not included */ static struct resource gpio_resources[] = { { .start = U300_GPIO_BASE, .end = (U300_GPIO_BASE + SZ_4K - 1), .flags = IORESOURCE_MEM, }, { .name = "gpio0", .start = IRQ_U300_GPIO_PORT0, .end = IRQ_U300_GPIO_PORT0, .flags = IORESOURCE_IRQ, }, { .name = "gpio1", .start = IRQ_U300_GPIO_PORT1, .end = IRQ_U300_GPIO_PORT1, .flags = IORESOURCE_IRQ, }, { .name = "gpio2", .start = IRQ_U300_GPIO_PORT2, .end = IRQ_U300_GPIO_PORT2, .flags = IORESOURCE_IRQ, }, #if defined(<API key>) || defined(<API key>) { .name = "gpio3", .start = IRQ_U300_GPIO_PORT3, .end = IRQ_U300_GPIO_PORT3, .flags = IORESOURCE_IRQ, }, { .name = "gpio4", .start = IRQ_U300_GPIO_PORT4, .end = IRQ_U300_GPIO_PORT4, .flags = IORESOURCE_IRQ, }, #endif #ifdef <API key> { .name = "gpio5", .start = IRQ_U300_GPIO_PORT5, .end = IRQ_U300_GPIO_PORT5, .flags = IORESOURCE_IRQ, }, { .name = "gpio6", .start = IRQ_U300_GPIO_PORT6, .end = IRQ_U300_GPIO_PORT6, .flags = IORESOURCE_IRQ, }, #endif /* <API key> */ }; static struct resource keypad_resources[] = { { .start = U300_KEYPAD_BASE, .end = U300_KEYPAD_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .name = "coh901461-press", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, { .name = "coh901461-release", .start = <API key>, .end = <API key>, .flags = IORESOURCE_IRQ, }, }; static struct resource rtc_resources[] = { { .start = U300_RTC_BASE, .end = U300_RTC_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = IRQ_U300_RTC, .end = IRQ_U300_RTC, .flags = IORESOURCE_IRQ, }, }; /* * Fsmc does have IRQs: #43 and #44 (NFIF and NFIF2) * but these are not yet used by the driver. */ static struct resource fsmc_resources[] = { { .name = "nand_data", .start = <API key>, .end = <API key> + SZ_16K - 1, .flags = IORESOURCE_MEM, }, { .name = "fsmc_regs", .start = <API key>, .end = <API key> + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct resource i2c0_resources[] = { { .start = U300_I2C0_BASE, .end = U300_I2C0_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = IRQ_U300_I2C0, .end = IRQ_U300_I2C0, .flags = IORESOURCE_IRQ, }, }; static struct resource i2c1_resources[] = { { .start = U300_I2C1_BASE, .end = U300_I2C1_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = IRQ_U300_I2C1, .end = IRQ_U300_I2C1, .flags = IORESOURCE_IRQ, }, }; static struct resource wdog_resources[] = { { .start = U300_WDOG_BASE, .end = U300_WDOG_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = IRQ_U300_WDOG, .end = IRQ_U300_WDOG, .flags = IORESOURCE_IRQ, } }; static struct resource dma_resource[] = { { .start = U300_DMAC_BASE, .end = U300_DMAC_BASE + PAGE_SIZE - 1, .flags = IORESOURCE_MEM, }, { .start = IRQ_U300_DMA, .end = IRQ_U300_DMA, .flags = IORESOURCE_IRQ, } }; #ifdef <API key> /* points out all dma slave channels. * Syntax is [A1, B1, A2, B2, .... ,-1,-1] * Select all channels from A to B, end of list is marked with -1,-1 */ static int dma_slave_channels[] = { U300_DMA_MSL_TX_0, U300_DMA_SPI_RX, U300_DMA_UART1_TX, U300_DMA_UART1_RX, -1, -1}; /* points out all dma memcpy channels. */ static int dma_memcpy_channels[] = { <API key>, <API key>, -1, -1}; #else /* <API key> */ static int dma_slave_channels[] = {U300_DMA_MSL_TX_0, U300_DMA_SPI_RX, -1, -1}; static int dma_memcpy_channels[] = { <API key>, <API key>, -1, -1}; #endif /** register dma for memory access * * active 1 means dma intends to access memory * 0 means dma wont access memory */ static void <API key>(struct device *dev, bool active) { } #define flags_memcpy_config (<API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key>) #define <API key> (<API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key>) #define flags_memcpy_lli (<API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key>) #define <API key> (<API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key> | \ <API key>) const struct coh_dma_channel chan_config[U300_DMA_CHANNELS] = { { .number = U300_DMA_MSL_TX_0, .name = "MSL TX 0", .priority_high = 0, .dev_addr = U300_MSL_BASE + 0 * 0x40 + 0x20, }, { .number = U300_DMA_MSL_TX_1, .name = "MSL TX 1", .priority_high = 0, .dev_addr = U300_MSL_BASE + 1 * 0x40 + 0x20, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_TX_2, .name = "MSL TX 2", .priority_high = 0, .dev_addr = U300_MSL_BASE + 2 * 0x40 + 0x20, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .desc_nbr_max = 10, }, { .number = U300_DMA_MSL_TX_3, .name = "MSL TX 3", .priority_high = 0, .dev_addr = U300_MSL_BASE + 3 * 0x40 + 0x20, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_TX_4, .name = "MSL TX 4", .priority_high = 0, .dev_addr = U300_MSL_BASE + 4 * 0x40 + 0x20, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_TX_5, .name = "MSL TX 5", .priority_high = 0, .dev_addr = U300_MSL_BASE + 5 * 0x40 + 0x20, }, { .number = U300_DMA_MSL_TX_6, .name = "MSL TX 6", .priority_high = 0, .dev_addr = U300_MSL_BASE + 6 * 0x40 + 0x20, }, { .number = U300_DMA_MSL_RX_0, .name = "MSL RX 0", .priority_high = 0, .dev_addr = U300_MSL_BASE + 0 * 0x40 + 0x220, }, { .number = U300_DMA_MSL_RX_1, .name = "MSL RX 1", .priority_high = 0, .dev_addr = U300_MSL_BASE + 1 * 0x40 + 0x220, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_RX_2, .name = "MSL RX 2", .priority_high = 0, .dev_addr = U300_MSL_BASE + 2 * 0x40 + 0x220, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_RX_3, .name = "MSL RX 3", .priority_high = 0, .dev_addr = U300_MSL_BASE + 3 * 0x40 + 0x220, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_RX_4, .name = "MSL RX 4", .priority_high = 0, .dev_addr = U300_MSL_BASE + 4 * 0x40 + 0x220, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_RX_5, .name = "MSL RX 5", .priority_high = 0, .dev_addr = U300_MSL_BASE + 5 * 0x40 + 0x220, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSL_RX_6, .name = "MSL RX 6", .priority_high = 0, .dev_addr = U300_MSL_BASE + 6 * 0x40 + 0x220, }, /* * Don't set up device address, burst count or size of src * or dst bus for this peripheral - handled by PrimeCell * DMA extension. */ { .number = <API key>, .name = "MMCSD RX TX", .priority_high = 0, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_MSPRO_TX, .name = "MSPRO TX", .priority_high = 0, }, { .number = U300_DMA_MSPRO_RX, .name = "MSPRO RX", .priority_high = 0, }, /* * Don't set up device address, burst count or size of src * or dst bus for this peripheral - handled by PrimeCell * DMA extension. */ { .number = U300_DMA_UART0_TX, .name = "UART0 TX", .priority_high = 0, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_UART0_RX, .name = "UART0 RX", .priority_high = 0, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_APEX_TX, .name = "APEX TX", .priority_high = 0, }, { .number = U300_DMA_APEX_RX, .name = "APEX RX", .priority_high = 0, }, { .number = <API key>, .name = "PCM I2S0 TX", .priority_high = 1, .dev_addr = U300_PCM_I2S0_BASE + 0x14, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = <API key>, .name = "PCM I2S0 RX", .priority_high = 1, .dev_addr = U300_PCM_I2S0_BASE + 0x10, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = <API key>, .name = "PCM I2S1 TX", .priority_high = 1, .dev_addr = U300_PCM_I2S1_BASE + 0x14, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = <API key>, .name = "PCM I2S1 RX", .priority_high = 1, .dev_addr = U300_PCM_I2S1_BASE + 0x10, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_XGAM_CDI, .name = "XGAM CDI", .priority_high = 0, }, { .number = U300_DMA_XGAM_PDI, .name = "XGAM PDI", .priority_high = 0, }, /* * Don't set up device address, burst count or size of src * or dst bus for this peripheral - handled by PrimeCell * DMA extension. */ { .number = U300_DMA_SPI_TX, .name = "SPI TX", .priority_high = 0, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = U300_DMA_SPI_RX, .name = "SPI RX", .priority_high = 0, .param.config = <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_chained = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, .param.ctrl_lli_last = 0 | <API key> | <API key> | <API key> | <API key> | <API key> | <API key> | <API key>, }, { .number = <API key>, .name = "GENERAL 00", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 01", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 02", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 03", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 04", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 05", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 06", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 07", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 08", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, #ifdef <API key> { .number = U300_DMA_UART1_TX, .name = "UART1 TX", .priority_high = 0, }, { .number = U300_DMA_UART1_RX, .name = "UART1 RX", .priority_high = 0, } #else { .number = <API key>, .name = "GENERAL 09", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, }, { .number = <API key>, .name = "GENERAL 10", .priority_high = 0, .param.config = flags_memcpy_config, .param.ctrl_lli_chained = <API key>, .param.ctrl_lli = flags_memcpy_lli, .param.ctrl_lli_last = <API key>, } #endif }; static struct coh901318_platform coh901318_platform = { .chans_slave = dma_slave_channels, .chans_memcpy = dma_memcpy_channels, .access_memory_state = <API key>, .chan_conf = chan_config, .max_channels = U300_DMA_CHANNELS, }; static struct resource pinctrl_resources[] = { { .start = U300_SYSCON_BASE, .end = U300_SYSCON_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct platform_device wdog_device = { .name = "coh901327_wdog", .id = -1, .num_resources = ARRAY_SIZE(wdog_resources), .resource = wdog_resources, }; static struct platform_device i2c0_device = { .name = "stu300", .id = 0, .num_resources = ARRAY_SIZE(i2c0_resources), .resource = i2c0_resources, }; static struct platform_device i2c1_device = { .name = "stu300", .id = 1, .num_resources = ARRAY_SIZE(i2c1_resources), .resource = i2c1_resources, }; static struct platform_device pinctrl_device = { .name = "pinctrl-u300", .id = -1, .num_resources = ARRAY_SIZE(pinctrl_resources), .resource = pinctrl_resources, }; /* * The different variants have a few different versions of the * GPIO block, with different number of ports. */ static struct u300_gpio_platform u300_gpio_plat = { #if defined(<API key>) || defined(<API key>) .variant = U300_GPIO_COH901335, .ports = 3, #endif #ifdef <API key> .variant = <API key>, .ports = 7, #endif #ifdef <API key> .variant = <API key>, .ports = 5, #endif .gpio_base = 0, .gpio_irq_base = IRQ_U300_GPIO_BASE, .pinctrl_device = &pinctrl_device, }; static struct platform_device gpio_device = { .name = "u300-gpio", .id = -1, .num_resources = ARRAY_SIZE(gpio_resources), .resource = gpio_resources, .dev = { .platform_data = &u300_gpio_plat, }, }; static struct platform_device keypad_device = { .name = "keypad", .id = -1, .num_resources = ARRAY_SIZE(keypad_resources), .resource = keypad_resources, }; static struct platform_device rtc_device = { .name = "rtc-coh901331", .id = -1, .num_resources = ARRAY_SIZE(rtc_resources), .resource = rtc_resources, }; static struct mtd_partition u300_partitions[] = { { .name = "bootrecords", .offset = 0, .size = SZ_128K, }, { .name = "free", .offset = SZ_128K, .size = 8064 * SZ_1K, }, { .name = "platform", .offset = 8192 * SZ_1K, .size = 253952 * SZ_1K, }, }; static struct <API key> nand_platform_data = { .partitions = u300_partitions, .nr_partitions = ARRAY_SIZE(u300_partitions), .options = NAND_SKIP_BBTSCAN, .width = FSMC_NAND_BW8, }; static struct platform_device nand_device = { .name = "fsmc-nand", .id = -1, .resource = fsmc_resources, .num_resources = ARRAY_SIZE(fsmc_resources), .dev = { .platform_data = &nand_platform_data, }, }; static struct platform_device dma_device = { .name = "coh901318", .id = -1, .resource = dma_resource, .num_resources = ARRAY_SIZE(dma_resource), .dev = { .platform_data = &coh901318_platform, .coherent_dma_mask = ~0, }, }; static unsigned long pin_pullup_conf[] = { PIN_CONF_PACKED(<API key>, 1), }; static unsigned long pin_highz_conf[] = { PIN_CONF_PACKED(<API key>, 0), }; /* Pin control settings */ static struct pinctrl_map __initdata u300_pinmux_map[] = { /* anonymous maps for chip power and EMIFs */ <API key>("pinctrl-u300", NULL, "power"), <API key>("pinctrl-u300", NULL, "emif0"), <API key>("pinctrl-u300", NULL, "emif1"), /* per-device maps for MMC/SD, SPI and UART */ <API key>("mmci", "pinctrl-u300", NULL, "mmc0"), <API key>("pl022", "pinctrl-u300", NULL, "spi0"), <API key>("uart0", "pinctrl-u300", NULL, "uart0"), /* This pin is used for clock return rather than GPIO */ <API key>("mmci", "pinctrl-u300", "PIO APP GPIO 11", pin_pullup_conf), /* This pin is used for card detect */ <API key>("mmci", "pinctrl-u300", "PIO MS INS", pin_highz_conf), }; struct u300_mux_hog { struct device *dev; struct pinctrl *p; }; static struct u300_mux_hog u300_mux_hogs[] = { { .dev = &uart0_device.dev, }, { .dev = &pl022_device.dev, }, { .dev = &mmcsd_device.dev, }, }; static int __init u300_pinctrl_fetch(void) { int i; for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) { struct pinctrl *p; p = <API key>(u300_mux_hogs[i].dev); if (IS_ERR(p)) { pr_err("u300: could not get pinmux hog for dev %s\n", dev_name(u300_mux_hogs[i].dev)); continue; } u300_mux_hogs[i].p = p; } return 0; } subsys_initcall(u300_pinctrl_fetch); /* * Notice that AMBA devices are initialized before platform devices. * */ static struct platform_device *platform_devs[] __initdata = { &dma_device, &i2c0_device, &i2c1_device, &keypad_device, &rtc_device, &gpio_device, &nand_device, &wdog_device, }; /* * Interrupts: the U300 platforms have two pl190 ARM PrimeCells connected * together so some interrupts are connected to the first one and some * to the second one. */ void __init u300_init_irq(void) { u32 mask[2] = {0, 0}; struct clk *clk; int i; /* initialize clocking early, we want to clock the INTCON */ u300_clock_init(); /* Clock the interrupt controller */ clk = clk_get_sys("intcon", NULL); BUG_ON(IS_ERR(clk)); clk_enable(clk); for (i = 0; i < U300_VIC_IRQS_END; i++) set_bit(i, (unsigned long *) &mask[0]); vic_init((void __iomem *) U300_INTCON0_VBASE, 0, mask[0], mask[0]); vic_init((void __iomem *) U300_INTCON1_VBASE, 32, mask[1], mask[1]); } /* * U300 platforms peripheral handling */ struct db_chip { u16 chipid; const char *name; }; /* * This is a list of the Digital Baseband chips used in the U300 platform. */ static struct db_chip db_chips[] __initdata = { { .chipid = 0xb800, .name = "DB3000", }, { .chipid = 0xc000, .name = "DB3100", }, { .chipid = 0xc800, .name = "DB3150", }, { .chipid = 0xd800, .name = "DB3200", }, { .chipid = 0xe000, .name = "DB3250", }, { .chipid = 0xe800, .name = "DB3210", }, { .chipid = 0xf000, .name = "DB3350 P1x", }, { .chipid = 0xf100, .name = "DB3350 P2x", }, { .chipid = 0x0000, /* List terminator */ .name = NULL, } }; static void __init <API key>(void) { u16 val; struct db_chip *chip; const char *chipname; const char unknown[] = "UNKNOWN"; /* Read out and print chip ID */ val = readw(U300_SYSCON_VBASE + U300_SYSCON_CIDR); /* This is in funky bigendian order... */ val = (val & 0xFFU) << 8 | (val >> 8); chip = db_chips; chipname = unknown; for ( ; chip->chipid; chip++) { if (chip->chipid == (val & 0xFF00U)) { chipname = chip->name; break; } } printk(KERN_INFO "Initializing U300 system on %s baseband chip " \ "(chip ID 0x%04x)\n", chipname, val); #ifdef <API key> if ((val & 0xFF00U) != 0xd800) { printk(KERN_ERR "Platform configured for BS330 " \ "with DB3200 but %s detected, expect problems!", chipname); } #endif #ifdef <API key> if ((val & 0xFF00U) != 0xf000 && (val & 0xFF00U) != 0xf100) { printk(KERN_ERR "Platform configured for BS335 " \ " with DB3350 but %s detected, expect problems!", chipname); } #endif #ifdef <API key> if ((val & 0xFF00U) != 0xe800) { printk(KERN_ERR "Platform configured for BS365 " \ "with DB3210 but %s detected, expect problems!", chipname); } #endif } /* * Some devices and their resources require reserved physical memory from * the end of the available RAM. This function traverses the list of devices * and assigns actual addresses to these. */ static void __init u300_assign_physmem(void) { unsigned long curr_start = __pa(high_memory); int i, j; for (i = 0; i < ARRAY_SIZE(platform_devs); i++) { for (j = 0; j < platform_devs[i]->num_resources; j++) { struct resource *const res = &platform_devs[i]->resource[j]; if (IORESOURCE_MEM == res->flags && 0 == res->start) { res->start = curr_start; res->end += curr_start; curr_start += resource_size(res); printk(KERN_INFO "core.c: Mapping RAM " \ "%#x-%#x to device %s:%s\n", res->start, res->end, platform_devs[i]->name, res->name); } } } } void __init u300_init_devices(void) { int i; u16 val; /* Check what platform we run and print some status information */ <API key>(); /* Set system to run at PLL208, max performance, a known state. */ val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR); val &= ~<API key>; writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR); /* Wait for the PLL208 to lock if not locked in yet */ while (!(readw(U300_SYSCON_VBASE + U300_SYSCON_CSR) & <API key>)); /* Initialize SPI device with some board specifics */ u300_spi_init(&pl022_device); /* Register the AMBA devices in the AMBA bus abstraction layer */ for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; <API key>(d, &iomem_resource); } u300_assign_physmem(); /* Initialize pinmuxing */ <API key>(u300_pinmux_map, ARRAY_SIZE(u300_pinmux_map)); /* Register subdevices on the I2C buses */ <API key>(); /* Register the platform devices */ <API key>(platform_devs, ARRAY_SIZE(platform_devs)); /* Register subdevices on the SPI bus */ <API key>(); /* Enable SEMI self refresh */ val = readw(U300_SYSCON_VBASE + U300_SYSCON_SMCR) | <API key>; writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR); } /* Forward declare this function from the watchdog */ void <API key>(void); void u300_restart(char mode, const char *cmd) { switch (mode) { case 's': case 'h': #ifdef <API key> <API key>(); #endif break; default: /* Do nothing */ break; } /* Wait for system do die/reset. */ while (1); }
#include <linux/config.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/init.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/jiffies.h> #include <asm/ebus.h> #include <asm/sbus.h> /* for sanity check... */ #include <asm/swift.h> /* for cache flushing. */ #include <asm/io.h> #include <linux/ctype.h> #include <linux/pci.h> #include <linux/time.h> #include <linux/timex.h> #include <linux/interrupt.h> #include <asm/irq.h> #include <asm/oplib.h> #include <asm/pcic.h> #include <asm/timer.h> #include <asm/uaccess.h> unsigned int pcic_pin_to_irq(unsigned int pin, char *name); /* * I studied different documents and many live PROMs both from 2.30 * family and 3.xx versions. I came to the amazing conclusion: there is * absolutely no way to route interrupts in IIep systems relying on * information which PROM presents. We must hardcode interrupt routing * schematics. And this actually sucks. -- zaitcev 1999/05/12 * * To find irq for a device we determine which routing map * is in effect or, in other words, on which machine we are running. * We use PROM name for this although other techniques may be used * in special cases (Gleb reports a PROMless IIep based system). * Once we know the map we take device configuration address and * find PCIC pin number where INT line goes. Then we may either program * preferred irq into the PCIC or supply the preexisting irq to the device. */ struct pcic_ca2irq { unsigned char busno; /* PCI bus number */ unsigned char devfn; /* Configuration address */ unsigned char pin; /* PCIC external interrupt pin */ unsigned char irq; /* Preferred IRQ (mappable in PCIC) */ unsigned int force; /* Enforce preferred IRQ */ }; struct pcic_sn2list { char *sysname; struct pcic_ca2irq *intmap; int mapdim; }; /* * JavaEngine-1 apparently has different versions. * * According to communications with Sun folks, for P2 build 501-4628-03: * pin 0 - parallel, audio; * pin 1 - Ethernet; * pin 2 - su; * pin 3 - PS/2 kbd and mouse. * * OEM manual (805-1486): * pin 0: Ethernet * pin 1: All EBus * pin 2: IGA (unused) * pin 3: Not connected * OEM manual says that 501-4628 & 501-4811 are the same thing, * only the latter has NAND flash in place. * * So far unofficial Sun wins over the OEM manual. Poor OEMs... */ static struct pcic_ca2irq pcic_i_je1a[] = { /* 501-4811-03 */ { 0, 0x00, 2, 12, 0 }, /* EBus: hogs all */ { 0, 0x01, 1, 6, 1 }, /* Happy Meal */ { 0, 0x80, 0, 7, 0 }, /* IGA (unused) */ }; /* XXX JS-E entry is incomplete - PCI Slot 2 address (pin 7)? */ static struct pcic_ca2irq pcic_i_jse[] = { { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */ { 0, 0x01, 1, 6, 0 }, /* hme */ { 0, 0x08, 2, 9, 0 }, /* VGA - we hope not used :) */ { 0, 0x10, 6, 8, 0 }, /* PCI INTA# in Slot 1 */ { 0, 0x18, 7, 12, 0 }, /* PCI INTA# in Slot 2, shared w. RTC */ { 0, 0x38, 4, 9, 0 }, /* All ISA devices. Read 8259. */ { 0, 0x80, 5, 11, 0 }, /* EIDE */ /* {0,0x88, 0,0,0} - unknown device... PMU? Probably no interrupt. */ { 0, 0xA0, 4, 9, 0 }, /* USB */ /* * Some pins belong to non-PCI devices, we hardcode them in drivers. * sun4m timers - irq 10, 14 * PC style RTC - pin 7, irq 4 ? * Smart card, Parallel - pin 4 shared with USB, ISA * audio - pin 3, irq 5 ? */ }; /* SPARCengine-6 was the original release name of CP1200. * The documentation differs between the two versions */ static struct pcic_ca2irq pcic_i_se6[] = { { 0, 0x08, 0, 2, 0 }, /* SCSI */ { 0, 0x01, 1, 6, 0 }, /* HME */ { 0, 0x00, 3, 13, 0 }, /* EBus */ }; /* * Krups (courtesy of Varol Kaptan) * No documentation available, but it was easy to guess * because it was very similar to Espresso. * * pin 0 - kbd, mouse, serial; * pin 1 - Ethernet; * pin 2 - igs (we do not use it); * pin 3 - audio; * pin 4,5,6 - unused; * pin 7 - RTC (from P2 onwards as David B. says). */ static struct pcic_ca2irq pcic_i_jk[] = { { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */ { 0, 0x01, 1, 6, 0 }, /* hme */ }; /* * Several entries in this list may point to the same routing map * as several PROMs may be installed on the same physical board. */ #define SN2L_INIT(name, map) \ { name, map, ARRAY_SIZE(map) } static struct pcic_sn2list pcic_known_sysnames[] = { SN2L_INIT("SUNW,JavaEngine1", pcic_i_je1a), /* JE1, PROM 2.32 */ SN2L_INIT("SUNW,JS-E", pcic_i_jse), /* PROLL JavaStation-E */ SN2L_INIT("SUNW,SPARCengine-6", pcic_i_se6), /* SPARCengine-6/CP-1200 */ SN2L_INIT("SUNW,JS-NC", pcic_i_jk), /* PROLL JavaStation-NC */ SN2L_INIT("SUNW,JSIIep", pcic_i_jk), /* OBP JavaStation-NC */ { NULL, NULL, 0 } }; /* * Only one PCIC per IIep, * and since we have no SMP IIep, only one per system. */ static int pcic0_up; static struct linux_pcic pcic0; void __iomem *pcic_regs; volatile int pcic_speculative; volatile int pcic_trapped; static void pci_do_gettimeofday(struct timeval *tv); static int pci_do_settimeofday(struct timespec *tv); #define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (((unsigned int)bus) << 16) | (((unsigned int)device_fn) << 8) | (where & ~3)) static int <API key>(unsigned int busno, unsigned int devfn, int where, u32 *value) { struct linux_pcic *pcic; unsigned long flags; pcic = &pcic0; local_irq_save(flags); #if 0 /* does not fail here */ pcic_speculative = 1; pcic_trapped = 0; #endif writel(CONFIG_CMD(busno, devfn, where), pcic-><API key>); #if 0 /* does not fail here */ nop(); if (pcic_trapped) { local_irq_restore(flags); *value = ~0; return 0; } #endif pcic_speculative = 2; pcic_trapped = 0; *value = readl(pcic-><API key> + (where&4)); nop(); if (pcic_trapped) { pcic_speculative = 0; local_irq_restore(flags); *value = ~0; return 0; } pcic_speculative = 0; local_irq_restore(flags); return 0; } static int pcic_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { unsigned int v; if (bus->number != 0) return -EINVAL; switch (size) { case 1: <API key>(bus->number, devfn, where&~3, &v); *val = 0xff & (v >> (8*(where & 3))); return 0; case 2: if (where&1) return -EINVAL; <API key>(bus->number, devfn, where&~3, &v); *val = 0xffff & (v >> (8*(where & 3))); return 0; case 4: if (where&3) return -EINVAL; <API key>(bus->number, devfn, where&~3, val); return 0; } return -EINVAL; } static int <API key>(unsigned int busno, unsigned int devfn, int where, u32 value) { struct linux_pcic *pcic; unsigned long flags; pcic = &pcic0; local_irq_save(flags); writel(CONFIG_CMD(busno, devfn, where), pcic-><API key>); writel(value, pcic-><API key> + (where&4)); local_irq_restore(flags); return 0; } static int pcic_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { unsigned int v; if (bus->number != 0) return -EINVAL; switch (size) { case 1: <API key>(bus->number, devfn, where&~3, &v); v = (v & ~(0xff << (8*(where&3)))) | ((0xff&val) << (8*(where&3))); return <API key>(bus->number, devfn, where&~3, v); case 2: if (where&1) return -EINVAL; <API key>(bus->number, devfn, where&~3, &v); v = (v & ~(0xffff << (8*(where&3)))) | ((0xffff&val) << (8*(where&3))); return <API key>(bus->number, devfn, where&~3, v); case 4: if (where&3) return -EINVAL; return <API key>(bus->number, devfn, where, val); } return -EINVAL; } static struct pci_ops pcic_ops = { .read = pcic_read_config, .write = pcic_write_config, }; /* * On sparc64 pcibios_init() calls <API key>(). * We want PCIC probed little ahead so that interrupt controller * would be operational. */ int __init pcic_probe(void) { struct linux_pcic *pcic; struct <API key> regs[PROMREG_MAX]; struct linux_pbm_info* pbm; char namebuf[64]; int node; int err; if (pcic0_up) { prom_printf("PCIC: called twice!\n"); prom_halt(); } pcic = &pcic0; node = prom_getchild (prom_root_node); node = prom_searchsiblings (node, "pci"); if (node == 0) return -ENODEV; /* * Map in PCIC register set, config space, and IO base */ err = prom_getproperty(node, "reg", (char*)regs, sizeof(regs)); if (err == 0 || err == -1) { prom_printf("PCIC: Error, cannot get PCIC registers " "from PROM.\n"); prom_halt(); } pcic0_up = 1; pcic->pcic_res_regs.name = "pcic_registers"; pcic->pcic_regs = ioremap(regs[0].phys_addr, regs[0].reg_size); if (!pcic->pcic_regs) { prom_printf("PCIC: Error, cannot map PCIC registers.\n"); prom_halt(); } pcic->pcic_res_io.name = "pcic_io"; if ((pcic->pcic_io = (unsigned long) ioremap(regs[1].phys_addr, 0x10000)) == 0) { prom_printf("PCIC: Error, cannot map PCIC IO Base.\n"); prom_halt(); } pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr"; if ((pcic-><API key> = ioremap(regs[2].phys_addr, regs[2].reg_size * 2)) == 0) { prom_printf("PCIC: Error, cannot map" "PCI Configuration Space Address.\n"); prom_halt(); } /* * Docs say three least significant bits in address and data * must be the same. Thus, we need adjust size of data. */ pcic->pcic_res_cfg_data.name = "pcic_cfg_data"; if ((pcic-><API key> = ioremap(regs[3].phys_addr, regs[3].reg_size * 2)) == 0) { prom_printf("PCIC: Error, cannot map" "PCI Configuration Space Data.\n"); prom_halt(); } pbm = &pcic->pbm; pbm->prom_node = node; prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0; strcpy(pbm->prom_name, namebuf); { extern volatile int t_nmi[1]; extern int pcic_nmi_trap_patch[1]; t_nmi[0] = pcic_nmi_trap_patch[0]; t_nmi[1] = pcic_nmi_trap_patch[1]; t_nmi[2] = pcic_nmi_trap_patch[2]; t_nmi[3] = pcic_nmi_trap_patch[3]; swift_flush_dcache(); pcic_regs = pcic->pcic_regs; } prom_getstring(prom_root_node, "name", namebuf, 63); namebuf[63] = 0; { struct pcic_sn2list *p; for (p = pcic_known_sysnames; p->sysname != NULL; p++) { if (strcmp(namebuf, p->sysname) == 0) break; } pcic->pcic_imap = p->intmap; pcic->pcic_imdim = p->mapdim; } if (pcic->pcic_imap == NULL) { /* * We do not panic here for the sake of embedded systems. */ printk("PCIC: System %s is unknown, cannot route interrupts\n", namebuf); } return 0; } static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) { struct linux_pbm_info *pbm = &pcic->pbm; pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm); #if 0 /* deadwood transplanted from sparc64 */ <API key>(pbm->pci_bus, pbm, pbm->prom_node); <API key>(pbm, pbm->pci_bus); <API key>(pbm, pbm->pci_bus); pci_fixup_irq(pbm, pbm->pci_bus); #endif } /* * Main entry point from the PCI subsystem. */ static int __init pcic_init(void) { struct linux_pcic *pcic; /* * PCIC should be initialized at start of the timer. * So, here we report the presence of PCIC and do some magic passes. */ if(!pcic0_up) return 0; pcic = &pcic0; /* * Switch off IOTLB translation. */ writeb(<API key>, pcic->pcic_regs+PCI_DVMA_CONTROL); /* * Increase mapped size for PCI memory space (DMA access). * Should be done in that order (size first, address second). * Why we couldn't set up 4GB and forget about it? XXX */ writel(0xF0000000UL, pcic->pcic_regs+PCI_SIZE_0); writel(0+<API key>, pcic->pcic_regs+PCI_BASE_ADDRESS_0); pcic_pbm_scan_bus(pcic); ebus_init(); return 0; } int pcic_present(void) { return pcic0_up; } static int __init pdev_to_pnode(struct linux_pbm_info *pbm, struct pci_dev *pdev) { struct <API key> regs[PROMREG_MAX]; int err; int node = prom_getchild(pbm->prom_node); while(node) { err = prom_getproperty(node, "reg", (char *)&regs[0], sizeof(regs)); if(err != 0 && err != -1) { unsigned long devfn = (regs[0].which_io >> 8) & 0xff; if(devfn == pdev->devfn) return node; } node = prom_getsibling(node); } return 0; } static inline struct pcidev_cookie *pci_devcookie_alloc(void) { return kmalloc(sizeof(struct pcidev_cookie), GFP_ATOMIC); } static void pcic_map_pci_device(struct linux_pcic *pcic, struct pci_dev *dev, int node) { char namebuf[64]; unsigned long address; unsigned long flags; int j; if (node == 0 || node == -1) { strcpy(namebuf, "???"); } else { prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0; } for (j = 0; j < 6; j++) { address = dev->resource[j].start; if (address == 0) break; /* are sequential */ flags = dev->resource[j].flags; if ((flags & IORESOURCE_IO) != 0) { if (address < 0x10000) { /* * A device responds to I/O cycles on PCI. * We generate these cycles with memory * access into the fixed map (phys 0x30000000). * * Since a device driver does not want to * do ioremap() before accessing PC-style I/O, * we supply virtual, ready to access address. * * Ebus devices do not come here even if * CheerIO makes a similar conversion. * See ebus.c for details. * * Note that request_region() * works for these devices. * * XXX Neat trick, but it's a *bad* idea * to shit into regions like that. * What if we want to allocate one more * PCI base address... */ dev->resource[j].start = pcic->pcic_io + address; dev->resource[j].end = 1; /* XXX */ dev->resource[j].flags = (flags & ~IORESOURCE_IO) | IORESOURCE_MEM; } else { /* * OOPS... PCI Spec allows this. Sun does * not have any devices getting above 64K * so it must be user with a weird I/O * board in a PCI slot. We must remap it * under 64K but it is not done yet. XXX */ printk("PCIC: Skipping I/O space at 0x%lx," "this will Oops if a driver attaches;" "device '%s' at %02x:%02x)\n", address, namebuf, dev->bus->number, dev->devfn); } } } } static void pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node) { struct pcic_ca2irq *p; int i, ivec; char namebuf[64]; if (node == 0 || node == -1) { strcpy(namebuf, "???"); } else { prom_getstring(node, "name", namebuf, sizeof(namebuf)); } if ((p = pcic->pcic_imap) == 0) { dev->irq = 0; return; } for (i = 0; i < pcic->pcic_imdim; i++) { if (p->busno == dev->bus->number && p->devfn == dev->devfn) break; p++; } if (i >= pcic->pcic_imdim) { printk("PCIC: device %s devfn %02x:%02x not found in %d\n", namebuf, dev->bus->number, dev->devfn, pcic->pcic_imdim); dev->irq = 0; return; } i = p->pin; if (i >= 0 && i < 4) { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); dev->irq = ivec >> (i << 2) & 0xF; } else if (i >= 4 && i < 8) { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); dev->irq = ivec >> ((i-4) << 2) & 0xF; } else { /* Corrupted map */ printk("PCIC: BAD PIN %d\n", i); for (;;) {} } /* * dev->irq=0 means PROM did not bother to program the upper * half of PCIC. This happens on JS-E with PROM 3.11, for instance. */ if (dev->irq == 0 || p->force) { if (p->irq == 0 || p->irq >= 15) { /* Corrupted map */ printk("PCIC: BAD IRQ %d\n", p->irq); for (;;) {} } printk("PCIC: setting irq %d at pin %d for device %02x:%02x\n", p->irq, p->pin, dev->bus->number, dev->devfn); dev->irq = p->irq; i = p->pin; if (i >= 4) { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); ivec &= ~(0xF << ((i - 4) << 2)); ivec |= p->irq << ((i - 4) << 2); writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_HI); } else { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); ivec &= ~(0xF << (i << 2)); ivec |= p->irq << (i << 2); writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_LO); } } return; } /* * Normally called from {do_}pci_scan_bus... */ void __init pcibios_fixup_bus(struct pci_bus *bus) { struct pci_dev *dev; int i, has_io, has_mem; unsigned int cmd; struct linux_pcic *pcic; /* struct linux_pbm_info* pbm = &pcic->pbm; */ int node; struct pcidev_cookie *pcp; if (!pcic0_up) { printk("pcibios_fixup_bus: no PCIC\n"); return; } pcic = &pcic0; /* * Next crud is an equivalent of pbm = pcic_bus_to_pbm(bus); */ if (bus->number != 0) { printk("pcibios_fixup_bus: nonzero bus 0x%x\n", bus->number); return; } list_for_each_entry(dev, &bus->devices, bus_list) { /* * Comment from i386 branch: * There are buggy BIOSes that forget to enable I/O and memory * access to PCI devices. We try to fix this, but we need to * be sure that the BIOS didn't forget to assign an address * to the device. [mj] * OBP is a case of such BIOS :-) */ has_io = has_mem = 0; for(i=0; i<6; i++) { unsigned long f = dev->resource[i].flags; if (f & IORESOURCE_IO) { has_io = 1; } else if (f & IORESOURCE_MEM) has_mem = 1; } pcic_read_config(dev->bus, dev->devfn, PCI_COMMAND, 2, &cmd); if (has_io && !(cmd & PCI_COMMAND_IO)) { printk("PCIC: Enabling I/O for device %02x:%02x\n", dev->bus->number, dev->devfn); cmd |= PCI_COMMAND_IO; pcic_write_config(dev->bus, dev->devfn, PCI_COMMAND, 2, cmd); } if (has_mem && !(cmd & PCI_COMMAND_MEMORY)) { printk("PCIC: Enabling memory for device %02x:%02x\n", dev->bus->number, dev->devfn); cmd |= PCI_COMMAND_MEMORY; pcic_write_config(dev->bus, dev->devfn, PCI_COMMAND, 2, cmd); } node = pdev_to_pnode(&pcic->pbm, dev); if(node == 0) node = -1; /* cookies */ pcp = pci_devcookie_alloc(); pcp->pbm = &pcic->pbm; pcp->prom_node = node; dev->sysdata = pcp; /* fixing I/O to look like memory */ if ((dev->class>>16) != <API key>) pcic_map_pci_device(pcic, dev, node); pcic_fill_irq(pcic, dev, node); } } /* * pcic_pin_to_irq() is exported to ebus.c. */ unsigned int pcic_pin_to_irq(unsigned int pin, char *name) { struct linux_pcic *pcic = &pcic0; unsigned int irq; unsigned int ivec; if (pin < 4) { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); irq = ivec >> (pin << 2) & 0xF; } else if (pin < 8) { ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); irq = ivec >> ((pin-4) << 2) & 0xF; } else { /* Corrupted map */ printk("PCIC: BAD PIN %d FOR %s\n", pin, name); for (;;) {} /* XXX Cannot panic properly in case of PROLL */ } return irq; } /* Makes compiler happy */ static volatile int pcic_timer_dummy; static void <API key>(void) { pcic_timer_dummy = readl(pcic0.pcic_regs+PCI_SYS_LIMIT); } static irqreturn_t pcic_timer_handler (int irq, void *h, struct pt_regs *regs) { write_seqlock(&xtime_lock); /* Dummy, to show that we remember */ <API key>(); do_timer(regs); #ifndef CONFIG_SMP <API key>(user_mode(regs)); #endif write_sequnlock(&xtime_lock); return IRQ_HANDLED; } #define USECS_PER_JIFFY 10000 /* We have 100HZ "standard" timer for sparc */ #define TICK_TIMER_LIMIT ((100*1000000/4)/100) void __init pci_time_init(void) { struct linux_pcic *pcic = &pcic0; unsigned long v; int timer_irq, irq; /* A hack until do_gettimeofday prototype is moved to arch specific headers and btfixupped. Patch do_gettimeofday with ba pci_do_gettimeofday; nop */ ((unsigned int *)do_gettimeofday)[0] = 0x10800000 | ((((unsigned long)pci_do_gettimeofday - (unsigned long)do_gettimeofday) >> 2) & 0x003fffff); ((unsigned int *)do_gettimeofday)[1] = 0x01000000; BTFIXUPSET_CALL(bus_do_settimeofday, pci_do_settimeofday, BTFIXUPCALL_NORM); btfixup(); writel (TICK_TIMER_LIMIT, pcic->pcic_regs+PCI_SYS_LIMIT); /* PROM should set appropriate irq */ v = readb(pcic->pcic_regs+PCI_COUNTER_IRQ); timer_irq = PCI_COUNTER_IRQ_SYS(v); writel (PCI_COUNTER_IRQ_SET(timer_irq, 0), pcic->pcic_regs+PCI_COUNTER_IRQ); irq = request_irq(timer_irq, pcic_timer_handler, (SA_INTERRUPT | SA_STATIC_ALLOC), "timer", NULL); if (irq) { prom_printf("time_init: unable to attach IRQ%d\n", timer_irq); prom_halt(); } local_irq_enable(); } static __inline__ unsigned long do_gettimeoffset(void) { /* * We devide all to 100 * to have microsecond resolution and to avoid overflow */ unsigned long count = readl(pcic0.pcic_regs+PCI_SYS_COUNTER) & ~<API key>; count = ((count/100)*USECS_PER_JIFFY) / (TICK_TIMER_LIMIT/100); return count; } extern unsigned long wall_jiffies; static void pci_do_gettimeofday(struct timeval *tv) { unsigned long flags; unsigned long seq; unsigned long usec, sec; unsigned long max_ntp_tick = tick_usec - tickadj; do { unsigned long lost; seq = <API key>(&xtime_lock, flags); usec = do_gettimeoffset(); lost = jiffies - wall_jiffies; /* * If time_adjust is negative then NTP is slowing the clock * so make sure not to go into next possible interval. * Better to lose some accuracy than have time go backwards.. */ if (unlikely(time_adjust < 0)) { usec = min(usec, max_ntp_tick); if (lost) usec += lost * max_ntp_tick; } else if (unlikely(lost)) usec += lost * tick_usec; sec = xtime.tv_sec; usec += (xtime.tv_nsec / 1000); } while (<API key>(&xtime_lock, seq, flags)); while (usec >= 1000000) { usec -= 1000000; sec++; } tv->tv_sec = sec; tv->tv_usec = usec; } static int pci_do_settimeofday(struct timespec *tv) { if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) return -EINVAL; /* * This is revolting. We need to set "xtime" correctly. However, the * value in this location is the value at the most recent update of * wall time. Discover what correction gettimeofday() would have * made, and then undo it! */ tv->tv_nsec -= 1000 * (do_gettimeoffset() + (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ)); while (tv->tv_nsec < 0) { tv->tv_nsec += NSEC_PER_SEC; tv->tv_sec } wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec; wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_nsec; if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) { wall_to_monotonic.tv_nsec -= NSEC_PER_SEC; wall_to_monotonic.tv_sec++; } if (wall_to_monotonic.tv_nsec < 0) { wall_to_monotonic.tv_nsec += NSEC_PER_SEC; wall_to_monotonic.tv_sec } xtime.tv_sec = tv->tv_sec; xtime.tv_nsec = tv->tv_nsec; ntp_clear(); return 0; } #if 0 static void watchdog_reset() { writeb(0, pcic->pcic_regs+PCI_SYS_STATUS); } #endif /* * Other archs parse arguments here. */ char * __init pcibios_setup(char *str) { return str; } void <API key>(void *data, struct resource *res, unsigned long size, unsigned long align) { } int <API key>(struct pci_dev *pdev, int mask) { return 0; } /* * NMI */ void pcic_nmi(unsigned int pend, struct pt_regs *regs) { pend = flip_dword(pend); if (!pcic_speculative || (pend & <API key>) == 0) { /* * XXX On CP-1200 PCI #SERR may happen, we do not know * what to do about it yet. */ printk("Aiee, NMI pend 0x%x pc 0x%x spec %d, hanging\n", pend, (int)regs->pc, pcic_speculative); for (;;) { } } pcic_speculative = 0; pcic_trapped = 1; regs->pc = regs->npc; regs->npc += 4; } static inline unsigned long get_irqmask(int irq_nr) { return 1 << irq_nr; } static inline char *pcic_irq_itoa(unsigned int irq) { static char buff[16]; sprintf(buff, "%d", irq); return buff; } static void pcic_disable_irq(unsigned int irq_nr) { unsigned long mask, flags; mask = get_irqmask(irq_nr); local_irq_save(flags); writel(mask, pcic0.pcic_regs+<API key>); local_irq_restore(flags); } static void pcic_enable_irq(unsigned int irq_nr) { unsigned long mask, flags; mask = get_irqmask(irq_nr); local_irq_save(flags); writel(mask, pcic0.pcic_regs+<API key>); local_irq_restore(flags); } static void <API key>(int cpu) { printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__); } static void <API key>(int cpu, unsigned int limit) { printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__); } /* We assume the caller has disabled local interrupts when these are called, * or else very bizarre behavior will result. */ static void <API key>(unsigned int pil) { writel(get_irqmask(pil), pcic0.pcic_regs+<API key>); } static void pcic_enable_pil_irq(unsigned int pil) { writel(get_irqmask(pil), pcic0.pcic_regs+<API key>); } void __init sun4m_pci_init_IRQ(void) { BTFIXUPSET_CALL(enable_irq, pcic_enable_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(disable_irq, pcic_disable_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(enable_pil_irq, pcic_enable_pil_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(disable_pil_irq, <API key>, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_clock_irq, <API key>, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_profile_irq, <API key>, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(load_profile_irq, <API key>, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(__irq_itoa, pcic_irq_itoa, BTFIXUPCALL_NORM); } int <API key>(struct pci_dev *pdev, int resource) { return -ENXIO; } /* * This probably belongs here rather than ioport.c because * we do not want this crud linked into SBus kernels. * Also, think for a moment about likes of floppy.c that * include architecture specific parts. They may want to redefine ins/outs. * * We do not use horroble macroses here because we want to * advance pointer by sizeof(size). */ void outsb(unsigned long addr, const void *src, unsigned long count) { while (count) { count -= 1; outb(*(const char *)src, addr); src += 1; /* addr += 1; */ } } void outsw(unsigned long addr, const void *src, unsigned long count) { while (count) { count -= 2; outw(*(const short *)src, addr); src += 2; /* addr += 2; */ } } void outsl(unsigned long addr, const void *src, unsigned long count) { while (count) { count -= 4; outl(*(const long *)src, addr); src += 4; /* addr += 4; */ } } void insb(unsigned long addr, void *dst, unsigned long count) { while (count) { count -= 1; *(unsigned char *)dst = inb(addr); dst += 1; /* addr += 1; */ } } void insw(unsigned long addr, void *dst, unsigned long count) { while (count) { count -= 2; *(unsigned short *)dst = inw(addr); dst += 2; /* addr += 2; */ } } void insl(unsigned long addr, void *dst, unsigned long count) { while (count) { count -= 4; /* * XXX I am sure we are in for an unaligned trap here. */ *(unsigned long *)dst = inl(addr); dst += 4; /* addr += 4; */ } } subsys_initcall(pcic_init);
var path = require("path"); module.exports = { entry: "./public/App.js", output: { filename: "bundle.js", path: path.resolve(__dirname, "public") } };
#ifdef HAVE_CONFIG_H #include <config.h> #endif #include <assert.h> #include <math.h> #include <string.h> #include "intl.h" #include "object.h" #include "orth_conn.h" #include "diarenderer.h" #include "attributes.h" #include "arrows.h" #include "properties.h" #include "stereotype.h" #include "uml.h" #include "pixmaps/realizes.xpm" typedef struct _Realizes Realizes; struct _Realizes { OrthConn orth; Point text_pos; Alignment text_align; real text_width; Color text_color; Color line_color; char *name; char *stereotype; /* excluding << and >> */ char *st_stereotype; /* including << and >> */ }; #define REALIZES_WIDTH 0.1 #define <API key> 0.8 #define REALIZES_DASHLEN 0.4 #define REALIZES_FONTHEIGHT 0.8 static DiaFont *realize_font = NULL; static real <API key>(Realizes *realize, Point *point); static void realizes_select(Realizes *realize, Point *clicked_point, DiaRenderer *<API key>); static ObjectChange* <API key>(Realizes *realize, Handle *handle, Point *to, ConnectionPoint *cp, HandleMoveReason reason, ModifierKeys modifiers); static ObjectChange* realizes_move(Realizes *realize, Point *to); static void realizes_draw(Realizes *realize, DiaRenderer *renderer); static DiaObject *realizes_create(Point *startpoint, void *user_data, Handle **handle1, Handle **handle2); static void realizes_destroy(Realizes *realize); static DiaMenu *<API key>(Realizes *realize, Point *clickedpoint); static PropDescription *<API key>(Realizes *realizes); static void realizes_get_props(Realizes * realizes, GPtrArray *props); static void realizes_set_props(Realizes * realizes, GPtrArray *props); static DiaObject *realizes_load(ObjectNode obj_node, int version, const char *filename); static void <API key>(Realizes *realize); static ObjectTypeOps realizes_type_ops = { (CreateFunc) realizes_create, (LoadFunc) realizes_load,/*using_properties*/ /* load */ (SaveFunc) <API key>, /* save */ (GetDefaultsFunc) NULL, (ApplyDefaultsFunc) NULL }; DiaObjectType realizes_type = { "UML - Realizes", /* name */ /* Version 0 had no autorouting and so shouldn't have it set by default. */ 1, /* version */ (char **) realizes_xpm, /* pixmap */ &realizes_type_ops, /* ops */ NULL, /* pixmap_file */ 0 /* default_user_data */ }; static ObjectOps realizes_ops = { (DestroyFunc) realizes_destroy, (DrawFunc) realizes_draw, (DistanceFunc) <API key>, (SelectFunc) realizes_select, (CopyFunc) <API key>, (MoveFunc) realizes_move, (MoveHandleFunc) <API key>, (GetPropertiesFunc) <API key>, (<API key>) <API key>, (ObjectMenuFunc) <API key>, (DescribePropsFunc) <API key>, (GetPropsFunc) realizes_get_props, (SetPropsFunc) realizes_set_props, (TextEditFunc) 0, (<API key>) object_apply_props, }; static PropDescription realizes_props[] = { <API key>, <API key>, /* can't use <API key> cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */ <API key>(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL), { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Name:"), NULL, NULL }, { "stereotype", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Stereotype:"), NULL, NULL }, PROP_DESC_END }; static PropDescription * <API key>(Realizes *realizes) { if (realizes_props[0].quark == 0) { <API key>(realizes_props); } return realizes_props; } static PropOffset realizes_offsets[] = { <API key>, { "line_colour", PROP_TYPE_COLOUR, offsetof(Realizes, line_color) }, { "text_colour", PROP_TYPE_COLOUR, offsetof(Realizes, text_color) }, { "name", PROP_TYPE_STRING, offsetof(Realizes, name) }, { "stereotype", PROP_TYPE_STRING, offsetof(Realizes, stereotype) }, { NULL, 0, 0 } }; static void realizes_get_props(Realizes * realizes, GPtrArray *props) { <API key>(&realizes->orth.object, realizes_offsets,props); } static void realizes_set_props(Realizes *realizes, GPtrArray *props) { <API key>(&realizes->orth.object, realizes_offsets, props); g_free(realizes->st_stereotype); realizes->st_stereotype = NULL; <API key>(realizes); } static real <API key>(Realizes *realize, Point *point) { OrthConn *orth = &realize->orth; return <API key>(orth, point, REALIZES_WIDTH); } static void realizes_select(Realizes *realize, Point *clicked_point, DiaRenderer *<API key>) { <API key>(&realize->orth); } static ObjectChange* <API key>(Realizes *realize, Handle *handle, Point *to, ConnectionPoint *cp, HandleMoveReason reason, ModifierKeys modifiers) { ObjectChange *change; assert(realize!=NULL); assert(handle!=NULL); assert(to!=NULL); change = <API key>(&realize->orth, handle, to, cp, reason, modifiers); <API key>(realize); return change; } static ObjectChange* realizes_move(Realizes *realize, Point *to) { orthconn_move(&realize->orth, to); <API key>(realize); return NULL; } static void realizes_draw(Realizes *realize, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = <API key> (renderer); OrthConn *orth = &realize->orth; Point *points; int n; Point pos; Arrow arrow; points = &orth->points[0]; n = orth->numpoints; renderer_ops->set_linewidth(renderer, REALIZES_WIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_DASHED); renderer_ops->set_dashlength(renderer, REALIZES_DASHLEN); renderer_ops->set_linejoin(renderer, LINEJOIN_MITER); renderer_ops->set_linecaps(renderer, LINECAPS_BUTT); arrow.type = <API key>; arrow.width = <API key>; arrow.length = <API key>; renderer_ops-><API key>(renderer, points, n, REALIZES_WIDTH, &realize->line_color, &arrow, NULL); renderer_ops->set_font(renderer, realize_font, REALIZES_FONTHEIGHT); pos = realize->text_pos; if (realize->st_stereotype != NULL && realize->st_stereotype[0] != '\0') { renderer_ops->draw_string(renderer, realize->st_stereotype, &pos, realize->text_align, &realize->text_color); pos.y += REALIZES_FONTHEIGHT; } if (realize->name != NULL && realize->name[0] != '\0') { renderer_ops->draw_string(renderer, realize->name, &pos, realize->text_align, &realize->text_color); } } static void <API key>(Realizes *realize) { OrthConn *orth = &realize->orth; DiaObject *obj = &orth->object; int num_segm, i; Point *points; Rectangle rect; PolyBBExtras *extra; <API key>(orth); realize->text_width = 0.0; realize->stereotype = <API key>(realize->stereotype); if (!realize->st_stereotype) { realize->st_stereotype = <API key>(realize->stereotype); } if (realize->name) realize->text_width = <API key>(realize->name, realize_font, REALIZES_FONTHEIGHT); if (realize->stereotype) realize->text_width = MAX(realize->text_width, <API key>(realize->stereotype, realize_font, REALIZES_FONTHEIGHT)); extra = &orth->extra_spacing; extra->start_trans = REALIZES_WIDTH/2.0 + <API key>; extra->start_long = extra->middle_trans = extra->end_trans = extra->end_long = REALIZES_WIDTH/2.0; <API key>(orth); /* Calc text pos: */ num_segm = realize->orth.numpoints - 1; points = realize->orth.points; i = num_segm / 2; if ((num_segm % 2) == 0) { /* If no middle segment, use horizontal */ if (realize->orth.orientation[i]==VERTICAL) i } switch (realize->orth.orientation[i]) { case HORIZONTAL: realize->text_align = ALIGN_CENTER; realize->text_pos.x = 0.5*(points[i].x+points[i+1].x); realize->text_pos.y = points[i].y; if (realize->name) realize->text_pos.y -= dia_font_descent(realize->name,realize_font, REALIZES_FONTHEIGHT); break; case VERTICAL: realize->text_align = ALIGN_LEFT; realize->text_pos.x = points[i].x + 0.1; realize->text_pos.y = 0.5*(points[i].y+points[i+1].y); if (realize->name) realize->text_pos.y -= dia_font_descent(realize->name, realize_font, REALIZES_FONTHEIGHT); break; } /* Add the text recangle to the bounding box: */ rect.left = realize->text_pos.x; if (realize->text_align == ALIGN_CENTER) rect.left -= realize->text_width/2.0; rect.right = rect.left + realize->text_width; rect.top = realize->text_pos.y; if (realize->name) rect.top -= dia_font_ascent(realize->name,realize_font, REALIZES_FONTHEIGHT); rect.bottom = rect.top + 2*REALIZES_FONTHEIGHT; rectangle_union(&obj->bounding_box, &rect); } static ObjectChange * <API key>(DiaObject *obj, Point *clicked, gpointer data) { ObjectChange *change; change = <API key>((OrthConn *)obj, clicked); <API key>((Realizes *)obj); return change; } static ObjectChange * <API key>(DiaObject *obj, Point *clicked, gpointer data) { ObjectChange *change; change = <API key>((OrthConn *)obj, clicked); <API key>((Realizes *)obj); return change; } static DiaMenuItem object_menu_items[] = { { N_("Add segment"), <API key>, NULL, 1 }, { N_("Delete segment"), <API key>, NULL, 1 }, <API key>, }; static DiaMenu object_menu = { "Realizes", sizeof(object_menu_items)/sizeof(DiaMenuItem), object_menu_items, NULL }; static DiaMenu * <API key>(Realizes *realize, Point *clickedpoint) { OrthConn *orth; orth = &realize->orth; /* Set entries sensitive/selected etc here */ object_menu_items[0].active = <API key>(orth, clickedpoint); object_menu_items[1].active = <API key>(orth, clickedpoint); <API key>(orth, clickedpoint, &object_menu_items[2]); return &object_menu; } static DiaObject * realizes_create(Point *startpoint, void *user_data, Handle **handle1, Handle **handle2) { Realizes *realize; OrthConn *orth; DiaObject *obj; PolyBBExtras *extra; if (realize_font == NULL) { realize_font = <API key> (DIA_FONT_MONOSPACE, REALIZES_FONTHEIGHT); } realize = g_malloc0(sizeof(Realizes)); orth = &realize->orth; obj = &orth->object; extra = &orth->extra_spacing; obj->type = &realizes_type; obj->ops = &realizes_ops; orthconn_init(orth, startpoint); realize->text_color = color_black; realize->line_color = <API key>(); realize->name = NULL; realize->stereotype = NULL; realize->st_stereotype = NULL; realize->text_width = 0; extra->start_trans = REALIZES_WIDTH/2.0 + <API key>; extra->start_long = extra->middle_trans = extra->end_trans = extra->end_long = REALIZES_WIDTH/2.0; <API key>(realize); *handle1 = orth->handles[0]; *handle2 = orth->handles[orth->numpoints-2]; return &realize->orth.object; } static void realizes_destroy(Realizes *realize) { g_free(realize->name); g_free(realize->stereotype); g_free(realize->st_stereotype); orthconn_destroy(&realize->orth); } static DiaObject * realizes_load(ObjectNode obj_node, int version, const char *filename) { DiaObject *obj = <API key>(&realizes_type, obj_node,version,filename); if (version == 0) { AttributeNode attr; /* In old objects with no autorouting, set it to false. */ attr = <API key>(obj_node, "autorouting"); if (attr == NULL) ((OrthConn*)obj)->autorouting = FALSE; } return obj; }
#include <linux/capability.h> #include <linux/net.h> #include <linux/module.h> #include <linux/if_arp.h> #include <linux/list.h> #include <linux/slab.h> #include <net/sock.h> #include <net/af_ieee802154.h> #include <net/ieee802154.h> #include <net/ieee802154_netdev.h> #include <asm/ioctls.h> #include "af802154.h" static HLIST_HEAD(dgram_head); static DEFINE_RWLOCK(dgram_lock); struct dgram_sock { struct sock sk; struct ieee802154_addr src_addr; struct ieee802154_addr dst_addr; unsigned int bound:1; unsigned int connected:1; unsigned int want_ack:1; unsigned int secen:1; unsigned int secen_override:1; unsigned int seclevel:3; unsigned int seclevel_override:1; }; static inline struct dgram_sock *dgram_sk(const struct sock *sk) { return container_of(sk, struct dgram_sock, sk); } static void dgram_hash(struct sock *sk) { write_lock_bh(&dgram_lock); sk_add_node(sk, &dgram_head); sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); write_unlock_bh(&dgram_lock); } static void dgram_unhash(struct sock *sk) { write_lock_bh(&dgram_lock); if (sk_del_node_init(sk)) sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); write_unlock_bh(&dgram_lock); } static int dgram_init(struct sock *sk) { struct dgram_sock *ro = dgram_sk(sk); ro->want_ack = 1; return 0; } static void dgram_close(struct sock *sk, long timeout) { sk_common_release(sk); } static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len) { struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr; struct ieee802154_addr haddr; struct dgram_sock *ro = dgram_sk(sk); int err = -EINVAL; struct net_device *dev; lock_sock(sk); ro->bound = 0; if (len < sizeof(*addr)) goto out; if (addr->family != AF_IEEE802154) goto out; <API key>(&haddr, &addr->addr); dev = ieee802154_get_dev(sock_net(sk), &haddr); if (!dev) { err = -ENODEV; goto out; } if (dev->type != ARPHRD_IEEE802154) { err = -ENODEV; goto out_put; } ro->src_addr = haddr; ro->bound = 1; err = 0; out_put: dev_put(dev); out: release_sock(sk); return err; } static int dgram_ioctl(struct sock *sk, int cmd, unsigned long arg) { switch (cmd) { case SIOCOUTQ: { int amount = sk_wmem_alloc_get(sk); return put_user(amount, (int __user *)arg); } case SIOCINQ: { struct sk_buff *skb; unsigned long amount; amount = 0; spin_lock_bh(&sk->sk_receive_queue.lock); skb = skb_peek(&sk->sk_receive_queue); if (skb != NULL) { /* We will only return the amount * of this packet since that is all * that will be read. */ amount = skb->len - <API key>(skb); } spin_unlock_bh(&sk->sk_receive_queue.lock); return put_user(amount, (int __user *)arg); } } return -ENOIOCTLCMD; } /* FIXME: autobind */ static int dgram_connect(struct sock *sk, struct sockaddr *uaddr, int len) { struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr; struct dgram_sock *ro = dgram_sk(sk); int err = 0; if (len < sizeof(*addr)) return -EINVAL; if (addr->family != AF_IEEE802154) return -EINVAL; lock_sock(sk); if (!ro->bound) { err = -ENETUNREACH; goto out; } <API key>(&ro->dst_addr, &addr->addr); ro->connected = 1; out: release_sock(sk); return err; } static int dgram_disconnect(struct sock *sk, int flags) { struct dgram_sock *ro = dgram_sk(sk); lock_sock(sk); ro->connected = 0; release_sock(sk); return 0; } static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t size) { struct net_device *dev; unsigned int mtu; struct sk_buff *skb; struct ieee802154_mac_cb *cb; struct dgram_sock *ro = dgram_sk(sk); struct ieee802154_addr dst_addr; int hlen, tlen; int err; if (msg->msg_flags & MSG_OOB) { pr_debug("msg->msg_flags = 0x%x\n", msg->msg_flags); return -EOPNOTSUPP; } if (!ro->connected && !msg->msg_name) return -EDESTADDRREQ; else if (ro->connected && msg->msg_name) return -EISCONN; if (!ro->bound) dev = <API key>(sock_net(sk), ARPHRD_IEEE802154); else dev = ieee802154_get_dev(sock_net(sk), &ro->src_addr); if (!dev) { pr_debug("no dev\n"); err = -ENXIO; goto out; } mtu = dev->mtu; pr_debug("name = %s, mtu = %u\n", dev->name, mtu); if (size > mtu) { pr_debug("size = %Zu, mtu = %u\n", size, mtu); err = -EMSGSIZE; goto out_dev; } hlen = LL_RESERVED_SPACE(dev); tlen = dev->needed_tailroom; skb = sock_alloc_send_skb(sk, hlen + tlen + size, msg->msg_flags & MSG_DONTWAIT, &err); if (!skb) goto out_dev; skb_reserve(skb, hlen); <API key>(skb); cb = mac_cb_init(skb); cb->type = <API key>; cb->ackreq = ro->want_ack; if (msg->msg_name) { DECLARE_SOCKADDR(struct sockaddr_ieee802154*, daddr, msg->msg_name); <API key>(&dst_addr, &daddr->addr); } else { dst_addr = ro->dst_addr; } cb->secen = ro->secen; cb->secen_override = ro->secen_override; cb->seclevel = ro->seclevel; cb->seclevel_override = ro->seclevel_override; err = dev_hard_header(skb, dev, ETH_P_IEEE802154, &dst_addr, ro->bound ? &ro->src_addr : NULL, size); if (err < 0) goto out_skb; err = memcpy_from_msg(skb_put(skb, size), msg, size); if (err < 0) goto out_skb; skb->dev = dev; skb->sk = sk; skb->protocol = htons(ETH_P_IEEE802154); dev_put(dev); err = dev_queue_xmit(skb); if (err > 0) err = net_xmit_errno(err); return err ?: size; out_skb: kfree_skb(skb); out_dev: dev_put(dev); out: return err; } static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len) { size_t copied = 0; int err = -EOPNOTSUPP; struct sk_buff *skb; DECLARE_SOCKADDR(struct sockaddr_ieee802154 *, saddr, msg->msg_name); skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) goto out; copied = skb->len; if (len < copied) { msg->msg_flags |= MSG_TRUNC; copied = len; } /* FIXME: skip headers if necessary ?! */ err = <API key>(skb, 0, msg->msg_iov, copied); if (err) goto done; <API key>(msg, sk, skb); if (saddr) { saddr->family = AF_IEEE802154; <API key>(&saddr->addr, &mac_cb(skb)->source); *addr_len = sizeof(*saddr); } if (flags & MSG_TRUNC) copied = skb->len; done: skb_free_datagram(sk, skb); out: if (err) return err; return copied; } static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb) { skb = skb_share_check(skb, GFP_ATOMIC); if (!skb) return NET_RX_DROP; if (sock_queue_rcv_skb(sk, skb) < 0) { kfree_skb(skb); return NET_RX_DROP; } return NET_RX_SUCCESS; } static inline bool <API key>(__le64 hw_addr, __le16 pan_id, __le16 short_addr, struct dgram_sock *ro) { if (!ro->bound) return true; if (ro->src_addr.mode == <API key> && hw_addr == ro->src_addr.extended_addr) return true; if (ro->src_addr.mode == <API key> && pan_id == ro->src_addr.pan_id && short_addr == ro->src_addr.short_addr) return true; return false; } int <API key>(struct net_device *dev, struct sk_buff *skb) { struct sock *sk, *prev = NULL; int ret = NET_RX_SUCCESS; __le16 pan_id, short_addr; __le64 hw_addr; /* Data frame processing */ BUG_ON(dev->type != ARPHRD_IEEE802154); pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev); short_addr = ieee802154_mlme_ops(dev)->get_short_addr(dev); hw_addr = <API key>(dev->dev_addr); read_lock(&dgram_lock); sk_for_each(sk, &dgram_head) { if (<API key>(hw_addr, pan_id, short_addr, dgram_sk(sk))) { if (prev) { struct sk_buff *clone; clone = skb_clone(skb, GFP_ATOMIC); if (clone) dgram_rcv_skb(prev, clone); } prev = sk; } } if (prev) { dgram_rcv_skb(prev, skb); } else { kfree_skb(skb); ret = NET_RX_DROP; } read_unlock(&dgram_lock); return ret; } static int dgram_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { struct dgram_sock *ro = dgram_sk(sk); int val, len; if (level != SOL_IEEE802154) return -EOPNOTSUPP; if (get_user(len, optlen)) return -EFAULT; len = min_t(unsigned int, len, sizeof(int)); switch (optname) { case WPAN_WANTACK: val = ro->want_ack; break; case WPAN_SECURITY: if (!ro->secen_override) val = <API key>; else if (ro->secen) val = WPAN_SECURITY_ON; else val = WPAN_SECURITY_OFF; break; case WPAN_SECURITY_LEVEL: if (!ro->seclevel_override) val = <API key>; else val = ro->seclevel; break; default: return -ENOPROTOOPT; } if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &val, len)) return -EFAULT; return 0; } static int dgram_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { struct dgram_sock *ro = dgram_sk(sk); struct net *net = sock_net(sk); int val; int err = 0; if (optlen < sizeof(int)) return -EINVAL; if (get_user(val, (int __user *)optval)) return -EFAULT; lock_sock(sk); switch (optname) { case WPAN_WANTACK: ro->want_ack = !!val; break; case WPAN_SECURITY: if (!ns_capable(net->user_ns, CAP_NET_ADMIN) && !ns_capable(net->user_ns, CAP_NET_RAW)) { err = -EPERM; break; } switch (val) { case <API key>: ro->secen_override = 0; break; case WPAN_SECURITY_ON: ro->secen_override = 1; ro->secen = 1; break; case WPAN_SECURITY_OFF: ro->secen_override = 1; ro->secen = 0; break; default: err = -EINVAL; break; } break; case WPAN_SECURITY_LEVEL: if (!ns_capable(net->user_ns, CAP_NET_ADMIN) && !ns_capable(net->user_ns, CAP_NET_RAW)) { err = -EPERM; break; } if (val < <API key> || val > <API key>) { err = -EINVAL; } else if (val == <API key>) { ro->seclevel_override = 0; } else { ro->seclevel_override = 1; ro->seclevel = val; } break; default: err = -ENOPROTOOPT; break; } release_sock(sk); return err; } struct proto <API key> = { .name = "IEEE-802.15.4-MAC", .owner = THIS_MODULE, .obj_size = sizeof(struct dgram_sock), .init = dgram_init, .close = dgram_close, .bind = dgram_bind, .sendmsg = dgram_sendmsg, .recvmsg = dgram_recvmsg, .hash = dgram_hash, .unhash = dgram_unhash, .connect = dgram_connect, .disconnect = dgram_disconnect, .ioctl = dgram_ioctl, .getsockopt = dgram_getsockopt, .setsockopt = dgram_setsockopt, };
#include <hurd.h> #include <hurd/signal.h> #include <hurd/threadvar.h> #include <stdlib.h> #include <mach/mips/mips_instruction.h> int __sigreturn (struct sigcontext *scp) { struct hurd_sigstate *ss; struct hurd_userlink *link = (void *) &scp[1]; mach_port_t *reply_port; if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK)) { errno = EINVAL; return -1; } ss = _hurd_self_sigstate (); __spin_lock (&ss->lock); /* Remove the link on the `active resources' chain added by <API key>. Its purpose was to make sure that we got called; now we have, it is done. */ <API key> (link); /* Restore the set of blocked signals, and the intr_port slot. */ ss->blocked = scp->sc_mask; ss->intr_port = scp->sc_intr_port; /* Check for pending signals that were blocked by the old set. */ if (ss->pending & ~ss->blocked) { /* There are pending signals that just became unblocked. Wake up the signal thread to deliver them. But first, squirrel away SCP where the signal thread will notice it if it runs another handler, and arrange to have us called over again in the new reality. */ ss->context = scp; __spin_unlock (&ss->lock); __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); /* If a pending signal was handled, sig_post never returned. */ __spin_lock (&ss->lock); ss->context = NULL; } if (scp->sc_onstack) { ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */ /* XXX cannot unlock until off sigstack */ abort (); } else __spin_unlock (&ss->lock); /* Destroy the MiG reply port used by the signal handler, and restore the reply port in use by the thread when interrupted. */ reply_port = (mach_port_t *) <API key> (<API key>); if (*reply_port) { mach_port_t port = *reply_port; /* Assigning MACH_PORT_DEAD here tells libc's mig_get_reply_port not to get another reply port, but avoids <API key> trying to deallocate it after the receive fails (which it will, because the reply port will be bogus, whether we do this or not). */ *reply_port = MACH_PORT_DEAD; __mach_port_destroy (__mach_task_self (), port); } *reply_port = scp->sc_reply_port; if (scp->sc_coproc_used & SC_COPROC_USE_FPU) { /* Restore FPU state. */ #define restore_fpr(n) \ asm volatile ("l.d $f" #n ",%0" : : "m" (scp->sc_fpr[n])) /* Restore floating-point registers. */ #ifdef __mips64 restore_fpr (0); restore_fpr (1); restore_fpr (2); restore_fpr (3); restore_fpr (4); restore_fpr (5); restore_fpr (6); restore_fpr (7); restore_fpr (8); restore_fpr (9); restore_fpr (10); restore_fpr (11); restore_fpr (12); restore_fpr (13); restore_fpr (14); restore_fpr (15); restore_fpr (16); restore_fpr (17); restore_fpr (18); restore_fpr (19); restore_fpr (20); restore_fpr (21); restore_fpr (22); restore_fpr (23); restore_fpr (24); restore_fpr (25); restore_fpr (26); restore_fpr (27); restore_fpr (28); restore_fpr (29); restore_fpr (30); restore_fpr (31); #else restore_fpr (0); restore_fpr (2); restore_fpr (4); restore_fpr (6); restore_fpr (8); restore_fpr (10); restore_fpr (12); restore_fpr (14); restore_fpr (16); restore_fpr (18); restore_fpr (20); restore_fpr (22); restore_fpr (24); restore_fpr (26); restore_fpr (28); restore_fpr (30); #endif /* Restore the floating-point control/status register ($f31). */ asm volatile ("ctc1 %0,$f31" : : "r" (scp->sc_fpcsr)); } /* Load all the registers from the sigcontext. */ #ifdef __mips64 #define restore_gpr(n) \ asm volatile ("ld $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1])) #else #define restore_gpr(n) \ asm volatile ("lw $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1])) #endif { register const struct sigcontext *const scpreg asm ("$1") = scp; register int *at asm ("$1"); /* First restore the multiplication result registers. The compiler will use some temporary registers, so we do this before restoring the general registers. */ asm volatile ("mtlo %0" : : "r" (scpreg->sc_mdlo)); asm volatile ("mthi %0" : : "r" (scpreg->sc_mdhi)); /* In the word after the saved PC, store the saved $1 value. */ (&scpreg->sc_pc)[1] = scpreg->sc_gpr[0]; asm volatile (".set noreorder; .set noat;"); /* Restore the normal registers. */ restore_gpr (2); restore_gpr (3); restore_gpr (4); restore_gpr (5); restore_gpr (6); restore_gpr (7); restore_gpr (8); restore_gpr (9); restore_gpr (10); restore_gpr (11); restore_gpr (12); restore_gpr (13); restore_gpr (14); restore_gpr (15); restore_gpr (16); restore_gpr (17); restore_gpr (18); restore_gpr (19); restore_gpr (20); restore_gpr (21); restore_gpr (22); restore_gpr (23); restore_gpr (24); restore_gpr (25); /* Registers 26-27 are kernel-only. */ restore_gpr (28); restore_gpr (29); /* Stack pointer. */ restore_gpr (30); /* Frame pointer. */ restore_gpr (31); /* Return address. */ at = &scpreg->sc_pc; /* This is an emulated instruction that will find at the address in $1 two words: the PC value to restore, and the $1 value to restore. */ asm volatile (".word %0" : : "i" (op_sigreturn)); asm volatile (".set reorder; .set at;"); /* NOTREACHED */ return at; /* To prevent optimization. */ } /* NOTREACHED */ return -1; } weak_alias (__sigreturn, sigreturn)
<?php /** * The Header for our theme. * * Displays all of the <head> section and everything up till <div class="wf-container wf-clearfix"> * * @package presscore * @since presscore 0.1 */ // File Security Check if ( ! defined( 'ABSPATH' ) ) { exit; } ?><!DOCTYPE html> <!--[if IE 6]> <html id="ie6" class="ancient-ie old-ie no-js" <?php language_attributes(); ?>> <![endif] <!--[if IE 7]> <html id="ie7" class="ancient-ie old-ie no-js" <?php language_attributes(); ?>> <![endif] <!--[if IE 8]> <html id="ie8" class="old-ie no-js" <?php language_attributes(); ?>> <![endif] <!--[if IE 9]> <html id="ie9" class="old-ie9 no-js" <?php language_attributes(); ?>> <![endif] <!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]--> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <?php if ( <API key>() ) : ?> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <?php endif; // is responsive?> <?php if ( dt_retina_on() ) { <API key>(); } ?> <title><?php echo <API key>(); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif] <style type="text/css" id="static-stylesheet"></style> <?php if ( ! is_preview() ) { presscore_favicon(); echo of_get_option('<API key>', ''); <API key>(); } wp_head(); ?> </head> <body <?php body_class(); ?>> <?php do_action( 'presscore_body_top' ); ?> <div id="page"<?php if ( 'boxed' == of_get_option('general-layout', 'wide') ) echo ' class="boxed"'; ?>> <?php if ( of_get_option('top_bar-show', 1) ) : ?> <?php get_template_part( 'templates/header/top-bar', of_get_option('<API key>', 'side') ); ?> <?php endif; // show top bar ?> <?php if ( apply_filters( '<API key>', true ) ) : ?> <?php get_template_part( 'templates/header/header', of_get_option( 'header-layout', 'left' ) ); ?> <?php endif; // show header ?> <?php do_action( '<API key>' ); ?> <div id="main" <?php <API key>(); ?>><!-- class="sidebar-none", class="sidebar-left", class="sidebar-right" --> <?php if ( <API key>() ): ?> <div class="main-gradient"></div> <div class="wf-wrap"> <div class="wf-container-main"> <?php do_action( '<API key>' ); ?> <?php endif; ?>
#include <MSGUI/MSRadioBox.H> MSRadioBox::MSRadioBox(MSWidget *owner_,const char *title_) : MSActionBox(owner_,title_) { _activeButton=0; } MSRadioBox::MSRadioBox(MSWidget *owner_,const MSStringVector& title_) : MSActionBox(owner_,title_) { _activeButton=0; } MSRadioBox::~MSRadioBox(void) {} const MSSymbol& MSRadioBox::symbol(void) { static MSSymbol sym ("MSRadioBox"); return sym; } const MSSymbol& MSRadioBox::widgetType(void) const { return symbol(); } void MSRadioBox::arm(MSRadioButton *radioButton_) { disarm(); _activeButton=radioButton_; if (activeButton()!=0) activeButton()->state(MSTrue); } void MSRadioBox::disarm(void) { if (activeButton()!=0) activeButton()->state(MSFalse); _activeButton=0; } void MSRadioBox::firstMapNotify(void) { MSNodeItem *hp=childListHead(); MSNodeItem *np=hp; MSLayoutEntry *entry; MSRadioButton *radioButton; unsigned count=0; while ((np=np->next())!=hp) { entry=(MSLayoutEntry *)np->data(); radioButton=(MSRadioButton *)entry->widget(); if (radioButton->state()==MSTrue) { if (count==0) _activeButton=radioButton; count++; } if (count>1) radioButton->state(MSFalse); } if (count==0&&(np=np->next())!=hp) { entry=(MSLayoutEntry *)np->data(); radioButton=(MSRadioButton *)entry->widget(); radioButton->state(MSTrue); _activeButton=radioButton; } MSActionBox::firstMapNotify(); } void MSRadioBox::activeButton(MSRadioButton *radioButton_, MSBoolean callback_) { radioButton_->arm(callback_); }
<?php defined('JPATH_PLATFORM') or die(); /** * Twitter API Search class for the Joomla Platform. * * @since 12.3 */ class JTwittersearch extends JTwitterObject { /** * Method to get tweets that match a specified query. * * @param string $query Search query. Should be URL encoded. Queries will be limited by complexity. * @param string $callback If supplied, the response will use the JSONP format with a callback of the given name * @param string $geocode Returns tweets by users located within a given radius of the given latitude/longitude. The parameter value is * specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). * @param string $lang Restricts tweets to the given language, given by an ISO 639-1 code. * @param string $locale Specify the language of the query you are sending (only ja is currently effective). This is intended for * language-specific clients and the default should work in the majority of cases. * @param string $result_type Specifies what type of search results you would prefer to receive. The current default is "mixed." * @param integer $count The number of tweets to return per page, up to a maximum of 100. Defaults to 15. * @param string $until Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. * @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID. * @param integer $max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a * variety of metadata about the tweet in a discrete structure, including: urls, media and hashtags. * * @return array The decoded JSON response * * @since 12.3 */ public function search($query, $callback = null, $geocode = null, $lang = null, $locale = null, $result_type = null, $count = 15, $until = null, $since_id = 0, $max_id = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('search', 'tweets'); // Set the API path $path = '/search/tweets.json'; // Set query parameter. $data['q'] = rawurlencode($query); // Check if callback is specified. if ($callback) { $data['callback'] = $callback; } // Check if geocode is specified. if ($geocode) { $data['geocode'] = $geocode; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Check if locale is specified. if ($locale) { $data['locale'] = $locale; } // Check if result_type is specified. if ($result_type) { $data['result_type'] = $result_type; } // Check if count is specified. if ($count != 15) { $data['count'] = $count; } // Check if until is specified. if ($until) { $data['until'] = $until; } // Check if since_id is specified. if ($since_id > 0) { $data['since_id'] = $since_id; } // Check if max_id is specified. if ($max_id > 0) { $data['max_id'] = $max_id; } // Check if entities is specified. if (!is_null($entities)) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); } /** * Method to get the authenticated user's saved search queries. * * @return array The decoded JSON response * * @since 12.3 */ public function getSavedSearches() { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'list'); // Set the API path $path = '/saved_searches/list.json'; // Send the request. return $this->sendRequest($path); } /** * Method to get the information for the saved search represented by the given id. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 12.3 */ public function <API key>($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'show/:id'); // Set the API path $path = '/saved_searches/show/' . $id . '.json'; // Send the request. return $this->sendRequest($path); } /** * Method to create a new saved search for the authenticated user. * * @param string $query The query of the search the user would like to save. * * @return array The decoded JSON response * * @since 12.3 */ public function createSavedSearch($query) { // Set the API path $path = '/saved_searches/create.json'; // Set POST request data $data['query'] = rawurlencode($query); // Send the request. return $this->sendRequest($path, 'POST', $data); } /** * Method to delete a saved search for the authenticating user. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 12.3 */ public function deleteSavedSearch($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'destroy/:id'); // Set the API path $path = '/saved_searches/destroy/' . $id . '.json'; // Send the request. return $this->sendRequest($path, 'POST'); } }
$(document).ready(function(){ // removing some column headers when there is at least one product if ( $('#lines tbody tr.product').length > 0 ) { $('#lines').addClass('with-product'); $('body').addClass('with-product'); } if ( $('#lines tbody tr.ticket').length > 0 ) { $('#lines').addClass('with-ticket'); $('body').addClass('with-ticket'); } window.print(); // update the parent window's content if ( window.opener != undefined && typeof window.opener.li === 'object' ) window.opener.li.initContent(); // print again if ( $('#options #print-again').length > 0 ) window.location = $('#options #print-again a').prop('href'); // close if ( $('#options #close').length > 0 && $('#options #print-again').length == 0 ) window.close(); });
#ifndef _LINUX_PTRACE_H #define _LINUX_PTRACE_H /* ptrace.h */ /* structs and defines to help the user use the ptrace system call. */ /* has the defines to get at the registers. */ #define PTRACE_TRACEME 0 #define PTRACE_PEEKTEXT 1 #define PTRACE_PEEKDATA 2 #define PTRACE_PEEKUSR 3 #define PTRACE_POKETEXT 4 #define PTRACE_POKEDATA 5 #define PTRACE_POKEUSR 6 #define PTRACE_CONT 7 #define PTRACE_KILL 8 #define PTRACE_SINGLESTEP 9 #define PTRACE_ATTACH 0x10 #define PTRACE_DETACH 0x11 #define PTRACE_SYSCALL 24 /* 0x4200-0x4300 are reserved for <API key> additions. */ #define PTRACE_SETOPTIONS 0x4200 #define PTRACE_GETEVENTMSG 0x4201 #define PTRACE_GETSIGINFO 0x4202 #define PTRACE_SETSIGINFO 0x4203 /* options set using PTRACE_SETOPTIONS */ #define <API key> 0x00000001 #define PTRACE_O_TRACEFORK 0x00000002 #define PTRACE_O_TRACEVFORK 0x00000004 #define PTRACE_O_TRACECLONE 0x00000008 #define PTRACE_O_TRACEEXEC 0x00000010 #define <API key> 0x00000020 #define PTRACE_O_TRACEEXIT 0x00000040 #define PTRACE_O_MASK 0x0000007f /* Wait extended result codes for the above trace options. */ #define PTRACE_EVENT_FORK 1 #define PTRACE_EVENT_VFORK 2 #define PTRACE_EVENT_CLONE 3 #define PTRACE_EVENT_EXEC 4 #define <API key> 5 #define PTRACE_EVENT_EXIT 6 #include <asm/ptrace.h> #ifdef __KERNEL__ /* * Ptrace flags */ #define PT_PTRACED 0x00000001 #define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ #define PT_TRACESYSGOOD 0x00000004 #define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ #define PT_TRACE_FORK 0x00000010 #define PT_TRACE_VFORK 0x00000020 #define PT_TRACE_CLONE 0x00000040 #define PT_TRACE_EXEC 0x00000080 #define PT_TRACE_VFORK_DONE 0x00000100 #define PT_TRACE_EXIT 0x00000200 #define PT_ATTACHED 0x00000400 /* parent != real_parent */ #define PT_TRACE_MASK 0x000003f4 /* single stepping state bits (used on ARM and PA-RISC) */ #define PT_SINGLESTEP_BIT 31 #define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT) #define PT_BLOCKSTEP_BIT 30 #define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT) #include <linux/compiler.h> /* For unlikely. */ #include <linux/sched.h> /* For struct task_struct. */ extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len); extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len); extern int ptrace_attach(struct task_struct *tsk); extern int ptrace_detach(struct task_struct *, unsigned int); extern void ptrace_disable(struct task_struct *); extern int ptrace_check_attach(struct task_struct *task, int kill); extern int ptrace_request(struct task_struct *child, long request, long addr, long data); extern void ptrace_notify(int exit_code); extern void __ptrace_link(struct task_struct *child, struct task_struct *new_parent); extern void __ptrace_unlink(struct task_struct *child); static inline void ptrace_link(struct task_struct *child, struct task_struct *new_parent) { if (unlikely(child->ptrace)) __ptrace_link(child, new_parent); } static inline void ptrace_unlink(struct task_struct *child) { if (unlikely(child->ptrace)) __ptrace_unlink(child); } #ifndef <API key> /* * System call handlers that, upon successful completion, need to return a * negative value should call <API key>() right before * returning. On architectures where the syscall convention provides for a * separate error flag (e.g., alpha, ia64, ppc{,64}, sparc{,64}, possibly * others), this macro can be used to ensure that the error flag will not get * set. On architectures which do not support a separate error flag, the macro * is a no-op and the spurious error condition needs to be filtered out by some * other means (e.g., in user-level, by passing an extra argument to the * syscall handler, or something along those lines). */ #define <API key>() do { } while (0) #endif #endif #endif
<?php /** * Class <API key> * * TODO This class will probably need to be renamed to <API key> to explain more functionality * TODO than just inserting slides. * * @since 2.0.0 * @author Stefan Boonstra */ class <API key> { /** @var bool $localizedScript Flag to see if localizeScript function has been called */ private static $localizedScript; /** * Returns the html for showing the image insert button. * Localizes script unless $localizeScript is set to false. * * @since 2.0.0 * @param boolean $localizeScript * @return String $button */ static function <API key>($localizeScript = true) { if ($localizeScript) { self::localizeScript(); } // Put popup html in footer add_action('admin_footer', array(__CLASS__, 'includePopup')); // Return button html ob_start(); include(SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/insert-image-button.php'); return ob_get_clean(); } /** * Returns the html for showing the text insert button. * Localizes script unless $localizeScript is set to false. * * @since 2.0.0 * @param boolean $localizeScript * @return String $button */ static function <API key>($localizeScript = true) { if ($localizeScript) { self::localizeScript(); } // Return button html ob_start(); include(SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/insert-text-button.php'); return ob_get_clean(); } /** * Returns the html for showing the video insert button. * Localizes script unless $localizeScript is set to false. * * @since 2.1.0 * @param boolean $localizeScript * @return String $button */ static function <API key>($localizeScript = true) { if ($localizeScript) { self::localizeScript(); } // Return button html ob_start(); include(SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/insert-video-button.php'); return ob_get_clean(); } /** * This function is registered in the SlideshowPluginAjax class * and prints the results from the search query. * * @since 2.0.0 */ static function printSearchResults() { global $wpdb; // Numberposts and offset $numberPosts = 10; $offset = 0; if (isset($_POST['offset']) && is_numeric($_POST['offset'])) { $offset = $_POST['offset']; } $attachmentIDs = array(); if (isset($_POST['attachmentIDs'])) { $attachmentIDs = array_filter($_POST['attachmentIDs'], 'ctype_digit'); } // Get attachments with a title alike the search string, needs to be filtered add_filter('posts_where', array(__CLASS__, '<API key>')); $query = new WP_Query(array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'offset' => $offset, 'posts_per_page' => $numberPosts + 1, 'orderby' => 'date', 'order' => 'DESC' )); $attachments = $query->get_posts(); remove_filter('posts_where', array(__CLASS__, '<API key>')); // Look for images by their file's name when not enough matching results were found if (count($attachments) < $numberPosts) { $searchString = esc_sql($_POST['search']); // Add results found with the previous query to the $attachmentIDs array to exclude them as well foreach ($attachments as $attachment) { $attachmentIDs[] = $attachment->ID; } // Search by file name $fileNameQuery = new WP_Query(array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => $numberPosts - count($attachments), 'post__not_in' => $attachmentIDs, 'meta_query' => array( array( 'key' => '_wp_attached_file', 'value' => $searchString, 'compare' => 'LIKE' ) ) )); // Put found results in attachments array $<API key> = $fileNameQuery->get_posts(); if (is_array($<API key>) && count($<API key>) > 0) { foreach ($<API key> as $<API key>) { $attachments[] = $<API key>; } } } // Check if there are enough attachments to print a 'Load more images' button $loadMoreResults = false; if (count($attachments) > $numberPosts) { array_pop($attachments); $loadMoreResults = true; } // Print results to the screen if (count($attachments) > 0) { if ($offset > 0) { echo '<tr valign="top"> <td colspan="3" style="text-align: center;"> <b>' . count($attachments) . ' ' . __('More results loaded', 'slideshow-plugin') . '<b> </td> </tr>'; } foreach ($attachments as $attachment) { $image = <API key>($attachment->ID); if (!is_array($image) || !$image) { if (!empty($attachment->guid)) { $imageSrc = $attachment->guid; } else { continue; } } else { $imageSrc = $image[0]; } if (!$imageSrc || empty($imageSrc)) { $imageSrc = SlideshowPluginMain::getPluginUrl() . '/images/<API key>/no-img.png'; } echo '<tr valign="top" data-attachment-Id="' . $attachment->ID . '" class="result-table-row"> <td class="image"> <img width="60" height="60" src="' . $imageSrc . '" class="attachment" alt="' . $attachment->post_title . '" title="' . $attachment->post_title . '"> </td> <td class="column-title"> <strong class="title">' . $attachment->post_title . '</strong> <p class="description">' . $attachment->post_content . '</p> </td> <td class="insert-button"> <input type="button" class="insert-attachment button-secondary" value="' . __('Insert', 'slideshow-plugin') . '" /> </td> </tr>'; } if ($loadMoreResults) { echo '<tr> <td colspan="3" style="text-align: center;"> <button class="button-secondary load-more-results" data-offset="' . ($offset + $numberPosts) . '"> ' . __('Load more results', 'slideshow-plugin') . ' </button> </td> </tr>'; } } else { echo '<tr> <td colspan="3" style="text-align: center;"> <a href="' . admin_url() . 'media-new.php" target="_blank"> ' . __('No images were found, click here to upload some.', 'slideshow-plugin') . ' </a> </td> </tr>'; } die; } /** * Applies a where clause on the get_posts call from self::printSearchResults() * * @since 2.0.0 * @param string $where * @return string $where */ static function <API key>($where) { global $wpdb; $searchString = $_POST['search']; $searchString = esc_sql($searchString); if (isset($_POST['search'])) { $where .= $wpdb->prepare( " AND (post_title LIKE '%%%s%%' OR ID LIKE '%%%s%%') ", $searchString, $searchString ); } return $where; } /** * Include popup, needs to be called in the footer * * @since 2.0.0 */ static function includePopup() { include(SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/search-popup.php'); } /** * Enqueues styles and scripts necessary for the media upload button. * * @since 2.2.12 */ static function localizeScript() { // Return if function doesn't exist if (!function_exists('get_current_screen') || self::$localizedScript) { return; } // Return when not on a slideshow edit page, or files have already been included. $currentScreen = get_current_screen(); if ($currentScreen->post_type != <API key>::$postType) { return; } wp_localize_script( '<API key>', '<API key>', array( 'data' => array(), 'localization' => array( 'confirm' => __('Are you sure you want to delete this slide?', 'slideshow-plugin'), 'uploaderTitle' => __('Insert image slide', 'slideshow-plugin') ) ) ); // Set enqueued to true self::$localizedScript = true; } }
#import <Foundation/Foundation.h> #ifndef RunLoopThread_h #define RunLoopThread_h @interface RunLoopThread : NSObject typedef void* (*ThreadMainType)(void*); + (ThreadMainType)threadMain; - (void)<API key>; - (void)start; - (void)join; @end #endif // RunLoopThread_h
#include <mpi.h> #include "Base/Foundation/Foundation.h" #include "Base/IO/IO.h" #include "units.h" #include "types.h" #include "IndexMap.h" #include "PtrMap.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <assert.h> /* Textual name of this class */ const Type IndexMap_Type = "IndexMap"; IndexMap* IndexMap_New_Param( unsigned delta ) { return _IndexMap_New( sizeof(IndexMap), IndexMap_Type, _IndexMap_Delete, _IndexMap_Print, _IndexMap_Copy, delta ); } void IndexMap_Init( IndexMap* self, unsigned delta ) { /* General info */ self->type = IndexMap_Type; self->_sizeOfSelf = sizeof(IndexMap); self->_deleteSelf = False; /* Virtual info */ self->_delete = _IndexMap_Delete; self->_print = _IndexMap_Print; self->_copy = NULL; _Stg_Class_Init( (Stg_Class*)self ); /* IndexMap info */ _IndexMap_Init( self, delta ); } IndexMap* _IndexMap_New( SizeT _sizeOfSelf, Type type, <API key>* _delete, <API key>* _print, <API key>* _copy, unsigned delta ) { IndexMap* self; /* Allocate memory */ assert( _sizeOfSelf >= sizeof(IndexMap) ); self = (IndexMap*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy ); /* General info */ /* Virtual info */ /* IndexMap info */ _IndexMap_Init( self, delta ); return self; } void _IndexMap_Init( IndexMap* self, unsigned delta ) { /* General and Virtual info should already be set */ /* IndexMap info */ assert( self ); self->delta = delta; self->maxTuples = self->delta; self->tupleTbl = Memory_Alloc_Array( IndexMapTuple, self->maxTuples, "IndexMap->tupleTbl" ); assert( self->tupleTbl ); /* TODO change this to a firewall, or something */ self->tupleCnt = 0; } void _IndexMap_Delete( void* indexMap ) { IndexMap* self = (IndexMap*)indexMap; /* Stg_Class_Delete the class itself */ assert( self ); if( self->tupleTbl ) { Memory_Free( self->tupleTbl ); } /* Stg_Class_Delete parent */ _Stg_Class_Delete( self ); } void _IndexMap_Print( void* indexMap, Stream* stream ) { IndexMap* self = (IndexMap*)indexMap; unsigned tuple_I; /* Set the Journal for printing informations */ Stream* myStream; myStream = Journal_Register( InfoStream_Type, "IndexMapStream" ); /* Print parent */ assert( self ); _Stg_Class_Print( self, stream ); /* General info */ Journal_Printf( myStream, "IndexMap (ptr): (%p)\n", self ); /* Virtual info */ /* IndexMap info */ for( tuple_I = 0; tuple_I < self->tupleCnt; tuple_I++ ) { Journal_Printf( myStream, "\ttuple[%d]: %d -> %d\n", tuple_I, self->tupleTbl[tuple_I].key, self->tupleTbl[tuple_I].idx ); } } void* _IndexMap_Copy( void* indexMap, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) { IndexMap* self = (IndexMap*)indexMap; IndexMap* newIndexMap; PtrMap* map = ptrMap; Bool ownMap = False; if( !map ) { map = PtrMap_New( 10 ); ownMap = True; } newIndexMap = _Stg_Class_Copy( self, dest, deep, nameExt, map ); newIndexMap->dictionary = self->dictionary; newIndexMap->delta = self->delta; newIndexMap->maxTuples = self->maxTuples; newIndexMap->tupleCnt = self->tupleCnt; if( deep ) { if( (newIndexMap->tupleTbl = PtrMap_Find( map, self->tupleTbl )) == NULL && self->tupleTbl ) { newIndexMap->tupleTbl = Memory_Alloc_Array( IndexMapTuple, self->maxTuples, "IndexMap->tupleTbl" ); memcpy( newIndexMap->tupleTbl, self->tupleTbl, sizeof(IndexMapTuple) * self->maxTuples ); PtrMap_Append( map, self->tupleTbl, newIndexMap->tupleTbl ); } } else { newIndexMap->tupleTbl = self->tupleTbl; } if( ownMap ) { Stg_Class_Delete( map ); } return (void*)newIndexMap; } void IndexMap_Append( void* indexMap, Index key, Index idx ) { IndexMap* self = (IndexMap*)indexMap; unsigned newTupleCnt; assert( self && key != -1 && idx != -1 ); if( IndexMap_Find( self, key ) != -1 ) { return; } newTupleCnt = self->tupleCnt + 1; if( newTupleCnt >= self->maxTuples ) { unsigned factor; IndexMapTuple* newTuples; factor = ceil( (float)(newTupleCnt - self->maxTuples) / (float)self->delta ); self->maxTuples += factor * self->delta; newTuples = Memory_Alloc_Array( IndexMapTuple, self->maxTuples, "IndexMap->tupleTbl" ); assert( newTuples ); /* TODO change this */ if( self->tupleTbl ) { memcpy( newTuples, self->tupleTbl, sizeof(IndexMapTuple) * self->tupleCnt ); Memory_Free( self->tupleTbl ); } self->tupleTbl = newTuples; } self->tupleTbl[self->tupleCnt].key = key; self->tupleTbl[self->tupleCnt].idx = idx; self->tupleCnt = newTupleCnt; } Index IndexMap_Find( void* indexMap, Index key ) { IndexMap* self = (IndexMap*)indexMap; unsigned tuple_I; assert( self ); if( key != -1 ) { for( tuple_I = 0; tuple_I < self->tupleCnt; tuple_I++ ) { if( self->tupleTbl[tuple_I].key == key ) return self->tupleTbl[tuple_I].idx; } } return -1; } void IndexMap_Remap( void* indexMap, void* mapThrough ) { IndexMap* self = (IndexMap*)indexMap; Index tuple_I; for( tuple_I = 0; tuple_I < self->tupleCnt; tuple_I++ ) { self->tupleTbl[tuple_I].idx = IndexMap_Find( mapThrough, self->tupleTbl[tuple_I].idx ); } }
#include <linux/module.h> #include <linux/init.h> #include <linux/firmware.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/device.h> #include <linux/printk.h> #include <linux/ratelimit.h> #include <linux/debugfs.h> #include <linux/list.h> #include <linux/mfd/wcd9xxx/core.h> #include <linux/mfd/wcd9xxx/core-resource.h> #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h> #include <linux/mfd/wcd9xxx/wcd9320_registers.h> #include <linux/mfd/wcd9xxx/pdata.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <linux/bitops.h> #include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/kernel.h> #include <linux/gpio.h> #include <linux/input.h> #include "wcd9320.h" #include "wcd9306.h" #include "wcd9xxx-mbhc.h" #include "wcdcal-hwdep.h" #include "wcd9xxx-resmgr.h" #include "wcd9xxx-common.h" #define WCD9XXX_JACK_MASK (SND_JACK_HEADSET | SND_JACK_OC_HPHL | \ SND_JACK_OC_HPHR | SND_JACK_LINEOUT | \ <API key> | <API key>) #define <API key> (SND_JACK_BTN_0 | SND_JACK_BTN_1 | \ SND_JACK_BTN_2 | SND_JACK_BTN_3 | \ SND_JACK_BTN_4 | SND_JACK_BTN_5 | \ SND_JACK_BTN_6 | SND_JACK_BTN_7) #define NUM_DCE_PLUG_DETECT 3 #define <API key> 5 #define <API key> 25 #define <API key> 5 #define <API key> 10 #define FAKE_INS_LOW 10 #define FAKE_INS_HIGH 80 #define <API key> 150 #define <API key> 50 #define <API key> 300 #define BUTTON_MIN 0x8000 #define <API key> 0x0C #define <API key> (5 * 1000) #define <API key> (5 * 1000) #define <API key> 100 #define <API key> 50 #define <API key> 5000 #define <API key> 25 #define <API key> 2 #define OCP_ATTEMPT 1 #define FW_READ_ATTEMPTS 15 #define FW_READ_TIMEOUT 4000000 #define <API key> true #define MCLK_RATE_12288KHZ 12288000 #define MCLK_RATE_9600KHZ 9600000 #define <API key> 55 #define DEFAULT_DCE_WAIT 60000 #define DEFAULT_STA_WAIT 5000 #define VDDIO_MICBIAS_MV 1800 #define <API key> 5000 #define <API key> 1000 #define <API key> 50 #define <API key> 120 #define <API key> 20 #define <API key> 80 /* Threshold in milliohm used for mono/stereo * plug classification */ #define <API key> 20000000 #define <API key> 2000 /* * Invalid voltage range for the detection * of plug type with current source */ #define <API key> 160 #define <API key> 265 /* * Threshold used to detect euro headset * with current source */ #define <API key> 10 #define <API key> 40 #define WCD9XXX_MBHC_NSC_CS 9 #define <API key> 150 #define <API key> 650 #define <API key> 200 #define <API key> 100 /* RX_HPH_CNP_WG_TIME increases by 0.24ms */ #define <API key> 240 #ifdef VENDOR_EDIT // Modified begin by MingLiu@MultiMedia.AudioDrv for headset detect on 2014-10-17 #define WCD9XXX_V_CS_HS_MAX 500 #else /* VENDOR_EDIT */ #define WCD9XXX_V_CS_HS_MAX 1000 // Modified end by MingLiu@MultiMedia.AudioDrv for headset detect on 2014-10-17 #endif /* VENDOR_EDIT */ #ifdef VENDOR_EDIT /*wangdongdong@MultiMedia.AudioDrv,2015/06/04,add for headset detect*/ /*kang change from 20 to 15 for supporting lenove U.S./CTIA headset*/ #define WCD9XXX_V_CS_NO_MIC 15 #else #define WCD9XXX_V_CS_NO_MIC 5 #endif #define <API key> 80 #define <API key> 12 #define WCD9XXX_ZDET_ZONE_1 80000 #define WCD9XXX_ZDET_ZONE_2 800000 #define <API key>(x) (x < WCD9XXX_ZDET_ZONE_1 ? 1 : 0) #define <API key>(x) ((x > WCD9XXX_ZDET_ZONE_1 && \ x < WCD9XXX_ZDET_ZONE_2) ? 1 : 0) #define <API key>(x) (x > WCD9XXX_ZDET_ZONE_2 ? 1 : 0) #define <API key> 1 #define <API key> 10 static int impedance_detect_en; module_param(impedance_detect_en, int, S_IRUGO | S_IWUSR | S_IWGRP); MODULE_PARM_DESC(impedance_detect_en, "enable/disable impedance detect"); static unsigned int z_det_box_car_avg = 1; module_param(z_det_box_car_avg, int, S_IRUGO | S_IWUSR | S_IWGRP); MODULE_PARM_DESC(z_det_box_car_avg, "Number of samples for impedance detection"); static bool <API key>; struct wcd9xxx_mbhc_detect { u16 dce; u16 sta; u16 hphl_status; bool swap_gnd; bool vddio; bool hwvalue; bool mic_bias; /* internal purpose from here */ bool _above_no_mic; bool _below_v_hs_max; s16 _vdces; enum <API key> _type; }; enum meas_type { STA = 0, DCE, }; enum { <API key> = 1, MBHC_USE_MB_TRIGGER = 2 }; /* * Flags to track of PA and DAC state. * PA and DAC should be tracked separately as AUXPGA loopback requires * only PA to be turned on without DAC being on. */ enum pa_dac_ack_flags { <API key> = 0, <API key>, <API key>, <API key> }; enum <API key> { <API key>, <API key>, <API key>, <API key>, <API key>, }; static int <API key>(struct wcd9xxx_mbhc *mbhc, uint32_t *zl, uint32_t *zr); static s16 <API key>(struct wcd9xxx_mbhc *mbhc, const enum <API key> idx); static void wcd9xxx_get_z(struct wcd9xxx_mbhc *mbhc, s16 *dce_z, s16 *sta_z, struct mbhc_micbias_regs *micb_regs, bool norel); static void <API key>(struct wcd9xxx_mbhc *mbhc); static u16 <API key>(struct wcd9xxx_mbhc *mbhc, enum meas_type dce, s16 vin_mv, bool cs_enable); static bool <API key>(struct wcd9xxx_mbhc *mbhc) { return snd_soc_read(mbhc->codec, <API key>) & 0x1; } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool on) { struct snd_soc_codec *codec = mbhc->codec; snd_soc_update_bits(codec, <API key>, 0x04, on ? 0x04 : 0x00); } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); if (!mbhc->polling_active) { pr_debug("polling not active, nothing to pause\n"); return; } /* Soft reset MBHC block */ snd_soc_update_bits(codec, <API key>, 0x8, 0x8); pr_debug("%s: leave\n", __func__); } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; int mbhc_state = mbhc->mbhc_state; pr_debug("%s: enter\n", __func__); if (!mbhc->polling_active) { pr_debug("Polling is not active, do not start polling\n"); return; } /* * setup internal micbias if codec uses internal micbias for * headset detection */ if (mbhc->mbhc_cfg->use_int_rbias) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias) mbhc->mbhc_cb->setup_int_rbias(codec, true); else pr_err("%s: internal bias requested but codec did not provide callback\n", __func__); } snd_soc_write(codec, <API key>, 0x04); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); if (!mbhc-><API key> && mbhc_state == <API key>) { pr_debug("%s recovering MBHC state machine\n", __func__); mbhc->mbhc_state = <API key>; /* set to max button press threshold */ snd_soc_write(codec, <API key>, 0x7F); snd_soc_write(codec, <API key>, 0xFF); snd_soc_write(codec, <API key>, 0x7F); snd_soc_write(codec, <API key>, 0xFF); /* set to max */ snd_soc_write(codec, <API key>, 0x7F); snd_soc_write(codec, <API key>, 0xFF); } snd_soc_write(codec, <API key>, 0x1); snd_soc_update_bits(codec, <API key>, 0x8, 0x0); snd_soc_write(codec, <API key>, 0x1); pr_debug("%s: leave\n", __func__); } static int <API key>(struct wcd9xxx_mbhc *mbhc, unsigned int cfilt_mv) { return <API key>(mbhc->resmgr, cfilt_mv); } /* * called under codec_resource_lock acquisition * return old status */ static bool <API key>(struct wcd9xxx_mbhc *mbhc, int vddio_switch, bool restartpolling, bool checkpolling) { bool ret; int cfilt_k_val; bool override; struct snd_soc_codec *codec; struct <API key> *d = &mbhc->mbhc_data; codec = mbhc->codec; if (mbhc->micbias_enable) { pr_debug("%s: micbias is already on\n", __func__); ret = mbhc-><API key>; return ret; } ret = mbhc-><API key>; if (vddio_switch && !mbhc-><API key> && (!checkpolling || mbhc->polling_active)) { if (restartpolling) <API key>(mbhc); override = snd_soc_read(codec, <API key>) & 0x04; if (!override) <API key>(mbhc, true); /* Adjust threshold if Mic Bias voltage changes */ if (d->micb_mv != VDDIO_MICBIAS_MV) { cfilt_k_val = <API key>(mbhc, VDDIO_MICBIAS_MV); usleep_range(10000, 10100); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_val, 0xFC, (cfilt_k_val << 2)); usleep_range(10000, 10100); /* Threshods for insertion/removal */ snd_soc_write(codec, <API key>, d->v_ins_hu[MBHC_V_IDX_VDDIO] & 0xFF); snd_soc_write(codec, <API key>, (d->v_ins_hu[MBHC_V_IDX_VDDIO] >> 8) & 0xFF); if (mbhc->mbhc_state != <API key>) { /* Threshods for button press */ snd_soc_write(codec, <API key>, d->v_b1_hu[MBHC_V_IDX_VDDIO] & 0xFF); snd_soc_write(codec, <API key>, (d->v_b1_hu[MBHC_V_IDX_VDDIO] >> 8) & 0xFF); snd_soc_write(codec, <API key>, d->v_b1_h[MBHC_V_IDX_VDDIO] & 0xFF); snd_soc_write(codec, <API key>, (d->v_b1_h[MBHC_V_IDX_VDDIO] >> 8) & 0xFF); /* Threshods for button release */ snd_soc_write(codec, <API key>, d->v_brh[MBHC_V_IDX_VDDIO] & 0xFF); snd_soc_write(codec, <API key>, (d->v_brh[MBHC_V_IDX_VDDIO] >> 8) & 0xFF); } pr_debug("%s: Programmed MBHC thresholds to VDDIO\n", __func__); } /* Enable MIC BIAS Switch to VDDIO */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x80, 0x80); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); if (!override) <API key>(mbhc, false); if (restartpolling) <API key>(mbhc); mbhc-><API key> = true; pr_debug("%s: VDDIO switch enabled\n", __func__); } else if (!vddio_switch && mbhc-><API key>) { if ((!checkpolling || mbhc->polling_active) && restartpolling) <API key>(mbhc); /* Reprogram thresholds */ if (d->micb_mv != VDDIO_MICBIAS_MV) { cfilt_k_val = <API key>(mbhc, d->micb_mv); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_val, 0xFC, (cfilt_k_val << 2)); usleep_range(10000, 10100); /* Revert threshods for insertion/removal */ snd_soc_write(codec, <API key>, d->v_ins_hu[MBHC_V_IDX_CFILT] & 0xFF); snd_soc_write(codec, <API key>, (d->v_ins_hu[MBHC_V_IDX_CFILT] >> 8) & 0xFF); if (mbhc->mbhc_state != <API key>) { /* Revert threshods for button press */ snd_soc_write(codec, <API key>, d->v_b1_hu[MBHC_V_IDX_CFILT] & 0xFF); snd_soc_write(codec, <API key>, (d->v_b1_hu[MBHC_V_IDX_CFILT] >> 8) & 0xFF); snd_soc_write(codec, <API key>, d->v_b1_h[MBHC_V_IDX_CFILT] & 0xFF); snd_soc_write(codec, <API key>, (d->v_b1_h[MBHC_V_IDX_CFILT] >> 8) & 0xFF); /* Revert threshods for button release */ snd_soc_write(codec, <API key>, d->v_brh[MBHC_V_IDX_CFILT] & 0xFF); snd_soc_write(codec, <API key>, (d->v_brh[MBHC_V_IDX_CFILT] >> 8) & 0xFF); } pr_debug("%s: Programmed MBHC thresholds to MICBIAS\n", __func__); } /* Disable MIC BIAS Switch to VDDIO */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x80, 0x00); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); if ((!checkpolling || mbhc->polling_active) && restartpolling) <API key>(mbhc); mbhc-><API key> = false; pr_debug("%s: VDDIO switch disabled\n", __func__); } return ret; } static void <API key>(struct wcd9xxx_mbhc *mbhc, int vddio_switch) { <API key>(mbhc, vddio_switch, true, true); } static s16 <API key>(struct wcd9xxx_mbhc *mbhc, const enum <API key> idx) { enum mbhc_v_index vidx; s16 ret = -EINVAL; if ((mbhc->mbhc_data.micb_mv != VDDIO_MICBIAS_MV) && mbhc-><API key>) vidx = MBHC_V_IDX_VDDIO; else vidx = MBHC_V_IDX_CFILT; switch (idx) { case <API key>: ret = (s16)mbhc->mbhc_data.v_ins_h[vidx]; break; case <API key>: ret = (s16)mbhc->mbhc_data.v_ins_hu[vidx]; break; case <API key>: ret = (s16)mbhc->mbhc_data.v_b1_h[vidx]; break; case <API key>: ret = (s16)mbhc->mbhc_data.v_b1_hu[vidx]; break; case <API key>: ret = (s16)mbhc->mbhc_data.v_brh[vidx]; break; } return ret; } void *<API key>( const struct <API key> *btn_det, const enum <API key> mem) { void *ret = (void *)&btn_det->_v_btn_low; switch (mem) { case MBHC_BTN_DET_GAIN: ret += sizeof(btn_det->_n_cic); case MBHC_BTN_DET_N_CIC: ret += sizeof(btn_det->_n_ready); case <API key>: ret += sizeof(btn_det->_v_btn_high[0]) * btn_det->num_btn; case <API key>: ret += sizeof(btn_det->_v_btn_low[0]) * btn_det->num_btn; case <API key>: /* do nothing */ break; default: ret = NULL; } return ret; } EXPORT_SYMBOL(<API key>); static void <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; const s16 v_ins_hu = <API key>(mbhc, <API key>); const s16 v_b1_hu = <API key>(mbhc, <API key>); const s16 v_b1_h = <API key>(mbhc, <API key>); const s16 v_brh = <API key>(mbhc, <API key>); snd_soc_write(codec, <API key>, v_ins_hu & 0xFF); snd_soc_write(codec, <API key>, (v_ins_hu >> 8) & 0xFF); if (mbhc->mbhc_state != <API key>) { snd_soc_write(codec, <API key>, v_b1_hu & 0xFF); snd_soc_write(codec, <API key>, (v_b1_hu >> 8) & 0xFF); snd_soc_write(codec, <API key>, v_b1_h & 0xFF); snd_soc_write(codec, <API key>, (v_b1_h >> 8) & 0xFF); snd_soc_write(codec, <API key>, v_brh & 0xFF); snd_soc_write(codec, <API key>, (v_brh >> 8) & 0xFF); snd_soc_write(codec, <API key>, mbhc->mbhc_data.v_brl & 0xFF); snd_soc_write(codec, <API key>, (mbhc->mbhc_data.v_brl >> 8) & 0xFF); } } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool fast) { struct snd_soc_codec *codec = mbhc->codec; struct wcd9xxx_cfilt_mode cfilt_mode; if (mbhc->mbhc_cb && mbhc->mbhc_cb->switch_cfilt_mode) { cfilt_mode = mbhc->mbhc_cb->switch_cfilt_mode(mbhc, fast); } else { if (fast) cfilt_mode.reg_mode_val = <API key>; else cfilt_mode.reg_mode_val = <API key>; cfilt_mode.reg_mask = 0x40; cfilt_mode.cur_mode_val = snd_soc_read(codec, mbhc->mbhc_bias_regs.cfilt_ctl) & 0x40; } if (cfilt_mode.cur_mode_val != cfilt_mode.reg_mode_val) { if (mbhc->polling_active && <API key>(mbhc)) <API key>(mbhc); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, cfilt_mode.reg_mask, cfilt_mode.reg_mode_val); if (mbhc->polling_active && <API key>(mbhc)) <API key>(mbhc); pr_debug("%s: CFILT mode change (%x to %x)\n", __func__, cfilt_mode.cur_mode_val, cfilt_mode.reg_mode_val); } else { pr_debug("%s: CFILT Value is already %x\n", __func__, cfilt_mode.cur_mode_val); } } static void wcd9xxx_jack_report(struct wcd9xxx_mbhc *mbhc, struct snd_soc_jack *jack, int status, int mask) { if (jack == &mbhc->headset_jack) { <API key>(mbhc->resmgr, <API key>, status & SND_JACK_MICROPHONE); <API key>(mbhc->resmgr, WCD9XXX_COND_HPH, status & SND_JACK_HEADPHONE); } <API key>(jack, status, mask); } static void __hphocp_off_report(struct wcd9xxx_mbhc *mbhc, u32 jack_status, int irq) { struct snd_soc_codec *codec; pr_debug("%s: clear ocp status %x\n", __func__, jack_status); codec = mbhc->codec; if (mbhc->hph_status & jack_status) { mbhc->hph_status &= ~jack_status; wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, mbhc->hph_status, WCD9XXX_JACK_MASK); snd_soc_update_bits(codec, <API key>, 0x10, 0x00); snd_soc_update_bits(codec, <API key>, 0x10, 0x10); /* * reset retry counter as PA is turned off signifying * start of new OCP detection session */ if (mbhc->intr_ids->hph_left_ocp) mbhc->hphlocp_cnt = 0; else mbhc->hphrocp_cnt = 0; wcd9xxx_enable_irq(mbhc->resmgr->core_res, irq); } } static void hphrocp_off_report(struct wcd9xxx_mbhc *mbhc, u32 jack_status) { __hphocp_off_report(mbhc, SND_JACK_OC_HPHR, mbhc->intr_ids->hph_right_ocp); } static void hphlocp_off_report(struct wcd9xxx_mbhc *mbhc, u32 jack_status) { __hphocp_off_report(mbhc, SND_JACK_OC_HPHL, mbhc->intr_ids->hph_left_ocp); } static void <API key>(struct wcd9xxx_mbhc *mbhc, enum <API key> mb_type) { unsigned int cfilt; struct <API key> *micbias_pdata = mbhc->resmgr->micbias_pdata; struct mbhc_micbias_regs *micbias_regs; enum wcd9xxx_micbias_num mb_num; if (mb_type == MBHC_ANC_MIC_MB) { micbias_regs = &mbhc->mbhc_anc_bias_regs; mb_num = mbhc->mbhc_cfg->anc_micbias; } else { micbias_regs = &mbhc->mbhc_bias_regs; mb_num = mbhc->mbhc_cfg->micbias; } switch (mb_num) { case MBHC_MICBIAS1: cfilt = micbias_pdata->bias1_cfilt_sel; micbias_regs->mbhc_reg = <API key>; micbias_regs->int_rbias = <API key>; micbias_regs->ctl_reg = <API key>; break; case MBHC_MICBIAS2: cfilt = micbias_pdata->bias2_cfilt_sel; micbias_regs->mbhc_reg = <API key>; micbias_regs->int_rbias = <API key>; micbias_regs->ctl_reg = <API key>; break; case MBHC_MICBIAS3: cfilt = micbias_pdata->bias3_cfilt_sel; micbias_regs->mbhc_reg = <API key>; micbias_regs->int_rbias = <API key>; micbias_regs->ctl_reg = <API key>; break; case MBHC_MICBIAS4: cfilt = micbias_pdata->bias4_cfilt_sel; micbias_regs->mbhc_reg = mbhc->resmgr->reg_addr->micb_4_mbhc; micbias_regs->int_rbias = mbhc->resmgr->reg_addr->micb_4_int_rbias; micbias_regs->ctl_reg = mbhc->resmgr->reg_addr->micb_4_ctl; break; default: /* Should never reach here */ pr_err("%s: Invalid MIC BIAS for MBHC\n", __func__); return; } micbias_regs->cfilt_sel = cfilt; switch (cfilt) { case WCD9XXX_CFILT1_SEL: micbias_regs->cfilt_val = <API key>; micbias_regs->cfilt_ctl = <API key>; break; case WCD9XXX_CFILT2_SEL: micbias_regs->cfilt_val = <API key>; micbias_regs->cfilt_ctl = <API key>; break; case WCD9XXX_CFILT3_SEL: micbias_regs->cfilt_val = <API key>; micbias_regs->cfilt_ctl = <API key>; break; } if (mb_type == MBHC_PRIMARY_MIC_MB) { switch (cfilt) { case WCD9XXX_CFILT1_SEL: mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt1_mv; break; case WCD9XXX_CFILT2_SEL: mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt2_mv; break; case WCD9XXX_CFILT3_SEL: mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt3_mv; break; } } } static void <API key>(struct wcd9xxx_mbhc *mbhc) { bool pa_turned_on = false; struct snd_soc_codec *codec = mbhc->codec; u8 wg_time; wg_time = snd_soc_read(codec, <API key>); wg_time += 1; if (test_and_clear_bit(<API key>, &mbhc->hph_pa_dac_state)) { pr_debug("%s: HPHR clear flag and enable DAC\n", __func__); snd_soc_update_bits(codec, <API key>, 0xC0, 0xC0); } if (test_and_clear_bit(<API key>, &mbhc->hph_pa_dac_state)) { pr_debug("%s: HPHL clear flag and enable DAC\n", __func__); snd_soc_update_bits(codec, <API key>, 0x80, 0x80); } if (test_and_clear_bit(<API key>, &mbhc->hph_pa_dac_state)) { pr_debug("%s: HPHR clear flag and enable PA\n", __func__); snd_soc_update_bits(codec, <API key>, 0x10, 1 << 4); pa_turned_on = true; } if (test_and_clear_bit(<API key>, &mbhc->hph_pa_dac_state)) { pr_debug("%s: HPHL clear flag and enable PA\n", __func__); snd_soc_update_bits(codec, <API key>, 0x20, 1 << 5); pa_turned_on = true; } if (pa_turned_on) { pr_debug("%s: PA was turned on by MBHC and not by DAPM\n", __func__); usleep_range(wg_time * 1000, wg_time * 1000 + 50); } } static int <API key>(struct wcd9xxx_mbhc *mbhc) { int r; r = <API key>(&mbhc->mbhc_btn_dwork); if (r) /* if scheduled mbhc.mbhc_btn_dwork is canceled from here, * we have to unlock from here instead btn_work */ <API key>(mbhc->resmgr->core_res); return r; } static bool <API key>(struct snd_soc_codec *codec, int left) { u8 hph_reg_val = 0; if (left) hph_reg_val = snd_soc_read(codec, <API key>); else hph_reg_val = snd_soc_read(codec, <API key>); return (hph_reg_val & 0xC0) ? true : false; } static bool <API key>(struct snd_soc_codec *codec) { u8 hph_reg_val = 0; hph_reg_val = snd_soc_read(codec, <API key>); return (hph_reg_val & 0x30) ? true : false; } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { u8 wg_time; struct snd_soc_codec *codec = mbhc->codec; wg_time = snd_soc_read(codec, <API key>); wg_time += 1; /* If headphone PA is on, check if userspace receives * removal event to sync-up PA's state */ if (<API key>(codec)) { pr_debug("%s PA is on, setting PA_OFF_ACK\n", __func__); set_bit(<API key>, &mbhc->hph_pa_dac_state); set_bit(<API key>, &mbhc->hph_pa_dac_state); } else { pr_debug("%s PA is off\n", __func__); } if (<API key>(codec, 1)) set_bit(<API key>, &mbhc->hph_pa_dac_state); if (<API key>(codec, 0)) set_bit(<API key>, &mbhc->hph_pa_dac_state); snd_soc_update_bits(codec, <API key>, 0x30, 0x00); snd_soc_update_bits(codec, <API key>, 0x80, 0x00); snd_soc_update_bits(codec, <API key>, 0xC0, 0x00); usleep_range(wg_time * 1000, wg_time * 1000 + 50); } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool ins) { if (!mbhc->mbhc_cfg->insert_detect) return; pr_debug("%s: Setting up %s detection\n", __func__, ins ? "insert" : "removal"); /* Disable detection to avoid glitch */ snd_soc_update_bits(mbhc->codec, <API key>, 1, 0); if (mbhc->mbhc_cfg->gpio_level_insert) snd_soc_write(mbhc->codec, <API key>, (0x68 | (ins ? (1 << 1) : 0))); else snd_soc_write(mbhc->codec, <API key>, (0x6C | (ins ? (1 << 1) : 0))); /* Re-enable detection */ snd_soc_update_bits(mbhc->codec, <API key>, 1, 1); } /* called under codec_resource_lock acquisition */ static void wcd9xxx_report_plug(struct wcd9xxx_mbhc *mbhc, int insertion, enum snd_jack_types jack_type) { <API key>(mbhc->resmgr); pr_debug("%s: enter insertion %d hph_status %x\n", __func__, insertion, mbhc->hph_status); if (!insertion) { /* Report removal */ mbhc->hph_status &= ~jack_type; /* * cancel possibly scheduled btn work and * report release if we reported button press */ if (<API key>(mbhc)) pr_debug("%s: button press is canceled\n", __func__); else if (mbhc->buttons_pressed) { pr_debug("%s: release of button press%d\n", __func__, jack_type); wcd9xxx_jack_report(mbhc, &mbhc->button_jack, 0, mbhc->buttons_pressed); mbhc->buttons_pressed &= ~<API key>; } if (mbhc->micbias_enable && mbhc->micbias_enable_cb) { pr_debug("%s: Disabling micbias\n", __func__); mbhc->micbias_enable = false; mbhc->micbias_enable_cb(mbhc->codec, false, mbhc->mbhc_cfg->micbias); } mbhc->zl = mbhc->zr = 0; mbhc->hph_type = MBHC_HPH_NONE; pr_debug("%s: Reporting removal %d(%x)\n", __func__, jack_type, mbhc->hph_status); #ifdef VENDOR_EDIT /*wangdongdong@MultiMedia.AudioDrv, 2015-03-24, Modify for headset uevent*/ switch_set_state(&mbhc->wcd9xxx_sdev,0); #endif wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, mbhc->hph_status, WCD9XXX_JACK_MASK); <API key>(mbhc); hphrocp_off_report(mbhc, SND_JACK_OC_HPHR); hphlocp_off_report(mbhc, SND_JACK_OC_HPHL); mbhc->current_plug = PLUG_TYPE_NONE; mbhc->polling_active = false; if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(mbhc->codec, false); } else { /* * Report removal of current jack type. * Headphone to headset shouldn't report headphone * removal. */ if (mbhc->mbhc_cfg->detect_extn_cable && !(mbhc->current_plug == PLUG_TYPE_HEADPHONE && jack_type == SND_JACK_HEADSET) && (mbhc->hph_status && mbhc->hph_status != jack_type)) { if (mbhc->micbias_enable && mbhc->micbias_enable_cb && mbhc->hph_status == SND_JACK_HEADSET) { pr_debug("%s: Disabling micbias\n", __func__); mbhc->micbias_enable = false; mbhc->micbias_enable_cb(mbhc->codec, false, mbhc->mbhc_cfg->micbias); } pr_debug("%s: Reporting removal (%x)\n", __func__, mbhc->hph_status); mbhc->zl = mbhc->zr = 0; wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, 0, WCD9XXX_JACK_MASK); mbhc->hph_status &= ~(SND_JACK_HEADSET | SND_JACK_LINEOUT | <API key> | <API key>); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>( mbhc->codec, false); } /* Report insertion */ mbhc->hph_status |= jack_type; if (jack_type == SND_JACK_HEADPHONE) { mbhc->current_plug = PLUG_TYPE_HEADPHONE; } else if (jack_type == <API key>) { mbhc->current_plug = <API key>; } else if (jack_type == SND_JACK_HEADSET) { mbhc->polling_active = <API key>; mbhc->current_plug = PLUG_TYPE_HEADSET; mbhc->update_z = true; } else if (jack_type == SND_JACK_LINEOUT) { mbhc->current_plug = PLUG_TYPE_HIGH_HPH; } else if (jack_type == <API key>) { mbhc->polling_active = <API key>; mbhc->current_plug = <API key>; } if (mbhc->micbias_enable && mbhc->micbias_enable_cb) { pr_debug("%s: Enabling micbias\n", __func__); mbhc->micbias_enable_cb(mbhc->codec, true, mbhc->mbhc_cfg->micbias); } if (mbhc->impedance_detect && impedance_detect_en) <API key>(mbhc, &mbhc->zl, &mbhc->zr); pr_debug("%s: Reporting insertion %d(%x)\n", __func__, jack_type, mbhc->hph_status); #ifdef VENDOR_EDIT /*wangdongdong@MultiMedia.AudioDrv, 2015-03-24, Modify for headset uevent*/ switch(mbhc->current_plug){ case PLUG_TYPE_HEADPHONE: case PLUG_TYPE_HIGH_HPH: mbhc->mbhc_cfg->headset_type = 0; switch_set_state(&mbhc->wcd9xxx_sdev,2); break; case <API key>: mbhc->mbhc_cfg->headset_type = 0; switch_set_state(&mbhc->wcd9xxx_sdev,1); break; case PLUG_TYPE_HEADSET: mbhc->mbhc_cfg->headset_type = 1; switch_set_state(&mbhc->wcd9xxx_sdev,1); break; default: mbhc->mbhc_cfg->headset_type = 0; switch_set_state(&mbhc->wcd9xxx_sdev,0); break; } printk("%s: Reporting insertion %d(%x)\n", __func__, jack_type, mbhc->hph_status); #endif wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, mbhc->hph_status, WCD9XXX_JACK_MASK); /* * if PA is already on, switch micbias * source to VDDIO */ if (((mbhc->current_plug == PLUG_TYPE_HEADSET) || (mbhc->current_plug == <API key>)) && ((mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR | 1 << <API key>)))) <API key>(mbhc, 1, false, false); <API key>(mbhc); } /* Setup insert detect */ <API key>(mbhc, !insertion); pr_debug("%s: leave hph_status %x\n", __func__, mbhc->hph_status); } /* should be called under interrupt context that hold suspend */ static void <API key>(struct wcd9xxx_mbhc *mbhc, struct work_struct *work) { pr_debug("%s: scheduling <API key>\n", __func__); <API key>(mbhc->resmgr); mbhc->hs_detect_work_stop = false; wcd9xxx_lock_sleep(mbhc->resmgr->core_res); schedule_work(work); } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc, struct work_struct *work) { pr_debug("%s: Canceling correct_plug_swch\n", __func__); <API key>(mbhc->resmgr); mbhc->hs_detect_work_stop = true; wmb(); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); if (cancel_work_sync(work)) { pr_debug("%s: correct_plug_swch is canceled\n", __func__); <API key>(mbhc->resmgr->core_res); } WCD9XXX_BCL_LOCK(mbhc->resmgr); } static s16 scale_v_micb_vddio(struct wcd9xxx_mbhc *mbhc, int v, bool tovddio) { int r; int vddio_k, mb_k; vddio_k = <API key>(mbhc, VDDIO_MICBIAS_MV); mb_k = <API key>(mbhc, mbhc->mbhc_data.micb_mv); if (tovddio) r = v * (vddio_k + 4) / (mb_k + 4); else r = v * (mb_k + 4) / (vddio_k + 4); return r; } static s16 <API key>(struct wcd9xxx_mbhc *mbhc) { s16 v_hs_max; struct <API key> *plug_type; plug_type = <API key>(mbhc->mbhc_cfg->calibration); if ((mbhc->mbhc_data.micb_mv != VDDIO_MICBIAS_MV) && mbhc-><API key>) v_hs_max = scale_v_micb_vddio(mbhc, plug_type->v_hs_max, true); else v_hs_max = plug_type->v_hs_max; return v_hs_max; } static short <API key>(struct snd_soc_codec *codec) { u8 bias_msb, bias_lsb; short bias_value; bias_msb = snd_soc_read(codec, <API key>); bias_lsb = snd_soc_read(codec, <API key>); bias_value = (bias_msb << 8) | bias_lsb; return bias_value; } static short <API key>(struct snd_soc_codec *codec) { u8 bias_msb, bias_lsb; short bias_value; bias_msb = snd_soc_read(codec, <API key>); bias_lsb = snd_soc_read(codec, <API key>); bias_value = (bias_msb << 8) | bias_lsb; return bias_value; } static void <API key>(struct snd_soc_codec *codec, bool on) { snd_soc_update_bits(codec, <API key>, 0x02, on << 1); } static short <API key>(struct wcd9xxx_mbhc *mbhc, int dce, bool override_bypass, bool noreldetection) { short bias_value; struct snd_soc_codec *codec = mbhc->codec; wcd9xxx_disable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); if (noreldetection) <API key>(codec, false); if (mbhc->mbhc_cfg->do_recalibration) snd_soc_update_bits(codec, <API key>, 0x2, 0x0); /* Turn on the override */ if (!override_bypass) snd_soc_update_bits(codec, <API key>, 0x4, 0x4); if (dce) { snd_soc_update_bits(codec, <API key>, 0x8, 0x8); snd_soc_write(codec, <API key>, 0x4); snd_soc_update_bits(codec, <API key>, 0x8, 0x0); if (mbhc->mbhc_cfg->do_recalibration) snd_soc_update_bits(codec, <API key>, 0x2, 0x2); usleep_range(mbhc->mbhc_data.t_sta_dce, mbhc->mbhc_data.t_sta_dce + 50); snd_soc_write(codec, <API key>, 0x4); usleep_range(mbhc->mbhc_data.t_dce, mbhc->mbhc_data.t_dce + 50); bias_value = <API key>(codec); } else { snd_soc_update_bits(codec, <API key>, 0x8, 0x8); snd_soc_write(codec, <API key>, 0x2); snd_soc_update_bits(codec, <API key>, 0x8, 0x0); if (mbhc->mbhc_cfg->do_recalibration) snd_soc_update_bits(codec, <API key>, 0x2, 0x2); usleep_range(mbhc->mbhc_data.t_sta_dce, mbhc->mbhc_data.t_sta_dce + 50); snd_soc_write(codec, <API key>, 0x2); usleep_range(mbhc->mbhc_data.t_sta, mbhc->mbhc_data.t_sta + 50); bias_value = <API key>(codec); snd_soc_update_bits(codec, <API key>, 0x8, 0x8); snd_soc_write(codec, <API key>, 0x0); } /* Turn off the override after measuring mic voltage */ if (!override_bypass) snd_soc_update_bits(codec, <API key>, 0x04, 0x00); if (noreldetection) <API key>(codec, true); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); return bias_value; } static short <API key>(struct wcd9xxx_mbhc *mbhc, int dce, bool norel) { bool override_bypass; /* Bypass override if it is already enabled */ override_bypass = (snd_soc_read(mbhc->codec, <API key>) & 0x04) ? true : false; return <API key>(mbhc, dce, override_bypass, norel); } static s32 <API key>(struct wcd9xxx_mbhc *mbhc, s8 dce, u16 bias_value, s16 z, u32 micb_mv) { s16 value, mb; s32 mv = 0; value = bias_value; if (dce) { mb = (mbhc->mbhc_data.dce_mb); if (mb - z) mv = (value - z) * (s32)micb_mv / (mb - z); } else { mb = (mbhc->mbhc_data.sta_mb); if (mb - z) mv = (value - z) * (s32)micb_mv / (mb - z); } return mv; } static s32 <API key>(struct wcd9xxx_mbhc *mbhc, s8 dce, u16 bias_value) { s16 z; z = dce ? (s16)mbhc->mbhc_data.dce_z : (s16)mbhc->mbhc_data.sta_z; return <API key>(mbhc, dce, bias_value, z, mbhc->mbhc_data.micb_mv); } /* To enable/disable bandgap and RC oscillator */ static void <API key>(struct wcd9xxx_mbhc *mbhc, bool enable) { if (enable) { WCD9XXX_BG_CLK_LOCK(mbhc->resmgr); <API key>(mbhc->resmgr, <API key>); if (mbhc->mbhc_cb && mbhc->mbhc_cb->codec_rco_ctrl) { <API key>(mbhc->resmgr); mbhc->mbhc_cb->codec_rco_ctrl(mbhc->codec, true); } else { <API key>(mbhc->resmgr, WCD9XXX_CLK_RCO); <API key>(mbhc->resmgr); } } else { if (mbhc->mbhc_cb && mbhc->mbhc_cb->codec_rco_ctrl) { mbhc->mbhc_cb->codec_rco_ctrl(mbhc->codec, false); WCD9XXX_BG_CLK_LOCK(mbhc->resmgr); } else { WCD9XXX_BG_CLK_LOCK(mbhc->resmgr); <API key>(mbhc->resmgr, WCD9XXX_CLK_RCO); } <API key>(mbhc->resmgr, <API key>); <API key>(mbhc->resmgr); } } /* called only from interrupt which is under codec_resource_lock acquisition */ static short <API key>(struct wcd9xxx_mbhc *mbhc, struct mbhc_micbias_regs *mbhc_micb_regs, bool is_cs_enable) { struct snd_soc_codec *codec = mbhc->codec; short bias_value; u8 cfilt_mode; <API key>(mbhc->resmgr); pr_debug("%s: enter\n", __func__); if (!mbhc->mbhc_cfg->calibration) { pr_err("%s: Error, no calibration exists\n", __func__); return -ENODEV; } /* Enable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true, true); /* * setup internal micbias if codec uses internal micbias for * headset detection */ if (mbhc->mbhc_cfg->use_int_rbias) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias) mbhc->mbhc_cb->setup_int_rbias(codec, true); else pr_err("%s: internal bias requested but codec did not provide callback\n", __func__); } snd_soc_update_bits(codec, <API key>, 0x05, 0x01); /* Make sure CFILT is in fast mode, save current mode */ cfilt_mode = snd_soc_read(codec, mbhc_micb_regs->cfilt_ctl); if (mbhc->mbhc_cb && mbhc->mbhc_cb->cfilt_fast_mode) mbhc->mbhc_cb->cfilt_fast_mode(codec, mbhc); else snd_soc_update_bits(codec, mbhc_micb_regs->cfilt_ctl, 0x70, 0x00); snd_soc_update_bits(codec, <API key>, 0x2, 0x2); snd_soc_write(codec, <API key>, mbhc->scaling_mux_in); pr_debug("%s: scaling_mux_input: %d\n", __func__, mbhc->scaling_mux_in); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); snd_soc_update_bits(codec, <API key>, 0x80, 0x80); snd_soc_update_bits(codec, <API key>, 0x1F, 0x1C); snd_soc_update_bits(codec, <API key>, 0x40, 0x40); snd_soc_update_bits(codec, <API key>, 0x80, 0x00); snd_soc_update_bits(codec, <API key>, 0x8, 0x8); snd_soc_update_bits(codec, <API key>, 0x8, 0x00); snd_soc_update_bits(codec, <API key>, 0x2, 0x2); snd_soc_update_bits(codec, <API key>, 0x8, 0x8); if (!mbhc->mbhc_cfg->do_recalibration) { if (!is_cs_enable) <API key>(mbhc); } /* don't flip override */ bias_value = <API key>(mbhc, 1, true, true); snd_soc_write(codec, mbhc_micb_regs->cfilt_ctl, cfilt_mode); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x13, 0x00); return bias_value; } static void wcd9xxx_recalibrate(struct wcd9xxx_mbhc *mbhc, struct mbhc_micbias_regs *mbhc_micb_regs, bool is_cs_enable) { struct snd_soc_codec *codec = mbhc->codec; s16 reg; int change; struct <API key> *btn_det; s16 sta_z = 0, dce_z = 0; btn_det = <API key>(mbhc->mbhc_cfg->calibration); if (mbhc->mbhc_cfg->do_recalibration) { /* recalibrate dce_z and sta_z */ reg = snd_soc_read(codec, <API key>); change = snd_soc_update_bits(codec, <API key>, 0x78, btn_det->mbhc_nsc << 3); wcd9xxx_get_z(mbhc, &dce_z, &sta_z, mbhc_micb_regs, true); if (change) snd_soc_write(codec, <API key>, reg); if (dce_z && sta_z) { pr_debug("%s: sta_z 0x%x -> 0x%x, dce_z 0x%x -> 0x%x\n", __func__, mbhc->mbhc_data.sta_z, sta_z & 0xffff, mbhc->mbhc_data.dce_z, dce_z & 0xffff); mbhc->mbhc_data.dce_z = dce_z; mbhc->mbhc_data.sta_z = sta_z; <API key>(mbhc); <API key>(mbhc); } else { pr_warn("%s: failed get new dce_z/sta_z 0x%x/0x%x\n", __func__, dce_z, sta_z); } if (is_cs_enable) { /* recalibrate dce_nsc_cs_z */ reg = snd_soc_read(mbhc->codec, <API key>); snd_soc_update_bits(mbhc->codec, <API key>, 0x78, WCD9XXX_MBHC_NSC_CS << 3); wcd9xxx_get_z(mbhc, &dce_z, NULL, mbhc_micb_regs, true); snd_soc_write(mbhc->codec, <API key>, reg); if (dce_z) { mbhc->mbhc_data.dce_nsc_cs_z = dce_z; /* update v_cs_ins_h with new dce_nsc_cs_z */ mbhc->mbhc_data.v_cs_ins_h = <API key>( mbhc, DCE, WCD9XXX_V_CS_HS_MAX, is_cs_enable); pr_debug("%s: dce_nsc_cs_z 0x%x -> 0x%x, v_cs_ins_h 0x%x\n", __func__, mbhc->mbhc_data.dce_nsc_cs_z, dce_z & 0xffff, mbhc->mbhc_data.v_cs_ins_h); } else { pr_debug("%s: failed get new dce_nsc_cs_z\n", __func__); } } } } static void <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; const struct <API key> *generic = <API key>(mbhc->mbhc_cfg->calibration); /* Need MBHC clock */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->codec_rco_ctrl) mbhc->mbhc_cb->codec_rco_ctrl(mbhc->codec, true); else { WCD9XXX_BG_CLK_LOCK(mbhc->resmgr); <API key>(mbhc->resmgr, WCD9XXX_CLK_RCO); <API key>(mbhc->resmgr); } snd_soc_update_bits(codec, <API key>, 0x2, 0x2); snd_soc_update_bits(codec, <API key>, 0x6, 0x0); <API key>(mbhc, 0, false, false); usleep_range(generic->t_shutdown_plug_rem, generic->t_shutdown_plug_rem + 50); snd_soc_update_bits(codec, <API key>, 0xA, 0x8); if (mbhc->mbhc_cb && mbhc->mbhc_cb->codec_rco_ctrl) mbhc->mbhc_cb->codec_rco_ctrl(mbhc->codec, false); else { WCD9XXX_BG_CLK_LOCK(mbhc->resmgr); /* Put requested CLK back */ <API key>(mbhc->resmgr, WCD9XXX_CLK_RCO); <API key>(mbhc->resmgr); } snd_soc_write(codec, <API key>, 0x00); } static void <API key>(struct wcd9xxx_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); <API key>(mbhc); /* Disable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(mbhc->codec, false, true); mbhc->polling_active = false; mbhc->mbhc_state = MBHC_STATE_NONE; pr_debug("%s: leave\n", __func__); } /* called under codec_resource_lock acquisition */ static void <API key>(struct snd_soc_codec *codec, bool on) { snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x01, on); if (on) usleep_range(5000, 5100); } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool on) { pr_debug("%s: vddio %d\n", __func__, on); if (mbhc->mbhc_cb && mbhc->mbhc_cb->pull_mb_to_vddio) { mbhc->mbhc_cb->pull_mb_to_vddio(mbhc->codec, on); goto exit; } if (on) { snd_soc_update_bits(mbhc->codec, mbhc->mbhc_bias_regs.mbhc_reg, 1 << 7, 1 << 7); snd_soc_update_bits(mbhc->codec, <API key>, 1 << 4, 0); } else { snd_soc_update_bits(mbhc->codec, <API key>, 1 << 4, 1 << 4); snd_soc_update_bits(mbhc->codec, mbhc->mbhc_bias_regs.mbhc_reg, 1 << 7, 0); } exit: /* * Wait for the micbias to settle down to vddio * when the micbias to vddio switch is enabled. */ if (on) usleep_range(10000, 10100); } static int wcd9xxx_hphl_status(struct wcd9xxx_mbhc *mbhc) { u16 hph, status; struct snd_soc_codec *codec = mbhc->codec; <API key>(mbhc->resmgr); hph = snd_soc_read(codec, WCD9XXX_A_MBHC_HPH); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x12, 0x02); usleep_range(<API key>, <API key> + <API key>); status = snd_soc_read(codec, <API key>); snd_soc_write(codec, WCD9XXX_A_MBHC_HPH, hph); return status; } static enum <API key> <API key>(struct wcd9xxx_mbhc *mbhc, struct wcd9xxx_mbhc_detect *dt, const int size, bool highhph, unsigned long event_state) { int i; int vdce, mb_mv; int ch, sz, delta_thr; int minv = 0, maxv = INT_MIN; struct wcd9xxx_mbhc_detect *d = dt; struct wcd9xxx_mbhc_detect *dprev = d, *dmicbias = NULL, *dgnd = NULL; enum <API key> type = PLUG_TYPE_INVALID; const struct <API key> *plug_type = <API key>(mbhc->mbhc_cfg->calibration); s16 hs_max, no_mic, dce_z; int highhph_cnt = 0; pr_debug("%s: enter\n", __func__); pr_debug("%s: event_state 0x%lx\n", __func__, event_state); sz = size - 1; for (i = 0, d = dt, ch = 0; i < sz; i++, d++) { if (d->mic_bias) { dce_z = mbhc->mbhc_data.dce_z; mb_mv = mbhc->mbhc_data.micb_mv; hs_max = plug_type->v_hs_max; no_mic = plug_type->v_no_mic; } else { dce_z = mbhc->mbhc_data.dce_nsc_cs_z; mb_mv = VDDIO_MICBIAS_MV; hs_max = WCD9XXX_V_CS_HS_MAX; no_mic = WCD9XXX_V_CS_NO_MIC; } vdce = <API key>(mbhc, true, d->dce, dce_z, (u32)mb_mv); d->_vdces = vdce; if (d->_vdces < no_mic) d->_type = PLUG_TYPE_HEADPHONE; else if (d->_vdces >= hs_max) { d->_type = PLUG_TYPE_HIGH_HPH; highhph_cnt++; } else d->_type = PLUG_TYPE_HEADSET; pr_debug("%s: DCE #%d, %04x, V %04d(%04d), HPHL %d TYPE %d\n", __func__, i, d->dce, vdce, d->_vdces, d->hphl_status & 0x01, d->_type); ch += d->hphl_status & 0x01; if (!d->swap_gnd && !d->mic_bias) { if (maxv < d->_vdces) maxv = d->_vdces; if (!minv || minv > d->_vdces) minv = d->_vdces; } if ((!d->mic_bias && (d->_vdces >= <API key> && d->_vdces <= <API key>)) || (d->mic_bias && (d->_vdces >= <API key> && d->_vdces <= <API key>))) { pr_debug("%s: within invalid range\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } } delta_thr = ((highhph_cnt == sz) || highhph) ? <API key> : <API key>; for (i = 0, d = dt; i < sz; i++, d++) { if ((i > 0) && !d->mic_bias && !d->swap_gnd && (d->_type != dprev->_type)) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } if (!d->swap_gnd && !d->mic_bias && (abs(minv - d->_vdces) > delta_thr || abs(maxv - d->_vdces) > delta_thr)) { pr_debug("%s: Invalid, delta %dmv, %dmv and %dmv\n", __func__, d->_vdces, minv, maxv); type = PLUG_TYPE_INVALID; goto exit; } else if (d->swap_gnd) { dgnd = d; } if (!d->mic_bias && !d->swap_gnd) dprev = d; else if (d->mic_bias) dmicbias = d; } if (dgnd && dt->_type != PLUG_TYPE_HEADSET && dt->_type != dgnd->_type) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } type = dt->_type; if (dmicbias) { if (dmicbias->_type == PLUG_TYPE_HEADSET && (dt->_type == PLUG_TYPE_HIGH_HPH || dt->_type == PLUG_TYPE_HEADSET)) { type = PLUG_TYPE_HEADSET; if (dt->_type == PLUG_TYPE_HIGH_HPH) { pr_debug("%s: Headset with threshold on MIC detected\n", __func__); if (mbhc->mbhc_cfg-><API key> & (1 << <API key>)) mbhc->micbias_enable = true; } } } if (type == PLUG_TYPE_HEADSET && dgnd && !dgnd->mic_bias) { /* if plug type is Headphone report as GND_MIC_SWAP */ if (dgnd->_type == PLUG_TYPE_HEADPHONE) { pr_debug("%s: GND_MIC_SWAP\n", __func__); type = <API key>; /* * if type is GND_MIC_SWAP we should not check * HPHL status hence goto exit */ goto exit; } else if (dgnd->_type != PLUG_TYPE_HEADSET && !dmicbias) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != sz && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL..\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } if (!(event_state & (1UL << MBHC_EVENT_PA_HPHL))) { if (((type == PLUG_TYPE_HEADSET || type == PLUG_TYPE_HEADPHONE) && ch != sz)) { pr_debug("%s: Invalid, not fully inserted, TYPE %d\n", __func__, type); type = PLUG_TYPE_INVALID; } } if (type == PLUG_TYPE_HEADSET && (mbhc->mbhc_cfg-><API key> & (1 << <API key>))) mbhc->micbias_enable = true; exit: pr_debug("%s: Plug type %d detected\n", __func__, type); return type; } /* * <API key> : Find out and return the best plug type with given * list of wcd9xxx_mbhc_detect structure. * param mbhc wcd9xxx_mbhc structure * param dt collected measurements * param size array size of dt * param event_state mbhc->event_state when dt is collected */ static enum <API key> <API key>(struct wcd9xxx_mbhc *mbhc, struct wcd9xxx_mbhc_detect *dt, const int size, unsigned long event_state) { int i; int ch; enum <API key> type; int vdce; struct wcd9xxx_mbhc_detect *d, *dprev, *dgnd = NULL, *dvddio = NULL; int maxv = 0, minv = 0; const struct <API key> *plug_type = <API key>(mbhc->mbhc_cfg->calibration); const s16 hs_max = plug_type->v_hs_max; const s16 no_mic = plug_type->v_no_mic; pr_debug("%s: event_state 0x%lx\n", __func__, event_state); for (i = 0, d = dt, ch = 0; i < size; i++, d++) { vdce = <API key>(mbhc, true, d->dce); if (d->vddio) d->_vdces = scale_v_micb_vddio(mbhc, vdce, false); else d->_vdces = vdce; if (d->_vdces >= no_mic && d->_vdces < hs_max) d->_type = PLUG_TYPE_HEADSET; else if (d->_vdces < no_mic) d->_type = PLUG_TYPE_HEADPHONE; else d->_type = PLUG_TYPE_HIGH_HPH; ch += d->hphl_status & 0x01; if (!d->swap_gnd && !d->hwvalue && !d->vddio) { if (maxv < d->_vdces) maxv = d->_vdces; if (!minv || minv > d->_vdces) minv = d->_vdces; } pr_debug("%s: DCE #%d, %04x, V %04d(%04d), GND %d, VDDIO %d, HPHL %d TYPE %d\n", __func__, i, d->dce, vdce, d->_vdces, d->swap_gnd, d->vddio, d->hphl_status & 0x01, d->_type); /* * If GND and MIC prongs are aligned to HPHR and GND of * headphone, codec measures the voltage based on * impedance between HPHR and GND which results in ~80mv. * Avoid this. */ if (d->_vdces >= <API key> && d->_vdces <= <API key>) { pr_debug("%s: within invalid range\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != size && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } for (i = 0, dprev = NULL, d = dt; i < size; i++, d++) { if (d->vddio) { dvddio = d; continue; } if ((i > 0) && (dprev != NULL) && (d->_type != dprev->_type)) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } if (!d->swap_gnd && !d->hwvalue && (abs(minv - d->_vdces) > <API key> || abs(maxv - d->_vdces) > <API key>)) { pr_debug("%s: Invalid, delta %dmv, %dmv and %dmv\n", __func__, d->_vdces, minv, maxv); type = PLUG_TYPE_INVALID; goto exit; } else if (d->swap_gnd) { dgnd = d; } dprev = d; } WARN_ON(i != size); type = dt->_type; if (type == PLUG_TYPE_HEADSET && dgnd) { if ((dgnd->_vdces + <API key> < minv) && (dgnd->_vdces + <API key> > maxv)) type = <API key>; } /* if HPHL PA was on, we cannot use hphl status */ if (!(event_state & (1UL << MBHC_EVENT_PA_HPHL))) { if (((type == PLUG_TYPE_HEADSET || type == PLUG_TYPE_HEADPHONE) && ch != size) || (type == <API key> && ch)) { pr_debug("%s: Invalid, not fully inserted, TYPE %d\n", __func__, type); type = PLUG_TYPE_INVALID; } } if (type == PLUG_TYPE_HEADSET) { if (dvddio && ((dvddio->_vdces > hs_max) || (dvddio->_vdces > minv + <API key>))) { pr_debug("%s: Headset with threshold on MIC detected\n", __func__); if (mbhc->mbhc_cfg-><API key> & (1 << <API key>)) mbhc->micbias_enable = true; } else { pr_debug("%s: Headset with regular MIC detected\n", __func__); if (mbhc->mbhc_cfg-><API key> & (1 << <API key>)) mbhc->micbias_enable = true; } } exit: pr_debug("%s: Plug type %d detected, micbias_enable %d\n", __func__, type, mbhc->micbias_enable); return type; } /* * Pull down MBHC micbias for provided duration in microsecond. */ static int <API key>(struct wcd9xxx_mbhc *mbhc, int us) { bool micbiasconn = false; struct snd_soc_codec *codec = mbhc->codec; const u16 ctlreg = mbhc->mbhc_bias_regs.ctl_reg; /* * Disable MBHC to micbias connection to pull down * micbias and pull down micbias for a moment. */ if ((snd_soc_read(mbhc->codec, ctlreg) & 0x01)) { WARN_ONCE(1, "MBHC micbias is already pulled down unexpectedly\n"); return -EFAULT; } if ((snd_soc_read(mbhc->codec, <API key>) & 1 << 4)) { snd_soc_update_bits(mbhc->codec, <API key>, 1 << 4, 0); micbiasconn = true; } snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x01); /* * Pull down for 1ms to discharge bias. Give small margin (10us) to be * able to get consistent result across DCEs. */ usleep_range(1000, 1000 + 10); if (micbiasconn) snd_soc_update_bits(mbhc->codec, <API key>, 1 << 4, 1 << 4); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); usleep_range(us, us + <API key>); return 0; } /* Called under codec resource lock acquisition */ void <API key>(struct wcd9xxx_mbhc *mbhc, struct mbhc_micbias_regs *mbhc_micb_regs, bool on, bool highhph) { struct snd_soc_codec *codec; struct <API key> *btn_det; const struct <API key> *plug_det = <API key>(mbhc->mbhc_cfg->calibration); btn_det = <API key>(mbhc->mbhc_cfg->calibration); codec = mbhc->codec; <API key>(mbhc->resmgr); if ((on && mbhc->is_cs_enabled) || (!on && !mbhc->is_cs_enabled)) { pr_debug("%s: Current source is already %s\n", __func__, on ? "ON" : "OFF"); return; } if (on) { pr_debug("%s: enabling current source\n", __func__); /* Nsc to 9 */ snd_soc_update_bits(codec, <API key>, 0x78, 0x48); /* pull down diode bit to 0 */ snd_soc_update_bits(codec, mbhc_micb_regs->mbhc_reg, 0x01, 0x00); /* * Keep the low power insertion/removal * detection (reg 0x3DD) disabled */ snd_soc_update_bits(codec, <API key>, 0x01, 0x00); /* * Enable the Mic Bias current source * Write bits[6:5] of register MICB_2_MBHC to 0x3 (V_20_UA) * Write bit[7] of register MICB_2_MBHC to 1 * (<API key>) * <API key> to 1 */ snd_soc_update_bits(codec, mbhc_micb_regs->mbhc_reg, 0xF0, 0xF0); /* Disconnect MBHC Override from MicBias and LDOH */ snd_soc_update_bits(codec, <API key>, 0x10, 0x00); mbhc->is_cs_enabled = true; } else { pr_debug("%s: disabling current source\n", __func__); /* Connect MBHC Override from MicBias and LDOH */ snd_soc_update_bits(codec, <API key>, 0x10, 0x10); /* INS_DET_ISRC_CTL to acdb value */ snd_soc_update_bits(codec, mbhc_micb_regs->mbhc_reg, 0x60, plug_det->mic_current << 5); if (!highhph) { /* <API key> to 0 */ snd_soc_update_bits(codec, mbhc_micb_regs->mbhc_reg, 0x80, 0x00); /* <API key> to 0 */ snd_soc_update_bits(codec, mbhc_micb_regs->mbhc_reg, 0x10, 0x00); } /* Nsc to acdb value */ snd_soc_update_bits(codec, <API key>, 0x78, btn_det->mbhc_nsc << 3); mbhc->is_cs_enabled = false; } } static enum <API key> <API key>(struct wcd9xxx_mbhc *mbhc, bool highhph) { struct snd_soc_codec *codec = mbhc->codec; struct wcd9xxx_mbhc_detect rt[<API key>]; enum <API key> type = PLUG_TYPE_INVALID; int i; pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); BUG_ON(<API key> < 4); <API key>(mbhc, true); rt[0].swap_gnd = false; rt[0].vddio = false; rt[0].hwvalue = true; rt[0].hphl_status = wcd9xxx_hphl_status(mbhc); rt[0].dce = <API key>(mbhc, &mbhc->mbhc_bias_regs, true); rt[0].mic_bias = false; for (i = 1; i < <API key> - 1; i++) { rt[i].swap_gnd = (i == <API key> - 3); rt[i].mic_bias = ((i == <API key> - 4) && highhph); rt[i].hphl_status = wcd9xxx_hphl_status(mbhc); if (rt[i].swap_gnd) <API key>(codec, true); if (rt[i].mic_bias) <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); rt[i].dce = <API key>(mbhc, 1, !highhph, true); if (rt[i].mic_bias) <API key>(mbhc, &mbhc->mbhc_bias_regs, true, false); if (rt[i].swap_gnd) <API key>(codec, false); } /* recalibrate DCE/STA GND voltages */ wcd9xxx_recalibrate(mbhc, &mbhc->mbhc_bias_regs, true); type = <API key>(mbhc, rt, ARRAY_SIZE(rt), highhph, mbhc->event_state); <API key>(mbhc, false); pr_debug("%s: plug_type:%d\n", __func__, type); return type; } static enum <API key> <API key>(struct wcd9xxx_mbhc *mbhc, bool highhph) { int i; bool vddioon; struct <API key> *plug_type_ptr; struct wcd9xxx_mbhc_detect rt[<API key>]; enum <API key> type = PLUG_TYPE_INVALID; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); /* make sure override is on */ WARN_ON(!(snd_soc_read(codec, <API key>) & 0x04)); /* GND and MIC swap detection requires at least 2 rounds of DCE */ BUG_ON(<API key> < 2); <API key> = mbhc->mbhc_cfg->use_vddio_meas; /* * There are chances vddio switch is on and cfilt voltage is adjusted * to vddio voltage even after plug type removal reported. */ vddioon = <API key>(mbhc, 0, false, false); pr_debug("%s: vddio switch was %s\n", __func__, vddioon ? "on" : "off"); plug_type_ptr = <API key>(mbhc->mbhc_cfg->calibration); /* * cfilter in fast mode requires 1ms to charge up and down micbias * fully. */ (void) <API key>(mbhc, <API key>); <API key>(mbhc, true); rt[0].hphl_status = wcd9xxx_hphl_status(mbhc); rt[0].dce = <API key>(mbhc, &mbhc->mbhc_bias_regs, false); rt[0].swap_gnd = false; rt[0].vddio = false; rt[0].hwvalue = true; for (i = 1; i < <API key>; i++) { rt[i].swap_gnd = (i == <API key> - 2); if (<API key>) rt[i].vddio = (i == 1); else rt[i].vddio = false; rt[i].hphl_status = wcd9xxx_hphl_status(mbhc); rt[i].hwvalue = false; if (rt[i].swap_gnd) <API key>(codec, true); if (rt[i].vddio) <API key>(mbhc, true); /* * Pull down micbias to detect headset with mic which has * threshold and to have more consistent voltage measurements. * * cfilter in fast mode requires 1ms to charge up and down * micbias fully. */ (void) <API key>(mbhc, <API key>); rt[i].dce = <API key>(mbhc, 1, true, true); if (rt[i].vddio) <API key>(mbhc, false); if (rt[i].swap_gnd) <API key>(codec, false); } /* recalibrate DCE/STA GND voltages */ wcd9xxx_recalibrate(mbhc, &mbhc->mbhc_bias_regs, false); if (vddioon) <API key>(mbhc, 1, false, false); type = <API key>(mbhc, rt, ARRAY_SIZE(rt), mbhc->event_state); <API key>(mbhc, false); pr_debug("%s: leave\n", __func__); return type; } static bool <API key>(struct wcd9xxx_mbhc *mbhc) { if (mbhc->mbhc_cfg->gpio) return (<API key>(mbhc->mbhc_cfg->gpio) != mbhc->mbhc_cfg->gpio_level_insert); else if (mbhc->mbhc_cfg->insert_detect) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->insert_rem_status) return mbhc->mbhc_cb->insert_rem_status(mbhc->codec); else return snd_soc_read(mbhc->codec, <API key>) & (1 << 2); } else WARN(1, "Invalid jack detection configuration\n"); return true; } static bool is_clk_active(struct snd_soc_codec *codec) { return !!(snd_soc_read(codec, <API key>) & 0x05); } static int <API key>(struct wcd9xxx_mbhc *mbhc, int insertion, int trigger, bool padac_off) { struct snd_soc_codec *codec = mbhc->codec; int <API key> = 0; const struct <API key> *generic = <API key>(mbhc->mbhc_cfg->calibration); const struct <API key> *plug_det = <API key>(mbhc->mbhc_cfg->calibration); pr_debug("%s: enter insertion(%d) trigger(0x%x)\n", __func__, insertion, trigger); if (!mbhc->mbhc_cfg->calibration) { pr_err("Error, no wcd9xxx calibration\n"); return -EINVAL; } snd_soc_update_bits(codec, <API key>, 0x1, 0); /* * Make sure mic bias and Mic line schmitt trigger * are turned OFF */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x90, 0x00); if (insertion) { <API key>(mbhc, 0); /* DAPM can manipulate PA/DAC bits concurrently */ if (padac_off == true) <API key>(mbhc); if (trigger & <API key>) { /* Enable HPH Schmitt Trigger */ snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x11, 0x11); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x0C, plug_det->hph_current << 2); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x02, 0x02); } if (trigger & MBHC_USE_MB_TRIGGER) { /* enable the mic line schmitt trigger */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x60, plug_det->mic_current << 5); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x80, 0x80); usleep_range(plug_det->t_mic_pid, plug_det->t_mic_pid + <API key>); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x10, 0x10); } /* setup for insetion detection */ snd_soc_update_bits(codec, <API key>, 0x2, 0); } else { pr_debug("setup for removal detection\n"); /* Make sure the HPH schmitt trigger is OFF */ snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x12, 0x00); /* enable the mic line schmitt trigger */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x60, plug_det->mic_current << 5); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x80, 0x80); usleep_range(plug_det->t_mic_pid, plug_det->t_mic_pid + <API key>); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x10, 0x10); /* Setup for low power removal detection */ snd_soc_update_bits(codec, <API key>, 0x2, 0x2); } if (snd_soc_read(codec, <API key>) & 0x4) { /* called by interrupt */ if (!is_clk_active(codec)) { <API key>(mbhc->resmgr, 1); snd_soc_update_bits(codec, <API key>, 0x06, 0); usleep_range(generic->t_shutdown_plug_rem, generic->t_shutdown_plug_rem + <API key>); <API key>(mbhc->resmgr, 0); } else snd_soc_update_bits(codec, <API key>, 0x06, 0); } snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.int_rbias, 0x80, 0); /* If central bandgap disabled */ if (!(snd_soc_read(codec, <API key>) & 1)) { snd_soc_update_bits(codec, <API key>, 0x3, 0x3); usleep_range(generic->t_bg_fast_settle, generic->t_bg_fast_settle + <API key>); <API key> = 1; } /* If LDO_H disabled */ if (snd_soc_read(codec, <API key>) & 0x80) { snd_soc_update_bits(codec, <API key>, 0x10, 0); snd_soc_update_bits(codec, <API key>, 0x80, 0x80); usleep_range(generic->t_ldoh, generic->t_ldoh + <API key>); snd_soc_update_bits(codec, <API key>, 0x80, 0); if (<API key>) snd_soc_update_bits(codec, <API key>, 0x1, 0); } if (mbhc->resmgr->reg_addr && mbhc->resmgr->reg_addr->micb_4_mbhc) snd_soc_update_bits(codec, mbhc->resmgr->reg_addr->micb_4_mbhc, 0x3, mbhc->mbhc_cfg->micbias); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->insertion); snd_soc_update_bits(codec, <API key>, 0x1, 0x1); pr_debug("%s: leave\n", __func__); return 0; } /* * Function to determine whether anc microphone is preset or not. * Return true if anc microphone is detected or false if not detected. */ static bool <API key>(struct wcd9xxx_mbhc *mbhc) { struct wcd9xxx_mbhc_detect rt[<API key> - 1]; bool anc_mic_found = true; int i, mb_mv; const struct <API key> *plug_type = <API key>(mbhc->mbhc_cfg->calibration); s16 hs_max, dce_z; s16 no_mic; bool override_en; bool timedout; unsigned long timeout, retry = 0; enum <API key> type; bool cs_enable; if (mbhc->mbhc_cfg->anc_micbias != MBHC_MICBIAS3 && mbhc->mbhc_cfg->anc_micbias != MBHC_MICBIAS2) return false; pr_debug("%s: enter\n", __func__); override_en = (snd_soc_read(mbhc->codec, <API key>) & 0x04) ? true : false; cs_enable = ((mbhc->mbhc_cfg->cs_enable_flags & (1 << <API key>)) != 0) && (!(snd_soc_read(mbhc->codec, mbhc->mbhc_anc_bias_regs.ctl_reg) & 0x80)) && (mbhc->mbhc_cfg->micbias != mbhc->mbhc_cfg->anc_micbias); if (cs_enable) { <API key>(mbhc, &mbhc->mbhc_anc_bias_regs, true, false); } else { if (mbhc->mbhc_cfg->anc_micbias == MBHC_MICBIAS3) { if (mbhc->micbias_enable_cb) mbhc->micbias_enable_cb(mbhc->codec, true, mbhc->mbhc_cfg->anc_micbias); else return false; } else { /* Enable override */ if (!override_en) <API key>(mbhc, true); } } if (!cs_enable) { hs_max = plug_type->v_hs_max; no_mic = plug_type->v_no_mic; dce_z = mbhc->mbhc_data.dce_z; mb_mv = mbhc->mbhc_data.micb_mv; } else { hs_max = WCD9XXX_V_CS_HS_MAX; no_mic = WCD9XXX_V_CS_NO_MIC; mb_mv = VDDIO_MICBIAS_MV; dce_z = mbhc->mbhc_data.dce_nsc_cs_z; } <API key>(mbhc, true); timeout = jiffies + msecs_to_jiffies(<API key>); anc_mic_found = true; while (!(timedout = time_after(jiffies, timeout))) { retry++; if (<API key>(mbhc)) { pr_debug("%s: Switch level is low\n", __func__); anc_mic_found = false; break; } pr_debug("%s: Retry attempt %lu", __func__, retry - 1); rt[0].hphl_status = wcd9xxx_hphl_status(mbhc); rt[0].dce = <API key>(mbhc, &mbhc->mbhc_anc_bias_regs, cs_enable); rt[0]._vdces = <API key>(mbhc, true, rt[0].dce, dce_z, (u32)mb_mv); if (rt[0]._vdces >= no_mic && rt[0]._vdces < hs_max) rt[0]._type = PLUG_TYPE_HEADSET; else if (rt[0]._vdces < no_mic) rt[0]._type = PLUG_TYPE_HEADPHONE; else rt[0]._type = PLUG_TYPE_HIGH_HPH; pr_debug("%s: DCE #%d, V %04d, HPHL %d TYPE %d\n", __func__, 0, rt[0]._vdces, rt[0].hphl_status & 0x01, rt[0]._type); for (i = 1; i < <API key> - 1; i++) { rt[i].dce = <API key>(mbhc, 1, true, true); rt[i]._vdces = <API key>(mbhc, true, rt[i].dce, dce_z, (u32) mb_mv); if (rt[i]._vdces >= no_mic && rt[i]._vdces < hs_max) rt[i]._type = PLUG_TYPE_HEADSET; else if (rt[i]._vdces < no_mic) rt[i]._type = PLUG_TYPE_HEADPHONE; else rt[i]._type = PLUG_TYPE_HIGH_HPH; rt[i].hphl_status = wcd9xxx_hphl_status(mbhc); pr_debug("%s: DCE #%d, V %04d, HPHL %d TYPE %d\n", __func__, i, rt[i]._vdces, rt[i].hphl_status & 0x01, rt[i]._type); } /* * Check for the "type" of all the 4 measurements * If all 4 measurements have the Type as PLUG_TYPE_HEADSET * then it is proper mic and declare that the plug has two mics */ for (i = 0; i < <API key> - 1; i++) { if (i > 0 && (rt[i - 1]._type != rt[i]._type)) { type = PLUG_TYPE_INVALID; break; } else { type = rt[0]._type; } } pr_debug("%s: Plug type found in ANC detection :%d", __func__, type); if (type != PLUG_TYPE_HEADSET) anc_mic_found = false; if (anc_mic_found || (type == PLUG_TYPE_HEADPHONE && mbhc->mbhc_cfg->hw_jack_type == FIVE_POLE_JACK) || (type == PLUG_TYPE_HIGH_HPH && mbhc->mbhc_cfg->hw_jack_type == SIX_POLE_JACK)) break; } <API key>(mbhc, false); if (cs_enable) { <API key>(mbhc, &mbhc->mbhc_anc_bias_regs, false, false); } else { if (mbhc->mbhc_cfg->anc_micbias == MBHC_MICBIAS3) { if (mbhc->micbias_enable_cb) mbhc->micbias_enable_cb(mbhc->codec, false, mbhc->mbhc_cfg->anc_micbias); } else { /* Disable override */ if (!override_en) <API key>(mbhc, false); } } pr_debug("%s: leave\n", __func__); return anc_mic_found; } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc, enum <API key> plug_type) { bool anc_mic_found = false; pr_debug("%s: enter current_plug(%d) new_plug(%d)\n", __func__, mbhc->current_plug, plug_type); <API key>(mbhc->resmgr); if (plug_type == PLUG_TYPE_HEADPHONE && mbhc->current_plug == PLUG_TYPE_NONE) { /* * Nothing was reported previously * report a headphone or unsupported */ wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); <API key>(mbhc); } else if (plug_type == <API key>) { if (!mbhc->mbhc_cfg->detect_extn_cable) { if (mbhc->current_plug == PLUG_TYPE_HEADSET) wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADSET); else if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADPHONE); } wcd9xxx_report_plug(mbhc, 1, <API key>); <API key>(mbhc); } else if (plug_type == PLUG_TYPE_HEADSET) { if (mbhc->mbhc_cfg-><API key>) { /* * Do not report Headset, because at this point * it could be a ANC headphone having two mics. * So, proceed further to detect if there is a * second mic. */ mbhc->scaling_mux_in = 0x08; anc_mic_found = <API key>(mbhc); } if (anc_mic_found) { /* Report ANC headphone */ wcd9xxx_report_plug(mbhc, 1, <API key>); } else { /* * If Headphone was reported previously, this will * only report the mic line */ wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADSET); } /* Button detection required RC oscillator */ <API key>(mbhc, true); /* * sleep so that audio path completely tears down * before report plug insertion to the user space */ msleep(100); <API key>(mbhc); } else if (plug_type == PLUG_TYPE_HIGH_HPH) { if (mbhc->mbhc_cfg->detect_extn_cable) { /* High impedance device found. Report as LINEOUT*/ if (mbhc->current_plug == PLUG_TYPE_NONE) wcd9xxx_report_plug(mbhc, 1, SND_JACK_LINEOUT); <API key>(mbhc); pr_debug("%s: setup mic trigger for further detection\n", __func__); mbhc->lpi_enabled = true; /* * Do not enable HPHL trigger. If playback is active, * it might lead to continuous false HPHL triggers */ <API key>(mbhc, 1, MBHC_USE_MB_TRIGGER, false); } else { if (mbhc->current_plug == PLUG_TYPE_NONE) wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); <API key>(mbhc); pr_debug("setup mic trigger for further detection\n"); mbhc->lpi_enabled = true; <API key>(mbhc, 1, MBHC_USE_MB_TRIGGER | <API key>, false); } } else { WARN(1, "Unexpected current plug_type %d, plug_type %d\n", mbhc->current_plug, plug_type); } pr_debug("%s: leave\n", __func__); } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { enum <API key> plug_type; bool <API key>; pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); <API key> = (((mbhc->mbhc_cfg->cs_enable_flags & (1 << <API key>)) != 0) && (!(snd_soc_read(mbhc->codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80))); mbhc->scaling_mux_in = 0x04; if (<API key>) { <API key>(mbhc, &mbhc->mbhc_bias_regs, true, false); plug_type = <API key>(mbhc, false); /* * For other plug types, the current source disable * will be done from <API key> */ if (plug_type == PLUG_TYPE_HEADSET) <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); } else { <API key>(mbhc, true); plug_type = <API key>(mbhc, true); <API key>(mbhc, false); } if (<API key>(mbhc)) { if (<API key> && mbhc->is_cs_enabled) { <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); } pr_debug("%s: Switch level is low when determining plug\n", __func__); return; } if (plug_type == PLUG_TYPE_INVALID || plug_type == <API key>) { <API key>(mbhc); <API key>(mbhc, &mbhc->correct_plug_swch); } else if (plug_type == PLUG_TYPE_HEADPHONE) { wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); <API key>(mbhc); <API key>(mbhc, &mbhc->correct_plug_swch); } else if (plug_type == PLUG_TYPE_HIGH_HPH) { <API key>(mbhc); <API key>(mbhc, &mbhc->correct_plug_swch); } else { pr_debug("%s: Valid plug found, determine plug type %d\n", __func__, plug_type); <API key>(mbhc, plug_type); } pr_debug("%s: leave\n", __func__); } /* called under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); if (<API key>(mbhc)) pr_debug("%s: Switch level low when determining plug\n", __func__); else <API key>(mbhc); pr_debug("%s: leave\n", __func__); } /* called only from interrupt which is under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc, bool is_removal) { if (!is_removal) { pr_debug("%s: MIC trigger insertion interrupt\n", __func__); rmb(); if (mbhc->lpi_enabled) msleep(100); rmb(); if (!mbhc->lpi_enabled) { pr_debug("%s: lpi is disabled\n", __func__); } else if (!<API key>(mbhc)) { pr_debug("%s: Valid insertion, detect plug type\n", __func__); <API key>(mbhc); } else { pr_debug("%s: Invalid insertion stop plug detection\n", __func__); } } else if (mbhc->mbhc_cfg->detect_extn_cable) { pr_debug("%s: Removal\n", __func__); if (!<API key>(mbhc)) { /* * Switch indicates, something is still inserted. * This could be extension cable i.e. headset is * removed from extension cable. */ /* cancel detect plug */ <API key>(mbhc, &mbhc->correct_plug_swch); <API key>(mbhc); } } else { pr_err("%s: Switch IRQ used, invalid MBHC Removal\n", __func__); } } static bool <API key>(struct wcd9xxx_mbhc *mbhc, s32 mic_mv, bool cs_enable) { const struct <API key> *plug_type = <API key>(mbhc->mbhc_cfg->calibration); const s16 v_hs_max = <API key>(mbhc); if (cs_enable) return ((mic_mv > WCD9XXX_V_CS_NO_MIC) && (mic_mv < WCD9XXX_V_CS_HS_MAX)) ? true : false; else return (!(mic_mv > <API key> && mic_mv < <API key>) && (mic_mv > plug_type->v_no_mic) && (mic_mv < v_hs_max)) ? true : false; } /* * called under codec_resource_lock acquisition * returns true if mic voltage range is back to normal insertion * returns false either if timedout or removed */ static bool <API key>(struct wcd9xxx_mbhc *mbhc) { int i; bool timedout, settled = false; s32 mic_mv[NUM_DCE_PLUG_DETECT]; short mb_v[NUM_DCE_PLUG_DETECT]; unsigned long retry = 0, timeout; bool cs_enable; cs_enable = (((mbhc->mbhc_cfg->cs_enable_flags & (1 << <API key>)) != 0) && (!(snd_soc_read(mbhc->codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80))); if (cs_enable) <API key>(mbhc, &mbhc->mbhc_bias_regs, true, false); timeout = jiffies + msecs_to_jiffies(<API key>); while (!(timedout = time_after(jiffies, timeout))) { retry++; if (<API key>(mbhc)) { pr_debug("%s: Switch indicates removal\n", __func__); break; } if (retry > 1) msleep(250); else msleep(50); if (<API key>(mbhc)) { pr_debug("%s: Switch indicates removal\n", __func__); break; } if (cs_enable) { for (i = 0; i < NUM_DCE_PLUG_DETECT; i++) { mb_v[i] = <API key>(mbhc, 1, true, true); mic_mv[i] = <API key>(mbhc, true, mb_v[i], mbhc->mbhc_data.dce_nsc_cs_z, (u32)VDDIO_MICBIAS_MV); pr_debug("%s : DCE run %lu, mic_mv = %d(%x)\n", __func__, retry, mic_mv[i], mb_v[i]); } } else { for (i = 0; i < NUM_DCE_PLUG_DETECT; i++) { mb_v[i] = <API key>(mbhc, 1, true); mic_mv[i] = <API key>(mbhc, 1, mb_v[i]); pr_debug("%s : DCE run %lu, mic_mv = %d(%x)\n", __func__, retry, mic_mv[i], mb_v[i]); } } if (<API key>(mbhc)) { pr_debug("%s: Switcn indicates removal\n", __func__); break; } if (mbhc->current_plug == PLUG_TYPE_NONE) { pr_debug("%s : headset/headphone is removed\n", __func__); break; } for (i = 0; i < NUM_DCE_PLUG_DETECT; i++) if (!<API key>(mbhc, mic_mv[i], cs_enable)) break; if (i == NUM_DCE_PLUG_DETECT) { pr_debug("%s: MIC voltage settled\n", __func__); settled = true; msleep(200); break; } } if (cs_enable) <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); if (timedout) pr_debug("%s: Microphone did not settle in %d seconds\n", __func__, <API key>); return settled; } /* called only from interrupt which is under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); if (<API key>(mbhc)) <API key>(mbhc); pr_debug("%s: leave\n", __func__); } /* called only from interrupt which is under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc) { s16 dce, dcez; unsigned long timeout; bool removed = true; struct snd_soc_codec *codec = mbhc->codec; const struct <API key> *generic = <API key>(mbhc->mbhc_cfg->calibration); bool cs_enable; s16 cur_v_ins_h; u32 mb_mv; pr_debug("%s: enter\n", __func__); if (mbhc->current_plug != PLUG_TYPE_HEADSET && mbhc->current_plug != <API key>) { pr_debug("%s(): Headset is not inserted, ignore removal\n", __func__); snd_soc_update_bits(codec, <API key>, 0x08, 0x08); return; } usleep_range(generic->t_shutdown_plug_rem, generic->t_shutdown_plug_rem + <API key>); /* If micbias is enabled, don't enable current source */ cs_enable = (((mbhc->mbhc_cfg->cs_enable_flags & (1 << <API key>)) != 0) && (!(snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80))); if (cs_enable) <API key>(mbhc, &mbhc->mbhc_bias_regs, true, false); timeout = jiffies + msecs_to_jiffies(<API key>); do { if (cs_enable) { dce = <API key>(mbhc, 1, true, true); dcez = mbhc->mbhc_data.dce_nsc_cs_z; mb_mv = VDDIO_MICBIAS_MV; } else { dce = <API key>(mbhc, 1, true); dcez = mbhc->mbhc_data.dce_z; mb_mv = mbhc->mbhc_data.micb_mv; } pr_debug("%s: DCE 0x%x,%d\n", __func__, dce, <API key>(mbhc, true, dce, dcez, mb_mv)); cur_v_ins_h = cs_enable ? (s16) mbhc->mbhc_data.v_cs_ins_h : (<API key>(mbhc, <API key>)); if (dce < cur_v_ins_h) { removed = false; break; } } while (!time_after(jiffies, timeout)); pr_debug("%s: headset %sactually removed\n", __func__, removed ? "" : "not "); if (cs_enable) <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); if (removed) { if (mbhc->mbhc_cfg->detect_extn_cable) { if (!<API key>(mbhc)) { /* * extension cable is still plugged in * report it as LINEOUT device */ if (mbhc->hph_status == SND_JACK_HEADSET) <API key>(mbhc, false); wcd9xxx_report_plug(mbhc, 1, SND_JACK_LINEOUT); <API key>(mbhc); <API key>(mbhc, 1, MBHC_USE_MB_TRIGGER, false); } } else { /* Cancel possibly running hs_detect_work */ <API key>(mbhc, &mbhc->correct_plug_noswch); /* * If this removal is not false, first check the micbias * switch status and switch it to LDOH if it is already * switched to VDDIO. */ <API key>(mbhc, 0); wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADSET); <API key>(mbhc, false); <API key>(mbhc); <API key>(mbhc, 1, MBHC_USE_MB_TRIGGER | <API key>, true); } } else { <API key>(mbhc); } pr_debug("%s: leave\n", __func__); } /* called only from interrupt which is under codec_resource_lock acquisition */ static void <API key>(struct wcd9xxx_mbhc *mbhc, bool is_mb_trigger) { /* Cancel possibly running hs_detect_work */ <API key>(mbhc, &mbhc->correct_plug_swch); if (is_mb_trigger) { pr_debug("%s: Waiting for Headphone left trigger\n", __func__); <API key>(mbhc, 1, <API key>, false); } else { pr_debug("%s: HPHL trigger received, detecting plug type\n", __func__); <API key>(mbhc); } } static irqreturn_t <API key>(int irq, void *data) { struct wcd9xxx_mbhc *mbhc = data; pr_debug("%s: enter, removal interrupt\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); /* * While we don't know whether MIC is there or not, let the resmgr know * so micbias can be disabled temporarily */ if (mbhc->current_plug == PLUG_TYPE_HEADSET) { <API key>(mbhc->resmgr, <API key>, false); <API key>(mbhc->resmgr, WCD9XXX_COND_HPH, false); } else if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) { <API key>(mbhc->resmgr, WCD9XXX_COND_HPH, false); } if (mbhc->mbhc_cfg->detect_extn_cable && !<API key>(mbhc)) <API key>(mbhc); else <API key>(mbhc); if (mbhc->current_plug == PLUG_TYPE_HEADSET) { <API key>(mbhc->resmgr, WCD9XXX_COND_HPH, true); <API key>(mbhc->resmgr, <API key>, true); } else if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) { <API key>(mbhc->resmgr, WCD9XXX_COND_HPH, true); } WCD9XXX_BCL_UNLOCK(mbhc->resmgr); return IRQ_HANDLED; } static irqreturn_t <API key>(int irq, void *data) { bool is_mb_trigger, is_removal; struct wcd9xxx_mbhc *mbhc = data; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); wcd9xxx_disable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->insertion); is_mb_trigger = !!(snd_soc_read(codec, mbhc->mbhc_bias_regs.mbhc_reg) & 0x10); is_removal = !!(snd_soc_read(codec, <API key>) & 0x02); snd_soc_update_bits(codec, <API key>, 0x03, 0x00); /* Turn off both HPH and MIC line schmitt triggers */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x90, 0x00); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x13, 0x00); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); if (mbhc->mbhc_cfg->detect_extn_cable && mbhc->current_plug == PLUG_TYPE_HIGH_HPH) <API key>(mbhc, is_mb_trigger); else <API key>(mbhc, is_removal); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); return IRQ_HANDLED; } static void <API key>(struct work_struct *work) { struct delayed_work *dwork; short bias_value; int dce_mv, sta_mv; struct wcd9xxx_mbhc *mbhc; pr_debug("%s:\n", __func__); dwork = to_delayed_work(work); mbhc = container_of(dwork, struct wcd9xxx_mbhc, mbhc_btn_dwork); bias_value = <API key>(mbhc->codec); sta_mv = <API key>(mbhc, 0, bias_value); bias_value = <API key>(mbhc->codec); dce_mv = <API key>(mbhc, 1, bias_value); pr_debug("%s: STA: %d, DCE: %d\n", __func__, sta_mv, dce_mv); pr_debug("%s: Reporting long button press event\n", __func__); wcd9xxx_jack_report(mbhc, &mbhc->button_jack, mbhc->buttons_pressed, mbhc->buttons_pressed); pr_debug("%s: leave\n", __func__); <API key>(mbhc->resmgr->core_res); } static void <API key>(struct work_struct *work) { struct delayed_work *dwork; struct wcd9xxx_mbhc *mbhc; struct snd_soc_codec *codec; struct <API key> *core_res; dwork = to_delayed_work(work); mbhc = container_of(dwork, struct wcd9xxx_mbhc, mbhc_insert_dwork); codec = mbhc->codec; core_res = mbhc->resmgr->core_res; pr_debug("%s:\n", __func__); /* Turn off both HPH and MIC line schmitt triggers */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x90, 0x00); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x13, 0x00); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); <API key>(core_res, mbhc->intr_ids->insertion); <API key>(mbhc); <API key>(core_res); } static bool <API key>(const void *data, size_t size) { u32 cfg_offset; struct <API key> *imped_cfg; struct <API key> *btn_cfg; struct firmware_cal fw; fw.data = (void *)data; fw.size = size; if (fw.size < <API key>) return false; /* * Previous check guarantees that there is enough fw data up * to num_btn */ btn_cfg = <API key>(fw.data); cfg_offset = (u32) ((void *) btn_cfg - (void *) fw.data); if (fw.size < (cfg_offset + <API key>(btn_cfg))) return false; /* * Previous check guarantees that there is enough fw data up * to start of impedance detection configuration */ imped_cfg = <API key>(fw.data); cfg_offset = (u32) ((void *) imped_cfg - (void *) fw.data); if (fw.size < (cfg_offset + <API key>)) return false; if (fw.size < (cfg_offset + <API key>(imped_cfg))) return false; return true; } static u16 <API key>(struct wcd9xxx_mbhc *mbhc, enum meas_type dce, s16 vin_mv, bool cs_enable) { s16 diff, zero; u32 mb_mv, in; u16 value; s16 dce_z; mb_mv = mbhc->mbhc_data.micb_mv; dce_z = mbhc->mbhc_data.dce_z; if (mb_mv == 0) { pr_err("%s: Mic Bias voltage is set to zero\n", __func__); return -EINVAL; } if (cs_enable) { mb_mv = VDDIO_MICBIAS_MV; dce_z = mbhc->mbhc_data.dce_nsc_cs_z; } if (dce) { diff = (mbhc->mbhc_data.dce_mb) - (dce_z); zero = (dce_z); } else { diff = (mbhc->mbhc_data.sta_mb) - (mbhc->mbhc_data.sta_z); zero = (mbhc->mbhc_data.sta_z); } in = (u32) diff * vin_mv; value = (u16) (in / mb_mv) + zero; return value; } static void <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec; s16 adj_v_hs_max; s16 btn_mv = 0, btn_mv_sta[MBHC_V_IDX_NUM], btn_mv_dce[MBHC_V_IDX_NUM]; struct <API key> *btn_det; struct <API key> *plug_type; u16 *btn_high; int i; pr_debug("%s: enter\n", __func__); codec = mbhc->codec; btn_det = <API key>(mbhc->mbhc_cfg->calibration); plug_type = <API key>(mbhc->mbhc_cfg->calibration); mbhc->mbhc_data.v_ins_hu[MBHC_V_IDX_CFILT] = <API key>(mbhc, STA, plug_type->v_hs_max, false); mbhc->mbhc_data.v_ins_h[MBHC_V_IDX_CFILT] = <API key>(mbhc, DCE, plug_type->v_hs_max, false); mbhc->mbhc_data.v_inval_ins_low = FAKE_INS_LOW; mbhc->mbhc_data.v_inval_ins_high = FAKE_INS_HIGH; if (mbhc->mbhc_data.micb_mv != VDDIO_MICBIAS_MV) { adj_v_hs_max = scale_v_micb_vddio(mbhc, plug_type->v_hs_max, true); mbhc->mbhc_data.v_ins_hu[MBHC_V_IDX_VDDIO] = <API key>(mbhc, STA, adj_v_hs_max, false); mbhc->mbhc_data.v_ins_h[MBHC_V_IDX_VDDIO] = <API key>(mbhc, DCE, adj_v_hs_max, false); mbhc->mbhc_data.v_inval_ins_low = scale_v_micb_vddio(mbhc, mbhc->mbhc_data.v_inval_ins_low, false); mbhc->mbhc_data.v_inval_ins_high = scale_v_micb_vddio(mbhc, mbhc->mbhc_data.v_inval_ins_high, false); } mbhc->mbhc_data.v_cs_ins_h = <API key>(mbhc, DCE, WCD9XXX_V_CS_HS_MAX, true); pr_debug("%s: v_ins_h for current source: 0x%x\n", __func__, mbhc->mbhc_data.v_cs_ins_h); btn_high = <API key>(btn_det, <API key>); for (i = 0; i < btn_det->num_btn; i++) btn_mv = btn_high[i] > btn_mv ? btn_high[i] : btn_mv; btn_mv_sta[MBHC_V_IDX_CFILT] = btn_mv + btn_det-><API key>; btn_mv_dce[MBHC_V_IDX_CFILT] = btn_mv + btn_det-><API key>; btn_mv_sta[MBHC_V_IDX_VDDIO] = scale_v_micb_vddio(mbhc, btn_mv_sta[MBHC_V_IDX_CFILT], true); btn_mv_dce[MBHC_V_IDX_VDDIO] = scale_v_micb_vddio(mbhc, btn_mv_dce[MBHC_V_IDX_CFILT], true); mbhc->mbhc_data.v_b1_hu[MBHC_V_IDX_CFILT] = <API key>(mbhc, STA, btn_mv_sta[MBHC_V_IDX_CFILT], false); mbhc->mbhc_data.v_b1_h[MBHC_V_IDX_CFILT] = <API key>(mbhc, DCE, btn_mv_dce[MBHC_V_IDX_CFILT], false); mbhc->mbhc_data.v_b1_hu[MBHC_V_IDX_VDDIO] = <API key>(mbhc, STA, btn_mv_sta[MBHC_V_IDX_VDDIO], false); mbhc->mbhc_data.v_b1_h[MBHC_V_IDX_VDDIO] = <API key>(mbhc, DCE, btn_mv_dce[MBHC_V_IDX_VDDIO], false); mbhc->mbhc_data.v_brh[MBHC_V_IDX_CFILT] = mbhc->mbhc_data.v_b1_h[MBHC_V_IDX_CFILT]; mbhc->mbhc_data.v_brh[MBHC_V_IDX_VDDIO] = mbhc->mbhc_data.v_b1_h[MBHC_V_IDX_VDDIO]; mbhc->mbhc_data.v_brl = BUTTON_MIN; mbhc->mbhc_data.v_no_mic = <API key>(mbhc, STA, plug_type->v_no_mic, false); pr_debug("%s: leave\n", __func__); } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool on) { /* * XXX: {codec}_mclk_enable holds WCD9XXX_BCL_LOCK, * therefore <API key> caller SHOULDN'T hold * WCD9XXX_BCL_LOCK when it calls <API key>() */ if (mbhc && mbhc->mbhc_cfg && mbhc->mbhc_cfg->mclk_cb_fn) mbhc->mbhc_cfg->mclk_cb_fn(mbhc->codec, on, false); } /* * Mic Bias Enable Decision * Return true if high_hph_cnt is a power of 2 (!= 2) * otherwise return false */ static bool <API key>(int high_hph_cnt) { return (high_hph_cnt > 2) && !(high_hph_cnt & (high_hph_cnt - 1)); } static inline void <API key>(struct wcd9xxx_mbhc *mbhc, int pt_gnd_mic_swap_cnt, enum <API key> plug_type) { if (mbhc->mbhc_cfg->swap_gnd_mic && (pt_gnd_mic_swap_cnt == <API key>)) { /* * if switch is toggled, check again, * otherwise report unsupported plug */ mbhc->mbhc_cfg->swap_gnd_mic(mbhc->codec); } else if (pt_gnd_mic_swap_cnt >= <API key>) { /* Report UNSUPPORTED plug * and continue polling */ WCD9XXX_BCL_LOCK(mbhc->resmgr); if (!mbhc->mbhc_cfg->detect_extn_cable) { if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADPHONE); else if (mbhc->current_plug == PLUG_TYPE_HEADSET) wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADSET); } if (mbhc->current_plug != plug_type) wcd9xxx_report_plug(mbhc, 1, <API key>); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } } static void <API key>(struct work_struct *work) { struct wcd9xxx_mbhc *mbhc; struct snd_soc_codec *codec; enum <API key> plug_type = PLUG_TYPE_INVALID; unsigned long timeout; int retry = 0, pt_gnd_mic_swap_cnt = 0, invalid_cnt = 0; int highhph_cnt = 0; bool correction = false; bool <API key>; bool wrk_complete = true, highhph = false; pr_debug("%s: enter\n", __func__); mbhc = container_of(work, struct wcd9xxx_mbhc, correct_plug_swch); codec = mbhc->codec; <API key> = (((mbhc->mbhc_cfg->cs_enable_flags & (1 << <API key>)) != 0) && (!(snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80))); <API key>(mbhc, true); /* * Keep override on during entire plug type correction work. * * This is okay under the assumption that any switch irqs which use * MBHC block cancel and sync this work so override is off again * prior to switch interrupt handler's MBHC block usage. * Also while this correction work is running, we can guarantee * DAPM doesn't use any MBHC block as this work only runs with * headphone detection. */ if (<API key>) { WCD9XXX_BCL_LOCK(mbhc->resmgr); <API key>(mbhc, &mbhc->mbhc_bias_regs, true, false); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } else { <API key>(mbhc, true); } timeout = jiffies + msecs_to_jiffies(<API key>); while (!time_after(jiffies, timeout)) { ++retry; rmb(); if (mbhc->hs_detect_work_stop) { wrk_complete = false; pr_debug("%s: stop requested\n", __func__); break; } msleep(<API key>); if (<API key>(mbhc)) { wrk_complete = false; pr_debug("%s: Switch level is low\n", __func__); break; } /* can race with removal interrupt */ WCD9XXX_BCL_LOCK(mbhc->resmgr); if (<API key>) #ifndef VENDOR_EDIT /*wangdongdong@MultiMedia.AudioDrv,2015/05/27,modify for chinese headset detection*/ plug_type = <API key>(mbhc, highhph); #else plug_type = <API key>(mbhc,true); #endif else plug_type = <API key>(mbhc, true); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); pr_debug("%s: attempt(%d) current_plug(%d) new_plug(%d)\n", __func__, retry, mbhc->current_plug, plug_type); highhph_cnt = (plug_type == PLUG_TYPE_HIGH_HPH) ? (highhph_cnt + 1) : 0; highhph = <API key>(highhph_cnt); if (plug_type == PLUG_TYPE_INVALID) { invalid_cnt++; pr_debug("Invalid plug in attempt # %d count %d\n", retry,invalid_cnt); if (!mbhc->mbhc_cfg->detect_extn_cable && retry == <API key> && mbhc->current_plug == PLUG_TYPE_NONE) { WCD9XXX_BCL_LOCK(mbhc->resmgr); wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } else if (invalid_cnt == <API key>) { pr_debug("invalit_cnt = 10 report unsupported\n"); WCD9XXX_BCL_LOCK(mbhc->resmgr); wcd9xxx_report_plug(mbhc, 1, <API key>); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } } else if (plug_type == PLUG_TYPE_HEADPHONE) { pr_debug("Good headphone detected, continue polling\n"); WCD9XXX_BCL_LOCK(mbhc->resmgr); if (mbhc->mbhc_cfg->detect_extn_cable) { if (mbhc->current_plug != plug_type) wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); } else if (mbhc->current_plug == PLUG_TYPE_NONE) { wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); } WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } else if (plug_type == PLUG_TYPE_HIGH_HPH) { pr_debug("%s: High HPH detected, continue polling\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); if (mbhc->mbhc_cfg->detect_extn_cable) { if (mbhc->current_plug != plug_type) wcd9xxx_report_plug(mbhc, 1, SND_JACK_LINEOUT); } else if (mbhc->current_plug == PLUG_TYPE_NONE) { wcd9xxx_report_plug(mbhc, 1, SND_JACK_HEADPHONE); } WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } else { if (plug_type == <API key>) { pt_gnd_mic_swap_cnt++; if (pt_gnd_mic_swap_cnt >= <API key>) <API key>(mbhc, pt_gnd_mic_swap_cnt, plug_type); pr_debug("%s: unsupported HS detected, continue polling\n", __func__); continue; } else { pt_gnd_mic_swap_cnt = 0; WCD9XXX_BCL_LOCK(mbhc->resmgr); /* Turn off override/current source */ if (<API key>) <API key>(mbhc, &mbhc->mbhc_bias_regs, false, false); else <API key>(mbhc, false); /* * The valid plug also includes * <API key> */ <API key>(mbhc, plug_type); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); pr_debug("Attempt %d found correct plug %d\n", retry, plug_type); correction = true; } break; } } highhph = false; if (wrk_complete && plug_type == PLUG_TYPE_HIGH_HPH) { pr_debug("%s: polling is done, still HPH, so enabling MIC trigger\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); <API key>(mbhc, plug_type); highhph = true; WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } if (plug_type == PLUG_TYPE_HEADPHONE) { if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec, true); } if (!correction && <API key>) { WCD9XXX_BCL_LOCK(mbhc->resmgr); <API key>(mbhc, &mbhc->mbhc_bias_regs, false, highhph); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } else if (!correction) { <API key>(mbhc, false); } <API key>(mbhc, false); if (mbhc->mbhc_cfg->detect_extn_cable) { WCD9XXX_BCL_LOCK(mbhc->resmgr); if ((mbhc->current_plug == PLUG_TYPE_HEADPHONE && wrk_complete) || mbhc->current_plug == <API key> || mbhc->current_plug == PLUG_TYPE_INVALID || (plug_type == PLUG_TYPE_INVALID && wrk_complete)) { /* Enable removal detection */ <API key>(mbhc); <API key>(mbhc, 0, 0, false); } WCD9XXX_BCL_UNLOCK(mbhc->resmgr); } pr_debug("%s: leave current_plug(%d)\n", __func__, mbhc->current_plug); /* unlock sleep */ <API key>(mbhc->resmgr->core_res); } static void <API key>(struct wcd9xxx_mbhc *mbhc) { bool insert; bool is_removed = false; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); mbhc->in_swch_irq_handler = true; /* Wait here for debounce time */ usleep_range(<API key>, <API key> + <API key>); WCD9XXX_BCL_LOCK(mbhc->resmgr); /* cancel pending button press */ if (<API key>(mbhc)) pr_debug("%s: button press is canceled\n", __func__); insert = !<API key>(mbhc); pr_debug("%s: Current plug type %d, insert %d\n", __func__, mbhc->current_plug, insert); if ((mbhc->current_plug == PLUG_TYPE_NONE) && insert) { mbhc->lpi_enabled = false; wmb(); /* cancel detect plug */ <API key>(mbhc, &mbhc->correct_plug_swch); if ((mbhc->current_plug != PLUG_TYPE_NONE) && (mbhc->current_plug != PLUG_TYPE_HIGH_HPH) && !(snd_soc_read(codec, <API key>) & (1 << 1))) { pr_debug("%s: current plug: %d\n", __func__, mbhc->current_plug); goto exit; } /* Disable Mic Bias pull down and HPH Switch to GND */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x01, 0x00); <API key>(mbhc); } else if ((mbhc->current_plug != PLUG_TYPE_NONE) && !insert) { mbhc->lpi_enabled = false; wmb(); /* cancel detect plug */ <API key>(mbhc, &mbhc->correct_plug_swch); if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) { wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADPHONE); is_removed = true; } else if (mbhc->current_plug == <API key>) { wcd9xxx_report_plug(mbhc, 0, <API key>); is_removed = true; } else if (mbhc->current_plug == PLUG_TYPE_HEADSET) { <API key>(mbhc); <API key>(mbhc, false); <API key>(mbhc); wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADSET); is_removed = true; } else if (mbhc->current_plug == PLUG_TYPE_HIGH_HPH) { wcd9xxx_report_plug(mbhc, 0, SND_JACK_LINEOUT); is_removed = true; } else if (mbhc->current_plug == <API key>) { <API key>(mbhc); <API key>(mbhc, false); <API key>(mbhc); wcd9xxx_report_plug(mbhc, 0, <API key>); is_removed = true; } if (is_removed) { snd_soc_write(codec, <API key>, 0x00); snd_soc_update_bits(codec, <API key>, 0x02, 0x00); /* Enable Mic Bias pull down and HPH Switch to GND */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x01, 0x01); /* Make sure mic trigger is turned off */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.mbhc_reg, 0x90, 0x00); /* Reset MBHC State Machine */ snd_soc_update_bits(codec, <API key>, 0x08, 0x08); snd_soc_update_bits(codec, <API key>, 0x08, 0x00); /* Turn off override */ <API key>(mbhc, false); } } exit: mbhc->in_swch_irq_handler = false; WCD9XXX_BCL_UNLOCK(mbhc->resmgr); pr_debug("%s: leave\n", __func__); } static irqreturn_t <API key>(int irq, void *data) { int r = IRQ_HANDLED; struct wcd9xxx_mbhc *mbhc = data; pr_debug("%s: enter\n", __func__); if (unlikely(wcd9xxx_lock_sleep(mbhc->resmgr->core_res) == false)) { pr_warn("%s: failed to hold suspend\n", __func__); r = IRQ_NONE; } else { /* Call handler */ <API key>(mbhc); <API key>(mbhc->resmgr->core_res); } pr_debug("%s: leave %d\n", __func__, r); return r; } static int <API key>(struct wcd9xxx_mbhc *mbhc) { s16 mb_v; int i = 0; int r = 0; const s16 v_ins_hu = <API key>(mbhc, <API key>); const s16 v_ins_h = <API key>(mbhc, <API key>); const s16 v_b1_hu = <API key>(mbhc, <API key>); const s16 v_b1_h = <API key>(mbhc, <API key>); const unsigned long timeout = jiffies + msecs_to_jiffies(<API key>); while (time_before(jiffies, timeout)) { /* * This function needs to run measurements just few times during * release debounce time. Make 1ms interval to avoid * unnecessary excessive measurements. */ usleep_range(1000, 1000 + <API key>); if (i == 0) { mb_v = <API key>(mbhc, 0, true); pr_debug("%s: STA[0]: %d,%d\n", __func__, mb_v, <API key>(mbhc, 0, mb_v)); if (mb_v < v_b1_hu || mb_v > v_ins_hu) { r = 1; break; } } else { mb_v = <API key>(mbhc, 1, true); pr_debug("%s: DCE[%d]: %d,%d\n", __func__, i, mb_v, <API key>(mbhc, 1, mb_v)); if (mb_v < v_b1_h || mb_v > v_ins_h) { r = 1; break; } } i++; } return r; } /* called under codec_resource_lock acquisition */ static int <API key>(const struct wcd9xxx_mbhc *mbhc, const s32 micmv) { s16 *v_btn_low, *v_btn_high; struct <API key> *btn_det; int i, btn = -1; btn_det = <API key>(mbhc->mbhc_cfg->calibration); v_btn_low = <API key>(btn_det, <API key>); v_btn_high = <API key>(btn_det, <API key>); for (i = 0; i < btn_det->num_btn; i++) { if ((v_btn_low[i] <= micmv) && (v_btn_high[i] >= micmv)) { btn = i; break; } } if (btn == -1) pr_debug("%s: couldn't find button number for mic mv %d\n", __func__, micmv); return btn; } static int <API key>(const int btn) { int mask = 0; switch (btn) { case 0: mask = SND_JACK_BTN_0; break; case 1: mask = SND_JACK_BTN_1; break; case 2: mask = SND_JACK_BTN_2; break; case 3: mask = SND_JACK_BTN_3; break; case 4: mask = SND_JACK_BTN_4; break; case 5: mask = SND_JACK_BTN_5; break; case 6: mask = SND_JACK_BTN_6; break; case 7: mask = SND_JACK_BTN_7; break; } return mask; } static void wcd9xxx_get_z(struct wcd9xxx_mbhc *mbhc, s16 *dce_z, s16 *sta_z, struct mbhc_micbias_regs *micb_regs, bool norel_detection) { s16 reg0, reg1; int change; struct snd_soc_codec *codec = mbhc->codec; <API key>(mbhc->resmgr); /* Pull down micbias to ground and disconnect vddio switch */ reg0 = snd_soc_read(codec, micb_regs->ctl_reg); snd_soc_update_bits(codec, micb_regs->ctl_reg, 0x81, 0x1); reg1 = snd_soc_read(codec, micb_regs->mbhc_reg); snd_soc_update_bits(codec, micb_regs->mbhc_reg, 1 << 7, 0); /* Disconnect override from micbias */ change = snd_soc_update_bits(codec, <API key>, 1 << 4, 1 << 0); usleep_range(1000, 1000 + 1000); if (sta_z) { *sta_z = <API key>(mbhc, 0, norel_detection); pr_debug("%s: sta_z 0x%x\n", __func__, *sta_z & 0xFFFF); } if (dce_z) { *dce_z = <API key>(mbhc, 1, norel_detection); pr_debug("%s: dce_z 0x%x\n", __func__, *dce_z & 0xFFFF); } /* Connect override from micbias */ if (change) snd_soc_update_bits(codec, <API key>, 1 << 4, 1 << 4); /* Disable pull down micbias to ground */ snd_soc_write(codec, micb_regs->mbhc_reg, reg1); snd_soc_write(codec, micb_regs->ctl_reg, reg0); } /* * This function recalibrates dce_z and sta_z parameters. * No release detection will be false when this function is * used. */ void wcd9xxx_update_z(struct wcd9xxx_mbhc *mbhc) { const u16 sta_z = mbhc->mbhc_data.sta_z; const u16 dce_z = mbhc->mbhc_data.dce_z; wcd9xxx_get_z(mbhc, &mbhc->mbhc_data.dce_z, &mbhc->mbhc_data.sta_z, &mbhc->mbhc_bias_regs, false); pr_debug("%s: sta_z 0x%x,dce_z 0x%x -> sta_z 0x%x,dce_z 0x%x\n", __func__, sta_z & 0xFFFF, dce_z & 0xFFFF, mbhc->mbhc_data.sta_z & 0xFFFF, mbhc->mbhc_data.dce_z & 0xFFFF); <API key>(mbhc); <API key>(mbhc); } /* * <API key> : update mbhc release upper bound threshold * to ceilmv + buffer */ static int <API key>(struct wcd9xxx_mbhc *mbhc, int ceilmv, bool vddio) { u16 v_brh, v_b1_hu; int mv; struct <API key> *btn_det; void *calibration = mbhc->mbhc_cfg->calibration; struct snd_soc_codec *codec = mbhc->codec; btn_det = <API key>(calibration); mv = ceilmv + btn_det-><API key>; if (vddio) mv = scale_v_micb_vddio(mbhc, mv, true); pr_debug("%s: reprogram vb1hu/vbrh to %dmv\n", __func__, mv); if (mbhc->mbhc_state != <API key>) { /* * update LSB first so mbhc hardware block * doesn't see too low value. */ v_b1_hu = <API key>(mbhc, STA, mv, false); snd_soc_write(codec, <API key>, v_b1_hu & 0xFF); snd_soc_write(codec, <API key>, (v_b1_hu >> 8) & 0xFF); v_brh = <API key>(mbhc, DCE, mv, false); snd_soc_write(codec, <API key>, v_brh & 0xFF); snd_soc_write(codec, <API key>, (v_brh >> 8) & 0xFF); } return 0; } irqreturn_t wcd9xxx_dce_handler(int irq, void *data) { int i, mask; bool vddio; u8 mbhc_status; s16 dce_z, sta_z; s32 stamv, stamv_s; s16 *v_btn_high; struct <API key> *btn_det; int btn = -1, meas = 0; struct wcd9xxx_mbhc *mbhc = data; const struct <API key> *d = <API key>(mbhc->mbhc_cfg->calibration); short btnmeas[d->n_btn_meas + 1]; short dce[d->n_btn_meas + 1], sta; s32 mv[d->n_btn_meas + 1], mv_s[d->n_btn_meas + 1]; struct snd_soc_codec *codec = mbhc->codec; struct <API key> *core_res = mbhc->resmgr->core_res; int n_btn_meas = d->n_btn_meas; void *calibration = mbhc->mbhc_cfg->calibration; pr_debug("%s: enter\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); mutex_lock(&mbhc->mbhc_lock); mbhc_status = snd_soc_read(codec, <API key>) & 0x3E; if (mbhc->mbhc_state == <API key>) { pr_debug("%s: mbhc is being recovered, skip button press\n", __func__); goto done; } mbhc->mbhc_state = <API key>; if (!mbhc->polling_active) { pr_warn("%s: mbhc polling is not active, skip button press\n", __func__); goto done; } /* If switch nterrupt already kicked in, ignore button press */ if (mbhc->in_swch_irq_handler) { pr_debug("%s: Swtich level changed, ignore button press\n", __func__); btn = -1; goto done; } /* * setup internal micbias if codec uses internal micbias for * headset detection */ if (mbhc->mbhc_cfg->use_int_rbias) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias) mbhc->mbhc_cb->setup_int_rbias(codec, true); else pr_err("%s: internal bias requested but codec did not provide callback\n", __func__); } /* Measure scaled HW DCE */ vddio = (mbhc->mbhc_data.micb_mv != VDDIO_MICBIAS_MV && mbhc-><API key>); dce_z = mbhc->mbhc_data.dce_z; sta_z = mbhc->mbhc_data.sta_z; /* Measure scaled HW STA */ dce[0] = <API key>(codec); sta = <API key>(codec); if (mbhc_status != <API key>) { if (mbhc->mbhc_last_resume && !time_after(jiffies, mbhc->mbhc_last_resume + HZ)) { pr_debug("%s: Button is released after resume\n", __func__); n_btn_meas = 0; } else { pr_debug("%s: Button is released without resume", __func__); if (mbhc->update_z) { wcd9xxx_update_z(mbhc); dce_z = mbhc->mbhc_data.dce_z; sta_z = mbhc->mbhc_data.sta_z; mbhc->update_z = true; } stamv = <API key>(mbhc, 0, sta, sta_z, mbhc->mbhc_data.micb_mv); if (vddio) stamv_s = scale_v_micb_vddio(mbhc, stamv, false); else stamv_s = stamv; mv[0] = <API key>(mbhc, 1, dce[0], dce_z, mbhc->mbhc_data.micb_mv); mv_s[0] = vddio ? scale_v_micb_vddio(mbhc, mv[0], false) : mv[0]; btn = <API key>(mbhc, mv_s[0]); if (btn != <API key>(mbhc, stamv_s)) btn = -1; goto done; } } for (meas = 1; ((d->n_btn_meas) && (meas < (d->n_btn_meas + 1))); meas++) dce[meas] = <API key>(mbhc, 1, false); if (mbhc->update_z) { wcd9xxx_update_z(mbhc); dce_z = mbhc->mbhc_data.dce_z; sta_z = mbhc->mbhc_data.sta_z; mbhc->update_z = true; } stamv = <API key>(mbhc, 0, sta, sta_z, mbhc->mbhc_data.micb_mv); if (vddio) stamv_s = scale_v_micb_vddio(mbhc, stamv, false); else stamv_s = stamv; pr_debug("%s: Meas HW - STA 0x%x,%d,%d\n", __func__, sta & 0xFFFF, stamv, stamv_s); /* determine pressed button */ mv[0] = <API key>(mbhc, 1, dce[0], dce_z, mbhc->mbhc_data.micb_mv); mv_s[0] = vddio ? scale_v_micb_vddio(mbhc, mv[0], false) : mv[0]; btnmeas[0] = <API key>(mbhc, mv_s[0]); pr_debug("%s: Meas HW - DCE 0x%x,%d,%d button %d\n", __func__, dce[0] & 0xFFFF, mv[0], mv_s[0], btnmeas[0]); if (n_btn_meas == 0) btn = btnmeas[0]; for (meas = 1; (n_btn_meas && d->n_btn_meas && (meas < (d->n_btn_meas + 1))); meas++) { mv[meas] = <API key>(mbhc, 1, dce[meas], dce_z, mbhc->mbhc_data.micb_mv); mv_s[meas] = vddio ? scale_v_micb_vddio(mbhc, mv[meas], false) : mv[meas]; btnmeas[meas] = <API key>(mbhc, mv_s[meas]); pr_debug("%s: Meas %d - DCE 0x%x,%d,%d button %d\n", __func__, meas, dce[meas] & 0xFFFF, mv[meas], mv_s[meas], btnmeas[meas]); /* * if large enough measurements are collected, * start to check if last all n_btn_con measurements were * in same button low/high range */ if (meas + 1 >= d->n_btn_con) { for (i = 0; i < d->n_btn_con; i++) if ((btnmeas[meas] < 0) || (btnmeas[meas] != btnmeas[meas - i])) break; if (i == d->n_btn_con) { /* button pressed */ btn = btnmeas[meas]; break; } else if ((n_btn_meas - meas) < (d->n_btn_con - 1)) { /* * if left measurements are less than n_btn_con, * it's impossible to find button number */ break; } } } if (btn >= 0) { if (mbhc->in_swch_irq_handler) { pr_debug( "%s: Switch irq triggered, ignore button press\n", __func__); goto done; } btn_det = <API key>(calibration); v_btn_high = <API key>(btn_det, <API key>); WARN_ON(btn >= btn_det->num_btn); /* reprogram release threshold to catch voltage ramp up early */ <API key>(mbhc, v_btn_high[btn], vddio); mask = <API key>(btn); mbhc->buttons_pressed |= mask; wcd9xxx_lock_sleep(core_res); if (<API key>(&mbhc->mbhc_btn_dwork, msecs_to_jiffies(400)) == 0) { WARN(1, "Button pressed twice without release event\n"); <API key>(core_res); } } else { pr_debug("%s: bogus button press, too short press?\n", __func__); } done: pr_debug("%s: leave\n", __func__); mutex_unlock(&mbhc->mbhc_lock); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); return IRQ_HANDLED; } static irqreturn_t <API key>(int irq, void *data) { int ret; bool waitdebounce = true; struct wcd9xxx_mbhc *mbhc = data; pr_debug("%s: enter\n", __func__); WCD9XXX_BCL_LOCK(mbhc->resmgr); mbhc->mbhc_state = MBHC_STATE_RELEASE; if (mbhc->buttons_pressed & <API key>) { ret = <API key>(mbhc); if (ret == 0) { pr_debug("%s: Reporting long button release event\n", __func__); wcd9xxx_jack_report(mbhc, &mbhc->button_jack, 0, mbhc->buttons_pressed); } else { if (<API key>(mbhc)) { pr_debug("%s: Fake button press interrupt\n", __func__); } else { if (mbhc->in_swch_irq_handler) { pr_debug("%s: Switch irq kicked in, ignore\n", __func__); } else { pr_debug("%s: Reporting btn press\n", __func__); wcd9xxx_jack_report(mbhc, &mbhc->button_jack, mbhc->buttons_pressed, mbhc->buttons_pressed); pr_debug("%s: Reporting btn release\n", __func__); wcd9xxx_jack_report(mbhc, &mbhc->button_jack, 0, mbhc->buttons_pressed); waitdebounce = false; } } } mbhc->buttons_pressed &= ~<API key>; } <API key>(mbhc); if (waitdebounce) msleep(<API key>); <API key>(mbhc); pr_debug("%s: leave\n", __func__); WCD9XXX_BCL_UNLOCK(mbhc->resmgr); return IRQ_HANDLED; } static irqreturn_t <API key>(int irq, void *data) { struct wcd9xxx_mbhc *mbhc = data; struct snd_soc_codec *codec; pr_info("%s: received HPHL OCP irq\n", __func__); if (mbhc) { codec = mbhc->codec; if ((mbhc->hphlocp_cnt < OCP_ATTEMPT) && (!mbhc->hphrocp_cnt)) { pr_info("%s: retry\n", __func__); mbhc->hphlocp_cnt++; snd_soc_update_bits(codec, <API key>, 0x10, 0x00); snd_soc_update_bits(codec, <API key>, 0x10, 0x10); } else { wcd9xxx_disable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->hph_left_ocp); mbhc->hph_status |= SND_JACK_OC_HPHL; wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, mbhc->hph_status, WCD9XXX_JACK_MASK); } } else { pr_err("%s: Bad wcd9xxx private data\n", __func__); } return IRQ_HANDLED; } static irqreturn_t <API key>(int irq, void *data) { struct wcd9xxx_mbhc *mbhc = data; struct snd_soc_codec *codec; pr_info("%s: received HPHR OCP irq\n", __func__); codec = mbhc->codec; if ((mbhc->hphrocp_cnt < OCP_ATTEMPT) && (!mbhc->hphlocp_cnt)) { pr_info("%s: retry\n", __func__); mbhc->hphrocp_cnt++; snd_soc_update_bits(codec, <API key>, 0x10, 0x00); snd_soc_update_bits(codec, <API key>, 0x10, 0x10); } else { wcd9xxx_disable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->hph_right_ocp); mbhc->hph_status |= SND_JACK_OC_HPHR; wcd9xxx_jack_report(mbhc, &mbhc->headset_jack, mbhc->hph_status, WCD9XXX_JACK_MASK); } return IRQ_HANDLED; } static int <API key>(const int rate) { if (rate == MCLK_RATE_12288KHZ) return 0; else if (rate == MCLK_RATE_9600KHZ) return 1; else { BUG_ON(1); return -EINVAL; } } static void <API key>(struct wcd9xxx_mbhc *mbhc, u32 rate) { u32 dce_wait, sta_wait; u8 ncic, nmeas, navg; void *calibration; u8 *n_cic, *n_ready; struct <API key> *btn_det; u8 npoll = 4, nbounce_wait = 30; struct snd_soc_codec *codec = mbhc->codec; int idx = <API key>(rate); int idxmclk = <API key>(mbhc->mbhc_cfg->mclk_rate); pr_debug("%s: Updating clock rate dependents, rate = %u\n", __func__, rate); calibration = mbhc->mbhc_cfg->calibration; /* * First compute the DCE / STA wait times depending on tunable * parameters. The value is computed in microseconds */ btn_det = <API key>(calibration); n_ready = <API key>(btn_det, <API key>); n_cic = <API key>(btn_det, MBHC_BTN_DET_N_CIC); nmeas = <API key>(calibration)->n_meas; navg = <API key>(calibration)->mbhc_navg; /* ncic stays with the same what we had during calibration */ ncic = n_cic[idxmclk]; dce_wait = (1000 * 512 * ncic * (nmeas + 1)) / (rate / 1000); sta_wait = (1000 * 128 * (navg + 1)) / (rate / 1000); mbhc->mbhc_data.t_dce = dce_wait; /* give extra margin to sta for safety */ mbhc->mbhc_data.t_sta = sta_wait + 250; mbhc->mbhc_data.t_sta_dce = ((1000 * 256) / (rate / 1000) * n_ready[idx]) + 10; snd_soc_write(codec, <API key>, n_ready[idx]); snd_soc_write(codec, <API key>, ncic); if (rate == MCLK_RATE_12288KHZ) { npoll = 4; nbounce_wait = 30; } else if (rate == MCLK_RATE_9600KHZ) { npoll = 3; nbounce_wait = 23; } snd_soc_write(codec, <API key>, npoll); snd_soc_write(codec, <API key>, nbounce_wait); pr_debug("%s: leave\n", __func__); } static void wcd9xxx_mbhc_cal(struct wcd9xxx_mbhc *mbhc) { u8 cfilt_mode; u16 reg0, reg1, reg2; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); wcd9xxx_disable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); <API key>(codec, false); /* t_dce and t_sta are updated by <API key>() */ WARN_ON(!mbhc->mbhc_data.t_dce); WARN_ON(!mbhc->mbhc_data.t_sta); /* * LDOH and CFILT are already configured during pdata handling. * Only need to make sure CFILT and bandgap are in Fast mode. * Need to restore defaults once calculation is done. * * In case when Micbias is powered by external source, request * turn on the external voltage source for Calibration. */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true, false); cfilt_mode = snd_soc_read(codec, mbhc->mbhc_bias_regs.cfilt_ctl); if (mbhc->mbhc_cb && mbhc->mbhc_cb->cfilt_fast_mode) mbhc->mbhc_cb->cfilt_fast_mode(codec, mbhc); else snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, 0x40, 0x00); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(mbhc, false); /* * Micbias, CFILT, LDOH, MBHC MUX mode settings * to perform ADC calibration */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->select_cfilt) mbhc->mbhc_cb->select_cfilt(codec, mbhc); else snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x60, mbhc->mbhc_cfg->micbias << 5); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x00); snd_soc_update_bits(codec, <API key>, 0x60, 0x60); snd_soc_write(codec, <API key>, 0x78); if (mbhc->mbhc_cb && mbhc->mbhc_cb->codec_specific_cal) mbhc->mbhc_cb->codec_specific_cal(codec, mbhc); else snd_soc_update_bits(codec, <API key>, 0x04, 0x04); /* Pull down micbias to ground */ reg0 = snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 1, 1); /* Disconnect override from micbias */ reg1 = snd_soc_read(codec, <API key>); snd_soc_update_bits(codec, <API key>, 1 << 4, 1 << 0); /* Connect the MUX to micbias */ snd_soc_write(codec, <API key>, 0x02); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); /* * Hardware that has external cap can delay mic bias ramping down up * to 50ms. */ msleep(<API key>); /* DCE measurement for 0 voltage */ snd_soc_write(codec, <API key>, 0x0A); snd_soc_write(codec, <API key>, 0x02); mbhc->mbhc_data.dce_z = <API key>(mbhc, 1, true, false); /* compute dce_z for current source */ reg2 = snd_soc_read(codec, <API key>); snd_soc_update_bits(codec, <API key>, 0x78, WCD9XXX_MBHC_NSC_CS << 3); snd_soc_write(codec, <API key>, 0x0A); snd_soc_write(codec, <API key>, 0x02); mbhc->mbhc_data.dce_nsc_cs_z = <API key>(mbhc, 1, true, false); pr_debug("%s: dce_z with nsc cs: 0x%x\n", __func__, mbhc->mbhc_data.dce_nsc_cs_z); snd_soc_write(codec, <API key>, reg2); /* STA measurement for 0 voltage */ snd_soc_write(codec, <API key>, 0x0A); snd_soc_write(codec, <API key>, 0x02); mbhc->mbhc_data.sta_z = <API key>(mbhc, 0, true, false); /* Restore registers */ snd_soc_write(codec, mbhc->mbhc_bias_regs.ctl_reg, reg0); snd_soc_write(codec, <API key>, reg1); /* DCE measurment for MB voltage */ snd_soc_write(codec, <API key>, 0x0A); snd_soc_write(codec, <API key>, 0x02); snd_soc_write(codec, <API key>, 0x02); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); /* * Hardware that has external cap can delay mic bias ramping down up * to 50ms. */ msleep(<API key>); snd_soc_write(codec, <API key>, 0x04); usleep_range(mbhc->mbhc_data.t_dce, mbhc->mbhc_data.t_dce + <API key>); mbhc->mbhc_data.dce_mb = <API key>(codec); /* STA Measurement for MB Voltage */ snd_soc_write(codec, <API key>, 0x0A); snd_soc_write(codec, <API key>, 0x02); snd_soc_write(codec, <API key>, 0x02); snd_soc_write(codec, <API key>, 0x02); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); /* * Hardware that has external cap can delay mic bias ramping down up * to 50ms. */ msleep(<API key>); snd_soc_write(codec, <API key>, 0x02); usleep_range(mbhc->mbhc_data.t_sta, mbhc->mbhc_data.t_sta + <API key>); mbhc->mbhc_data.sta_mb = <API key>(codec); /* Restore default settings. */ snd_soc_update_bits(codec, <API key>, 0x04, 0x00); snd_soc_write(codec, mbhc->mbhc_bias_regs.cfilt_ctl, cfilt_mode); snd_soc_write(codec, <API key>, 0x04); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); usleep_range(100, 110); if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, false, false); if (mbhc->mbhc_cb && mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(mbhc, true); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); <API key>(codec, true); pr_debug("%s: leave\n", __func__); } static void wcd9xxx_mbhc_setup(struct wcd9xxx_mbhc *mbhc) { int n; u8 *gain; struct <API key> *generic; struct <API key> *btn_det; struct snd_soc_codec *codec = mbhc->codec; const int idx = <API key>(mbhc->mbhc_cfg->mclk_rate); pr_debug("%s: enter\n", __func__); generic = <API key>(mbhc->mbhc_cfg->calibration); btn_det = <API key>(mbhc->mbhc_cfg->calibration); for (n = 0; n < 8; n++) { snd_soc_update_bits(codec, <API key>, 0x07, n); snd_soc_write(codec, <API key>, btn_det->c[n]); } snd_soc_update_bits(codec, <API key>, 0x07, btn_det->nc); snd_soc_update_bits(codec, <API key>, 0x70, generic->mbhc_nsa << 4); snd_soc_update_bits(codec, <API key>, 0x0F, btn_det->n_meas); snd_soc_write(codec, <API key>, generic->mbhc_navg); snd_soc_update_bits(codec, <API key>, 0x80, 0x80); snd_soc_update_bits(codec, <API key>, 0x78, btn_det->mbhc_nsc << 3); if (mbhc->mbhc_cb && mbhc->mbhc_cb->get_cdc_type && mbhc->mbhc_cb->get_cdc_type() != <API key>) { if (mbhc->resmgr->reg_addr->micb_4_mbhc) snd_soc_update_bits(codec, mbhc->resmgr->reg_addr->micb_4_mbhc, 0x03, MBHC_MICBIAS2); } snd_soc_update_bits(codec, <API key>, 0x02, 0x02); snd_soc_update_bits(codec, <API key>, 0xF0, 0xF0); gain = <API key>(btn_det, MBHC_BTN_DET_GAIN); snd_soc_update_bits(codec, <API key>, 0x78, gain[idx] << 3); snd_soc_update_bits(codec, <API key>, 0x04, 0x04); pr_debug("%s: leave\n", __func__); } static int <API key>(struct wcd9xxx_mbhc *mbhc) { int ret = 0; void *core_res = mbhc->resmgr->core_res; if (mbhc->mbhc_cfg->gpio) { ret = <API key>(mbhc->mbhc_cfg->gpio_irq, NULL, <API key>, (IRQF_TRIGGER_RISING | <API key> | IRQF_DISABLED), "headset detect", mbhc); if (ret) { pr_err("%s: Failed to request gpio irq %d\n", __func__, mbhc->mbhc_cfg->gpio_irq); } else { ret = enable_irq_wake(mbhc->mbhc_cfg->gpio_irq); if (ret) pr_err("%s: Failed to enable wake up irq %d\n", __func__, mbhc->mbhc_cfg->gpio_irq); } } else if (mbhc->mbhc_cfg->insert_detect) { /* Enable HPHL_10K_SW */ snd_soc_update_bits(mbhc->codec, <API key>, 1 << 1, 1 << 1); ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->hs_jack_switch, <API key>, "Jack Detect", mbhc); if (ret) pr_err("%s: Failed to request insert detect irq %d\n", __func__, mbhc->intr_ids->hs_jack_switch); } return ret; } static int <API key>(struct wcd9xxx_mbhc *mbhc) { int ret = 0; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); /* Enable MCLK during calibration */ <API key>(mbhc, true); wcd9xxx_mbhc_setup(mbhc); wcd9xxx_mbhc_cal(mbhc); <API key>(mbhc); <API key>(mbhc, false); <API key>(mbhc); /* Enable Mic Bias pull down and HPH Switch to GND */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x01, 0x01); INIT_WORK(&mbhc->correct_plug_swch, <API key>); if (!IS_ERR_VALUE(ret)) { snd_soc_update_bits(codec, <API key>, 0x10, 0x10); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->hph_left_ocp); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->hph_right_ocp); /* Initialize mechanical mbhc */ ret = <API key>(mbhc); if (!ret && mbhc->mbhc_cfg->gpio) { /* Requested with IRQF_DISABLED */ enable_irq(mbhc->mbhc_cfg->gpio_irq); /* Bootup time detection */ <API key>(mbhc); } else if (!ret && mbhc->mbhc_cfg->insert_detect) { pr_debug("%s: Setting up codec own insert detection\n", __func__); /* Setup for insertion detection */ <API key>(mbhc, true); } } pr_debug("%s: leave\n", __func__); return ret; } static void <API key>(struct work_struct *work) { struct delayed_work *dwork; struct wcd9xxx_mbhc *mbhc; struct snd_soc_codec *codec; const struct firmware *fw; struct firmware_cal *fw_data = NULL; int ret = -1, retry = 0; bool use_default_cal = false; dwork = to_delayed_work(work); mbhc = container_of(dwork, struct wcd9xxx_mbhc, mbhc_firmware_dwork); codec = mbhc->codec; while (retry < FW_READ_ATTEMPTS) { retry++; pr_info("%s:Attempt %d to request MBHC firmware\n", __func__, retry); if (mbhc->mbhc_cb->get_hwdep_fw_cal) fw_data = mbhc->mbhc_cb->get_hwdep_fw_cal(codec, WCD9XXX_MBHC_CAL); if (!fw_data) ret = request_firmware(&fw, "wcd9320/wcd9320_mbhc.bin", codec->dev); /* * if request_firmware and hwdep cal both fail then * retry for few times before bailing out */ if ((ret != 0) && !fw_data) { usleep_range(FW_READ_TIMEOUT, FW_READ_TIMEOUT + <API key>); } else { pr_info("%s: MBHC Firmware read succesful\n", __func__); break; } } if (!fw_data) pr_info("%s: using request_firmware\n", __func__); else pr_info("%s: using hwdep cal\n", __func__); if (ret != 0 && !fw_data) { pr_err("%s: Cannot load MBHC firmware use default cal\n", __func__); use_default_cal = true; } if (!use_default_cal) { const void *data; size_t size; if (fw_data) { data = fw_data->data; size = fw_data->size; } else { data = fw->data; size = fw->size; } if (<API key>(data, size) == false) { pr_err("%s: Invalid MBHC cal data size use default cal\n", __func__); if (!fw_data) release_firmware(fw); } else { if (fw_data) { mbhc->mbhc_cfg->calibration = (void *)fw_data->data; mbhc->mbhc_cal = fw_data; } else { mbhc->mbhc_cfg->calibration = (void *)fw->data; mbhc->mbhc_fw = fw; } } } (void) <API key>(mbhc); } #ifdef CONFIG_DEBUG_FS ssize_t <API key>(struct file *file, char __user *buf, size_t count, loff_t *pos) { const int size = 768; char buffer[size]; int n = 0; struct wcd9xxx_mbhc *mbhc = file->private_data; const struct <API key> *p = &mbhc->mbhc_data; const s16 v_ins_hu = <API key>(mbhc, <API key>); const s16 v_ins_h = <API key>(mbhc, <API key>); const s16 v_b1_hu = <API key>(mbhc, <API key>); const s16 v_b1_h = <API key>(mbhc, <API key>); const s16 v_br_h = <API key>(mbhc, <API key>); n = scnprintf(buffer, size - n, "dce_z = %x(%dmv)\n", p->dce_z, <API key>(mbhc, 1, p->dce_z)); n += scnprintf(buffer + n, size - n, "dce_mb = %x(%dmv)\n", p->dce_mb, <API key>(mbhc, 1, p->dce_mb)); n += scnprintf(buffer + n, size - n, "dce_nsc_cs_z = %x(%dmv)\n", p->dce_nsc_cs_z, <API key>(mbhc, 1, p->dce_nsc_cs_z, p->dce_nsc_cs_z, VDDIO_MICBIAS_MV)); n += scnprintf(buffer + n, size - n, "sta_z = %x(%dmv)\n", p->sta_z, <API key>(mbhc, 0, p->sta_z)); n += scnprintf(buffer + n, size - n, "sta_mb = %x(%dmv)\n", p->sta_mb, <API key>(mbhc, 0, p->sta_mb)); n += scnprintf(buffer + n, size - n, "t_dce = %d\n", p->t_dce); n += scnprintf(buffer + n, size - n, "t_sta = %d\n", p->t_sta); n += scnprintf(buffer + n, size - n, "micb_mv = %dmv\n", p->micb_mv); n += scnprintf(buffer + n, size - n, "v_ins_hu = %x(%dmv)\n", v_ins_hu, <API key>(mbhc, 0, v_ins_hu)); n += scnprintf(buffer + n, size - n, "v_ins_h = %x(%dmv)\n", v_ins_h, <API key>(mbhc, 1, v_ins_h)); n += scnprintf(buffer + n, size - n, "v_b1_hu = %x(%dmv)\n", v_b1_hu, <API key>(mbhc, 0, v_b1_hu)); n += scnprintf(buffer + n, size - n, "v_b1_h = %x(%dmv)\n", v_b1_h, <API key>(mbhc, 1, v_b1_h)); n += scnprintf(buffer + n, size - n, "v_brh = %x(%dmv)\n", v_br_h, <API key>(mbhc, 1, v_br_h)); n += scnprintf(buffer + n, size - n, "v_brl = %x(%dmv)\n", p->v_brl, <API key>(mbhc, 0, p->v_brl)); n += scnprintf(buffer + n, size - n, "v_no_mic = %x(%dmv)\n", p->v_no_mic, <API key>(mbhc, 0, p->v_no_mic)); n += scnprintf(buffer + n, size - n, "v_inval_ins_low = %d\n", p->v_inval_ins_low); n += scnprintf(buffer + n, size - n, "v_inval_ins_high = %d\n", p->v_inval_ins_high); n += scnprintf(buffer + n, size - n, "Insert detect insert = %d\n", !<API key>(mbhc)); buffer[n] = 0; return <API key>(buf, count, pos, buffer, n); } static int codec_debug_open(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } static ssize_t codec_debug_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { char lbuf[32]; char *buf; int rc; struct wcd9xxx_mbhc *mbhc = filp->private_data; if (cnt > sizeof(lbuf) - 1) return -EINVAL; rc = copy_from_user(lbuf, ubuf, cnt); if (rc) return -EFAULT; lbuf[cnt] = '\0'; buf = (char *)lbuf; mbhc-><API key> = (*strsep(&buf, " ") == '0') ? false : true; return rc; } static const struct file_operations mbhc_trrs_debug_ops = { .open = codec_debug_open, .write = codec_debug_write, }; static const struct file_operations mbhc_debug_ops = { .open = codec_debug_open, .read = <API key>, }; static void <API key>(struct wcd9xxx_mbhc *mbhc) { mbhc->debugfs_poke = debugfs_create_file("TRRS", S_IFREG | S_IRUGO, NULL, mbhc, &mbhc_trrs_debug_ops); mbhc->debugfs_mbhc = debugfs_create_file("wcd9xxx_mbhc", S_IFREG | S_IRUGO, NULL, mbhc, &mbhc_debug_ops); } static void <API key>(struct wcd9xxx_mbhc *mbhc) { debugfs_remove(mbhc->debugfs_poke); debugfs_remove(mbhc->debugfs_mbhc); } #else static void <API key>(struct wcd9xxx_mbhc *mbhc) { } static void <API key>(struct wcd9xxx_mbhc *mbhc) { } #endif int wcd9xxx_mbhc_start(struct wcd9xxx_mbhc *mbhc, struct wcd9xxx_mbhc_config *mbhc_cfg) { int rc = 0; struct snd_soc_codec *codec = mbhc->codec; pr_debug("%s: enter\n", __func__); if (!codec) { pr_err("%s: no codec\n", __func__); return -EINVAL; } if (mbhc_cfg->mclk_rate != MCLK_RATE_12288KHZ && mbhc_cfg->mclk_rate != MCLK_RATE_9600KHZ) { pr_err("Error: unsupported clock rate %d\n", mbhc_cfg->mclk_rate); return -EINVAL; } /* Save mbhc config */ mbhc->mbhc_cfg = mbhc_cfg; /* Get HW specific mbhc registers' address */ <API key>(mbhc, MBHC_PRIMARY_MIC_MB); /* Get HW specific mbhc registers' address for anc */ <API key>(mbhc, MBHC_ANC_MIC_MB); /* Put CFILT in fast mode by default */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->cfilt_fast_mode) mbhc->mbhc_cb->cfilt_fast_mode(codec, mbhc); else snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, 0x40, <API key>); /* * setup internal micbias if codec uses internal micbias for * headset detection */ if (mbhc->mbhc_cfg->use_int_rbias) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias) { mbhc->mbhc_cb->setup_int_rbias(codec, true); } else { pr_info("%s: internal bias requested but codec did not provide callback\n", __func__); } } /* * If codec has specific clock gating for MBHC, * remove the clock gate */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_clock_gate) mbhc->mbhc_cb->enable_clock_gate(mbhc->codec, true); if (!mbhc->mbhc_cfg->read_fw_bin || (mbhc->mbhc_cfg->read_fw_bin && mbhc->mbhc_fw) || (mbhc->mbhc_cfg->read_fw_bin && mbhc->mbhc_cal)) { rc = <API key>(mbhc); } else { if (!mbhc->mbhc_fw || !mbhc->mbhc_cal) <API key>(&mbhc->mbhc_firmware_dwork, usecs_to_jiffies(FW_READ_TIMEOUT)); else pr_debug("%s: Skipping to read mbhc fw, 0x%p %p\n", __func__, mbhc->mbhc_fw, mbhc->mbhc_cal); } pr_debug("%s: leave %d\n", __func__, rc); return rc; } EXPORT_SYMBOL(wcd9xxx_mbhc_start); void wcd9xxx_mbhc_stop(struct wcd9xxx_mbhc *mbhc) { if (mbhc->mbhc_fw || mbhc->mbhc_cal) { <API key>(&mbhc->mbhc_firmware_dwork); if (!mbhc->mbhc_cal) release_firmware(mbhc->mbhc_fw); mbhc->mbhc_fw = NULL; mbhc->mbhc_cal = NULL; } } EXPORT_SYMBOL(wcd9xxx_mbhc_stop); static enum wcd9xxx_micbias_num <API key>(const enum <API key> event) { enum wcd9xxx_micbias_num ret; switch (event) { case <API key>: case <API key>: case <API key>: case <API key>: ret = MBHC_MICBIAS1; break; case <API key>: case <API key>: case <API key>: case <API key>: ret = MBHC_MICBIAS2; break; case <API key>: case <API key>: case <API key>: case <API key>: ret = MBHC_MICBIAS3; break; case <API key>: case <API key>: case <API key>: case <API key>: ret = MBHC_MICBIAS4; break; default: WARN_ONCE(1, "Cannot convert event %d to micbias\n", event); ret = <API key>; break; } return ret; } static int <API key>(const enum <API key> event) { int ret; switch (event) { case <API key>: case <API key>: case <API key>: case <API key>: ret = WCD9XXX_CFILT1_SEL; break; case <API key>: case <API key>: case <API key>: case <API key>: ret = WCD9XXX_CFILT2_SEL; break; case <API key>: case <API key>: case <API key>: case <API key>: ret = WCD9XXX_CFILT3_SEL; break; default: ret = -1; } return ret; } static int <API key>(struct wcd9xxx_mbhc *mbhc) { int cfilt; const struct <API key> *mb_pdata = mbhc->resmgr->micbias_pdata; switch (mbhc->mbhc_cfg->micbias) { case MBHC_MICBIAS1: cfilt = mb_pdata->bias1_cfilt_sel; break; case MBHC_MICBIAS2: cfilt = mb_pdata->bias2_cfilt_sel; break; case MBHC_MICBIAS3: cfilt = mb_pdata->bias3_cfilt_sel; break; case MBHC_MICBIAS4: cfilt = mb_pdata->bias4_cfilt_sel; break; default: cfilt = <API key>; break; } return cfilt; } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool on) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mbhc_txfe) mbhc->mbhc_cb->enable_mbhc_txfe(mbhc->codec, on); else snd_soc_update_bits(mbhc->codec, <API key>, 0x40, on ? 0x40 : 0x00); } static int <API key>(struct notifier_block *self, unsigned long val, void *data) { int ret = 0; struct wcd9xxx_mbhc *mbhc = ((struct wcd9xxx_resmgr *)data)->mbhc; struct snd_soc_codec *codec; enum <API key> event = (enum <API key>)val; pr_debug("%s: enter event %s(%d)\n", __func__, <API key>(event), event); if (!mbhc || !mbhc->mbhc_cfg) { pr_debug("mbhc not initialized\n"); return 0; } codec = mbhc->codec; mutex_lock(&mbhc->mbhc_lock); switch (event) { /* MICBIAS usage change */ case <API key>: case <API key>: case <API key>: case <API key>: if (mbhc->mbhc_cfg && mbhc->mbhc_cfg->micbias == <API key>(event)) { <API key>(mbhc, 0); /* * Enable MBHC TxFE whenever micbias is * turned ON and polling is active */ if (mbhc->polling_active) <API key>(mbhc, true); } break; case <API key>: case <API key>: case <API key>: case <API key>: if (mbhc->mbhc_cfg && mbhc->mbhc_cfg->micbias == <API key>(event) && <API key>(mbhc)) { /* if polling is on, restart it */ <API key>(mbhc); <API key>(mbhc); } break; case <API key>: case <API key>: case <API key>: case <API key>: if (mbhc->mbhc_cfg && mbhc->mbhc_cfg->micbias == <API key>(event)) { if (mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR)) <API key>(mbhc, 1); /* * Disable MBHC TxFE, in case it was enabled earlier * when micbias was enabled and polling is not active. */ if (!mbhc->polling_active) <API key>(mbhc, false); } if (mbhc->micbias_enable && mbhc->polling_active && !(snd_soc_read(mbhc->codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80)) { pr_debug("%s:Micbias turned off by recording, set up again", __func__); snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x80, 0x80); } break; /* PA usage change */ case <API key>: set_bit(MBHC_EVENT_PA_HPHL, &mbhc->event_state); if (!(snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80)) /* if micbias is not enabled, switch to vddio */ <API key>(mbhc, 1); break; case <API key>: set_bit(MBHC_EVENT_PA_HPHR, &mbhc->event_state); break; case <API key>: clear_bit(MBHC_EVENT_PA_HPHL, &mbhc->event_state); /* if HPH PAs are off, report OCP and switch back to CFILT */ clear_bit(<API key>, &mbhc->hph_pa_dac_state); clear_bit(<API key>, &mbhc->hph_pa_dac_state); if (mbhc->hph_status & SND_JACK_OC_HPHL) hphlocp_off_report(mbhc, SND_JACK_OC_HPHL); if (!(mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR | 1 << <API key>))) <API key>(mbhc, 0); break; case <API key>: clear_bit(MBHC_EVENT_PA_HPHR, &mbhc->event_state); /* if HPH PAs are off, report OCP and switch back to CFILT */ clear_bit(<API key>, &mbhc->hph_pa_dac_state); clear_bit(<API key>, &mbhc->hph_pa_dac_state); if (mbhc->hph_status & SND_JACK_OC_HPHR) hphrocp_off_report(mbhc, SND_JACK_OC_HPHL); if (!(mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR | 1 << <API key>))) <API key>(mbhc, 0); break; /* Clock usage change */ case <API key>: break; case <API key>: /* Change to lower TxAAF frequency */ snd_soc_update_bits(codec, <API key>, 1 << 4, 1 << 4); /* Re-calibrate clock rate dependent values */ <API key>(mbhc, mbhc->mbhc_cfg->mclk_rate); /* If clock source changes, stop and restart polling */ if (<API key>(mbhc)) { <API key>(mbhc); <API key>(mbhc); } break; case <API key>: /* If clock source changes, stop and restart polling */ if (<API key>(mbhc)) <API key>(mbhc); break; case <API key>: break; case <API key>: break; case <API key>: /* Change to higher TxAAF frequency */ snd_soc_update_bits(codec, <API key>, 1 << 4, 0 << 4); /* Re-calibrate clock rate dependent values */ <API key>(mbhc, mbhc->rco_clk_rate); /* If clock source changes, stop and restart polling */ if (<API key>(mbhc)) { <API key>(mbhc); <API key>(mbhc); } break; case <API key>: /* If clock source changes, stop and restart polling */ if (<API key>(mbhc)) <API key>(mbhc); break; case <API key>: break; /* CFILT usage change */ case <API key>: case <API key>: case <API key>: if (<API key>(mbhc) == <API key>(event)) /* * Switch CFILT to slow mode if MBHC CFILT is being * used. */ <API key>(mbhc, false); break; case <API key>: case <API key>: case <API key>: if (<API key>(mbhc) == <API key>(event)) /* * Switch CFILT to fast mode if MBHC CFILT is not * used anymore. */ <API key>(mbhc, true); break; /* System resume */ case <API key>: mbhc->mbhc_last_resume = jiffies; break; /* BG mode chage */ case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: /* Not used for now */ break; case <API key>: /* * if polling is ON, mbhc micbias not enabled * switch micbias source to VDDIO */ set_bit(<API key>, &mbhc->event_state); if (!(snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg) & 0x80) && mbhc->polling_active && !mbhc-><API key>) <API key>(mbhc, 1); break; case <API key>: /* * Switch back to micbias if HPH PA or TX3 path * is disabled */ clear_bit(<API key>, &mbhc->event_state); if (mbhc->polling_active && mbhc-><API key> && !(mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR))) <API key>(mbhc, 0); break; default: WARN(1, "Unknown event %d\n", event); ret = -EINVAL; } mutex_unlock(&mbhc->mbhc_lock); pr_debug("%s: leave\n", __func__); return ret; } static s16 <API key>(struct wcd9xxx_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; short bias_value; int i; s32 z_t = 0; s32 z_loop = z_det_box_car_avg; /* Box Car avrg of less than a particular loop count will not be * accomodated. Similarly if the count is more than a particular number * it will not be counted. Set z_loop counter to a limit, if its more * or less than the value in <API key> or * <API key> */ if (z_loop < <API key>) { dev_dbg(codec->dev, "%s: Box Car avrg counter < %d. Limiting it to %d\n", __func__, <API key>, <API key>); z_loop = <API key>; } else if (z_loop > <API key>) { dev_dbg(codec->dev, "%s: Box Car avrg counter > %d. Limiting it to %d\n", __func__, <API key>, <API key>); z_loop = <API key>; } /* Take box car average if needed */ for (i = 0; i < z_loop; i++) { snd_soc_write(codec, <API key>, 0x2); /* Wait for atleast 1800uS to let register write to settle */ usleep_range(1800, 1800 + <API key>); z_t += <API key>(codec); } /* Take average of the Z values read */ bias_value = (s16) (z_t / z_loop); return bias_value; } static int <API key>(struct wcd9xxx_mbhc *mbhc, s16 l[3], s16 r[3], uint32_t *zl, uint32_t *zr, u32 *zl_stereo, u32 *zl_mono) { s16 l_t[3] = {0}, r_t[3] = {0}; s16 l2_stereo, l2_mono; bool left, right; struct snd_soc_codec *codec = mbhc->codec; if (!mbhc->mbhc_cb || !mbhc->mbhc_cb->setup_zdet || !mbhc->mbhc_cb->compute_impedance) { dev_err(codec->dev, "%s: Invalid parameters\n", __func__); return -EINVAL; } left = !!(l); right = !!(r); dev_dbg(codec->dev, "%s: Remeasuring impedance values\n", __func__); dev_dbg(codec->dev, "%s: l: %p, r: %p, left=%d, right=%d\n", __func__, l, r, left, right); /* Remeasure V2 values */ snd_soc_update_bits(codec, <API key>, 0xFF, 0xF0); if (right) r_t[2] = <API key>(mbhc); snd_soc_update_bits(codec, <API key>, 0xFF, 0xC0); if (left) l_t[2] = <API key>(mbhc); /* Ramp down HPHR */ mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); if (right) { /* Take R0'/R1' */ snd_soc_update_bits(codec, <API key>, 0xFF, 0xF8); snd_soc_update_bits(codec, <API key>, 0xFF, 0xA0); r_t[1] = <API key>(mbhc); snd_soc_update_bits(codec, <API key>, 0xFF, 0xF0); r_t[0] = <API key>(mbhc); } /* Put back gain to 1x */ if (!left && right) mbhc->mbhc_cb->setup_zdet(mbhc, MBHC_ZDET_GAIN_0); snd_soc_update_bits(codec, <API key>, 0xFF, 0xC0); /* Take L2'' measurement */ l2_stereo = <API key>(mbhc); /* Turn off HPHR PA and take L2''' */ mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); l2_mono = <API key>(mbhc); /* Ramp HPHL from -15mV to 0V */ mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); /* Take L0' and L1' with iCal */ l_t[0] = <API key>(mbhc); snd_soc_update_bits(codec, <API key>, 0xFF, 0xF8); l_t[1] = <API key>(mbhc); if (left) { l[0] = l_t[0]; l[1] = l_t[1]; l[2] = l_t[2]; } if (right) { r[0] = r_t[0]; r[1] = r_t[1]; r[2] = r_t[2]; } /* compute the new impedance values */ mbhc->mbhc_cb->compute_impedance(mbhc, l, r, zl, zr); if (!left && right) mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); /* compute the new ZL'' value */ l_t[2] = l2_stereo; mbhc->mbhc_cb->compute_impedance(mbhc, l_t, NULL, zl_stereo, NULL); /* compute the new ZL''' value */ l_t[2] = l2_mono; mbhc->mbhc_cb->compute_impedance(mbhc, l_t, NULL, zl_mono, NULL); pr_debug("%s: L0': 0x%x, L1': 0x%x L2_stereo: 0x%x, L2_mono: 0x%x\n", __func__, l_t[0] & 0xffff, l_t[1] & 0xffff, l2_stereo & 0xffff, l2_mono & 0xffff); pr_debug("%s: ZL_stereo = %u, ZL_mono = %u\n", __func__, *zl_stereo, *zl_mono); return 0; } static enum mbhc_zdet_zones <API key>(uint32_t zl, uint32_t zr, int32_t *gain) { enum mbhc_zdet_zones zdet_zone; if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE1__ZR_ZONE1; *gain = 0; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE2__ZR_ZONE2; *gain = MBHC_ZDET_GAIN_1; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE3__ZR_ZONE3; *gain = MBHC_ZDET_GAIN_2; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE2__ZR_ZONE1; *gain = MBHC_ZDET_GAIN_1; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE3__ZR_ZONE1; *gain = MBHC_ZDET_GAIN_2; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE1__ZR_ZONE2; *gain = MBHC_ZDET_GAIN_1; } else if (<API key>(zl) && <API key>(zr)) { zdet_zone = ZL_ZONE1__ZR_ZONE3; *gain = MBHC_ZDET_GAIN_2; } else { zdet_zone = ZL_ZR_NOT_IN_ZONE1; *gain = MBHC_ZDET_GAIN_1; } return zdet_zone; } static int <API key>(struct wcd9xxx_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { int i; int ret = 0; u8 micb_mbhc_val; s16 l[3], r[3]; s16 *z[] = { &l[0], &r[0], &r[1], &l[1], &l[2], &r[2], }; u32 zl_stereo, zl_mono; u32 zl_diff_1, zl_diff_2; bool override_en; struct snd_soc_codec *codec = mbhc->codec; const int mux_wait_us = 25; const struct <API key> reg_set_mux[] = { /* Phase 1 */ /* Set MBHC_MUX for HPHL without ical */ {<API key>, 0xFF, 0xF0}, /* Set MBHC_MUX for HPHR without ical */ {<API key>, 0xFF, 0xA0}, /* Set MBHC_MUX for HPHR with ical */ {<API key>, 0xFF, 0xF8}, /* Set MBHC_MUX for HPHL with ical */ {<API key>, 0xFF, 0xC0}, /* Phase 2 */ {<API key>, 0xFF, 0xF0}, /* Set MBHC_MUX for HPHR without ical and wait for 25us */ {<API key>, 0xFF, 0xA0}, }; pr_debug("%s: enter\n", __func__); <API key>(mbhc->resmgr); if (!mbhc->mbhc_cb || !mbhc->mbhc_cb->setup_zdet || !mbhc->mbhc_cb->compute_impedance || !zl || !zr) { return -EINVAL; } /* * Impedance detection is an intrusive function as it mutes RX paths, * enable PAs and etc. Therefore codec drvier including ALSA * shouldn't read and write hardware registers during detection. */ mutex_lock(&codec->mutex); <API key>(mbhc, true); /* * For impedance detection, make sure to disable micbias from * override signal so that override does not cause micbias * to be enabled. This setting will be undone after completing * impedance measurement. */ micb_mbhc_val = snd_soc_read(codec, <API key>); snd_soc_update_bits(codec, <API key>, 0x10, 0x00); override_en = (snd_soc_read(codec, <API key>) & 0x04) ? true : false; if (!override_en) <API key>(mbhc, true); pr_debug("%s: Setting impedance detection\n", __func__); /* Codec specific setup for L0, R0, L1 and R1 measurements */ mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); pr_debug("%s: Performing impedance detection\n", __func__); for (i = 0; i < ARRAY_SIZE(reg_set_mux) - 2; i++) { snd_soc_update_bits(codec, reg_set_mux[i].reg, reg_set_mux[i].mask, reg_set_mux[i].val); if (mbhc->mbhc_cb->get_cdc_type && mbhc->mbhc_cb->get_cdc_type() == <API key>) { *(z[i]) = <API key>(mbhc); } else { if (mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); /* 25us is required after mux change to settle down */ usleep_range(mux_wait_us, mux_wait_us + <API key>); *(z[i]) = <API key>(mbhc, 0, true, false); } } /* Codec specific setup for L2 and R2 measurements */ mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); for (; i < ARRAY_SIZE(reg_set_mux); i++) { snd_soc_update_bits(codec, reg_set_mux[i].reg, reg_set_mux[i].mask, reg_set_mux[i].val); if (mbhc->mbhc_cb->get_cdc_type && mbhc->mbhc_cb->get_cdc_type() == <API key>) { *(z[i]) = <API key>(mbhc); } else { if (mbhc->mbhc_cb-><API key>) mbhc->mbhc_cb-><API key>(codec); else snd_soc_update_bits(codec, <API key>, 0x80, 0x80); /* 25us is required after mux change to settle down */ usleep_range(mux_wait_us, mux_wait_us + <API key>); *(z[i]) = <API key>(mbhc, 0, true, false); } } mbhc->mbhc_cb->compute_impedance(mbhc, l, r, zl, zr); /* * For some codecs, an additional step of zdet is needed * to overcome effects of noise and for better accuracy of * z values */ if (mbhc->mbhc_cb->get_cdc_type && mbhc->mbhc_cb->get_cdc_type() == <API key>) { uint32_t zl_t = 0, zr_t = 0; s16 *l_p, *r_p; enum mbhc_zdet_zones zdet_zone; int32_t gain; zdet_zone = <API key>(*zl, *zr, &gain); switch (zdet_zone) { case ZL_ZONE1__ZR_ZONE1: l_p = NULL; r_p = NULL; break; case ZL_ZONE2__ZR_ZONE2: case ZL_ZONE3__ZR_ZONE3: case ZL_ZR_NOT_IN_ZONE1: l_p = l; r_p = r; break; case ZL_ZONE2__ZR_ZONE1: case ZL_ZONE3__ZR_ZONE1: /* If ZR falls in Zone 1, further computations with * gain update are not required */ l_p = l; r_p = NULL; break; case ZL_ZONE1__ZR_ZONE2: case ZL_ZONE1__ZR_ZONE3: /* If ZL falls in Zone 1, further computations with * gain update are not required */ l_p = NULL; r_p = r; break; } pr_debug("%s:zdet_zone = %d, gain = %d\n", __func__, zdet_zone, gain); if (gain) mbhc->mbhc_cb->setup_zdet(mbhc, gain); <API key>(mbhc, l_p, r_p, &zl_t, &zr_t, &zl_stereo, &zl_mono); *zl = (zl_t) ? zl_t : *zl; *zr = (zr_t) ? zr_t : *zr; /* Check for Mono/Stereo Type * Conditions to classify Mono/Stereo * i. Difference of zl_stereo and zl_mono > (1/2) of zl_mono * ii. Absolute difference of zl and zr above a threshold */ zl_diff_1 = (zl_mono > zl_stereo) ? (zl_mono - zl_stereo) : (zl_stereo - zl_mono); zl_diff_2 = (*zl > *zr) ? (*zl - *zr) : (*zr - *zl); mbhc->hph_type = MBHC_HPH_NONE; if (mbhc->current_plug != PLUG_TYPE_HIGH_HPH) { if ((zl_diff_1 > (zl_mono >> 1)) || (zl_diff_2 > <API key>) || ((*zl < <API key>) && (*zr > <API key>)) || ((*zr < <API key>) && (*zl > <API key>))) { pr_debug("%s: MONO plug type detected\n", __func__); mbhc->hph_type = MBHC_HPH_MONO; *zl = zl_mono; } else { pr_debug("%s: STEREO plug type detected\n", __func__); mbhc->hph_type = MBHC_HPH_STEREO; } } } mbhc->mbhc_cb->setup_zdet(mbhc, <API key>); /* Calculate z values based on the Q-fuse registers, if used */ if (mbhc->mbhc_cb->zdet_error_approx) mbhc->mbhc_cb->zdet_error_approx(mbhc, zl, zr); mutex_unlock(&codec->mutex); <API key>(mbhc, false); if (!override_en) <API key>(mbhc, false); /* Undo the micbias disable for override */ snd_soc_write(codec, <API key>, micb_mbhc_val); pr_debug("%s: L0: 0x%x(%d), L1: 0x%x(%d), L2: 0x%x(%d)\n", __func__, l[0] & 0xffff, l[0], l[1] & 0xffff, l[1], l[2] & 0xffff, l[2]); pr_debug("%s: R0: 0x%x(%d), R1: 0x%x(%d), R2: 0x%x(%d)\n", __func__, r[0] & 0xffff, r[0], r[1] & 0xffff, r[1], r[2] & 0xffff, r[2]); pr_debug("%s: RL %u milliohm, RR %u milliohm\n", __func__, *zl, *zr); pr_debug("%s: Impedance detection completed\n", __func__); return ret; } int <API key>(struct wcd9xxx_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { *zl = mbhc->zl; *zr = mbhc->zr; if (*zl && *zr) return 0; else return -EINVAL; } /* * wcd9xxx_mbhc_init : initialize MBHC internal structures. * * NOTE: mbhc->mbhc_cfg is not YET configure so shouldn't be used */ int wcd9xxx_mbhc_init(struct wcd9xxx_mbhc *mbhc, struct wcd9xxx_resmgr *resmgr, struct snd_soc_codec *codec, int (*micbias_enable_cb) (struct snd_soc_codec*, bool, enum wcd9xxx_micbias_num), const struct wcd9xxx_mbhc_cb *mbhc_cb, const struct wcd9xxx_mbhc_intr *mbhc_cdc_intr_ids, int rco_clk_rate, bool impedance_det_en) { int ret; void *core_res; pr_debug("%s: enter\n", __func__); memset(&mbhc->mbhc_bias_regs, 0, sizeof(struct mbhc_micbias_regs)); memset(&mbhc->mbhc_data, 0, sizeof(struct <API key>)); mbhc->mbhc_data.t_sta_dce = <API key>; mbhc->mbhc_data.t_dce = DEFAULT_DCE_WAIT; mbhc->mbhc_data.t_sta = DEFAULT_STA_WAIT; mbhc-><API key> = false; mbhc->polling_active = false; mbhc->mbhc_state = MBHC_STATE_NONE; mbhc->in_swch_irq_handler = false; mbhc->current_plug = PLUG_TYPE_NONE; mbhc->lpi_enabled = false; mbhc-><API key> = false; mbhc->mbhc_last_resume = 0; mbhc->codec = codec; mbhc->resmgr = resmgr; mbhc->resmgr->mbhc = mbhc; mbhc->micbias_enable_cb = micbias_enable_cb; mbhc->rco_clk_rate = rco_clk_rate; mbhc->mbhc_cb = mbhc_cb; mbhc->intr_ids = mbhc_cdc_intr_ids; mbhc->impedance_detect = impedance_det_en; mbhc->hph_type = MBHC_HPH_NONE; if (mbhc->intr_ids == NULL) { pr_err("%s: Interrupt mapping not provided\n", __func__); return -EINVAL; } if (mbhc->headset_jack.jack == NULL) { ret = snd_soc_jack_new(codec, "Headset Jack", WCD9XXX_JACK_MASK, &mbhc->headset_jack); if (ret) { pr_err("%s: Failed to create new jack\n", __func__); return ret; } ret = snd_soc_jack_new(codec, "Button Jack", <API key>, &mbhc->button_jack); if (ret) { pr_err("Failed to create new jack\n"); return ret; } ret = snd_jack_set_key(mbhc->button_jack.jack, SND_JACK_BTN_0, KEY_MEDIA); if (ret) { pr_err("%s: Failed to set code for btn-0\n", __func__); return ret; } #ifdef VENDOR_EDIT //Ming.Liu@MultiMedia.AudioDrv, 2015-03-02, Add for 1+ headphone line control ret = snd_jack_set_key(mbhc->button_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEUP); if (ret) { pr_err("%s: Failed to set code for btn-3\n", __func__); return ret; } ret = snd_jack_set_key(mbhc->button_jack.jack, SND_JACK_BTN_7, KEY_VOLUMEDOWN); if (ret) { pr_err("%s: Failed to set code for btn-7\n", __func__); return ret; } #endif /* VENDOR_EDIT */ INIT_DELAYED_WORK(&mbhc->mbhc_firmware_dwork, <API key>); INIT_DELAYED_WORK(&mbhc->mbhc_btn_dwork, <API key>); INIT_DELAYED_WORK(&mbhc->mbhc_insert_dwork, <API key>); } mutex_init(&mbhc->mbhc_lock); /* Register event notifier */ mbhc->nblock.notifier_call = <API key>; ret = <API key>(mbhc->resmgr, &mbhc->nblock); if (ret) { pr_err("%s: Failed to register notifier %d\n", __func__, ret); mutex_destroy(&mbhc->mbhc_lock); return ret; } <API key>(mbhc); /* Disable Impedance detection by default for certain codec types */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->get_cdc_type && (mbhc->mbhc_cb->get_cdc_type() == <API key>)) impedance_detect_en = 0; else impedance_detect_en = impedance_det_en ? 1 : 0; core_res = mbhc->resmgr->core_res; ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->insertion, <API key>, "Headset insert detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d, ret = %d\n", __func__, mbhc->intr_ids->insertion, ret); goto err_insert_irq; } wcd9xxx_disable_irq(core_res, mbhc->intr_ids->insertion); ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->poll_plug_rem, <API key>, "Headset remove detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->poll_plug_rem); goto err_remove_irq; } ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->dce_est_complete, wcd9xxx_dce_handler, "DC Estimation detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->dce_est_complete); goto err_potential_irq; } ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->button_release, <API key>, "Button Release detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->button_release); goto err_release_irq; } ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->hph_left_ocp, <API key>, "HPH_L OCP detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->hph_left_ocp); goto err_hphl_ocp_irq; } wcd9xxx_disable_irq(core_res, mbhc->intr_ids->hph_left_ocp); ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->hph_right_ocp, <API key>, "HPH_R OCP detect", mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->hph_right_ocp); goto err_hphr_ocp_irq; } wcd9xxx_disable_irq(core_res, mbhc->intr_ids->hph_right_ocp); <API key>(resmgr, 1 << <API key> | 1 << WCD9XXX_COND_HPH); pr_debug("%s: leave ret %d\n", __func__, ret); return ret; err_hphr_ocp_irq: wcd9xxx_free_irq(core_res, mbhc->intr_ids->hph_left_ocp, mbhc); err_hphl_ocp_irq: wcd9xxx_free_irq(core_res, mbhc->intr_ids->button_release, mbhc); err_release_irq: wcd9xxx_free_irq(core_res, mbhc->intr_ids->dce_est_complete, mbhc); err_potential_irq: wcd9xxx_free_irq(core_res, mbhc->intr_ids->poll_plug_rem, mbhc); err_remove_irq: wcd9xxx_free_irq(core_res, mbhc->intr_ids->insertion, mbhc); err_insert_irq: <API key>(mbhc->resmgr, &mbhc->nblock); mutex_destroy(&mbhc->mbhc_lock); pr_debug("%s: leave ret %d\n", __func__, ret); return ret; } EXPORT_SYMBOL(wcd9xxx_mbhc_init); void wcd9xxx_mbhc_deinit(struct wcd9xxx_mbhc *mbhc) { struct <API key> *core_res = mbhc->resmgr->core_res; <API key>(mbhc->resmgr, 1 << <API key> | 1 << WCD9XXX_COND_HPH); wcd9xxx_free_irq(core_res, mbhc->intr_ids->button_release, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->dce_est_complete, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->poll_plug_rem, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->insertion, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->hs_jack_switch, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->hph_left_ocp, mbhc); wcd9xxx_free_irq(core_res, mbhc->intr_ids->hph_right_ocp, mbhc); mutex_destroy(&mbhc->mbhc_lock); <API key>(mbhc->resmgr, &mbhc->nblock); <API key>(mbhc); } EXPORT_SYMBOL(wcd9xxx_mbhc_deinit); MODULE_DESCRIPTION("wcd9xxx MBHC module"); MODULE_LICENSE("GPL v2");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>XED2: XED2 User Guide - Tue Nov 22 12:27:53 2011 </title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.6 --> <div class="tabs"> <ul> <li><a href="main.html"><span>Main&nbsp;Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul></div> <div class="tabs"> <ul> <li><a href="files.html"><span>File&nbsp;List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul></div> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#if !defined(<API key>)</span> <a name="l00035"></a><a class="code" href="<API key>.html#<API key>">00035</a> <span class="preprocessor"></span><span class="preprocessor"># define <API key></span> <a name="l00036"></a>00036 <span class="preprocessor"></span> <a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="xed-common-hdrs_8h.html">xed-common-hdrs.h</a>"</span> <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="xed-common-defs_8h.html">xed-common-defs.h</a>"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="xed-portability_8h.html">xed-portability.h</a>"</span> <a name="l00040"></a>00040 <span class="preprocessor">#include "<a class="code" href="xed-util_8h.html">xed-util.h</a>"</span> <a name="l00041"></a>00041 <span class="preprocessor">#include "<a class="code" href="xed-types_8h.html">xed-types.h</a>"</span> <a name="l00042"></a>00042 <span class="preprocessor">#include "<a class="code" href="xed-state_8h.html">xed-state.h</a>"</span> <span class="comment">// a generated file</span> <a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="xed-operand-enum_8h.html">xed-operand-enum.h</a>"</span> <span class="comment">// a generated file</span> <a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="<API key>.html">xed-operand-storage.h</a>"</span> <a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="xed-reg-enum_8h.html">xed-reg-enum.h</a>"</span> <span class="comment">// generated</span> <a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="xed-iclass-enum_8h.html">xed-iclass-enum.h</a>"</span> <span class="comment">// generated</span> <a name="l00048"></a>00048 <span class="comment"></span> <a name="l00049"></a>00049 <a name="l00050"></a>00050 <a name="l00051"></a>00051 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00052"></a>00052 <a name="l00055"></a>00055 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00056"></a>00056 <span class="keyword">const</span> <a class="code" href="group__INIT.html#<API key>">xed_state_t</a>* dstate); <a name="l00057"></a>00057 <a name="l00060"></a>00060 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00061"></a>00061 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00062"></a>00062 <span class="keyword">const</span> <a class="code" href="group__INIT.html#<API key>">xed_state_t</a>* dstate); <a name="l00063"></a>00063 <a name="l00067"></a>00067 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00068"></a>00068 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>( <a class="code" href="<API key>.html#<API key>"><API key></a>* dst, <a name="l00069"></a>00069 <span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* src ); <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="comment">// Returns the raw operand fields. Do not use this. </span> <a name="l00073"></a>00073 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00074"></a>00074 <a class="code" href="<API key>.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00075"></a>00075 <a class="code" href="xed-operand-enum_8h.html#<API key>">xed_operand_enum_t</a> <API key>) ; <a name="l00076"></a>00076 <a name="l00077"></a>00077 <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00084"></a>00084 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* ov, <a name="l00085"></a>00085 <span class="keywordtype">char</span>* buf, <a name="l00086"></a>00086 <span class="keywordtype">int</span> buflen); <a name="l00089"></a>00089 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00090"></a>00090 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* ov, <a name="l00091"></a>00091 <span class="keywordtype">char</span>* buf, <a name="l00092"></a>00092 <span class="keywordtype">int</span> buflen); <a name="l00094"></a>00094 <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a name="l00098"></a>00098 <a name="l00099"></a>00099 <a name="l00100"></a>00100 <a name="l00101"></a>00101 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00102"></a>00102 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00106"></a>00106 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00107"></a>00107 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00111"></a>00111 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00112"></a>00112 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00113"></a>00113 <a name="l00116"></a>00116 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00119"></a>00119 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00122"></a>00122 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00123"></a>00123 <a name="l00125"></a>00125 <a name="l00130"></a>00130 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00131"></a>00131 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00132"></a>00132 <a name="l00135"></a>00135 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00136"></a>00136 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00137"></a>00137 <a name="l00144"></a>00144 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00145"></a>00145 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00146"></a>00146 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i); <a name="l00147"></a>00147 <a name="l00148"></a>00148 <a name="l00149"></a>00149 <a name="l00156"></a>00156 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00157"></a>00157 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00160"></a>00160 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00161"></a>00161 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00164"></a>00164 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00165"></a>00165 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00166"></a>00166 <a name="l00167"></a>00167 <a name="l00170"></a>00170 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00171"></a>00171 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00174"></a>00174 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00175"></a>00175 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00178"></a>00178 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00179"></a>00179 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00180"></a>00180 <a name="l00181"></a>00181 <a name="l00184"></a>00184 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00185"></a>00185 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00186"></a>00186 <a name="l00189"></a>00189 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00190"></a>00190 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00191"></a>00191 <a name="l00192"></a>00192 <a name="l00197"></a>00197 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00198"></a>00198 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00199"></a>00199 <a name="l00202"></a>00202 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00203"></a>00203 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00204"></a>00204 <a name="l00208"></a>00208 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00209"></a>00209 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00210"></a>00210 <a name="l00213"></a>00213 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00214"></a>00214 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00215"></a>00215 <a name="l00218"></a>00218 <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00219"></a>00219 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="preprocessor">#if 0</span> <a name="l00222"></a>00222 <span class="preprocessor"></span><a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00223"></a>00223 <API key>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00224"></a>00224 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00225"></a>00225 <API key>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00226"></a>00226 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00227"></a>00227 <API key>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00228"></a>00228 <span class="preprocessor">#endif</span> <a name="l00229"></a>00229 <span class="preprocessor"></span> <a name="l00231"></a>00231 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00232"></a>00232 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00233"></a>00233 <a name="l00236"></a>00236 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> <a name="l00237"></a>00237 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00238"></a>00238 <a name="l00240"></a>00240 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00241"></a>00241 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00242"></a>00242 <a name="l00244"></a>00244 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00245"></a>00245 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00247"></a>00247 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00248"></a>00248 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00249"></a>00249 <a name="l00251"></a>00251 <a name="l00252"></a>00252 <a name="l00253"></a>00253 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00254"></a>00254 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00255"></a>00255 <a name="l00257"></a>00257 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00258"></a>00258 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00259"></a>00259 <a name="l00261"></a>00261 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00262"></a>00262 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00263"></a>00263 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx); <a name="l00264"></a>00264 <a name="l00266"></a>00266 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> <a name="l00267"></a>00267 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00268"></a>00268 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx); <a name="l00269"></a>00269 <a name="l00271"></a>00271 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> <a name="l00272"></a>00272 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00273"></a>00273 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx); <a name="l00274"></a>00274 <a name="l00276"></a>00276 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> <a name="l00277"></a>00277 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00278"></a>00278 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx); <a name="l00279"></a>00279 <a name="l00281"></a>00281 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00282"></a>00282 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00283"></a>00283 <a name="l00287"></a>00287 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00288"></a>00288 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00291"></a>00291 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00292"></a>00292 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00293"></a>00293 <a name="l00296"></a>00296 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00297"></a>00297 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00299"></a>00299 <a name="l00301"></a>00301 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00302"></a>00302 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00304"></a>00304 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00305"></a>00305 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00306"></a>00306 <a name="l00308"></a>00308 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_bool_t</a> <a name="l00309"></a>00309 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00310"></a>00310 <a name="l00311"></a>00311 <a name="l00313"></a>00313 <a name="l00314"></a>00314 <a name="l00315"></a>00315 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_int64_t <a name="l00316"></a>00316 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00317"></a>00317 <a name="l00319"></a>00319 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint64_t <a name="l00320"></a>00320 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00321"></a>00321 <a name="l00324"></a>00324 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-types_8h.html#<API key>">xed_uint_t</a> <a name="l00325"></a>00325 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00326"></a>00326 <a name="l00327"></a>00327 <a name="l00330"></a>00330 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint8_t <a name="l00331"></a>00331 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00332"></a>00332 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i); <a name="l00333"></a>00333 <a name="l00335"></a>00335 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint8_t <a name="l00336"></a>00336 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00338"></a>00338 <a name="l00340"></a>00340 <a name="l00341"></a>00341 <a name="l00342"></a>00342 <a name="l00343"></a>00343 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00344"></a>00344 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00347"></a>00347 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00348"></a>00348 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00349"></a>00349 <a name="l00351"></a>00351 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_int64_t <a name="l00352"></a>00352 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00353"></a>00353 <a name="l00355"></a>00355 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint8_t <a name="l00356"></a>00356 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00357"></a>00357 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i); <a name="l00359"></a>00359 <a name="l00361"></a>00361 <a name="l00362"></a>00362 <a name="l00363"></a>00363 <a name="l00364"></a>00364 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00365"></a>00365 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00368"></a>00368 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint32_t <a name="l00369"></a>00369 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00370"></a>00370 <a name="l00372"></a>00372 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_int32_t <a name="l00373"></a>00373 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00374"></a>00374 <a name="l00376"></a>00376 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> xed_uint8_t <a name="l00377"></a>00377 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00378"></a>00378 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i); <a name="l00380"></a>00380 <a name="l00381"></a>00381 <a name="l00383"></a>00383 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <a class="code" href="xed-iclass-enum_8h.html#<API key>">xed_iclass_enum_t</a> <a name="l00384"></a>00384 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<span class="keyword">const</span> <a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00385"></a>00385 <a name="l00387"></a>00387 <span class="comment">// ENCODE API</span> <a name="l00390"></a>00390 <span class="comment"></span> <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00393"></a>00393 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00395"></a>00395 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00396"></a>00396 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00398"></a>00398 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00399"></a>00399 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00400"></a>00400 <a name="l00402"></a>00402 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00404"></a>00404 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00405"></a>00405 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00406"></a>00406 <a name="l00407"></a>00407 <a name="l00409"></a>00409 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00410"></a>00410 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00411"></a>00411 <a class="code" href="xed-iclass-enum_8h.html#<API key>">xed_iclass_enum_t</a> iclass); <a name="l00412"></a>00412 <a name="l00415"></a>00415 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00416"></a>00416 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00417"></a>00417 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width); <a name="l00418"></a>00418 <a name="l00421"></a>00421 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00422"></a>00422 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00423"></a>00423 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width); <a name="l00424"></a>00424 <a name="l00426"></a>00426 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00427"></a>00427 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00428"></a>00428 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_length); <a name="l00429"></a>00429 <a name="l00430"></a>00430 <a name="l00433"></a>00433 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00434"></a>00434 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00435"></a>00435 xed_int64_t x, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len); <a name="l00438"></a>00438 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00439"></a>00439 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00440"></a>00440 xed_int64_t x, <a name="l00441"></a>00441 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len_bits); <a name="l00442"></a>00442 <a name="l00445"></a>00445 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p); <a name="l00446"></a>00446 <a name="l00449"></a>00449 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00450"></a>00450 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00451"></a>00451 xed_int32_t x, <a name="l00452"></a>00452 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len); <a name="l00455"></a>00455 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00456"></a>00456 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00457"></a>00457 xed_int32_t x, <a name="l00458"></a>00458 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len_bits); <a name="l00459"></a>00459 <a name="l00462"></a>00462 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00463"></a>00463 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00464"></a>00464 xed_int32_t x, <a name="l00465"></a>00465 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bytes); <a name="l00468"></a>00468 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00469"></a>00469 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00470"></a>00470 xed_int32_t x, <a name="l00471"></a>00471 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bits); <a name="l00472"></a>00472 <a name="l00473"></a>00473 <a name="l00476"></a>00476 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00477"></a>00477 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00478"></a>00478 xed_uint64_t x, <a name="l00479"></a>00479 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bytes); <a name="l00482"></a>00482 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00483"></a>00483 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00484"></a>00484 xed_uint64_t x, <a name="l00485"></a>00485 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bits); <a name="l00486"></a>00486 <a name="l00487"></a>00487 <a name="l00488"></a>00488 <a name="l00490"></a>00490 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00491"></a>00491 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx, <a name="l00492"></a>00492 <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> new_base); <a name="l00493"></a>00493 <a name="l00495"></a>00495 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00496"></a>00496 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx, <a name="l00497"></a>00497 <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> new_seg); <a name="l00498"></a>00498 <a name="l00500"></a>00500 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00501"></a>00501 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> memop_idx, <a name="l00502"></a>00502 <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> new_index); <a name="l00503"></a>00503 <a name="l00505"></a>00505 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00506"></a>00506 <a class="code" href="xed-types_8h.html#<API key>">xed_uint_t</a> memop_idx, <a name="l00507"></a>00507 <a class="code" href="xed-types_8h.html#<API key>">xed_uint_t</a> new_scale); <a name="l00508"></a>00508 <a name="l00509"></a>00509 <a name="l00513"></a>00513 <a class="code" href="xed-common-hdrs_8h.html#<API key>">XED_DLL_EXPORT</a> <span class="keywordtype">void</span> <a name="l00514"></a>00514 <a class="code" href="group__OPERANDS.html#<API key>"><API key></a>(<a class="code" href="<API key>.html#<API key>"><API key></a>* p, <a name="l00515"></a>00515 <a class="code" href="xed-operand-enum_8h.html#<API key>">xed_operand_enum_t</a> operand_name, <a name="l00516"></a>00516 <a class="code" href="xed-reg-enum_8h.html#<API key>">xed_reg_enum_t</a> reg_name); <a name="l00517"></a>00517 <a name="l00519"></a>00519 <span class="preprocessor">#endif</span> <a name="l00520"></a>00520 <span class="preprocessor"></span> <a name="l00521"></a>00521 <span class="comment">//Local Variables:</span> <a name="l00522"></a>00522 <span class="comment">//pref: "../../<API key>.c"</span> <a name="l00523"></a>00523 <span class="comment">//End:</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 22 12:27:53 2011 for XED2 by&nbsp; <a href="http: <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address> </body> </html>
<?php /** * @file * Contains \Drupal\migrate_drupal\Tests\d6\<API key>. */ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\<API key>; /** * Migrate field widget settings. * * @group migrate_drupal */ class <API key> extends <API key> { /** * Modules to enable. * * @var array */ public static $modules = array( 'field', 'telephone', 'link', 'file', 'image', 'datetime', 'node', ); /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); entity_create('node_type', array('type' => 'test_page'))->save(); entity_create('node_type', array('type' => 'story'))->save(); // Add some id mappings for the dependant migrations. $id_mappings = array( 'd6_field_instance' => array( array(array('fieldname', 'page'), array('node', 'fieldname', 'page')), ), 'd6_field' => array( array(array('field_test'), array('node', 'field_test')), array(array('field_test_two'), array('node', 'field_test_two')), array(array('field_test_three'), array('node', 'field_test_three')), array(array('field_test_email'), array('node', 'field_test_email')), array(array('field_test_link'), array('node', 'field_test_link')), array(array('<API key>'), array('node', '<API key>')), array(array('<API key>'), array('node', '<API key>')), array(array('field_test_phone'), array('node', 'field_test_phone')), array(array('field_test_date'), array('node', 'field_test_date')), array(array('<API key>'), array('node', '<API key>')), array(array('field_test_datetime'), array('node', 'field_test_datetime')), ), ); $this->prepareMigrations($id_mappings); $migration = entity_load('migration', '<API key>'); $dumps = array( $this->getDumpDirectory() . '/<API key>.php', $this->getDumpDirectory() . '/ContentNodeField.php', $this->getDumpDirectory() . '/ContentFieldTest.php', $this->getDumpDirectory() . '/ContentFieldTestTwo.php', $this->getDumpDirectory() . '/<API key>.php', ); $this->prepare($migration, $dumps); $executable = new MigrateExecutable($migration, $this); $executable->import(); } /** * Test that migrated view modes can be loaded using D8 API's. */ public function testWidgetSettings() { // Test the config can be loaded. $form_display = entity_load('entity_form_display', 'node.story.default'); $this->assertEqual(is_null($form_display), FALSE, "Form display node.story.default loaded with config."); // Text field. $component = $form_display->getComponent('field_test'); $expected = array('weight' => 1, 'type' => 'text_textfield'); $expected['settings'] = array('size' => 60, 'placeholder' => ''); $expected['<API key>'] = array(); $this->assertEqual($component, $expected, 'Text field settings are correct.'); // Integer field. $component = $form_display->getComponent('field_test_two'); $expected['type'] = 'number'; $expected['weight'] = 1; $expected['settings'] = array('placeholder' => ''); $this->assertEqual($component, $expected); // Float field. $component = $form_display->getComponent('field_test_three'); $expected['weight'] = 2; $this->assertEqual($component, $expected); // Email field. $component = $form_display->getComponent('field_test_email'); $expected['type'] = 'email_default'; $expected['weight'] = 6; $this->assertEqual($component, $expected); // Link field. $component = $form_display->getComponent('field_test_link'); $this->assertEqual($component['type'], 'link_default'); $this->assertEqual($component['weight'], 7); $this->assertFalse(array_filter($component['settings'])); // File field. $component = $form_display->getComponent('<API key>'); $expected['type'] = 'file_generic'; $expected['weight'] = 8; $expected['settings'] = array('progress_indicator' => 'bar'); $this->assertEqual($component, $expected); // Image field. $component = $form_display->getComponent('<API key>'); $expected['type'] = 'image_image'; $expected['weight'] = 9; $expected['settings'] = array('progress_indicator' => 'bar', 'preview_image_style' => 'thumbnail'); $this->assertEqual($component, $expected); // Phone field. $component = $form_display->getComponent('field_test_phone'); $expected['type'] = 'telephone_default'; $expected['weight'] = 13; $expected['settings'] = array('placeholder' => ''); $this->assertEqual($component, $expected); // Date fields. $component = $form_display->getComponent('field_test_date'); $expected['type'] = 'datetime_default'; $expected['weight'] = 10; $expected['settings'] = array(); $this->assertEqual($component, $expected); $component = $form_display->getComponent('<API key>'); $expected['weight'] = 11; $this->assertEqual($component, $expected); $component = $form_display->getComponent('field_test_datetime'); $expected['weight'] = 12; $this->assertEqual($component, $expected); } }
package java.nio; /** * A read/write HeapLongBuffer. */ class HeapLongBuffer extends LongBuffer { // For speed these fields are actually declared in X-Buffer; // these declarations are here as documentation /* protected final long[] hb; protected final int offset; */ HeapLongBuffer(int cap, int lim) { // package-private this(cap, lim, false); } HeapLongBuffer(int cap, int lim, boolean isReadOnly) { // package-private super(-1, 0, lim, cap, new long[cap], 0); this.isReadOnly = isReadOnly; } HeapLongBuffer(long[] buf, int off, int len) { // package-private this(buf, off, len, false); } HeapLongBuffer(long[] buf, int off, int len, boolean isReadOnly) { // package-private super(-1, off, off + len, buf.length, buf, 0); this.isReadOnly = isReadOnly; } protected HeapLongBuffer(long[] buf, int mark, int pos, int lim, int cap, int off) { this(buf, mark, pos, lim, cap, off, false); } protected HeapLongBuffer(long[] buf, int mark, int pos, int lim, int cap, int off, boolean isReadOnly) { super(mark, pos, lim, cap, buf, off); this.isReadOnly = isReadOnly; } public LongBuffer slice() { return new HeapLongBuffer(hb, -1, 0, this.remaining(), this.remaining(), this.position() + offset, isReadOnly); } public LongBuffer duplicate() { return new HeapLongBuffer(hb, this.markValue(), this.position(), this.limit(), this.capacity(), offset, isReadOnly); } public LongBuffer asReadOnlyBuffer() { return new HeapLongBuffer(hb, this.markValue(), this.position(), this.limit(), this.capacity(), offset, true); } protected int ix(int i) { return i + offset; } public long get() { return hb[ix(nextGetIndex())]; } public long get(int i) { return hb[ix(checkIndex(i))]; } public LongBuffer get(long[] dst, int offset, int length) { checkBounds(offset, length, dst.length); if (length > remaining()) throw new <API key>(); System.arraycopy(hb, ix(position()), dst, offset, length); position(position() + length); return this; } public boolean isDirect() { return false; } public boolean isReadOnly() { return isReadOnly; } public LongBuffer put(long x) { if (isReadOnly) { throw new <API key>(); } hb[ix(nextPutIndex())] = x; return this; } public LongBuffer put(int i, long x) { if (isReadOnly) { throw new <API key>(); } hb[ix(checkIndex(i))] = x; return this; } public LongBuffer put(long[] src, int offset, int length) { if (isReadOnly) { throw new <API key>(); } checkBounds(offset, length, src.length); if (length > remaining()) throw new <API key>(); System.arraycopy(src, offset, hb, ix(position()), length); position(position() + length); return this; } public LongBuffer put(LongBuffer src) { if (isReadOnly) { throw new <API key>(); } if (src instanceof HeapLongBuffer) { if (src == this) throw new <API key>(); HeapLongBuffer sb = (HeapLongBuffer) src; int n = sb.remaining(); if (n > remaining()) throw new <API key>(); System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n); sb.position(sb.position() + n); position(position() + n); } else if (src.isDirect()) { int n = src.remaining(); if (n > remaining()) throw new <API key>(); src.get(hb, ix(position()), n); position(position() + n); } else { super.put(src); } return this; } public LongBuffer compact() { if (isReadOnly) { throw new <API key>(); } System.arraycopy(hb, ix(position()), hb, ix(0), remaining()); position(remaining()); limit(capacity()); discardMark(); return this; } public ByteOrder order() { return ByteOrder.nativeOrder(); } }
<? include('catalog.php'); $out = array(); foreach ($catalog as $row){ $hex = ''; foreach ($row['unicode'] as $cp) $hex .= sprintf('%x', $cp); $html = "<span class=\"emoji emoji$hex\"></span>"; $out[] = array( 'name' => $row['char_name']['title'], 'unified' => $row['unicode'], 'docomo' => $row['docomo']['unicode'], 'kddi' => $row['au']['unicode'], 'softbank' => $row['softbank']['unicode'], 'google' => $row['google']['unicode'], 'html' => $html, ); } function format_codepoints($us){ if (!count($us)) return '-'; $out = array(); foreach ($us as $u){ $out[] = 'U+'.sprintf('%04X', $u); } return implode(' ', $out); } ?> <html> <head> <title>Emoji Catalog</title> <link rel="stylesheet" type="text/css" media="all" href="emoji.css" /> <style type="text/css"> body { font-size: 12px; font-family: Arial, Helvetica, sans-serif; } table { -<API key>: 0.41em; -moz-border-radius: 0.41em; border: 1px solid #999; font-size: 12px; } table td { padding-left: 0.41em; padding-right: 0.41em; } table th { font-weight: bold; text-align: left; background: #BBB; color: #333; font-size: 14px; padding: 0.41em; } table tbody tr:nth-child(even) { background: #dedede; } table tbody td { padding: 0.41em; } </style> </head> <body> <h1>Emoji Catalog</h1> <table cellspacing="0" cellpadding="0"> <tr> <th colspan="2">Name</th> <th>Unified</th> <th>DoCoMo</th> <th>KDDI</th> <th>Softbank</th> <th>Google</th> </tr> <tbody> <? foreach ($out as $row){ echo "\t<tr>\n"; echo "\t\t<td>$row[html]</td>\n"; echo "\t\t<td>".HtmlSpecialChars(StrToLower($row['name']))."</td>\n"; echo "\t\t<td>".format_codepoints($row['unified'])."</td>\n"; echo "\t\t<td>".format_codepoints($row['docomo'])."</td>\n"; echo "\t\t<td>".format_codepoints($row['kddi'])."</td>\n"; echo "\t\t<td>".format_codepoints($row['softbank'])."</td>\n"; echo "\t\t<td>".format_codepoints($row['google'])."</td>\n"; echo "\t</tr>\n"; } ?> </tbody> </table> </body> <html>
<?php /** * @file * Contains the UCXF_Field class. */ /** * Base class for a Extra Fields Pane field */ class UCXF_Field { // CONSTANTS // Fieldtypes const <API key> = 1; const <API key> = 2; const <API key> = 3; const <API key> = 4; const <API key> = 5; const <API key> = 6; // PROPERTIES /** * An array of pane types the field is in. * @var array * @access private */ private $pane_types; /** * An array of page names on which the field may be displayed * @var array * @access private */ private $display_settings; // CONSTRUCT /** * UCXF_Field object constructor * @access public * @return void */ public function __construct() { // Set default values $this->weight = 0; $this->value_type = self::<API key>; $this->required = FALSE; $this->enabled = TRUE; $this->pane_types = array(); $this->display_settings = array(); } // STATIC METHODS /** * Returns an example for the value section * @param int $field_type * One of the field types defined by Extra Fields Pane * @access public * @static * @return string */ public static function get_example($field_type) { switch ($field_type) { case self::<API key>: return '<code> &nbsp;|' . t('Please select') . '<br /> option1|' . t('Option 1') . '<br /> option2|' . t('Option 2') . '</code>'; case self::<API key>: return '<code>' . t('A constant value') . '</code>'; case self::<API key>: return '<code>&lt;?php return "' . t('A string') . '"; ?&gt;</code>'; case self::<API key>: return "<code> &lt;?php<br /> return array(<br /> &nbsp;&nbsp;'' => '" . t('Please select') . "',<br /> &nbsp;&nbsp;'option1' => '" . t('Option 1') . "',<br /> &nbsp;&nbsp;'option2' => '" . t('Option 2') . "',<br /> );<br /> ?&gt;" . "</code>"; } } // SETTERS /** * Setter * @param string $p_sMember * @param mixed $p_mValue * @access public * @return boolean */ public function __set($p_sMember, $p_mValue) { switch ($p_sMember) { case 'display_settings': if (is_string($p_mValue)) { $p_mValue = unserialize($p_mValue); } if (is_array($p_mValue)) { foreach ($p_mValue as $option_id => $display_setting) { $this->display_settings[$option_id] = ($display_setting) ? TRUE : FALSE; } return TRUE; } break; case 'pane_type': if (is_string($p_mValue)) { $pane_types = explode('|', $p_mValue); return $this->__set('pane_type', $pane_types); } elseif (is_array($p_mValue)) { $this->pane_types = array(); foreach ($p_mValue as $pane_type) { $pane_type = (string) $pane_type; if (!empty($pane_type)) { $this->pane_types[$pane_type] = $pane_type; } } return TRUE; } default: $this->{$p_sMember} = $p_mValue; return TRUE; } return FALSE; } /** * Load an existing item from an array. * @access public * @param array $p_aParams */ function from_array($p_aParams) { foreach ($p_aParams as $sKey => $mValue) { $this->__set($sKey, $mValue); } } // GETTERS /** * Getter * @param string $p_sMember * @access public * @return mixed */ public function __get($p_sMember) { switch ($p_sMember) { case 'id': return $this->__get('field_id'); case 'pane_type': return implode('|', $this->pane_types); case 'pane_types': return $this->pane_types; default: if (isset($this->{$p_sMember})) { return $this->{$p_sMember}; } break; } return NULL; } /** * Return as an array of values. * @access public * @return array */ public function to_array() { $aOutput = array(); // Return fields as specified in the schema. $schema = drupal_get_schema('uc_extra_fields'); if (!empty($schema['fields']) && is_array($schema['fields'])) { foreach ($schema['fields'] as $field => $info) { $aOutput[$field] = $this->__get($field); } } return $aOutput; } /** * Output a value with filtering * @param string $p_sMember * @access public * @return string */ public function output($p_sMember) { switch ($p_sMember) { case 'description': return <API key>("field:$this->db_name:description", filter_xss_admin($this->{$p_sMember})); case 'label': return <API key>("field:$this->db_name:label", check_plain($this->{$p_sMember})); case 'pane_type': return check_plain($this->__get('pane_type')); default: if (isset($this->{$p_sMember})) { return check_plain($this->{$p_sMember}); } } return ''; } /** * Output a value based on the field type * @param string $p_sValue * The given value * @access public * @return void */ public function output_value($p_sValue) { switch ($this->value_type) { case self::<API key>: return ($p_sValue) ? t('Yes') : t('No'); case self::<API key>: case self::<API key>: $values = $this->generate_value(); return (isset($values[$p_sValue])) ? check_plain($values[$p_sValue]) : check_plain($p_sValue); default: return ($p_sValue != '') ? check_plain($p_sValue) : t('n/a'); } } /** * Returns the "readable" value type, as a string. * * @return string */ public function get_value_type() { switch ($this->value_type) { case UCXF_Field::<API key>: return t('Textfield'); case UCXF_Field::<API key>: return t('Select list'); case UCXF_Field::<API key>: return t('Checkbox'); case UCXF_Field::<API key>: return t('Constant'); case UCXF_Field::<API key>: return t('PHP string'); case UCXF_Field::<API key>: return t('PHP select list'); } } // LOGIC /** * Returns if the field's value may be displayed on te given page. * * Returns TRUE if the display setting for the given page does not exist. * * @param string $p_sPage * @access public * @return boolean */ public function may_display($p_sPage) { if (isset($this->display_settings[$p_sPage])) { return ($this->display_settings[$p_sPage]) ? TRUE : FALSE; } return TRUE; } /** * Returns if field is in given pane * * @param string $p_sPane * @access public * @return boolean */ public function in_pane($p_sPane) { return (isset($this->pane_types[$p_sPane])); } // DATABASE REQUESTS // Deprecated /** * load() * Loads field from database * @param int $p_iField_id * @access public * @return UCXF_Field */ public function load($p_iField_id) { return <API key>($p_iField_id); } /** * save() * Saves field in database * @access public * @return void */ public function save() { // Prepare values $values = $this->to_array(); $update = array(); $sHook = 'insert'; if (!empty($this->field_id)) { $update[] = 'field_id'; $sHook = 'update'; } drupal_write_record('uc_extra_fields', $values, $update); $this->field_id = $values['field_id']; // Let other modules react on this module_invoke_all('ucxf_field', $this, $sHook); } /** * Delete the field from the database. * @access public * @return boolean */ public function delete() { return UCXF_FieldList::deleteField($this); } // FORMS /** * Get the edit form for the field. * @access public * @return array */ public function edit_form() { $form = array('#tree' => TRUE); // Add instance of this to the form $form['field'] = array( '#type' => 'value', '#value' => $this, ); if (!empty($this->field_id)) { $form['ucxf']['field_id'] = array( '#type' => 'hidden', '#value' => $this->field_id, ); drupal_set_title(t('Modify field: @name', array('@name' => $this->db_name)), PASS_THROUGH); } $form['ucxf']['label'] = array( '#title' => t('Label'), '#type' => 'textfield', '#size' => 25, '#description' => t('Label shown to customers in checkout pages.'), '#required' => TRUE, '#default_value' => $this->label, '#weight' => 0, ); $default_db_name = $this->db_name; if (strpos($default_db_name, 'ucxf_') !== 0) { $default_db_name = 'ucxf_'; } $form['ucxf']['db_name'] = array( '#title' => t('Field name'), '#type' => 'textfield', '#size' => 25, '#description' => t('Database field name. It must contain only lower chars a-z, digits 0-9 and _. Max allowed length is !number characters. This is inclusive the prefix %prefix.', array('!number' => 32, '%prefix' => 'ucxf_')), '#required' => TRUE, '#default_value' => $this->db_name, '#weight' => 1, '#maxlength' => 32, ); if (isset($this->field_id)) { // if field already exists, don't allow to alter the name $form['ucxf']['db_name']['#disabled'] = 'disabled'; $form['ucxf']['db_name']['#value'] = $this->db_name; } $form['ucxf']['description'] = array( '#title' => t('Description'), '#type' => 'textarea', '#rows' => 3, '#description' => t('Insert a description to tell customers how to fill this field. ONLY applies for select/textbox options'), '#default_value' => $this->description, '#weight' => 3, ); $form['ucxf']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#delta' => 30, '#default_value' => $this->weight, '#description' => t('The listing position to display the order data on checkout/order panes.'), '#weight' => 5, ); $form['ucxf']['pane_type'] = array( '#title' => t('Select which pane you would like the form value to be hooked into.'), '#type' => 'select', '#options' => array('extra_information' => t('Extra Information pane')), '#default_value' => $this->pane_type, '#weight' => 7, ); $value_type_options = array( self::<API key> => array( '#title' => t('Textfield'), '#description' => t('Let the user input the data in a textbox. If you want a default value, put it in "value" field below.'), ), self::<API key> => array( '#title' => t('Select list'), '#description' => t('Let the user select from a list of options (enter one <strong>safe_key|Some readable option</strong> per line).'), ), self::<API key> => array( '#title' => t('Checkbox'), '#description' => t('Let the user select from a checkbox.'), ), self::<API key> => array( '#title' => t('Constant'), '#description' => t('Show a admin defined constant value, insert the value in the "value" section.'), ), ); if (user_access('use php fields')) { $value_type_options += array( self::<API key> => array( '#title' => t('PHP string'), '#description' => t('Set the value to the php code that returns a <code>STRING</code> (PHP-mode, experts only).'), ), self::<API key> => array( '#title' => t('PHP select list'), '#description' => t('Let the user select from a list of options from php code returning a <code>ARRAY</code> of key => value pairs. ie- <code>return array(\'element1\' => \'somevalue1\',\'element2\' => \'somevalue2\')</code> (PHP-mode, experts only).'), ), ); } $form['ucxf']['value_type'] = array( '#type' => 'radios', '#title' => t('Field type'), '#options' => $value_type_options, '#default_value' => $this->value_type, '#weight' => 9, '#required' => TRUE, '#after_build' => array('<API key>'), ); $form['ucxf']['value'] = array( '#type' => 'textarea', '#title' => t('Value'), '#description' => t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>')), '#default_value' => $this->value, '#weight' => 10, ); $form['ucxf']['required'] = array( '#title' => t('Field required'), '#type' => 'checkbox', '#description' => t('Check this item if the field is mandatory.'), '#default_value' => $this->required, '#weight' => 12, ); $form['ucxf']['enabled'] = array( '#title' => t('Enabled'), '#type' => 'checkbox', '#default_value' => $this->enabled, '#weight' => 14, ); $display_options = module_invoke_all('<API key>', $this); $form['ucxf']['display_settings'] = array( '#title' => t('Display options'), '#type' => 'fieldset', '#weight' => 16, '#description' => t('Choose on which pages you want to display the field.'), ); foreach ($display_options as $option_id => $option) { $form['ucxf']['display_settings'][$option_id] = array( '#title' => $option_id, '#type' => 'checkbox', '#default_value' => $this->may_display($option_id), ); foreach ($option as $attribute_name => $attribute_value) { switch ($attribute_name) { case 'title': $form['ucxf']['display_settings'][$option_id]['#title'] = $attribute_value; break; case 'description': $form['ucxf']['display_settings'][$option_id]['#description'] = $attribute_value; break; case 'weight': $form['ucxf']['display_settings'][$option_id]['#weight'] = $attribute_value; break; } } } $form['ucxf']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 50, ); if ($this->returnpath) { // Add 'cancel'-link $form['ucxf']['submit']['#suffix'] = l(t('Cancel'), $this->returnpath); } return $form; } /** * Validate the edit form for the item. * @param array $form * @param array $form_state * @access public * @return void */ public function edit_form_validate($form, &$form_state) { $field = $form_state['values']['ucxf']; // No label. if (!$field['label']) { form_set_error('ucxf][label', t('Custom order field: you need to provide a label.')); } // No field name. if (!$field['db_name']) { form_set_error('ucxf][db_name', t('Custom order field: you need to provide a field name.')); } if (isset($field['weight']) && !$field['weight'] && $field['weight'] !== 0 && $field['weight'] !== '0') { form_set_error('ucxf][weight', t('Custom order field: you need to provide a weight value for this extra field.')); } if (isset($form['ucxf']['pane_type']) && empty($field['pane_type'])) { form_set_error('ucxf][pane_type', t('Custom order field: you need to provide a pane-type for this extra field.')); } if (!$field['value_type']) { form_set_error('ucxf][value_type', t('Custom order field: you need to provide a way of processing the value for this field as either textbox, select, constant, or php.')); } if (($field['value_type'] == self::<API key> || $field['value_type'] == self::<API key>) && !$field['value'] ) { form_set_error('ucxf][value', t('Custom order field: you need to provide a value for this way of calculating the field value.')); } // Field name validation. if (empty($field['field_id'])) { $field_name = $field['db_name']; // Add the 'ucxf_' prefix. if (strpos($field_name, 'ucxf_') !== 0) { $field_name = 'ucxf_' . $field_name; form_set_value($form['ucxf']['db_name'], $field_name, $form_state); } // Invalid field name. if (!preg_match('!^ucxf_[a-z0-9_]+$!', $field_name)) { form_set_error('ucxf][db_name', t('Custom order field: the field name %field_name is invalid. The name must include only lowercase unaccentuated letters, numbers, and underscores.', array('%field_name' => $field_name))); } // considering prefix ucxf_ no more than 32 characters (32 max for a db field) if (strlen($field_name) > 32) { form_set_error('ucxf][db_name', t('Custom order field: the field name %field_name is too long. The name is limited to !number characters, including the \'ucxf_\' prefix.', array('!number' => 32, '%field_name' => $field_name))); } // Check if field name already exists in table. $count = db_select('uc_extra_fields') ->condition('db_name', $field_name) ->countQuery() ->execute() ->fetchField(); if ((int) $count > 0) { form_set_error('ucxf][db_name', t('Custom order field: the field name %field_name already exists.', array('%field_name' => $field_name))); } } // Check if php tags are present in case of a php field if ($field['value_type'] == self::<API key> || $field['value_type'] == self::<API key>) { $<API key> = stripos($field['value'], '<?php'); $<API key> = strripos($field['value'], '?>'); if ($<API key> === FALSE || $<API key> === FALSE || $<API key> > $<API key>) { form_set_error('ucxf][value', t('The PHP code is not entered between %php.', array('%php' => '<?php ?>'))); return; } } // Display a warning when select or PHP-select fields are marked as required, but have no option with an empty key if (($field['value_type'] == self::<API key> || $field['value_type'] == self::<API key>) && $field['required'] == TRUE) { $this->value_type = $field['value_type']; $this->value = $field['value']; $options = $this->generate_value(FALSE); $has_empty_key = FALSE; foreach ($options as $key => $value) { if ($key === '' || $key === ' ') { $has_empty_key = TRUE; break; } } if (!$has_empty_key) { switch ($field['value_type']) { case self::<API key>: $message_suffix = t('In this example the key of the first item is just a single space.'); break; case self::<API key>: $message_suffix = t('In this example the key of the first item is an empty string.'); break; } drupal_set_message(t('The select field %field is marked as required, but there is no "empty" option in the list. Enter an empty option in the value section as in this example: !example', array('%field' => $field['db_name'], '!example' => '<br />' . self::get_example($field['value_type']) . '<br />')) . $message_suffix, 'warning'); } } } /** * Submit the edit form for the item. * @param array $form * @param array $form_state * @access public * @return void */ public function edit_form_submit($form, &$form_state) { $this->from_array($form_state['values']['ucxf']); $this->display_settings = $form_state['values']['ucxf']['display_settings']; $this->save(); drupal_set_message(t('Field saved')); if ($this->returnpath) { $form_state['redirect'] = $this->returnpath; } } // ACTION /** * generate() * Generates a field array used in forms generated by <API key> * @access public * @return void */ public function generate() { $return_field = array(); switch ($this->value_type) { case self::<API key>: $return_field = array( '#type' => 'textfield', '#title' => $this->output('label'), '#description' => $this->output('description'), '#size' => 32, '#maxlength' => 255, '#required' => $this->required, ); // Add default value only when there is one $default_value = $this->generate_value(); if ($default_value != '') { $return_field['#default_value'] = $default_value; } break; case self::<API key>: $return_field = array( '#type' => 'checkbox', '#title' => $this->output('label'), '#description' => $this->output('description'), '#required' => $this->required, ); break; case self::<API key>: $return_field = array( '#type' => 'select', '#title' => $this->output('label'), '#description' => $this->output('description'), '#required' => $this->required, '#options' => $this->generate_value(), //'#default_value' => NULL, ); break; case self::<API key>: case self::<API key>: $return_field = array( '#type' => 'hidden', '#value' => $this->generate_value(), ); break; case self::<API key>: $return_field = array( '#type' => 'select', '#title' => $this->output('label'), '#description' => $this->output('description'), '#required' => $this->required, '#options' => $this->generate_value(), //'#default_value' => NULL, ); break; } return $return_field; } /** * Generates the value for use in fields. * This value will be used as a default value for textfields * and as an array of options for selection fields. * @param boolean $translate * If values may be translated. * @access public * @return mixed */ public function generate_value($translate = TRUE) { switch ($this->value_type) { case self::<API key>: // This will return a string $value = (string) $this->value; if ($translate) { $value = <API key>("field:$this->db_name:value", $value); } return $value; case self::<API key>: // This will return a string, sanitized. $value = (string) $this->value; if ($translate) { $value = check_plain(<API key>("field:$this->db_name:value", $value)); } return $value; case self::<API key>: // This will return an array of options // like array('key' => 'label', 'key2' => 'label2') $options = array(); $input_token = strtok($this->value, "\n"); while ($input_token !== FALSE) { if (strpos($input_token, "|")) { $arr = explode("|", $input_token); $key = trim($arr[0]); $label = trim($arr[1]); } else { $key = trim($input_token); $label = trim($input_token); } $options[$key] = $label; $input_token = strtok("\n"); } if ($translate) { // Translate the labels of the options foreach ($options as $key => $label) { $options[$key] = <API key>("field:$this->db_name:value:$key", $label); } } return $options; case self::<API key>: // This will return a string. $value = (string) eval('?>' . $this->value); if ($translate) { $value = <API key>("field:$this->db_name:value", $value); } return $value; case self::<API key>: // This will return an array of options created with eval // like array('name' => 'value', 'name2' => 'value2') // unfortunately php_eval() is not equipped for the task, // so we need to use the standard php-eval. $options = eval('?>' . $this->value); if ($translate) { // Translate the labels of the options foreach ($options as $key => $label) { $options[$key] = <API key>("field:$this->db_name:value:$key", $label); } } return $options; } } }
#include <bits/armsigctx.h> #define SIGCONTEXT int _a2, int _a3, int _a4, union k_sigcontext #define <API key> _a2, _a3, _a4, #define GET_PC(ctx) ((void *)((ctx.v20.magic == <API key>) ? \ ctx.v20.reg.ARM_pc : ctx.v21.arm_pc)) #define GET_FRAME(ctx) \ ADVANCE_STACK_FRAME((void *)((ctx.v20.magic == <API key>) ? \ ctx.v20.reg.ARM_fp : ctx.v21.arm_fp)) #define GET_STACK(ctx) ((void *)((ctx.v20.magic == <API key>) ? \ ctx.v20.reg.ARM_sp : ctx.v21.arm_sp)) #define ADVANCE_STACK_FRAME(frm) \ ((struct layout *)frm - 1) #define CALL_SIGHANDLER(handler, signo, ctx) \ (handler)((signo), <API key> (ctx))
#ifndef _SYS_PROTO_H_ #define _SYS_PROTO_H_ #include <asm/arch/omap4.h> #include <asm/io.h> struct omap_sysinfo { char *board_string; }; void gpmc_init(void); void watchdog_init(void); u32 get_device_type(void); void invalidate_dcache(u32); void set_muxconf_regs(void); extern const struct omap_sysinfo sysinfo; #endif
#include <linux/delay.h> #include <linux/dma-mapping.h> #include <linux/dmaengine.h> #include <linux/interrupt.h> #include <linux/list.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_dma.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/spinlock.h> #include "../dmaengine.h" #include "../virt-dma.h" /* * struct usb_dmac_sg - Descriptor for a hardware transfer * @mem_addr: memory address * @size: transfer size in bytes */ struct usb_dmac_sg { dma_addr_t mem_addr; u32 size; }; /* * struct usb_dmac_desc - USB DMA Transfer Descriptor * @vd: base virtual channel DMA transaction descriptor * @direction: direction of the DMA transfer * @sg_allocated_len: length of allocated sg * @sg_len: length of sg * @sg_index: index of sg * @residue: residue after the DMAC completed a transfer * @node: node for desc_got and desc_freed * @done_cookie: cookie after the DMAC completed a transfer * @sg: information for the transfer */ struct usb_dmac_desc { struct virt_dma_desc vd; enum <API key> direction; unsigned int sg_allocated_len; unsigned int sg_len; unsigned int sg_index; u32 residue; struct list_head node; dma_cookie_t done_cookie; struct usb_dmac_sg sg[0]; }; #define to_usb_dmac_desc(vd) container_of(vd, struct usb_dmac_desc, vd) /* * struct usb_dmac_chan - USB DMA Controller Channel * @vc: base virtual DMA channel object * @iomem: channel I/O memory base * @index: index of this channel in the controller * @irq: irq number of this channel * @desc: the current descriptor * @descs_allocated: number of descriptors allocated * @desc_got: got descriptors * @desc_freed: freed descriptors after the DMAC completed a transfer */ struct usb_dmac_chan { struct virt_dma_chan vc; void __iomem *iomem; unsigned int index; int irq; struct usb_dmac_desc *desc; int descs_allocated; struct list_head desc_got; struct list_head desc_freed; }; #define to_usb_dmac_chan(c) container_of(c, struct usb_dmac_chan, vc.chan) /* * struct usb_dmac - USB DMA Controller * @engine: base DMA engine object * @dev: the hardware device * @iomem: remapped I/O memory base * @n_channels: number of available channels * @channels: array of DMAC channels */ struct usb_dmac { struct dma_device engine; struct device *dev; void __iomem *iomem; unsigned int n_channels; struct usb_dmac_chan *channels; }; #define to_usb_dmac(d) container_of(d, struct usb_dmac, engine) #define <API key>(i) (0x20 + 0x20 * (i)) #define USB_DMASWR 0x0008 #define USB_DMASWR_SWR (1 << 0) #define USB_DMAOR 0x0060 #define USB_DMAOR_AE (1 << 1) #define USB_DMAOR_DME (1 << 0) #define USB_DMASAR 0x0000 #define USB_DMADAR 0x0004 #define USB_DMATCR 0x0008 #define USB_DMATCR_MASK 0x00ffffff #define USB_DMACHCR 0x0014 #define USB_DMACHCR_FTE (1 << 24) #define USB_DMACHCR_NULLE (1 << 16) #define USB_DMACHCR_NULL (1 << 12) #define USB_DMACHCR_TS_8B ((0 << 7) | (0 << 6)) #define USB_DMACHCR_TS_16B ((0 << 7) | (1 << 6)) #define USB_DMACHCR_TS_32B ((1 << 7) | (0 << 6)) #define USB_DMACHCR_IE (1 << 5) #define USB_DMACHCR_SP (1 << 2) #define USB_DMACHCR_TE (1 << 1) #define USB_DMACHCR_DE (1 << 0) #define USB_DMATEND 0x0018 /* Hardcode the xfer_shift to 5 (32bytes) */ #define USB_DMAC_XFER_SHIFT 5 #define USB_DMAC_XFER_SIZE (1 << USB_DMAC_XFER_SHIFT) #define USB_DMAC_CHCR_TS USB_DMACHCR_TS_32B #define <API key> <API key> /* for descriptors */ #define <API key> 16 #define <API key> 8 static void usb_dmac_write(struct usb_dmac *dmac, u32 reg, u32 data) { writel(data, dmac->iomem + reg); } static u32 usb_dmac_read(struct usb_dmac *dmac, u32 reg) { return readl(dmac->iomem + reg); } static u32 usb_dmac_chan_read(struct usb_dmac_chan *chan, u32 reg) { return readl(chan->iomem + reg); } static void usb_dmac_chan_write(struct usb_dmac_chan *chan, u32 reg, u32 data) { writel(data, chan->iomem + reg); } static bool <API key>(struct usb_dmac_chan *chan) { u32 chcr = usb_dmac_chan_read(chan, USB_DMACHCR); return (chcr & (USB_DMACHCR_DE | USB_DMACHCR_TE)) == USB_DMACHCR_DE; } static u32 usb_dmac_calc_tend(u32 size) { /* * Please refer to the Figure "Example of Final Transaction Valid * Data Transfer Enable (EDTEN) Setting" in the data sheet. */ return 0xffffffff << (32 - (size % USB_DMAC_XFER_SIZE ? : USB_DMAC_XFER_SIZE)); } /* This function is already held by vc.lock */ static void <API key>(struct usb_dmac_chan *chan, unsigned int index) { struct usb_dmac_desc *desc = chan->desc; struct usb_dmac_sg *sg = desc->sg + index; dma_addr_t src_addr = 0, dst_addr = 0; WARN_ON_ONCE(<API key>(chan)); if (desc->direction == DMA_DEV_TO_MEM) dst_addr = sg->mem_addr; else src_addr = sg->mem_addr; dev_dbg(chan->vc.chan.device->dev, "chan%u: queue sg %p: %u@%pad -> %pad\n", chan->index, sg, sg->size, &src_addr, &dst_addr); usb_dmac_chan_write(chan, USB_DMASAR, src_addr & 0xffffffff); usb_dmac_chan_write(chan, USB_DMADAR, dst_addr & 0xffffffff); usb_dmac_chan_write(chan, USB_DMATCR, DIV_ROUND_UP(sg->size, USB_DMAC_XFER_SIZE)); usb_dmac_chan_write(chan, USB_DMATEND, usb_dmac_calc_tend(sg->size)); usb_dmac_chan_write(chan, USB_DMACHCR, USB_DMAC_CHCR_TS | USB_DMACHCR_NULLE | USB_DMACHCR_IE | USB_DMACHCR_DE); } /* This function is already held by vc.lock */ static void <API key>(struct usb_dmac_chan *chan) { struct virt_dma_desc *vd; vd = vchan_next_desc(&chan->vc); if (!vd) { chan->desc = NULL; return; } /* * Remove this request from vc->desc_issued. Otherwise, this driver * will get the previous value from vchan_next_desc() after a transfer * was completed. */ list_del(&vd->node); chan->desc = to_usb_dmac_desc(vd); chan->desc->sg_index = 0; <API key>(chan, 0); } static int usb_dmac_init(struct usb_dmac *dmac) { u16 dmaor; /* Clear all channels and enable the DMAC globally. */ usb_dmac_write(dmac, USB_DMAOR, USB_DMAOR_DME); dmaor = usb_dmac_read(dmac, USB_DMAOR); if ((dmaor & (USB_DMAOR_AE | USB_DMAOR_DME)) != USB_DMAOR_DME) { dev_warn(dmac->dev, "DMAOR initialization failed.\n"); return -EIO; } return 0; } static int usb_dmac_desc_alloc(struct usb_dmac_chan *chan, unsigned int sg_len, gfp_t gfp) { struct usb_dmac_desc *desc; unsigned long flags; desc = kzalloc(sizeof(*desc) + sg_len * sizeof(desc->sg[0]), gfp); if (!desc) return -ENOMEM; desc->sg_allocated_len = sg_len; INIT_LIST_HEAD(&desc->node); spin_lock_irqsave(&chan->vc.lock, flags); list_add_tail(&desc->node, &chan->desc_freed); <API key>(&chan->vc.lock, flags); return 0; } static void usb_dmac_desc_free(struct usb_dmac_chan *chan) { struct usb_dmac_desc *desc, *_desc; LIST_HEAD(list); list_splice_init(&chan->desc_freed, &list); list_splice_init(&chan->desc_got, &list); <API key>(desc, _desc, &list, node) { list_del(&desc->node); kfree(desc); } chan->descs_allocated = 0; } static struct usb_dmac_desc *usb_dmac_desc_get(struct usb_dmac_chan *chan, unsigned int sg_len, gfp_t gfp) { struct usb_dmac_desc *desc = NULL; unsigned long flags; /* Get a freed descritpor */ spin_lock_irqsave(&chan->vc.lock, flags); list_for_each_entry(desc, &chan->desc_freed, node) { if (sg_len <= desc->sg_allocated_len) { list_move_tail(&desc->node, &chan->desc_got); <API key>(&chan->vc.lock, flags); return desc; } } <API key>(&chan->vc.lock, flags); /* Allocate a new descriptor */ if (!usb_dmac_desc_alloc(chan, sg_len, gfp)) { /* If allocated the desc, it was added to tail of the list */ spin_lock_irqsave(&chan->vc.lock, flags); desc = list_last_entry(&chan->desc_freed, struct usb_dmac_desc, node); list_move_tail(&desc->node, &chan->desc_got); <API key>(&chan->vc.lock, flags); return desc; } return NULL; } static void usb_dmac_desc_put(struct usb_dmac_chan *chan, struct usb_dmac_desc *desc) { unsigned long flags; spin_lock_irqsave(&chan->vc.lock, flags); list_move_tail(&desc->node, &chan->desc_freed); <API key>(&chan->vc.lock, flags); } static void usb_dmac_soft_reset(struct usb_dmac_chan *uchan) { struct dma_chan *chan = &uchan->vc.chan; struct usb_dmac *dmac = to_usb_dmac(chan->device); int i; /* Don't issue soft reset if any one of channels is busy */ for (i = 0; i < dmac->n_channels; ++i) { if (<API key>(uchan)) return; } usb_dmac_write(dmac, USB_DMAOR, 0); usb_dmac_write(dmac, USB_DMASWR, USB_DMASWR_SWR); udelay(100); usb_dmac_write(dmac, USB_DMASWR, 0); usb_dmac_write(dmac, USB_DMAOR, 1); } static void usb_dmac_chan_halt(struct usb_dmac_chan *chan) { u32 chcr = usb_dmac_chan_read(chan, USB_DMACHCR); chcr &= ~(USB_DMACHCR_IE | USB_DMACHCR_TE | USB_DMACHCR_DE); usb_dmac_chan_write(chan, USB_DMACHCR, chcr); usb_dmac_soft_reset(chan); } static void usb_dmac_stop(struct usb_dmac *dmac) { usb_dmac_write(dmac, USB_DMAOR, 0); } static int <API key>(struct dma_chan *chan) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); int ret; while (uchan->descs_allocated < <API key>) { ret = usb_dmac_desc_alloc(uchan, <API key>, GFP_KERNEL); if (ret < 0) { usb_dmac_desc_free(uchan); return ret; } uchan->descs_allocated++; } return pm_runtime_get_sync(chan->device->dev); } static void <API key>(struct dma_chan *chan) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); unsigned long flags; /* Protect against ISR */ spin_lock_irqsave(&uchan->vc.lock, flags); usb_dmac_chan_halt(uchan); <API key>(&uchan->vc.lock, flags); usb_dmac_desc_free(uchan); <API key>(&uchan->vc); pm_runtime_put(chan->device->dev); } static struct <API key> * <API key>(struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum <API key> dir, unsigned long dma_flags, void *context) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); struct usb_dmac_desc *desc; struct scatterlist *sg; int i; if (!sg_len) { dev_warn(chan->device->dev, "%s: bad parameter: len=%d\n", __func__, sg_len); return NULL; } desc = usb_dmac_desc_get(uchan, sg_len, GFP_NOWAIT); if (!desc) return NULL; desc->direction = dir; desc->sg_len = sg_len; for_each_sg(sgl, sg, sg_len, i) { desc->sg[i].mem_addr = sg_dma_address(sg); desc->sg[i].size = sg_dma_len(sg); } return vchan_tx_prep(&uchan->vc, &desc->vd, dma_flags); } static int <API key>(struct dma_chan *chan) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); struct usb_dmac_desc *desc; unsigned long flags; LIST_HEAD(head); LIST_HEAD(list); spin_lock_irqsave(&uchan->vc.lock, flags); usb_dmac_chan_halt(uchan); <API key>(&uchan->vc, &head); if (uchan->desc) uchan->desc = NULL; list_splice_init(&uchan->desc_got, &list); list_for_each_entry(desc, &list, node) list_move_tail(&desc->node, &uchan->desc_freed); <API key>(&uchan->vc.lock, flags); <API key>(&uchan->vc, &head); return 0; } static unsigned int <API key>(struct usb_dmac_chan *chan, struct usb_dmac_desc *desc, int sg_index) { struct usb_dmac_sg *sg = desc->sg + sg_index; u32 mem_addr = sg->mem_addr & 0xffffffff; unsigned int residue = sg->size; /* * We cannot use USB_DMATCR to calculate residue because USB_DMATCR * has unsuited value to calculate. */ if (desc->direction == DMA_DEV_TO_MEM) residue -= usb_dmac_chan_read(chan, USB_DMADAR) - mem_addr; else residue -= usb_dmac_chan_read(chan, USB_DMASAR) - mem_addr; return residue; } static u32 <API key>(struct usb_dmac_chan *chan, dma_cookie_t cookie) { struct usb_dmac_desc *desc; u32 residue = 0; <API key>(desc, &chan->desc_freed, node) { if (desc->done_cookie == cookie) { residue = desc->residue; break; } } return residue; } static u32 <API key>(struct usb_dmac_chan *chan, dma_cookie_t cookie) { u32 residue = 0; struct virt_dma_desc *vd; struct usb_dmac_desc *desc = chan->desc; int i; if (!desc) { vd = vchan_find_desc(&chan->vc, cookie); if (!vd) return 0; desc = to_usb_dmac_desc(vd); } /* Compute the size of all usb_dmac_sg still to be transferred */ for (i = desc->sg_index + 1; i < desc->sg_len; i++) residue += desc->sg[i].size; /* Add the residue for the current sg */ residue += <API key>(chan, desc, desc->sg_index); return residue; } static enum dma_status usb_dmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); enum dma_status status; unsigned int residue = 0; unsigned long flags; status = dma_cookie_status(chan, cookie, txstate); /* a client driver will get residue after DMA_COMPLETE */ if (!txstate) return status; spin_lock_irqsave(&uchan->vc.lock, flags); if (status == DMA_COMPLETE) residue = <API key>(uchan, cookie); else residue = <API key>(uchan, cookie); <API key>(&uchan->vc.lock, flags); dma_set_residue(txstate, residue); return status; } static void <API key>(struct dma_chan *chan) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); unsigned long flags; spin_lock_irqsave(&uchan->vc.lock, flags); if (vchan_issue_pending(&uchan->vc) && !uchan->desc) <API key>(uchan); <API key>(&uchan->vc.lock, flags); } static void <API key>(struct virt_dma_desc *vd) { struct usb_dmac_desc *desc = to_usb_dmac_desc(vd); struct usb_dmac_chan *chan = to_usb_dmac_chan(vd->tx.chan); usb_dmac_desc_put(chan, desc); } static void <API key>(struct usb_dmac_chan *chan) { struct usb_dmac_desc *desc = chan->desc; BUG_ON(!desc); if (++desc->sg_index < desc->sg_len) { <API key>(chan, desc->sg_index); } else { desc->residue = <API key>(chan, desc, desc->sg_index - 1); desc->done_cookie = desc->vd.tx.cookie; <API key>(&desc->vd); /* Restart the next transfer if this driver has a next desc */ <API key>(chan); } } static irqreturn_t <API key>(int irq, void *dev) { struct usb_dmac_chan *chan = dev; irqreturn_t ret = IRQ_NONE; u32 mask = 0; u32 chcr; bool xfer_end = false; spin_lock(&chan->vc.lock); chcr = usb_dmac_chan_read(chan, USB_DMACHCR); if (chcr & (USB_DMACHCR_TE | USB_DMACHCR_SP)) { mask |= USB_DMACHCR_DE | USB_DMACHCR_TE | USB_DMACHCR_SP; if (chcr & USB_DMACHCR_DE) xfer_end = true; ret |= IRQ_HANDLED; } if (chcr & USB_DMACHCR_NULL) { /* An interruption of TE will happen after we set FTE */ mask |= USB_DMACHCR_NULL; chcr |= USB_DMACHCR_FTE; ret |= IRQ_HANDLED; } if (mask) usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); if (xfer_end) <API key>(chan); spin_unlock(&chan->vc.lock); return ret; } static bool <API key>(struct dma_chan *chan, void *arg) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); struct of_phandle_args *dma_spec = arg; if (dma_spec->np != chan->device->dev->of_node) return false; /* USB-DMAC should be used with fixed usb controller's FIFO */ if (uchan->index != dma_spec->args[0]) return false; return true; } static struct dma_chan *usb_dmac_of_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct usb_dmac_chan *uchan; struct dma_chan *chan; dma_cap_mask_t mask; if (dma_spec->args_count != 1) return NULL; /* Only slave DMA channels can be allocated via DT */ dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); chan = dma_request_channel(mask, <API key>, dma_spec); if (!chan) return NULL; uchan = to_usb_dmac_chan(chan); return chan; } #ifdef CONFIG_PM static int <API key>(struct device *dev) { struct usb_dmac *dmac = dev_get_drvdata(dev); int i; for (i = 0; i < dmac->n_channels; ++i) { if (!dmac->channels[i].iomem) break; usb_dmac_chan_halt(&dmac->channels[i]); } return 0; } static int <API key>(struct device *dev) { struct usb_dmac *dmac = dev_get_drvdata(dev); return usb_dmac_init(dmac); } #endif /* CONFIG_PM */ static const struct dev_pm_ops usb_dmac_pm = { SET_RUNTIME_PM_OPS(<API key>, <API key>, NULL) }; static int usb_dmac_chan_probe(struct usb_dmac *dmac, struct usb_dmac_chan *uchan, unsigned int index) { struct platform_device *pdev = to_platform_device(dmac->dev); char pdev_irqname[5]; char *irqname; int ret; uchan->index = index; uchan->iomem = dmac->iomem + <API key>(index); /* Request the channel interrupt. */ sprintf(pdev_irqname, "ch%u", index); uchan->irq = <API key>(pdev, pdev_irqname); if (uchan->irq < 0) { dev_err(dmac->dev, "no IRQ specified for channel %u\n", index); return -ENODEV; } irqname = devm_kasprintf(dmac->dev, GFP_KERNEL, "%s:%u", dev_name(dmac->dev), index); if (!irqname) return -ENOMEM; ret = devm_request_irq(dmac->dev, uchan->irq, <API key>, IRQF_SHARED, irqname, uchan); if (ret) { dev_err(dmac->dev, "failed to request IRQ %u (%d)\n", uchan->irq, ret); return ret; } uchan->vc.desc_free = <API key>; vchan_init(&uchan->vc, &dmac->engine); INIT_LIST_HEAD(&uchan->desc_freed); INIT_LIST_HEAD(&uchan->desc_got); return 0; } static int usb_dmac_parse_of(struct device *dev, struct usb_dmac *dmac) { struct device_node *np = dev->of_node; int ret; ret = <API key>(np, "dma-channels", &dmac->n_channels); if (ret < 0) { dev_err(dev, "unable to read dma-channels property\n"); return ret; } if (dmac->n_channels <= 0 || dmac->n_channels >= 100) { dev_err(dev, "invalid number of channels %u\n", dmac->n_channels); return -EINVAL; } return 0; } static int usb_dmac_probe(struct platform_device *pdev) { const enum dma_slave_buswidth widths = <API key>; struct dma_device *engine; struct usb_dmac *dmac; struct resource *mem; unsigned int i; int ret; dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); if (!dmac) return -ENOMEM; dmac->dev = &pdev->dev; <API key>(pdev, dmac); ret = usb_dmac_parse_of(&pdev->dev, dmac); if (ret < 0) return ret; dmac->channels = devm_kcalloc(&pdev->dev, dmac->n_channels, sizeof(*dmac->channels), GFP_KERNEL); if (!dmac->channels) return -ENOMEM; /* Request resources. */ mem = <API key>(pdev, IORESOURCE_MEM, 0); dmac->iomem = <API key>(&pdev->dev, mem); if (IS_ERR(dmac->iomem)) return PTR_ERR(dmac->iomem); /* Enable runtime PM and initialize the device. */ pm_runtime_enable(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) { dev_err(&pdev->dev, "runtime PM get sync failed (%d)\n", ret); goto error_pm; } ret = usb_dmac_init(dmac); if (ret) { dev_err(&pdev->dev, "failed to reset device\n"); goto error; } /* Initialize the channels. */ INIT_LIST_HEAD(&dmac->engine.channels); for (i = 0; i < dmac->n_channels; ++i) { ret = usb_dmac_chan_probe(dmac, &dmac->channels[i], i); if (ret < 0) goto error; } /* Register the DMAC as a DMA provider for DT. */ ret = <API key>(pdev->dev.of_node, usb_dmac_of_xlate, NULL); if (ret < 0) goto error; /* * Register the DMA engine device. * * Default transfer size of 32 bytes requires 32-byte alignment. */ engine = &dmac->engine; dma_cap_set(DMA_SLAVE, engine->cap_mask); engine->dev = &pdev->dev; engine->src_addr_widths = widths; engine->dst_addr_widths = widths; engine->directions = BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM); engine->residue_granularity = <API key>; engine-><API key> = <API key>; engine-><API key> = <API key>; engine-><API key> = <API key>; engine-><API key> = <API key>; engine->device_tx_status = usb_dmac_tx_status; engine-><API key> = <API key>; ret = <API key>(engine); if (ret < 0) goto error; pm_runtime_put(&pdev->dev); return 0; error: <API key>(pdev->dev.of_node); pm_runtime_put(&pdev->dev); error_pm: pm_runtime_disable(&pdev->dev); return ret; } static void <API key>(struct usb_dmac *dmac, struct usb_dmac_chan *uchan) { usb_dmac_chan_halt(uchan); devm_free_irq(dmac->dev, uchan->irq, uchan); } static int usb_dmac_remove(struct platform_device *pdev) { struct usb_dmac *dmac = <API key>(pdev); int i; for (i = 0; i < dmac->n_channels; ++i) <API key>(dmac, &dmac->channels[i]); <API key>(pdev->dev.of_node); <API key>(&dmac->engine); pm_runtime_disable(&pdev->dev); return 0; } static void usb_dmac_shutdown(struct platform_device *pdev) { struct usb_dmac *dmac = <API key>(pdev); usb_dmac_stop(dmac); } static const struct of_device_id usb_dmac_of_ids[] = { { .compatible = "renesas,usb-dmac", }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, usb_dmac_of_ids); static struct platform_driver usb_dmac_driver = { .driver = { .pm = &usb_dmac_pm, .name = "usb-dmac", .of_match_table = usb_dmac_of_ids, }, .probe = usb_dmac_probe, .remove = usb_dmac_remove, .shutdown = usb_dmac_shutdown, }; <API key>(usb_dmac_driver); MODULE_DESCRIPTION("Renesas USB DMA Controller Driver"); MODULE_AUTHOR("Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>"); MODULE_LICENSE("GPL v2");
<?php namespace VuFind\Search\SolrAuth; class Results extends \VuFind\Search\Solr\Results { /** * Constructor * * @param \VuFind\Search\Base\Params $params Object representing user search * parameters. */ public function __construct(\VuFind\Search\Base\Params $params) { parent::__construct($params); $this->backendId = 'SolrAuth'; } }
#!/usr/bin/env python from runtest import TestBase class TestCase(TestBase): def __init__(self): TestBase.__init__(self, 'abc', """ # DURATION TID FUNCTION 62.202 us [28141] | __cxa_atexit(); [28141] | main() { [28141] | a() { [28141] | b() { [28141] | c() { 0.753 us [28141] | getpid(); 1.430 us [28141] | } /* c */ 1.915 us [28141] | } /* b */ 2.405 us [28141] | } /* a */ 3.005 us [28141] | } /* main */ """)
using System; using System.Collections; namespace FSpot { public class DirectoryAdaptor : GroupAdaptor { System.Collections.DictionaryEntry [] dirs; // FIXME store the Photo.Id list here not just the count private class Group : IComparer { public int Count = 1; public int Compare (object obj1, object obj2) { // FIXME use a real exception if (obj1 is DictionaryEntry && obj2 is DictionaryEntry) return Compare ((DictionaryEntry)obj1, (DictionaryEntry)obj2); else throw new Exception ("I can't compare that"); } private static int Compare (DictionaryEntry de1, DictionaryEntry de2) { return string.Compare ((string)de1.Key, (string)de2.Key); } } public override event GlassSetHandler GlassSet; public override void SetGlass (int group) { if (group < 0 || group > dirs.Length) return; Console.WriteLine ("Selected Path {0}", dirs [group].Key); int item = LookupItem (group); if (GlassSet != null) GlassSet (this, item); } public override int Count () { return dirs.Length; } public override string GlassLabel (int item) { return (string)dirs [item].Key; } public override string TickLabel (int item) { return null; } public override int Value (int item) { return ((DirectoryAdaptor.Group)dirs [item].Value).Count; } public override event ChangedHandler Changed; protected override void Reload () { System.Collections.Hashtable ht = new System.Collections.Hashtable (); Photo [] photos = query.Store.Query ((Tag [])null, null, null, null); foreach (Photo p in photos) { if (ht.Contains (p.DirectoryPath)) { DirectoryAdaptor.Group group = (DirectoryAdaptor.Group) ht [p.DirectoryPath]; group.Count += 1; } else ht [p.DirectoryPath] = new DirectoryAdaptor.Group (); } Console.WriteLine ("Count = {0}", ht.Count); dirs = new System.Collections.DictionaryEntry [ht.Count]; ht.CopyTo (dirs, 0); Array.Sort (dirs, new DirectoryAdaptor.Group ()); Array.Sort (query.Photos, new Photo.CompareDirectory ()); if (!order_ascending) { Array.Reverse (dirs); Array.Reverse (query.Photos); } if (Changed != null) Changed (this); } public override int IndexFromPhoto(FSpot.IBrowsableItem item) { Photo photo = (Photo)item; string directory_path = photo.DirectoryPath; for (int i = 0; i < dirs.Length; i++) { if ((string)dirs [i].Key == directory_path) { return i; } } // FIXME not truly implemented return 0; } public override FSpot.IBrowsableItem PhotoFromIndex (int item) { return query.Items [LookupItem (item)]; } private int LookupItem (int group) { int i = 0; while (i < query.Count) { if (((Photo)(query [i])).DirectoryPath == (string)dirs [group].Key) { return i; } i++; } return 0; } public DirectoryAdaptor (PhotoQuery query) : base (query) { } } }
<?php class <API key> { function __construct(){ global $aio_wp_security; if ($aio_wp_security->configs->get_value('<API key>') == '1') { add_action( 'widgets_init', array(&$this, '<API key>' )); add_filter( '<API key>', array(&$this, 'decode_reset_pw_msg'), 10, 4); //Fix for non decoded html entities in password reset link } add_action('admin_notices', array(&$this,'<API key>')); if(isset($_REQUEST['<API key>'])){ if(strip_tags($_REQUEST['<API key>']) == 1){ include_once ('<API key>.php'); if(<API key>::reactivation_tasks()){ echo '<div class="updated"><p>The AIOWPS .htaccess rules were successfully re-inserted.</p></div>'; }else{ echo '<div class="error"><p>AIOWPS encountered an error when trying to write to your .htaccess file. Please check the logs.</p></div>'; } }elseif(strip_tags($_REQUEST['<API key>']) == 2){ //Don't re-write the rules and just delete the temp config item delete_option('aiowps_temp_configs'); } } if($aio_wp_security->configs->get_value('<API key>') == '1'){ <API key>(); //send X-Frame-Options: SAMEORIGIN in HTTP header } if($aio_wp_security->configs->get_value('<API key>') == '1'){ add_filter('the_generator', array(&$this,'<API key>')); } //For the cookie based brute force prevention feature if($aio_wp_security->configs->get_value('<API key>') == 1){ $bfcf_secret_word = $aio_wp_security->configs->get_value('<API key>'); if(isset($_GET[$bfcf_secret_word])){ //If URL contains secret word in query param then set cookie and then redirect to the login page <API key>::set_cookie_value($bfcf_secret_word, "1"); <API key>::redirect_to_url(AIOWPSEC_WP_URL."/wp-admin"); } } //For user unlock request feature if(isset($_POST['<API key>']) || isset($_POST['<API key>'])){ nocache_headers(); remove_action('wp_head','head_addons',7); include_once(<API key>.'/other-includes/<API key>.php'); exit(); } if(isset($_GET['aiowps_auth_key'])){ //If URL contains unlock key in query param then process the request $unlock_key = strip_tags($_GET['aiowps_auth_key']); <API key>::<API key>($unlock_key); } //For honeypot feature if(isset($_POST['aio_special_field'])){ $special_field_value = strip_tags($_POST['aio_special_field']); if(!empty($special_field_value)){ //This means a robot has submitted the login form! //Redirect back to its localhost <API key>::redirect_to_url('http://127.0.0.1'); } } //For 404 IP lockout feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in() || !current_user_can('administrator')) { $this-><API key>(); } } //For login captcha feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_action('login_form', array(&$this, '<API key>')); } } //For custom login form captcha feature, ie, when wp_login_form() function is used to generate login form if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_filter( 'login_form_middle', array(&$this, '<API key>'), 10, 2); //For cases where the WP wp_login_form() function is used } } //For honeypot feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_action('login_form', array(&$this, '<API key>')); } } //For lost password captcha feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_action('lostpassword_form', array(&$this, '<API key>')); add_action('lostpassword_post', array(&$this, '<API key>')); } } //For registration page captcha feature if (<API key>::<API key>()){ $blog_id = get_current_blog_id(); switch_to_blog($blog_id); if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_action('signup_extra_fields', array(&$this, '<API key>')); //add_action('<API key>', array(&$this, '<API key>')); add_filter( '<API key>', array(&$this, '<API key>') ); } } <API key>(); }else{ if($aio_wp_security->configs->get_value('<API key>') == '1'){ if (!is_user_logged_in()) { add_action('register_form', array(&$this, '<API key>')); } } } //For comment captcha feature if (<API key>::<API key>()){ $blog_id = get_current_blog_id(); switch_to_blog($blog_id); if($aio_wp_security->configs->get_value('<API key>') == '1'){ add_action( '<API key>', array(&$this, '<API key>'), 1 ); add_action( '<API key>', array(&$this, '<API key>'), 1 ); add_filter( 'preprocess_comment', array(&$this, '<API key>') ); } <API key>(); }else{ if($aio_wp_security->configs->get_value('<API key>') == '1'){ add_action( '<API key>', array(&$this, '<API key>'), 1 ); add_action( '<API key>', array(&$this, '<API key>'), 1 ); add_filter( 'preprocess_comment', array(&$this, '<API key>') ); } } //For buddypress registration captcha feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ add_action('<API key>', array(&$this, '<API key>')); add_action('bp_signup_validate', array(&$this, '<API key>')); } //For feature which displays logged in users $this-><API key>(); //For block fake googlebots feature if($aio_wp_security->configs->get_value('<API key>') == '1'){ include_once(<API key>.'/classes/<API key>.php'); <API key>::<API key>(); } //For 404 event logging if($aio_wp_security->configs->get_value('<API key>') == '1'){ add_action('wp_head', array(&$this, 'check_404_event')); } //Add more tasks that need to be executed at init time } function <API key>() { unregister_widget('WP_Widget_Meta'); } function <API key>() { return ''; } function <API key>(){ global $aio_wp_security; $redirect_url = $aio_wp_security->configs->get_value('<API key>'); //This is the redirect URL for blocked users $visitor_ip = <API key>::get_user_ip_address(); $is_locked = <API key>::check_locked_ip($visitor_ip); if($is_locked){ //redirect blocked user to configured URL <API key>::redirect_to_url($redirect_url); }else{ //allow through } } function <API key>(){ if(is_user_logged_in()){ $current_user_ip = <API key>::get_user_ip_address(); // get the logged in users list from transients entry $logged_in_users = (<API key>::<API key>() ? get_site_transient('users_online') : get_transient('users_online')); $current_user = wp_get_current_user(); $current_user = $current_user->ID; $current_time = current_time('timestamp'); $current_user_info = array("user_id" => $current_user, "last_activity" => $current_time, "ip_address" => $current_user_ip); //We will store last activity time and ip address in transient entry if($logged_in_users === false || $logged_in_users == NULL){ $logged_in_users = array(); $logged_in_users[] = $current_user_info; <API key>::<API key>() ? set_site_transient('users_online', $logged_in_users, 30 * 60) : set_transient('users_online', $logged_in_users, 30 * 60); } else { $key = 0; $do_nothing = false; $update_existing = false; $item_index = 0; foreach ($logged_in_users as $value) { if($value['user_id'] == $current_user && strcmp($value['ip_address'], $current_user_ip) == 0) { if ($value['last_activity'] < ($current_time - (15 * 60))) { $update_existing = true; $item_index = $key; break; }else{ $do_nothing = true; break; } } $key++; } if($update_existing) { //Update transient if the last activity was less than 15 min ago for this user $logged_in_users[$item_index] = $current_user_info; <API key>::<API key>() ? set_site_transient('users_online', $logged_in_users, 30 * 60) : set_transient('users_online', $logged_in_users, 30 * 60); }else if($do_nothing){ //Do nothing }else{ $logged_in_users[] = $current_user_info; <API key>::<API key>() ? set_site_transient('users_online', $logged_in_users, 30 * 60) : set_transient('users_online', $logged_in_users, 30 * 60); } } } } function <API key>($cust_html_code, $args) { global $aio_wp_security; $cap_form = '<p class="aiowps-captcha"><label>'.__('Please enter an answer in digits:','aiowpsecurity').'</label>'; $cap_form .= '<div class="<API key>"><strong>'; $<API key> = $aio_wp_security->captcha_obj-><API key>(); $cap_form .= $<API key> . '</strong></div></p>'; $cust_html_code .= $cap_form; return $cust_html_code; } function <API key>($error) { global $aio_wp_security; $aio_wp_security->captcha_obj-><API key>(); } function <API key>($result) { global $aio_wp_security; //Check if captcha enabled if (array_key_exists('<API key>', $_POST)) //If the register form with captcha was submitted then do some processing { isset($_POST['<API key>'])?$captcha_answer = strip_tags(trim($_POST['<API key>'])): $captcha_answer = ''; $<API key> = $aio_wp_security->configs->get_value('<API key>'); $<API key> = base64_encode($_POST['<API key>'].$<API key>.$captcha_answer); if($<API key> !== $_POST['<API key>']) { //This means a wrong answer was entered $result['errors']->add('generic', __('<strong>ERROR</strong>: Your answer was incorrect - please try again.', 'aiowpsecurity')); } } return $result; } function <API key>(){ global $aio_wp_security; $aio_wp_security->captcha_obj-><API key>(); } function <API key>(){ $honey_input = '<p style="display: none;"><label>'.__('Enter something special:','aiowpsecurity').'</label>'; $honey_input .= '<input name="aio_special_field" type="text" id="aio_special_field" class="aio_special_field" /></p>'; echo $honey_input; } function <API key>( $comment ) { global $aio_wp_security; if (is_user_logged_in()) { return $comment; } //Don't process captcha for comment replies inside admin menu if (isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'replyto-comment' && (check_ajax_referer('replyto-comment', '_ajax_nonce', false) || check_ajax_referer('replyto-comment', '<API key>', false))) { return $comment; } //Don't do captcha for pingback/trackback if ($comment['comment_type'] != '' && $comment['comment_type'] != 'comment') { return $comment; } if (isset($_REQUEST['<API key>'])) { // If answer is empty if ($_REQUEST['<API key>'] == ''){ wp_die( __('Please enter an answer in the CAPTCHA field.', 'aiowpsecurity' ) ); } $captcha_answer = trim($_REQUEST['<API key>']); $<API key> = $aio_wp_security->configs->get_value('<API key>'); $<API key> = base64_encode($_POST['<API key>'].$<API key>.$captcha_answer); if ($_REQUEST['<API key>'] === $<API key>){ //Correct answer given return($comment); }else{ //Wrong answer wp_die( __('Error: You entered an incorrect CAPTCHA answer. Please go back and try again.', 'aiowpsecurity')); } } } function <API key>() { global $aio_wp_security; //Check if captcha enabled if ($aio_wp_security->configs->get_value('<API key>') == '1') { if (array_key_exists('<API key>', $_POST)) //If the lost pass form with captcha was submitted then do some processing { isset($_POST['<API key>'])?($captcha_answer = strip_tags(trim($_POST['<API key>']))):($captcha_answer = ''); $<API key> = $aio_wp_security->configs->get_value('<API key>'); $<API key> = base64_encode($_POST['<API key>'].$<API key>.$captcha_answer); if($<API key> !== $_POST['<API key>']) { add_filter('<API key>', array(&$this, 'add_lost<API key>)); } } } } function add_lost<API key>() { //Insert an error just before the password reset process kicks in return new WP_Error('<API key>',__('<strong>ERROR</strong>: Your answer was incorrect - please try again.', 'aiowpsecurity')); } function check_404_event() { if(is_404()){ //This means a 404 event has occurred - let's log it! <API key>::event_logger('404'); } } function <API key>($errors) { global $bp, $aio_wp_security; //Check if captcha enabled if (array_key_exists('<API key>', $_POST)) //If the register form with captcha was submitted then do some processing { isset($_POST['<API key>'])?$captcha_answer = strip_tags(trim($_POST['<API key>'])): $captcha_answer = ''; $<API key> = $aio_wp_security->configs->get_value('<API key>'); $<API key> = base64_encode($_POST['<API key>'].$<API key>.$captcha_answer); if($<API key> !== $_POST['<API key>']) { //This means a wrong answer was entered $bp->signup->errors['<API key>'] = __('Your CAPTCHA answer was incorrect - please try again.', 'aiowpsecurity'); } } return; } //Displays a notice message if the plugin was reactivated after being initially deactivated. //Notice message gives users option of re-applying the aiowps rules which were deleted from the .htaccess when deactivation occurred function <API key>() { if (get_option('aiowps_temp_configs') !== FALSE){ echo '<div class="updated"><p>Would you like All In One WP Security & Firewall to re-insert the security rules in your .htaccess file which were cleared when you deactivated the plugin?&nbsp;&nbsp;<a href="admin.php?page='.<API key>.'&<API key>=1" class="button-primary">Yes</a>&nbsp;&nbsp;<a href="admin.php?page='.<API key>.'&<API key>=2" class="button-primary">No</a></p></div>'; } } //This is a fix for cases when the password reset URL in the email was not decoding all html entities properly function decode_reset_pw_msg($message, $key, $user_login, $user_data) { global $aio_wp_security; $message = html_entity_decode($message); return $message; } }
function c1802450.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(<API key>) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetTarget(c1802450.target1) e1:SetOperation(c1802450.operation) c:RegisterEffect(e1) --remove local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(1802450,1)) e2:SetProperty(<API key>) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_FREE_CHAIN) e2:SetHintTiming(0,TIMING_END_PHASE) e2:SetCost(c1802450.cost2) e2:SetTarget(c1802450.target2) e2:SetOperation(c1802450.operation) c:RegisterEffect(e2) end function c1802450.cfilter(c) return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_EARTH) end function c1802450.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end if chk==0 then return true end if Duel.CheckReleaseGroup(tp,c1802450.cfilter,1,nil) and Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(1802450,0)) then e:SetProperty(<API key>) local cg=Duel.SelectReleaseGroup(tp,c1802450.cfilter,1,1,nil) Duel.Release(cg,REASON_COST) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,2,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0) e:GetHandler():RegisterFlagEffect(1802450,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) else e:SetProperty(0) end end function c1802450.cost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,c1802450.cfilter,1,nil) end local cg=Duel.SelectReleaseGroup(tp,c1802450.cfilter,1,1,nil) Duel.Release(cg,REASON_COST) end function c1802450.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end if chk==0 then return e:GetHandler():GetFlagEffect(1802450)==0 and Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,2,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0) e:GetHandler():RegisterFlagEffect(1802450,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) end function c1802450.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetChainInfo(0,<API key>) if not g then return end g=g:Filter(Card.IsRelateToEffect,nil,e) Duel.Remove(g,POS_FACEUP,REASON_EFFECT) end
package javax.crypto; import java.io.*; /** * A CipherOutputStream is composed of an OutputStream and a Cipher so * that write() methods first process the data before writing them out * to the underlying OutputStream. The cipher must be fully * initialized before being used by a CipherOutputStream. * * <p> For example, if the cipher is initialized for encryption, the * CipherOutputStream will attempt to encrypt data before writing out the * encrypted data. * * <p> This class adheres strictly to the semantics, especially the * failure semantics, of its ancestor classes * java.io.OutputStream and java.io.FilterOutputStream. This class * has exactly those methods specified in its ancestor classes, and * overrides them all. Moreover, this class catches all exceptions * that are not thrown by its ancestor classes. In particular, this * class catches BadPaddingException and other exceptions thrown by * failed integrity checks during decryption. These exceptions are not * re-thrown, so the client will not be informed that integrity checks * failed. Because of this behavior, this class may not be suitable * for use with decryption in an authenticated mode of operation (e.g. GCM) * if the application requires explicit notification when authentication * fails. Such an application can use the Cipher API directly as an * alternative to using this class. * * <p> It is crucial for a programmer using this class not to use * methods that are not defined or overriden in this class (such as a * new method or constructor that is later added to one of the super * classes), because the design and implementation of those methods * are unlikely to have considered security impact with regard to * CipherOutputStream. * * @author Li Gong * @see java.io.OutputStream * @see java.io.FilterOutputStream * @see javax.crypto.Cipher * @see javax.crypto.CipherInputStream * * @since 1.4 */ public class CipherOutputStream extends FilterOutputStream { // the cipher engine to use to process stream data private Cipher cipher; // the underlying output stream private OutputStream output; /* the buffer holding one byte of incoming data */ private byte[] ibuffer = new byte[1]; // the buffer holding data ready to be written out private byte[] obuffer; // stream status private boolean closed = false; /** * * Constructs a CipherOutputStream from an OutputStream and a * Cipher. * <br>Note: if the specified output stream or cipher is * null, a <API key> may be thrown later when * they are used. * * @param os the OutputStream object * @param c an initialized Cipher object */ public CipherOutputStream(OutputStream os, Cipher c) { super(os); output = os; cipher = c; }; /** * Constructs a CipherOutputStream from an OutputStream without * specifying a Cipher. This has the effect of constructing a * CipherOutputStream using a NullCipher. * <br>Note: if the specified output stream is null, a * <API key> may be thrown later when it is used. * * @param os the OutputStream object */ protected CipherOutputStream(OutputStream os) { super(os); output = os; cipher = new NullCipher(); } /** * Writes the specified byte to this output stream. * * @param b the <code>byte</code>. * @exception IOException if an I/O error occurs. * @since JCE1.2 */ public void write(int b) throws IOException { ibuffer[0] = (byte) b; obuffer = cipher.update(ibuffer, 0, 1); if (obuffer != null) { output.write(obuffer); obuffer = null; } }; /** * Writes <code>b.length</code> bytes from the specified byte array * to this output stream. * <p> * The <code>write</code> method of * <code>CipherOutputStream</code> calls the <code>write</code> * method of three arguments with the three arguments * <code>b</code>, <code>0</code>, and <code>b.length</code>. * * @param b the data. * @exception <API key> if <code>b</code> is null. * @exception IOException if an I/O error occurs. * @see javax.crypto.CipherOutputStream#write(byte[], int, int) * @since JCE1.2 */ public void write(byte b[]) throws IOException { write(b, 0, b.length); } /** * Writes <code>len</code> bytes from the specified byte array * starting at offset <code>off</code> to this output stream. * * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. * @since JCE1.2 */ public void write(byte b[], int off, int len) throws IOException { obuffer = cipher.update(b, off, len); if (obuffer != null) { output.write(obuffer); obuffer = null; } } /** * Flushes this output stream by forcing any buffered output bytes * that have already been processed by the encapsulated cipher object * to be written out. * * <p>Any bytes buffered by the encapsulated cipher * and waiting to be processed by it will not be written out. For example, * if the encapsulated cipher is a block cipher, and the total number of * bytes written using one of the <code>write</code> methods is less than * the cipher's block size, no bytes will be written out. * * @exception IOException if an I/O error occurs. * @since JCE1.2 */ public void flush() throws IOException { if (obuffer != null) { output.write(obuffer); obuffer = null; } output.flush(); } /** * Closes this output stream and releases any system resources * associated with this stream. * <p> * This method invokes the <code>doFinal</code> method of the encapsulated * cipher object, which causes any bytes buffered by the encapsulated * cipher to be processed. The result is written out by calling the * <code>flush</code> method of this output stream. * <p> * This method resets the encapsulated cipher object to its initial state * and calls the <code>close</code> method of the underlying output * stream. * * @exception IOException if an I/O error occurs. * @since JCE1.2 */ public void close() throws IOException { if (closed) { return; } closed = true; try { obuffer = cipher.doFinal(); } catch (<API key> | BadPaddingException e) { obuffer = null; } try { flush(); } catch (IOException ignored) {} out.close(); } }
#include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/io.h> #include <linux/irq.h> #include <linux/i2c.h> #include <linux/i2c/sx150x.h> #include <linux/i2c/isl9519.h> #include <linux/gpio.h> #include <linux/msm_ssbi.h> #include <linux/regulator/gpio-regulator.h> #include <linux/mfd/pm8xxx/pm8921.h> #include <linux/mfd/pm8xxx/pm8xxx-adc.h> #include <linux/regulator/consumer.h> #include <linux/spi/spi.h> #include <linux/slimbus/slimbus.h> #include <linux/bootmem.h> #include <linux/msm_kgsl.h> #ifdef CONFIG_ANDROID_PMEM #include <linux/android_pmem.h> #endif #include <linux/cyttsp.h> #include <linux/dma-mapping.h> #include <linux/platform_data/qcom_crypto_device.h> #include <linux/platform_data/qcom_wcnss_device.h> #include <linux/leds.h> #include <linux/leds-pm8xxx.h> #include <linux/i2c/atmel_mxt_ts.h> #include <linux/msm_tsens.h> #include <linux/ks8851.h> #include <linux/i2c/isa1200.h> #include <linux/gpio_keys.h> #include <linux/memory.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/setup.h> #include <asm/hardware/gic.h> #include <asm/mach/mmc.h> #include <mach/board.h> #include <mach/msm_iomap.h> #include <mach/msm_spi.h> #ifdef <API key> #include <mach/msm_hsusb.h> #else #include <linux/usb/msm_hsusb.h> #endif #include <linux/usb/android.h> #include <mach/usbdiag.h> #include <mach/socinfo.h> #include <mach/rpm.h> #include <mach/gpio.h> #include <mach/gpiomux.h> #include <mach/msm_bus_board.h> #include <mach/msm_memtypes.h> #include <mach/dma.h> #include <mach/msm_xo.h> #include <mach/restart.h> #ifdef <API key> #include <linux/slimbus/slimbus.h> #include <linux/mfd/wcd9310/core.h> #include <linux/mfd/wcd9310/pdata.h> #endif #include <linux/ion.h> #include <mach/ion.h> #include <mach/mdm2.h> #include <mach/msm_rtb.h> #include "timer.h" #include "devices.h" #include "devices-msm8x60.h" #include "spm.h" #include "pm.h" #include <mach/cpuidle.h> #include "rpm_resources.h" #include <mach/mpm.h> #include "acpuclock.h" #include "rpm_log.h" #include "smd_private.h" #include "pm-boot.h" #include "msm_watchdog.h" #include "board-8930.h" static struct platform_device <API key> = { .name = "iris_fm", .id = -1, }; #define KS8851_RST_GPIO 89 #define KS8851_IRQ_GPIO 90 #define <API key> 47 #if defined(CONFIG_GPIO_SX150X) || defined(<API key>) struct <API key> msm8930_sx150x_data[] = { [SX150X_CAM] = { .gpio_base = <API key>, .oscio_is_gpo = false, .io_pullup_ena = 0x0, .io_pulldn_ena = 0xc0, .io_open_drain_ena = 0x0, .irq_summary = -1, }, }; #endif #define MSM_PMEM_ADSP_SIZE 0x7800000 #define MSM_PMEM_AUDIO_SIZE 0x2B4000 #ifdef <API key> #define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */ #else #define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */ #endif #ifdef <API key> #define <API key> 0x280000 #define MSM_ION_SF_SIZE MSM_PMEM_SIZE #define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */ #define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE #define MSM_ION_QSECOM_SIZE 0x300000 /* (3MB) */ #define MSM_ION_MFC_SIZE SZ_8K #define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE #define MSM_ION_HEAP_NUM 8 #else #define <API key> 0x110C000 #define MSM_ION_HEAP_NUM 1 #endif #ifdef <API key> static unsigned <API key> = <API key>; static int __init <API key>(char *p) { <API key> = memparse(p, NULL); return 0; } early_param("<API key>", <API key>); #endif #ifdef CONFIG_ANDROID_PMEM static unsigned pmem_size = MSM_PMEM_SIZE; static int __init pmem_size_setup(char *p) { pmem_size = memparse(p, NULL); return 0; } early_param("pmem_size", pmem_size_setup); static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; static int __init <API key>(char *p) { pmem_adsp_size = memparse(p, NULL); return 0; } early_param("pmem_adsp_size", <API key>); static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE; static int __init <API key>(char *p) { pmem_audio_size = memparse(p, NULL); return 0; } early_param("pmem_audio_size", <API key>); #endif #ifdef CONFIG_ANDROID_PMEM #ifndef <API key> static struct <API key> android_pmem_pdata = { .name = "pmem", .allocator_type = <API key>, .cached = 1, .memory_type = MEMTYPE_EBI1, }; static struct platform_device android_pmem_device = { .name = "android_pmem", .id = 0, .dev = {.platform_data = &android_pmem_pdata}, }; static struct <API key> <API key> = { .name = "pmem_adsp", .allocator_type = <API key>, .cached = 0, .memory_type = MEMTYPE_EBI1, }; static struct platform_device <API key> = { .name = "android_pmem", .id = 2, .dev = { .platform_data = &<API key> }, }; #endif static struct <API key> <API key> = { .name = "pmem_audio", .allocator_type = <API key>, .cached = 0, .memory_type = MEMTYPE_EBI1, }; static struct platform_device <API key> = { .name = "android_pmem", .id = 4, .dev = { .platform_data = &<API key> }, }; #endif #define DSP_RAM_BASE_8960 0x8da00000 #define DSP_RAM_SIZE_8960 0x1800000 static int <API key> = 0xDEADDEAD; static struct resource <API key>[] = { { .name = "msm_dspcrashd", .start = DSP_RAM_BASE_8960, .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960, .flags = IORESOURCE_DMA, }, }; static struct platform_device <API key> = { .name = "msm_dspcrashd", .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, .dev = { .platform_data = &<API key> }, }; static struct memtype_reserve <API key>[] __initdata = { [MEMTYPE_SMI] = { }, [MEMTYPE_EBI0] = { .flags = <API key>, }, [MEMTYPE_EBI1] = { .flags = <API key>, }, }; #if defined(CONFIG_MSM_RTB) static struct <API key> msm_rtb_pdata = { .size = SZ_1M, }; static int __init <API key>(char *p) { int s; s = memparse(p, NULL); msm_rtb_pdata.size = ALIGN(s, SZ_4K); return 0; } early_param("msm_rtb_size", <API key>); static struct platform_device msm_rtb_device = { .name = "msm_rtb", .id = -1, .dev = { .platform_data = &msm_rtb_pdata, }, }; #endif static void __init reserve_rtb_memory(void) { #if defined(CONFIG_MSM_RTB) <API key>[MEMTYPE_EBI1].size += msm_rtb_pdata.size; #endif } static void __init size_pmem_devices(void) { #ifdef CONFIG_ANDROID_PMEM #ifndef <API key> <API key>.size = pmem_adsp_size; android_pmem_pdata.size = pmem_size; #endif <API key>.size = MSM_PMEM_AUDIO_SIZE; #endif } static void __init reserve_memory_for(struct <API key> *p) { <API key>[p->memory_type].size += p->size; } static void __init reserve_pmem_memory(void) { #ifdef CONFIG_ANDROID_PMEM #ifndef <API key> reserve_memory_for(&<API key>); reserve_memory_for(&android_pmem_pdata); #endif reserve_memory_for(&<API key>); <API key>[MEMTYPE_EBI1].size += <API key>; #endif } static int <API key>(unsigned int paddr) { return MEMTYPE_EBI1; } #ifdef CONFIG_ION_MSM #ifdef <API key> static struct ion_cp_heap_pdata cp_mm_ion_pdata = { .permission_type = <API key>, .align = PAGE_SIZE, }; static struct ion_cp_heap_pdata cp_mfc_ion_pdata = { .permission_type = <API key>, .align = PAGE_SIZE, }; static struct ion_co_heap_pdata co_ion_pdata = { .adjacent_mem_id = INVALID_HEAP_ID, .align = PAGE_SIZE, }; static struct ion_co_heap_pdata fw_co_ion_pdata = { .adjacent_mem_id = ION_CP_MM_HEAP_ID, .align = SZ_128K, }; #endif /** * These heaps are listed in the order they will be allocated. Due to * video hardware restrictions and content protection the FW heap has to * be allocated adjacent (below) the MM heap and the MFC heap has to be * allocated after the MM heap to ensure MFC heap is not more than 256MB * away from the base address of the FW heap. * However, the order of FW heap and MM heap doesn't matter since these * two heaps are taken care of by separate code to ensure they are adjacent * to each other. * Don't swap the order unless you know what you are doing! */ static struct ion_platform_data ion_pdata = { .nr = MSM_ION_HEAP_NUM, .heaps = { { .id = ION_SYSTEM_HEAP_ID, .type = <API key>, .name = <API key>, }, #ifdef <API key> { .id = ION_CP_MM_HEAP_ID, .type = ION_HEAP_TYPE_CP, .name = ION_MM_HEAP_NAME, .size = MSM_ION_MM_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &cp_mm_ion_pdata, }, { .id = <API key>, .type = <API key>, .name = <API key>, .size = MSM_ION_MM_FW_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &fw_co_ion_pdata, }, { .id = ION_CP_MFC_HEAP_ID, .type = ION_HEAP_TYPE_CP, .name = ION_MFC_HEAP_NAME, .size = MSM_ION_MFC_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &cp_mfc_ion_pdata, }, { .id = ION_SF_HEAP_ID, .type = <API key>, .name = ION_SF_HEAP_NAME, .size = MSM_ION_SF_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &co_ion_pdata, }, { .id = ION_IOMMU_HEAP_ID, .type = ION_HEAP_TYPE_IOMMU, .name = ION_IOMMU_HEAP_NAME, }, { .id = ION_QSECOM_HEAP_ID, .type = <API key>, .name = <API key>, .size = MSM_ION_QSECOM_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &co_ion_pdata, }, { .id = ION_AUDIO_HEAP_ID, .type = <API key>, .name = ION_AUDIO_HEAP_NAME, .size = MSM_ION_AUDIO_SIZE, .memory_type = ION_EBI_TYPE, .extra_data = (void *) &co_ion_pdata, }, #endif } }; static struct platform_device ion_dev = { .name = "ion-msm", .id = 1, .dev = { .platform_data = &ion_pdata }, }; #endif static void reserve_ion_memory(void) { #if defined(CONFIG_ION_MSM) && defined(<API key>) <API key>[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE; <API key>[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE; <API key>[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE; <API key>[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE; <API key>[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE; <API key>[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE; #endif } static void __init reserve_mdp_memory(void) { <API key>(<API key>); } static void __init <API key>(void) { size_pmem_devices(); reserve_pmem_memory(); reserve_ion_memory(); reserve_mdp_memory(); reserve_rtb_memory(); } static struct reserve_info <API key> __initdata = { .<API key> = <API key>, .<API key> = <API key>, .paddr_to_memtype = <API key>, }; static int <API key>(void) { return 1<<29; } static void __init <API key>(void) { struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1]; unsigned long bank_size; unsigned long low, high; bank_size = <API key>(); low = meminfo.bank[0].start; high = mb->start + mb->size; /* Check if 32 bit overflow occured */ if (high < mb->start) high = ~0UL; low &= ~(bank_size - 1); if (high - low <= bank_size) return; <API key>.bank_size = bank_size; #ifdef CONFIG_ENABLE_DMM <API key>.<API key> = mb->start - <API key> + mb->size; <API key>.max_unstable_size = <API key>; pr_info("low unstable address %lx max size %lx bank size %lx\n", <API key>.<API key>, <API key>.max_unstable_size, <API key>.bank_size); #else <API key>.<API key> = 0; <API key>.max_unstable_size = 0; #endif } static void __init place_movable_zone(void) { #ifdef CONFIG_ENABLE_DMM <API key> = <API key>.<API key>; <API key> = <API key>.max_unstable_size; pr_info("movable zone start %lx size %lx\n", <API key>, <API key>); #endif } static void __init <API key>(void) { reserve_info = &<API key>; <API key>(); place_movable_zone(); } static void __init msm8930_reserve(void) { msm_reserve(); } static int <API key>(u64 start, u64 size, int change_type) { return <API key>(start, size, change_type); } static void __init <API key>(void) { <API key>(); } #ifdef <API key> #define <API key> (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS) /* Micbias setting is based on 8660 CDP/MTP/FLUID requirement * 4 micbiases are used to power various analog and digital * microphones operating at 1800 mV. Technically, all micbiases * can source from single cfilter since all microphones operate * at the same voltage level. The arrangement below is to make * sure all cfilters are exercised. LDO_H regulator ouput level * does not need to be as high as 2.85V. It is choosen for * microphone sensitivity purpose. */ static struct tabla_pdata tabla_platform_data = { .<API key> = { .name = "tabla-slave", .e_addr = {0, 0, 0x10, 0, 0x17, 2}, }, .irq = MSM_GPIO_TO_INT(62), .irq_base = <API key>, .num_irqs = NR_TABLA_IRQS, /*TODO: Replace this with right PM8038 gpio */ #ifndef MSM8930_PHASE_2 .reset_gpio = <API key>(34), #endif .micbias = { .ldoh_v = TABLA_LDOH_2P85_V, .cfilt1_mv = 1800, .cfilt2_mv = 1800, .cfilt3_mv = 1800, .bias1_cfilt_sel = TABLA_CFILT1_SEL, .bias2_cfilt_sel = TABLA_CFILT2_SEL, .bias3_cfilt_sel = TABLA_CFILT3_SEL, .bias4_cfilt_sel = TABLA_CFILT3_SEL, } }; static struct slim_device msm_slim_tabla = { .name = "tabla-slim", .e_addr = {0, 1, 0x10, 0, 0x17, 2}, .dev = { .platform_data = &tabla_platform_data, }, }; static struct tabla_pdata <API key> = { .<API key> = { .name = "tabla-slave", .e_addr = {0, 0, 0x60, 0, 0x17, 2}, }, .irq = MSM_GPIO_TO_INT(62), .irq_base = <API key>, .num_irqs = NR_TABLA_IRQS, /*TODO: Replace this with right PM8038 gpio */ #ifndef MSM8930_PHASE_2 .reset_gpio = <API key>(34), #endif .micbias = { .ldoh_v = TABLA_LDOH_2P85_V, .cfilt1_mv = 1800, .cfilt2_mv = 1800, .cfilt3_mv = 1800, .bias1_cfilt_sel = TABLA_CFILT1_SEL, .bias2_cfilt_sel = TABLA_CFILT2_SEL, .bias3_cfilt_sel = TABLA_CFILT3_SEL, .bias4_cfilt_sel = TABLA_CFILT3_SEL, } }; static struct slim_device msm_slim_tabla20 = { .name = "tabla2x-slim", .e_addr = {0, 1, 0x60, 0, 0x17, 2}, .dev = { .platform_data = &<API key>, }, }; #endif static struct slim_boardinfo msm_slim_devices[] = { #ifdef <API key> { .bus_num = 1, .slim_slave = &msm_slim_tabla, }, { .bus_num = 1, .slim_slave = &msm_slim_tabla20, }, #endif /* add more slimbus slaves as needed */ }; #define MSM_WCNSS_PHYS 0x03000000 #define MSM_WCNSS_SIZE 0x280000 static struct resource <API key>[] = { { .start = <API key>, .end = <API key>, .name = "wcnss_wlanrx_irq", .flags = IORESOURCE_IRQ, }, { .start = <API key>, .end = <API key>, .name = "wcnss_wlantx_irq", .flags = IORESOURCE_IRQ, }, { .start = MSM_WCNSS_PHYS, .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1, .name = "wcnss_mmio", .flags = IORESOURCE_MEM, }, { .start = 84, .end = 88, .name = "wcnss_gpios_5wire", .flags = IORESOURCE_IO, }, }; static struct qcom_wcnss_opts qcom_wcnss_pdata = { .has_48mhz_xo = 1, }; static struct platform_device <API key> = { .name = "wcnss_wlan", .id = 0, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, .dev = {.platform_data = &qcom_wcnss_pdata}, }; #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) #define QCE_SIZE 0x10000 #define QCE_0_BASE 0x18500000 #define QCE_HW_KEY_SUPPORT 0 #define <API key> 1 #define <API key> 1 #define QCE_CE_SHARED 0 static struct resource qcrypto_resources[] = { [0] = { .start = QCE_0_BASE, .end = QCE_0_BASE + QCE_SIZE - 1, .flags = IORESOURCE_MEM, }, [1] = { .name = "crypto_channels", .start = DMOV_CE_IN_CHAN, .end = DMOV_CE_OUT_CHAN, .flags = IORESOURCE_DMA, }, [2] = { .name = "crypto_crci_in", .start = DMOV_CE_IN_CRCI, .end = DMOV_CE_IN_CRCI, .flags = IORESOURCE_DMA, }, [3] = { .name = "crypto_crci_out", .start = DMOV_CE_OUT_CRCI, .end = DMOV_CE_OUT_CRCI, .flags = IORESOURCE_DMA, }, }; static struct resource qcedev_resources[] = { [0] = { .start = QCE_0_BASE, .end = QCE_0_BASE + QCE_SIZE - 1, .flags = IORESOURCE_MEM, }, [1] = { .name = "crypto_channels", .start = DMOV_CE_IN_CHAN, .end = DMOV_CE_OUT_CHAN, .flags = IORESOURCE_DMA, }, [2] = { .name = "crypto_crci_in", .start = DMOV_CE_IN_CRCI, .end = DMOV_CE_IN_CRCI, .flags = IORESOURCE_DMA, }, [3] = { .name = "crypto_crci_out", .start = DMOV_CE_OUT_CRCI, .end = DMOV_CE_OUT_CRCI, .flags = IORESOURCE_DMA, }, }; #endif #if defined(<API key>) || \ defined(<API key>) static struct msm_ce_hw_support <API key> = { .ce_shared = QCE_CE_SHARED, .shared_ce_resource = <API key>, .hw_key_support = QCE_HW_KEY_SUPPORT, .sha_hmac = <API key>, }; static struct platform_device qcrypto_device = { .name = "qcrypto", .id = 0, .num_resources = ARRAY_SIZE(qcrypto_resources), .resource = qcrypto_resources, .dev = { .coherent_dma_mask = DMA_BIT_MASK(32), .platform_data = &<API key>, }, }; #endif #if defined(<API key>) || \ defined(<API key>) static struct msm_ce_hw_support <API key> = { .ce_shared = QCE_CE_SHARED, .shared_ce_resource = <API key>, .hw_key_support = QCE_HW_KEY_SUPPORT, .sha_hmac = <API key>, }; static struct platform_device qcedev_device = { .name = "qce", .id = 0, .num_resources = ARRAY_SIZE(qcedev_resources), .resource = qcedev_resources, .dev = { .coherent_dma_mask = DMA_BIT_MASK(32), .platform_data = &<API key>, }, }; #endif #define MDM2AP_ERRFATAL 70 #define AP2MDM_ERRFATAL 95 #define MDM2AP_STATUS 69 #define AP2MDM_STATUS 94 #define AP2MDM_PMIC_RESET_N 80 #define AP2MDM_KPDPWR_N 81 static struct resource mdm_resources[] = { { .start = MDM2AP_ERRFATAL, .end = MDM2AP_ERRFATAL, .name = "MDM2AP_ERRFATAL", .flags = IORESOURCE_IO, }, { .start = AP2MDM_ERRFATAL, .end = AP2MDM_ERRFATAL, .name = "AP2MDM_ERRFATAL", .flags = IORESOURCE_IO, }, { .start = MDM2AP_STATUS, .end = MDM2AP_STATUS, .name = "MDM2AP_STATUS", .flags = IORESOURCE_IO, }, { .start = AP2MDM_STATUS, .end = AP2MDM_STATUS, .name = "AP2MDM_STATUS", .flags = IORESOURCE_IO, }, { .start = AP2MDM_PMIC_RESET_N, .end = AP2MDM_PMIC_RESET_N, .name = "AP2MDM_PMIC_RESET_N", .flags = IORESOURCE_IO, }, { .start = AP2MDM_KPDPWR_N, .end = AP2MDM_KPDPWR_N, .name = "AP2MDM_KPDPWR_N", .flags = IORESOURCE_IO, }, }; static struct mdm_platform_data mdm_platform_data = { .mdm_version = "2.5", }; static struct platform_device mdm_device = { .name = "mdm2_modem", .id = -1, .num_resources = ARRAY_SIZE(mdm_resources), .resource = mdm_resources, .dev = { .platform_data = &mdm_platform_data, }, }; static struct platform_device *mdm_devices[] __initdata = { &mdm_device, }; #define MSM_SHARED_RAM_PHYS 0x80000000 static void __init msm8930_map_io(void) { msm_shared_ram_phys = MSM_SHARED_RAM_PHYS; msm_map_msm8930_io(); if (socinfo_init() < 0) pr_err("socinfo_init() failed!\n"); } static void __init msm8930_init_irq(void) { <API key>(); gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, (void *)MSM_QGIC_CPU_BASE); /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); mb(); } static void __init msm8930_init_buses(void) { #ifdef <API key> <API key>(); <API key>.rpm_enabled = 1; <API key>.rpm_enabled = 1; <API key>.rpm_enabled = 1; msm_bus_apps_fabric.dev.platform_data = &<API key>; msm_bus_sys_fabric.dev.platform_data = &<API key>; msm_bus_mm_fabric.dev.platform_data = &<API key>; msm_bus_sys_fpb.dev.platform_data = &<API key>; msm_bus_cpss_fpb.dev.platform_data = &<API key>; #endif } static struct <API key> <API key> = { .max_clock_speed = 15060000, }; #ifdef <API key> static struct <API key> msm_otg_pdata; #else static struct <API key> msm_otg_pdata = { .mode = USB_OTG, .otg_control = OTG_PMIC_CONTROL, .phy_type = <API key>, .pmic_id_irq = <API key>(PM8038_IRQ_BASE), .power_budget = 750, }; #endif #ifdef <API key> #define HSIC_HUB_RESET_GPIO 91 static struct <API key> msm_hsic_pdata = { .strobe = 150, .data = 151, }; #else static struct <API key> msm_hsic_pdata; #endif #define PID_MAGIC_ID 0x71432909 #define SERIAL_NUM_MAGIC_ID 0x61945374 #define <API key> 127 #define DLOAD_USB_BASE_ADD 0x2A03F0C8 struct magic_num_struct { uint32_t pid; uint32_t serial_num; }; struct dload_struct { uint32_t reserved1; uint32_t reserved2; uint32_t reserved3; uint16_t reserved4; uint16_t pid; char serial_number[<API key>]; uint16_t reserved5; struct magic_num_struct magic_struct; }; static int <API key>(uint32_t pid, const char *snum) { struct dload_struct __iomem *dload = 0; dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload)); if (!dload) { pr_err("%s: cannot remap I/O memory region: %08x\n", __func__, DLOAD_USB_BASE_ADD); return -ENXIO; } pr_debug("%s: dload:%p pid:%x serial_num:%s\n", __func__, dload, pid, snum); /* update pid */ dload->magic_struct.pid = PID_MAGIC_ID; dload->pid = pid; /* update serial number */ dload->magic_struct.serial_num = 0; if (!snum) { memset(dload->serial_number, 0, <API key>); goto out; } dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID; strlcpy(dload->serial_number, snum, <API key>); out: iounmap(dload); return 0; } static struct <API key> android_usb_pdata = { .<API key> = <API key>, }; static struct platform_device android_usb_device = { .name = "android_usb", .id = -1, .dev = { .platform_data = &android_usb_pdata, }, }; static uint8_t <API key>[] __initdata = { 0x03, 0x0f, }; static uint8_t <API key>[] __initdata = { 0x00, 0x24, 0x54, 0x10, 0x09, 0x03, 0x01, 0x10, 0x54, 0x30, 0x0C, 0x24, 0x30, 0x0f, }; static uint8_t <API key>[] __initdata = { 0x00, 0x24, 0x54, 0x10, 0x09, 0x07, 0x01, 0x0B, 0x10, 0x54, 0x30, 0x0C, 0x24, 0x30, 0x0f, }; static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = { [0] = { .mode = <API key>, .notify_rpm = false, .cmd = <API key>, }, [1] = { .mode = <API key>, .notify_rpm = false, .cmd = <API key>, }, [2] = { .mode = <API key>, .notify_rpm = true, .cmd = <API key>, }, }; static struct <API key> msm_spm_data[] __initdata = { [0] = { .reg_base_addr = MSM_SAW0_BASE, .reg_init_values[<API key>] = 0x1F, #if defined(CONFIG_MSM_AVS_HW) .reg_init_values[<API key>] = 0x00, .reg_init_values[<API key>] = 0x00, #endif .reg_init_values[<API key>] = 0x01, .reg_init_values[<API key>] = 0x02020204, .reg_init_values[<API key>] = 0x0060009C, .reg_init_values[<API key>] = 0x0000001C, .vctl_timeout_us = 50, .num_modes = ARRAY_SIZE(msm_spm_seq_list), .modes = msm_spm_seq_list, }, [1] = { .reg_base_addr = MSM_SAW1_BASE, .reg_init_values[<API key>] = 0x1F, #if defined(CONFIG_MSM_AVS_HW) .reg_init_values[<API key>] = 0x00, .reg_init_values[<API key>] = 0x00, #endif .reg_init_values[<API key>] = 0x01, .reg_init_values[<API key>] = 0x02020204, .reg_init_values[<API key>] = 0x0060009C, .reg_init_values[<API key>] = 0x0000001C, .vctl_timeout_us = 50, .num_modes = ARRAY_SIZE(msm_spm_seq_list), .modes = msm_spm_seq_list, }, }; static uint8_t <API key>[] __initdata = { 0x00, 0x20, 0x03, 0x20, 0x00, 0x0f, }; static uint8_t <API key>[] __initdata = { 0x00, 0x20, 0x34, 0x64, 0x48, 0x07, 0x48, 0x20, 0x50, 0x64, 0x04, 0x34, 0x50, 0x0f, }; static uint8_t <API key>[] __initdata = { 0x00, 0x10, 0x34, 0x64, 0x48, 0x07, 0x48, 0x10, 0x50, 0x64, 0x04, 0x34, 0x50, 0x0F, }; static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = { [0] = { .mode = <API key>, .notify_rpm = false, .cmd = <API key>, }, [1] = { .mode = <API key>, .notify_rpm = true, .cmd = <API key>, }, [2] = { .mode = <API key>, .notify_rpm = true, .cmd = <API key>, }, }; static struct <API key> msm_spm_l2_data[] __initdata = { [0] = { .reg_base_addr = MSM_SAW_L2_BASE, .reg_init_values[<API key>] = 0x00, .reg_init_values[<API key>] = 0x02020204, .reg_init_values[<API key>] = 0x00A000AE, .reg_init_values[<API key>] = 0x00A00020, .modes = msm_spm_l2_seq_list, .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list), }, }; #/* TODO: Remove this once PM8038 physically becomes * available. */ #ifndef MSM8930_PHASE_2 #define PM_HAP_EN_GPIO <API key>(33) #define PM_HAP_LEN_GPIO <API key>(20) #else #define ISA1200_HAP_EN_GPIO 77 #define <API key> 78 #define ISA1200_HAP_CLK <API key>(7) #endif #ifndef MSM8930_PHASE_2 static struct msm_xo_voter *xo_handle_d1; #endif static int isa1200_power(int on) { #ifndef MSM8930_PHASE_2 int rc = 0; gpio_set_value(<API key>, !!on); rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) : msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF); if (rc < 0) { pr_err("%s: failed to %svote for TCXO D1 buffer%d\n", __func__, on ? "" : "de-", rc); goto err_xo_vote; } return 0; err_xo_vote: gpio_set_value(<API key>, !on); return rc; #else <API key>(ISA1200_HAP_CLK, !!on); return 0; #endif } static int isa1200_dev_setup(bool enable) { int rc = 0; #ifndef MSM8930_PHASE_2 struct pm_gpio hap_gpio_config = { .direction = PM_GPIO_DIR_OUT, .pull = PM_GPIO_PULL_NO, .out_strength = <API key>, .function = PM_GPIO_FUNC_NORMAL, .inv_int_pol = 0, .vin_sel = 2, .output_buffer = <API key>, .output_value = 0, }; if (enable == true) { rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config); if (rc) { pr_err("%s: pm8921 gpio %d config failed(%d)\n", __func__, PM_HAP_EN_GPIO, rc); return rc; } rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config); if (rc) { pr_err("%s: pm8921 gpio %d config failed(%d)\n", __func__, PM_HAP_LEN_GPIO, rc); return rc; } rc = gpio_request(<API key>, "hap_shft_lvl_oe"); if (rc) { pr_err("%s: unable to request gpio %d (%d)\n", __func__, <API key>, rc); return rc; } rc = <API key>(<API key>, 0); if (rc) { pr_err("%s: Unable to set direction\n", __func__); goto free_gpio; } xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200"); if (IS_ERR(xo_handle_d1)) { rc = PTR_ERR(xo_handle_d1); pr_err("%s: failed to get the handle for D1(%d)\n", __func__, rc); goto gpio_set_dir; } } else { gpio_free(<API key>); msm_xo_put(xo_handle_d1); } return 0; gpio_set_dir: gpio_set_value(<API key>, 0); free_gpio: gpio_free(<API key>); return rc; #else struct pm_gpio hap_clk_gpio_config = { .direction = PM_GPIO_DIR_OUT, .pull = PM_GPIO_PULL_NO, .out_strength = <API key>, .function = PM_GPIO_FUNC_1, .inv_int_pol = 0, .vin_sel = PM_GPIO_VIN_S4, .output_buffer = <API key>, .output_value = 0, }; rc = pm8xxx_gpio_config(ISA1200_HAP_CLK, &hap_clk_gpio_config); if (rc) { pr_err("%s: pm8038 gpio %d config failed(%d)\n", __func__, ISA1200_HAP_CLK, rc); return rc; } rc = gpio_request(ISA1200_HAP_CLK, "haptics_clk"); if (rc) { pr_err("%s: gpio_request for %d gpio failed rc(%d)\n", __func__, ISA1200_HAP_CLK, rc); goto fail_gpio_req; } rc = <API key>(ISA1200_HAP_CLK, 0); if (rc) { pr_err("%s: <API key> failed for %d gpio rc(%d)\n", __func__, ISA1200_HAP_CLK, rc); goto fail_gpio_dir; } return 0; fail_gpio_dir: gpio_free(ISA1200_HAP_CLK); fail_gpio_req: return rc; #endif } static struct isa1200_regulator isa1200_reg_data[] = { #ifndef MSM8930_PHASE_2 { .name = "vcc_i2c", .min_uV = ISA_I2C_VTG_MIN_UV, .max_uV = ISA_I2C_VTG_MAX_UV, .load_uA = ISA_I2C_CURR_UA, }, #else { .name = "vddp", .min_uV = ISA_I2C_VTG_MIN_UV, .max_uV = ISA_I2C_VTG_MAX_UV, .load_uA = ISA_I2C_CURR_UA, }, #endif }; static struct <API key> isa1200_1_pdata = { .name = "vibrator", .dev_setup = isa1200_dev_setup, .power_on = isa1200_power, #ifndef MSM8930_PHASE_2 .hap_en_gpio = PM_HAP_EN_GPIO, .hap_len_gpio = PM_HAP_LEN_GPIO, #else .hap_en_gpio = ISA1200_HAP_EN_GPIO, .hap_len_gpio = <API key>, #endif .max_timeout = 15000, .mode_ctrl = PWM_GEN_MODE, .pwm_fd = { .pwm_div = 256, }, .is_erm = false, .smart_en = true, .ext_clk_en = true, .chip_en = 1, .regulator_info = isa1200_reg_data, .num_regulators = ARRAY_SIZE(isa1200_reg_data), }; static struct i2c_board_info <API key>[] __initdata = { { I2C_BOARD_INFO("isa1200_1", 0x90>>1), .platform_data = &isa1200_1_pdata, }, }; #define CYTTSP_TS_GPIO_IRQ 11 #define <API key> 50 #define <API key> 52 /*virtual key support */ static ssize_t tma340_vkeys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return snprintf(buf, 200, __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97" ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97" ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97" ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97" "\n"); } static struct kobj_attribute tma340_vkeys_attr = { .attr = { .mode = S_IRUGO, }, .show = &tma340_vkeys_show, }; static struct attribute *<API key>[] = { &tma340_vkeys_attr.attr, NULL }; static struct attribute_group <API key> = { .attrs = <API key>, }; static int <API key>(struct i2c_client *client) { int rc = 0; static struct kobject *<API key>; tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c"; <API key> = <API key>("board_properties", NULL); if (<API key>) rc = sysfs_create_group(<API key>, &<API key>); if (!<API key> || rc) pr_err("%s: failed to create board_properties\n", __func__); return 0; } static struct cyttsp_regulator regulator_data[] = { { .name = "vdd", .min_uV = <API key>, .max_uV = <API key>, .hpm_load_uA = <API key>, .lpm_load_uA = <API key>, }, /* TODO: Remove after runtime PM is enabled in I2C driver */ { .name = "vcc_i2c", .min_uV = CY_I2C_VTG_MIN_UV, .max_uV = CY_I2C_VTG_MAX_UV, .hpm_load_uA = CY_I2C_CURR_UA, .lpm_load_uA = <API key>, }, }; static struct <API key> cyttsp_pdata = { .panel_maxx = 634, .panel_maxy = 1166, .disp_maxx = 616, .disp_maxy = 1023, .disp_minx = 0, .disp_miny = 16, .flags = 0x01, .gen = CY_GEN3, .use_st = CY_USE_ST, .use_mt = CY_USE_MT, .use_hndshk = CY_SEND_HNDSHK, .use_trk_id = CY_USE_TRACKING_ID, .use_sleep = <API key> | <API key>, .use_gestures = CY_USE_GESTURES, .fw_fname = "cyttsp_8960_cdp.hex", /* activate up to 4 groups * and set active distance */ .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 | CY_GEST_GRP3 | CY_GEST_GRP4 | CY_ACT_DIST, /* change act_intrvl to customize the Active power state * scanning/processing refresh interval for Operating mode */ .act_intrvl = CY_ACT_INTRVL_DFLT, /* change tch_tmout to customize the touch timeout for the * Active power state for Operating mode */ .tch_tmout = CY_TCH_TMOUT_DFLT, /* change lp_intrvl to customize the Low Power power state * scanning/processing refresh interval for Operating mode */ .lp_intrvl = CY_LP_INTRVL_DFLT, .sleep_gpio = <API key>, .resout_gpio = <API key>, .irq_gpio = CYTTSP_TS_GPIO_IRQ, .regulator_info = regulator_data, .num_regulators = ARRAY_SIZE(regulator_data), .init = <API key>, .correct_fw_ver = 9, }; static struct i2c_board_info cyttsp_info[] __initdata = { { I2C_BOARD_INFO(CY_I2C_NAME, 0x24), .platform_data = &cyttsp_pdata, #ifndef CY_USE_TIMER .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ), #endif /* CY_USE_TIMER */ }, }; #define MXT_TS_GPIO_IRQ 11 #define MXT_TS_RESET_GPIO 52 static const u8 <API key>[] = { /* T6 Object */ 0, 0, 0, 0, 0, 0, /* T38 Object */ 15, 1, 0, 15, 12, 11, 0, 0, /* T7 Object */ 48, 255, 25, /* T8 Object */ 27, 0, 5, 1, 0, 0, 8, 8, 0, 0, /* T9 Object */ 131, 0, 0, 19, 11, 0, 16, 35, 1, 3, 10, 15, 1, 11, 4, 5, 40, 10, 54, 2, 43, 4, 0, 0, 0, 0, 143, 40, 143, 80, 18, 15, 50, 50, 2, /* T15 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* T18 Object */ 0, 0, /* T19 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* T23 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* T25 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* T40 Object */ 0, 0, 0, 0, 0, /* T42 Object */ 0, 0, 0, 0, 0, 0, 0, 0, /* T46 Object */ 0, 3, 16, 48, 0, 0, 1, 0, 0, /* T47 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* T48 Object */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static ssize_t mxt224e_vkeys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return snprintf(buf, 200, __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":65:938:90:90" ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":208:938:90:90" ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":348:938:90:90" ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":490:938:90:90" "\n"); } static struct kobj_attribute mxt224e_vkeys_attr = { .attr = { .mode = S_IRUGO, }, .show = &mxt224e_vkeys_show, }; static struct attribute *<API key>[] = { &mxt224e_vkeys_attr.attr, NULL }; static struct attribute_group <API key> = { .attrs = <API key>, }; static void mxt_init_vkeys_8930(void) { int rc = 0; static struct kobject *<API key>; mxt224e_vkeys_attr.attr.name = "virtualkeys.atmel_mxt_ts"; <API key> = <API key>("board_properties", NULL); if (<API key>) rc = sysfs_create_group(<API key>, &<API key>); if (!<API key> || rc) pr_err("%s: failed to create board_properties\n", __func__); return; } static struct mxt_config_info mxt_config_array[] = { { .config = <API key>, .config_length = ARRAY_SIZE(<API key>), .family_id = 0x81, .variant_id = 0x01, .version = 0x10, .build = 0xAA, }, }; static struct mxt_platform_data <API key> = { .config_array = mxt_config_array, .config_array_size = ARRAY_SIZE(mxt_config_array), .panel_minx = 0, .panel_maxx = 566, .panel_miny = 0, .panel_maxy = 1067, .disp_minx = 0, .disp_maxx = 540, .disp_miny = 0, .disp_maxy = 960, .irqflags = <API key>, #ifdef MSM8930_PHASE_2 .<API key> = true, #endif .i2c_pull_up = true, .reset_gpio = MXT_TS_RESET_GPIO, .irq_gpio = MXT_TS_GPIO_IRQ, }; static struct i2c_board_info <API key>[] __initdata = { { I2C_BOARD_INFO("atmel_mxt_ts", 0x4a), .platform_data = &<API key>, .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ), }, }; #ifdef MSM8930_PHASE_2 #define GPIO_VOLUME_UP <API key>(3) #define GPIO_VOLUME_DOWN <API key>(8) #define <API key> <API key>(10) #define GPIO_CAMERA_FOCUS <API key>(11) static struct gpio_keys_button keys_8930[] = { { .code = KEY_VOLUMEUP, .type = EV_KEY, .desc = "volume_up", .gpio = GPIO_VOLUME_UP, .wakeup = 1, .active_low = 1, }, { .code = KEY_VOLUMEDOWN, .type = EV_KEY, .desc = "volume_down", .gpio = GPIO_VOLUME_DOWN, .wakeup = 1, .active_low = 1, }, { .code = KEY_CAMERA_FOCUS, .type = EV_KEY, .desc = "camera_focus", .gpio = GPIO_CAMERA_FOCUS, .wakeup = 1, .active_low = 1, }, { .code = KEY_CAMERA_SNAPSHOT, .type = EV_KEY, .desc = "camera_snapshot", .gpio = <API key>, .wakeup = 1, .active_low = 1, }, }; /* Add GPIO keys for 8930 */ static struct <API key> <API key> = { .buttons = keys_8930, .nbuttons = 4, }; static struct platform_device gpio_keys_8930 = { .name = "gpio-keys", .id = -1, .dev = { .platform_data = &<API key>, }, }; #endif /* MSM8930_PHASE_2 */ static struct <API key> <API key> = { .clk_freq = 100000, .src_clk_rate = 24000000, }; static struct <API key> <API key> = { .clk_freq = 100000, .src_clk_rate = 24000000, }; static struct <API key> <API key> = { .clk_freq = 100000, .src_clk_rate = 24000000, }; static struct <API key> <API key> = { .clk_freq = 100000, .src_clk_rate = 24000000, }; static struct <API key> msm_rpm_data = { .reg_base_addrs = { [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE, [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400, [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600, [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00, }, .irq_ack = <API key>, .irq_err = <API key>, .irq_vmpm = <API key>, .<API key> = MSM_APCS_GCC_BASE + 0x008, .<API key> = 4, }; static struct ks8851_pdata spi_eth_pdata = { .irq_gpio = KS8851_IRQ_GPIO, .rst_gpio = KS8851_RST_GPIO, }; static struct spi_board_info spi_board_info[] __initdata = { { .modalias = "ks8851", .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO), .max_speed_hz = 19200000, .bus_num = 0, .chip_select = 0, .mode = SPI_MODE_0, .platform_data = &spi_eth_pdata }, { .modalias = "<API key>", .max_speed_hz = 10800000, .bus_num = 0, .chip_select = 1, .mode = SPI_MODE_0, }, }; static struct platform_device <API key> = { .name = "saw-regulator", .id = 0, .dev = { .platform_data = &<API key>, }, }; static struct platform_device <API key> = { .name = "saw-regulator", .id = 1, .dev = { .platform_data = &<API key>, }, }; static struct tsens_platform_data msm_tsens_pdata = { .slope = {910, 910, 910, 910, 910}, .tsens_factor = 1000, .hw_type = MSM_8960, .tsens_num_sensor = 5, }; #ifdef <API key> static struct platform_device fish_battery_device = { .name = "fish_battery", }; #endif #ifndef MSM8930_PHASE_2 /* 8930 Phase 1 */ static struct platform_device <API key> __devinitdata = { .name = <API key>, .id = <API key>(7), .dev = { .platform_data = &<API key>[GPIO_VREG_ID_EXT_5V], }, }; static struct platform_device <API key> __devinitdata = { .name = <API key>, .id = 91, .dev = { .platform_data = &<API key>[GPIO_VREG_ID_EXT_L2], }, }; #else /* 8930 Phase 2 */ static struct platform_device <API key> __devinitdata = { .name = <API key>, .id = 63, .dev = { .platform_data = &<API key>[<API key>], }, }; static struct platform_device <API key> __devinitdata = { .name = <API key>, .id = 97, .dev = { .platform_data = &<API key>[<API key>], }, }; #endif static struct platform_device <API key> __devinitdata = { .name = "rpm-regulator", .id = -1, .dev = { /* * TODO: When physical 8930/PM8038 hardware becomes * available, replace <API key> * with 8930 rpm regulator object. */ #if !defined(MSM8930_PHASE_2) .platform_data = &<API key>, #endif }, }; static struct <API key> msm_rpm_log_pdata = { .phys_addr_base = 0x0010C000, .reg_offsets = { [<API key>] = 0x00000080, [<API key>] = 0x000000A0, }, .phys_size = SZ_8K, .log_len = 4096, /* log's buffer length in bytes */ .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */ }; static struct platform_device msm_rpm_log_device = { .name = "msm_rpm_log", .id = -1, .dev = { .platform_data = &msm_rpm_log_pdata, }, }; static struct platform_device *common_devices[] __initdata = { &msm8960_device_dmov, &msm_device_smd, &<API key>, &msm_device_uart_dm6, &<API key>, &<API key>, &<API key>, #ifndef MSM8930_PHASE_2 &<API key>, #endif &<API key>, #ifdef MSM8930_PHASE_2 &<API key>, #endif &msm_8960_q6_lpass, &msm_8960_q6_mss_fw, &msm_8960_q6_mss_sw, &msm_8960_riva, &msm_pil_tzapps, &msm_pil_vidc, &<API key>, &<API key>, &<API key>, &<API key>, &<API key>, &msm_slim_ctrl, &<API key>, #if defined(<API key>) || \ defined(<API key>) &qcrypto_device, #endif #if defined(<API key>) || \ defined(<API key>) &qcedev_device, #endif #ifdef CONFIG_MSM_ROTATOR &msm_rotator_device, #endif &msm_device_sps, #ifdef <API key> &fish_battery_device, #endif #ifdef CONFIG_ANDROID_PMEM #ifndef <API key> &android_pmem_device, &<API key>, #endif &<API key>, #endif &msm_device_vidc, &msm_device_bam_dmux, &<API key>, #ifdef <API key> &msm_device_rng, #endif &msm_rpm_device, #ifdef CONFIG_ION_MSM &ion_dev, #endif &msm_rpm_log_device, &msm_rpm_stat_device, &msm_device_tz_log, #ifdef CONFIG_MSM_QDSS &msm_etb_device, &msm_tpiu_device, &msm_funnel_device, &msm_etm_device, #endif &<API key>, &<API key>, #ifdef MSM8930_PHASE_2 &gpio_keys_8930, #endif #ifdef CONFIG_MSM_RTB &msm_rtb_device, #endif &<API key>, }; static struct platform_device *cdp_devices[] __initdata = { &msm8960_device_otg, &<API key>, &<API key>, &android_usb_device, &msm_pcm, &msm_pcm_routing, &msm_cpudai0, &msm_cpudai1, &msm_cpudai_hdmi_rx, &msm_cpudai_bt_rx, &msm_cpudai_bt_tx, &msm_cpudai_fm_rx, &msm_cpudai_fm_tx, &<API key>, &<API key>, &msm_cpu_fe, &msm_stub_codec, &msm_kgsl_3d0, #ifdef CONFIG_MSM_KGSL_2D &msm_kgsl_2d0, &msm_kgsl_2d1, #endif #ifdef CONFIG_MSM_GEMINI &<API key>, #endif &msm_voice, &msm_voip, &msm_lpa_pcm, &<API key>, &<API key>, &<API key>, &<API key>, &msm_pcm_afe, &msm_compr_dsp, &<API key>, &<API key>, &<API key>, &msm_pcm_hostless, &msm_bus_apps_fabric, &msm_bus_sys_fabric, &msm_bus_mm_fabric, &msm_bus_sys_fpb, &msm_bus_cpss_fpb, }; static void __init msm8930_i2c_init(void) { <API key>.dev.platform_data = &<API key>; <API key>.dev.platform_data = &<API key>; <API key>.dev.platform_data = &<API key>; <API key>.dev.platform_data = &<API key>; } static void __init msm8930_gfx_init(void) { uint32_t <API key> = socinfo_get_version(); if (<API key>(<API key>) == 1) { struct <API key> *kgsl_3d0_pdata = msm_kgsl_3d0.dev.platform_data; kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000; kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000; } } static struct msm_cpuidle_state msm_cstates[] __initdata = { {0, 0, "C0", "WFI", <API key>}, {0, 1, "C1", "<API key>", <API key>}, {0, 2, "C2", "POWER_COLLAPSE", <API key>}, {1, 0, "C0", "WFI", <API key>}, {1, 1, "C1", "<API key>", <API key>}, }; static struct <API key> msm_pm_data[<API key> * 2] = { [MSM_PM_MODE(0, <API key>)] = { .idle_supported = 1, .suspend_supported = 1, .idle_enabled = 0, .suspend_enabled = 0, }, [MSM_PM_MODE(0, <API key>)] = { .idle_supported = 1, .suspend_supported = 1, .idle_enabled = 0, .suspend_enabled = 0, }, [MSM_PM_MODE(0, <API key>)] = { .idle_supported = 1, .suspend_supported = 1, .idle_enabled = 1, .suspend_enabled = 1, }, [MSM_PM_MODE(1, <API key>)] = { .idle_supported = 0, .suspend_supported = 1, .idle_enabled = 0, .suspend_enabled = 0, }, [MSM_PM_MODE(1, <API key>)] = { .idle_supported = 1, .suspend_supported = 1, .idle_enabled = 0, .suspend_enabled = 0, }, [MSM_PM_MODE(1, <API key>)] = { .idle_supported = 1, .suspend_supported = 0, .idle_enabled = 1, .suspend_enabled = 0, }, }; static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = { { <API key>, MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE), true, 100, 8000, 100000, 1, }, { <API key>, MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE), true, 2000, 6000, 60100000, 3000, }, { <API key>, MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE), false, 4200, 5000, 60350000, 3500, }, { <API key>, MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE), false, 6300, 4500, 65350000, 4800, }, { <API key>, MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH), false, 7000, 3500, 66600000, 5150, }, { <API key>, MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE), false, 11700, 2500, 67850000, 5500, }, { <API key>, MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE), false, 13800, 2000, 71850000, 6800, }, { <API key>, MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH), false, 29700, 500, 75850000, 8800, }, { <API key>, MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW), false, 29700, 0, 76350000, 9800, }, }; static struct <API key> msm_pm_boot_pdata __initdata = { .mode = <API key>, }; #ifdef CONFIG_I2C #define I2C_SURF 1 #define I2C_FFA (1 << 1) #define I2C_RUMI (1 << 2) #define I2C_SIM (1 << 3) #define I2C_FLUID (1 << 4) #define I2C_LIQUID (1 << 5) struct i2c_registry { u8 machs; int bus; struct i2c_board_info *info; int len; }; static void __init msm8930_init_hsic(void) { #ifdef <API key> uint32_t version = socinfo_get_version(); pr_info("%s: version:%d mtp:%d\n", __func__, <API key>(version), <API key>()); if ((<API key>(version) == 1) || <API key>() || <API key>()) return; <API key>(&<API key>); #endif } #ifdef <API key> static struct isl_platform_data isl_data __initdata = { .valid_n_gpio = 0, /* Not required when notify-by-pmic */ .<API key> = NULL, /* Not required when notify-by-pmic */ .max_system_voltage = 4200, .min_system_voltage = 3200, .chgcurrent = 1000, /* 1900, */ .term_current = 400, /* Need fine tuning */ .input_current = 2048, }; static struct i2c_board_info <API key>[] __initdata = { { I2C_BOARD_INFO("isl9519q", 0x9), .irq = 0, /* Not required when notify-by-pmic */ .platform_data = &isl_data, }, }; #endif /* <API key> */ static struct i2c_registry msm8960_i2c_devices[] __initdata = { #ifdef <API key> { I2C_LIQUID, <API key>, <API key>, ARRAY_SIZE(<API key>), }, #endif /* <API key> */ { I2C_SURF | I2C_FFA | I2C_FLUID, <API key>, cyttsp_info, ARRAY_SIZE(cyttsp_info), }, #ifndef MSM8930_PHASE_2 { I2C_LIQUID, <API key>, <API key>, ARRAY_SIZE(<API key>), }, #else { I2C_FFA | I2C_FLUID, <API key>, <API key>, ARRAY_SIZE(<API key>), }, #endif { I2C_SURF, <API key>, <API key>, ARRAY_SIZE(<API key>), }, }; #endif /* CONFIG_I2C */ static void __init <API key>(void) { #ifdef CONFIG_I2C u8 mach_mask = 0; int i; #ifdef CONFIG_MSM_CAMERA struct i2c_registry <API key> = { I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI, <API key>, <API key>.board_info, <API key>.num_i2c_board_info, }; #endif /* Build the matching 'supported_machs' bitmask */ if (<API key>() || <API key>()) mach_mask = I2C_SURF; else if (<API key>()) mach_mask = I2C_FLUID; else if (<API key>() || <API key>()) mach_mask = I2C_FFA; else pr_err("unmatched machine ID in <API key>\n"); /* Run the array and install devices as appropriate */ for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) { if (msm8960_i2c_devices[i].machs & mach_mask) <API key>(msm8960_i2c_devices[i].bus, msm8960_i2c_devices[i].info, msm8960_i2c_devices[i].len); } #ifdef CONFIG_MSM_CAMERA if (<API key>.machs & mach_mask) <API key>(<API key>.bus, <API key>.info, <API key>.len); #endif #endif } static void __init msm8930_cdp_init(void) { if (meminfo_init(SYS_MEMORY, SZ_256M) < 0) pr_err("meminfo_init() failed!\n"); <API key>(&msm_tsens_pdata); BUG_ON(msm_rpm_init(&msm_rpm_data)); BUG_ON(<API key>(msm_rpmrs_levels, ARRAY_SIZE(msm_rpmrs_levels))); <API key>(); if (msm_xo_init()) pr_err("Failed to initialize XO votes\n"); <API key>(&<API key>); msm_clock_init(&<API key>); msm8960_device_otg.dev.platform_data = &msm_otg_pdata; <API key>.dev.platform_data = &msm_hsic_pdata; <API key>(); <API key>.dev.platform_data = &<API key>; <API key>(spi_board_info, ARRAY_SIZE(spi_board_info)); /* * TODO: When physical 8930/PM8038 hardware becomes * available, remove this block or add the config * option. */ #ifndef MSM8930_PHASE_2 msm8960_init_pmic(); #else msm8930_init_pmic(); #endif msm8930_i2c_init(); msm8930_gfx_init(); msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data)); msm_spm_l2_init(msm_spm_l2_data); msm8930_init_buses(); <API key>(<API key>, <API key>); <API key>(common_devices, ARRAY_SIZE(common_devices)); /* * TODO: When physical 8930/PM8038 hardware becomes * available, remove this block or add the config * option. */ #ifndef MSM8930_PHASE_2 <API key>(); #else <API key>(); #endif <API key>(cdp_devices, ARRAY_SIZE(cdp_devices)); msm8930_init_hsic(); msm8930_init_cam(); msm8930_init_mmc(); acpuclk_init(&<API key>); if (<API key>() || <API key>()) mxt_init_vkeys_8930(); <API key>(); msm8930_init_fb(); <API key>(msm_slim_devices, ARRAY_SIZE(msm_slim_devices)); <API key>(msm_pm_data, ARRAY_SIZE(msm_pm_data)); <API key>(<API key>); <API key>(msm_cstates, ARRAY_SIZE(msm_cstates), msm_pm_data); change_memory_power = &<API key>; BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); if (PLATFORM_IS_CHARM25()) <API key>(mdm_devices, ARRAY_SIZE(mdm_devices)); } MACHINE_START(MSM8930_CDP, "QCT MSM8930 CDP") .map_io = msm8930_map_io, .reserve = msm8930_reserve, .init_irq = msm8930_init_irq, .handle_irq = gic_handle_irq, .timer = &msm_timer, .init_machine = msm8930_cdp_init, .init_early = <API key>, .init_very_early = <API key>, MACHINE_END MACHINE_START(MSM8930_MTP, "QCT MSM8930 MTP") .map_io = msm8930_map_io, .reserve = msm8930_reserve, .init_irq = msm8930_init_irq, .handle_irq = gic_handle_irq, .timer = &msm_timer, .init_machine = msm8930_cdp_init, .init_early = <API key>, .init_very_early = <API key>, MACHINE_END MACHINE_START(MSM8930_FLUID, "QCT MSM8930 FLUID") .map_io = msm8930_map_io, .reserve = msm8930_reserve, .init_irq = msm8930_init_irq, .handle_irq = gic_handle_irq, .timer = &msm_timer, .init_machine = msm8930_cdp_init, .init_early = <API key>, .init_very_early = <API key>, MACHINE_END MACHINE_START(MSM8627_CDP, "QCT MSM8627 CDP") .map_io = msm8930_map_io, .reserve = msm8930_reserve, .init_irq = msm8930_init_irq, .handle_irq = gic_handle_irq, .timer = &msm_timer, .init_machine = msm8930_cdp_init, .init_early = <API key>, .init_very_early = <API key>, MACHINE_END MACHINE_START(MSM8627_MTP, "QCT MSM8627 MTP") .map_io = msm8930_map_io, .reserve = msm8930_reserve, .init_irq = msm8930_init_irq, .handle_irq = gic_handle_irq, .timer = &msm_timer, .init_machine = msm8930_cdp_init, .init_early = <API key>, .init_very_early = <API key>, MACHINE_END
#ifndef <API key> #define <API key> #include <glib-object.h> #include <gst/gst.h> #include "gstfragment.h" G_BEGIN_DECLS #define <API key> (<API key>()) #define GST_URI_DOWNLOADER(obj) (<API key>((obj),<API key>,GstUriDownloader)) #define <API key>(klass) (<API key>((klass),<API key>,<API key>)) #define <API key>(obj) (<API key>((obj),<API key>)) #define <API key>(klass) (<API key>((klass),<API key>)) typedef struct _GstUriDownloader GstUriDownloader; typedef struct <API key> <API key>; typedef struct <API key> <API key>; struct _GstUriDownloader { GstObject parent; <API key> *priv; }; struct <API key> { GstObjectClass parent_class; /*< private >*/ gpointer _gst_reserved[GST_PADDING]; }; GType <API key> (void); GstUriDownloader * <API key> (void); GstFragment * <API key> (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, gboolean allow_cache, GError ** err); GstFragment * <API key> (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, gboolean allow_cache, gint64 range_start, gint64 range_end, GError ** err); void <API key> (GstUriDownloader *downloader); void <API key> (GstUriDownloader *downloader); void <API key> (GstUriDownloader *downloader); G_END_DECLS #endif /* <API key> */
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - <API key></title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular.min.js"></script> </head> <body ng-app=""> <script type="text/ng-template" id="/tpl.html"> Content of the template. </script> <a ng-click="currentTpl='/tpl.html'" id="tpl-link">Load inlined template</a> <div id="tpl-content" ng-include src="currentTpl"></div> </body> </html>
import 'bootstrap'; import $ from 'jquery'; import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import {<API key>} from '../<API key>'; import Modal = require('TYPO3/CMS/Backend/Modal'); import Notification = require('TYPO3/CMS/Backend/Notification'); import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); import InfoBox = require('../../Renderable/InfoBox'); import ProgressBar = require('../../Renderable/ProgressBar'); import Severity = require('../../Renderable/Severity'); import Router = require('../../Router'); /** * Module: TYPO3/CMS/Install/EnvironmentCheck */ class EnvironmentCheck extends <API key> { private <API key>: string = '.<API key>'; private <API key>: string = '.<API key>'; private <API key>: string = '.<API key>'; public initialize(currentModal: JQuery): void { this.currentModal = currentModal; // Get status on initialize to have the badge and content ready this.runTests(); currentModal.on('click', this.<API key>, (e: JQueryEventObject): void => { e.preventDefault(); this.runTests(); }); } private runTests(): void { this.<API key>(false); const modalContent = this.getModalBody(); const $errorBadge = $(this.<API key>); $errorBadge.text('').hide(); const message = ProgressBar.render(Severity.loading, 'Loading...', ''); modalContent.find(this.<API key>).empty().append(message); (new AjaxRequest(Router.getUrl('<API key>'))) .get({cache: 'no-cache'}) .then( async (response: AjaxResponse): Promise<any> => { const data = await response.resolve(); modalContent.empty().append(data.html); Modal.setButtons(data.buttons); let warningCount = 0; let errorCount = 0; if (data.success === true && typeof (data.status) === 'object') { $.each(data.status, (i: number, element: any): void => { if (Array.isArray(element) && element.length > 0) { element.forEach((aStatus: any): void => { if (aStatus.severity === 1) { warningCount++; } if (aStatus.severity === 2) { errorCount++; } const aMessage = InfoBox.render(aStatus.severity, aStatus.title, aStatus.message); modalContent.find(this.<API key>).append(aMessage); }); } }); if (errorCount > 0) { $errorBadge.removeClass('label-warning').addClass('label-danger').text(errorCount).show(); } else if (warningCount > 0) { $errorBadge.removeClass('label-error').addClass('label-warning').text(warningCount).show(); } } else { Notification.error('Something went wrong', 'The request was not processed successfully. Please check the browser\'s console and TYPO3\'s log.'); } }, (error: AjaxResponse): void => { Router.handleAjaxError(error, modalContent); } ); } } export = new EnvironmentCheck();
<?php if ( !defined('IN_HLSTATS') ) { die('Do not access this file directly.'); } flush(); $tblTeams = new Table ( array ( new TableColumn ( 'name', 'Team', 'width=35' ), new TableColumn ( 'teamcount', 'Joined', 'width=10&align=right&append=+times' ), new TableColumn ( 'percent', '%', 'width=10&sort=no&align=right&append=' . urlencode('%') ), new TableColumn ( 'percent', 'Ratio', 'width=40&sort=no&type=bargraph' ) ), 'name', 'teamcount', 'name', true, 9999, 'teams_page', 'teams_sort', 'teams_sortorder', 'tabteams', 'desc', true ); $db->query (" SELECT COUNT(*) FROM <API key> WHERE <API key>.playerId = $player "); list($numteamjoins) = $db->fetch_row(); if($numteamjoins == 0) { $numteamjoins = 1; } $result = $db->query (" SELECT IFNULL(hlstats_Teams.name, <API key>.team) AS name, COUNT(<API key>.id) AS teamcount, ROUND((COUNT(<API key>.id) / $numteamjoins) * 100, 2) AS percent FROM <API key> LEFT JOIN hlstats_Teams ON <API key>.team = hlstats_Teams.code WHERE hlstats_Teams.game = '$game' AND <API key>.playerId = $player AND ( hidden <> '1' OR hidden IS NULL ) GROUP BY <API key>.team ORDER BY $tblTeams->sort $tblTeams->sortorder, $tblTeams->sort2 $tblTeams->sortorder "); $numitems = $db->num_rows($result); if ($numitems > 0) { printSectionTitle('Team Selection *'); $tblTeams->draw($result, $numitems, 95); ?> <br /><br /> <?php } flush(); $result = $db->query (" SELECT hlstats_Roles.code, hlstats_Roles.name FROM hlstats_Roles WHERE hlstats_Roles.game = '$game' "); while ($rowdata = $db->fetch_row($result)) { $code = preg_replace("/[ \r\n\t]+/", "", $rowdata[0]); $fname[strToLower($code)] = htmlspecialchars($rowdata[1]); } $tblRoles = new Table ( array ( new TableColumn ( 'code', 'Role', 'width=25&type=roleimg&align=left&link=' . urlencode("mode=rolesinfo&amp;role=%k&amp;game=$game"), $fname ), new TableColumn ( 'rolecount', 'Joined', 'width=10&align=right&append=+times' ), new TableColumn ( 'percent', '%', 'width=10&sort=no&align=right&append=' . urlencode('%') ), new TableColumn ( 'percent', 'Ratio', 'width=20&sort=no&type=bargraph' ), new TableColumn ( 'killsTotal', 'Kills', 'width=10&align=right' ), new TableColumn ( 'deathsTotal', 'Deaths', 'width=10&align=right' ), new TableColumn ( 'kpd', 'K:D', 'width=10&align=right' ) ), 'code', 'rolecount', 'name', true, 9999, 'roles_page', 'roles_sort', 'roles_sortorder', 'roles', 'desc', true ); $db->query (" DROP TABLE IF EXISTS hlstats_Frags_as "); $db->query (" CREATE TEMPORARY TABLE hlstats_Frags_as ( playerId INT(10), kills INT(10), deaths INT(10), role varchar(128) NOT NULL default '' ) "); $db->query (" INSERT INTO hlstats_Frags_as ( playerId, kills, role ) SELECT <API key>.victimId, <API key>.killerId, <API key>.killerRole FROM <API key> WHERE <API key>.killerId = $player "); $db->query (" INSERT INTO hlstats_Frags_as ( playerId, deaths, role ) SELECT <API key>.killerId, <API key>.victimId, <API key>.victimRole FROM <API key> WHERE <API key>.victimId = $player "); $db->query (" DROP TABLE IF EXISTS <API key> "); $db->query (" CREATE TEMPORARY TABLE <API key> ( killsTotal INT(10), deathsTotal INT(10), role varchar(128) NOT NULL default '' ) "); $db->query (" INSERT INTO <API key> ( killsTotal, deathsTotal, role ) SELECT COUNT(hlstats_Frags_as.kills) AS kills, COUNT(hlstats_Frags_as.deaths) AS deaths, hlstats_Frags_as.role FROM hlstats_Frags_as GROUP BY hlstats_Frags_as.role "); $db->query (" SELECT COUNT(*) FROM <API key> WHERE <API key>.playerId = $player "); list($numrolejoins) = $db->fetch_row(); $result = $db->query (" SELECT IFNULL(hlstats_Roles.name, <API key>.role) AS name, IFNULL(hlstats_Roles.code, <API key>.role) AS code, COUNT(<API key>.id) AS rolecount, ROUND(COUNT(<API key>.id) / IF($numrolejoins = 0, 1, $numrolejoins) * 100, 2) AS percent, <API key>.killsTotal, <API key>.deathsTotal, ROUND(<API key>.killsTotal / IF(<API key>.deathsTotal = 0, 1, <API key>.deathsTotal), 2) AS kpd FROM <API key> LEFT JOIN hlstats_Roles ON <API key>.role = hlstats_Roles.code LEFT JOIN <API key> ON <API key>.role = <API key>.role WHERE <API key>.playerId = $player AND ( hidden <> '1' OR hidden IS NULL ) AND hlstats_Roles.game = '$game' GROUP BY <API key>.role ORDER BY $tblRoles->sort $tblRoles->sortorder, $tblRoles->sort2 $tblRoles->sortorder "); $numitems = $db->num_rows($result); if ($numitems > 0) { printSectionTitle('Role Selection *'); $tblRoles->draw($result, $numitems, 95); ?> <br /><br /> <?php } ?>
static void FPU_FINIT(void) { FPU_SetCW(0x37F); fpu.sw = 0; TOP=FPU_GET_TOP(); fpu.tags[0] = TAG_Empty; fpu.tags[1] = TAG_Empty; fpu.tags[2] = TAG_Empty; fpu.tags[3] = TAG_Empty; fpu.tags[4] = TAG_Empty; fpu.tags[5] = TAG_Empty; fpu.tags[6] = TAG_Empty; fpu.tags[7] = TAG_Empty; fpu.tags[8] = TAG_Valid; // is only used by us } static void FPU_FCLEX(void){ fpu.sw &= 0x7f00; //should clear exceptions } static void FPU_FNOP(void){ return; } static void FPU_PUSH(double in){ TOP = (TOP - 1) &7; //actually check if empty fpu.tags[TOP] = TAG_Valid; fpu.regs[TOP].d = in; // LOG(LOG_FPU,LOG_ERROR)("Pushed at %d %g to the stack",newtop,in); return; } static void FPU_PREP_PUSH(void){ TOP = (TOP - 1) &7; fpu.tags[TOP] = TAG_Valid; } static void FPU_FPOP(void){ fpu.tags[TOP]=TAG_Empty; //maybe set zero in it as well TOP = ((TOP+1)&7); // LOG(LOG_FPU,LOG_ERROR)("popped from %d %g off the stack",top,fpu.regs[top].d); return; } static double FROUND(double in){ switch(fpu.round){ case ROUND_Nearest: if (in-floor(in)>0.5) return (floor(in)+1); else if (in-floor(in)<0.5) return (floor(in)); else return (((static_cast<Bit64s>(floor(in)))&1)!=0)?(floor(in)+1):(floor(in)); break; case ROUND_Down: return (floor(in)); break; case ROUND_Up: return (ceil(in)); break; case ROUND_Chop: return in; //the cast afterwards will do it right maybe cast here break; default: return in; break; } } #define BIAS80 16383 #define BIAS64 1023 static Real64 FPU_FLD80(PhysPt addr) { struct { Bit16s begin; FPU_Reg eind; } test; test.eind.l.lower = mem_readd(addr); test.eind.l.upper = mem_readd(addr+4); test.begin = mem_readw(addr+8); Bit64s exp64 = (((test.begin&0x7fff) - BIAS80)); Bit64s blah = ((exp64 >0)?exp64:-exp64)&0x3ff; Bit64s exp64final = ((exp64 >0)?blah:-blah) +BIAS64; Bit64s mant64 = (test.eind.ll >> 11) & LONGTYPE(0xfffffffffffff); Bit64s sign = (test.begin&0x8000)?1:0; FPU_Reg result; result.ll = (sign <<63)|(exp64final << 52)| mant64; if(test.eind.l.lower == 0 && test.eind.l.upper == 0x80000000 && (test.begin&0x7fff) == 0x7fff) { //Detect INF and -INF (score 3.11 when drawing a slur.) result.d = sign?-HUGE_VAL:HUGE_VAL; } return result.d; } static void FPU_ST80(PhysPt addr,Bitu reg) { struct { Bit16s begin; FPU_Reg eind; } test; Bit64s sign80 = (fpu.regs[reg].ll&LONGTYPE(0x8000000000000000))?1:0; Bit64s exp80 = fpu.regs[reg].ll&LONGTYPE(0x7ff0000000000000); Bit64s exp80final = (exp80>>52); Bit64s mant80 = fpu.regs[reg].ll&LONGTYPE(0x000fffffffffffff); Bit64s mant80final = (mant80 << 11); if(fpu.regs[reg].d != 0){ //Zero is a special case // Elvira wants the 8 and tcalc doesn't mant80final |= LONGTYPE(0x8000000000000000); //Ca-cyber doesn't like this when result is zero. exp80final += (BIAS80 - BIAS64); } test.begin = (static_cast<Bit16s>(sign80)<<15)| static_cast<Bit16s>(exp80final); test.eind.ll = mant80final; mem_writed(addr,test.eind.l.lower); mem_writed(addr+4,test.eind.l.upper); mem_writew(addr+8,test.begin); } static void FPU_FLD_F32(PhysPt addr,Bitu store_to) { union { float f; Bit32u l; } blah; blah.l = mem_readd(addr); fpu.regs[store_to].d = static_cast<Real64>(blah.f); } static void FPU_FLD_F64(PhysPt addr,Bitu store_to) { fpu.regs[store_to].l.lower = mem_readd(addr); fpu.regs[store_to].l.upper = mem_readd(addr+4); } static void FPU_FLD_F80(PhysPt addr) { fpu.regs[TOP].d = FPU_FLD80(addr); } static void FPU_FLD_I16(PhysPt addr,Bitu store_to) { Bit16s blah = mem_readw(addr); fpu.regs[store_to].d = static_cast<Real64>(blah); } static void FPU_FLD_I32(PhysPt addr,Bitu store_to) { Bit32s blah = mem_readd(addr); fpu.regs[store_to].d = static_cast<Real64>(blah); } static void FPU_FLD_I64(PhysPt addr,Bitu store_to) { FPU_Reg blah; blah.l.lower = mem_readd(addr); blah.l.upper = mem_readd(addr+4); fpu.regs[store_to].d = static_cast<Real64>(blah.ll); } static void FPU_FBLD(PhysPt addr,Bitu store_to) { Bit64u val = 0; Bitu in = 0; Bit64u base = 1; for(Bitu i = 0;i < 9;i++){ in = mem_readb(addr + i); val += ( (in&0xf) * base); //in&0xf shouldn't be higher then 9 base *= 10; val += ((( in>>4)&0xf) * base); base *= 10; } //last number, only now convert to float in order to get //the best signification Real64 temp = static_cast<Real64>(val); in = mem_readb(addr + 9); temp += ( (in&0xf) * base ); if(in&0x80) temp *= -1.0; fpu.regs[store_to].d = temp; } static INLINE void FPU_FLD_F32_EA(PhysPt addr) { FPU_FLD_F32(addr,8); } static INLINE void FPU_FLD_F64_EA(PhysPt addr) { FPU_FLD_F64(addr,8); } static INLINE void FPU_FLD_I32_EA(PhysPt addr) { FPU_FLD_I32(addr,8); } static INLINE void FPU_FLD_I16_EA(PhysPt addr) { FPU_FLD_I16(addr,8); } static void FPU_FST_F32(PhysPt addr) { union { float f; Bit32u l; } blah; //should depend on rounding method blah.f = static_cast<float>(fpu.regs[TOP].d); mem_writed(addr,blah.l); } static void FPU_FST_F64(PhysPt addr) { mem_writed(addr,fpu.regs[TOP].l.lower); mem_writed(addr+4,fpu.regs[TOP].l.upper); } static void FPU_FST_F80(PhysPt addr) { FPU_ST80(addr,TOP); } static void FPU_FST_I16(PhysPt addr) { mem_writew(addr,static_cast<Bit16s>(FROUND(fpu.regs[TOP].d))); } static void FPU_FST_I32(PhysPt addr) { mem_writed(addr,static_cast<Bit32s>(FROUND(fpu.regs[TOP].d))); } static void FPU_FST_I64(PhysPt addr) { FPU_Reg blah; blah.ll = static_cast<Bit64s>(FROUND(fpu.regs[TOP].d)); mem_writed(addr,blah.l.lower); mem_writed(addr+4,blah.l.upper); } static void FPU_FBST(PhysPt addr) { FPU_Reg val = fpu.regs[TOP]; bool sign = false; if(fpu.regs[TOP].ll & LONGTYPE(0x8000000000000000)) { //sign sign=true; val.d=-val.d; } //numbers from back to front Real64 temp=val.d; Bitu p; for(Bitu i=0;i<9;i++){ val.d=temp; temp = static_cast<Real64>(static_cast<Bit64s>(floor(val.d/10.0))); p = static_cast<Bitu>(val.d - 10.0*temp); val.d=temp; temp = static_cast<Real64>(static_cast<Bit64s>(floor(val.d/10.0))); p |= (static_cast<Bitu>(val.d - 10.0*temp)<<4); mem_writeb(addr+i,p); } val.d=temp; temp = static_cast<Real64>(static_cast<Bit64s>(floor(val.d/10.0))); p = static_cast<Bitu>(val.d - 10.0*temp); if(sign) p|=0x80; mem_writeb(addr+9,p); } static void FPU_FADD(Bitu op1, Bitu op2){ fpu.regs[op1].d+=fpu.regs[op2].d; //flags and such :) return; } static void FPU_FSIN(void){ fpu.regs[TOP].d = sin(fpu.regs[TOP].d); FPU_SET_C2(0); //flags and such :) return; } static void FPU_FSINCOS(void){ Real64 temp = fpu.regs[TOP].d; fpu.regs[TOP].d = sin(temp); FPU_PUSH(cos(temp)); FPU_SET_C2(0); //flags and such :) return; } static void FPU_FCOS(void){ fpu.regs[TOP].d = cos(fpu.regs[TOP].d); FPU_SET_C2(0); //flags and such :) return; } static void FPU_FSQRT(void){ fpu.regs[TOP].d = sqrt(fpu.regs[TOP].d); //flags and such :) return; } static void FPU_FPATAN(void){ fpu.regs[STV(1)].d = atan2(fpu.regs[STV(1)].d,fpu.regs[TOP].d); FPU_FPOP(); //flags and such :) return; } static void FPU_FPTAN(void){ fpu.regs[TOP].d = tan(fpu.regs[TOP].d); FPU_PUSH(1.0); FPU_SET_C2(0); //flags and such :) return; } static void FPU_FDIV(Bitu st, Bitu other){ fpu.regs[st].d= fpu.regs[st].d/fpu.regs[other].d; //flags and such :) return; } static void FPU_FDIVR(Bitu st, Bitu other){ fpu.regs[st].d= fpu.regs[other].d/fpu.regs[st].d; // flags and such :) return; } static void FPU_FMUL(Bitu st, Bitu other){ fpu.regs[st].d*=fpu.regs[other].d; //flags and such :) return; } static void FPU_FSUB(Bitu st, Bitu other){ fpu.regs[st].d = fpu.regs[st].d - fpu.regs[other].d; //flags and such :) return; } static void FPU_FSUBR(Bitu st, Bitu other){ fpu.regs[st].d= fpu.regs[other].d - fpu.regs[st].d; //flags and such :) return; } static void FPU_FXCH(Bitu st, Bitu other){ FPU_Tag tag = fpu.tags[other]; FPU_Reg reg = fpu.regs[other]; fpu.tags[other] = fpu.tags[st]; fpu.regs[other] = fpu.regs[st]; fpu.tags[st] = tag; fpu.regs[st] = reg; } static void FPU_FST(Bitu st, Bitu other){ fpu.tags[other] = fpu.tags[st]; fpu.regs[other] = fpu.regs[st]; } static void FPU_FCOM(Bitu st, Bitu other){ if(((fpu.tags[st] != TAG_Valid) && (fpu.tags[st] != TAG_Zero)) || ((fpu.tags[other] != TAG_Valid) && (fpu.tags[other] != TAG_Zero))){ FPU_SET_C3(1);FPU_SET_C2(1);FPU_SET_C0(1);return; } if(fpu.regs[st].d == fpu.regs[other].d){ FPU_SET_C3(1);FPU_SET_C2(0);FPU_SET_C0(0);return; } if(fpu.regs[st].d < fpu.regs[other].d){ FPU_SET_C3(0);FPU_SET_C2(0);FPU_SET_C0(1);return; } // st > other FPU_SET_C3(0);FPU_SET_C2(0);FPU_SET_C0(0);return; } static void FPU_FUCOM(Bitu st, Bitu other){ //does atm the same as fcom FPU_FCOM(st,other); } static void FPU_FRNDINT(void){ Bit64s temp= static_cast<Bit64s>(FROUND(fpu.regs[TOP].d)); fpu.regs[TOP].d=static_cast<double>(temp); } static void FPU_FPREM(void){ Real64 valtop = fpu.regs[TOP].d; Real64 valdiv = fpu.regs[STV(1)].d; Bit64s ressaved = static_cast<Bit64s>( (valtop/valdiv) ); // Some backups // Real64 res=valtop - ressaved*valdiv; // res= fmod(valtop,valdiv); fpu.regs[TOP].d = valtop - ressaved*valdiv; FPU_SET_C0(static_cast<Bitu>(ressaved&4)); FPU_SET_C3(static_cast<Bitu>(ressaved&2)); FPU_SET_C1(static_cast<Bitu>(ressaved&1)); FPU_SET_C2(0); } static void FPU_FPREM1(void){ Real64 valtop = fpu.regs[TOP].d; Real64 valdiv = fpu.regs[STV(1)].d; double quot = valtop/valdiv; double quotf = floor(quot); Bit64s ressaved; if (quot-quotf>0.5) ressaved = static_cast<Bit64s>(quotf+1); else if (quot-quotf<0.5) ressaved = static_cast<Bit64s>(quotf); else ressaved = static_cast<Bit64s>((((static_cast<Bit64s>(quotf))&1)!=0)?(quotf+1):(quotf)); fpu.regs[TOP].d = valtop - ressaved*valdiv; FPU_SET_C0(static_cast<Bitu>(ressaved&4)); FPU_SET_C3(static_cast<Bitu>(ressaved&2)); FPU_SET_C1(static_cast<Bitu>(ressaved&1)); FPU_SET_C2(0); } static void FPU_FXAM(void){ if(fpu.regs[TOP].ll & LONGTYPE(0x8000000000000000)) //sign { FPU_SET_C1(1); } else { FPU_SET_C1(0); } if(fpu.tags[TOP] == TAG_Empty) { FPU_SET_C3(1);FPU_SET_C2(0);FPU_SET_C0(1); return; } if(fpu.regs[TOP].d == 0.0) //zero or normalized number. { FPU_SET_C3(1);FPU_SET_C2(0);FPU_SET_C0(0); } else { FPU_SET_C3(0);FPU_SET_C2(1);FPU_SET_C0(0); } } static void FPU_F2XM1(void){ fpu.regs[TOP].d = pow(2.0,fpu.regs[TOP].d) - 1; return; } static void FPU_FYL2X(void){ fpu.regs[STV(1)].d*=log(fpu.regs[TOP].d)/log(static_cast<Real64>(2.0)); FPU_FPOP(); return; } static void FPU_FYL2XP1(void){ fpu.regs[STV(1)].d*=log(fpu.regs[TOP].d+1.0)/log(static_cast<Real64>(2.0)); FPU_FPOP(); return; } static void FPU_FSCALE(void){ fpu.regs[TOP].d *= pow(2.0,static_cast<Real64>(static_cast<Bit64s>(fpu.regs[STV(1)].d))); return; //2^x where x is chopped. } static void FPU_FSTENV(PhysPt addr){ FPU_SET_TOP(TOP); if(!cpu.code.big) { mem_writew(addr+0,static_cast<Bit16u>(fpu.cw)); mem_writew(addr+2,static_cast<Bit16u>(fpu.sw)); mem_writew(addr+4,static_cast<Bit16u>(FPU_GetTag())); } else { mem_writed(addr+0,static_cast<Bit32u>(fpu.cw)); mem_writed(addr+4,static_cast<Bit32u>(fpu.sw)); mem_writed(addr+8,static_cast<Bit32u>(FPU_GetTag())); } } static void FPU_FLDENV(PhysPt addr){ Bit16u tag; Bit32u tagbig; Bitu cw; if(!cpu.code.big) { cw = mem_readw(addr+0); fpu.sw = mem_readw(addr+2); tag = mem_readw(addr+4); } else { cw = mem_readd(addr+0); fpu.sw = (Bit16u)mem_readd(addr+4); tagbig = mem_readd(addr+8); tag = static_cast<Bit16u>(tagbig); } FPU_SetTag(tag); FPU_SetCW(cw); TOP = FPU_GET_TOP(); } static void FPU_FSAVE(PhysPt addr){ FPU_FSTENV(addr); Bitu start = (cpu.code.big?28:14); for(Bitu i = 0;i < 8;i++){ FPU_ST80(addr+start,STV(i)); start += 10; } FPU_FINIT(); } static void FPU_FRSTOR(PhysPt addr){ FPU_FLDENV(addr); Bitu start = (cpu.code.big?28:14); for(Bitu i = 0;i < 8;i++){ fpu.regs[STV(i)].d = FPU_FLD80(addr+start); start += 10; } } static void FPU_FXTRACT(void) { // function stores real bias in st and // pushes the significant number onto the stack // if double ever uses a different base please correct this function FPU_Reg test = fpu.regs[TOP]; Bit64s exp80 = test.ll&LONGTYPE(0x7ff0000000000000); Bit64s exp80final = (exp80>>52) - BIAS64; Real64 mant = test.d / (pow(2.0,static_cast<Real64>(exp80final))); fpu.regs[TOP].d = static_cast<Real64>(exp80final); FPU_PUSH(mant); } static void FPU_FCHS(void){ fpu.regs[TOP].d = -1.0*(fpu.regs[TOP].d); } static void FPU_FABS(void){ fpu.regs[TOP].d = fabs(fpu.regs[TOP].d); } static void FPU_FTST(void){ fpu.regs[8].d = 0.0; FPU_FCOM(TOP,8); } static void FPU_FLD1(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = 1.0; } static void FPU_FLDL2T(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = L2T; } static void FPU_FLDL2E(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = L2E; } static void FPU_FLDPI(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = PI; } static void FPU_FLDLG2(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = LG2; } static void FPU_FLDLN2(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = LN2; } static void FPU_FLDZ(void){ FPU_PREP_PUSH(); fpu.regs[TOP].d = 0.0; fpu.tags[TOP] = TAG_Zero; } static INLINE void FPU_FADD_EA(Bitu op1){ FPU_FADD(op1,8); } static INLINE void FPU_FMUL_EA(Bitu op1){ FPU_FMUL(op1,8); } static INLINE void FPU_FSUB_EA(Bitu op1){ FPU_FSUB(op1,8); } static INLINE void FPU_FSUBR_EA(Bitu op1){ FPU_FSUBR(op1,8); } static INLINE void FPU_FDIV_EA(Bitu op1){ FPU_FDIV(op1,8); } static INLINE void FPU_FDIVR_EA(Bitu op1){ FPU_FDIVR(op1,8); } static INLINE void FPU_FCOM_EA(Bitu op1){ FPU_FCOM(op1,8); }
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # This file is part of duplicity. # Duplicity is free software; you can redistribute it and/or modify it # option) any later version. # Duplicity is distributed in the hope that it will be useful, but # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): def test_all(self): td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() td.cleanup() if __name__ == "__main__": unittest.main()
#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/device.h> #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/clk.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/asoundef.h> #include <asm/mach-types.h> //#include <asm/arch/hardware.h> #include "../sound/soc/codecs/rt5623.h" #include <linux/mbus.h> #include <asm/setup.h> #include <asm/mach/arch.h> #include <../arch/arm/mach-dove/common.h> //#include <asm/plat-orion/i2s-orion.h> #include "mv88fx-pcm.h" #include "mv88fx-i2s.h" #include "ctrlEnv/mvCtrlEnvSpec.h" #include "audio/mvAudioRegs.h" extern int <API key>(unsigned int); extern int <API key>(unsigned int,int); static struct <API key> mv88fx_machine_data; static struct rt5623_setup_data rt5623_setup; static int <API key>(struct snd_pcm_substream *substream) { // struct snd_soc_pcm_runtime *rtd = substream->private_data; // struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai; // struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; // int ret; #if 0 int phoneInDetected; // printk("%s\n",__func__); /* check the jack status at stream startup */ phoneInDetected = <API key>(MPP_PhLine_IN); if (phoneInDetected < 0) { snd_printk("Failed to detect phone-in.\n"); } else { if (! phoneInDetected) { rt5623_setup.mic2_input = 0; } else { rt5623_setup.mic2_input = 1; } } #endif return 0; } static void <API key>(struct snd_pcm_substream *substream) { // printk("%s\n",__func__); } static int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; unsigned int clk = 0; int ret = 0; unsigned int format; // printk("%s\n",__func__); /* set codec DAI configuration */ switch (params_rate(params)) { case 44100: clk = 11289600; break; case 48000: clk = 12288000; break; case 96000: clk = 24576000; break; } format = <API key> | SND_SOC_DAIFMT_I2S | <API key>; ret = codec_dai->ops->set_fmt(codec_dai, format); if (ret < 0) return ret; /* set cpu DAI configuration */ ret = cpu_dai->ops->set_fmt(cpu_dai, format); if (ret < 0) return ret; /* cpu clock is the mv88fx master clock sent to codec */ ret = cpu_dai->ops->set_sysclk(cpu_dai, 0, 0, SND_SOC_CLOCK_IN); if (ret < 0) return ret; /* codec system clock is supplied by mv88fx*/ ret = codec_dai->ops->set_sysclk(codec_dai, 0, clk, SND_SOC_CLOCK_IN); if (ret < 0) return ret; return 0; } static int <API key>(struct snd_pcm_substream *substream,int cmd) { switch (cmd) { case <API key>: if(substream->stream==<API key>) { // <API key>(MPP_Amp_PwrDn,1); } break; case <API key>: if(substream->stream==<API key>) { // <API key>(MPP_Amp_PwrDn,0); } break; } return 0; } static int mv88fx_rt5623_init(struct snd_soc_codec *codec) { mv88fx_snd_debug(""); // <API key>(MPP_Amp_PwrDn,0); return 0; } /* machine stream operations */ static struct snd_soc_ops <API key> = { .startup = <API key>, .shutdown = <API key>, .hw_params = <API key>, .trigger = <API key>, }; static struct snd_soc_dai_link mv88fx_dai = { .name = "RT5623", .stream_name = "RT5623", .cpu_dai = &mv88fx_i2s_dai1, .codec_dai = &rt5623_dai, .ops = &<API key>, .init = mv88fx_rt5623_init, }; static int mv88fx_probe(struct platform_device *pdev) { return 0; } static int mv88fx_remove(struct platform_device *pdev) { return 0; } static struct snd_soc_card dove = { .name = "Dove", .platform = &mv88fx_soc_platform, .probe = mv88fx_probe, .remove = mv88fx_remove, /* CPU <--> Codec DAI links */ .dai_link = &mv88fx_dai, .num_links = 1, }; static struct rt5623_setup_data rt5623_setup = { .i2c_address = 0x1a, .mic2_input = 1, }; static struct snd_soc_device mv88fx_snd_devdata = { .card = &dove, .codec_dev = &<API key>, .codec_data = &rt5623_setup, }; static int <API key>(struct platform_device *pdev) { struct resource *r = NULL; int err = 0; mv88fx_snd_debug(""); mv88fx_machine_data.port = pdev->id; mv88fx_machine_data.pdata = (struct <API key> *)pdev->dev.platform_data; r = <API key>(pdev, IORESOURCE_MEM, 0); if (!r) { err = -ENXIO; goto error; } r = request_mem_region(r->start, SZ_16K, DRIVER_NAME); if (!r) { err = -EBUSY; goto error; } mv88fx_machine_data.res = r; mv88fx_machine_data.base = ioremap(r->start, SZ_16K); if (!mv88fx_machine_data.base) { mv88fx_snd_error("ioremap failed"); err = -ENOMEM; goto error; } mv88fx_machine_data.base -= <API key>(mv88fx_machine_data.port); mv88fx_machine_data.irq = platform_get_irq(pdev, 0); if (mv88fx_machine_data.irq == NO_IRQ) { err = -ENXIO; goto error; } #if defined(CONFIG_HAVE_CLK) mv88fx_machine_data.clk = clk_get(&pdev->dev, NULL); if (IS_ERR(mv88fx_machine_data.clk)) dev_notice(&pdev->dev, "cannot get clkdev\n"); else clk_enable(mv88fx_machine_data.clk); #endif return 0; error: if (mv88fx_machine_data.base) { iounmap(mv88fx_machine_data.base); mv88fx_machine_data.base = NULL; } release_mem_region(mv88fx_machine_data.res->start, SZ_16K); return err; } static int mv88fx_snd_probe(struct platform_device *pdev) { int ret = 0; mv88fx_snd_debug(""); if (<API key>(pdev) != 0) goto error; mv88fx_machine_data.snd_dev = <API key>("soc-audio", pdev->id); if (!mv88fx_machine_data.snd_dev) { ret = -ENOMEM; goto error; } <API key>(mv88fx_machine_data.snd_dev, &mv88fx_snd_devdata); mv88fx_snd_devdata.dev = &mv88fx_machine_data.snd_dev->dev; mv88fx_machine_data.snd_dev->dev.platform_data = &mv88fx_machine_data; ret = platform_device_add(mv88fx_machine_data.snd_dev); if(ret) { platform_device_put(mv88fx_machine_data.snd_dev); } return ret; error: mv88fx_snd_error(""); #if defined(CONFIG_HAVE_CLK) if (!IS_ERR(mv88fx_machine_data.clk)) { clk_disable(mv88fx_machine_data.clk); clk_put(mv88fx_machine_data.clk); } #endif if (mv88fx_machine_data.snd_dev) <API key>(mv88fx_machine_data.snd_dev); return ret; } static int mv88fx_snd_remove(struct platform_device *dev) { mv88fx_snd_debug(""); #if defined(CONFIG_HAVE_CLK) if (!IS_ERR(mv88fx_machine_data.clk)) { clk_disable(mv88fx_machine_data.clk); clk_put(mv88fx_machine_data.clk); } #endif mv88fx_machine_data.snd_dev->dev.platform_data = NULL; <API key>(mv88fx_machine_data.snd_dev); release_mem_region(mv88fx_machine_data.res->start, SZ_16K); return 0; } static struct platform_driver mv88fx_snd_driver = { .probe = mv88fx_snd_probe, .remove = mv88fx_snd_remove, .suspend = NULL, .resume = NULL, .driver = { .name = DRIVER_NAME, }, }; static int __init mv88fx_snd_init(void) { if (!<API key>()) return -ENODEV; mv88fx_snd_debug(""); return <API key>(&mv88fx_snd_driver); } static void __exit mv88fx_snd_exit(void) { mv88fx_snd_debug(""); <API key>(&mv88fx_snd_driver); } module_init(mv88fx_snd_init); module_exit(mv88fx_snd_exit); /* Module information */ MODULE_AUTHOR("Yuval Elmaliah <eyuval@marvell.com>"); MODULE_AUTHOR("Ethan Ku <eku@marvell.com>"); MODULE_DESCRIPTION("ALSA SoC Dove"); MODULE_LICENSE("GPL");
#pragma once #include <wx/bitmap.h> #include <wx/defs.h> #include <wx/event.h> #include <wx/gdicmn.h> #include <wx/panel.h> #include <wx/string.h> #include <wx/translation.h> #include <wx/windowid.h> #include "Common/CommonTypes.h" #include "Common/Event.h" #include "DolphinWX/Globals.h" class CFrame; class CRegisterWindow; class CWatchWindow; class CBreakPointWindow; class CMemoryWindow; class CJitWindow; class CCodeView; class DSPDebuggerLLE; class GFXDebuggerPanel; struct <API key>; class wxToolBar; class wxListBox; class wxMenu; class wxMenuBar; class CCodeWindow : public wxPanel { public: CCodeWindow(const <API key>& <API key>, CFrame * parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxBORDER_NONE, const wxString& name = _("Code")); void Load(); void Save(); // Parent interaction CFrame *Parent; wxMenuBar * GetMenuBar(); wxToolBar * GetToolBar(); wxBitmap m_Bitmaps[<API key>]; bool UseInterpreter(); bool BootToPause(); bool AutomaticStart(); bool JITNoBlockCache(); bool JITNoBlockLinking(); bool JumpToAddress(u32 address); void Update() override; void NotifyMapLoaded(); void CreateMenu(const <API key>& <API key>, wxMenuBar *pMenuBar); void CreateMenuOptions(wxMenu *pMenu); void CreateMenuSymbols(wxMenuBar *pMenuBar); void RecreateToolbar(wxToolBar*); void PopulateToolbar(wxToolBar* toolBar); void UpdateButtonStates(); void OpenPages(); void UpdateManager(); // Menu bar void OnCPUMode(wxCommandEvent& event); // CPU Mode menu void OnJITOff(wxCommandEvent& event); void ToggleCodeWindow(bool bShow); void <API key>(bool bShow); void ToggleWatchWindow(bool bShow); void <API key>(bool bShow); void ToggleMemoryWindow(bool bShow); void ToggleJitWindow(bool bShow); void ToggleSoundWindow(bool bShow); void ToggleVideoWindow(bool bShow); void OnChangeFont(wxCommandEvent& event); void OnCodeStep(wxCommandEvent& event); void OnAddrBoxChange(wxCommandEvent& event); void OnSymbolsMenu(wxCommandEvent& event); void OnJitMenu(wxCommandEvent& event); void OnProfilerMenu(wxCommandEvent& event); // Sub dialogs CRegisterWindow* m_RegisterWindow; CWatchWindow* m_WatchWindow; CBreakPointWindow* m_BreakpointWindow; CMemoryWindow* m_MemoryWindow; CJitWindow* m_JitWindow; DSPDebuggerLLE* m_SoundWindow; GFXDebuggerPanel* m_VideoWindow; // Settings bool bAutomaticStart; bool bBootToPause; bool bShowOnStart[IDM_VIDEO_WINDOW - IDM_LOG_WINDOW + 1]; int iNbAffiliation[IDM_CODE_WINDOW - IDM_LOG_WINDOW + 1]; private: void OnSymbolListChange(wxCommandEvent& event); void <API key>(wxContextMenuEvent& event); void <API key>(wxCommandEvent& event); void OnCallersListChange(wxCommandEvent& event); void OnCallsListChange(wxCommandEvent& event); void OnCodeViewChange(wxCommandEvent &event); void OnHostMessage(wxCommandEvent& event); // Debugger functions void SingleStep(); void StepOver(); void StepOut(); void ToggleBreakpoint(); void UpdateLists(); void UpdateCallstack(); void InitBitmaps(); CCodeView* codeview; wxListBox* callstack; wxListBox* symbols; wxListBox* callers; wxListBox* calls; Common::Event sync_event; };
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/etherdevice.h> #include <linux/if_vlan.h> #include <linux/interrupt.h> #include <linux/ip.h> #include <linux/crash_dump.h> #include <net/tcp.h> #include <net/ipv6.h> #include <net/ip6_checksum.h> #include <net/busy_poll.h> #include <linux/prefetch.h> #include "bnx2x_cmn.h" #include "bnx2x_init.h" #include "bnx2x_sp.h" static void <API key>(struct bnx2x *bp); static int <API key>(struct bnx2x *bp); static int bnx2x_alloc_fp_mem(struct bnx2x *bp); static int bnx2x_poll(struct napi_struct *napi, int budget); static void <API key>(struct bnx2x *bp) { int i; /* Add NAPI objects */ <API key>(bp, i) { netif_napi_add(bp->dev, &bnx2x_fp(bp, i, napi), bnx2x_poll, NAPI_POLL_WEIGHT); } } static void bnx2x_add_all_napi(struct bnx2x *bp) { int i; /* Add NAPI objects */ for_each_eth_queue(bp, i) { netif_napi_add(bp->dev, &bnx2x_fp(bp, i, napi), bnx2x_poll, NAPI_POLL_WEIGHT); } } static int <API key>(struct bnx2x *bp) { int nq = bnx2x_num_queues ? : <API key>(); /* Reduce memory usage in kdump environment by using only one queue */ if (is_kdump_kernel()) nq = 1; nq = clamp(nq, 1, BNX2X_MAX_QUEUES(bp)); return nq; } /** * bnx2x_move_fp - move content of the fastpath structure. * * @bp: driver handle * @from: source FP index * @to: destination FP index * * Makes sure the contents of the bp->fp[to].napi is kept * intact. This is done by first copying the napi struct from * the target to the source, and then mem copying the entire * source onto the target. Update txdata pointers and related * content. */ static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to) { struct bnx2x_fastpath *from_fp = &bp->fp[from]; struct bnx2x_fastpath *to_fp = &bp->fp[to]; struct bnx2x_sp_objs *from_sp_objs = &bp->sp_objs[from]; struct bnx2x_sp_objs *to_sp_objs = &bp->sp_objs[to]; struct bnx2x_fp_stats *from_fp_stats = &bp->fp_stats[from]; struct bnx2x_fp_stats *to_fp_stats = &bp->fp_stats[to]; int old_max_eth_txqs, new_max_eth_txqs; int old_txdata_index = 0, new_txdata_index = 0; struct bnx2x_agg_info *old_tpa_info = to_fp->tpa_info; /* Copy the NAPI object as it has been already initialized */ from_fp->napi = to_fp->napi; /* Move bnx2x_fastpath contents */ memcpy(to_fp, from_fp, sizeof(*to_fp)); to_fp->index = to; /* Retain the tpa_info of the original `to' version as we don't want * 2 FPs to contain the same tpa_info pointer. */ to_fp->tpa_info = old_tpa_info; /* move sp_objs contents as well, as their indices match fp ones */ memcpy(to_sp_objs, from_sp_objs, sizeof(*to_sp_objs)); /* move fp_stats contents as well, as their indices match fp ones */ memcpy(to_fp_stats, from_fp_stats, sizeof(*to_fp_stats)); /* Update txdata pointers in fp and move txdata content accordingly: * Each fp consumes 'max_cos' txdata structures, so the index should be * decremented by max_cos x delta. */ old_max_eth_txqs = <API key>(bp) * (bp)->max_cos; new_max_eth_txqs = (<API key>(bp) - from + to) * (bp)->max_cos; if (from == FCOE_IDX(bp)) { old_txdata_index = old_max_eth_txqs + FCOE_TXQ_IDX_OFFSET; new_txdata_index = new_max_eth_txqs + FCOE_TXQ_IDX_OFFSET; } memcpy(&bp->bnx2x_txq[new_txdata_index], &bp->bnx2x_txq[old_txdata_index], sizeof(struct bnx2x_fp_txdata)); to_fp->txdata_ptr[0] = &bp->bnx2x_txq[new_txdata_index]; } /** * bnx2x_fill_fw_str - Fill buffer with FW version string. * * @bp: driver handle * @buf: character buffer to fill with the fw name * @buf_len: length of the above buffer * */ void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len) { if (IS_PF(bp)) { u8 phy_fw_ver[PHY_FW_VER_LEN]; phy_fw_ver[0] = '\0'; <API key>(&bp->link_params, phy_fw_ver, PHY_FW_VER_LEN); strlcpy(buf, bp->fw_ver, buf_len); snprintf(buf + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), "bc %d.%d.%d%s%s", (bp->common.bc_ver & 0xff0000) >> 16, (bp->common.bc_ver & 0xff00) >> 8, (bp->common.bc_ver & 0xff), ((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver); } else { <API key>(bp, buf, buf_len); } } /** * bnx2x_shrink_eth_fp - guarantees fastpath structures stay intact * * @bp: driver handle * @delta: number of eth queues which were not allocated */ static void bnx2x_shrink_eth_fp(struct bnx2x *bp, int delta) { int i, cos, old_eth_num = <API key>(bp); /* Queue pointer cannot be re-set on an fp-basis, as moving pointer * backward along the array could cause memory to be overridden */ for (cos = 1; cos < bp->max_cos; cos++) { for (i = 0; i < old_eth_num - delta; i++) { struct bnx2x_fastpath *fp = &bp->fp[i]; int new_idx = cos * (old_eth_num - delta) + i; memcpy(&bp->bnx2x_txq[new_idx], fp->txdata_ptr[cos], sizeof(struct bnx2x_fp_txdata)); fp->txdata_ptr[cos] = &bp->bnx2x_txq[new_idx]; } } } int bnx2x_load_count[2][3] = { {0} }; /* per-path: 0-common, 1-port0, 2-port1 */ /* free skb in the packet ring at pos idx * return idx of last bd freed */ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, u16 idx, unsigned int *pkts_compl, unsigned int *bytes_compl) { struct sw_tx_bd *tx_buf = &txdata->tx_buf_ring[idx]; struct eth_tx_start_bd *tx_start_bd; struct eth_tx_bd *tx_data_bd; struct sk_buff *skb = tx_buf->skb; u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons; int nbd; u16 split_bd_len = 0; /* prefetch skb end pointer to speedup dev_kfree_skb() */ prefetch(&skb->end); DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n", txdata->txq_index, idx, tx_buf, skb); tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd; nbd = le16_to_cpu(tx_start_bd->nbd) - 1; #ifdef BNX2X_STOP_ON_ERROR if ((nbd - 1) > (MAX_SKB_FRAGS + 2)) { BNX2X_ERR("BAD nbd!\n"); bnx2x_panic(); } #endif new_cons = nbd + tx_buf->first_bd; /* Get the next bd */ bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); /* Skip a parse bd... */ --nbd; bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); if (tx_buf->flags & <API key>) { /* Skip second parse bd... */ --nbd; bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); } /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */ if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) { tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd; split_bd_len = BD_UNMAP_LEN(tx_data_bd); --nbd; bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); } /* unmap first bd */ dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd), BD_UNMAP_LEN(tx_start_bd) + split_bd_len, DMA_TO_DEVICE); /* now free frags */ while (nbd > 0) { tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd; dma_unmap_page(&bp->pdev->dev, BD_UNMAP_ADDR(tx_data_bd), BD_UNMAP_LEN(tx_data_bd), DMA_TO_DEVICE); if (--nbd) bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); } /* release skb */ WARN_ON(!skb); if (likely(skb)) { (*pkts_compl)++; (*bytes_compl) += skb->len; dev_kfree_skb_any(skb); } tx_buf->first_bd = 0; tx_buf->skb = NULL; return new_cons; } int bnx2x_tx_int(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata) { struct netdev_queue *txq; u16 hw_cons, sw_cons, bd_cons = txdata->tx_bd_cons; unsigned int pkts_compl = 0, bytes_compl = 0; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return -1; #endif txq = netdev_get_tx_queue(bp->dev, txdata->txq_index); hw_cons = le16_to_cpu(*txdata->tx_cons_sb); sw_cons = txdata->tx_pkt_cons; while (sw_cons != hw_cons) { u16 pkt_cons; pkt_cons = TX_BD(sw_cons); DP(NETIF_MSG_TX_DONE, "queue[%d]: hw_cons %u sw_cons %u pkt_cons %u\n", txdata->txq_index, hw_cons, sw_cons, pkt_cons); bd_cons = bnx2x_free_tx_pkt(bp, txdata, pkt_cons, &pkts_compl, &bytes_compl); sw_cons++; } <API key>(txq, pkts_compl, bytes_compl); txdata->tx_pkt_cons = sw_cons; txdata->tx_bd_cons = bd_cons; /* Need to make the tx_bd_cons update visible to start_xmit() * before checking for <API key>(). Without the * memory barrier, there is a small possibility that * start_xmit() will miss it and cause the queue to be stopped * forever. * On the other hand we need an rmb() here to ensure the proper * ordering of bit testing in the following * <API key>(txq) call. */ smp_mb(); if (unlikely(<API key>(txq))) { /* Taking tx_lock() is needed to prevent re-enabling the queue * while it's empty. This could have happen if rx_action() gets * suspended in bnx2x_tx_int() after the condition before * netif_tx_wake_queue(), while tx_action (bnx2x_start_xmit()): * * stops the queue->sees fresh tx_bd_cons->releases the queue-> * sends some packets consuming the whole queue again-> * stops the queue */ __netif_tx_lock(txq, smp_processor_id()); if ((<API key>(txq)) && (bp->state == BNX2X_STATE_OPEN) && (bnx2x_tx_avail(bp, txdata) >= MAX_DESC_PER_TX_PKT)) netif_tx_wake_queue(txq); __netif_tx_unlock(txq); } return 0; } static inline void <API key>(struct bnx2x_fastpath *fp, u16 idx) { u16 last_max = fp->last_max_sge; if (SUB_S16(idx, last_max) > 0) fp->last_max_sge = idx; } static inline void <API key>(struct bnx2x_fastpath *fp, u16 sge_len, struct eth_end_agg_rx_cqe *cqe) { struct bnx2x *bp = fp->bp; u16 last_max, last_elem, first_elem; u16 delta = 0; u16 i; if (!sge_len) return; /* First mark all used pages */ for (i = 0; i < sge_len; i++) BIT_VEC64_CLEAR_BIT(fp->sge_mask, RX_SGE(le16_to_cpu(cqe->sgl_or_raw_data.sgl[i]))); DP(NETIF_MSG_RX_STATUS, "fp_cqe->sgl[%d] = %d\n", sge_len - 1, le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1])); /* Here we assume that the last SGE index is the biggest */ prefetch((void *)(fp->sge_mask)); <API key>(fp, le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1])); last_max = RX_SGE(fp->last_max_sge); last_elem = last_max >> <API key>; first_elem = RX_SGE(fp->rx_sge_prod) >> <API key>; /* If ring is not full */ if (last_elem + 1 != first_elem) last_elem++; /* Now update the prod */ for (i = first_elem; i != last_elem; i = NEXT_SGE_MASK_ELEM(i)) { if (likely(fp->sge_mask[i])) break; fp->sge_mask[i] = <API key>; delta += BIT_VEC64_ELEM_SZ; } if (delta > 0) { fp->rx_sge_prod += delta; /* clear page-end entries */ <API key>(fp); } DP(NETIF_MSG_RX_STATUS, "fp->last_max_sge = %d fp->rx_sge_prod = %d\n", fp->last_max_sge, fp->rx_sge_prod); } /* Get Toeplitz hash value in the skb using the value from the * CQE (calculated by HW). */ static u32 bnx2x_get_rxhash(const struct bnx2x *bp, const struct <API key> *cqe, enum pkt_hash_types *rxhash_type) { /* Get Toeplitz hash from CQE */ if ((bp->dev->features & NETIF_F_RXHASH) && (cqe->status_flags & <API key>)) { enum eth_rss_hash_type htype; htype = cqe->status_flags & <API key>; *rxhash_type = ((htype == TCP_IPV4_HASH_TYPE) || (htype == TCP_IPV6_HASH_TYPE)) ? PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3; return le32_to_cpu(cqe->rss_hash_result); } *rxhash_type = PKT_HASH_TYPE_NONE; return 0; } static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, u16 cons, u16 prod, struct <API key> *cqe) { struct bnx2x *bp = fp->bp; struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons]; struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod]; struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod]; dma_addr_t mapping; struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; struct sw_rx_bd *first_buf = &tpa_info->first_buf; /* print error if current state != stop */ if (tpa_info->tpa_state != BNX2X_TPA_STOP) BNX2X_ERR("start of bin not in stop [%d]\n", queue); /* Try to map an empty data buffer from the aggregation info */ mapping = dma_map_single(&bp->pdev->dev, first_buf->data + NET_SKB_PAD, fp->rx_buf_size, DMA_FROM_DEVICE); /* * ...if it fails - move the skb from the consumer to the producer * and set the current aggregation state as ERROR to drop it * when TPA_STOP arrives. */ if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { /* Move the BD from the consumer to the producer */ bnx2x_reuse_rx_data(fp, cons, prod); tpa_info->tpa_state = BNX2X_TPA_ERROR; return; } /* move empty data from pool to prod */ prod_rx_buf->data = first_buf->data; dma_unmap_addr_set(prod_rx_buf, mapping, mapping); /* point prod_bd to new data */ prod_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); prod_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); /* move partial skb from cons to pool (don't unmap yet) */ *first_buf = *cons_rx_buf; /* mark bin state as START */ tpa_info->parsing_flags = le16_to_cpu(cqe->pars_flags.flags); tpa_info->vlan_tag = le16_to_cpu(cqe->vlan_tag); tpa_info->tpa_state = BNX2X_TPA_START; tpa_info->len_on_bd = le16_to_cpu(cqe->len_on_bd); tpa_info->placement_offset = cqe->placement_offset; tpa_info->rxhash = bnx2x_get_rxhash(bp, cqe, &tpa_info->rxhash_type); if (fp->mode == TPA_MODE_GRO) { u16 gro_size = le16_to_cpu(cqe-><API key>); tpa_info->full_page = SGE_PAGES / gro_size * gro_size; tpa_info->gro_size = gro_size; } #ifdef BNX2X_STOP_ON_ERROR fp->tpa_queue_used |= (1 << queue); DP(NETIF_MSG_RX_STATUS, "fp->tpa_queue_used = 0x%llx\n", fp->tpa_queue_used); #endif } /* Timestamp option length allowed for TPA aggregation: * * nop nop kind length echo val */ #define TPA_TSTAMP_OPT_LEN 12 /** * <API key> - compute GRO values * * @skb: packet skb * @parsing_flags: parsing flags from the START CQE * @len_on_bd: total length of the first packet for the * aggregation. * @pkt_len: length of all segments * * Approximate value of the MSS for this aggregation calculated using * the first packet of it. * Compute number of aggregated segments, and gso_type. */ static void <API key>(struct sk_buff *skb, u16 parsing_flags, u16 len_on_bd, unsigned int pkt_len, u16 <API key>) { /* TPA aggregation won't have either IP options or TCP options * other than timestamp or IPv6 extension headers. */ u16 hdrs_len = ETH_HLEN + sizeof(struct tcphdr); if (GET_FLAG(parsing_flags, <API key>) == <API key>) { hdrs_len += sizeof(struct ipv6hdr); skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; } else { hdrs_len += sizeof(struct iphdr); skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; } /* Check if there was a TCP timestamp, if there is it's will * always be 12 bytes length: nop nop kind length echo val. * * Otherwise FW would close the aggregation. */ if (parsing_flags & <API key>) hdrs_len += TPA_TSTAMP_OPT_LEN; skb_shinfo(skb)->gso_size = len_on_bd - hdrs_len; /* tcp_gro_complete() will copy NAPI_GRO_CB(skb)->count * to skb_shinfo(skb)->gso_segs */ NAPI_GRO_CB(skb)->count = <API key>; } static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp, u16 index, gfp_t gfp_mask) { struct sw_rx_page *sw_buf = &fp->rx_page_ring[index]; struct eth_rx_sge *sge = &fp->rx_sge_ring[index]; struct bnx2x_alloc_pool *pool = &fp->page_pool; dma_addr_t mapping; if (!pool->page) { pool->page = alloc_pages(gfp_mask, PAGES_PER_SGE_SHIFT); if (unlikely(!pool->page)) return -ENOMEM; pool->offset = 0; } mapping = dma_map_page(&bp->pdev->dev, pool->page, pool->offset, SGE_PAGE_SIZE, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { BNX2X_ERR("Can't map sge\n"); return -ENOMEM; } sw_buf->page = pool->page; sw_buf->offset = pool->offset; dma_unmap_addr_set(sw_buf, mapping, mapping); sge->addr_hi = cpu_to_le32(U64_HI(mapping)); sge->addr_lo = cpu_to_le32(U64_LO(mapping)); pool->offset += SGE_PAGE_SIZE; if (PAGE_SIZE - pool->offset >= SGE_PAGE_SIZE) get_page(pool->page); else pool->page = NULL; return 0; } static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_agg_info *tpa_info, u16 pages, struct sk_buff *skb, struct eth_end_agg_rx_cqe *cqe, u16 cqe_idx) { struct sw_rx_page *rx_pg, old_rx_pg; u32 i, frag_len, frag_size; int err, j, frag_id = 0; u16 len_on_bd = tpa_info->len_on_bd; u16 full_page = 0, gro_size = 0; frag_size = le16_to_cpu(cqe->pkt_len) - len_on_bd; if (fp->mode == TPA_MODE_GRO) { gro_size = tpa_info->gro_size; full_page = tpa_info->full_page; } /* This is needed in order to enable forwarding support */ if (frag_size) <API key>(skb, tpa_info->parsing_flags, len_on_bd, le16_to_cpu(cqe->pkt_len), le16_to_cpu(cqe-><API key>)); #ifdef BNX2X_STOP_ON_ERROR if (pages > min_t(u32, 8, MAX_SKB_FRAGS) * SGE_PAGES) { BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n", pages, cqe_idx); BNX2X_ERR("cqe->pkt_len = %d\n", cqe->pkt_len); bnx2x_panic(); return -EINVAL; } #endif /* Run through the SGL and compose the fragmented skb */ for (i = 0, j = 0; i < pages; i += PAGES_PER_SGE, j++) { u16 sge_idx = RX_SGE(le16_to_cpu(cqe->sgl_or_raw_data.sgl[j])); /* FW gives the indices of the SGE as if the ring is an array (meaning that "next" element will consume 2 indices) */ if (fp->mode == TPA_MODE_GRO) frag_len = min_t(u32, frag_size, (u32)full_page); else /* LRO */ frag_len = min_t(u32, frag_size, (u32)SGE_PAGES); rx_pg = &fp->rx_page_ring[sge_idx]; old_rx_pg = *rx_pg; /* If we fail to allocate a substitute page, we simply stop where we are and drop the whole packet */ err = bnx2x_alloc_rx_sge(bp, fp, sge_idx, GFP_ATOMIC); if (unlikely(err)) { bnx2x_fp_qstats(bp, fp)->rx_skb_alloc_failed++; return err; } dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(&old_rx_pg, mapping), SGE_PAGE_SIZE, DMA_FROM_DEVICE); /* Add one frag and update the appropriate fields in the skb */ if (fp->mode == TPA_MODE_LRO) skb_fill_page_desc(skb, j, old_rx_pg.page, old_rx_pg.offset, frag_len); else { /* GRO */ int rem; int offset = 0; for (rem = frag_len; rem > 0; rem -= gro_size) { int len = rem > gro_size ? gro_size : rem; skb_fill_page_desc(skb, frag_id++, old_rx_pg.page, old_rx_pg.offset + offset, len); if (offset) get_page(old_rx_pg.page); offset += len; } } skb->data_len += frag_len; skb->truesize += SGE_PAGES; skb->len += frag_len; frag_size -= frag_len; } return 0; } static void bnx2x_frag_free(const struct bnx2x_fastpath *fp, void *data) { if (fp->rx_frag_size) skb_free_frag(data); else kfree(data); } static void *bnx2x_frag_alloc(const struct bnx2x_fastpath *fp, gfp_t gfp_mask) { if (fp->rx_frag_size) { /* GFP_KERNEL allocations are used only during initialization */ if (unlikely(<API key>(gfp_mask))) return (void *)__get_free_page(gfp_mask); return netdev_alloc_frag(fp->rx_frag_size); } return kmalloc(fp->rx_buf_size + NET_SKB_PAD, gfp_mask); } #ifdef CONFIG_INET static void bnx2x_gro_ip_csum(struct bnx2x *bp, struct sk_buff *skb) { const struct iphdr *iph = ip_hdr(skb); struct tcphdr *th; <API key>(skb, sizeof(struct iphdr)); th = tcp_hdr(skb); th->check = ~tcp_v4_check(skb->len - <API key>(skb), iph->saddr, iph->daddr, 0); } static void bnx2x_gro_ipv6_csum(struct bnx2x *bp, struct sk_buff *skb) { struct ipv6hdr *iph = ipv6_hdr(skb); struct tcphdr *th; <API key>(skb, sizeof(struct ipv6hdr)); th = tcp_hdr(skb); th->check = ~tcp_v6_check(skb->len - <API key>(skb), &iph->saddr, &iph->daddr, 0); } static void bnx2x_gro_csum(struct bnx2x *bp, struct sk_buff *skb, void (*gro_func)(struct bnx2x*, struct sk_buff*)) { <API key>(skb); gro_func(bp, skb); tcp_gro_complete(skb); } #endif static void bnx2x_gro_receive(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct sk_buff *skb) { #ifdef CONFIG_INET if (skb_shinfo(skb)->gso_size) { switch (be16_to_cpu(skb->protocol)) { case ETH_P_IP: bnx2x_gro_csum(bp, skb, bnx2x_gro_ip_csum); break; case ETH_P_IPV6: bnx2x_gro_csum(bp, skb, bnx2x_gro_ipv6_csum); break; default: WARN_ONCE(1, "Error: FW GRO supports only IPv4/IPv6, not 0x%04x\n", be16_to_cpu(skb->protocol)); } } #endif skb_record_rx_queue(skb, fp->rx_queue); napi_gro_receive(&fp->napi, skb); } static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_agg_info *tpa_info, u16 pages, struct eth_end_agg_rx_cqe *cqe, u16 cqe_idx) { struct sw_rx_bd *rx_buf = &tpa_info->first_buf; u8 pad = tpa_info->placement_offset; u16 len = tpa_info->len_on_bd; struct sk_buff *skb = NULL; u8 *new_data, *data = rx_buf->data; u8 old_tpa_state = tpa_info->tpa_state; tpa_info->tpa_state = BNX2X_TPA_STOP; /* If we there was an error during the handling of the TPA_START - * drop this aggregation. */ if (old_tpa_state == BNX2X_TPA_ERROR) goto drop; /* Try to allocate the new data */ new_data = bnx2x_frag_alloc(fp, GFP_ATOMIC); /* Unmap skb in the pool anyway, as we are going to change pool entry status to BNX2X_TPA_STOP even if new skb allocation fails. */ dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); if (likely(new_data)) skb = build_skb(data, fp->rx_frag_size); if (likely(skb)) { #ifdef BNX2X_STOP_ON_ERROR if (pad + len > fp->rx_buf_size) { BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n", pad, len, fp->rx_buf_size); bnx2x_panic(); return; } #endif skb_reserve(skb, pad + NET_SKB_PAD); skb_put(skb, len); skb_set_hash(skb, tpa_info->rxhash, tpa_info->rxhash_type); skb->protocol = eth_type_trans(skb, bp->dev); skb->ip_summed = <API key>; if (!bnx2x_fill_frag_skb(bp, fp, tpa_info, pages, skb, cqe, cqe_idx)) { if (tpa_info->parsing_flags & PARSING_FLAGS_VLAN) <API key>(skb, htons(ETH_P_8021Q), tpa_info->vlan_tag); bnx2x_gro_receive(bp, fp, skb); } else { DP(NETIF_MSG_RX_STATUS, "Failed to allocate new pages - dropping packet!\n"); dev_kfree_skb_any(skb); } /* put new data in bin */ rx_buf->data = new_data; return; } if (new_data) bnx2x_frag_free(fp, new_data); drop: /* drop the packet and keep the buffer in the bin */ DP(NETIF_MSG_RX_STATUS, "Failed to allocate or map a new skb - dropping packet!\n"); bnx2x_fp_stats(bp, fp)->eth_q_stats.rx_skb_alloc_failed++; } static int bnx2x_alloc_rx_data(struct bnx2x *bp, struct bnx2x_fastpath *fp, u16 index, gfp_t gfp_mask) { u8 *data; struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[index]; struct eth_rx_bd *rx_bd = &fp->rx_desc_ring[index]; dma_addr_t mapping; data = bnx2x_frag_alloc(fp, gfp_mask); if (unlikely(data == NULL)) return -ENOMEM; mapping = dma_map_single(&bp->pdev->dev, data + NET_SKB_PAD, fp->rx_buf_size, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { bnx2x_frag_free(fp, data); BNX2X_ERR("Can't map rx data\n"); return -ENOMEM; } rx_buf->data = data; dma_unmap_addr_set(rx_buf, mapping, mapping); rx_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); rx_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); return 0; } static void bnx2x_csum_validate(struct sk_buff *skb, union eth_rx_cqe *cqe, struct bnx2x_fastpath *fp, struct bnx2x_eth_q_stats *qstats) { /* Do nothing if no L4 csum validation was done. * We do not check whether IP csum was validated. For IPv4 we assume * that if the card got as far as validating the L4 csum, it also * validated the IP csum. IPv6 has no IP csum. */ if (cqe->fast_path_cqe.status_flags & <API key>) return; /* If L4 validation was done, check if an error was found. */ if (cqe->fast_path_cqe.type_error_flags & (<API key> | <API key>)) qstats->hw_csum_err++; else skb->ip_summed = <API key>; } static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) { struct bnx2x *bp = fp->bp; u16 bd_cons, bd_prod, bd_prod_fw, comp_ring_cons; u16 sw_comp_cons, sw_comp_prod; int rx_pkt = 0; union eth_rx_cqe *cqe; struct <API key> *cqe_fp; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return 0; #endif if (budget <= 0) return rx_pkt; bd_cons = fp->rx_bd_cons; bd_prod = fp->rx_bd_prod; bd_prod_fw = bd_prod; sw_comp_cons = fp->rx_comp_cons; sw_comp_prod = fp->rx_comp_prod; comp_ring_cons = RCQ_BD(sw_comp_cons); cqe = &fp->rx_comp_ring[comp_ring_cons]; cqe_fp = &cqe->fast_path_cqe; DP(NETIF_MSG_RX_STATUS, "queue[%d]: sw_comp_cons %u\n", fp->index, sw_comp_cons); while (<API key>(cqe_fp)) { struct sw_rx_bd *rx_buf = NULL; struct sk_buff *skb; u8 cqe_fp_flags; enum eth_rx_cqe_type cqe_fp_type; u16 len, pad, queue; u8 *data; u32 rxhash; enum pkt_hash_types rxhash_type; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return 0; #endif bd_prod = RX_BD(bd_prod); bd_cons = RX_BD(bd_cons); /* A rmb() is required to ensure that the CQE is not read * before it is written by the adapter DMA. PCI ordering * rules will make sure the other fields are written before * the marker at the end of struct <API key> * but without rmb() a weakly ordered processor can process * stale data. Without the barrier TPA state-machine might * enter inconsistent state and kernel stack might be * provided with incorrect packet description - these lead * to various kernel crashed. */ rmb(); cqe_fp_flags = cqe_fp->type_error_flags; cqe_fp_type = cqe_fp_flags & <API key>; DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags), cqe_fp_flags, cqe_fp->status_flags, le32_to_cpu(cqe_fp->rss_hash_result), le16_to_cpu(cqe_fp->vlan_tag), le16_to_cpu(cqe_fp-><API key>)); /* is this a slowpath msg? */ if (unlikely(CQE_TYPE_SLOW(cqe_fp_type))) { bnx2x_sp_event(fp, cqe); goto next_cqe; } rx_buf = &fp->rx_buf_ring[bd_cons]; data = rx_buf->data; if (!CQE_TYPE_FAST(cqe_fp_type)) { struct bnx2x_agg_info *tpa_info; u16 frag_size, pages; #ifdef BNX2X_STOP_ON_ERROR /* sanity check */ if (fp->mode == TPA_MODE_DISABLED && (CQE_TYPE_START(cqe_fp_type) || CQE_TYPE_STOP(cqe_fp_type))) BNX2X_ERR("START/STOP packet while TPA disabled, type %x\n", CQE_TYPE(cqe_fp_type)); #endif if (CQE_TYPE_START(cqe_fp_type)) { u16 queue = cqe_fp->queue_index; DP(NETIF_MSG_RX_STATUS, "calling tpa_start on queue %d\n", queue); bnx2x_tpa_start(fp, queue, bd_cons, bd_prod, cqe_fp); goto next_rx; } queue = cqe->end_agg_cqe.queue_index; tpa_info = &fp->tpa_info[queue]; DP(NETIF_MSG_RX_STATUS, "calling tpa_stop on queue %d\n", queue); frag_size = le16_to_cpu(cqe->end_agg_cqe.pkt_len) - tpa_info->len_on_bd; if (fp->mode == TPA_MODE_GRO) pages = (frag_size + tpa_info->full_page - 1) / tpa_info->full_page; else pages = SGE_PAGE_ALIGN(frag_size) >> SGE_PAGE_SHIFT; bnx2x_tpa_stop(bp, fp, tpa_info, pages, &cqe->end_agg_cqe, comp_ring_cons); #ifdef BNX2X_STOP_ON_ERROR if (bp->panic) return 0; #endif <API key>(fp, pages, &cqe->end_agg_cqe); goto next_cqe; } /* non TPA */ len = le16_to_cpu(cqe_fp-><API key>); pad = cqe_fp->placement_offset; <API key>(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), pad + RX_COPY_THRESH, DMA_FROM_DEVICE); pad += NET_SKB_PAD; prefetch(data + pad); /* speedup eth_type_trans() */ /* is this an error packet? */ if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, "ERROR flags %x rx packet %u\n", cqe_fp_flags, sw_comp_cons); bnx2x_fp_qstats(bp, fp)->rx_err_discard_pkt++; goto reuse_rx; } /* Since we don't have a jumbo ring * copy small packets if mtu > 1500 */ if ((bp->dev->mtu > ETH_MAX_PACKET_SIZE) && (len <= RX_COPY_THRESH)) { skb = napi_alloc_skb(&fp->napi, len); if (skb == NULL) { DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, "ERROR packet dropped because of alloc failure\n"); bnx2x_fp_qstats(bp, fp)->rx_skb_alloc_failed++; goto reuse_rx; } memcpy(skb->data, data + pad, len); bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); } else { if (likely(bnx2x_alloc_rx_data(bp, fp, bd_prod, GFP_ATOMIC) == 0)) { dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); skb = build_skb(data, fp->rx_frag_size); if (unlikely(!skb)) { bnx2x_frag_free(fp, data); bnx2x_fp_qstats(bp, fp)-> rx_skb_alloc_failed++; goto next_rx; } skb_reserve(skb, pad); } else { DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, "ERROR packet dropped because of alloc failure\n"); bnx2x_fp_qstats(bp, fp)->rx_skb_alloc_failed++; reuse_rx: bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); goto next_rx; } } skb_put(skb, len); skb->protocol = eth_type_trans(skb, bp->dev); /* Set Toeplitz hash for a none-LRO skb */ rxhash = bnx2x_get_rxhash(bp, cqe_fp, &rxhash_type); skb_set_hash(skb, rxhash, rxhash_type); <API key>(skb); if (bp->dev->features & NETIF_F_RXCSUM) bnx2x_csum_validate(skb, cqe, fp, bnx2x_fp_qstats(bp, fp)); skb_record_rx_queue(skb, fp->rx_queue); /* Check if this packet was timestamped */ if (unlikely(cqe->fast_path_cqe.type_error_flags & (1 << <API key>))) bnx2x_set_rx_ts(bp, skb); if (le16_to_cpu(cqe_fp->pars_flags.flags) & PARSING_FLAGS_VLAN) <API key>(skb, htons(ETH_P_8021Q), le16_to_cpu(cqe_fp->vlan_tag)); napi_gro_receive(&fp->napi, skb); next_rx: rx_buf->data = NULL; bd_cons = NEXT_RX_IDX(bd_cons); bd_prod = NEXT_RX_IDX(bd_prod); bd_prod_fw = NEXT_RX_IDX(bd_prod_fw); rx_pkt++; next_cqe: sw_comp_prod = NEXT_RCQ_IDX(sw_comp_prod); sw_comp_cons = NEXT_RCQ_IDX(sw_comp_cons); /* mark CQE as free */ BNX2X_SEED_CQE(cqe_fp); if (rx_pkt == budget) break; comp_ring_cons = RCQ_BD(sw_comp_cons); cqe = &fp->rx_comp_ring[comp_ring_cons]; cqe_fp = &cqe->fast_path_cqe; } /* while */ fp->rx_bd_cons = bd_cons; fp->rx_bd_prod = bd_prod_fw; fp->rx_comp_cons = sw_comp_cons; fp->rx_comp_prod = sw_comp_prod; /* Update producers */ <API key>(bp, fp, bd_prod_fw, sw_comp_prod, fp->rx_sge_prod); return rx_pkt; } static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie) { struct bnx2x_fastpath *fp = fp_cookie; struct bnx2x *bp = fp->bp; u8 cos; DP(NETIF_MSG_INTR, "got an MSI-X interrupt on IDX:SB [fp %d fw_sd %d igusb %d]\n", fp->index, fp->fw_sb_id, fp->igu_sb_id); bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_DISABLE, 0); #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return IRQ_HANDLED; #endif /* Handle Rx and Tx according to MSI-X vector */ <API key>(fp, cos) prefetch(fp->txdata_ptr[cos]->tx_cons_sb); prefetch(&fp->sb_running_index[SM_RX_ID]); <API key>(&bnx2x_fp(bp, fp->index, napi)); return IRQ_HANDLED; } /* HW Lock for shared dual port PHYs */ void <API key>(struct bnx2x *bp) { mutex_lock(&bp->port.phy_mutex); <API key>(bp, <API key>); } void <API key>(struct bnx2x *bp) { <API key>(bp, <API key>); mutex_unlock(&bp->port.phy_mutex); } /* calculates MF speed according to current linespeed and MF configuration */ u16 bnx2x_get_mf_speed(struct bnx2x *bp) { u16 line_speed = bp->link_vars.line_speed; if (IS_MF(bp)) { u16 maxCfg = <API key>(bp, bp->mf_config[BP_VN(bp)]); /* Calculate the current MAX line speed limit for the MF * devices */ if (IS_MF_PERCENT_BW(bp)) line_speed = (line_speed * maxCfg) / 100; else { /* SD mode */ u16 vn_max_rate = maxCfg * 100; if (vn_max_rate < line_speed) line_speed = vn_max_rate; } } return line_speed; } /** * <API key> - fill link report data to report * * @bp: driver handle * @data: link state to update * * It uses a none-atomic bit operations because is called under the mutex. */ static void <API key>(struct bnx2x *bp, struct <API key> *data) { memset(data, 0, sizeof(*data)); if (IS_PF(bp)) { /* Fill the report data: effective line speed */ data->line_speed = bnx2x_get_mf_speed(bp); /* Link is down */ if (!bp->link_vars.link_up || (bp->flags & MF_FUNC_DIS)) __set_bit(<API key>, &data->link_report_flags); if (!<API key>(bp)) __set_bit(<API key>, &data->link_report_flags); /* Full DUPLEX */ if (bp->link_vars.duplex == DUPLEX_FULL) __set_bit(<API key>, &data->link_report_flags); /* Rx Flow Control is ON */ if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_RX) __set_bit(<API key>, &data->link_report_flags); /* Tx Flow Control is ON */ if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX) __set_bit(<API key>, &data->link_report_flags); } else { *data = bp->vf_link_vars; } } /** * bnx2x_link_report - report link status to OS. * * @bp: driver handle * * Calls the __bnx2x_link_report() under the same locking scheme * as a link/PHY state managing code to ensure a consistent link * reporting. */ void bnx2x_link_report(struct bnx2x *bp) { <API key>(bp); __bnx2x_link_report(bp); <API key>(bp); } /** * __bnx2x_link_report - report link status to OS. * * @bp: driver handle * * None atomic implementation. * Should be called under the phy_lock. */ void __bnx2x_link_report(struct bnx2x *bp) { struct <API key> cur_data; /* reread mf_cfg */ if (IS_PF(bp) && !CHIP_IS_E1(bp)) bnx2x_read_mf_cfg(bp); /* Read the current link report info */ <API key>(bp, &cur_data); /* Don't report link down or exactly the same link status twice */ if (!memcmp(&cur_data, &bp->last_reported_link, sizeof(cur_data)) || (test_bit(<API key>, &bp->last_reported_link.link_report_flags) && test_bit(<API key>, &cur_data.link_report_flags))) return; bp->link_cnt++; /* We are going to report a new link parameters now - * remember the current data for the next time. */ memcpy(&bp->last_reported_link, &cur_data, sizeof(cur_data)); /* propagate status to VFs */ if (IS_PF(bp)) <API key>(bp); if (test_bit(<API key>, &cur_data.link_report_flags)) { netif_carrier_off(bp->dev); netdev_err(bp->dev, "NIC Link is Down\n"); return; } else { const char *duplex; const char *flow; netif_carrier_on(bp->dev); if (test_and_clear_bit(<API key>, &cur_data.link_report_flags)) duplex = "full"; else duplex = "half"; /* Handle the FC at the end so that only these flags would be * possibly set. This way we may easily check if there is no FC * enabled. */ if (cur_data.link_report_flags) { if (test_bit(<API key>, &cur_data.link_report_flags)) { if (test_bit(<API key>, &cur_data.link_report_flags)) flow = "ON - receive & transmit"; else flow = "ON - receive"; } else { flow = "ON - transmit"; } } else { flow = "none"; } netdev_info(bp->dev, "NIC Link is Up, %d Mbps %s duplex, Flow control: %s\n", cur_data.line_speed, duplex, flow); } } static void <API key>(struct bnx2x_fastpath *fp) { int i; for (i = 1; i <= NUM_RX_SGE_PAGES; i++) { struct eth_rx_sge *sge; sge = &fp->rx_sge_ring[RX_SGE_CNT * i - 2]; sge->addr_hi = cpu_to_le32(U64_HI(fp->rx_sge_mapping + BCM_PAGE_SIZE*(i % NUM_RX_SGE_PAGES))); sge->addr_lo = cpu_to_le32(U64_LO(fp->rx_sge_mapping + BCM_PAGE_SIZE*(i % NUM_RX_SGE_PAGES))); } } static void bnx2x_free_tpa_pool(struct bnx2x *bp, struct bnx2x_fastpath *fp, int last) { int i; for (i = 0; i < last; i++) { struct bnx2x_agg_info *tpa_info = &fp->tpa_info[i]; struct sw_rx_bd *first_buf = &tpa_info->first_buf; u8 *data = first_buf->data; if (data == NULL) { DP(NETIF_MSG_IFDOWN, "tpa bin %d empty on free\n", i); continue; } if (tpa_info->tpa_state == BNX2X_TPA_START) dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(first_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); bnx2x_frag_free(fp, data); first_buf->data = NULL; } } void <API key>(struct bnx2x *bp) { int j; <API key>(bp, j) { struct bnx2x_fastpath *fp = &bp->fp[j]; fp->rx_bd_cons = 0; /* Activate BD ring */ /* Warning! * this will generate an interrupt (to the TSTORM) * must only be done after chip is initialized */ <API key>(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod, fp->rx_sge_prod); } } void bnx2x_init_rx_rings(struct bnx2x *bp) { int func = BP_FUNC(bp); u16 ring_prod; int i, j; /* Allocate TPA resources */ for_each_eth_queue(bp, j) { struct bnx2x_fastpath *fp = &bp->fp[j]; DP(NETIF_MSG_IFUP, "mtu %d rx_buf_size %d\n", bp->dev->mtu, fp->rx_buf_size); if (fp->mode != TPA_MODE_DISABLED) { /* Fill the per-aggregation pool */ for (i = 0; i < MAX_AGG_QS(bp); i++) { struct bnx2x_agg_info *tpa_info = &fp->tpa_info[i]; struct sw_rx_bd *first_buf = &tpa_info->first_buf; first_buf->data = bnx2x_frag_alloc(fp, GFP_KERNEL); if (!first_buf->data) { BNX2X_ERR("Failed to allocate TPA skb pool for queue[%d] - disabling TPA on this queue!\n", j); bnx2x_free_tpa_pool(bp, fp, i); fp->mode = TPA_MODE_DISABLED; break; } dma_unmap_addr_set(first_buf, mapping, 0); tpa_info->tpa_state = BNX2X_TPA_STOP; } /* "next page" elements initialization */ <API key>(fp); /* set SGEs bit mask */ <API key>(fp); /* Allocate SGEs and initialize the ring elements */ for (i = 0, ring_prod = 0; i < MAX_RX_SGE_CNT*NUM_RX_SGE_PAGES; i++) { if (bnx2x_alloc_rx_sge(bp, fp, ring_prod, GFP_KERNEL) < 0) { BNX2X_ERR("was only able to allocate %d rx sges\n", i); BNX2X_ERR("disabling TPA for queue[%d]\n", j); /* Cleanup already allocated elements */ <API key>(bp, fp, ring_prod); bnx2x_free_tpa_pool(bp, fp, MAX_AGG_QS(bp)); fp->mode = TPA_MODE_DISABLED; ring_prod = 0; break; } ring_prod = NEXT_SGE_IDX(ring_prod); } fp->rx_sge_prod = ring_prod; } } for_each_eth_queue(bp, j) { struct bnx2x_fastpath *fp = &bp->fp[j]; fp->rx_bd_cons = 0; /* Activate BD ring */ /* Warning! * this will generate an interrupt (to the TSTORM) * must only be done after chip is initialized */ <API key>(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod, fp->rx_sge_prod); if (j != 0) continue; if (CHIP_IS_E1(bp)) { REG_WR(bp, BAR_USTRORM_INTMEM + <API key>(func), U64_LO(fp->rx_comp_mapping)); REG_WR(bp, BAR_USTRORM_INTMEM + <API key>(func) + 4, U64_HI(fp->rx_comp_mapping)); } } } static void <API key>(struct bnx2x_fastpath *fp) { u8 cos; struct bnx2x *bp = fp->bp; <API key>(fp, cos) { struct bnx2x_fp_txdata *txdata = fp->txdata_ptr[cos]; unsigned pkts_compl = 0, bytes_compl = 0; u16 sw_prod = txdata->tx_pkt_prod; u16 sw_cons = txdata->tx_pkt_cons; while (sw_cons != sw_prod) { bnx2x_free_tx_pkt(bp, txdata, TX_BD(sw_cons), &pkts_compl, &bytes_compl); sw_cons++; } <API key>( netdev_get_tx_queue(bp->dev, txdata->txq_index)); } } static void <API key>(struct bnx2x *bp) { int i; <API key>(bp, i) { <API key>(&bp->fp[i]); } } static void bnx2x_free_tx_skbs(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) { <API key>(&bp->fp[i]); } } static void bnx2x_free_rx_bds(struct bnx2x_fastpath *fp) { struct bnx2x *bp = fp->bp; int i; /* ring wasn't allocated */ if (fp->rx_buf_ring == NULL) return; for (i = 0; i < NUM_RX_BD; i++) { struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i]; u8 *data = rx_buf->data; if (data == NULL) continue; dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); rx_buf->data = NULL; bnx2x_frag_free(fp, data); } } static void <API key>(struct bnx2x *bp) { int j; <API key>(bp, j) { bnx2x_free_rx_bds(&bp->fp[j]); } } static void bnx2x_free_rx_skbs(struct bnx2x *bp) { int j; for_each_eth_queue(bp, j) { struct bnx2x_fastpath *fp = &bp->fp[j]; bnx2x_free_rx_bds(fp); if (fp->mode != TPA_MODE_DISABLED) bnx2x_free_tpa_pool(bp, fp, MAX_AGG_QS(bp)); } } static void <API key>(struct bnx2x *bp) { <API key>(bp); <API key>(bp); } void bnx2x_free_skbs(struct bnx2x *bp) { bnx2x_free_tx_skbs(bp); bnx2x_free_rx_skbs(bp); } void <API key>(struct bnx2x *bp, u32 value) { /* load old values */ u32 mf_cfg = bp->mf_config[BP_VN(bp)]; if (value != <API key>(bp, mf_cfg)) { /* leave all but MAX value */ mf_cfg &= ~<API key>; /* set new MAX value */ mf_cfg |= (value << <API key>) & <API key>; bnx2x_fw_command(bp, <API key>, mf_cfg); } } /** * <API key> - free previously requested MSI-X IRQ vectors * * @bp: driver handle * @nvecs: number of vectors to be released */ static void <API key>(struct bnx2x *bp, int nvecs) { int i, offset = 0; if (nvecs == offset) return; /* VFs don't have a default SB */ if (IS_PF(bp)) { free_irq(bp->msix_table[offset].vector, bp->dev); DP(NETIF_MSG_IFDOWN, "released sp irq (%d)\n", bp->msix_table[offset].vector); offset++; } if (CNIC_SUPPORT(bp)) { if (nvecs == offset) return; offset++; } for_each_eth_queue(bp, i) { if (nvecs == offset) return; DP(NETIF_MSG_IFDOWN, "about to release fp #%d->%d irq\n", i, bp->msix_table[offset].vector); free_irq(bp->msix_table[offset++].vector, &bp->fp[i]); } } void bnx2x_free_irq(struct bnx2x *bp) { if (bp->flags & USING_MSIX_FLAG && !(bp->flags & <API key>)) { int nvecs = <API key>(bp) + CNIC_SUPPORT(bp); /* vfs don't have a default status block */ if (IS_PF(bp)) nvecs++; <API key>(bp, nvecs); } else { free_irq(bp->dev->irq, bp->dev); } } int bnx2x_enable_msix(struct bnx2x *bp) { int msix_vec = 0, i, rc; /* VFs don't have a default status block */ if (IS_PF(bp)) { bp->msix_table[msix_vec].entry = msix_vec; BNX2X_DEV_INFO("msix_table[0].entry = %d (slowpath)\n", bp->msix_table[0].entry); msix_vec++; } /* Cnic requires an msix vector for itself */ if (CNIC_SUPPORT(bp)) { bp->msix_table[msix_vec].entry = msix_vec; BNX2X_DEV_INFO("msix_table[%d].entry = %d (CNIC)\n", msix_vec, bp->msix_table[msix_vec].entry); msix_vec++; } /* We need separate vectors for ETH queues only (not FCoE) */ for_each_eth_queue(bp, i) { bp->msix_table[msix_vec].entry = msix_vec; BNX2X_DEV_INFO("msix_table[%d].entry = %d (fastpath msix_vec, msix_vec, i); msix_vec++; } DP(BNX2X_MSG_SP, "about to request enable msix with %d vectors\n", msix_vec); rc = <API key>(bp->pdev, &bp->msix_table[0], <API key>(bp), msix_vec); /* * reconfigure number of tx/rx queues according to available * MSI-X vectors */ if (rc == -ENOSPC) { /* Get by with single vector */ rc = <API key>(bp->pdev, &bp->msix_table[0], 1, 1); if (rc < 0) { BNX2X_DEV_INFO("Single MSI-X is not attainable rc %d\n", rc); goto no_msix; } BNX2X_DEV_INFO("Using single MSI-X vector\n"); bp->flags |= <API key>; BNX2X_DEV_INFO("set number of queues to 1\n"); bp->num_ethernet_queues = 1; bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues; } else if (rc < 0) { BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc); goto no_msix; } else if (rc < msix_vec) { /* how less vectors we will have? */ int diff = msix_vec - rc; BNX2X_DEV_INFO("Trying to use less MSI-X vectors: %d\n", rc); /* * decrease number of queues by number of unallocated entries */ bp->num_ethernet_queues -= diff; bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues; BNX2X_DEV_INFO("New queue configuration set: %d\n", bp->num_queues); } bp->flags |= USING_MSIX_FLAG; return 0; no_msix: /* fall to INTx if not enough memory */ if (rc == -ENOMEM) bp->flags |= DISABLE_MSI_FLAG; return rc; } static int bnx2x_req_msix_irqs(struct bnx2x *bp) { int i, rc, offset = 0; /* no default status block for vf */ if (IS_PF(bp)) { rc = request_irq(bp->msix_table[offset++].vector, bnx2x_msix_sp_int, 0, bp->dev->name, bp->dev); if (rc) { BNX2X_ERR("request sp irq failed\n"); return -EBUSY; } } if (CNIC_SUPPORT(bp)) offset++; for_each_eth_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; snprintf(fp->name, sizeof(fp->name), "%s-fp-%d", bp->dev->name, i); rc = request_irq(bp->msix_table[offset].vector, bnx2x_msix_fp_int, 0, fp->name, fp); if (rc) { BNX2X_ERR("request fp #%d irq (%d) failed rc %d\n", i, bp->msix_table[offset].vector, rc); <API key>(bp, offset); return -EBUSY; } offset++; } i = <API key>(bp); if (IS_PF(bp)) { offset = 1 + CNIC_SUPPORT(bp); netdev_info(bp->dev, "using MSI-X IRQs: sp %d fp[%d] %d ... fp[%d] %d\n", bp->msix_table[0].vector, 0, bp->msix_table[offset].vector, i - 1, bp->msix_table[offset + i - 1].vector); } else { offset = CNIC_SUPPORT(bp); netdev_info(bp->dev, "using MSI-X IRQs: fp[%d] %d ... fp[%d] %d\n", 0, bp->msix_table[offset].vector, i - 1, bp->msix_table[offset + i - 1].vector); } return 0; } int bnx2x_enable_msi(struct bnx2x *bp) { int rc; rc = pci_enable_msi(bp->pdev); if (rc) { BNX2X_DEV_INFO("MSI is not attainable\n"); return -1; } bp->flags |= USING_MSI_FLAG; return 0; } static int bnx2x_req_irq(struct bnx2x *bp) { unsigned long flags; unsigned int irq; if (bp->flags & (USING_MSI_FLAG | USING_MSIX_FLAG)) flags = 0; else flags = IRQF_SHARED; if (bp->flags & USING_MSIX_FLAG) irq = bp->msix_table[0].vector; else irq = bp->pdev->irq; return request_irq(irq, bnx2x_interrupt, flags, bp->dev->name, bp->dev); } static int bnx2x_setup_irqs(struct bnx2x *bp) { int rc = 0; if (bp->flags & USING_MSIX_FLAG && !(bp->flags & <API key>)) { rc = bnx2x_req_msix_irqs(bp); if (rc) return rc; } else { rc = bnx2x_req_irq(bp); if (rc) { BNX2X_ERR("IRQ request failed rc %d, aborting\n", rc); return rc; } if (bp->flags & USING_MSI_FLAG) { bp->dev->irq = bp->pdev->irq; netdev_info(bp->dev, "using MSI IRQ %d\n", bp->dev->irq); } if (bp->flags & USING_MSIX_FLAG) { bp->dev->irq = bp->msix_table[0].vector; netdev_info(bp->dev, "using MSIX IRQ %d\n", bp->dev->irq); } } return 0; } static void <API key>(struct bnx2x *bp) { int i; <API key>(bp, i) { napi_enable(&bnx2x_fp(bp, i, napi)); } } static void bnx2x_napi_enable(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) { napi_enable(&bnx2x_fp(bp, i, napi)); } } static void <API key>(struct bnx2x *bp) { int i; <API key>(bp, i) { napi_disable(&bnx2x_fp(bp, i, napi)); } } static void bnx2x_napi_disable(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) { napi_disable(&bnx2x_fp(bp, i, napi)); } } void bnx2x_netif_start(struct bnx2x *bp) { if (netif_running(bp->dev)) { bnx2x_napi_enable(bp); if (CNIC_LOADED(bp)) <API key>(bp); bnx2x_int_enable(bp); if (bp->state == BNX2X_STATE_OPEN) <API key>(bp->dev); } } void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw) { <API key>(bp, disable_hw); bnx2x_napi_disable(bp); if (CNIC_LOADED(bp)) <API key>(bp); } u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb, void *accel_priv, <API key> fallback) { struct bnx2x *bp = netdev_priv(dev); if (CNIC_LOADED(bp) && !NO_FCOE(bp)) { struct ethhdr *hdr = (struct ethhdr *)skb->data; u16 ether_type = ntohs(hdr->h_proto); /* Skip VLAN tag if present */ if (ether_type == ETH_P_8021Q) { struct vlan_ethhdr *vhdr = (struct vlan_ethhdr *)skb->data; ether_type = ntohs(vhdr-><API key>); } /* If ethertype is FCoE or FIP - use FCoE ring */ if ((ether_type == ETH_P_FCOE) || (ether_type == ETH_P_FIP)) return bnx2x_fcoe_tx(bp, txq_index); } /* select a non-FCoE queue */ return fallback(dev, skb) % (<API key>(bp) * bp->max_cos); } void <API key>(struct bnx2x *bp) { /* RSS queues */ bp->num_ethernet_queues = <API key>(bp); /* override in STORAGE SD modes */ if (IS_MF_STORAGE_ONLY(bp)) bp->num_ethernet_queues = 1; /* Add special queues */ bp->num_cnic_queues = CNIC_SUPPORT(bp); /* For FCOE */ bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues; BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues); } /** * <API key> - configure netdev->real_num_[tx,rx]_queues * * @bp: Driver handle * * We currently support for at most 16 Tx queues for each CoS thus we will * allocate a multiple of 16 for ETH L2 rings according to the value of the * bp->max_cos. * * If there is an FCoE L2 queue the appropriate Tx queue will have the next * index after all ETH L2 indices. * * If the actual number of Tx queues (for each CoS) is less than 16 then there * will be the holes at the end of each group of 16 ETh L2 indices (0..15, * 16..31,...) with indices that are not coupled with any real Tx queue. * * The proper configuration of skb->queue_mapping is handled by * bnx2x_select_queue() and __skb_tx_hash(). * * bnx2x_setup_tc() takes care of the proper TC mappings so that __skb_tx_hash() * will return a proper Tx index if TC is enabled (netdev->num_tc > 0). */ static int <API key>(struct bnx2x *bp, int include_cnic) { int rc, tx, rx; tx = <API key>(bp) * bp->max_cos; rx = <API key>(bp); /* account for fcoe queue */ if (include_cnic && !NO_FCOE(bp)) { rx++; tx++; } rc = <API key>(bp->dev, tx); if (rc) { BNX2X_ERR("Failed to set real number of Tx queues: %d\n", rc); return rc; } rc = <API key>(bp->dev, rx); if (rc) { BNX2X_ERR("Failed to set real number of Rx queues: %d\n", rc); return rc; } DP(NETIF_MSG_IFUP, "Setting real num queues to (tx, rx) (%d, %d)\n", tx, rx); return rc; } static void <API key>(struct bnx2x *bp) { int i; for_each_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; u32 mtu; /* Always use a mini-jumbo MTU for the FCoE L2 ring */ if (IS_FCOE_IDX(i)) /* * Although there are no IP frames expected to arrive to * this ring we still want to add an * <API key> to prevent a buffer * overrun attack. */ mtu = <API key>; else mtu = bp->dev->mtu; fp->rx_buf_size = <API key> + <API key> + ETH_OVERHEAD + mtu + <API key>; fp->rx_buf_size = SKB_DATA_ALIGN(fp->rx_buf_size); /* Note : rx_buf_size doesn't take into account NET_SKB_PAD */ if (fp->rx_buf_size + NET_SKB_PAD <= PAGE_SIZE) fp->rx_frag_size = fp->rx_buf_size + NET_SKB_PAD; else fp->rx_frag_size = 0; } } static int bnx2x_init_rss(struct bnx2x *bp) { int i; u8 num_eth_queues = <API key>(bp); /* Prepare the initial contents for the indirection table if RSS is * enabled */ for (i = 0; i < sizeof(bp->rss_conf_obj.ind_table); i++) bp->rss_conf_obj.ind_table[i] = bp->fp->cl_id + <API key>(i, num_eth_queues); /* * For 57710 and 57711 SEARCHER configuration (rss_keys) is * per-port, so if explicit configuration is needed , do it only * for a PMF. * * For 57712 and newer on the other hand it's a per-function * configuration. */ return <API key>(bp, bp->port.pmf || !CHIP_IS_E1x(bp)); } int bnx2x_rss(struct bnx2x *bp, struct <API key> *rss_obj, bool config_hash, bool enable) { struct <API key> params = {NULL}; /* Although RSS is meaningless when there is a single HW queue we * still need it enabled in order to have HW Rx hash generated. * * if (!is_eth_multi(bp)) * bp->multi_mode = <API key>; */ params.rss_obj = rss_obj; __set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags); if (enable) { __set_bit(<API key>, &params.rss_flags); /* RSS configuration */ __set_bit(BNX2X_RSS_IPV4, &params.rss_flags); __set_bit(BNX2X_RSS_IPV4_TCP, &params.rss_flags); __set_bit(BNX2X_RSS_IPV6, &params.rss_flags); __set_bit(BNX2X_RSS_IPV6_TCP, &params.rss_flags); if (rss_obj->udp_rss_v4) __set_bit(BNX2X_RSS_IPV4_UDP, &params.rss_flags); if (rss_obj->udp_rss_v6) __set_bit(BNX2X_RSS_IPV6_UDP, &params.rss_flags); if (!CHIP_IS_E1x(bp)) { /* valid only for TUNN_MODE_VXLAN tunnel mode */ __set_bit(<API key>, &params.rss_flags); __set_bit(<API key>, &params.rss_flags); /* valid only for TUNN_MODE_GRE tunnel mode */ __set_bit(<API key>, &params.rss_flags); } } else { __set_bit(<API key>, &params.rss_flags); } /* Hash bits */ params.rss_result_mask = MULTI_MASK; memcpy(params.ind_table, rss_obj->ind_table, sizeof(params.ind_table)); if (config_hash) { /* RSS keys */ netdev_rss_key_fill(params.rss_key, T_ETH_RSS_KEY * 4); __set_bit(BNX2X_RSS_SET_SRCH, &params.rss_flags); } if (IS_PF(bp)) return bnx2x_config_rss(bp, &params); else return <API key>(bp, &params); } static int bnx2x_init_hw(struct bnx2x *bp, u32 load_code) { struct <API key> func_params = {NULL}; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_HW_INIT; func_params.params.hw_init.load_phase = load_code; return <API key>(bp, &func_params); } /* * Cleans the object that have internal lists without sending * ramrods. Should be run when interrupts are disabled. */ void <API key>(struct bnx2x *bp) { int rc; unsigned long ramrod_flags = 0, vlan_mac_flags = 0; struct <API key> rparam = {NULL}; struct bnx2x_vlan_mac_obj *mac_obj = &bp->sp_objs->mac_obj; /* Wait for completion of requested */ __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); /* Perform a dry cleanup */ __set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags); /* Clean ETH primary MAC */ __set_bit(BNX2X_ETH_MAC, &vlan_mac_flags); rc = mac_obj->delete_all(bp, &bp->sp_objs->mac_obj, &vlan_mac_flags, &ramrod_flags); if (rc != 0) BNX2X_ERR("Failed to clean ETH MACs: %d\n", rc); /* Cleanup UC list */ vlan_mac_flags = 0; __set_bit(BNX2X_UC_LIST_MAC, &vlan_mac_flags); rc = mac_obj->delete_all(bp, mac_obj, &vlan_mac_flags, &ramrod_flags); if (rc != 0) BNX2X_ERR("Failed to clean UC list MACs: %d\n", rc); rparam.mcast_obj = &bp->mcast_obj; __set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags); /* Add a DEL command... - Since we're doing a driver cleanup only, * we take a lock surrounding both the initial send and the CONTs, * as we don't want a true completion to disrupt us in the middle. */ netif_addr_lock_bh(bp->dev); rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL); if (rc < 0) BNX2X_ERR("Failed to add a new DEL command to a multi-cast object: %d\n", rc); /* ...and wait until all pending commands are cleared */ rc = bnx2x_config_mcast(bp, &rparam, <API key>); while (rc != 0) { if (rc < 0) { BNX2X_ERR("Failed to clean multi-cast object: %d\n", rc); <API key>(bp->dev); return; } rc = bnx2x_config_mcast(bp, &rparam, <API key>); } <API key>(bp->dev); } #ifndef BNX2X_STOP_ON_ERROR #define LOAD_ERROR_EXIT(bp, label) \ do { \ (bp)->state = BNX2X_STATE_ERROR; \ goto label; \ } while (0) #define <API key>(bp, label) \ do { \ bp->cnic_loaded = false; \ goto label; \ } while (0) #else /*BNX2X_STOP_ON_ERROR*/ #define LOAD_ERROR_EXIT(bp, label) \ do { \ (bp)->state = BNX2X_STATE_ERROR; \ (bp)->panic = 1; \ return -EBUSY; \ } while (0) #define <API key>(bp, label) \ do { \ bp->cnic_loaded = false; \ (bp)->panic = 1; \ return -EBUSY; \ } while (0) #endif /*BNX2X_STOP_ON_ERROR*/ static void <API key>(struct bnx2x *bp) { BNX2X_PCI_FREE(bp->fw_stats, bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); return; } static int <API key>(struct bnx2x *bp) { int num_groups, vf_headroom = 0; int is_fcoe_stats = NO_FCOE(bp) ? 0 : 1; /* number of queues for statistics is number of eth queues + FCoE */ u8 num_queue_stats = <API key>(bp) + is_fcoe_stats; /* Total number of FW statistics requests = * 1 for port stats + 1 for PF stats + potential 2 for FCoE (fcoe proper * and fcoe l2 queue) stats + num of queues (which includes another 1 * for fcoe l2 queue if applicable) */ bp->fw_stats_num = 2 + is_fcoe_stats + num_queue_stats; /* vf stats appear in the request list, but their data is allocated by * the VFs themselves. We don't include them in the bp->fw_stats_num as * it is used to determine where to place the vf stats queries in the * request struct */ if (IS_SRIOV(bp)) vf_headroom = bnx2x_vf_headroom(bp); /* Request is built from stats_query_header and an array of * <API key> each of which contains * <API key> rules. The real number or requests is * configured in the stats_query_header. */ num_groups = (((bp->fw_stats_num + vf_headroom) / <API key>) + (((bp->fw_stats_num + vf_headroom) % <API key>) ? 1 : 0)); DP(BNX2X_MSG_SP, "stats fw_stats_num %d, vf headroom %d, num_groups %d\n", bp->fw_stats_num, vf_headroom, num_groups); bp->fw_stats_req_sz = sizeof(struct stats_query_header) + num_groups * sizeof(struct <API key>); /* Data for statistics requests + stats_counter * stats_counter holds per-STORM counters that are incremented * when STORM has finished with the current request. * memory for FCoE offloaded statistics are counted anyway, * even if they will not be sent. * VF stats are not accounted for here as the data of VF stats is stored * in memory allocated by the VF, not here. */ bp->fw_stats_data_sz = sizeof(struct per_port_stats) + sizeof(struct per_pf_stats) + sizeof(struct <API key>) + sizeof(struct per_queue_stats) * num_queue_stats + sizeof(struct stats_counter); bp->fw_stats = BNX2X_PCI_ALLOC(&bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); if (!bp->fw_stats) goto alloc_mem_err; /* Set shortcuts */ bp->fw_stats_req = (struct bnx2x_fw_stats_req *)bp->fw_stats; bp-><API key> = bp->fw_stats_mapping; bp->fw_stats_data = (struct bnx2x_fw_stats_data *) ((u8 *)bp->fw_stats + bp->fw_stats_req_sz); bp-><API key> = bp->fw_stats_mapping + bp->fw_stats_req_sz; DP(BNX2X_MSG_SP, "statistics request base address set to %x %x\n", U64_HI(bp-><API key>), U64_LO(bp-><API key>)); DP(BNX2X_MSG_SP, "statistics data base address set to %x %x\n", U64_HI(bp-><API key>), U64_LO(bp-><API key>)); return 0; alloc_mem_err: <API key>(bp); BNX2X_ERR("Can't allocate FW stats memory\n"); return -ENOMEM; } /* send load request to mcp and analyze response */ static int <API key>(struct bnx2x *bp, u32 *load_code) { u32 param; /* init fw_seq */ bp->fw_seq = (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & <API key>); BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); /* Get current FW pulse sequence */ bp->fw_drv_pulse_wr_seq = (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb) & DRV_PULSE_SEQ_MASK); BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq); param = <API key>; if (IS_MF_SD(bp) && <API key>(bp)) param |= <API key>; /* load request */ (*load_code) = bnx2x_fw_command(bp, <API key>, param); /* if mcp fails to respond we must abort */ if (!(*load_code)) { BNX2X_ERR("MCP response failure, aborting\n"); return -EBUSY; } /* If mcp refused (e.g. other port is in diagnostic mode) we * must abort */ if ((*load_code) == <API key>) { BNX2X_ERR("MCP refused load request, aborting\n"); return -EBUSY; } return 0; } /* check whether another PF has already loaded FW to chip. In * virtualized environments a pf from another VM may have already * initialized the device including loading FW */ int <API key>(struct bnx2x *bp, u32 load_code, bool print_err) { /* is another pf loaded on this engine? */ if (load_code != <API key> && load_code != <API key>) { /* build my FW version dword */ u32 my_fw = (<API key>) + (<API key> << 8) + (<API key> << 16) + (<API key> << 24); /* read loaded FW from chip */ u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM); DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x\n", loaded_fw, my_fw); /* abort nic load if version mismatch */ if (my_fw != loaded_fw) { if (print_err) BNX2X_ERR("bnx2x with FW %x was already loaded which mismatches my %x FW. Aborting\n", loaded_fw, my_fw); else BNX2X_DEV_INFO("bnx2x with FW %x was already loaded which mismatches my %x FW, possibly due to MF UNDI\n", loaded_fw, my_fw); return -EBUSY; } } return 0; } /* returns the "mcp load_code" according to global load_count array */ static int <API key>(struct bnx2x *bp, int port) { int path = BP_PATH(bp); DP(NETIF_MSG_IFUP, "NO MCP - load counts[%d] %d, %d, %d\n", path, bnx2x_load_count[path][0], bnx2x_load_count[path][1], bnx2x_load_count[path][2]); bnx2x_load_count[path][0]++; bnx2x_load_count[path][1 + port]++; DP(NETIF_MSG_IFUP, "NO MCP - new load counts[%d] %d, %d, %d\n", path, bnx2x_load_count[path][0], bnx2x_load_count[path][1], bnx2x_load_count[path][2]); if (bnx2x_load_count[path][0] == 1) return <API key>; else if (bnx2x_load_count[path][1 + port] == 1) return <API key>; else return <API key>; } /* mark PMF if applicable */ static void bnx2x_nic_load_pmf(struct bnx2x *bp, u32 load_code) { if ((load_code == <API key>) || (load_code == <API key>) || (load_code == <API key>)) { bp->port.pmf = 1; /* We need the barrier to ensure the ordering between the * writing to bp->port.pmf here and reading it from the * bnx2x_periodic_task(). */ smp_mb(); } else { bp->port.pmf = 0; } DP(NETIF_MSG_LINK, "pmf %d\n", bp->port.pmf); } static void <API key>(struct bnx2x *bp, int load_code) { if (((load_code == <API key>) || (load_code == <API key>)) && (bp->common.shmem2_base)) { if (SHMEM2_HAS(bp, dcc_support)) SHMEM2_WR(bp, dcc_support, (<API key> | <API key>)); if (SHMEM2_HAS(bp, afex_driver_support)) SHMEM2_WR(bp, afex_driver_support, <API key>); } /* Set AFEX default VLAN tag to an invalid value */ bp->afex_def_vlan_tag = -1; } /** * bnx2x_bz_fp - zero content of the fastpath structure. * * @bp: driver handle * @index: fastpath index to be zeroed * * Makes sure the contents of the bp->fp[index].napi is kept * intact. */ static void bnx2x_bz_fp(struct bnx2x *bp, int index) { struct bnx2x_fastpath *fp = &bp->fp[index]; int cos; struct napi_struct orig_napi = fp->napi; struct bnx2x_agg_info *orig_tpa_info = fp->tpa_info; /* bzero bnx2x_fastpath contents */ if (fp->tpa_info) memset(fp->tpa_info, 0, <API key> * sizeof(struct bnx2x_agg_info)); memset(fp, 0, sizeof(*fp)); /* Restore the NAPI object as it has been already initialized */ fp->napi = orig_napi; fp->tpa_info = orig_tpa_info; fp->bp = bp; fp->index = index; if (IS_ETH_FP(fp)) fp->max_cos = bp->max_cos; else /* Special queues support only one CoS */ fp->max_cos = 1; /* Init txdata pointers */ if (IS_FCOE_FP(fp)) fp->txdata_ptr[0] = &bp->bnx2x_txq[FCOE_TXQ_IDX(bp)]; if (IS_ETH_FP(fp)) <API key>(fp, cos) fp->txdata_ptr[cos] = &bp->bnx2x_txq[cos * <API key>(bp) + index]; /* set the tpa flag for each queue. The tpa flag determines the queue * minimal size so it must be set prior to queue memory allocation */ if (bp->dev->features & NETIF_F_LRO) fp->mode = TPA_MODE_LRO; else if (bp->dev->features & NETIF_F_GRO && <API key>(bp->dev->mtu)) fp->mode = TPA_MODE_GRO; else fp->mode = TPA_MODE_DISABLED; /* We don't want TPA if it's disabled in bp * or if this is an FCoE L2 ring. */ if (bp->disable_tpa || IS_FCOE_FP(fp)) fp->mode = TPA_MODE_DISABLED; } void <API key>(struct bnx2x *bp, u32 state) { u32 cur; if (!IS_MF_BD(bp) || !SHMEM2_HAS(bp, os_driver_state) || IS_VF(bp)) return; cur = SHMEM2_RD(bp, os_driver_state[BP_FW_MB_IDX(bp)]); DP(NETIF_MSG_IFUP, "Driver state %08x-->%08x\n", cur, state); SHMEM2_WR(bp, os_driver_state[BP_FW_MB_IDX(bp)], state); } int bnx2x_load_cnic(struct bnx2x *bp) { int i, rc, port = BP_PORT(bp); DP(NETIF_MSG_IFUP, "Starting CNIC-related load\n"); mutex_init(&bp->cnic_mutex); if (IS_PF(bp)) { rc = <API key>(bp); if (rc) { BNX2X_ERR("Unable to allocate bp memory for cnic\n"); <API key>(bp, load_error_cnic0); } } rc = <API key>(bp); if (rc) { BNX2X_ERR("Unable to allocate memory for cnic fps\n"); <API key>(bp, load_error_cnic0); } /* Update the number of queues with the cnic queues */ rc = <API key>(bp, 1); if (rc) { BNX2X_ERR("Unable to set real_num_queues including cnic\n"); <API key>(bp, load_error_cnic0); } /* Add all CNIC NAPI objects */ <API key>(bp); DP(NETIF_MSG_IFUP, "cnic napi added\n"); <API key>(bp); rc = <API key>(bp); if (rc) <API key>(bp, load_error_cnic1); bnx2x_nic_init_cnic(bp); if (IS_PF(bp)) { /* Enable Timer scan */ REG_WR(bp, <API key> + port*4, 1); /* setup cnic queues */ for_each_cnic_queue(bp, i) { rc = bnx2x_setup_queue(bp, &bp->fp[i], 0); if (rc) { BNX2X_ERR("Queue setup failed\n"); LOAD_ERROR_EXIT(bp, load_error_cnic2); } } } /* Initialize Rx filter. */ <API key>(bp); /* re-read iscsi info */ <API key>(bp); <API key>(bp); <API key>(bp); bp->cnic_loaded = true; if (bp->state == BNX2X_STATE_OPEN) bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); DP(NETIF_MSG_IFUP, "Ending successfully CNIC-related load\n"); return 0; #ifndef BNX2X_STOP_ON_ERROR load_error_cnic2: /* Disable Timer scan */ REG_WR(bp, <API key> + port*4, 0); load_error_cnic1: <API key>(bp); /* Update the number of queues without the cnic queues */ if (<API key>(bp, 0)) BNX2X_ERR("Unable to set real_num_queues not including cnic\n"); load_error_cnic0: BNX2X_ERR("CNIC-related load failed\n"); <API key>(bp); bnx2x_free_mem_cnic(bp); return rc; #endif /* ! BNX2X_STOP_ON_ERROR */ } /* must be called with rtnl_lock */ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) { int port = BP_PORT(bp); int i, rc = 0, load_code = 0; DP(NETIF_MSG_IFUP, "Starting NIC load\n"); DP(NETIF_MSG_IFUP, "CNIC is %s\n", CNIC_ENABLED(bp) ? "enabled" : "disabled"); #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) { BNX2X_ERR("Can't load NIC when there is panic\n"); return -EPERM; } #endif bp->state = <API key>; /* zero the structure w/o any lock, before SP handler is initialized */ memset(&bp->last_reported_link, 0, sizeof(bp->last_reported_link)); __set_bit(<API key>, &bp->last_reported_link.link_report_flags); if (IS_PF(bp)) /* must be called before memory allocation and HW init */ bnx2x_ilt_set_info(bp); /* * Zero fastpath structures preserving invariants like napi, which are * allocated only once, fp index, max_cos, bp pointer. * Also set fp->mode and txdata_ptr. */ DP(NETIF_MSG_IFUP, "num queues: %d", bp->num_queues); for_each_queue(bp, i) bnx2x_bz_fp(bp, i); memset(bp->bnx2x_txq, 0, (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS + bp->num_cnic_queues) * sizeof(struct bnx2x_fp_txdata)); bp->fcoe_init = false; /* Set the receive queues buffer size */ <API key>(bp); if (IS_PF(bp)) { rc = bnx2x_alloc_mem(bp); if (rc) { BNX2X_ERR("Unable to allocate bp memory\n"); return rc; } } /* need to be done after alloc mem, since it's self adjusting to amount * of memory available for RSS queues */ rc = bnx2x_alloc_fp_mem(bp); if (rc) { BNX2X_ERR("Unable to allocate memory for fps\n"); LOAD_ERROR_EXIT(bp, load_error0); } /* Allocated memory for FW statistics */ if (<API key>(bp)) LOAD_ERROR_EXIT(bp, load_error0); /* request pf to initialize status blocks */ if (IS_VF(bp)) { rc = bnx2x_vfpf_init(bp); if (rc) LOAD_ERROR_EXIT(bp, load_error0); } /* As long as bnx2x_alloc_mem() may possibly update * bp->num_queues, <API key>() should always * come after it. At this stage cnic queues are not counted. */ rc = <API key>(bp, 0); if (rc) { BNX2X_ERR("Unable to set real_num_queues\n"); LOAD_ERROR_EXIT(bp, load_error0); } /* configure multi cos mappings in kernel. * this configuration may be overridden by a multi class queue * discipline or by a dcbx negotiation result. */ bnx2x_setup_tc(bp->dev, bp->max_cos); /* Add all NAPI objects */ bnx2x_add_all_napi(bp); DP(NETIF_MSG_IFUP, "napi added\n"); bnx2x_napi_enable(bp); if (IS_PF(bp)) { /* set pf load just before approaching the MCP */ bnx2x_set_pf_load(bp); /* if mcp exists send load request and analyze response */ if (!BP_NOMCP(bp)) { /* attempt to load pf */ rc = <API key>(bp, &load_code); if (rc) LOAD_ERROR_EXIT(bp, load_error1); /* what did mcp say? */ rc = <API key>(bp, load_code, true); if (rc) { bnx2x_fw_command(bp, <API key>, 0); LOAD_ERROR_EXIT(bp, load_error2); } } else { load_code = <API key>(bp, port); } /* mark pmf if applicable */ bnx2x_nic_load_pmf(bp, load_code); /* Init Function state controlling object */ <API key>(bp); /* Initialize HW */ rc = bnx2x_init_hw(bp, load_code); if (rc) { BNX2X_ERR("HW init failed, aborting\n"); bnx2x_fw_command(bp, <API key>, 0); LOAD_ERROR_EXIT(bp, load_error2); } } <API key>(bp); /* Connect to IRQs */ rc = bnx2x_setup_irqs(bp); if (rc) { BNX2X_ERR("setup irqs failed\n"); if (IS_PF(bp)) bnx2x_fw_command(bp, <API key>, 0); LOAD_ERROR_EXIT(bp, load_error2); } /* Init per-function objects */ if (IS_PF(bp)) { /* Setup NIC internals and enable interrupts */ <API key>(bp, load_code); bnx2x_init_bp_objs(bp); bnx2x_iov_nic_init(bp); /* Set AFEX default VLAN tag to an invalid value */ bp->afex_def_vlan_tag = -1; <API key>(bp, load_code); bp->state = <API key>; rc = bnx2x_func_start(bp); if (rc) { BNX2X_ERR("Function start failed!\n"); bnx2x_fw_command(bp, <API key>, 0); LOAD_ERROR_EXIT(bp, load_error3); } /* Send LOAD_DONE command to MCP */ if (!BP_NOMCP(bp)) { load_code = bnx2x_fw_command(bp, <API key>, 0); if (!load_code) { BNX2X_ERR("MCP response failure, aborting\n"); rc = -EBUSY; LOAD_ERROR_EXIT(bp, load_error3); } } /* initialize FW coalescing state machines in RAM */ <API key>(bp); } /* setup the leading queue */ rc = bnx2x_setup_leading(bp); if (rc) { BNX2X_ERR("Setup leading failed!\n"); LOAD_ERROR_EXIT(bp, load_error3); } /* set up the rest of the queues */ <API key>(bp, i) { if (IS_PF(bp)) rc = bnx2x_setup_queue(bp, &bp->fp[i], false); else rc = bnx2x_vfpf_setup_q(bp, &bp->fp[i], false); if (rc) { BNX2X_ERR("Queue %d setup failed\n", i); LOAD_ERROR_EXIT(bp, load_error3); } } /* setup rss */ rc = bnx2x_init_rss(bp); if (rc) { BNX2X_ERR("PF RSS init failed\n"); LOAD_ERROR_EXIT(bp, load_error3); } /* Now when Clients are configured we are ready to work */ bp->state = BNX2X_STATE_OPEN; /* Configure a ucast MAC */ if (IS_PF(bp)) rc = bnx2x_set_eth_mac(bp, true); else rc = <API key>(bp, bp->dev->dev_addr, bp->fp->index, true); if (rc) { BNX2X_ERR("Setting Ethernet MAC failed\n"); LOAD_ERROR_EXIT(bp, load_error3); } if (IS_PF(bp) && bp->pending_max) { <API key>(bp, bp->pending_max); bp->pending_max = 0; } if (bp->port.pmf) { rc = <API key>(bp, load_mode); if (rc) LOAD_ERROR_EXIT(bp, load_error3); } bp->link_params.<API key> &= ~<API key>; /* Start fast path */ /* Re-configure vlan filters */ rc = <API key>(bp); if (rc) LOAD_ERROR_EXIT(bp, load_error3); /* Initialize Rx filter. */ <API key>(bp); if (bp->flags & PTP_SUPPORTED) { bnx2x_init_ptp(bp); <API key>(bp); } /* Start Tx */ switch (load_mode) { case LOAD_NORMAL: /* Tx queue should be only re-enabled */ <API key>(bp->dev); break; case LOAD_OPEN: <API key>(bp->dev); <API key>(); break; case LOAD_DIAG: case LOAD_LOOPBACK_EXT: bp->state = BNX2X_STATE_DIAG; break; default: break; } if (bp->port.pmf) <API key>(bp, 1 << DRV_FLAGS_PORT_MASK, 0); else <API key>(bp); /* start the timer */ mod_timer(&bp->timer, jiffies + bp->current_interval); if (CNIC_ENABLED(bp)) bnx2x_load_cnic(bp); if (IS_PF(bp)) <API key>(bp, <API key>, 0); if (IS_PF(bp) && SHMEM2_HAS(bp, <API key>)) { /* mark driver is loaded in shmem2 */ u32 val; val = SHMEM2_RD(bp, <API key>[BP_FW_MB_IDX(bp)]); val &= ~DRV_FLAGS_MTU_MASK; val |= (bp->dev->mtu << DRV_FLAGS_MTU_SHIFT); SHMEM2_WR(bp, <API key>[BP_FW_MB_IDX(bp)], val | <API key> | <API key>); } /* Wait for all pending SP commands to complete */ if (IS_PF(bp) && !bnx2x_wait_sp_comp(bp, ~0x0UL)) { BNX2X_ERR("Timeout waiting for SP elements to complete\n"); bnx2x_nic_unload(bp, UNLOAD_CLOSE, false); return -EBUSY; } /* Update driver data for On-Chip MFW dump. */ if (IS_PF(bp)) <API key>(bp); /* If PMF - send ADMIN DCBX msg to MFW to initiate DCBX FSM */ if (bp->port.pmf && (bp->state != BNX2X_STATE_DIAG)) bnx2x_dcbx_init(bp, false); if (!<API key>(bp)) <API key>(bp, <API key>); DP(NETIF_MSG_IFUP, "Ending successfully NIC load\n"); return 0; #ifndef BNX2X_STOP_ON_ERROR load_error3: if (IS_PF(bp)) { <API key>(bp, 1); /* Clean queueable objects */ <API key>(bp); } /* Free SKBs, SGEs, TPA pool and driver internals */ bnx2x_free_skbs(bp); for_each_rx_queue(bp, i) <API key>(bp, bp->fp + i, NUM_RX_SGE); /* Release IRQs */ bnx2x_free_irq(bp); load_error2: if (IS_PF(bp) && !BP_NOMCP(bp)) { bnx2x_fw_command(bp, <API key>, 0); bnx2x_fw_command(bp, <API key>, 0); } bp->port.pmf = 0; load_error1: bnx2x_napi_disable(bp); bnx2x_del_all_napi(bp); /* clear pf_load status, as it was already set */ if (IS_PF(bp)) bnx2x_clear_pf_load(bp); load_error0: <API key>(bp); bnx2x_free_fp_mem(bp); bnx2x_free_mem(bp); return rc; #endif /* ! BNX2X_STOP_ON_ERROR */ } int <API key>(struct bnx2x *bp) { u8 rc = 0, cos, i; /* Wait until tx fastpath tasks complete */ for_each_tx_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; <API key>(fp, cos) rc = <API key>(bp, fp->txdata_ptr[cos]); if (rc) return rc; } return 0; } /* must be called with rtnl_lock */ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link) { int i; bool global = false; DP(NETIF_MSG_IFUP, "Starting NIC unload\n"); if (!<API key>(bp)) <API key>(bp, <API key>); /* mark driver is unloaded in shmem2 */ if (IS_PF(bp) && SHMEM2_HAS(bp, <API key>)) { u32 val; val = SHMEM2_RD(bp, <API key>[BP_FW_MB_IDX(bp)]); SHMEM2_WR(bp, <API key>[BP_FW_MB_IDX(bp)], val & ~<API key>); } if (IS_PF(bp) && bp->recovery_state != BNX2X_RECOVERY_DONE && (bp->state == BNX2X_STATE_CLOSED || bp->state == BNX2X_STATE_ERROR)) { /* We can get here if the driver has been unloaded * during parity error recovery and is either waiting for a * leader to complete or for other functions to unload and * then ifdown has been issued. In this case we want to * unload and let other functions to complete a recovery * process. */ bp->recovery_state = BNX2X_RECOVERY_DONE; bp->is_leader = 0; <API key>(bp); smp_mb(); DP(NETIF_MSG_IFDOWN, "Releasing a leadership...\n"); BNX2X_ERR("Can't unload in closed or error state\n"); return -EINVAL; } /* Nothing to do during unload if previous bnx2x_nic_load() * have not completed successfully - all resources are released. * * we can get here only after unsuccessful ndo_* callback, during which * dev->IFF_UP flag is still on. */ if (bp->state == BNX2X_STATE_CLOSED || bp->state == BNX2X_STATE_ERROR) return 0; /* It's important to set the bp->state to the value different from * BNX2X_STATE_OPEN and only then stop the Tx. Otherwise bnx2x_tx_int() * may restart the Tx from the NAPI context (see bnx2x_tx_int()). */ bp->state = <API key>; smp_mb(); /* indicate to VFs that the PF is going down */ <API key>(bp); if (CNIC_LOADED(bp)) bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD); /* Stop Tx */ bnx2x_tx_disable(bp); netdev_reset_tc(bp->dev); bp->rx_mode = BNX2X_RX_MODE_NONE; del_timer_sync(&bp->timer); if (IS_PF(bp)) { /* Set ALWAYS_ALIVE bit in shmem */ bp->fw_drv_pulse_wr_seq |= <API key>; bnx2x_drv_pulse(bp); bnx2x_stats_handle(bp, STATS_EVENT_STOP); <API key>(bp); } /* wait till consumers catch up with producers in all queues. * If we're recovering, FW can't write to host so no reason * to wait for the queues to complete all Tx. */ if (unload_mode != UNLOAD_RECOVERY) <API key>(bp); /* if VF indicate to PF this function is going down (PF will delete sp * elements and clear initializations */ if (IS_VF(bp)) bnx2x_vfpf_close_vf(bp); else if (unload_mode != UNLOAD_RECOVERY) /* if this is a normal/close unload need to clean up chip*/ bnx2x_chip_cleanup(bp, unload_mode, keep_link); else { /* Send the UNLOAD_REQUEST to the MCP */ <API key>(bp, unload_mode); /* Prevent transactions to host from the functions on the * engine that doesn't reset global blocks in case of global * attention once global blocks are reset and gates are opened * (the engine which leader will perform the recovery * last). */ if (!CHIP_IS_E1x(bp)) bnx2x_pf_disable(bp); /* Disable HW interrupts, NAPI */ bnx2x_netif_stop(bp, 1); /* Delete all NAPI objects */ bnx2x_del_all_napi(bp); if (CNIC_LOADED(bp)) <API key>(bp); /* Release IRQs */ bnx2x_free_irq(bp); /* Report UNLOAD_DONE to MCP */ <API key>(bp, false); } /* * At this stage no more interrupts will arrive so we may safely clean * the queueable objects here in case they failed to get cleaned so far. */ if (IS_PF(bp)) <API key>(bp); /* There should be no more pending SP commands at this stage */ bp->sp_state = 0; bp->port.pmf = 0; /* clear pending work in rtnl task */ bp->sp_rtnl_state = 0; smp_mb(); /* Free SKBs, SGEs, TPA pool and driver internals */ bnx2x_free_skbs(bp); if (CNIC_LOADED(bp)) <API key>(bp); for_each_rx_queue(bp, i) <API key>(bp, bp->fp + i, NUM_RX_SGE); bnx2x_free_fp_mem(bp); if (CNIC_LOADED(bp)) <API key>(bp); if (IS_PF(bp)) { if (CNIC_LOADED(bp)) bnx2x_free_mem_cnic(bp); } bnx2x_free_mem(bp); bp->state = BNX2X_STATE_CLOSED; bp->cnic_loaded = false; /* Clear driver version indication in shmem */ if (IS_PF(bp)) <API key>(bp); /* Check if there are pending parity attentions. If there are - set * <API key>. */ if (IS_PF(bp) && <API key>(bp, &global, false)) { <API key>(bp); /* Set RESET_IS_GLOBAL if needed */ if (global) <API key>(bp); } /* The last driver must disable a "close the gate" if there is no * parity attention or "process kill" pending. */ if (IS_PF(bp) && !bnx2x_clear_pf_load(bp) && bnx2x_reset_is_done(bp, BP_PATH(bp))) <API key>(bp); DP(NETIF_MSG_IFUP, "Ending NIC unload\n"); return 0; } int <API key>(struct bnx2x *bp, pci_power_t state) { u16 pmcsr; /* If there is no power capability, silently succeed */ if (!bp->pdev->pm_cap) { BNX2X_DEV_INFO("No power capability. Breaking.\n"); return 0; } <API key>(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL, &pmcsr); switch (state) { case PCI_D0: <API key>(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL, ((pmcsr & ~<API key>) | <API key>)); if (pmcsr & <API key>) /* delay required during transition out of D3hot */ msleep(20); break; case PCI_D3hot: /* If there are other clients above don't shut down the power */ if (atomic_read(&bp->pdev->enable_cnt) != 1) return 0; /* Don't shut down the power for emulation and FPGA */ if (CHIP_REV_IS_SLOW(bp)) return 0; pmcsr &= ~<API key>; pmcsr |= 3; if (bp->wol) pmcsr |= <API key>; <API key>(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL, pmcsr); /* No more memory access after this point until * device is brought back to D0. */ break; default: dev_err(&bp->pdev->dev, "Can't support state = %d\n", state); return -EINVAL; } return 0; } /* * net_device service functions */ static int bnx2x_poll(struct napi_struct *napi, int budget) { struct bnx2x_fastpath *fp = container_of(napi, struct bnx2x_fastpath, napi); struct bnx2x *bp = fp->bp; int rx_work_done; u8 cos; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) { napi_complete(napi); return 0; } #endif <API key>(fp, cos) if (<API key>(fp->txdata_ptr[cos])) bnx2x_tx_int(bp, fp->txdata_ptr[cos]); rx_work_done = (bnx2x_has_rx_work(fp)) ? bnx2x_rx_int(fp, budget) : 0; if (rx_work_done < budget) { /* No need to update SB for FCoE L2 ring as long as * it's connected to the default SB and the SB * has been updated when NAPI was scheduled. */ if (IS_FCOE_FP(fp)) { napi_complete_done(napi, rx_work_done); } else { <API key>(fp); /* bnx2x_has_rx_work() reads the status block, * thus we need to ensure that status block indices * have been actually read (<API key>) * prior to this check (bnx2x_has_rx_work) so that * we won't write the "newer" value of the status block * to IGU (if there was a DMA right after * bnx2x_has_rx_work and if there is no rmb, the memory * reading (<API key>) may be postponed * to right before bnx2x_ack_sb). In this case there * will never be another interrupt until there is * another update of the status block, while there * is still unhandled work. */ rmb(); if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) { if (napi_complete_done(napi, rx_work_done)) { /* Re-enable interrupts */ DP(NETIF_MSG_RX_STATUS, "Update index to %d\n", fp->fp_hc_idx); bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, le16_to_cpu(fp->fp_hc_idx), IGU_INT_ENABLE, 1); } } else { rx_work_done = budget; } } } return rx_work_done; } /* we split the first BD into headers and data BDs * to ease the pain of our fellow microcode engineers * we use one mapping for both BDs */ static u16 bnx2x_tx_split(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, struct sw_tx_bd *tx_buf, struct eth_tx_start_bd **tx_bd, u16 hlen, u16 bd_prod) { struct eth_tx_start_bd *h_tx_bd = *tx_bd; struct eth_tx_bd *d_tx_bd; dma_addr_t mapping; int old_len = le16_to_cpu(h_tx_bd->nbytes); /* first fix first BD */ h_tx_bd->nbytes = cpu_to_le16(hlen); DP(NETIF_MSG_TX_QUEUED, "TSO split header size is %d (%x:%x)\n", h_tx_bd->nbytes, h_tx_bd->addr_hi, h_tx_bd->addr_lo); /* now get a new data BD * (after the pbd) and fill it */ bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); d_tx_bd = &txdata->tx_desc_ring[bd_prod].reg_bd; mapping = HILO_U64(le32_to_cpu(h_tx_bd->addr_hi), le32_to_cpu(h_tx_bd->addr_lo)) + hlen; d_tx_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); d_tx_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); d_tx_bd->nbytes = cpu_to_le16(old_len - hlen); /* this marks the BD as one that has no individual mapping */ tx_buf->flags |= BNX2X_TSO_SPLIT_BD; DP(NETIF_MSG_TX_QUEUED, "TSO split data size is %d (%x:%x)\n", d_tx_bd->nbytes, d_tx_bd->addr_hi, d_tx_bd->addr_lo); /* update tx_bd */ *tx_bd = (struct eth_tx_start_bd *)d_tx_bd; return bd_prod; } #define bswab32(b32) ((__force __le32) swab32((__force __u32) (b32))) #define bswab16(b16) ((__force __le16) swab16((__force __u16) (b16))) static __le16 bnx2x_csum_fix(unsigned char *t_header, u16 csum, s8 fix) { __sum16 tsum = (__force __sum16) csum; if (fix > 0) tsum = ~csum_fold(csum_sub((__force __wsum) csum, csum_partial(t_header - fix, fix, 0))); else if (fix < 0) tsum = ~csum_fold(csum_add((__force __wsum) csum, csum_partial(t_header, -fix, 0))); return bswab16(tsum); } static u32 bnx2x_xmit_type(struct bnx2x *bp, struct sk_buff *skb) { u32 rc; __u8 prot = 0; __be16 protocol; if (skb->ip_summed != CHECKSUM_PARTIAL) return XMIT_PLAIN; protocol = vlan_get_protocol(skb); if (protocol == htons(ETH_P_IPV6)) { rc = XMIT_CSUM_V6; prot = ipv6_hdr(skb)->nexthdr; } else { rc = XMIT_CSUM_V4; prot = ip_hdr(skb)->protocol; } if (!CHIP_IS_E1x(bp) && skb->encapsulation) { if (inner_ip_hdr(skb)->version == 6) { rc |= XMIT_CSUM_ENC_V6; if (inner_ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) rc |= XMIT_CSUM_TCP; } else { rc |= XMIT_CSUM_ENC_V4; if (inner_ip_hdr(skb)->protocol == IPPROTO_TCP) rc |= XMIT_CSUM_TCP; } } if (prot == IPPROTO_TCP) rc |= XMIT_CSUM_TCP; if (skb_is_gso(skb)) { if (skb_is_gso_v6(skb)) { rc |= (XMIT_GSO_V6 | XMIT_CSUM_TCP); if (rc & XMIT_CSUM_ENC) rc |= XMIT_GSO_ENC_V6; } else { rc |= (XMIT_GSO_V4 | XMIT_CSUM_TCP); if (rc & XMIT_CSUM_ENC) rc |= XMIT_GSO_ENC_V4; } } return rc; } /* VXLAN: 4 = 1 (for linear data BD) + 3 (2 for PBD and last BD) */ #define <API key> 4 /* Regular: 3 = 1 (for linear data BD) + 2 (for PBD and last BD) */ #define <API key> 3 #if (MAX_SKB_FRAGS >= MAX_FETCH_BD - BDS_PER_TX_PKT) /* check if packet requires linearization (packet is too fragmented) no need to check fragmentation if page size > 8K (there will be no violation to FW restrictions) */ static int bnx2x_pkt_req_lin(struct bnx2x *bp, struct sk_buff *skb, u32 xmit_type) { int first_bd_sz = 0, num_tso_win_sub = <API key>; int to_copy = 0, hlen = 0; if (xmit_type & XMIT_GSO_ENC) num_tso_win_sub = <API key>; if (skb_shinfo(skb)->nr_frags >= (MAX_FETCH_BD - num_tso_win_sub)) { if (xmit_type & XMIT_GSO) { unsigned short lso_mss = skb_shinfo(skb)->gso_size; int wnd_size = MAX_FETCH_BD - num_tso_win_sub; /* Number of windows to check */ int num_wnds = skb_shinfo(skb)->nr_frags - wnd_size; int wnd_idx = 0; int frag_idx = 0; u32 wnd_sum = 0; /* Headers length */ if (xmit_type & XMIT_GSO_ENC) hlen = (int)(<API key>(skb) - skb->data) + inner_tcp_hdrlen(skb); else hlen = (int)(<API key>(skb) - skb->data) + tcp_hdrlen(skb); /* Amount of data (w/o headers) on linear part of SKB*/ first_bd_sz = skb_headlen(skb) - hlen; wnd_sum = first_bd_sz; /* Calculate the first sum - it's special */ for (frag_idx = 0; frag_idx < wnd_size - 1; frag_idx++) wnd_sum += skb_frag_size(&skb_shinfo(skb)->frags[frag_idx]); /* If there was data on linear skb data - check it */ if (first_bd_sz > 0) { if (unlikely(wnd_sum < lso_mss)) { to_copy = 1; goto exit_lbl; } wnd_sum -= first_bd_sz; } /* Others are easier: run through the frag list and check all windows */ for (wnd_idx = 0; wnd_idx <= num_wnds; wnd_idx++) { wnd_sum += skb_frag_size(&skb_shinfo(skb)->frags[wnd_idx + wnd_size - 1]); if (unlikely(wnd_sum < lso_mss)) { to_copy = 1; break; } wnd_sum -= skb_frag_size(&skb_shinfo(skb)->frags[wnd_idx]); } } else { /* in non-LSO too fragmented packet should always be linearized */ to_copy = 1; } } exit_lbl: if (unlikely(to_copy)) DP(NETIF_MSG_TX_QUEUED, "Linearization IS REQUIRED for %s packet. num_frags %d hlen %d first_bd_sz %d\n", (xmit_type & XMIT_GSO) ? "LSO" : "non-LSO", skb_shinfo(skb)->nr_frags, hlen, first_bd_sz); return to_copy; } #endif /** * bnx2x_set_pbd_gso - update PBD in GSO case. * * @skb: packet skb * @pbd: parse BD * @xmit_type: xmit flags */ static void bnx2x_set_pbd_gso(struct sk_buff *skb, struct eth_tx_parse_bd_e1x *pbd, u32 xmit_type) { pbd->lso_mss = cpu_to_le16(skb_shinfo(skb)->gso_size); pbd->tcp_send_seq = bswab32(tcp_hdr(skb)->seq); pbd->tcp_flags = pbd_tcp_flags(tcp_hdr(skb)); if (xmit_type & XMIT_GSO_V4) { pbd->ip_id = bswab16(ip_hdr(skb)->id); pbd->tcp_pseudo_csum = bswab16(~csum_tcpudp_magic(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr, 0, IPPROTO_TCP, 0)); } else { pbd->tcp_pseudo_csum = bswab16(~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0)); } pbd->global_data |= cpu_to_le16(<API key>); } /** * <API key> - update PBD with checksum and return header length * * @bp: driver handle * @skb: packet skb * @parsing_data: data to be updated * @xmit_type: xmit flags * * 57712/578xx related, when skb has encapsulation */ static u8 <API key>(struct bnx2x *bp, struct sk_buff *skb, u32 *parsing_data, u32 xmit_type) { *parsing_data |= ((((u8 *)<API key>(skb) - skb->data) >> 1) << <API key>) & <API key>; if (xmit_type & XMIT_CSUM_TCP) { *parsing_data |= ((inner_tcp_hdrlen(skb) / 4) << <API key>) & <API key>; return <API key>(skb) + inner_tcp_hdrlen(skb) - skb->data; } /* We support checksum offload for TCP and UDP only. * No need to pass the UDP header length - it's a constant. */ return <API key>(skb) + sizeof(struct udphdr) - skb->data; } /** * <API key> - update PBD with checksum and return header length * * @bp: driver handle * @skb: packet skb * @parsing_data: data to be updated * @xmit_type: xmit flags * * 57712/578xx related */ static u8 <API key>(struct bnx2x *bp, struct sk_buff *skb, u32 *parsing_data, u32 xmit_type) { *parsing_data |= ((((u8 *)<API key>(skb) - skb->data) >> 1) << <API key>) & <API key>; if (xmit_type & XMIT_CSUM_TCP) { *parsing_data |= ((tcp_hdrlen(skb) / 4) << <API key>) & <API key>; return <API key>(skb) + tcp_hdrlen(skb) - skb->data; } /* We support checksum offload for TCP and UDP only. * No need to pass the UDP header length - it's a constant. */ return <API key>(skb) + sizeof(struct udphdr) - skb->data; } /* set FW indication according to inner or outer protocols if tunneled */ static void bnx2x_set_sbd_csum(struct bnx2x *bp, struct sk_buff *skb, struct eth_tx_start_bd *tx_start_bd, u32 xmit_type) { tx_start_bd->bd_flags.as_bitfield |= <API key>; if (xmit_type & (XMIT_CSUM_ENC_V6 | XMIT_CSUM_V6)) tx_start_bd->bd_flags.as_bitfield |= <API key>; if (!(xmit_type & XMIT_CSUM_TCP)) tx_start_bd->bd_flags.as_bitfield |= <API key>; } /** * bnx2x_set_pbd_csum - update PBD with checksum and return header length * * @bp: driver handle * @skb: packet skb * @pbd: parse BD to be updated * @xmit_type: xmit flags */ static u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, struct eth_tx_parse_bd_e1x *pbd, u32 xmit_type) { u8 hlen = (skb_network_header(skb) - skb->data) >> 1; /* for now NS flag is not used in Linux */ pbd->global_data = cpu_to_le16(hlen | ((skb->protocol == cpu_to_be16(ETH_P_8021Q)) << <API key>)); pbd->ip_hlen_w = (<API key>(skb) - skb_network_header(skb)) >> 1; hlen += pbd->ip_hlen_w; /* We support checksum offload for TCP and UDP only */ if (xmit_type & XMIT_CSUM_TCP) hlen += tcp_hdrlen(skb) / 2; else hlen += sizeof(struct udphdr) / 2; pbd->total_hlen_w = cpu_to_le16(hlen); hlen = hlen*2; if (xmit_type & XMIT_CSUM_TCP) { pbd->tcp_pseudo_csum = bswab16(tcp_hdr(skb)->check); } else { s8 fix = SKB_CS_OFF(skb); /* signed! */ DP(NETIF_MSG_TX_QUEUED, "hlen %d fix %d csum before fix %x\n", le16_to_cpu(pbd->total_hlen_w), fix, SKB_CS(skb)); /* HW bug: fixup the CSUM */ pbd->tcp_pseudo_csum = bnx2x_csum_fix(<API key>(skb), SKB_CS(skb), fix); DP(NETIF_MSG_TX_QUEUED, "csum after fix %x\n", pbd->tcp_pseudo_csum); } return hlen; } static void <API key>(struct sk_buff *skb, struct eth_tx_parse_bd_e2 *pbd_e2, struct eth_tx_parse_2nd_bd *pbd2, u16 *global_data, u32 xmit_type) { u16 hlen_w = 0; u8 outerip_off, outerip_len = 0; /* from outer IP to transport */ hlen_w = (<API key>(skb) - skb_network_header(skb)) >> 1; /* transport len */ hlen_w += inner_tcp_hdrlen(skb) >> 1; pbd2-><API key> = hlen_w; /* outer IP header info */ if (xmit_type & XMIT_CSUM_V4) { struct iphdr *iph = ip_hdr(skb); u32 csum = (__force u32)(~iph->check) - (__force u32)iph->tot_len - (__force u32)iph->frag_off; outerip_len = iph->ihl << 1; pbd2-><API key> = bswab16(csum_fold((__force __wsum)csum)); } else { pbd2-><API key> = hlen_w - ((sizeof(struct ipv6hdr)) >> 1); pbd_e2->data.tunnel_data.flags |= <API key>; } pbd2->tcp_send_seq = bswab32(inner_tcp_hdr(skb)->seq); pbd2->tcp_flags = pbd_tcp_flags(inner_tcp_hdr(skb)); /* inner IP header info */ if (xmit_type & XMIT_CSUM_ENC_V4) { pbd2->hw_ip_id = bswab16(inner_ip_hdr(skb)->id); pbd_e2->data.tunnel_data.pseudo_csum = bswab16(~csum_tcpudp_magic( inner_ip_hdr(skb)->saddr, inner_ip_hdr(skb)->daddr, 0, IPPROTO_TCP, 0)); } else { pbd_e2->data.tunnel_data.pseudo_csum = bswab16(~csum_ipv6_magic( &inner_ipv6_hdr(skb)->saddr, &inner_ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0)); } outerip_off = (skb_network_header(skb) - skb->data) >> 1; *global_data |= outerip_off | (outerip_len << <API key>) | ((skb->protocol == cpu_to_be16(ETH_P_8021Q)) << <API key>); if (ip_hdr(skb)->protocol == IPPROTO_UDP) { SET_FLAG(*global_data, <API key>, 1); pbd2-><API key> = <API key>(skb) >> 1; } } static inline void <API key>(struct sk_buff *skb, u32 *parsing_data, u32 xmit_type) { struct ipv6hdr *ipv6; if (!(xmit_type & (XMIT_GSO_ENC_V6 | XMIT_GSO_V6))) return; if (xmit_type & XMIT_GSO_ENC_V6) ipv6 = inner_ipv6_hdr(skb); else /* XMIT_GSO_V6 */ ipv6 = ipv6_hdr(skb); if (ipv6->nexthdr == NEXTHDR_IPV6) *parsing_data |= <API key>; } /* called with netif_tx_lock * bnx2x_tx_int() runs without netif_tx_lock unless it needs to call * netif_wake_queue() */ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); struct netdev_queue *txq; struct bnx2x_fp_txdata *txdata; struct sw_tx_bd *tx_buf; struct eth_tx_start_bd *tx_start_bd, *first_bd; struct eth_tx_bd *tx_data_bd, *total_pkt_bd = NULL; struct eth_tx_parse_bd_e1x *pbd_e1x = NULL; struct eth_tx_parse_bd_e2 *pbd_e2 = NULL; struct eth_tx_parse_2nd_bd *pbd2 = NULL; u32 pbd_e2_parsing_data = 0; u16 pkt_prod, bd_prod; int nbd, txq_index; dma_addr_t mapping; u32 xmit_type = bnx2x_xmit_type(bp, skb); int i; u8 hlen = 0; __le16 pkt_size = 0; struct ethhdr *eth; u8 mac_type = UNICAST_ADDRESS; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return NETDEV_TX_BUSY; #endif txq_index = <API key>(skb); txq = netdev_get_tx_queue(dev, txq_index); BUG_ON(txq_index >= MAX_ETH_TXQ_IDX(bp) + (CNIC_LOADED(bp) ? 1 : 0)); txdata = &bp->bnx2x_txq[txq_index]; /* enable this debug print to view the transmission queue being used DP(NETIF_MSG_TX_QUEUED, "indices: txq %d, fp %d, txdata %d\n", txq_index, fp_index, txdata_index); */ /* enable this debug print to view the transmission details DP(NETIF_MSG_TX_QUEUED, "transmitting packet cid %d fp index %d txdata_index %d tx_data ptr %p fp pointer %p\n", txdata->cid, fp_index, txdata_index, txdata, fp); */ if (unlikely(bnx2x_tx_avail(bp, txdata) < skb_shinfo(skb)->nr_frags + BDS_PER_TX_PKT + NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))) { /* Handle special storage cases separately */ if (txdata->tx_ring_size == 0) { struct bnx2x_eth_q_stats *q_stats = bnx2x_fp_qstats(bp, txdata->parent_fp); q_stats-><API key>++; dev_kfree_skb(skb); return NETDEV_TX_OK; } bnx2x_fp_qstats(bp, txdata->parent_fp)->driver_xoff++; netif_tx_stop_queue(txq); BNX2X_ERR("BUG! Tx ring full when queue awake!\n"); return NETDEV_TX_BUSY; } DP(NETIF_MSG_TX_QUEUED, "queue[%d]: SKB: summed %x protocol %x protocol(%x,%x) gso type %x xmit_type %x len %d\n", txq_index, skb->ip_summed, skb->protocol, ipv6_hdr(skb)->nexthdr, ip_hdr(skb)->protocol, skb_shinfo(skb)->gso_type, xmit_type, skb->len); eth = (struct ethhdr *)skb->data; /* set flag according to packet type (UNICAST_ADDRESS is default)*/ if (unlikely(<API key>(eth->h_dest))) { if (<API key>(eth->h_dest)) mac_type = BROADCAST_ADDRESS; else mac_type = MULTICAST_ADDRESS; } #if (MAX_SKB_FRAGS >= MAX_FETCH_BD - BDS_PER_TX_PKT) /* First, check if we need to linearize the skb (due to FW restrictions). No need to check fragmentation if page size > 8K (there will be no violation to FW restrictions) */ if (bnx2x_pkt_req_lin(bp, skb, xmit_type)) { /* Statistics of linearization */ bp->lin_cnt++; if (skb_linearize(skb) != 0) { DP(NETIF_MSG_TX_QUEUED, "SKB linearization failed - silently dropping this SKB\n"); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } } #endif /* Map skb linear data for DMA */ mapping = dma_map_single(&bp->pdev->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { DP(NETIF_MSG_TX_QUEUED, "SKB mapping failed - silently dropping this SKB\n"); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } /* Please read carefully. First we use one BD which we mark as start, then we have a parsing info BD (used for TSO or xsum), and only then we have the rest of the TSO BDs. (don't forget to mark the last one as last, and to unmap only AFTER you write to the BD ...) And above all, all pdb sizes are in words - NOT DWORDS! */ /* get current pkt produced now - advance it just before sending packet * since mapping of pages may fail and cause packet to be dropped */ pkt_prod = txdata->tx_pkt_prod; bd_prod = TX_BD(txdata->tx_bd_prod); /* get a tx_buf and first BD * tx_start_bd may be changed during SPLIT, * but first_bd will always stay first */ tx_buf = &txdata->tx_buf_ring[TX_BD(pkt_prod)]; tx_start_bd = &txdata->tx_desc_ring[bd_prod].start_bd; first_bd = tx_start_bd; tx_start_bd->bd_flags.as_bitfield = <API key>; if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { if (!(bp->flags & TX_TIMESTAMPING_EN)) { BNX2X_ERR("Tx timestamping was not enabled, this packet will not be timestamped\n"); } else if (bp->ptp_tx_skb) { BNX2X_ERR("The device supports only a single outstanding packet to timestamp, this packet will not be timestamped\n"); } else { skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; /* schedule check for Tx timestamp */ bp->ptp_tx_skb = skb_get(skb); bp->ptp_tx_start = jiffies; schedule_work(&bp->ptp_task); } } /* header nbd: indirectly zero other flags! */ tx_start_bd->general_data = 1 << <API key>; /* remember the first BD of the packet */ tx_buf->first_bd = txdata->tx_bd_prod; tx_buf->skb = skb; tx_buf->flags = 0; DP(NETIF_MSG_TX_QUEUED, "sending pkt %u @%p next_idx %u bd %u @%p\n", pkt_prod, tx_buf, txdata->tx_pkt_prod, bd_prod, tx_start_bd); if (<API key>(skb)) { tx_start_bd->vlan_or_ethertype = cpu_to_le16(skb_vlan_tag_get(skb)); tx_start_bd->bd_flags.as_bitfield |= (X_ETH_OUTBAND_VLAN << <API key>); } else { /* when transmitting in a vf, start bd must hold the ethertype * for fw to enforce it */ #ifndef BNX2X_STOP_ON_ERROR if (IS_VF(bp)) #endif tx_start_bd->vlan_or_ethertype = cpu_to_le16(ntohs(eth->h_proto)); #ifndef BNX2X_STOP_ON_ERROR else /* used by FW for packet accounting */ tx_start_bd->vlan_or_ethertype = cpu_to_le16(pkt_prod); #endif } nbd = 2; /* start_bd + pbd + frags (updated when pages are mapped) */ /* turn on parsing and get a BD */ bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); if (xmit_type & XMIT_CSUM) bnx2x_set_sbd_csum(bp, skb, tx_start_bd, xmit_type); if (!CHIP_IS_E1x(bp)) { pbd_e2 = &txdata->tx_desc_ring[bd_prod].parse_bd_e2; memset(pbd_e2, 0, sizeof(struct eth_tx_parse_bd_e2)); if (xmit_type & XMIT_CSUM_ENC) { u16 global_data = 0; /* Set PBD in enc checksum offload case */ hlen = <API key>(bp, skb, &pbd_e2_parsing_data, xmit_type); /* turn on 2nd parsing and get a BD */ bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); pbd2 = &txdata->tx_desc_ring[bd_prod].parse_2nd_bd; memset(pbd2, 0, sizeof(*pbd2)); pbd_e2->data.tunnel_data.<API key> = (<API key>(skb) - skb->data) >> 1; if (xmit_type & XMIT_GSO_ENC) <API key>(skb, pbd_e2, pbd2, &global_data, xmit_type); pbd2->global_data = cpu_to_le16(global_data); /* add addition parse BD indication to start BD */ SET_FLAG(tx_start_bd->general_data, <API key>, 1); /* set encapsulation flag in start BD */ SET_FLAG(tx_start_bd->general_data, <API key>, 1); tx_buf->flags |= <API key>; nbd++; } else if (xmit_type & XMIT_CSUM) { /* Set PBD in checksum offload case w/o encapsulation */ hlen = <API key>(bp, skb, &pbd_e2_parsing_data, xmit_type); } <API key>(skb, &pbd_e2_parsing_data, xmit_type); /* Add the macs to the parsing BD if this is a vf or if * Tx Switching is enabled. */ if (IS_VF(bp)) { /* override GRE parameters in BD */ <API key>(&pbd_e2->data.mac_addr.src_hi, &pbd_e2->data.mac_addr.src_mid, &pbd_e2->data.mac_addr.src_lo, eth->h_source); <API key>(&pbd_e2->data.mac_addr.dst_hi, &pbd_e2->data.mac_addr.dst_mid, &pbd_e2->data.mac_addr.dst_lo, eth->h_dest); } else { if (bp->flags & TX_SWITCHING) <API key>( &pbd_e2->data.mac_addr.dst_hi, &pbd_e2->data.mac_addr.dst_mid, &pbd_e2->data.mac_addr.dst_lo, eth->h_dest); #ifdef BNX2X_STOP_ON_ERROR /* Enforce security is always set in Stop on Error - * source mac should be present in the parsing BD */ <API key>(&pbd_e2->data.mac_addr.src_hi, &pbd_e2->data.mac_addr.src_mid, &pbd_e2->data.mac_addr.src_lo, eth->h_source); #endif } SET_FLAG(pbd_e2_parsing_data, <API key>, mac_type); } else { u16 global_data = 0; pbd_e1x = &txdata->tx_desc_ring[bd_prod].parse_bd_e1x; memset(pbd_e1x, 0, sizeof(struct eth_tx_parse_bd_e1x)); /* Set PBD in checksum offload case */ if (xmit_type & XMIT_CSUM) hlen = bnx2x_set_pbd_csum(bp, skb, pbd_e1x, xmit_type); SET_FLAG(global_data, <API key>, mac_type); pbd_e1x->global_data |= cpu_to_le16(global_data); } /* Setup the data pointer of the first BD of the packet */ tx_start_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); tx_start_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); tx_start_bd->nbytes = cpu_to_le16(skb_headlen(skb)); pkt_size = tx_start_bd->nbytes; DP(NETIF_MSG_TX_QUEUED, "first bd @%p addr (%x:%x) nbytes %d flags %x vlan %x\n", tx_start_bd, tx_start_bd->addr_hi, tx_start_bd->addr_lo, le16_to_cpu(tx_start_bd->nbytes), tx_start_bd->bd_flags.as_bitfield, le16_to_cpu(tx_start_bd->vlan_or_ethertype)); if (xmit_type & XMIT_GSO) { DP(NETIF_MSG_TX_QUEUED, "TSO packet len %d hlen %d total len %d tso size %d\n", skb->len, hlen, skb_headlen(skb), skb_shinfo(skb)->gso_size); tx_start_bd->bd_flags.as_bitfield |= <API key>; if (unlikely(skb_headlen(skb) > hlen)) { nbd++; bd_prod = bnx2x_tx_split(bp, txdata, tx_buf, &tx_start_bd, hlen, bd_prod); } if (!CHIP_IS_E1x(bp)) pbd_e2_parsing_data |= (skb_shinfo(skb)->gso_size << <API key>) & <API key>; else bnx2x_set_pbd_gso(skb, pbd_e1x, xmit_type); } /* Set the PBD's parsing_data field if not zero * (for the chips newer than 57711). */ if (pbd_e2_parsing_data) pbd_e2->parsing_data = cpu_to_le32(pbd_e2_parsing_data); tx_data_bd = (struct eth_tx_bd *)tx_start_bd; /* Handle fragmented skb */ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { unsigned int pkts_compl = 0, bytes_compl = 0; DP(NETIF_MSG_TX_QUEUED, "Unable to map page - dropping packet...\n"); /* we need unmap all buffers already mapped * for this SKB; * first_bd->nbd need to be properly updated * before call to bnx2x_free_tx_pkt */ first_bd->nbd = cpu_to_le16(nbd); bnx2x_free_tx_pkt(bp, txdata, TX_BD(txdata->tx_pkt_prod), &pkts_compl, &bytes_compl); return NETDEV_TX_OK; } bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); tx_data_bd = &txdata->tx_desc_ring[bd_prod].reg_bd; if (total_pkt_bd == NULL) total_pkt_bd = &txdata->tx_desc_ring[bd_prod].reg_bd; tx_data_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); tx_data_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); tx_data_bd->nbytes = cpu_to_le16(skb_frag_size(frag)); le16_add_cpu(&pkt_size, skb_frag_size(frag)); nbd++; DP(NETIF_MSG_TX_QUEUED, "frag %d bd @%p addr (%x:%x) nbytes %d\n", i, tx_data_bd, tx_data_bd->addr_hi, tx_data_bd->addr_lo, le16_to_cpu(tx_data_bd->nbytes)); } DP(NETIF_MSG_TX_QUEUED, "last bd @%p\n", tx_data_bd); /* update with actual num BDs */ first_bd->nbd = cpu_to_le16(nbd); bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); /* now send a tx doorbell, counting the next BD * if the packet contains or ends with it */ if (TX_BD_POFF(bd_prod) < nbd) nbd++; /* total_pkt_bytes should be set on the first data BD if * it's not an LSO packet and there is more than one * data BD. In this case pkt_size is limited by an MTU value. * However we prefer to set it for an LSO packet (while we don't * have to) in order to save some CPU cycles in a none-LSO * case, when we much more care about them. */ if (total_pkt_bd != NULL) total_pkt_bd->total_pkt_bytes = pkt_size; if (pbd_e1x) DP(NETIF_MSG_TX_QUEUED, "PBD (E1X) @%p ip_data %x ip_hlen %u ip_id %u lso_mss %u tcp_flags %x xsum %x seq %u hlen %u\n", pbd_e1x, pbd_e1x->global_data, pbd_e1x->ip_hlen_w, pbd_e1x->ip_id, pbd_e1x->lso_mss, pbd_e1x->tcp_flags, pbd_e1x->tcp_pseudo_csum, pbd_e1x->tcp_send_seq, le16_to_cpu(pbd_e1x->total_hlen_w)); if (pbd_e2) DP(NETIF_MSG_TX_QUEUED, "PBD (E2) @%p dst %x %x %x src %x %x %x parsing_data %x\n", pbd_e2, pbd_e2->data.mac_addr.dst_hi, pbd_e2->data.mac_addr.dst_mid, pbd_e2->data.mac_addr.dst_lo, pbd_e2->data.mac_addr.src_hi, pbd_e2->data.mac_addr.src_mid, pbd_e2->data.mac_addr.src_lo, pbd_e2->parsing_data); DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %d bd %u\n", nbd, bd_prod); <API key>(txq, skb->len); skb_tx_timestamp(skb); txdata->tx_pkt_prod++; /* * Make sure that the BD data is updated before updating the producer * since FW might read the BD right after the producer is updated. * This is only applicable for weak-ordered memory model archs such * as IA-64. The following barrier is also mandatory since FW will * assumes packets must have BDs. */ wmb(); txdata->tx_db.data.prod += nbd; barrier(); DOORBELL(bp, txdata->cid, txdata->tx_db.raw); mmiowb(); txdata->tx_bd_prod += nbd; if (unlikely(bnx2x_tx_avail(bp, txdata) < MAX_DESC_PER_TX_PKT)) { netif_tx_stop_queue(txq); /* paired memory barrier is in bnx2x_tx_int(), we have to keep * ordering of set_bit() in netif_tx_stop_queue() and read of * fp->bd_tx_cons */ smp_mb(); bnx2x_fp_qstats(bp, txdata->parent_fp)->driver_xoff++; if (bnx2x_tx_avail(bp, txdata) >= MAX_DESC_PER_TX_PKT) netif_tx_wake_queue(txq); } txdata->tx_pkt++; return NETDEV_TX_OK; } void <API key>(struct bnx2x *bp, u8 *c2s_map, u8 *c2s_default) { int mfw_vn = BP_FW_MB_IDX(bp); u32 tmp; /* If the shmem shouldn't affect configuration, reflect */ if (!IS_MF_BD(bp)) { int i; for (i = 0; i < BNX2X_MAX_PRIORITY; i++) c2s_map[i] = i; *c2s_default = 0; return; } tmp = SHMEM2_RD(bp, c2s_pcp_map_lower[mfw_vn]); tmp = (__force u32)be32_to_cpu((__force __be32)tmp); c2s_map[0] = tmp & 0xff; c2s_map[1] = (tmp >> 8) & 0xff; c2s_map[2] = (tmp >> 16) & 0xff; c2s_map[3] = (tmp >> 24) & 0xff; tmp = SHMEM2_RD(bp, c2s_pcp_map_upper[mfw_vn]); tmp = (__force u32)be32_to_cpu((__force __be32)tmp); c2s_map[4] = tmp & 0xff; c2s_map[5] = (tmp >> 8) & 0xff; c2s_map[6] = (tmp >> 16) & 0xff; c2s_map[7] = (tmp >> 24) & 0xff; tmp = SHMEM2_RD(bp, c2s_pcp_map_default[mfw_vn]); tmp = (__force u32)be32_to_cpu((__force __be32)tmp); *c2s_default = (tmp >> (8 * mfw_vn)) & 0xff; } /** * bnx2x_setup_tc - routine to configure net_device for multi tc * * @netdev: net device to configure * @tc: number of traffic classes to enable * * callback connected to the ndo_setup_tc function pointer */ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc) { struct bnx2x *bp = netdev_priv(dev); u8 c2s_map[BNX2X_MAX_PRIORITY], c2s_def; int cos, prio, count, offset; /* setup tc must be called under rtnl lock */ ASSERT_RTNL(); /* no traffic classes requested. Aborting */ if (!num_tc) { netdev_reset_tc(dev); return 0; } /* requested to support too many traffic classes */ if (num_tc > bp->max_cos) { BNX2X_ERR("support for too many traffic classes requested: %d. Max supported is %d\n", num_tc, bp->max_cos); return -EINVAL; } /* declare amount of supported traffic classes */ if (netdev_set_num_tc(dev, num_tc)) { BNX2X_ERR("failed to declare %d traffic classes\n", num_tc); return -EINVAL; } <API key>(bp, c2s_map, &c2s_def); /* configure priority to traffic class mapping */ for (prio = 0; prio < BNX2X_MAX_PRIORITY; prio++) { int outer_prio = c2s_map[prio]; <API key>(dev, prio, bp->prio_to_cos[outer_prio]); DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, "mapping priority %d to tc %d\n", outer_prio, bp->prio_to_cos[outer_prio]); } /* Use this configuration to differentiate tc0 from other COSes This can be used for ets or pfc, and save the effort of setting up a multio class queue disc or negotiating DCBX with a switch <API key>(dev, 0, 0); DP(BNX2X_MSG_SP, "mapping priority %d to tc %d\n", 0, 0); for (prio = 1; prio < 16; prio++) { <API key>(dev, prio, 1); DP(BNX2X_MSG_SP, "mapping priority %d to tc %d\n", prio, 1); } */ /* configure traffic class to transmission queue mapping */ for (cos = 0; cos < bp->max_cos; cos++) { count = <API key>(bp); offset = cos * <API key>(bp); netdev_set_tc_queue(dev, cos, count, offset); DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, "mapping tc %d to offset %d count %d\n", cos, offset, count); } return 0; } int __bnx2x_setup_tc(struct net_device *dev, u32 handle, __be16 proto, struct tc_to_netdev *tc) { if (tc->type != TC_SETUP_MQPRIO) return -EINVAL; tc->mqprio->hw = <API key>; return bnx2x_setup_tc(dev, tc->mqprio->num_tc); } /* called with rtnl_lock */ int <API key>(struct net_device *dev, void *p) { struct sockaddr *addr = p; struct bnx2x *bp = netdev_priv(dev); int rc = 0; if (!is_valid_ether_addr(addr->sa_data)) { BNX2X_ERR("Requested MAC address is not valid\n"); return -EINVAL; } if (IS_MF_STORAGE_ONLY(bp)) { BNX2X_ERR("Can't change address on STORAGE ONLY function\n"); return -EINVAL; } if (netif_running(dev)) { rc = bnx2x_set_eth_mac(bp, false); if (rc) return rc; } memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); if (netif_running(dev)) rc = bnx2x_set_eth_mac(bp, true); if (IS_PF(bp) && SHMEM2_HAS(bp, curr_cfg)) SHMEM2_WR(bp, curr_cfg, CURR_CFG_MET_OS); return rc; } static void <API key>(struct bnx2x *bp, int fp_index) { union <API key> *sb = &bnx2x_fp(bp, fp_index, status_blk); struct bnx2x_fastpath *fp = &bp->fp[fp_index]; u8 cos; /* Common */ if (IS_FCOE_IDX(fp_index)) { memset(sb, 0, sizeof(union <API key>)); fp->status_blk_mapping = 0; } else { /* status blocks */ if (!CHIP_IS_E1x(bp)) BNX2X_PCI_FREE(sb->e2_sb, bnx2x_fp(bp, fp_index, status_blk_mapping), sizeof(struct <API key>)); else BNX2X_PCI_FREE(sb->e1x_sb, bnx2x_fp(bp, fp_index, status_blk_mapping), sizeof(struct <API key>)); } if (!skip_rx_queue(bp, fp_index)) { bnx2x_free_rx_bds(fp); /* fastpath rx rings: rx_buf rx_desc rx_comp */ BNX2X_FREE(bnx2x_fp(bp, fp_index, rx_buf_ring)); BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_desc_ring), bnx2x_fp(bp, fp_index, rx_desc_mapping), sizeof(struct eth_rx_bd) * NUM_RX_BD); BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_comp_ring), bnx2x_fp(bp, fp_index, rx_comp_mapping), sizeof(struct <API key>) * NUM_RCQ_BD); /* SGE ring */ BNX2X_FREE(bnx2x_fp(bp, fp_index, rx_page_ring)); BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_sge_ring), bnx2x_fp(bp, fp_index, rx_sge_mapping), BCM_PAGE_SIZE * NUM_RX_SGE_PAGES); } if (!skip_tx_queue(bp, fp_index)) { /* fastpath tx rings: tx_buf tx_desc */ <API key>(fp, cos) { struct bnx2x_fp_txdata *txdata = fp->txdata_ptr[cos]; DP(NETIF_MSG_IFDOWN, "freeing tx memory of fp %d cos %d cid %d\n", fp_index, cos, txdata->cid); BNX2X_FREE(txdata->tx_buf_ring); BNX2X_PCI_FREE(txdata->tx_desc_ring, txdata->tx_desc_mapping, sizeof(union eth_tx_bd_types) * NUM_TX_BD); } } /* end of fastpath */ } static void <API key>(struct bnx2x *bp) { int i; for_each_cnic_queue(bp, i) <API key>(bp, i); } void bnx2x_free_fp_mem(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) <API key>(bp, i); } static void set_sb_shortcuts(struct bnx2x *bp, int index) { union <API key> status_blk = bnx2x_fp(bp, index, status_blk); if (!CHIP_IS_E1x(bp)) { bnx2x_fp(bp, index, sb_index_values) = (__le16 *)status_blk.e2_sb->sb.index_values; bnx2x_fp(bp, index, sb_running_index) = (__le16 *)status_blk.e2_sb->sb.running_index; } else { bnx2x_fp(bp, index, sb_index_values) = (__le16 *)status_blk.e1x_sb->sb.index_values; bnx2x_fp(bp, index, sb_running_index) = (__le16 *)status_blk.e1x_sb->sb.running_index; } } /* Returns the number of actually allocated BDs */ static int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, int rx_ring_size) { struct bnx2x *bp = fp->bp; u16 ring_prod, cqe_ring_prod; int i, failure_cnt = 0; fp->rx_comp_cons = 0; cqe_ring_prod = ring_prod = 0; /* This routine is called only during fo init so * fp->eth_q_stats.rx_skb_alloc_failed = 0 */ for (i = 0; i < rx_ring_size; i++) { if (bnx2x_alloc_rx_data(bp, fp, ring_prod, GFP_KERNEL) < 0) { failure_cnt++; continue; } ring_prod = NEXT_RX_IDX(ring_prod); cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod); WARN_ON(ring_prod <= (i - failure_cnt)); } if (failure_cnt) BNX2X_ERR("was only able to allocate %d rx skbs on queue[%d]\n", i - failure_cnt, fp->index); fp->rx_bd_prod = ring_prod; /* Limit the CQE producer by the CQE ring size */ fp->rx_comp_prod = min_t(u16, NUM_RCQ_RINGS*RCQ_DESC_CNT, cqe_ring_prod); bnx2x_fp_stats(bp, fp)->eth_q_stats.rx_skb_alloc_failed += failure_cnt; return i - failure_cnt; } static void <API key>(struct bnx2x_fastpath *fp) { int i; for (i = 1; i <= NUM_RCQ_RINGS; i++) { struct <API key> *nextpg; nextpg = (struct <API key> *) &fp->rx_comp_ring[RCQ_DESC_CNT * i - 1]; nextpg->addr_hi = cpu_to_le32(U64_HI(fp->rx_comp_mapping + BCM_PAGE_SIZE*(i % NUM_RCQ_RINGS))); nextpg->addr_lo = cpu_to_le32(U64_LO(fp->rx_comp_mapping + BCM_PAGE_SIZE*(i % NUM_RCQ_RINGS))); } } static int <API key>(struct bnx2x *bp, int index) { union <API key> *sb; struct bnx2x_fastpath *fp = &bp->fp[index]; int ring_size = 0; u8 cos; int rx_ring_size = 0; if (!bp->rx_ring_size && IS_MF_STORAGE_ONLY(bp)) { rx_ring_size = MIN_RX_SIZE_NONTPA; bp->rx_ring_size = rx_ring_size; } else if (!bp->rx_ring_size) { rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp); if (CHIP_IS_E3(bp)) { u32 cfg = SHMEM_RD(bp, dev_info.port_hw_config[BP_PORT(bp)]. default_cfg); /* Decrease ring size for 1G functions */ if ((cfg & <API key>) == <API key>) rx_ring_size /= 10; } /* allocate at least number of buffers required by FW */ rx_ring_size = max_t(int, bp->disable_tpa ? MIN_RX_SIZE_NONTPA : MIN_RX_SIZE_TPA, rx_ring_size); bp->rx_ring_size = rx_ring_size; } else /* if rx_ring_size specified - use it */ rx_ring_size = bp->rx_ring_size; DP(BNX2X_MSG_SP, "calculated rx_ring_size %d\n", rx_ring_size); /* Common */ sb = &bnx2x_fp(bp, index, status_blk); if (!IS_FCOE_IDX(index)) { /* status blocks */ if (!CHIP_IS_E1x(bp)) { sb->e2_sb = BNX2X_PCI_ALLOC(&bnx2x_fp(bp, index, status_blk_mapping), sizeof(struct <API key>)); if (!sb->e2_sb) goto alloc_mem_err; } else { sb->e1x_sb = BNX2X_PCI_ALLOC(&bnx2x_fp(bp, index, status_blk_mapping), sizeof(struct <API key>)); if (!sb->e1x_sb) goto alloc_mem_err; } } /* FCoE Queue uses Default SB and doesn't ACK the SB, thus no need to * set shortcuts for it. */ if (!IS_FCOE_IDX(index)) set_sb_shortcuts(bp, index); if (!skip_tx_queue(bp, index)) { /* fastpath tx rings: tx_buf tx_desc */ <API key>(fp, cos) { struct bnx2x_fp_txdata *txdata = fp->txdata_ptr[cos]; DP(NETIF_MSG_IFUP, "allocating tx memory of fp %d cos %d\n", index, cos); txdata->tx_buf_ring = kcalloc(NUM_TX_BD, sizeof(struct sw_tx_bd), GFP_KERNEL); if (!txdata->tx_buf_ring) goto alloc_mem_err; txdata->tx_desc_ring = BNX2X_PCI_ALLOC(&txdata->tx_desc_mapping, sizeof(union eth_tx_bd_types) * NUM_TX_BD); if (!txdata->tx_desc_ring) goto alloc_mem_err; } } if (!skip_rx_queue(bp, index)) { /* fastpath rx rings: rx_buf rx_desc rx_comp */ bnx2x_fp(bp, index, rx_buf_ring) = kcalloc(NUM_RX_BD, sizeof(struct sw_rx_bd), GFP_KERNEL); if (!bnx2x_fp(bp, index, rx_buf_ring)) goto alloc_mem_err; bnx2x_fp(bp, index, rx_desc_ring) = BNX2X_PCI_ALLOC(&bnx2x_fp(bp, index, rx_desc_mapping), sizeof(struct eth_rx_bd) * NUM_RX_BD); if (!bnx2x_fp(bp, index, rx_desc_ring)) goto alloc_mem_err; /* Seed all CQEs by 1s */ bnx2x_fp(bp, index, rx_comp_ring) = BNX2X_PCI_FALLOC(&bnx2x_fp(bp, index, rx_comp_mapping), sizeof(struct <API key>) * NUM_RCQ_BD); if (!bnx2x_fp(bp, index, rx_comp_ring)) goto alloc_mem_err; /* SGE ring */ bnx2x_fp(bp, index, rx_page_ring) = kcalloc(NUM_RX_SGE, sizeof(struct sw_rx_page), GFP_KERNEL); if (!bnx2x_fp(bp, index, rx_page_ring)) goto alloc_mem_err; bnx2x_fp(bp, index, rx_sge_ring) = BNX2X_PCI_ALLOC(&bnx2x_fp(bp, index, rx_sge_mapping), BCM_PAGE_SIZE * NUM_RX_SGE_PAGES); if (!bnx2x_fp(bp, index, rx_sge_ring)) goto alloc_mem_err; /* RX BD ring */ <API key>(fp); /* CQ ring */ <API key>(fp); /* BDs */ ring_size = bnx2x_alloc_rx_bds(fp, rx_ring_size); if (ring_size < rx_ring_size) goto alloc_mem_err; } return 0; /* handles low memory cases */ alloc_mem_err: BNX2X_ERR("Unable to allocate full memory for queue %d (size %d)\n", index, ring_size); /* FW will drop all packets if queue is not big enough, * In these cases we disable the queue * Min size is different for OOO, TPA and non-TPA queues */ if (ring_size < (fp->mode == TPA_MODE_DISABLED ? MIN_RX_SIZE_NONTPA : MIN_RX_SIZE_TPA)) { /* release memory allocated for this queue */ <API key>(bp, index); return -ENOMEM; } return 0; } static int <API key>(struct bnx2x *bp) { if (!NO_FCOE(bp)) /* FCoE */ if (<API key>(bp, FCOE_IDX(bp))) /* we will fail load process instead of mark * NO_FCOE_FLAG */ return -ENOMEM; return 0; } static int bnx2x_alloc_fp_mem(struct bnx2x *bp) { int i; /* 1. Allocate FP for leading - fatal if error * 2. Allocate RSS - fix number of queues if error */ /* leading */ if (<API key>(bp, 0)) return -ENOMEM; /* RSS */ <API key>(bp, i) if (<API key>(bp, i)) break; /* handle memory failures */ if (i != <API key>(bp)) { int delta = <API key>(bp) - i; WARN_ON(delta < 0); bnx2x_shrink_eth_fp(bp, delta); if (CNIC_SUPPORT(bp)) /* move non eth FPs next to last eth FP * must be done in that order * FCOE_IDX < FWD_IDX < OOO_IDX */ /* move FCoE fp even NO_FCOE_FLAG is on */ bnx2x_move_fp(bp, FCOE_IDX(bp), FCOE_IDX(bp) - delta); bp->num_ethernet_queues -= delta; bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues; BNX2X_ERR("Adjusted num of queues from %d to %d\n", bp->num_queues + delta, bp->num_queues); } return 0; } void bnx2x_free_mem_bp(struct bnx2x *bp) { int i; for (i = 0; i < bp->fp_array_size; i++) kfree(bp->fp[i].tpa_info); kfree(bp->fp); kfree(bp->sp_objs); kfree(bp->fp_stats); kfree(bp->bnx2x_txq); kfree(bp->msix_table); kfree(bp->ilt); } int bnx2x_alloc_mem_bp(struct bnx2x *bp) { struct bnx2x_fastpath *fp; struct msix_entry *tbl; struct bnx2x_ilt *ilt; int msix_table_size = 0; int fp_array_size, txq_array_size; int i; /* * The biggest MSI-X table we might need is as a maximum number of fast * path IGU SBs plus default SB (for PF only). */ msix_table_size = bp->igu_sb_cnt; if (IS_PF(bp)) msix_table_size++; BNX2X_DEV_INFO("msix_table_size %d\n", msix_table_size); /* fp array: RSS plus CNIC related L2 queues */ fp_array_size = BNX2X_MAX_RSS_COUNT(bp) + CNIC_SUPPORT(bp); bp->fp_array_size = fp_array_size; BNX2X_DEV_INFO("fp_array_size %d\n", bp->fp_array_size); fp = kcalloc(bp->fp_array_size, sizeof(*fp), GFP_KERNEL); if (!fp) goto alloc_err; for (i = 0; i < bp->fp_array_size; i++) { fp[i].tpa_info = kcalloc(<API key>, sizeof(struct bnx2x_agg_info), GFP_KERNEL); if (!(fp[i].tpa_info)) goto alloc_err; } bp->fp = fp; /* allocate sp objs */ bp->sp_objs = kcalloc(bp->fp_array_size, sizeof(struct bnx2x_sp_objs), GFP_KERNEL); if (!bp->sp_objs) goto alloc_err; /* allocate fp_stats */ bp->fp_stats = kcalloc(bp->fp_array_size, sizeof(struct bnx2x_fp_stats), GFP_KERNEL); if (!bp->fp_stats) goto alloc_err; /* Allocate memory for the transmission queues array */ txq_array_size = BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS + CNIC_SUPPORT(bp); BNX2X_DEV_INFO("txq_array_size %d", txq_array_size); bp->bnx2x_txq = kcalloc(txq_array_size, sizeof(struct bnx2x_fp_txdata), GFP_KERNEL); if (!bp->bnx2x_txq) goto alloc_err; /* msix table */ tbl = kcalloc(msix_table_size, sizeof(*tbl), GFP_KERNEL); if (!tbl) goto alloc_err; bp->msix_table = tbl; /* ilt */ ilt = kzalloc(sizeof(*ilt), GFP_KERNEL); if (!ilt) goto alloc_err; bp->ilt = ilt; return 0; alloc_err: bnx2x_free_mem_bp(bp); return -ENOMEM; } int <API key>(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); if (unlikely(!netif_running(dev))) return 0; bnx2x_nic_unload(bp, UNLOAD_NORMAL, true); return bnx2x_nic_load(bp, LOAD_NORMAL); } int <API key>(struct bnx2x *bp) { u32 sel_phy_idx = 0; if (bp->link_params.num_phys <= 1) return INT_PHY; if (bp->link_vars.link_up) { sel_phy_idx = EXT_PHY1; /* In case link is SERDES, check if the EXT_PHY2 is the one */ if ((bp->link_vars.link_status & <API key>) && (bp->link_params.phy[EXT_PHY2].supported & SUPPORTED_FIBRE)) sel_phy_idx = EXT_PHY2; } else { switch (bnx2x_phy_selection(&bp->link_params)) { case <API key>: case <API key>: case <API key>: sel_phy_idx = EXT_PHY1; break; case <API key>: case <API key>: sel_phy_idx = EXT_PHY2; break; } } return sel_phy_idx; } int <API key>(struct bnx2x *bp) { u32 sel_phy_idx = <API key>(bp); /* * The selected activated PHY is always after swapping (in case PHY * swapping is enabled). So when swapping is enabled, we need to reverse * the configuration */ if (bp->link_params.multi_phy_config & <API key>) { if (sel_phy_idx == EXT_PHY1) sel_phy_idx = EXT_PHY2; else if (sel_phy_idx == EXT_PHY2) sel_phy_idx = EXT_PHY1; } return LINK_CONFIG_IDX(sel_phy_idx); } #ifdef NETDEV_FCOE_WWNN int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type) { struct bnx2x *bp = netdev_priv(dev); struct cnic_eth_dev *cp = &bp->cnic_eth_dev; switch (type) { case NETDEV_FCOE_WWNN: *wwn = HILO_U64(cp-><API key>, cp-><API key>); break; case NETDEV_FCOE_WWPN: *wwn = HILO_U64(cp-><API key>, cp-><API key>); break; default: BNX2X_ERR("Wrong WWN type requested - %d\n", type); return -EINVAL; } return 0; } #endif /* called with rtnl_lock */ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) { struct bnx2x *bp = netdev_priv(dev); if (pci_num_vf(bp->pdev)) { DP(BNX2X_MSG_IOV, "VFs are enabled, can not change MTU\n"); return -EPERM; } if (bp->recovery_state != BNX2X_RECOVERY_DONE) { BNX2X_ERR("Can't perform change MTU during parity recovery\n"); return -EAGAIN; } /* This does not race with packet allocation * because the actual alloc size is * only updated as part of load */ dev->mtu = new_mtu; if (IS_PF(bp) && SHMEM2_HAS(bp, curr_cfg)) SHMEM2_WR(bp, curr_cfg, CURR_CFG_MET_OS); return <API key>(dev); } netdev_features_t bnx2x_fix_features(struct net_device *dev, netdev_features_t features) { struct bnx2x *bp = netdev_priv(dev); if (pci_num_vf(bp->pdev)) { netdev_features_t changed = dev->features ^ features; /* Revert the requested changes in features if they * would require internal reload of PF in bnx2x_set_features(). */ if (!(features & NETIF_F_RXCSUM) && !bp->disable_tpa) { features &= ~NETIF_F_RXCSUM; features |= dev->features & NETIF_F_RXCSUM; } if (changed & NETIF_F_LOOPBACK) { features &= ~NETIF_F_LOOPBACK; features |= dev->features & NETIF_F_LOOPBACK; } } /* TPA requires Rx CSUM offloading */ if (!(features & NETIF_F_RXCSUM)) { features &= ~NETIF_F_LRO; features &= ~NETIF_F_GRO; } return features; } int bnx2x_set_features(struct net_device *dev, netdev_features_t features) { struct bnx2x *bp = netdev_priv(dev); netdev_features_t changes = features ^ dev->features; bool bnx2x_reload = false; int rc; /* VFs or non SRIOV PFs should be able to change loopback feature */ if (!pci_num_vf(bp->pdev)) { if (features & NETIF_F_LOOPBACK) { if (bp->link_params.loopback_mode != LOOPBACK_BMAC) { bp->link_params.loopback_mode = LOOPBACK_BMAC; bnx2x_reload = true; } } else { if (bp->link_params.loopback_mode != LOOPBACK_NONE) { bp->link_params.loopback_mode = LOOPBACK_NONE; bnx2x_reload = true; } } } /* if GRO is changed while LRO is enabled, don't force a reload */ if ((changes & NETIF_F_GRO) && (features & NETIF_F_LRO)) changes &= ~NETIF_F_GRO; /* if GRO is changed while HW TPA is off, don't force a reload */ if ((changes & NETIF_F_GRO) && bp->disable_tpa) changes &= ~NETIF_F_GRO; if (changes) bnx2x_reload = true; if (bnx2x_reload) { if (bp->recovery_state == BNX2X_RECOVERY_DONE) { dev->features = features; rc = <API key>(dev); return rc ? rc : 1; } /* else: bnx2x_nic_load() will be called at end of recovery */ } return 0; } void bnx2x_tx_timeout(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); #ifdef BNX2X_STOP_ON_ERROR if (!bp->panic) bnx2x_panic(); #endif /* This allows the netif to be shutdown gracefully before resetting */ <API key>(bp, <API key>, 0); } int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp; if (!dev) { dev_err(&pdev->dev, "BAD net device from bnx2x_init_one\n"); return -ENODEV; } bp = netdev_priv(dev); rtnl_lock(); pci_save_state(pdev); if (!netif_running(dev)) { rtnl_unlock(); return 0; } netif_device_detach(dev); bnx2x_nic_unload(bp, UNLOAD_CLOSE, false); <API key>(bp, pci_choose_state(pdev, state)); rtnl_unlock(); return 0; } int bnx2x_resume(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp; int rc; if (!dev) { dev_err(&pdev->dev, "BAD net device from bnx2x_init_one\n"); return -ENODEV; } bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { BNX2X_ERR("Handling parity error recovery. Try again later\n"); return -EAGAIN; } rtnl_lock(); pci_restore_state(pdev); if (!netif_running(dev)) { rtnl_unlock(); return 0; } <API key>(bp, PCI_D0); netif_device_attach(dev); rc = bnx2x_nic_load(bp, LOAD_OPEN); rtnl_unlock(); return rc; } void <API key>(struct bnx2x *bp, struct eth_context *cxt, u32 cid) { if (!cxt) { BNX2X_ERR("bad context pointer %p\n", cxt); return; } /* ustorm cxt validation */ cxt->ustorm_ag_context.cdu_usage = <API key>(HW_CID(bp, cid), <API key>, ETH_CONNECTION_TYPE); /* xcontext validation */ cxt->xstorm_ag_context.cdu_reserved = <API key>(HW_CID(bp, cid), <API key>, ETH_CONNECTION_TYPE); } static void <API key>(struct bnx2x *bp, u8 port, u8 fw_sb_id, u8 sb_index, u8 ticks) { u32 addr = BAR_CSTRORM_INTMEM + <API key>(fw_sb_id, sb_index); REG_WR8(bp, addr, ticks); DP(NETIF_MSG_IFUP, "port %x fw_sb_id %d sb_index %d ticks %d\n", port, fw_sb_id, sb_index, ticks); } static void <API key>(struct bnx2x *bp, u8 port, u16 fw_sb_id, u8 sb_index, u8 disable) { u32 enable_flag = disable ? 0 : (1 << <API key>); u32 addr = BAR_CSTRORM_INTMEM + <API key>(fw_sb_id, sb_index); u8 flags = REG_RD8(bp, addr); /* clear and set */ flags &= ~<API key>; flags |= enable_flag; REG_WR8(bp, addr, flags); DP(NETIF_MSG_IFUP, "port %x fw_sb_id %d sb_index %d disable %d\n", port, fw_sb_id, sb_index, disable); } void <API key>(struct bnx2x *bp, u8 fw_sb_id, u8 sb_index, u8 disable, u16 usec) { int port = BP_PORT(bp); u8 ticks = usec / BNX2X_BTR; <API key>(bp, port, fw_sb_id, sb_index, ticks); disable = disable ? 1 : (usec ? 0 : 1); <API key>(bp, port, fw_sb_id, sb_index, disable); } void <API key>(struct bnx2x *bp, enum sp_rtnl_flag flag, u32 verbose) { <API key>(); set_bit(flag, &bp->sp_rtnl_state); <API key>(); DP((BNX2X_MSG_SP | verbose), "Scheduling sp_rtnl task [Flag: %d]\n", flag); <API key>(&bp->sp_rtnl_task, 0); }
// Auto-generated with: android/scripts/gen-entries.py --mode=wrapper audio/wrappers/alsa.entries // DO NOT EDIT THIS FILE #include <dlfcn.h> #include <alsa/asoundlib.h> W R A P P E R P O I N T E R S static snd_pcm_sframes_t (*<API key>)(snd_pcm_t * pcm) = 0; static int (*__dll_snd_pcm_close)(snd_pcm_t * pcm) = 0; static int (*__dll_snd_pcm_drop)(snd_pcm_t * pcm) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params) = 0; static int (*<API key>)(const snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val) = 0; static int (*<API key>)(const snd_pcm_hw_params_t * params, snd_pcm_format_t * val) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_access_t _access) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_format_t val) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val, int * dir) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) = 0; static size_t (*<API key>)() = 0; static int (*__dll_snd_pcm_open)(snd_pcm_t ** pcm, const char * name, snd_pcm_stream_t stream, int mode) = 0; static int (*<API key>)(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int space) = 0; static int (*<API key>)(snd_pcm_t * pcm) = 0; static int (*<API key>)(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int nfds, unsigned short * revents) = 0; static int (*<API key>)(snd_pcm_t * pcm) = 0; static snd_pcm_sframes_t (*__dll_snd_pcm_readi)(snd_pcm_t * pcm, void * buffer, snd_pcm_uframes_t size) = 0; static int (*<API key>)(snd_pcm_t * pcm) = 0; static snd_pcm_state_t (*__dll_snd_pcm_state)(snd_pcm_t * pcm) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params) = 0; static int (*<API key>)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params, snd_pcm_uframes_t val) = 0; static size_t (*<API key>)() = 0; static snd_pcm_sframes_t (*<API key>)(snd_pcm_t * pcm, const void * buffer, snd_pcm_uframes_t size) = 0; static const char * (*__dll_snd_strerror)(int errnum) = 0; W R A P P E R F U N C T I O N S snd_pcm_sframes_t <API key>(snd_pcm_t * pcm) { return <API key>(pcm); } int snd_pcm_close(snd_pcm_t * pcm) { return __dll_snd_pcm_close(pcm); } int snd_pcm_drop(snd_pcm_t * pcm) { return __dll_snd_pcm_drop(pcm); } int snd_pcm_hw_params(snd_pcm_t * pcm, snd_pcm_hw_params_t * params) { return <API key>(pcm, params); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params) { return <API key>(pcm, params); } int <API key>(const snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val) { return <API key>(params, val); } int <API key>(const snd_pcm_hw_params_t * params, snd_pcm_format_t * val) { return <API key>(params, val); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_access_t _access) { return <API key>(pcm, params, _access); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val) { return <API key>(pcm, params, val); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) { return <API key>(pcm, params, val, dir); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val) { return <API key>(pcm, params, val); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_format_t val) { return <API key>(pcm, params, val); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val, int * dir) { return <API key>(pcm, params, val, dir); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) { return <API key>(pcm, params, val, dir); } int <API key>(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir) { return <API key>(pcm, params, val, dir); } size_t <API key>() { return <API key>(); } int snd_pcm_open(snd_pcm_t ** pcm, const char * name, snd_pcm_stream_t stream, int mode) { return __dll_snd_pcm_open(pcm, name, stream, mode); } int <API key>(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int space) { return <API key>(pcm, pfds, space); } int <API key>(snd_pcm_t * pcm) { return <API key>(pcm); } int <API key>(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int nfds, unsigned short * revents) { return <API key>(pcm, pfds, nfds, revents); } int snd_pcm_prepare(snd_pcm_t * pcm) { return <API key>(pcm); } snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t * pcm, void * buffer, snd_pcm_uframes_t size) { return __dll_snd_pcm_readi(pcm, buffer, size); } int snd_pcm_resume(snd_pcm_t * pcm) { return <API key>(pcm); } snd_pcm_state_t snd_pcm_state(snd_pcm_t * pcm) { return __dll_snd_pcm_state(pcm); } int snd_pcm_sw_params(snd_pcm_t * pcm, snd_pcm_sw_params_t * params) { return <API key>(pcm, params); } int <API key>(snd_pcm_t * pcm, snd_pcm_sw_params_t * params) { return <API key>(pcm, params); } int <API key>(snd_pcm_t * pcm, snd_pcm_sw_params_t * params, snd_pcm_uframes_t val) { return <API key>(pcm, params, val); } size_t <API key>() { return <API key>(); } snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t * pcm, const void * buffer, snd_pcm_uframes_t size) { return <API key>(pcm, buffer, size); } const char * snd_strerror(int errnum) { return __dll_snd_strerror(errnum); } I N I T I A L I Z A T I O N F U N C T I O N int alsa_dynlink_init(void* lib) { <API key> = (snd_pcm_sframes_t(*)(snd_pcm_t * pcm))dlsym(lib, "<API key>"); if (!<API key>) return -1; __dll_snd_pcm_close = (int(*)(snd_pcm_t * pcm))dlsym(lib, "snd_pcm_close"); if (!__dll_snd_pcm_close) return -1; __dll_snd_pcm_drop = (int(*)(snd_pcm_t * pcm))dlsym(lib, "snd_pcm_drop"); if (!__dll_snd_pcm_drop) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params))dlsym(lib, "snd_pcm_hw_params"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(const snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(const snd_pcm_hw_params_t * params, snd_pcm_format_t * val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_access_t _access))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_format_t val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, snd_pcm_uframes_t * val, int * dir))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_hw_params_t * params, unsigned int * val, int * dir))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (size_t(*)())dlsym(lib, "<API key>"); if (!<API key>) return -1; __dll_snd_pcm_open = (int(*)(snd_pcm_t ** pcm, const char * name, snd_pcm_stream_t stream, int mode))dlsym(lib, "snd_pcm_open"); if (!__dll_snd_pcm_open) return -1; <API key> = (int(*)(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int space))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, struct pollfd * pfds, unsigned int nfds, unsigned short * revents))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm))dlsym(lib, "snd_pcm_prepare"); if (!<API key>) return -1; __dll_snd_pcm_readi = (snd_pcm_sframes_t(*)(snd_pcm_t * pcm, void * buffer, snd_pcm_uframes_t size))dlsym(lib, "snd_pcm_readi"); if (!__dll_snd_pcm_readi) return -1; <API key> = (int(*)(snd_pcm_t * pcm))dlsym(lib, "snd_pcm_resume"); if (!<API key>) return -1; __dll_snd_pcm_state = (snd_pcm_state_t(*)(snd_pcm_t * pcm))dlsym(lib, "snd_pcm_state"); if (!__dll_snd_pcm_state) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params))dlsym(lib, "snd_pcm_sw_params"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (int(*)(snd_pcm_t * pcm, snd_pcm_sw_params_t * params, snd_pcm_uframes_t val))dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (size_t(*)())dlsym(lib, "<API key>"); if (!<API key>) return -1; <API key> = (snd_pcm_sframes_t(*)(snd_pcm_t * pcm, const void * buffer, snd_pcm_uframes_t size))dlsym(lib, "snd_pcm_writei"); if (!<API key>) return -1; __dll_snd_strerror = (const char *(*)(int errnum))dlsym(lib, "snd_strerror"); if (!__dll_snd_strerror) return -1; return 0; }
/* #define VERBOSE_DEBUG */ #include <linux/slab.h> #include <linux/kernel.h> #include <linux/device.h> #include <linux/etherdevice.h> #include "u_ether.h" /* * This function is a "CDC Ethernet Networking Control Model" (CDC ECM) * Ethernet link. The data transfer model is simple (packets sent and * received over bulk endpoints using normal short packet termination), * and the control model exposes various data and optional notifications. * * ECM is well standardized and (except for Microsoft) supported by most * operating systems with USB host support. It's the preferred interop * solution for Ethernet over USB, at least for firmware based solutions. * (Hardware solutions tend to be more minimalist.) A newer and simpler * "Ethernet Emulation Model" (CDC EEM) hasn't yet caught on. * * Note that ECM requires the use of "alternate settings" for its data * interface. This means that the set_alt() method has real work to do, * and also means that a get_alt() method is required. */ enum ecm_notify_state { ECM_NOTIFY_NONE, /* don't notify */ ECM_NOTIFY_CONNECT, /* issue CONNECT next */ ECM_NOTIFY_SPEED, /* issue SPEED_CHANGE next */ }; struct f_ecm { struct gether port; u8 ctrl_id, data_id; char ethaddr[14]; struct usb_ep *notify; struct usb_request *notify_req; u8 notify_state; bool is_open; /* FIXME is_open needs some irq-ish locking * ... possibly the same as port.ioport */ }; static inline struct f_ecm *func_to_ecm(struct usb_function *f) { return container_of(f, struct f_ecm, port.func); } /* peak (theoretical) bulk transfer rate in bits-per-second */ static inline unsigned ecm_bitrate(struct usb_gadget *g) { if (<API key>(g) && g->speed == USB_SPEED_SUPER) return 13 * 1024 * 8 * 1000 * 8; else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) return 13 * 512 * 8 * 1000 * 8; else return 19 * 64 * 1 * 1000 * 8; } /* * Include the status endpoint if we can, even though it's optional. * * Use wMaxPacketSize big enough to fit <API key> in one * packet, to simplify cancellation; and a big transfer interval, to * waste less bandwidth. * * Some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even * if they ignore the connect/disconnect notifications that real aether * can provide. More advanced cdc configurations might want to support * encapsulated commands (vendor-specific, using control-OUT). */ #define <API key> 5 /* 1 << 5 == 32 msec */ #define <API key> 16 /* 8 byte header + data */ /* interface descriptor: */ static struct <API key> ecm_iad_descriptor = { .bLength = sizeof ecm_iad_descriptor, .bDescriptorType = <API key>, /* .bFirstInterface = DYNAMIC, */ .bInterfaceCount = 2, /* control + data */ .bFunctionClass = USB_CLASS_COMM, .bFunctionSubClass = <API key>, .bFunctionProtocol = USB_CDC_PROTO_NONE, /* .iFunction = DYNAMIC */ }; static struct <API key> ecm_control_intf = { .bLength = sizeof ecm_control_intf, .bDescriptorType = USB_DT_INTERFACE, /* .bInterfaceNumber = DYNAMIC */ /* status endpoint is optional; this could be patched later */ .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_COMM, .bInterfaceSubClass = <API key>, .bInterfaceProtocol = USB_CDC_PROTO_NONE, /* .iInterface = DYNAMIC */ }; static struct usb_cdc_header_desc ecm_header_desc = { .bLength = sizeof ecm_header_desc, .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, .bcdCDC = cpu_to_le16(0x0110), }; static struct usb_cdc_union_desc ecm_union_desc = { .bLength = sizeof(ecm_union_desc), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_UNION_TYPE, /* .bMasterInterface0 = DYNAMIC */ /* .bSlaveInterface0 = DYNAMIC */ }; static struct usb_cdc_ether_desc ecm_desc = { .bLength = sizeof ecm_desc, .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = <API key>, /* this descriptor actually adds value, surprise! */ /* .iMACAddress = DYNAMIC */ .<API key> = cpu_to_le32(0), /* no statistics */ .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN), .wNumberMCFilters = cpu_to_le16(0), .bNumberPowerFilters = 0, }; /* the default data interface has no endpoints ... */ static struct <API key> ecm_data_nop_intf = { .bLength = sizeof ecm_data_nop_intf, .bDescriptorType = USB_DT_INTERFACE, .bInterfaceNumber = 1, .bAlternateSetting = 0, .bNumEndpoints = 0, .bInterfaceClass = USB_CLASS_CDC_DATA, .bInterfaceSubClass = 0, .bInterfaceProtocol = 0, /* .iInterface = DYNAMIC */ }; /* ... but the "real" data interface has two bulk endpoints */ static struct <API key> ecm_data_intf = { .bLength = sizeof ecm_data_intf, .bDescriptorType = USB_DT_INTERFACE, .bInterfaceNumber = 1, .bAlternateSetting = 1, .bNumEndpoints = 2, .bInterfaceClass = USB_CLASS_CDC_DATA, .bInterfaceSubClass = 0, .bInterfaceProtocol = 0, /* .iInterface = DYNAMIC */ }; /* full speed support: */ static struct <API key> fs_ecm_notify_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(<API key>), .bInterval = 1 << <API key>, }; static struct <API key> fs_ecm_in_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, }; static struct <API key> fs_ecm_out_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = <API key>, }; static struct <API key> *ecm_fs_function[] = { /* CDC ECM control descriptors */ (struct <API key> *) &ecm_iad_descriptor, (struct <API key> *) &ecm_control_intf, (struct <API key> *) &ecm_header_desc, (struct <API key> *) &ecm_union_desc, (struct <API key> *) &ecm_desc, /* NOTE: status endpoint might need to be removed */ (struct <API key> *) &fs_ecm_notify_desc, /* data interface, altsettings 0 and 1 */ (struct <API key> *) &ecm_data_nop_intf, (struct <API key> *) &ecm_data_intf, (struct <API key> *) &fs_ecm_in_desc, (struct <API key> *) &fs_ecm_out_desc, NULL, }; /* high speed support: */ static struct <API key> hs_ecm_notify_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(<API key>), .bInterval = <API key> + 4, }; static struct <API key> hs_ecm_in_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(512), }; static struct <API key> hs_ecm_out_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(512), }; static struct <API key> *ecm_hs_function[] = { /* CDC ECM control descriptors */ (struct <API key> *) &ecm_iad_descriptor, (struct <API key> *) &ecm_control_intf, (struct <API key> *) &ecm_header_desc, (struct <API key> *) &ecm_union_desc, (struct <API key> *) &ecm_desc, /* NOTE: status endpoint might need to be removed */ (struct <API key> *) &hs_ecm_notify_desc, /* data interface, altsettings 0 and 1 */ (struct <API key> *) &ecm_data_nop_intf, (struct <API key> *) &ecm_data_intf, (struct <API key> *) &hs_ecm_in_desc, (struct <API key> *) &hs_ecm_out_desc, NULL, }; /* super speed support: */ static struct <API key> ss_ecm_notify_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(<API key>), .bInterval = <API key> + 4, }; static struct <API key> <API key> = { .bLength = sizeof <API key>, .bDescriptorType = <API key>, /* the following 3 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ .wBytesPerInterval = cpu_to_le16(<API key>), }; static struct <API key> ss_ecm_in_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(1024), }; static struct <API key> ss_ecm_out_desc = { .bLength = <API key>, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = <API key>, .wMaxPacketSize = cpu_to_le16(1024), }; static struct <API key> <API key> = { .bLength = sizeof <API key>, .bDescriptorType = <API key>, /* the following 2 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ }; static struct <API key> *ecm_ss_function[] = { /* CDC ECM control descriptors */ (struct <API key> *) &ecm_control_intf, (struct <API key> *) &ecm_header_desc, (struct <API key> *) &ecm_union_desc, (struct <API key> *) &ecm_desc, /* NOTE: status endpoint might need to be removed */ (struct <API key> *) &ss_ecm_notify_desc, (struct <API key> *) &<API key>, /* data interface, altsettings 0 and 1 */ (struct <API key> *) &ecm_data_nop_intf, (struct <API key> *) &ecm_data_intf, (struct <API key> *) &ss_ecm_in_desc, (struct <API key> *) &<API key>, (struct <API key> *) &ss_ecm_out_desc, (struct <API key> *) &<API key>, NULL, }; /* string descriptors: */ static struct usb_string ecm_string_defs[] = { [0].s = "CDC Ethernet Control Model (ECM)", [1].s = NULL /* DYNAMIC */, [2].s = "CDC Ethernet Data", [3].s = "CDC ECM", { } /* end of list */ }; static struct usb_gadget_strings ecm_string_table = { .language = 0x0409, /* en-us */ .strings = ecm_string_defs, }; static struct usb_gadget_strings *ecm_strings[] = { &ecm_string_table, NULL, }; static void ecm_do_notify(struct f_ecm *ecm) { struct usb_request *req = ecm->notify_req; struct <API key> *event; struct usb_composite_dev *cdev = ecm->port.func.config->cdev; __le32 *data; int status; /* notification already in flight? */ if (!req) return; event = req->buf; switch (ecm->notify_state) { case ECM_NOTIFY_NONE: return; case ECM_NOTIFY_CONNECT: event->bNotificationType = <API key>; if (ecm->is_open) event->wValue = cpu_to_le16(1); else event->wValue = cpu_to_le16(0); event->wLength = 0; req->length = sizeof *event; DBG(cdev, "notify connect %s\n", ecm->is_open ? "true" : "false"); ecm->notify_state = ECM_NOTIFY_SPEED; break; case ECM_NOTIFY_SPEED: event->bNotificationType = <API key>; event->wValue = cpu_to_le16(0); event->wLength = cpu_to_le16(8); req->length = <API key>; /* SPEED_CHANGE data is up/down speeds in bits/sec */ data = req->buf + sizeof *event; data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget)); data[1] = data[0]; DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget)); ecm->notify_state = ECM_NOTIFY_NONE; break; } event->bmRequestType = 0xA1; event->wIndex = cpu_to_le16(ecm->ctrl_id); ecm->notify_req = NULL; status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC); if (status < 0) { ecm->notify_req = req; DBG(cdev, "notify --> %d\n", status); } } static void ecm_notify(struct f_ecm *ecm) { /* NOTE on most versions of Linux, host side cdc-ethernet * won't listen for notifications until its netdevice opens. * The first notification then sits in the FIFO for a long * time, and the second one is queued. */ ecm->notify_state = ECM_NOTIFY_CONNECT; ecm_do_notify(ecm); } static void ecm_notify_complete(struct usb_ep *ep, struct usb_request *req) { struct f_ecm *ecm = req->context; struct usb_composite_dev *cdev = ecm->port.func.config->cdev; struct <API key> *event = req->buf; switch (req->status) { case 0: /* no fault */ break; case -ECONNRESET: case -ESHUTDOWN: ecm->notify_state = ECM_NOTIFY_NONE; break; default: DBG(cdev, "event %02x event->bNotificationType, req->status); break; } ecm->notify_req = req; ecm_do_notify(ecm); } static int ecm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) { struct f_ecm *ecm = func_to_ecm(f); struct usb_composite_dev *cdev = f->config->cdev; struct usb_request *req = cdev->req; int value = -EOPNOTSUPP; u16 w_index = le16_to_cpu(ctrl->wIndex); u16 w_value = le16_to_cpu(ctrl->wValue); u16 w_length = le16_to_cpu(ctrl->wLength); /* composite driver infrastructure handles everything except * CDC class messages; interface activation uses set_alt(). */ switch ((ctrl->bRequestType << 8) | ctrl->bRequest) { case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) | <API key>: /* see 6.2.30: no data, wIndex = interface, * wValue = packet filter bitmap */ if (w_length != 0 || w_index != ecm->ctrl_id) goto invalid; DBG(cdev, "packet filter %02x\n", w_value); /* REVISIT locking of cdc_filter. This assumes the UDC * driver won't have a concurrent packet TX irq running on * another CPU; or that if it does, this write is atomic... */ ecm->port.cdc_filter = w_value; value = 0; break; /* and optionally: * case <API key>: * case <API key>: * case <API key>: * case <API key>: * case <API key>: * case <API key>: */ default: invalid: DBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n", ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); } /* respond with data transfer or status phase? */ if (value >= 0) { DBG(cdev, "ecm req%02x.%02x v%04x i%04x l%d\n", ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); req->zero = 0; req->length = value; value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); if (value < 0) ERROR(cdev, "ecm req %02x.%02x response err %d\n", ctrl->bRequestType, ctrl->bRequest, value); } /* device either stalls (value < 0) or reports success */ return value; } static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_ecm *ecm = func_to_ecm(f); struct usb_composite_dev *cdev = f->config->cdev; /* Control interface has only altsetting 0 */ if (intf == ecm->ctrl_id) { if (alt != 0) goto fail; if (ecm->notify->driver_data) { VDBG(cdev, "reset ecm control %d\n", intf); usb_ep_disable(ecm->notify); } if (!(ecm->notify->desc)) { VDBG(cdev, "init ecm ctrl %d\n", intf); if (config_ep_by_speed(cdev->gadget, f, ecm->notify)) goto fail; } usb_ep_enable(ecm->notify); ecm->notify->driver_data = ecm; /* Data interface has two altsettings, 0 and 1 */ } else if (intf == ecm->data_id) { if (alt > 1) goto fail; if (ecm->port.in_ep->driver_data) { DBG(cdev, "reset ecm\n"); gether_disconnect(&ecm->port); } if (!ecm->port.in_ep->desc || !ecm->port.out_ep->desc) { DBG(cdev, "init ecm\n"); if (config_ep_by_speed(cdev->gadget, f, ecm->port.in_ep) || config_ep_by_speed(cdev->gadget, f, ecm->port.out_ep)) { ecm->port.in_ep->desc = NULL; ecm->port.out_ep->desc = NULL; goto fail; } } /* CDC Ethernet only sends data in non-default altsettings. * Changing altsettings resets filters, statistics, etc. */ if (alt == 1) { struct net_device *net; /* Enable zlps by default for ECM conformance; * override for musb_hdrc (avoids txdma ovhead). */ ecm->port.is_zlp_ok = !(gadget_is_musbhdrc(cdev->gadget) ); ecm->port.cdc_filter = DEFAULT_FILTER; DBG(cdev, "activate ecm\n"); net = gether_connect(&ecm->port); if (IS_ERR(net)) return PTR_ERR(net); } /* NOTE this can be a minor disagreement with the ECM spec, * which says speed notifications will "always" follow * connection notifications. But we allow one connect to * follow another (if the first is in flight), and instead * just guarantee that a speed notification is always sent. */ ecm_notify(ecm); } else goto fail; return 0; fail: return -EINVAL; } /* Because the data interface supports multiple altsettings, * this ECM function *MUST* implement a get_alt() method. */ static int ecm_get_alt(struct usb_function *f, unsigned intf) { struct f_ecm *ecm = func_to_ecm(f); if (intf == ecm->ctrl_id) return 0; return ecm->port.in_ep->driver_data ? 1 : 0; } static void ecm_disable(struct usb_function *f) { struct f_ecm *ecm = func_to_ecm(f); struct usb_composite_dev *cdev = f->config->cdev; DBG(cdev, "ecm deactivated\n"); if (ecm->port.in_ep->driver_data) gether_disconnect(&ecm->port); if (ecm->notify->driver_data) { usb_ep_disable(ecm->notify); ecm->notify->driver_data = NULL; ecm->notify->desc = NULL; } } /* * Callbacks let us notify the host about connect/disconnect when the * net device is opened or closed. * * For testing, note that link states on this side include both opened * and closed variants of: * * - disconnected/unconfigured * - configured but inactive (data alt 0) * - configured and active (data alt 1) * * Each needs to be tested with unplug, rmmod, SET_CONFIGURATION, and * SET_INTERFACE (altsetting). Remember also that "configured" doesn't * imply the host is actually polling the notification endpoint, and * likewise that "active" doesn't imply it's actually using the data * endpoints for traffic. */ static void ecm_open(struct gether *geth) { struct f_ecm *ecm = func_to_ecm(&geth->func); DBG(ecm->port.func.config->cdev, "%s\n", __func__); ecm->is_open = true; ecm_notify(ecm); } static void ecm_close(struct gether *geth) { struct f_ecm *ecm = func_to_ecm(&geth->func); DBG(ecm->port.func.config->cdev, "%s\n", __func__); ecm->is_open = false; ecm_notify(ecm); } /* ethernet function driver setup/binding */ static int ecm_bind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c->cdev; struct f_ecm *ecm = func_to_ecm(f); int status; struct usb_ep *ep; /* allocate instance-specific interface IDs */ status = usb_interface_id(c, f); if (status < 0) goto fail; ecm->ctrl_id = status; ecm_iad_descriptor.bFirstInterface = status; ecm_control_intf.bInterfaceNumber = status; ecm_union_desc.bMasterInterface0 = status; status = usb_interface_id(c, f); if (status < 0) goto fail; ecm->data_id = status; ecm_data_nop_intf.bInterfaceNumber = status; ecm_data_intf.bInterfaceNumber = status; ecm_union_desc.bSlaveInterface0 = status; status = -ENODEV; /* allocate instance-specific endpoints */ ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc); if (!ep) goto fail; ecm->port.in_ep = ep; ep->driver_data = cdev; /* claim */ ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc); if (!ep) goto fail; ecm->port.out_ep = ep; ep->driver_data = cdev; /* claim */ /* NOTE: a status/notification endpoint is *OPTIONAL* but we * don't treat it that way. It's simpler, and some newer CDC * profiles (wireless handsets) no longer treat it as optional. */ ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc); if (!ep) goto fail; ecm->notify = ep; ep->driver_data = cdev; /* claim */ status = -ENOMEM; /* allocate notification request and buffer */ ecm->notify_req = <API key>(ep, GFP_KERNEL); if (!ecm->notify_req) goto fail; ecm->notify_req->buf = kmalloc(<API key>, GFP_KERNEL); if (!ecm->notify_req->buf) goto fail; ecm->notify_req->context = ecm; ecm->notify_req->complete = ecm_notify_complete; /* support all relevant hardware speeds... we expect that when * hardware is dual speed, all bulk-capable endpoints work at * both speeds */ hs_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; hs_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; hs_ecm_notify_desc.bEndpointAddress = fs_ecm_notify_desc.bEndpointAddress; ss_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; ss_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; ss_ecm_notify_desc.bEndpointAddress = fs_ecm_notify_desc.bEndpointAddress; status = <API key>(f, ecm_fs_function, ecm_hs_function, ecm_ss_function); if (status) goto fail; /* NOTE: all that is done without knowing or caring about * the network link ... which is unavailable to this code * until we're activated via set_alt(). */ ecm->port.open = ecm_open; ecm->port.close = ecm_close; DBG(cdev, "CDC Ethernet: %s speed IN/%s OUT/%s NOTIFY/%s\n", <API key>(c->cdev->gadget) ? "super" : gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", ecm->port.in_ep->name, ecm->port.out_ep->name, ecm->notify->name); return 0; fail: if (ecm->notify_req) { kfree(ecm->notify_req->buf); usb_ep_free_request(ecm->notify, ecm->notify_req); } /* we might as well release our claims on endpoints */ if (ecm->notify) ecm->notify->driver_data = NULL; if (ecm->port.out_ep->desc) ecm->port.out_ep->driver_data = NULL; if (ecm->port.in_ep->desc) ecm->port.in_ep->driver_data = NULL; ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); return status; } static void ecm_unbind(struct usb_configuration *c, struct usb_function *f) { struct f_ecm *ecm = func_to_ecm(f); DBG(c->cdev, "ecm unbind\n"); <API key>(f); kfree(ecm->notify_req->buf); usb_ep_free_request(ecm->notify, ecm->notify_req); ecm_string_defs[1].s = NULL; kfree(ecm); } /** * ecm_bind_config - add CDC Ethernet network link to a configuration * @c: the configuration to support the network link * @ethaddr: a buffer in which the ethernet address of the host side * side of the link was recorded * Context: single threaded during gadget setup * * Returns zero on success, else negative errno. * * Caller must have called @gether_setup(). Caller is also responsible * for calling @gether_cleanup() before module unload. */ int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) { struct f_ecm *ecm; int status; if (!can_support_ecm(c->cdev->gadget) || !ethaddr) return -EINVAL; /* maybe allocate device-global string IDs */ if (ecm_string_defs[0].id == 0) { /* control interface label */ status = usb_string_id(c->cdev); if (status < 0) return status; ecm_string_defs[0].id = status; ecm_control_intf.iInterface = status; /* data interface label */ status = usb_string_id(c->cdev); if (status < 0) return status; ecm_string_defs[2].id = status; ecm_data_intf.iInterface = status; /* MAC address */ status = usb_string_id(c->cdev); if (status < 0) return status; ecm_string_defs[1].id = status; ecm_desc.iMACAddress = status; /* IAD label */ status = usb_string_id(c->cdev); if (status < 0) return status; ecm_string_defs[3].id = status; ecm_iad_descriptor.iFunction = status; } /* allocate and initialize one new instance */ ecm = kzalloc(sizeof *ecm, GFP_KERNEL); if (!ecm) return -ENOMEM; /* export host's Ethernet address in CDC format */ snprintf(ecm->ethaddr, sizeof ecm->ethaddr, "%02X%02X%02X%02X%02X%02X", ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]); ecm_string_defs[1].s = ecm->ethaddr; ecm->port.cdc_filter = DEFAULT_FILTER; ecm->port.func.name = "cdc_ethernet"; ecm->port.func.strings = ecm_strings; /* descriptors are per-instance copies */ ecm->port.func.bind = ecm_bind; ecm->port.func.unbind = ecm_unbind; ecm->port.func.set_alt = ecm_set_alt; ecm->port.func.get_alt = ecm_get_alt; ecm->port.func.setup = ecm_setup; ecm->port.func.disable = ecm_disable; status = usb_add_function(c, &ecm->port.func); if (status) { ecm_string_defs[1].s = NULL; kfree(ecm); } return status; }
#ifndef __USB3503_H__ #define __USB3503_H__ #define USB3503_I2C_NAME "usb3503" enum usb3503_mode { <API key>, USB3503_MODE_HUB, <API key>, }; enum usb3503_ref_clk { USB3503_REFCLK_24M, USB3503_REFCLK_26M, }; struct <API key> { enum usb3503_mode initial_mode; enum usb3503_ref_clk ref_clk; int gpio_intn; int gpio_connect; int gpio_reset; }; #endif
#include "async.h" class my_resizer_t : public vec_resizer_t { public: my_resizer_t () : vec_resizer_t () {} size_t resize (u_int nalloc, u_int nwanted, int objid); }; size_t my_resizer_t::resize (u_int nalloc, u_int nwanted, int objid) { int exponent = fls (max (nalloc, nwanted)); int step; if (exponent < 3) step = 1; else if (exponent < 8) step = 3; else if (exponent < 10) step = 2; else step = 1; exponent = ((exponent - 1) / step + 1) * step; size_t ret = 1 << exponent; // If you want to know the pattern... warn << "resize: " << nalloc << "," << nwanted << "," << objid << " -> " << ret << "\n"; return ret; } template<> struct vec_obj_id_t<int> { vec_obj_id_t (){} int operator() (void) const { return 1; } }; static void vec_test (vec<int> &v, int n) { for (int i = 0; i < n; i++) { v.push_back (i); } for (int i = n - 1; i >= 0; i assert (v.pop_back () == i); } } static void vec_test (void) { vec<int> v1, v2; int n = 100; vec_test (v1, n); set_vec_resizer (New my_resizer_t ()); vec_test (v2, n); } int main (int argc, char *argv[]) { vec_test (); return 0; }
#include "NWNXDefenses.h" int <API key>(CNWSCreatureStats *target, uint8_t immtype, CNWSCreature *attacker) { return -1; } /* vim: set sw=4: */
/*! \file spibusdrv.c \brief spi bus driver module This file contains implementation of the spi bus driver. */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <asm/cacheflush.h> #include "smscoreapi.h" #include "smsdbg_prn.h" #include "smsspicommon.h" #include "smsspiphy.h" #ifdef MTK_SPI #include <linux/delay.h> #include <mach/eint.h> #include <cust_eint.h> #include <mach/irqs.h> #include <linux/io.h> //debug struct SMSDev_data { dev_t devt; spinlock_t spi_lock; struct spi_device *spi; struct list_head device_entry; struct mutex buf_lock; unsigned char users; u8 *tx_buf; u8 *rx_buf; }; extern struct SMSDev_data* SMSDev; #endif //MTK_SPI #ifdef CONFIG_SMP static struct workqueue_struct *spi_thread_wq=NULL; static struct work_struct spi_thread_work; #endif #define SMS_INTR_PIN 16 /* 0 for nova sip, 26 for vega */ #define TX_BUFFER_SIZE 0x200 //#define RX_BUFFER_SIZE (0x1000 + SPI_PACKET_SIZE + 0x100) #define NUM_RX_BUFFERS 72 struct _spi_device_st { struct _spi_dev dev; void *phy_dev; struct completion write_operation; struct list_head tx_queue; int allocatedPackets; int padding_allowed; char *rxbuf; struct smscore_device_t *coredev; struct list_head txqueue; char *txbuf; dma_addr_t txbuf_phy_addr; }; struct _smsspi_txmsg { struct list_head node; /*! internal management */ void *buffer; size_t size; int alignment; int add_preamble; struct completion completion; void (*prewrite) (void *); void (*postwrite) (void *); }; struct _Msg { struct SmsMsgHdr_ST hdr; u32 data[3]; }; struct _spi_device_st *spi_dev; #ifdef CONFIG_SMP static void spi_worker_thread(struct work_struct *work); #else static void spi_worker_thread(void *arg); static DECLARE_WORK(spi_work_queue, (void *)spi_worker_thread); #endif static u8 smsspi_preamble[] = { 0xa5, 0x5a, 0xe7, 0x7e }; static u8 smsspi_startup[] = { 0, 0, 0xde, 0xc1, 0xa5, 0x51, 0xf1, 0xed }; static u32 default_type = SMS_NOVA_B0; static u32 intr_pin = SMS_INTR_PIN; //static u32 intCount = 0; not used module_param(default_type, int, 0644); MODULE_PARM_DESC(default_type, "default board type."); module_param(intr_pin, int, 0644); MODULE_PARM_DESC(intr_pin, "interrupt pin number."); #ifdef CONFIG_SMP static void spi_worker_thread(struct work_struct *work) #else static void spi_worker_thread(void *arg) #endif { struct _spi_device_st *spi_device = spi_dev; struct _smsspi_txmsg *msg = NULL; struct _spi_msg txmsg; //sms_info("worker start"); do { /* do we have a msg to write ? */ if (!msg && !list_empty(&spi_device->txqueue)) msg = (struct _smsspi_txmsg *) list_entry(spi_device->txqueue. next, struct _smsspi_txmsg, node); if (msg) { if (msg->add_preamble) { txmsg.len = min(msg->size + sizeof(smsspi_preamble), (size_t) TX_BUFFER_SIZE); txmsg.buf = spi_device->txbuf; txmsg.buf_phy_addr = spi_device->txbuf_phy_addr; memcpy(txmsg.buf, smsspi_preamble, sizeof(smsspi_preamble)); memcpy(&txmsg.buf[sizeof(smsspi_preamble)], msg->buffer, txmsg.len - sizeof(smsspi_preamble)); msg->add_preamble = 0; msg->buffer += txmsg.len - sizeof(smsspi_preamble); msg->size -= txmsg.len - sizeof(smsspi_preamble); /* zero out the rest of aligned buffer */ memset(&txmsg.buf[txmsg.len], 0, TX_BUFFER_SIZE - txmsg.len); <API key>(&spi_device->dev, &txmsg, 1); } else { txmsg.len = min(msg->size, (size_t) TX_BUFFER_SIZE); txmsg.buf = spi_device->txbuf; txmsg.buf_phy_addr = spi_device->txbuf_phy_addr; memcpy(txmsg.buf, msg->buffer, txmsg.len); msg->buffer += txmsg.len; msg->size -= txmsg.len; /* zero out the rest of aligned buffer */ memset(&txmsg.buf[txmsg.len], 0, TX_BUFFER_SIZE - txmsg.len); <API key>(&spi_device->dev, &txmsg, 0); } } else { <API key>(&spi_device->dev, NULL, 1); } /* if there was write, have we finished ? */ if (msg && !msg->size) { /* call postwrite call back */ if (msg->postwrite) msg->postwrite(spi_device); list_del(&msg->node); complete(&msg->completion); msg = NULL; } /* if there was read, did we read anything ? */ } while (!list_empty(&spi_device->txqueue) || msg); //sms_info("worker end"); } static void msg_found(void *context, void *buf, int offset, int len) { struct _spi_device_st *spi_device = (struct _spi_device_st *) context; struct smscore_buffer_t *cb = (struct smscore_buffer_t *)(container_of(buf, struct smscore_buffer_t, p)); PDEBUG("entering\n"); cb->offset = offset; cb->size = len; /* PERROR ("buffer %p is sent back to core databuf=%p, offset=%d.\n", cb, cb->p, cb->offset); */ smscore_onresponse(spi_device->coredev, cb); PDEBUG("exiting\n"); } //static void smsspi_int_handler(void *context) static void smsspi_int_handler(void ) { //struct _spi_device_st *spi_device = (struct _spi_device_st *) context; // PDEBUG("interrupt\n"); // sms_info("**Interrupt %d", intCount++); #ifdef CONFIG_SMP queue_work(spi_thread_wq, &spi_thread_work); #else PREPARE_WORK(&spi_work_queue, (void *)spi_worker_thread); schedule_work(&spi_work_queue); #endif #ifdef MTK_SPI mt65xx_eint_unmask(CUST_EINT_CMMB_NUM); #endif } static int <API key>(struct _spi_device_st *spi_device, struct _smsspi_txmsg *msg) { init_completion(&msg->completion); list_add_tail(&msg->node, &spi_device->txqueue); #ifdef CONFIG_SMP queue_work(spi_thread_wq, &spi_thread_work); #else schedule_work(&spi_work_queue); #endif wait_for_completion(&msg->completion); return 0; } #if 0 struct _smsspi_txmsg *msg=NULL; struct _Msg *Msg=NULL; #endif static int smsspi_preload(void *context) { #if 1 struct _smsspi_txmsg msg; struct _spi_device_st *spi_device = (struct _spi_device_st *) context; /* struct _Msg Msg = { { <API key>, 0, HIF_TASK, sizeof(struct _Msg), 0}, { 0, intr_pin, 0} };*/ struct _Msg Msg = { { <API key>, 151, HIF_TASK, sizeof(struct _Msg), 0}, { 0, 4, 400} }; int rc; prepareForFWDnl(spi_device->phy_dev); sms_info("Sending SPI init sequence"); msg.buffer = smsspi_startup; msg.size = sizeof(smsspi_startup); msg.alignment = 4; msg.add_preamble = 0; msg.prewrite = NULL; /* <API key>; */ msg.postwrite = NULL; /* <API key>; */ rc = <API key>(context, &msg); if (rc < 0) { sms_err("<API key> error, rc = %d\n", rc); return rc; } sms_debug("sending <API key>"); msg.buffer = &Msg; msg.size = sizeof(Msg); msg.alignment = SPI_PACKET_SIZE; msg.add_preamble = 1; rc = <API key>(context, &msg); if (rc < 0) { sms_err("set interrupt line failed, rc = %d\n", rc); return rc; } #else void* buf_1=(void*) SMSDev->tx_buf; void* buf_2 =(void*)SMSDev->rx_buf ; struct _spi_device_st *spi_device = (struct _spi_device_st *) context; int rc; //buf_1 = kmalloc(sizeof(struct _smsspi_txmsg) + SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); //buf_2 = kmalloc(sizeof(struct _Msg) + SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); if((buf_1) &&(buf_2)) { msg = (struct _smsspi_txmsg *)SMS_ALIGN_ADDRESS(buf_1); Msg = (struct _Msg *)SMS_ALIGN_ADDRESS(buf_2); Msg->hdr.msgType = <API key>; Msg->hdr.msgSrcId = 151; Msg->hdr.msgDstId = HIF_TASK; Msg->hdr.msgLength = sizeof(struct _Msg); Msg->hdr.msgFlags = 0; Msg->data[0] = 0; Msg->data[1] = 4; Msg->data[2] = 400; prepareForFWDnl(spi_device->phy_dev); sms_info("Sending SPI init sequence"); msg->buffer = smsspi_startup; msg->size = sizeof(smsspi_startup); msg->alignment = 4; msg->add_preamble = 0; msg->prewrite = NULL; /* <API key>; */ msg->postwrite = NULL; /* <API key>; */ sms_log("**msg=%4x",msg); rc = <API key>(context, msg); if (rc < 0) { sms_err("<API key> error, rc = %d\n", rc); return rc; } sms_debug("sending <API key>"); sms_info("Sending SPI Set Interrupt command sequence"); msg->buffer = Msg; msg->size = sizeof(struct _Msg); msg->alignment = SPI_PACKET_SIZE; msg->add_preamble = 1; sms_log("**msg=%4x",msg); rc = <API key>(context, msg); if (rc < 0) { sms_err("set interrupt line failed, rc = %d\n", rc); return rc; } } //kfree(buf_1); //kfree(buf_2); #endif return rc; } static int smsspi_postload(void *context) { struct _spi_device_st *spi_device = (struct _spi_device_st *) context; int mode = <API key>(spi_device->coredev->devpath); if ( (mode != DEVICE_MODE_ISDBT) && (mode != <API key>) ) { fwDnlComplete(spi_device->phy_dev, 0); } return 0; } static int smsspi_write(void *context, void *txbuf, size_t len) { struct _smsspi_txmsg msg; msg.buffer = txbuf; msg.size = len; msg.prewrite = NULL; msg.postwrite = NULL; //int msgLen, i; not used if (len > 0x1000) { /* The FW is the only long message. Do not add preamble, and do not padd it */ msg.alignment = 4; msg.add_preamble = 0; msg.prewrite = smschipreset; } else { msg.alignment = SPI_PACKET_SIZE; msg.add_preamble = 1; } // sms_info("Writing message to SPI.\n"); /* u8 * t_txbuf =(u8*)txbuf; sms_info("msg hdr: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x.\n", ((u8 *) t_txbuf)[0], ((u8 *) t_txbuf)[1], ((u8 *) t_txbuf)[2], ((u8 *) t_txbuf)[3], ((u8 *) t_txbuf)[4], ((u8 *) t_txbuf)[5], ((u8 *) t_txbuf)[6], ((u8 *) t_txbuf)[7]); msgLen = (t_txbuf[5]<<8) + t_txbuf[4]; if((t_txbuf[0]==0x6C) && (t_txbuf[1]==0x03)) { sms_info("jackz, Set CW REQ, len: %d, payload:", msgLen); for(i=0; i<(msgLen-8); i++) { sms_info("0x%x ", t_txbuf[8+i]); } } if((t_txbuf[0]==0x6E) && (t_txbuf[1]==0x03)) { sms_info("jackz, Set SaltKey REQ, len: %d, payload:", msgLen); for(i=0; i<(msgLen-8); i++) { sms_info("0x%x ", t_txbuf[8+i]); } } */ sms_info("Send msg type: %d", (((u8 *) txbuf)[1]<<8) + ((u8 *) txbuf)[0]); return <API key>(context, &msg); } struct _rx_buffer_st *allocate_rx_buf(void *context, int size) { struct smscore_buffer_t *buf; struct _spi_device_st *spi_device = (struct _spi_device_st *) context; if (size > RX_BUFFER_SIZE) { PERROR("Requested size is bigger than max buffer size.\n"); return NULL; } buf = smscore_getbuffer(spi_device->coredev); PDEBUG("Recieved Rx buf %p physical 0x%x (contained in %p)\n", buf->p, buf->phys, buf); flush_cache_all(); /* note: this is not mistake! the rx_buffer_st is identical to part of smscore_buffer_t and we return the address of the start of the identical part */ return (struct _rx_buffer_st *) &buf->p; } static void free_rx_buf(void *context, struct _rx_buffer_st *buf) { struct _spi_device_st *spi_device = (struct _spi_device_st *) context; struct smscore_buffer_t *cb = (struct smscore_buffer_t *)(container_of(((void *)buf), struct smscore_buffer_t, p)); PDEBUG("buffer %p is released.\n", cb); smscore_putbuffer(spi_device->coredev, cb); } /*! Release device STUB \param[in] dev: device control block \return void */ static void smsspi_release(struct device *dev) { PDEBUG("nothing to do\n"); /* Nothing to release */ } static struct platform_device smsspi_device = { .name = "smsspi", .id = 1, .dev = { .release = smsspi_release, }, }; int smsspi_register(void) { struct smsdevice_params_t params; int ret; struct _spi_device_st *spi_device; struct _spi_dev_cb_st common_cb; PDEBUG("entering \n"); #ifdef CONFIG_SMP sms_info("create a signelthread workqueue"); spi_thread_wq = <API key>("siano work wq"); INIT_WORK(&spi_thread_work, spi_worker_thread); #endif spi_device = kmalloc(sizeof(struct _spi_device_st), GFP_KERNEL); spi_dev = spi_device; INIT_LIST_HEAD(&spi_device->txqueue); ret = <API key>(&smsspi_device); if (ret < 0) { PERROR("<API key> failed\n"); return ret; } #if 0 //buf issue 1214 spi_device->txbuf = dma_alloc_coherent(NULL, TX_BUFFER_SIZE, &spi_device->txbuf_phy_addr, GFP_KERNEL | GFP_DMA); #else spi_device->txbuf =kmalloc(TX_BUFFER_SIZE, GFP_KERNEL); spi_device->txbuf_phy_addr = (u32)spi_device->txbuf; //? check txbuf_phy_addr is use or not printk("**** spi_dev->txbuf = 0x %4x",(unsigned int)spi_dev->txbuf); #endif if (!spi_device->txbuf) { printk(KERN_INFO "%s dma_alloc_coherent(...) failed\n", __func__); ret = -ENOMEM; goto txbuf_error; } spi_device->phy_dev = smsspiphy_init(NULL, smsspi_int_handler, (void*)spi_device); if (spi_device->phy_dev == 0) { printk(KERN_INFO "%s smsspiphy_init(...) failed\n", __func__); //goto phy_error; } common_cb.allocate_rx_buf = allocate_rx_buf; common_cb.free_rx_buf = free_rx_buf; common_cb.msg_found_cb = msg_found; common_cb.transfer_data_cb = smsspibus_xfer; ret = smsspicommon_init(&spi_device->dev, spi_device, spi_device->phy_dev, &common_cb); if (ret) { printk(KERN_INFO "%s smsspiphy_init(...) failed\n", __func__); goto common_error; } /* register in smscore */ memset(&params, 0, sizeof(params)); params.context = spi_device; params.device = &smsspi_device.dev; params.buffer_size = RX_BUFFER_SIZE; params.num_buffers = NUM_RX_BUFFERS; params.flags = <API key>; params.sendrequest_handler = smsspi_write; strcpy(params.devpath, "spi"); params.device_type = default_type; if (0) { /* device family */ /* params.setmode_handler = smsspi_setmode; */ } else { params.flags = SMS_DEVICE_FAMILY2 | <API key>; params.preload_handler = smsspi_preload; params.postload_handler = smsspi_postload; } ret = <API key>(&params, &spi_device->coredev); if (ret < 0) { printk(KERN_INFO "%s <API key>(...) failed\n", __func__); goto reg_device_error; } ret = <API key>(spi_device->coredev); if (ret < 0) { printk(KERN_INFO "%s <API key>(...) failed\n", __func__); goto start_device_error; } PDEBUG("exiting\n"); return 0; start_device_error: <API key>(spi_device->coredev); reg_device_error: common_error: smsspiphy_deinit(spi_device->phy_dev); #if 0 // not used phy_error: #if 0 //buf issue 1214 /*dma_free_coherent(NULL, TX_BUFFER_SIZE, spi_device->txbuf, spi_device->txbuf_phy_addr);*/ #else kfree(spi_device->txbuf); #endif #endif txbuf_error: <API key>(&smsspi_device); PDEBUG("exiting error %d\n", ret); return ret; } void smsspi_unregister(void) { struct _spi_device_st *spi_device = spi_dev; PDEBUG("entering\n"); /* stop interrupts */ smsspiphy_deinit(spi_device->phy_dev); <API key>(spi_device->coredev); #if 0 //buf issue 1214 dma_free_coherent(NULL, TX_BUFFER_SIZE, spi_device->txbuf, spi_device->txbuf_phy_addr); #else kfree(spi_device->txbuf); #endif #ifdef CONFIG_SMP destroy_workqueue(spi_thread_wq); #endif <API key>(&smsspi_device); PDEBUG("exiting\n"); }
#ifndef KSYCOCADICT_H #define KSYCOCADICT_H #include <kdecore_export.h> #include "ksycocaentry.h" #include <QList> class QString; class QDataStream; /** * @internal * Hash table implementation for the sycoca database file * * Only exported for the unit test */ class KDECORE_EXPORT KSycocaDict //krazy:exclude=dpointer (not const because it gets deleted by clear()) { public: /** * Create an empty dict, for building the database */ KSycocaDict(); /** * Create a dict from an existing database */ KSycocaDict(QDataStream *str, int offset); ~KSycocaDict(); /** * Adds a 'payload' to the dictionary with key 'key'. * * 'payload' should have a valid offset by the time * the dictionary gets saved. **/ void add(const QString &key, const KSycocaEntry::Ptr& payload); /** * Removes the 'payload' from the dictionary with key 'key'. * * Not very fast, use with care O(N) **/ void remove(const QString &key); /** * Looks up an entry identified by 'key'. * * If 0 is returned, no matching entry exists. * Otherwise, the offset of the entry is returned. * * NOTE: It is not guaranteed that this entry is * indeed the one you were looking for. * After loading the entry you should check that it * indeed matches the search key. If it doesn't * then no matching entry exists. */ int find_string(const QString &key ) const; /** * Looks up all entries identified by 'key'. * This is useful when the dict is used as a multi-hash. * * If an empty list is returned, no matching entry exists. * Otherwise, the offset of the matching entries are returned. * * NOTE: It is not guaranteed that each entry is * indeed among the ones you were looking for. * After loading each entry you should check that it * indeed matches the search key. */ QList<int> findMultiString(const QString &key ) const; /** * The number of entries in the dictionary. * * Only valid when building the database. */ uint count() const; /** * Reset the dictionary. * * Only valid when building the database. */ void clear(); /** * Save the dictionary to the stream * A reasonable fast hash algorithm will be created. * * Typically this will find 90% of the entries directly. * Average hash table size: nrOfItems * 20 bytes. * Average duplicate list size: nrOfItms * avgKeyLength / 5. * * Unknown keys have an average 20% chance to give a false hit. * (That's why your program should check the result) * * Example: * Assume 1000 items with an average key length of 60 bytes. * * Approx. 900 items will hash directly to the right entry. * Approx. 100 items require a lookup in the duplicate list. * * The hash table size will be approx. 20Kb. * The duplicate list size will be approx. 12Kb. **/ void save(QDataStream &str); private: Q_DISABLE_COPY(KSycocaDict) class Private; Private* d; }; #endif
//This code is part of a larger project whose main purpose is to entretain either // //by working on it and helping it be better or by playing it in it's actual state // // This program is free software; you can redistribute it and/or modify // // the Free Software Foundation; either version 2, or (at your option) // // any later version. // // This program is distributed in the hope that it will be useful, // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // along with this program; if not, write to the Free Software Foundation, // // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // You can contact us at projectpgz.blogspot.com // #include "iPushable.h" iPushable::iPushable(){ init(stepPushDist, useConstraints); } iPushable::iPushable(int stepPushDist, bool useConstraints){ init(stepPushDist, useConstraints); } void iPushable::init(int stepPushDist, bool useConstraints){ this->stepPushDist = stepPushDist; this->useConstraints = useConstraints; locked = false; } iPushable::~iPushable(){ } std::pair<int, int> iPushable::onPush(Entity *ent, Direction dir){ // mover en base al stepPushDist si no estamos locked if(!locked){ // Mover en las direcciones aceptadas por los constraints if(useConstraints) if(pushConstraints.find(dir) != pushConstraints.end()){ return move(ent, dir); } else return make_pair(0, 0); // Mover sin restricciones return move(ent, dir); } return make_pair(0, 0); } void iPushable::lockPush(){ locked = true; } void iPushable::unlockPush(){ locked = false; } bool iPushable::isLockedPush(){ return locked; } void iPushable::setConstraints(set<Direction> pushConstrains){ this->pushConstraints = pushConstrains; useConstraints = true; } std::pair<int, int> iPushable::move(Entity *ent, Direction dir){ int xtemp, ytemp; int xorig, yorig; xorig = ent->x; yorig = ent->y; switch (dir) { case UP: xtemp = ent->x; ytemp = ent->y-stepPushDist; break; case DOWN: xtemp = ent->x; ytemp = ent->y+stepPushDist; break; case LEFT: xtemp = ent->x-stepPushDist; ytemp = ent->y; break; case RIGHT: xtemp = ent->x+stepPushDist; ytemp = ent->y; break; } if (xtemp == ent->x && ytemp == ent->y) return make_pair(0, 0); /*if (ent->world->place_free(ent->x, ytemp, ent)){ ent->y = ytemp; } else{ ent->world->moveToContact(ent->x,ytemp, ent); } if (ent->world->place_free(xtemp, ent->y, ent)){ ent->x = xtemp; } else{ ent->world->moveToContact(xtemp,ent->y, ent); }*/ if (!ent->world->place_free(xtemp, ytemp, ent)) ent->world->moveToContact(xtemp, ytemp, ent); else ent->x = xtemp, ent->y = ytemp; return make_pair(abs(ent->x - xorig), abs(ent-> y - yorig)); }
package javax.xml.bind.annotation; public enum XmlAccessType { FIELD, NONE, PROPERTY, PUBLIC_MEMBER; }
# This program is free software; you can redistribute it and/or modify # (at your option) any later version. # This program is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class WatchDirectoryKey < ActiveRecord::Migration def self.up add_column :servers, :directory_info_id, :integer remove_column :servers, :watch_directory end def self.down add_column :servers, :watch_directory, :string, :default => "", :null => false remove_column :servers, :directory_info_id end end
#include "product_config.h" #include "vos.h" #include "Taf_Tafm_Remote.h" #include "UsimPsInterface.h" #include "Ssa_Define.h" #include "MnCall.h" #include "Taf_Aps.h" #include "TafMmcInterface.h" #include "MnMsgExt.h" #include "UsimPsInterface.h" #include "MnComm.h" #include "siapppih.h" #include "MnCallTimer.h" #include "RabmTafInterface.h" #include "MmaAppLocal.h" #include "TafDrvAgentMain.h" #include "MnCallReqProc.h" #include "TafApsMain.h" #include "MnCallCtx.h" #include "MnCallProcNvim.h" #include "<API key>.h" #include "<API key>.h" #include "TafMtaMain.h" #include "TafSdcCtx.h" #include "TafSpmMain.h" #include "MnMsgSmCommProc.h" #include "NasUsimmApi.h" #include "TafCbaProcUsim.h" #include "MnCallImsaProc.h" #include "TafMntn.h" #ifdef __cplusplus #if __cplusplus extern "C"{ #endif #endif extern VOS_VOID R_ITF_InitFlowCtrl(VOS_VOID); #define THIS_FILE_ID <API key> VOS_VOID <API key>( struct MsgCB *pstAppMsg ); VOS_UINT8 g_ucMnOmConnectFlg = VOS_FALSE; VOS_UINT8 <API key> = VOS_FALSE; <API key> <API key>[] = { {STK_MSG_SEND_REQ, <API key>, MN_MSG_ProcAppSend}, {<API key>, <API key>, <API key>}, {<API key>, <API key>, <API key>}, {<API key>, <API key>, <API key>}, {<API key>, <API key>, <API key>}, {<API key>, <API key>, MN_SndAppMsgToSs}, {STK_SS_ERASESS_REQ, TAF_MSG_ERASESS_MSG, MN_SndAppMsgToSs}, {<API key>, <API key>, MN_SndAppMsgToSs}, {<API key>, <API key>, MN_SndAppMsgToSs}, {<API key>, <API key>, MN_SndAppMsgToSs}, {STK_SS_REGPWD_REQ, TAF_MSG_REGPWD_MSG, MN_SndAppMsgToSs}, {STK_SS_USSD_REQ, <API key>, MN_SndAppMsgToSs}, {<API key>, <API key>, <API key>} }; VOS_UINT32 MN_Init(enum <API key> ip) { TAF_SDC_CTX_STRU *pstSdcCtx = VOS_NULL_PTR; switch( ip ) { case VOS_IP_INITIAL: <API key>(WUEPS_PID_TAF); pstSdcCtx = TAF_SDC_GetSdcCtx(); TAF_SDC_InitCtx(<API key>, pstSdcCtx); MN_CALL_Init(<API key>); MN_MSG_Init(); Aps_Init(); TAF_SPM_Init(); SSA_Init(); break; default: break; } return VOS_OK; } VOS_VOID <API key>(struct MsgCB * pstMsg) { } VOS_VOID <API key>(struct MsgCB * pstMsg) { } VOS_VOID <API key>(struct MsgCB * pstMsg) { } VOS_VOID Taf_ProcSimaMsg (struct MsgCB * pstMsg) { } VOS_VOID MN_ProcTimerMsg (struct MsgCB * pstMsg) { REL_TIMER_MSG * pstTmrMsg = (REL_TIMER_MSG *)pstMsg; switch (pstTmrMsg->ulName & MN_TIMER_CLASS_MASK) { case MN_TIMER_CLASS_CCA: <API key>((REL_TIMER_MSG *)pstMsg); break; case MN_TIMER_CLASS_MSG: <API key>((REL_TIMER_MSG *)pstMsg); break; case MN_TIMER_CLASS_SSA: break; case MN_TIMER_CLASS_MMA: break; case MN_TIMER_CLASS_APS: TAF_APS_ProcMsg(pstMsg); break; default: MN_ERR_LOG("MN_ProcTimerMsg: Unknown timer class."); break; } } VOS_UINT32 <API key>(struct MsgCB * pstMsg) { VOS_UINT32 ulServerType; <API key> *pstEnvelope; switch (((MSG_HEADER_STRU *)pstMsg)->ulMsgName) { case <API key>: ulServerType = <API key>; break; case <API key>: pstEnvelope = (<API key> *)pstMsg; if (<API key> == pstEnvelope->ucDataType) { ulServerType = <API key>; } else { ulServerType = <API key>; } break; default: ulServerType = <API key>; break; } return ulServerType; } VOS_VOID MN_ProcUsimMsg (struct MsgCB * pstMsg) { VOS_UINT32 ulServerType; ulServerType = <API key>(pstMsg); switch(ulServerType) { case <API key>: <API key>(pstMsg); break; case <API key>: <API key>(pstMsg); break; case <API key>: <API key>(pstMsg); <API key>(pstMsg); break; default: MN_WARN_LOG("MN_ProcUsimMsg: Rcv Invalid ulClient."); break; } return; } VOS_VOID MN_ProcPihMsg (struct MsgCB * pstMsg) { MSG_HEADER_STRU *pstMsgHeader = VOS_NULL_PTR; pstMsgHeader = (MSG_HEADER_STRU *)pstMsg; if (PS_USIM_REFRESH_IND == pstMsgHeader->ulMsgName) { <API key>((<API key> *)pstMsgHeader); <API key>((<API key> *)pstMsgHeader); } return; } VOS_VOID MN_ProcMmcMsg (struct MsgCB * pstMsg) { switch (((MSG_HEADER_STRU *)pstMsg)->ulMsgName) { #if ((FEATURE_ON == FEATURE_GCBS) || (FEATURE_ON == FEATURE_WCBS)) case <API key>: case <API key>: TAF_CBA_MsgProc(pstMsg); break; #endif case <API key>: TAF_APS_ProcMsg(pstMsg); break; default: MN_WARN_LOG("MN_ProcMmcMsg:Rcv Invalid Msg Type"); break; } } VOS_VOID MN_ProcOmMsg (struct MsgCB * pstMsg) { <API key> *pstOmInquire; pstOmInquire = (<API key> *)pstMsg; switch ( pstOmInquire->usPrimId ) { case <API key> : case <API key> : MN_CALL_ProcOmMsg(pstMsg); break; case <API key> : TAF_APS_ProcMsg(pstMsg); break; default: MN_NORM_LOG("MN_CALL_ProcOmMsg:wrong PrimId!"); break; } return; } /* begin V7R1 PhaseI Modify */ VOS_VOID MN_ProcUsimStatus( struct MsgCB * pstMsg ) { <API key> *pstUsimStatus; <API key> *pstCustomCfgAddr; pstCustomCfgAddr = <API key>(); <API key>(EF_SMS_SMSS_ID, VOS_TRUE); <API key>(EF_SMS_SMS_ID, VOS_TRUE); <API key>(EF_SMS_SMSP_ID, VOS_TRUE); <API key>(EF_SMS_SMSR_ID, VOS_TRUE); pstUsimStatus = (<API key> *)pstMsg; MN_MSG_CfgDataInit(pstUsimStatus->enUsimStatus); #if ((FEATURE_ON == FEATURE_GCBS) || (FEATURE_ON == FEATURE_WCBS)) TAF_CBA_MsgProc(pstMsg); #endif if (<API key> == pstCustomCfgAddr->ucAlsSupportFlg ) { MN_CALL_LineInfo(pstUsimStatus->enUsimStatus); } <API key>(); <API key>(); } /* end V7R1 PhaseI Modify */ #ifndef __PS_WIN32_RECUR__ VOS_VOID <API key>( struct MsgCB *pstMsg ) { <API key> *pstOmMaintainInfo; pstOmMaintainInfo = (<API key>*)pstMsg; g_ucMnOmConnectFlg = pstOmMaintainInfo->ucOmConnectFlg; <API key> = pstOmMaintainInfo-><API key>; if ( (VOS_TRUE == g_ucMnOmConnectFlg) && (VOS_TRUE == <API key>) ) { <API key>(); <API key>(); <API key>(); } } #endif VOS_VOID MN_ProcMmaMsg ( struct MsgCB *pstMsg ) { switch (((MSG_HEADER_STRU *)pstMsg)->ulMsgName) { /* begin V7R1 PhaseI Modify */ case MN_USIM_STATUS_IND: MN_ProcUsimStatus(pstMsg); break; #ifndef __PS_WIN32_RECUR__ case <API key>: <API key>(pstMsg); break; #endif /* end V7R1 PhaseI Modify */ case <API key>: <API key>(pstMsg); break; case <API key>: Aps_PowerOff(); break; default: MN_WARN_LOG("MN_ProcMmaMsg:Rcv Invalid Msg Type"); break; } } VOS_VOID MN_SndAppMsgToSs (struct MsgCB *pstMsg) { MN_APP_REQ_MSG_STRU *pstSsMsg = VOS_NULL_PTR; VOS_UINT32 ulRet; VOS_UINT32 ulMsgLen; MN_APP_REQ_MSG_STRU *pstAppMsg = VOS_NULL_PTR; pstAppMsg = (MN_APP_REQ_MSG_STRU *)pstMsg; ulMsgLen = pstAppMsg->ulLength; pstSsMsg = (MN_APP_REQ_MSG_STRU *)PS_ALLOC_MSG(WUEPS_PID_TAF, ulMsgLen); if (VOS_NULL_PTR == pstSsMsg) { MN_WARN_LOG("MN_SndAppMsgToSs: alloc msg fail!"); return; } PS_MEM_CPY( ((VOS_UINT8 *)pstSsMsg + VOS_MSG_HEAD_LENGTH), ((VOS_UINT8 *)pstAppMsg+ VOS_MSG_HEAD_LENGTH), ulMsgLen); pstSsMsg->ulReceiverPid = WUEPS_PID_SS; ulRet = PS_SEND_MSG(WUEPS_PID_TAF, pstSsMsg); if (VOS_OK != ulRet) { MN_WARN_LOG("MN_SndAppMsgToSs: send msg fail!"); return; } return; } VOS_VOID <API key>(struct MsgCB * pstMsg) { <API key> *pstEnvelope = VOS_NULL_PTR; pstEnvelope = (<API key> *)pstMsg; if (<API key> != pstEnvelope->ucDataType) { <API key>(pstMsg); } return; } VOS_VOID MN_DispatchStkMsg(struct MsgCB * pstMsg) { VOS_UINT32 ulLoop; VOS_UINT32 ulFuncNum; MSG_HEADER_STRU *pstMsgHeader = VOS_NULL_PTR; <API key> pStkMsgFunc = VOS_NULL_PTR; pstMsgHeader = (MSG_HEADER_STRU *)pstMsg; ulFuncNum = sizeof(<API key>) / sizeof(<API key>[0]); for (ulLoop = 0; ulLoop < ulFuncNum; ulLoop ++ ) { if (pstMsgHeader->ulMsgName == <API key>[ulLoop].ulMsgName) { pStkMsgFunc = <API key>[ulLoop].pStkMsgFunc; pstMsgHeader->ulMsgName = <API key>[ulLoop].ulAppMsgName; break; } } if (VOS_NULL_PTR == pStkMsgFunc) { MN_WARN_LOG("MN_DispatchStkMsg: Invalid Msg Name"); return; } pStkMsgFunc(pstMsg); return; } VOS_VOID MN_DispatchTafMsg (struct MsgCB * pstMsg) { <API key> *pstTafMsg = VOS_NULL_PTR; pstTafMsg = (<API key> *)pstMsg; switch (pstTafMsg->ulMsgId & <API key>) { case <API key>: TAF_APS_ProcMsg(pstMsg); break; case <API key>: TAF_MSG_ProcTafMsg(pstMsg); break; default: MN_NORM_LOG("MN_DispatchTafMsg: Unknown message type."); break; } return; } VOS_VOID MN_DispatchAppMsg (struct MsgCB * pstMsg) { MN_APP_REQ_MSG_STRU * pstAppMsg = (MN_APP_REQ_MSG_STRU *)pstMsg; switch (pstAppMsg->usMsgName & <API key>) { case <API key>: <API key>(pstAppMsg); break; case <API key>: <API key>(pstAppMsg); break; case <API key>: MN_SndAppMsgToSs(pstMsg); break; case <API key>: break; case <API key>: break; default: MN_ERR_LOG("MN_DispatchAppMsg: Unknown message type."); break; } } VOS_VOID MN_DispatchRabmMsg ( VOS_VOID *pstMsg ) { <API key> *pstRabmMsg; pstRabmMsg = (<API key> *)pstMsg; if (pstRabmMsg->usMsgName > <API key>) { <API key>(pstRabmMsg); return; } TAF_APS_ProcMsg((struct MsgCB *)pstMsg); } #if (FEATURE_IMS == FEATURE_ON) VOS_VOID MN_DispatchImsaMsg ( VOS_VOID *pMsg ) { MSG_HEADER_STRU *pstImsaMsg = VOS_NULL_PTR; pstImsaMsg = (MSG_HEADER_STRU *)pMsg; switch (pstImsaMsg->ulMsgName & TAF_IMSA_MSG_MASK) { case <API key>: TAF_MSG_ProcImsaMsg(pstImsaMsg); break; case <API key>: <API key>(pstImsaMsg); break; default: break; } } #endif VOS_VOID MN_DispatchMsg (struct MsgCB * pstMsg) { struct MsgCB *pstSrcMsg = VOS_NULL_PTR; struct MsgCB *pstDestMsg = VOS_NULL_PTR; if (VOS_NULL_PTR == pstMsg) { return; } if (VOS_TRUE == <API key>()) { pstMsg->ulSenderPid = <API key>(pstMsg->ulSenderPid); } if ( VOS_TRUE == <API key>(pstMsg, &pstDestMsg) ) { return; } pstSrcMsg = pstDestMsg; if (VOS_TRUE == TAF_SPM_MsgProc(pstSrcMsg, &pstDestMsg)) { return; } switch (pstDestMsg->ulSenderPid) { case VOS_PID_TIMER: MN_ProcTimerMsg(pstDestMsg); break; case UEPS_PID_CST: <API key>(pstDestMsg); break; case MAPS_STK_PID: MN_DispatchStkMsg(pstDestMsg); break; case WUEPS_PID_TAF: MN_DispatchTafMsg(pstDestMsg); break; case WUEPS_PID_AT: MN_DispatchAppMsg(pstDestMsg); break; case WUEPS_PID_CC: <API key>(pstDestMsg); break; case WUEPS_PID_MMC: MN_ProcMmcMsg(pstDestMsg); break; case WUEPS_PID_MMA: MN_ProcMmaMsg(pstDestMsg); break; case WUEPS_PID_MM: break; case WUEPS_PID_SS: break; case WUEPS_PID_SMS: MN_MSG_ProcSmsMsg((VOS_VOID*)pstDestMsg); break; #if (FEATURE_IMS == FEATURE_ON) case PS_PID_IMSA: MN_DispatchImsaMsg((VOS_VOID*)pstDestMsg); break; #endif case WUEPS_PID_SM: TAF_APS_ProcMsg(pstDestMsg); break; #if (FEATURE_ON == FEATURE_LTE) case PS_PID_ESM: TAF_APS_ProcMsg(pstDestMsg); break; case MSP_L4_L4A_PID: TAF_APS_ProcMsg(pstDestMsg); break; #endif case WUEPS_PID_RABM: MN_DispatchRabmMsg(pstDestMsg); break; case UEPS_PID_SN: TAF_APS_ProcMsg(pstDestMsg); break; case WUEPS_PID_USIM: case MAPS_PB_PID: MN_ProcUsimMsg(pstDestMsg); break; case MAPS_PIH_PID: MN_ProcPihMsg(pstDestMsg); break; case WUEPS_PID_OM: MN_ProcOmMsg(pstDestMsg); break; case WUEPS_PID_VC: MN_CALL_ProcVCMsg(pstDestMsg); break; #if ((FEATURE_ON == FEATURE_GCBS) || (FEATURE_ON == FEATURE_WCBS)) case UEPS_PID_GAS: case WUEPS_PID_BMC: #if (FEATURE_ON == FEATURE_LTE) case PS_PID_ERRC: #endif case WUEPS_PID_WRR: TAF_CBA_MsgProc(pstDestMsg); break; #endif case UEPS_PID_NDCLIENT: TAF_APS_ProcMsg(pstDestMsg); break; case ACPU_PID_TAFAGENT: TAF_APS_ProcMsg(pstDestMsg); break; default: MN_ERR_LOG1("MN_DispatchMsg: Unknown message sender, SenderPid, ", (VOS_INT32)pstMsg->ulSenderPid); break; } } extern VOS_UINT32 WuepsAdminPidInit ( enum <API key> ip ); extern VOS_VOID Admin_TaskEntry (struct MsgCB * pRcvMsg); extern VOS_UINT32 WuepsVCPidInit ( enum <API key> ip ); extern VOS_VOID APP_VC_MsgProc(MsgBlock* pMsg); #if (VOS_WIN32 == VOS_OS_VER) extern VOS_VOID At_MsgProc(MsgBlock* pMsg); extern VOS_UINT32 At_PidInit(enum <API key> enPhase); #endif VOS_UINT32 WuepsTafFidInit ( enum <API key> ip ) { VOS_UINT32 ulRslt = VOS_OK; switch( ip ) { case VOS_IP_LOAD_CONFIG: ulRslt = VOS_RegisterPIDInfo(WUEPS_PID_ADMIN, (Init_Fun_Type) WuepsAdminPidInit, (Msg_Fun_Type) Admin_TaskEntry ); if( VOS_OK != ulRslt ) { return VOS_ERR; } ulRslt = VOS_RegisterPIDInfo(WUEPS_PID_TAF, (Init_Fun_Type) MN_Init, (Msg_Fun_Type) MN_DispatchMsg ); if( VOS_OK != ulRslt ) { return VOS_ERR; } ulRslt = VOS_RegisterPIDInfo(WUEPS_PID_VC, (Init_Fun_Type)WuepsVCPidInit, (Msg_Fun_Type)APP_VC_MsgProc ); if( VOS_OK != ulRslt ) { return VOS_ERR; } ulRslt = VOS_RegisterPIDInfo(WUEPS_PID_DRV_AGENT, (Init_Fun_Type)DRVAGENT_Init, (Msg_Fun_Type)<API key> ); if( VOS_OK != ulRslt ) { return VOS_ERR; } #if (VOS_WIN32 == VOS_OS_VER) ulRslt = VOS_RegisterPIDInfo(WUEPS_PID_AT, (Init_Fun_Type)At_PidInit, (Msg_Fun_Type)At_MsgProc); if (VOS_OK != ulRslt) { return VOS_ERR; } #endif ulRslt = <API key>(WUEPS_FID_TAF, VOS_PRIORITY_M5); if( VOS_OK != ulRslt ) { return VOS_ERR; } ulRslt = VOS_RegisterPIDInfo(UEPS_PID_MTA, (Init_Fun_Type)TAF_MTA_InitPid, (Msg_Fun_Type)TAF_MTA_ProcMsg ); if( VOS_OK != ulRslt ) { return VOS_ERR; } break; case VOS_IP_FARMALLOC: case VOS_IP_INITIAL: case VOS_IP_ENROLLMENT: case VOS_IP_LOAD_DATA: case VOS_IP_FETCH_DATA: case VOS_IP_STARTUP: case VOS_IP_RIVAL: case VOS_IP_KICKOFF: case VOS_IP_STANDBY: case <API key>: case VOS_IP_RESTART: case VOS_IP_BUTT: break; } return VOS_OK; } #ifdef __cplusplus #if __cplusplus } #endif #endif
<?php // No direct access defined('_HZEXEC_') or die(); /** * Groups plugin class for Member Options */ class <API key> extends \Hubzero\Plugin\Plugin { /** * Affects constructor behavior. If true, language files will be loaded automatically. * * @var boolean */ protected $_autoloadLanguage = true; /** * Return the alias and name for this category of content * * @return array */ public function &onGroupAreas() { $area = array( 'name' => 'memberoptions', 'title' => Lang::txt('GROUP_MEMBEROPTIONS'), 'default_access' => 'registered', 'display_menu_tab' => $this->params->get('display_tab', 0), 'icon' => '2699' ); return $area; } /** * Return data on a group view (this will be some form of HTML) * * @param object $group Current group * @param string $option Name of the component * @param string $authorized User's authorization level * @param integer $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param string $action Action to perform * @param array $access What can be accessed * @param array $areas Active area(s) * @return array */ public function onGroup($group, $option, $authorized, $limit=0, $limitstart=0, $action='', $access, $areas=null) { // The output array we're returning $arr = array( 'html' => '' ); $user = User::getInstance(); $this->group = $group; $this->option = $option; // Things we need from the form $recvEmailOptionID = Request::getInt('memberoptionid', 0); $<API key> = Request::getInt('recvpostemail', 0); include_once(__DIR__ . DS . 'models' . DS . 'memberoption.php'); switch ($action) { case 'editmemberoptions': $arr['html'] .= $this->edit($group, $user, $recvEmailOptionID, $<API key>); break; case 'savememberoptions': $arr['html'] .= $this->save($group, $user, $recvEmailOptionID, $<API key>); break; default: $arr['html'] .= $this->edit($group, $user, $recvEmailOptionID, $<API key>); break; } return $arr; } /** * Edit settings * * @param object $group * @param object $user * @param integer $recvEmailOptionID * @param integer $<API key> * @return string */ protected function edit($group, $user, $recvEmailOptionID, $<API key>) { // Load the options $recvEmailOption = Plugins\Groups\Memberoptions\Models\Memberoption::oneByUserAndOption( $group->get('gidNumber'), $user->get('id'), 'receive-forum-email' ); $view = $this->view('default', 'browse') ->set('recvEmailOptionID', $recvEmailOption->get('id', 0)) ->set('<API key>', $recvEmailOption->get('optionvalue', 0)) ->set('option', $this->option) ->set('group', $this->group); // Return the output return $view->loadTemplate(); } /** * Save settings * * @param object $group * @param object $user * @param integer $recvEmailOptionID * @param integer $<API key> * @return void */ protected function save($group, $user, $recvEmailOptionID, $<API key>) { $postSaveRedirect = Request::getVar('postsaveredirect', ''); // Save the <API key> setting $row = Plugins\Groups\Memberoptions\Models\Memberoption::blank()->set(array( 'id' => $recvEmailOptionID, 'userid' => $user->get('id'), 'gidNumber' => $group->get('gidNumber'), 'optionname' => 'receive-forum-email', 'optionvalue' => $<API key> )); // Store content if (!$row->save()) { $this->setError($row->getError()); return $this->edit($group, $user, $recvEmailOptionID, $<API key>); } if (Request::getInt('no_html')) { echo json_encode(array('success' => true)); exit(); } if (!$postSaveRedirect) { $postSaveRedirect = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=memberoptions&action=edit'); } App::redirect( $postSaveRedirect, Lang::txt('You have successfully updated your email settings') ); } /** * Subscribe a person to emails on enrollment * * @param integer $gidNumber * @param integer $userid * @return void */ public function <API key>($gidNumber, $userid) { // get group $group = \Hubzero\User\Group::getInstance($gidNumber); // is auto-subscribe on for discussion forum $autosubscribe = $group->get('<API key>'); // log variable Log::debug('$<API key>' . $autosubscribe); // if were not auto-subscribed then stop if (!$autosubscribe) { return; } include_once(__DIR__ . DS . 'models' . DS . 'memberoption.php'); // see if they've already got something, they shouldn't, but you never know $row = Plugins\Groups\Memberoptions\Models\Memberoption::oneByUserAndOption( $gidNumber, $userid, 'receive-forum-email' ); if ($row->get('id')) { // They already have a record, so ignore. return; } $row->set('gidNumber', $gidNumber); $row->set('userid', $userid); $row->set('optionname', 'receive-forum-email'); $row->set('optionvalue', 1); $row->save(); } }
#pragma once namespace vm { using namespace ps3; } // Return Codes enum { <API key> = 0x80610301, <API key> = 0x80610311, <API key> = 0x80610312, <API key> = 0x80610313, <API key> = 0x80610314, <API key> = 0x80610315, <API key> = 0x80610321, <API key> = 0x80610322, <API key> = 0x80610323, <API key> = 0x80610331, <API key> = 0x80610332, <API key> = 0x80610333, <API key> = 0x80610334, <API key> = 0x80610341, <API key> = 0x80610342, <API key> = 0x80610351, <API key> = 0x80610361, <API key> = 0x80610371, <API key> = 0x80610372, <API key> = 0x80610381, <API key> = 0x80610382, }; // Remain Frame enum : s32 { <API key> = -1, <API key> = -2, <API key> = -3, }; struct set_alignment(8) CellAtracHandle { vm::ptr<u8> pucWorkMem; }; CHECK_MAX_SIZE(CellAtracHandle, 512); struct CellAtracBufferInfo { vm::ptr<u8> pucWriteAddr; be_t<u32> uiWritableByte; be_t<u32> uiMinWriteByte; be_t<u32> uiReadPosition; }; struct CellAtracExtRes { vm::ptr<struct CellSpurs> pSpurs; u8 priority[8]; }; extern Module cellAtrac;
package com.redhat.rhn.taskomatic.task; import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.hibernate.HibernateFactory; import com.redhat.rhn.taskomatic.TaskoRun; import com.redhat.rhn.taskomatic.task.threaded.TaskQueue; import com.redhat.rhn.taskomatic.task.threaded.TaskQueueFactory; import org.apache.log4j.FileAppender; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.quartz.JobExecutionContext; import org.quartz.<API key>; import java.io.IOException; /** * Custom Quartz Job implementation which only allows one thread to * run at a time. All other threads return without performing any work. * This policy was chosen instead of blocking so as to reduce threading * problems inside Quartz itself. * * @version $Rev $ * */ public abstract class RhnQueueJob implements RhnJob { private TaskoRun jobRun = null; protected abstract Logger getLogger(); /** * {@inheritDoc} */ public void <API key>(Exception e) { getLogger().error(e.getMessage()); getLogger().error(e.getCause()); } private void logToNewFile() { PatternLayout pattern = new PatternLayout(<API key>); try { getLogger().removeAllAppenders(); FileAppender appender = new FileAppender(pattern, jobRun.<API key>()); getLogger().addAppender(appender); } catch (IOException e) { getLogger().warn("Logging to file disabled"); } } /** * {@inheritDoc} */ public void execute(JobExecutionContext ctx, TaskoRun runIn) throws <API key> { setJobRun(runIn); try { execute(ctx); } catch (Exception e) { if (HibernateFactory.getSession().getTransaction().isActive()) { HibernateFactory.rollbackTransaction(); HibernateFactory.closeSession(); } <API key>(e); jobRun.saveStatus(TaskoRun.STATUS_FAILED); } HibernateFactory.commitTransaction(); HibernateFactory.closeSession(); } /** * {@inheritDoc} */ public void execute(JobExecutionContext ctx) throws <API key> { TaskQueueFactory factory = TaskQueueFactory.get(); String queueName = getQueueName(); TaskQueue queue = factory.getQueue(queueName); if (queue == null) { try { queue = factory.createQueue(queueName, getDriverClass(), getLogger()); } catch (Exception e) { getLogger().error(e); return; } } if (queue.changeRun(jobRun)) { jobRun.start(); HibernateFactory.commitTransaction(); HibernateFactory.closeSession(); logToNewFile(); getLogger().debug("Starting run " + jobRun.getId()); } else { // close current run TaskoRun run = (TaskoRun) HibernateFactory.reload(jobRun); run.appendToOutputLog("Run with id " + queue.getQueueRun().getId() + " handles the whole task queue."); run.skipped(); HibernateFactory.commitTransaction(); HibernateFactory.closeSession(); } int defaultItems = 3; if (queueName.equals("channel_repodata")) { defaultItems = 1; } int maxWorkItems = Config.get().getInt("taskomatic." + queueName + "_max_work_items", defaultItems); if (queue.getQueueSize() < maxWorkItems) { queue.run(this); } else { getLogger().debug("Maximum number of workers already put ... skipping."); } } /** * @return Returns the run. */ public TaskoRun getRun() { return jobRun; } /** * @param runIn The run to set. */ public void setJobRun(TaskoRun runIn) { jobRun = runIn; } protected abstract Class getDriverClass(); protected abstract String getQueueName(); }
#ifndef <API key> #define <API key> /* clock IDs used by the modem processor */ #define P_ACPU_CLK 0 /* Applications processor clock */ #define P_ADM_CLK 1 /* Applications data mover clock */ #define P_ADSP_CLK 2 /* ADSP clock */ #define P_EBI1_CLK 3 /* External bus interface 1 clock */ #define P_EBI2_CLK 4 /* External bus interface 2 clock */ #define P_ECODEC_CLK 5 /* External CODEC clock */ #define P_EMDH_CLK 6 /* External MDDI host clock */ #define P_GP_CLK 7 /* General purpose clock */ #define P_GRP_CLK 8 /* Graphics clock */ #define P_I2C_CLK 9 /* I2C clock */ #define P_ICODEC_RX_CLK 10 /* Internal CODEX RX clock */ #define P_ICODEC_TX_CLK 11 /* Internal CODEX TX clock */ #define P_IMEM_CLK 12 /* Internal graphics memory clock */ #define P_MDC_CLK 13 /* MDDI client clock */ #define P_MDP_CLK 14 /* Mobile display processor clock */ #define P_PBUS_CLK 15 /* Peripheral bus clock */ #define P_PCM_CLK 16 /* PCM clock */ #define P_PMDH_CLK 17 /* Primary MDDI host clock */ #define P_SDAC_CLK 18 /* Stereo DAC clock */ #define P_SDC1_CLK 19 /* Secure Digital Card clocks */ #define P_SDC1_PCLK 20 #define P_SDC2_CLK 21 #define P_SDC2_PCLK 22 #define P_SDC3_CLK 23 #define P_SDC3_PCLK 24 #define P_SDC4_CLK 25 #define P_SDC4_PCLK 26 #define P_TSIF_CLK 27 /* Transport Stream Interface clocks */ #define P_TSIF_REF_CLK 28 #define P_TV_DAC_CLK 29 /* TV clocks */ #define P_TV_ENC_CLK 30 #define P_UART1_CLK 31 /* UART clocks */ #define P_UART2_CLK 32 #define P_UART3_CLK 33 #define P_UART1DM_CLK 34 #define P_UART2DM_CLK 35 #define P_USB_HS_CLK 36 /* High speed USB core clock */ #define P_USB_HS_PCLK 37 /* High speed USB pbus clock */ #define P_USB_OTG_CLK 38 /* Full speed USB clock */ #define P_VDC_CLK 39 /* Video controller clock */ #define P_VFE_MDC_CLK 40 /* Camera / Video Front End clock */ #define P_VFE_CLK 41 /* VFE MDDI client clock */ #define P_MDP_LCDC_PCLK_CLK 42 #define <API key> 43 #define P_MDP_VSYNC_CLK 44 #define P_SPI_CLK 45 #define P_VFE_AXI_CLK 46 #define P_USB_HS2_CLK 47 /* High speed USB 2 core clock */ #define P_USB_HS2_PCLK 48 /* High speed USB 2 pbus clock */ #define P_USB_HS3_CLK 49 /* High speed USB 3 core clock */ #define P_USB_HS3_PCLK 50 /* High speed USB 3 pbus clock */ #define P_GRP_PCLK 51 /* Graphics pbus clock */ #define P_USB_PHY_CLK 52 /* USB PHY clock */ #define P_USB_HS_CORE_CLK 53 /* High speed USB 1 core clock */ #define P_USB_HS2_CORE_CLK 54 /* High speed USB 2 core clock */ #define P_USB_HS3_CORE_CLK 55 /* High speed USB 3 core clock */ #define P_CAM_MCLK_CLK 56 #define P_CAMIF_PAD_PCLK 57 #define P_GRP_2D_CLK 58 #define P_GRP_2D_PCLK 59 #define P_I2S_CLK 60 #define P_JPEG_CLK 61 #define P_JPEG_PCLK 62 #define P_LPA_CODEC_CLK 63 #define P_LPA_CORE_CLK 64 #define P_LPA_PCLK 65 #define P_MDC_IO_CLK 66 #define P_MDC_PCLK 67 #define P_MFC_CLK 68 #define P_MFC_DIV2_CLK 69 #define P_MFC_PCLK 70 #define P_QUP_I2C_CLK 71 #define P_ROTATOR_IMEM_CLK 72 #define P_ROTATOR_PCLK 73 #define P_VFE_CAMIF_CLK 74 #define P_VFE_PCLK 75 #define P_VPE_CLK 76 #define P_I2C_2_CLK 77 #define <API key> 78 #define <API key> 79 #define <API key> 80 #define <API key> 81 #define P_PMDH_PCLK 82 #define P_EMDH_PCLK 83 #define P_SPI_PCLK 84 #define P_TSIF_PCLK 85 #define P_MDP_PCLK 86 #define P_SDAC_MCLK 87 #define P_MI2S_HDMI_CLK 88 #define P_MI2S_HDMI_MCLK 89 #define P_NR_CLKS 90 struct clk_ops; extern struct clk_ops clk_ops_pcom; #define CLK_PCOM(clk_name, clk_id, clk_dev, clk_flags) { \ .name = clk_name, \ .id = P_##clk_id, \ .ops = &clk_ops_pcom, \ .flags = clk_flags, \ .dev = clk_dev, \ .dbg_name = #clk_id, \ } #endif
// For information as to what this class does, see the Javadoc, below. // // 2007, 2008, 2009, 2010, 2014, 2015 by Peter Spirtes, Richard Scheines, Joseph // // Ramsey, and Clark Glymour. // // This program is free software; you can redistribute it and/or modify // // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package edu.cmu.tetrad.search.mb; import edu.cmu.tetrad.data.DataSet; import edu.cmu.tetrad.data.IKnowledge; import edu.cmu.tetrad.data.Knowledge2; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.graph.Node; import edu.cmu.tetrad.search.FgesOrienter; import edu.cmu.tetrad.search.GraphSearch; import edu.cmu.tetrad.search.IndependenceTest; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Implements the MMHC algorithm. * * @author Joseph Ramsey (this version). */ public class Mmhc implements GraphSearch { /** * The independence test used for the PC search. */ private IndependenceTest independenceTest; /** * The maximum number of nodes conditioned on in the search. */ private int depth = Integer.MAX_VALUE; private DataSet data; private IKnowledge knowledge = new Knowledge2(); public Mmhc(IndependenceTest test, DataSet dataSet) { this.depth = -1; this.independenceTest = test; this.data = dataSet; } public IndependenceTest getIndependenceTest() { return independenceTest; } public int getDepth() { return depth; } public long getElapsedTime() { return 0; } /** * Runs PC starting with a fully connected graph over all of the variables in the domain of the independence test. */ public Graph search() { List<Node> variables = independenceTest.getVariables(); Mmmb mmmb = new Mmmb(independenceTest, getDepth(), true); Map<Node, List<Node>> pc = new HashMap<>(); for (Node x : variables) { pc.put(x, mmmb.getPc(x)); } Graph graph = new EdgeListGraph(); for (Node x : variables) { graph.addNode(x); } for (Node x : variables) { for (Node y : pc.get(x)) { if (!graph.isAdjacentTo(x, y)) { graph.addUndirectedEdge(x, y); } } } FgesOrienter orienter = new FgesOrienter(data); orienter.orient(graph); return graph; } public IKnowledge getKnowledge() { return knowledge; } public void setKnowledge(IKnowledge knowledge) { if (knowledge == null) { throw new <API key>(); } this.knowledge = knowledge; } public void setDepth(int depth) { this.depth = depth; } }
#include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <scsi/scsi_host.h> #include <linux/libata.h> #define DRV_NAME "pata_ninja32" #define DRV_VERSION "0.0.1" /** * ninja32_set_piomode - set initial PIO mode data * @ap: ATA interface * @adev: ATA device * * Called to do the PIO mode setup. Our timing registers are shared * but we want to set the PIO timing by default. */ static void ninja32_set_piomode(struct ata_port *ap, struct ata_device *adev) { static u16 pio_timing[5] = { 0xd6, 0x85, 0x44, 0x33, 0x13 }; iowrite8(pio_timing[adev->pio_mode - XFER_PIO_0], ap->ioaddr.bmdma_addr + 0x1f); ap->private_data = adev; } static void ninja32_dev_select(struct ata_port *ap, unsigned int device) { struct ata_device *adev = &ap->link.device[device]; if (ap->private_data != adev) { iowrite8(0xd6, ap->ioaddr.bmdma_addr + 0x1f); ata_std_dev_select(ap, device); ninja32_set_piomode(ap, adev); } } static struct scsi_host_template ninja32_sht = { .module = THIS_MODULE, .name = DRV_NAME, .ioctl = ata_scsi_ioctl, .queuecommand = ata_scsi_queuecmd, .can_queue = ATA_DEF_QUEUE, .this_id = ATA_SHT_THIS_ID, .sg_tablesize = LIBATA_MAX_PRD, .cmd_per_lun = ATA_SHT_CMD_PER_LUN, .emulated = ATA_SHT_EMULATED, .use_clustering = <API key>, .proc_name = DRV_NAME, .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = <API key>, .slave_destroy = <API key>, .bios_param = ata_std_bios_param, }; static struct ata_port_operations ninja32_port_ops = { .set_piomode = ninja32_set_piomode, .mode_filter = <API key>, .tf_load = ata_tf_load, .tf_read = ata_tf_read, .check_status = ata_check_status, .exec_command = ata_exec_command, .dev_select = ninja32_dev_select, .freeze = ata_bmdma_freeze, .thaw = ata_bmdma_thaw, .error_handler = <API key>, .post_internal_cmd = <API key>, .cable_detect = ata_cable_40wire, .bmdma_setup = ata_bmdma_setup, .bmdma_start = ata_bmdma_start, .bmdma_stop = ata_bmdma_stop, .bmdma_status = ata_bmdma_status, .qc_prep = ata_qc_prep, .qc_issue = ata_qc_issue_prot, .data_xfer = ata_data_xfer, .irq_handler = ata_interrupt, .irq_clear = ata_bmdma_irq_clear, .irq_on = ata_irq_on, .port_start = ata_sff_port_start, }; static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id) { struct ata_host *host; struct ata_port *ap; void __iomem *base; int rc; host = ata_host_alloc(&dev->dev, 1); if (!host) return -ENOMEM; ap = host->ports[0]; /* Set up the PCI device */ rc = pcim_enable_device(dev); if (rc) return rc; rc = pcim_iomap_regions(dev, 1 << 0, DRV_NAME); if (rc == -EBUSY) pcim_pin_device(dev); if (rc) return rc; host->iomap = pcim_iomap_table(dev); rc = pci_set_dma_mask(dev, ATA_DMA_MASK); if (rc) return rc; rc = <API key>(dev, ATA_DMA_MASK); if (rc) return rc; pci_set_master(dev); /* Set up the register mappings */ base = host->iomap[0]; if (!base) return -ENOMEM; ap->ops = &ninja32_port_ops; ap->pio_mask = 0x1F; ap->flags |= ATA_FLAG_SLAVE_POSS; ap->ioaddr.cmd_addr = base + 0x10; ap->ioaddr.ctl_addr = base + 0x1E; ap->ioaddr.altstatus_addr = base + 0x1E; ap->ioaddr.bmdma_addr = base; ata_std_ports(&ap->ioaddr); iowrite8(0x05, base + 0x01); /* Enable interrupt lines */ iowrite8(0xBE, base + 0x02); /* Burst, ?? setup */ iowrite8(0x01, base + 0x03); /* Unknown */ iowrite8(0x20, base + 0x04); /* WAIT0 */ iowrite8(0x8f, base + 0x05); /* Unknown */ iowrite8(0xa4, base + 0x1c); /* Unknown */ iowrite8(0x83, base + 0x1d); /* BMDMA control: WAIT0 */ /* FIXME: Should we disable them at remove ? */ return ata_host_activate(host, dev->irq, ata_interrupt, IRQF_SHARED, &ninja32_sht); } static const struct pci_device_id ninja32[] = { { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { }, }; static struct pci_driver ninja32_pci_driver = { .name = DRV_NAME, .id_table = ninja32, .probe = ninja32_init_one, .remove = ata_pci_remove_one }; static int __init ninja32_init(void) { return pci_register_driver(&ninja32_pci_driver); } static void __exit ninja32_exit(void) { <API key>(&ninja32_pci_driver); } MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("low-level driver for Ninja32 ATA"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, ninja32); MODULE_VERSION(DRV_VERSION); module_init(ninja32_init); module_exit(ninja32_exit);
<?php /* * Local plugin enable/disable settings * Auto-generated through plugin/extension manager * * NOTE: Plugins will not be added to this file unless there is a need to override a default setting. Plugins are * enabled by default, unless having a 'disabled' file in their plugin folder. */ $plugins['authmysql'] = 0; $plugins['authad'] = 0; $plugins['authpgsql'] = 0; $plugins['authldap'] = 0;
#include <string> #include <map> #include <fstream> #include <iostream> #include <boost/regex.hpp> using namespace std; // purpose: // takes the contents of a file in the form of a string // and searches for all the C++ class definitions, storing // their locations in a map of strings/int's typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type; const char* re = // possibly leading whitespace: "^[[:space:]]*" // possible template declaration: "(template[[:space:]]*<[^;:{]+>[[:space:]]*)?" // class or struct: "(class|struct)[[:space:]]*" // leading declspec macros etc: "(" "\\<\\w+\\>" "(" "[[:blank:]]*\\([^)]*\\)" ")?" "[[:space:]]*" ")*" // the class name "(\\<\\w*\\>)[[:space:]]*" // template specialisation parameters "(<[^;:{]+>)?[[:space:]]*" // terminate in { or : "(\\{|:[^;\\{()]*\\{)"; boost::regex expression(re); map_type class_index; bool regex_callback(const boost::match_results<std::string::const_iterator>& what) { // what[0] contains the whole string // what[5] contains the class name. // what[6] contains the template specialisation if any. // add class name and position to map: class_index[what[5].str() + what[6].str()] = what.position(5); return true; } void load_file(std::string& s, std::istream& is) { s.erase(); if(is.bad()) return; s.reserve(is.rdbuf()->in_avail()); char c; while(is.get(c)) { if(s.capacity() == s.size()) s.reserve(s.capacity() * 3); s.append(1, c); } } int main(int argc, const char** argv) { std::string text; for(int i = 1; i < argc; ++i) { cout << "Processing file " << argv[i] << endl; std::ifstream fs(argv[i]); load_file(text, fs); fs.close(); // construct our iterators: boost::sregex_iterator m1(text.begin(), text.end(), expression); boost::sregex_iterator m2; std::for_each(m1, m2, &regex_callback); // copy results: cout << class_index.size() << " matches found" << endl; map_type::iterator c, d; c = class_index.begin(); d = class_index.end(); while(c != d) { cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl; ++c; } class_index.erase(class_index.begin(), class_index.end()); } return 0; }
<?php /** * @see <API key> */ require_once 'Zend/Validate/Abstract.php'; class Zend_Validate_Ip extends <API key> { const NOT_IP_ADDRESS = 'notIpAddress'; /** * @var array */ protected $_messageTemplates = array( self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address" ); /** * Defined by <API key> * * Returns true if and only if $value is a valid IP address * * @param mixed $value * @return boolean */ public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (ip2long($valueString) === false) { $this->_error(); return false; } return true; } }
~\\ \begin{enumerate} \item \upc{43,9} \item 197 \end{enumerate}
<head> <title>{#tagwrap_dlg.titleP}</title> <script type="text/javascript" src="../../../tinymce/tiny_mce_popup.js"></script> <script type="text/javascript" src="js/dialog.js"></script> <link rel="stylesheet" type="text/css" href="css/tagwrap.css" /> </head> <body> <div class="y_logo_contener"> <img src="img/html5.png" alt="HTML5" /> </div> <div class="yinstr"> <p>{#tagwrap_dlg.noteP}</p> <p>{#tagwrap_dlg.noteP3}</p> </div> <form onSubmit="TagwrapDialog.insert();return false;" action="#" method="post" name="P_tag"> <div class="mceActionPanel"> <script type="text/javascript" language="javascript"> var jwl_sel_content4 = tinyMCE.activeEditor.selection.getContent(); </script> {#tagwrap_dlg.noteP1} <input id="title_value" type="text" name="title" width="200px" value="" /> <em> {#tagwrap_dlg.noteP2}</em> <br /><br /> </div> <div style="margin-top:80px;"</div> <div class="bottom"> <p><!--{#tagwrap_dlg.bottomnote}--></p> <p class="pagelink_hover"><!--{#tagwrap_dlg.bottomnote2}--></p> </div> <script type="text/javascript" language="javascript"> function jwl_pass_form_data () { var name = jwl_title = document.getElementsByName("title")[0].value; } </script> <div class="mceActionPanel"> <div style="float:left;padding-top:5px"> <input type="button" id="insert" name="insert" value="{#insert}" onClick="jwl_pass_form_data();tinyMCE.execCommand('mceInsertContent',false,'<p style=\'' + jwl_title + '\'>' + jwl_sel_content4 + '</p>');tinyMCEPopup.close();" />&nbsp;<input type="button" id="cancel" name="cancel" value="{#cancel}" onClick="tinyMCEPopup.close();" /> </div> </div> </form> <span style="float:right;"><a target="_blank" href="http: </body>
#include <linux/err.h> #include <linux/if_ether.h> #include <linux/igmp.h> #include <linux/jhash.h> #include <linux/kernel.h> #include <linux/log2.h> #include <linux/netdevice.h> #include <linux/netfilter_bridge.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/timer.h> #include <net/ip.h> #if IS_ENABLED(CONFIG_IPV6) #include <net/ipv6.h> #include <net/mld.h> #include <net/addrconf.h> #include <net/ip6_checksum.h> #endif #include "br_private.h" #define mlock_dereference(X, br) \ <API key>(X, lockdep_is_held(&br->multicast_lock)) #if IS_ENABLED(CONFIG_IPV6) static inline int <API key>(const struct in6_addr *addr) { if (<API key>(addr) && <API key>(addr)) return 1; return 0; } #endif static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b) { if (a->proto != b->proto) return 0; switch (a->proto) { case htons(ETH_P_IP): return a->u.ip4 == b->u.ip4; #if IS_ENABLED(CONFIG_IPV6) case htons(ETH_P_IPV6): return ipv6_addr_equal(&a->u.ip6, &b->u.ip6); #endif } return 0; } static inline int __br_ip4_hash(struct <API key> *mdb, __be32 ip) { return jhash_1word(mdb->secret, (__force u32)ip) & (mdb->max - 1); } #if IS_ENABLED(CONFIG_IPV6) static inline int __br_ip6_hash(struct <API key> *mdb, const struct in6_addr *ip) { return jhash2((__force u32 *)ip->s6_addr32, 4, mdb->secret) & (mdb->max - 1); } #endif static inline int br_ip_hash(struct <API key> *mdb, struct br_ip *ip) { switch (ip->proto) { case htons(ETH_P_IP): return __br_ip4_hash(mdb, ip->u.ip4); #if IS_ENABLED(CONFIG_IPV6) case htons(ETH_P_IPV6): return __br_ip6_hash(mdb, &ip->u.ip6); #endif } return 0; } static struct <API key> *__br_mdb_ip_get( struct <API key> *mdb, struct br_ip *dst, int hash) { struct <API key> *mp; struct hlist_node *p; <API key>(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) { if (br_ip_equal(&mp->addr, dst)) return mp; } return NULL; } static struct <API key> *br_mdb_ip_get( struct <API key> *mdb, struct br_ip *dst) { if (!mdb) return NULL; return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst)); } static struct <API key> *br_mdb_ip4_get( struct <API key> *mdb, __be32 dst) { struct br_ip br_dst; br_dst.u.ip4 = dst; br_dst.proto = htons(ETH_P_IP); return br_mdb_ip_get(mdb, &br_dst); } #if IS_ENABLED(CONFIG_IPV6) static struct <API key> *br_mdb_ip6_get( struct <API key> *mdb, const struct in6_addr *dst) { struct br_ip br_dst; br_dst.u.ip6 = *dst; br_dst.proto = htons(ETH_P_IPV6); return br_mdb_ip_get(mdb, &br_dst); } #endif struct <API key> *br_mdb_get(struct net_bridge *br, struct sk_buff *skb) { struct <API key> *mdb = rcu_dereference(br->mdb); struct br_ip ip; int i = 0; ip.u.ip4 = 0; for (i=0; i<16; i++) ip.u.ip6.s6_addr[i] = 0; if (br->multicast_disabled) return NULL; if (BR_INPUT_SKB_CB(skb)->igmp) return NULL; ip.proto = skb->protocol; switch (skb->protocol) { case htons(ETH_P_IP): ip.u.ip4 = ip_hdr(skb)->daddr; break; #if IS_ENABLED(CONFIG_IPV6) case htons(ETH_P_IPV6): ip.u.ip6 = ipv6_hdr(skb)->daddr; break; #endif default: return NULL; } return br_mdb_ip_get(mdb, &ip); } static void br_mdb_free(struct rcu_head *head) { struct <API key> *mdb = container_of(head, struct <API key>, rcu); struct <API key> *old = mdb->old; mdb->old = NULL; kfree(old->mhash); kfree(old); } static int br_mdb_copy(struct <API key> *new, struct <API key> *old, int elasticity) { struct <API key> *mp; struct hlist_node *p; int maxlen; int len; int i; for (i = 0; i < old->max; i++) <API key>(mp, p, &old->mhash[i], hlist[old->ver]) hlist_add_head(&mp->hlist[new->ver], &new->mhash[br_ip_hash(new, &mp->addr)]); if (!elasticity) return 0; maxlen = 0; for (i = 0; i < new->max; i++) { len = 0; <API key>(mp, p, &new->mhash[i], hlist[new->ver]) len++; if (len > maxlen) maxlen = len; } return maxlen > elasticity ? -EINVAL : 0; } static void <API key>(struct rcu_head *head) { struct <API key> *p = container_of(head, struct <API key>, rcu); kfree(p); } static void <API key>(struct rcu_head *head) { struct <API key> *mp = container_of(head, struct <API key>, rcu); kfree(mp); } static void <API key>(unsigned long data) { struct <API key> *mp = (void *)data; struct net_bridge *br = mp->br; struct <API key> *mdb; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || timer_pending(&mp->timer)) goto out; mp->mglist = false; if (mp->ports) goto out; mdb = mlock_dereference(br->mdb, br); hlist_del_rcu(&mp->hlist[mdb->ver]); mdb->size call_rcu_bh(&mp->rcu, <API key>); out: spin_unlock(&br->multicast_lock); } static void br_multicast_del_pg(struct net_bridge *br, struct <API key> *pg) { struct <API key> *mdb; struct <API key> *mp; struct <API key> *p; struct <API key> __rcu **pp; mdb = mlock_dereference(br->mdb, br); mp = br_mdb_ip_get(mdb, &pg->addr); if (WARN_ON(!mp)) return; for (pp = &mp->ports; (p = mlock_dereference(*pp, br)) != NULL; pp = &p->next) { if (p != pg) continue; rcu_assign_pointer(*pp, p->next); hlist_del_init(&p->mglist); del_timer(&p->timer); call_rcu_bh(&p->rcu, <API key>); if (!mp->ports && !mp->mglist && netif_running(br->dev)) mod_timer(&mp->timer, jiffies); return; } WARN_ON(1); } static void <API key>(unsigned long data) { struct <API key> *pg = (void *)data; struct net_bridge *br = pg->port->br; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || timer_pending(&pg->timer) || hlist_unhashed(&pg->mglist)) goto out; br_multicast_del_pg(br, pg); out: spin_unlock(&br->multicast_lock); } static int br_mdb_rehash(struct <API key> __rcu **mdbp, int max, int elasticity) { struct <API key> *old = <API key>(*mdbp, 1); struct <API key> *mdb; int err; mdb = kmalloc(sizeof(*mdb), GFP_ATOMIC); if (!mdb) return -ENOMEM; mdb->max = max; mdb->old = old; mdb->mhash = kzalloc(max * sizeof(*mdb->mhash), GFP_ATOMIC); if (!mdb->mhash) { kfree(mdb); return -ENOMEM; } mdb->size = old ? old->size : 0; mdb->ver = old ? old->ver ^ 1 : 0; if (!old || elasticity) get_random_bytes(&mdb->secret, sizeof(mdb->secret)); else mdb->secret = old->secret; if (!old) goto out; err = br_mdb_copy(mdb, old, elasticity); if (err) { kfree(mdb->mhash); kfree(mdb); return err; } call_rcu_bh(&mdb->rcu, br_mdb_free); out: rcu_assign_pointer(*mdbp, mdb); return 0; } static struct sk_buff *<API key>(struct net_bridge *br, __be32 group) { struct sk_buff *skb; struct igmphdr *ih; struct ethhdr *eth; struct iphdr *iph; skb = <API key>(br->dev, sizeof(*eth) + sizeof(*iph) + sizeof(*ih) + 4); if (!skb) goto out; skb->protocol = htons(ETH_P_IP); <API key>(skb); eth = eth_hdr(skb); memcpy(eth->h_source, br->dev->dev_addr, 6); eth->h_dest[0] = 1; eth->h_dest[1] = 0; eth->h_dest[2] = 0x5e; eth->h_dest[3] = 0; eth->h_dest[4] = 0; eth->h_dest[5] = 1; eth->h_proto = htons(ETH_P_IP); skb_put(skb, sizeof(*eth)); <API key>(skb, skb->len); iph = ip_hdr(skb); iph->version = 4; iph->ihl = 6; iph->tos = 0xc0; iph->tot_len = htons(sizeof(*iph) + sizeof(*ih) + 4); iph->id = 0; iph->frag_off = htons(IP_DF); iph->ttl = 1; iph->protocol = IPPROTO_IGMP; iph->saddr = 0; iph->daddr = htonl(<API key>); ((u8 *)&iph[1])[0] = IPOPT_RA; ((u8 *)&iph[1])[1] = 4; ((u8 *)&iph[1])[2] = 0; ((u8 *)&iph[1])[3] = 0; ip_send_check(iph); skb_put(skb, 24); <API key>(skb, skb->len); ih = igmp_hdr(skb); ih->type = <API key>; ih->code = (group ? br-><API key> : br-><API key>) / (HZ / IGMP_TIMER_SCALE); ih->group = group; ih->csum = 0; ih->csum = ip_compute_csum((void *)ih, sizeof(struct igmphdr)); skb_put(skb, sizeof(*ih)); __skb_pull(skb, sizeof(*eth)); out: return skb; } #if IS_ENABLED(CONFIG_IPV6) static struct sk_buff *<API key>(struct net_bridge *br, const struct in6_addr *group) { struct sk_buff *skb; struct ipv6hdr *ip6h; struct mld_msg *mldq; struct ethhdr *eth; u8 *hopopt; unsigned long interval; skb = <API key>(br->dev, sizeof(*eth) + sizeof(*ip6h) + 8 + sizeof(*mldq)); if (!skb) goto out; skb->protocol = htons(ETH_P_IPV6); /* Ethernet header */ <API key>(skb); eth = eth_hdr(skb); memcpy(eth->h_source, br->dev->dev_addr, 6); eth->h_proto = htons(ETH_P_IPV6); skb_put(skb, sizeof(*eth)); /* IPv6 header + HbH option */ <API key>(skb, skb->len); ip6h = ipv6_hdr(skb); *(__force __be32 *)ip6h = htonl(0x60000000); ip6h->payload_len = htons(8 + sizeof(*mldq)); ip6h->nexthdr = IPPROTO_HOPOPTS; ip6h->hop_limit = 1; ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1)); if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0, &ip6h->saddr)) { kfree_skb(skb); return NULL; } ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); hopopt = (u8 *)(ip6h + 1); hopopt[0] = IPPROTO_ICMPV6; /* next hdr */ hopopt[1] = 0; /* length of HbH */ hopopt[2] = <API key>; /* Router Alert */ hopopt[3] = 2; /* Length of RA Option */ hopopt[4] = 0; /* Type = 0x0000 (MLD) */ hopopt[5] = 0; hopopt[6] = IPV6_TLV_PAD0; /* Pad0 */ hopopt[7] = IPV6_TLV_PAD0; /* Pad0 */ skb_put(skb, sizeof(*ip6h) + 8); /* ICMPv6 */ <API key>(skb, skb->len); mldq = (struct mld_msg *) icmp6_hdr(skb); interval = ipv6_addr_any(group) ? br-><API key> : br-><API key>; mldq->mld_type = ICMPV6_MGM_QUERY; mldq->mld_code = 0; mldq->mld_cksum = 0; mldq->mld_maxdelay = htons((u16)jiffies_to_msecs(interval)); mldq->mld_reserved = 0; mldq->mld_mca = *group; /* checksum */ mldq->mld_cksum = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, sizeof(*mldq), IPPROTO_ICMPV6, csum_partial(mldq, sizeof(*mldq), 0)); skb_put(skb, sizeof(*mldq)); __skb_pull(skb, sizeof(*eth)); out: return skb; } #endif static struct sk_buff *<API key>(struct net_bridge *br, struct br_ip *addr) { switch (addr->proto) { case htons(ETH_P_IP): return <API key>(br, addr->u.ip4); #if IS_ENABLED(CONFIG_IPV6) case htons(ETH_P_IPV6): return <API key>(br, &addr->u.ip6); #endif } return NULL; } static struct <API key> *<API key>( struct net_bridge *br, struct net_bridge_port *port, struct br_ip *group, int hash) { struct <API key> *mdb; struct <API key> *mp; struct hlist_node *p; unsigned count = 0; unsigned max; int elasticity; int err; mdb = <API key>(br->mdb, 1); <API key>(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) { count++; if (unlikely(br_ip_equal(group, &mp->addr))) return mp; } elasticity = 0; max = mdb->max; if (unlikely(count > br->hash_elasticity && count)) { if (net_ratelimit()) br_info(br, "Multicast hash table " "chain limit reached: %s\n", port ? port->dev->name : br->dev->name); elasticity = br->hash_elasticity; } if (mdb->size >= max) { max *= 2; if (unlikely(max >= br->hash_max)) { br_warn(br, "Multicast hash table maximum " "reached, disabling snooping: %s, %d\n", port ? port->dev->name : br->dev->name, max); err = -E2BIG; disable: br->multicast_disabled = 1; goto err; } } if (max > mdb->max || elasticity) { if (mdb->old) { if (net_ratelimit()) br_info(br, "Multicast hash table " "on fire: %s\n", port ? port->dev->name : br->dev->name); err = -EEXIST; goto err; } err = br_mdb_rehash(&br->mdb, max, elasticity); if (err) { br_warn(br, "Cannot rehash multicast " "hash table, disabling snooping: %s, %d, %d\n", port ? port->dev->name : br->dev->name, mdb->size, err); goto disable; } err = -EAGAIN; goto err; } return NULL; err: mp = ERR_PTR(err); return mp; } static struct <API key> *<API key>( struct net_bridge *br, struct net_bridge_port *port, struct br_ip *group) { struct <API key> *mdb; struct <API key> *mp; int hash; int err; mdb = <API key>(br->mdb, 1); if (!mdb) { err = br_mdb_rehash(&br->mdb, BR_HASH_SIZE, 0); if (err) return ERR_PTR(err); goto rehash; } hash = br_ip_hash(mdb, group); mp = <API key>(br, port, group, hash); switch (PTR_ERR(mp)) { case 0: break; case -EAGAIN: rehash: mdb = <API key>(br->mdb, 1); hash = br_ip_hash(mdb, group); break; default: goto out; } mp = kzalloc(sizeof(*mp), GFP_ATOMIC); if (unlikely(!mp)) return ERR_PTR(-ENOMEM); mp->br = br; mp->addr = *group; setup_timer(&mp->timer, <API key>, (unsigned long)mp); hlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]); mdb->size++; out: return mp; } static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct br_ip *group) { struct <API key> *mp; struct <API key> *p; struct <API key> __rcu **pp; unsigned long now = jiffies; int err; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || (port && port->state == BR_STATE_DISABLED)) goto out; mp = <API key>(br, port, group); err = PTR_ERR(mp); if (IS_ERR(mp)) goto err; if (!port) { mp->mglist = true; mod_timer(&mp->timer, now + br-><API key>); goto out; } for (pp = &mp->ports; (p = mlock_dereference(*pp, br)) != NULL; pp = &p->next) { if (p->port == port) goto found; if ((unsigned long)p->port < (unsigned long)port) break; } p = kzalloc(sizeof(*p), GFP_ATOMIC); err = -ENOMEM; if (unlikely(!p)) goto err; p->addr = *group; p->port = port; p->next = *pp; hlist_add_head(&p->mglist, &port->mglist); setup_timer(&p->timer, <API key>, (unsigned long)p); rcu_assign_pointer(*pp, p); found: mod_timer(&p->timer, now + br-><API key>); out: err = 0; err: spin_unlock(&br->multicast_lock); return err; } static int <API key>(struct net_bridge *br, struct net_bridge_port *port, __be32 group) { struct br_ip br_group; if (<API key>(group)) return 0; br_group.u.ip4 = group; br_group.proto = htons(ETH_P_IP); return <API key>(br, port, &br_group); } #if IS_ENABLED(CONFIG_IPV6) static int <API key>(struct net_bridge *br, struct net_bridge_port *port, const struct in6_addr *group) { struct br_ip br_group; if (!<API key>(group)) return 0; br_group.u.ip6 = *group; br_group.proto = htons(ETH_P_IPV6); return <API key>(br, port, &br_group); } #endif static void <API key>(unsigned long data) { struct net_bridge_port *port = (void *)data; struct net_bridge *br = port->br; spin_lock(&br->multicast_lock); if (port->multicast_router != 1 || timer_pending(&port-><API key>) || hlist_unhashed(&port->rlist)) goto out; hlist_del_init_rcu(&port->rlist); out: spin_unlock(&br->multicast_lock); } static void <API key>(unsigned long data) { } static void <API key>(struct net_bridge *br, struct net_bridge_port *port, struct br_ip *ip) { struct sk_buff *skb; skb = <API key>(br, ip); if (!skb) return; if (port) { __skb_push(skb, sizeof(struct ethhdr)); skb->dev = port->dev; NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, dev_queue_xmit); } else netif_rx(skb); } static void <API key>(struct net_bridge *br, struct net_bridge_port *port, u32 sent) { unsigned long time; struct br_ip br_group; if (!netif_running(br->dev) || br->multicast_disabled || timer_pending(&br-><API key>)) return; memset(&br_group.u, 0, sizeof(br_group.u)); br_group.proto = htons(ETH_P_IP); <API key>(br, port, &br_group); #if IS_ENABLED(CONFIG_IPV6) br_group.proto = htons(ETH_P_IPV6); <API key>(br, port, &br_group); #endif time = jiffies; time += sent < br-><API key> ? br-><API key> : br-><API key>; mod_timer(port ? &port-><API key> : &br-><API key>, time); } static void <API key>(unsigned long data) { struct net_bridge_port *port = (void *)data; struct net_bridge *br = port->br; spin_lock(&br->multicast_lock); if (port->state == BR_STATE_DISABLED || port->state == BR_STATE_BLOCKING) goto out; if (port-><API key> < br-><API key>) port-><API key>++; <API key>(port->br, port, port-><API key>); out: spin_unlock(&br->multicast_lock); } void <API key>(struct net_bridge_port *port) { port->multicast_router = 1; setup_timer(&port-><API key>, <API key>, (unsigned long)port); setup_timer(&port-><API key>, <API key>, (unsigned long)port); } void <API key>(struct net_bridge_port *port) { del_timer_sync(&port-><API key>); } static void <API key>(struct net_bridge_port *port) { port-><API key> = 0; if (<API key>(&port-><API key>) >= 0 || del_timer(&port-><API key>)) mod_timer(&port-><API key>, jiffies); } void <API key>(struct net_bridge_port *port) { struct net_bridge *br = port->br; spin_lock(&br->multicast_lock); if (br->multicast_disabled || !netif_running(br->dev)) goto out; <API key>(port); out: spin_unlock(&br->multicast_lock); } void <API key>(struct net_bridge_port *port) { struct net_bridge *br = port->br; struct <API key> *pg; struct hlist_node *p, *n; spin_lock(&br->multicast_lock); <API key>(pg, p, n, &port->mglist, mglist) br_multicast_del_pg(br, pg); if (!hlist_unhashed(&port->rlist)) hlist_del_init_rcu(&port->rlist); del_timer(&port-><API key>); del_timer(&port-><API key>); spin_unlock(&br->multicast_lock); } static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { struct igmpv3_report *ih; struct igmpv3_grec *grec; int i; int len; int num; int type; int err = 0; __be32 group; if (!pskb_may_pull(skb, sizeof(*ih))) return -EINVAL; ih = igmpv3_report_hdr(skb); num = ntohs(ih->ngrec); len = sizeof(*ih); for (i = 0; i < num; i++) { len += sizeof(*grec); if (!pskb_may_pull(skb, len)) return -EINVAL; grec = (void *)(skb->data + len - sizeof(*grec)); group = grec->grec_mca; type = grec->grec_type; len += ntohs(grec->grec_nsrcs) * 4; if (!pskb_may_pull(skb, len)) return -EINVAL; /* We treat this as an IGMPv2 report for now. */ switch (type) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: break; default: continue; } err = <API key>(br, port, group); if (err) break; } return err; } #if IS_ENABLED(CONFIG_IPV6) static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { struct icmp6hdr *icmp6h; struct mld2_grec *grec; int i; int len; int num; int err = 0; if (!pskb_may_pull(skb, sizeof(*icmp6h))) return -EINVAL; icmp6h = icmp6_hdr(skb); num = ntohs(icmp6h->icmp6_dataun.un_data16[1]); len = sizeof(*icmp6h); for (i = 0; i < num; i++) { __be16 *nsrcs, _nsrcs; nsrcs = skb_header_pointer(skb, len + offsetof(struct mld2_grec, grec_nsrcs), sizeof(_nsrcs), &_nsrcs); if (!nsrcs) return -EINVAL; if (!pskb_may_pull(skb, len + sizeof(*grec) + sizeof(struct in6_addr) * ntohs(*nsrcs))) return -EINVAL; grec = (struct mld2_grec *)(skb->data + len); len += sizeof(*grec) + sizeof(struct in6_addr) * ntohs(*nsrcs); /* We treat these as MLDv1 reports for now. */ switch (grec->grec_type) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: break; default: continue; } err = <API key>(br, port, &grec->grec_mca); if (err) break; } return err; } #endif /* * Add port to rotuer_list * list is maintained ordered by pointer value * and locked by br->multicast_lock and RCU */ static void <API key>(struct net_bridge *br, struct net_bridge_port *port) { struct net_bridge_port *p; struct hlist_node *n, *slot = NULL; if (!hlist_unhashed(&port->rlist)) return; <API key>(p, n, &br->router_list, rlist) { if ((unsigned long) port >= (unsigned long) p) break; slot = n; } if (slot) hlist_add_after_rcu(slot, &port->rlist); else hlist_add_head_rcu(&port->rlist, &br->router_list); } static void <API key>(struct net_bridge *br, struct net_bridge_port *port) { unsigned long now = jiffies; if (!port) { if (br->multicast_router == 1) mod_timer(&br-><API key>, now + br-><API key>); return; } if (port->multicast_router != 1) return; <API key>(br, port); mod_timer(&port-><API key>, now + br-><API key>); } static void <API key>(struct net_bridge *br, struct net_bridge_port *port, int saddr) { if (saddr) mod_timer(&br-><API key>, jiffies + br-><API key>); else if (timer_pending(&br-><API key>)) return; <API key>(br, port); } static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { const struct iphdr *iph = ip_hdr(skb); struct igmphdr *ih = igmp_hdr(skb); struct <API key> *mp; struct igmpv3_query *ih3; struct <API key> *p; struct <API key> __rcu **pp; unsigned long max_delay; unsigned long now = jiffies; __be32 group; int err = 0; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || (port && port->state == BR_STATE_DISABLED)) goto out; <API key>(br, port, !!iph->saddr); group = ih->group; if (skb->len == sizeof(*ih)) { max_delay = ih->code * (HZ / IGMP_TIMER_SCALE); if (!max_delay) { max_delay = 10 * HZ; group = 0; } } else { if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) { err = -EINVAL; goto out; } ih3 = igmpv3_query_hdr(skb); if (ih3->nsrcs) goto out; max_delay = ih3->code ? IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1; } if (!group) goto out; mp = br_mdb_ip4_get(mlock_dereference(br->mdb, br), group); if (!mp) goto out; max_delay *= br-><API key>; if (mp->mglist && (timer_pending(&mp->timer) ? time_after(mp->timer.expires, now + max_delay) : <API key>(&mp->timer) >= 0)) mod_timer(&mp->timer, now + max_delay); for (pp = &mp->ports; (p = mlock_dereference(*pp, br)) != NULL; pp = &p->next) { if (timer_pending(&p->timer) ? time_after(p->timer.expires, now + max_delay) : <API key>(&p->timer) >= 0) mod_timer(&p->timer, now + max_delay); } out: spin_unlock(&br->multicast_lock); return err; } #if IS_ENABLED(CONFIG_IPV6) static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { const struct ipv6hdr *ip6h = ipv6_hdr(skb); struct mld_msg *mld = (struct mld_msg *) icmp6_hdr(skb); struct <API key> *mp; struct mld2_query *mld2q; struct <API key> *p; struct <API key> __rcu **pp; unsigned long max_delay; unsigned long now = jiffies; const struct in6_addr *group = NULL; int err = 0; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || (port && port->state == BR_STATE_DISABLED)) goto out; <API key>(br, port, !ipv6_addr_any(&ip6h->saddr)); /* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */ if (!(ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL)) { err = -EINVAL; goto out; } if (skb->len == sizeof(*mld)) { if (!pskb_may_pull(skb, sizeof(*mld))) { err = -EINVAL; goto out; } mld = (struct mld_msg *) icmp6_hdr(skb); max_delay = msecs_to_jiffies(htons(mld->mld_maxdelay)); if (max_delay) group = &mld->mld_mca; } else if (skb->len >= sizeof(*mld2q)) { if (!pskb_may_pull(skb, sizeof(*mld2q))) { err = -EINVAL; goto out; } mld2q = (struct mld2_query *)icmp6_hdr(skb); if (!mld2q->mld2q_nsrcs) group = &mld2q->mld2q_mca; max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mld2q->mld2q_mrc))), 1UL); } if (!group) goto out; mp = br_mdb_ip6_get(mlock_dereference(br->mdb, br), group); if (!mp) goto out; max_delay *= br-><API key>; if (mp->mglist && (timer_pending(&mp->timer) ? time_after(mp->timer.expires, now + max_delay) : <API key>(&mp->timer) >= 0)) mod_timer(&mp->timer, now + max_delay); for (pp = &mp->ports; (p = mlock_dereference(*pp, br)) != NULL; pp = &p->next) { if (timer_pending(&p->timer) ? time_after(p->timer.expires, now + max_delay) : <API key>(&p->timer) >= 0) mod_timer(&p->timer, now + max_delay); } out: spin_unlock(&br->multicast_lock); return err; } #endif static void <API key>(struct net_bridge *br, struct net_bridge_port *port, struct br_ip *group) { struct <API key> *mdb; struct <API key> *mp; struct <API key> *p; unsigned long now; unsigned long time; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || (port && port->state == BR_STATE_DISABLED) || timer_pending(&br-><API key>)) goto out; mdb = mlock_dereference(br->mdb, br); mp = br_mdb_ip_get(mdb, group); if (!mp) goto out; now = jiffies; time = now + br-><API key> * br-><API key>; if (!port) { if (mp->mglist && (timer_pending(&mp->timer) ? time_after(mp->timer.expires, time) : <API key>(&mp->timer) >= 0)) { mod_timer(&mp->timer, time); } goto out; } for (p = mlock_dereference(mp->ports, br); p != NULL; p = mlock_dereference(p->next, br)) { if (p->port != port) continue; if (!hlist_unhashed(&p->mglist) && (timer_pending(&p->timer) ? time_after(p->timer.expires, time) : <API key>(&p->timer) >= 0)) { mod_timer(&p->timer, time); } break; } out: spin_unlock(&br->multicast_lock); } static void <API key>(struct net_bridge *br, struct net_bridge_port *port, __be32 group) { struct br_ip br_group; if (<API key>(group)) return; br_group.u.ip4 = group; br_group.proto = htons(ETH_P_IP); <API key>(br, port, &br_group); } #if IS_ENABLED(CONFIG_IPV6) static void <API key>(struct net_bridge *br, struct net_bridge_port *port, const struct in6_addr *group) { struct br_ip br_group; if (!<API key>(group)) return; br_group.u.ip6 = *group; br_group.proto = htons(ETH_P_IPV6); <API key>(br, port, &br_group); } #endif static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { struct sk_buff *skb2 = skb; const struct iphdr *iph; struct igmphdr *ih; unsigned len; unsigned offset; int err; /* We treat OOM as packet loss for now. */ if (!pskb_may_pull(skb, sizeof(*iph))) return -EINVAL; iph = ip_hdr(skb); if (iph->ihl < 5 || iph->version != 4) return -EINVAL; if (!pskb_may_pull(skb, ip_hdrlen(skb))) return -EINVAL; iph = ip_hdr(skb); if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl))) return -EINVAL; if (iph->protocol != IPPROTO_IGMP) { if ((iph->daddr & <API key>) != IGMP_LOCAL_GROUP) BR_INPUT_SKB_CB(skb)->mrouters_only = 1; return 0; } len = ntohs(iph->tot_len); if (skb->len < len || len < ip_hdrlen(skb)) return -EINVAL; if (skb->len > len) { skb2 = skb_clone(skb, GFP_ATOMIC); if (!skb2) return -ENOMEM; err = pskb_trim_rcsum(skb2, len); if (err) goto err_out; } len -= ip_hdrlen(skb2); offset = skb_network_offset(skb2) + ip_hdrlen(skb2); __skb_pull(skb2, offset); <API key>(skb2); err = -EINVAL; if (!pskb_may_pull(skb2, sizeof(*ih))) goto out; switch (skb2->ip_summed) { case CHECKSUM_COMPLETE: if (!csum_fold(skb2->csum)) break; /* fall through */ case CHECKSUM_NONE: skb2->csum = 0; if (<API key>(skb2)) goto out; } err = 0; BR_INPUT_SKB_CB(skb)->igmp = 1; ih = igmp_hdr(skb2); switch (ih->type) { case <API key>: case <API key>: BR_INPUT_SKB_CB(skb)->mrouters_only = 1; err = <API key>(br, port, ih->group); break; case <API key>: err = <API key>(br, port, skb2); break; case <API key>: err = <API key>(br, port, skb2); break; case <API key>: <API key>(br, port, ih->group); break; } out: __skb_push(skb2, offset); err_out: if (skb2 != skb) kfree_skb(skb2); return err; } #if IS_ENABLED(CONFIG_IPV6) static int <API key>(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { struct sk_buff *skb2; const struct ipv6hdr *ip6h; u8 icmp6_type; u8 nexthdr; __be16 frag_off; unsigned len; int offset; int err; if (!pskb_may_pull(skb, sizeof(*ip6h))) return -EINVAL; ip6h = ipv6_hdr(skb); /* * We're interested in MLD messages only. * - Version is 6 * - MLD has always Router Alert hop-by-hop option * - But we do not support jumbrograms. */ if (ip6h->version != 6 || ip6h->nexthdr != IPPROTO_HOPOPTS || ip6h->payload_len == 0) return 0; len = ntohs(ip6h->payload_len) + sizeof(*ip6h); if (skb->len < len) return -EINVAL; nexthdr = ip6h->nexthdr; offset = ipv6_skip_exthdr(skb, sizeof(*ip6h), &nexthdr, &frag_off); if (offset < 0 || nexthdr != IPPROTO_ICMPV6) return 0; /* Okay, we found ICMPv6 header */ skb2 = skb_clone(skb, GFP_ATOMIC); if (!skb2) return -ENOMEM; err = -EINVAL; if (!pskb_may_pull(skb2, offset + sizeof(struct icmp6hdr))) goto out; len -= offset - skb_network_offset(skb2); __skb_pull(skb2, offset); <API key>(skb2); skb_postpull_rcsum(skb2, skb_network_header(skb2), <API key>(skb2)); icmp6_type = icmp6_hdr(skb2)->icmp6_type; switch (icmp6_type) { case ICMPV6_MGM_QUERY: case ICMPV6_MGM_REPORT: case <API key>: case ICMPV6_MLD2_REPORT: break; default: err = 0; goto out; } /* Okay, we found MLD message. Check further. */ if (skb2->len > len) { err = pskb_trim_rcsum(skb2, len); if (err) goto out; err = -EINVAL; } ip6h = ipv6_hdr(skb2); switch (skb2->ip_summed) { case CHECKSUM_COMPLETE: if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, skb2->len, IPPROTO_ICMPV6, skb2->csum)) break; /*FALLTHROUGH*/ case CHECKSUM_NONE: skb2->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, skb2->len, IPPROTO_ICMPV6, 0)); if (<API key>(skb2)) goto out; } err = 0; BR_INPUT_SKB_CB(skb)->igmp = 1; switch (icmp6_type) { case ICMPV6_MGM_REPORT: { struct mld_msg *mld; if (!pskb_may_pull(skb2, sizeof(*mld))) { err = -EINVAL; goto out; } mld = (struct mld_msg *)<API key>(skb2); BR_INPUT_SKB_CB(skb)->mrouters_only = 1; err = <API key>(br, port, &mld->mld_mca); break; } case ICMPV6_MLD2_REPORT: err = <API key>(br, port, skb2); break; case ICMPV6_MGM_QUERY: err = <API key>(br, port, skb2); break; case <API key>: { struct mld_msg *mld; if (!pskb_may_pull(skb2, sizeof(*mld))) { err = -EINVAL; goto out; } mld = (struct mld_msg *)<API key>(skb2); <API key>(br, port, &mld->mld_mca); } } out: kfree_skb(skb2); return err; } #endif int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { BR_INPUT_SKB_CB(skb)->igmp = 0; BR_INPUT_SKB_CB(skb)->mrouters_only = 0; if (br->multicast_disabled) return 0; switch (skb->protocol) { case htons(ETH_P_IP): return <API key>(br, port, skb); #if IS_ENABLED(CONFIG_IPV6) case htons(ETH_P_IPV6): return <API key>(br, port, skb); #endif } return 0; } static void <API key>(unsigned long data) { struct net_bridge *br = (void *)data; spin_lock(&br->multicast_lock); if (br-><API key> < br-><API key>) br-><API key>++; <API key>(br, NULL, br-><API key>); spin_unlock(&br->multicast_lock); } void br_multicast_init(struct net_bridge *br) { br->hash_elasticity = 4; br->hash_max = 512; br->multicast_router = 1; br-><API key> = 2; br-><API key> = 2; br-><API key> = HZ; br-><API key> = 10 * HZ; br-><API key> = 125 * HZ / 4; br-><API key> = 125 * HZ; br-><API key> = 255 * HZ; br-><API key> = 260 * HZ; spin_lock_init(&br->multicast_lock); setup_timer(&br-><API key>, <API key>, 0); setup_timer(&br-><API key>, <API key>, 0); setup_timer(&br-><API key>, <API key>, (unsigned long)br); } void br_multicast_open(struct net_bridge *br) { br-><API key> = 0; if (br->multicast_disabled) return; mod_timer(&br-><API key>, jiffies); } void br_multicast_stop(struct net_bridge *br) { struct <API key> *mdb; struct <API key> *mp; struct hlist_node *p, *n; u32 ver; int i; del_timer_sync(&br-><API key>); del_timer_sync(&br-><API key>); del_timer_sync(&br-><API key>); spin_lock_bh(&br->multicast_lock); mdb = mlock_dereference(br->mdb, br); if (!mdb) goto out; br->mdb = NULL; ver = mdb->ver; for (i = 0; i < mdb->max; i++) { <API key>(mp, p, n, &mdb->mhash[i], hlist[ver]) { del_timer(&mp->timer); call_rcu_bh(&mp->rcu, <API key>); } } if (mdb->old) { spin_unlock_bh(&br->multicast_lock); rcu_barrier_bh(); spin_lock_bh(&br->multicast_lock); WARN_ON(mdb->old); } mdb->old = mdb; call_rcu_bh(&mdb->rcu, br_mdb_free); out: spin_unlock_bh(&br->multicast_lock); } int <API key>(struct net_bridge *br, unsigned long val) { int err = -ENOENT; spin_lock_bh(&br->multicast_lock); if (!netif_running(br->dev)) goto unlock; switch (val) { case 0: case 2: del_timer(&br-><API key>); /* fall through */ case 1: br->multicast_router = val; err = 0; break; default: err = -EINVAL; break; } unlock: spin_unlock_bh(&br->multicast_lock); return err; } int <API key>(struct net_bridge_port *p, unsigned long val) { struct net_bridge *br = p->br; int err = -ENOENT; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || p->state == BR_STATE_DISABLED) goto unlock; switch (val) { case 0: case 1: case 2: p->multicast_router = val; err = 0; if (val < 2 && !hlist_unhashed(&p->rlist)) hlist_del_init_rcu(&p->rlist); if (val == 1) break; del_timer(&p-><API key>); if (val == 0) break; <API key>(br, p); break; default: err = -EINVAL; break; } unlock: spin_unlock(&br->multicast_lock); return err; } int br_multicast_toggle(struct net_bridge *br, unsigned long val) { struct net_bridge_port *port; int err = 0; struct <API key> *mdb; spin_lock_bh(&br->multicast_lock); if (br->multicast_disabled == !val) goto unlock; br->multicast_disabled = !val; if (br->multicast_disabled) goto unlock; if (!netif_running(br->dev)) goto unlock; mdb = mlock_dereference(br->mdb, br); if (mdb) { if (mdb->old) { err = -EEXIST; rollback: br->multicast_disabled = !!val; goto unlock; } err = br_mdb_rehash(&br->mdb, mdb->max, br->hash_elasticity); if (err) goto rollback; } br_multicast_open(br); list_for_each_entry(port, &br->port_list, list) { if (port->state == BR_STATE_DISABLED || port->state == BR_STATE_BLOCKING) continue; <API key>(port); } unlock: spin_unlock_bh(&br->multicast_lock); return err; } int <API key>(struct net_bridge *br, unsigned long val) { int err = -ENOENT; u32 old; struct <API key> *mdb; spin_lock_bh(&br->multicast_lock); if (!netif_running(br->dev)) goto unlock; err = -EINVAL; if (!is_power_of_2(val)) goto unlock; mdb = mlock_dereference(br->mdb, br); if (mdb && val < mdb->size) goto unlock; err = 0; old = br->hash_max; br->hash_max = val; if (mdb) { if (mdb->old) { err = -EEXIST; rollback: br->hash_max = old; goto unlock; } err = br_mdb_rehash(&br->mdb, br->hash_max, br->hash_elasticity); if (err) goto rollback; } unlock: spin_unlock_bh(&br->multicast_lock); return err; }
#include <ndb_global.h> #include <ndb_version.h> #include "<API key>.hpp" #include "Config.hpp" #include <NdbOut.hpp> #include "ConfigInfo.hpp" #include "EventLogger.hpp" #include <m_string.h> #include <util/SparseBitmask.hpp> #include "../common/util/parse_mask.hpp" extern EventLogger *g_eventLogger; const int MAX_LINE_LENGTH = 1024; // Max length of line of text in config file static void trim(char *); if (file == NULL) { return 0; } while (fgets(line, MAX_LINE_LENGTH, file)) { ctx.m_lineno++; trim(line); if (isEmptyLine(line)) // Skip if line is empty or comment continue; // End with NULL instead of newline if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; if (char* section = <API key>(line)) { if(!storeSection(ctx)){ free(section); ctx.reportError("Could not store previous default section " "of configuration file."); return 0; } BaseString::snprintf(ctx.fname, sizeof(ctx.fname), "%s", section); free(section); ctx.type = <API key>::DefaultSection; ctx.m_sectionLineno = ctx.m_lineno; ctx.m_currentSection = new Properties(true); ctx.m_userDefaults = NULL; require((ctx.m_currentInfo = m_info->getInfo(ctx.fname)) != 0); require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0); continue; } if (char* section = parseSectionHeader(line)) { if(!storeSection(ctx)){ free(section); ctx.reportError("Could not store previous section " "of configuration file."); return 0; } BaseString::snprintf(ctx.fname, sizeof(ctx.fname), "%s", section); free(section); ctx.type = <API key>::Section; ctx.m_sectionLineno = ctx.m_lineno; ctx.m_currentSection = new Properties(true); ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); require((ctx.m_currentInfo = m_info->getInfo(ctx.fname)) != 0); require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0); continue; } if (!parseNameValuePair(ctx, line)) { ctx.reportError("Could not parse name-value pair in config file."); return 0; } } if (ferror(file)){ ctx.reportError("Failure in reading"); return 0; } if(!storeSection(ctx)) { ctx.reportError("Could not store section of configuration file."); return 0; } return run_config_rules(ctx); } Config* <API key>::run_config_rules(Context& ctx) { for(size_t i = 0; ConfigInfo::m_ConfigRules[i].m_configRule != 0; i++){ ctx.type = <API key>::Undefined; ctx.m_info = m_info; ctx.m_currentSection = 0; ctx.m_userDefaults = 0; ctx.m_currentInfo = 0; ctx.m_systemDefaults = 0; Vector<ConfigInfo::ConfigRuleSection> tmp; if(!(* ConfigInfo::m_ConfigRules[i].m_configRule)(tmp, ctx, ConfigInfo::m_ConfigRules[i].m_ruleData)) return 0; for(unsigned j = 0; j<tmp.size(); j++){ BaseString::snprintf(ctx.fname, sizeof(ctx.fname), "%s", tmp[j].m_sectionType.c_str()); ctx.type = <API key>::Section; ctx.m_currentSection = tmp[j].m_sectionData; ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); require((ctx.m_currentInfo = m_info->getInfo(ctx.fname)) != 0); require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0); if(!storeSection(ctx)) return 0; } } Uint32 nConnections = 0; Uint32 nComputers = 0; Uint32 nNodes = 0; Uint32 nExtConnections = 0; const char * system = "?"; ctx.m_userProperties.get("NoOfConnections", &nConnections); ctx.m_userProperties.get("NoOfComputers", &nComputers); ctx.m_userProperties.get("NoOfNodes", &nNodes); ctx.m_userProperties.get("ExtNoOfConnections", &nExtConnections); ctx.m_userProperties.get("ExtSystem", &system); ctx.m_config->put("NoOfConnections", nConnections); ctx.m_config->put("NoOfComputers", nComputers); ctx.m_config->put("NoOfNodes", nNodes); char tmpLine[MAX_LINE_LENGTH]; BaseString::snprintf(tmpLine, MAX_LINE_LENGTH, "EXTERNAL SYSTEM_%s:NoOfConnections", system); ctx.m_config->put(tmpLine, nExtConnections); return new Config(ctx.m_configValues.getConfigValues()); } /** * Add ndbd, ndb_mgmd, api/mysqld */ Uint32 idx = options.size(); { struct my_option opt; memset(&opt, 0, sizeof(opt)); opt.name = "ndbd"; opt.id = 256; opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "ndb_mgmd"; opt.id = 256; opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "mysqld"; opt.id = 256; opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "ndbapi"; opt.id = 256; opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); memset(&opt, 0, sizeof(opt)); options.push_back(opt); ndbd = &options[idx]; ndb_mgmd = &options[idx+1]; mysqld = &options[idx+2]; api = &options[idx+3]; } Context ctx(m_info); const char *groups[]= { "cluster_config", 0 }; if (load_defaults(options, groups)) goto end; ctx.m_lineno = 0; if(!<API key>(options, ctx, "DB")) goto end; if(!<API key>(options, ctx, "API")) goto end; if(!<API key>(options, ctx, "MGM")) goto end; if(!<API key>(options, ctx, "TCP")) goto end; if(!<API key>(options, ctx, "SHM")) goto end; if(!<API key>(options, ctx, "SCI")) goto end; { struct sect { struct my_option* src; const char * name; } sections[] = { { ndb_mgmd, "MGM" }, { ndbd, "DB" }, { mysqld, "API" }, { api, "API" } }; for(unsigned i = 0; i + 1 < NDB_ARRAY_SIZE(sections) ; i++) { for(unsigned j = i + 1; j < NDB_ARRAY_SIZE(sections) ; j++) { if (sections[j].src->app_type < sections[i].src->app_type) { sect swap = sections[i]; sections[i] = sections[j]; sections[j] = swap; } } } ctx.type = <API key>::Section; ctx.m_sectionLineno = ctx.m_lineno; for(unsigned i = 0; i < NDB_ARRAY_SIZE(sections) ; i++) { if (sections[i].src->app_type) { strcpy(ctx.fname, sections[i].name); BaseString str(*(char**)sections[i].src->value); Vector<BaseString> list; str.split(list, ","); const char * defaults_groups[] = { 0, 0, 0 }; for(unsigned j = 0; j<list.size(); j++) { // Remove leading and trailing spaces from hostname list[j].trim(); BaseString group_idx; BaseString group_host; group_idx.assfmt("%s.%s.%d", groups[0], sections[i].src->name, j + 1); group_host.assfmt("%s.%s.%s", groups[0], sections[i].src->name, list[j].c_str()); defaults_groups[0] = group_idx.c_str(); if(list[j].length()) defaults_groups[1] = group_host.c_str(); else defaults_groups[1] = 0; ctx.m_currentSection = new Properties(true); ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); require((ctx.m_currentInfo = m_info->getInfo(ctx.fname)) != 0); require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname))!= 0); if(!load_mycnf_groups(options, ctx, sections[i].name, defaults_groups)) goto end; // The [cluster_config] section in my.cnf specifies the hostname, // but it can also be specified a second time in the nodes section // make sure they match if specified in both places, else // save the value from cluster_config section // Example: // [cluster_config] // ndbd=hostname1 // [cluster_config.ndbd.1] // HostName=hostname1 if (ctx.m_currentSection->contains("HostName")) { // HostName specified a second time, check that it matches const char* host_name; require(ctx.m_currentSection->get("HostName", &host_name)); if (strcmp(host_name, list[j].c_str())) { ctx.reportError("Illegal value 'HostName=%s' specified for " "%s, previously set to '%s'", host_name, group_idx.c_str(), list[j].c_str()); goto end; } } else { require(ctx.m_currentSection->put("HostName", list[j].c_str())); } if(!storeSection(ctx)) goto end; } } } } res = run_config_rules(ctx); end: for(int i = 0; options[i].name; i++) free(options[i].value); return res; } template class Vector<struct my_option>; /* See include/my_getopt.h for the declaration of struct my_option */
'use strict'; const common = require('../common.js'); const bench = common.createBenchmark(main, { pieces: [1, 4, 16], pieceSize: [1, 16, 256], withTotalLength: [0, 1], n: [1024] }); function main(conf) { const n = +conf.n; const size = +conf.pieceSize; const pieces = +conf.pieces; const list = new Array(pieces); list.fill(Buffer.allocUnsafe(size)); const totalLength = conf.withTotalLength ? pieces * size : undefined; bench.start(); for (var i = 0; i < n * 1024; i++) { Buffer.concat(list, totalLength); } bench.end(n); }
#include "config.h" #if ENABLE(INSPECTOR) && ENABLE(WORKERS) #include "WorkerRuntimeAgent.h" #include "InjectedScript.h" #include "InstrumentingAgents.h" #include "ScriptState.h" #include "WorkerContext.h" #include "WorkerDebuggerAgent.h" #include "WorkerRunLoop.h" #include "WorkerThread.h" namespace WebCore { WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents, <API key>* state, <API key>* <API key>, WorkerContext* workerContext) : <API key>(instrumentingAgents, state, <API key>) , m_workerContext(workerContext) , m_paused(false) { <API key>-><API key>(this); } WorkerRuntimeAgent::~WorkerRuntimeAgent() { <API key>-><API key>(0); } InjectedScript WorkerRuntimeAgent::<API key>(ErrorString* error, const int* executionContextId) { if (executionContextId) { *error = "Execution context id is not supported for workers as there is only one execution context."; return InjectedScript(); } ScriptState* scriptState = <API key>(m_workerContext); return <API key>()->injectedScriptFor(scriptState); } void WorkerRuntimeAgent::muteConsole() { // We don't need to mute console for workers. } void WorkerRuntimeAgent::unmuteConsole() { // We don't need to mute console for workers. } void WorkerRuntimeAgent::run(ErrorString*) { m_paused = false; } #if ENABLE(JAVASCRIPT_DEBUGGER) void WorkerRuntimeAgent::pauseWorkerContext(WorkerContext* context) { m_paused = true; <API key> result; do { result = context->thread()->runLoop().runInMode(context, WorkerDebuggerAgent::debuggerTaskMode); // Keep waiting until execution is resumed. } while (result == <API key> && m_paused); } #endif // ENABLE(JAVASCRIPT_DEBUGGER) } // namespace WebCore #endif // ENABLE(INSPECTOR) && ENABLE(WORKERS)
<?php require('includes/application_top.php'); $action = isset($_GET['action']) ? $_GET['action'] : ''; switch ($action) { case 'insert': case 'save': $return_reason_id = isset($_GET['oID']) ? <API key>($_GET['oID']) : 0; $languages = tep_get_languages(); for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { $<API key> = $_POST['return_reason_name']; $language_id = $languages[$i]['id']; $sql_data_array = array('return_reason_name' => <API key>($<API key>[$language_id])); if ($_GET['action'] == 'insert') { if (!tep_not_null($return_reason_id)) { $next_id_query = tep_db_query("select max(return_reason_id) as return_reason_id from " . <API key> . ""); $next_id = tep_db_fetch_array($next_id_query); $return_reason_id = $next_id['return_reason_id'] + 1; } $insert_sql_data = array('return_reason_id' => $return_reason_id, 'language_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(<API key>, $sql_data_array); } elseif ($_GET['action'] == 'save') { tep_db_perform(<API key>, $sql_data_array, 'update', "return_reason_id = '" . tep_db_input($return_reason_id) . "' and language_id = '" . $language_id . "'"); } } if ($_POST['default'] == 'on') { tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($return_reason_id) . "' where configuration_key = '<API key>'"); } tep_redirect(tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $return_reason_id)); break; case 'deleteconfirm': $oID = <API key>($_GET['oID']); $orders_status_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '<API key>'"); $orders_status = tep_db_fetch_array($orders_status_query); if ($orders_status['configuration_value'] == $oID) { tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = '<API key>'"); } tep_db_query("delete from " . <API key> . " where return_reason_id = '" . tep_db_input($oID) . "'"); tep_redirect(tep_href_link(<API key>, 'page=' . $_GET['page'])); break; case 'delete': $oID = <API key>($_GET['oID']); /* $status_query = tep_db_query("select count(*) as count from " . <API key> . " where orders_status = '" . tep_db_input($oID) . "'"); $status = tep_db_fetch_array($status_query); */ $remove_status = true; /* if ($oID == <API key>) { $remove_status = false; $messageStack->add(<API key>, 'error'); } elseif ($status['count'] > 0) { $remove_status = false; $messageStack->add(<API key>, 'error'); } else { $history_query = tep_db_query("select count(*) as count from " . <API key> . " where '" . tep_db_input($oID) . "' in (new_value, old_value)"); $history = tep_db_fetch_array($history_query); if ($history['count'] > 0) { $remove_status = false; $messageStack->add(<API key>, 'error'); } } break; */ } if (!isset($_GET['action'])) { $_GET['action'] = ''; } ?> <!DOCTYPE HTML PUBLIC "- <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <script type="text/javascript" src="<?php echo (($request_type == 'SSL') ? 'https:' : 'http:'); ?>//ajax.googleapis.com/ajax/libs/jquery/<?php echo JQUERY_VERSION; ?>/jquery.min.js"></script> <script type="text/javascript"> if (typeof jQuery == 'undefined') { //alert('You are running a local copy of jQuery!'); document.write(unescape("%3Cscript src='includes/javascript/jquery-1.6.2.min.js' type='text/javascript'%3E%3C/script%3E")); } </script> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <!--[if IE]> <link rel="stylesheet" type="text/css" href="includes/stylesheet-ie.css"> <![endif] <script language="javascript" src="includes/general.js"></script> <link rel="stylesheet" type="text/css" href="includes/headernavmenu.css"> <script type="text/javascript" src="includes/menu.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <!-- header <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof <!-- body <div id="body"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="body-table"> <tr> <!-- left_navigation <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof <!-- body_text <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td> </tr> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, <API key>); ?></td> </tr> </table></td> </tr> <tr> <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="data-table"> <tr class="dataTableHeadingRow"> <td class="<API key>"><?php echo <API key>; ?></td> <td class="<API key>" align="right"><?php echo <API key>; ?>&nbsp;</td> </tr> <?php $<API key> = "select return_reason_id, return_reason_name from " . <API key> . " where language_id = '" . $languages_id . "' order by return_reason_id"; $orders_status_split = new splitPageResults($_GET['page'], <API key>, $<API key>, $<API key>); $orders_status_query = tep_db_query($<API key>); while ($orders_status = tep_db_fetch_array($orders_status_query)) { if (((!isset($_GET['oID'])) || (isset($_GET['oID']) && $_GET['oID'] == $orders_status['return_reason_id'])) && (!isset($oInfo)) && ( substr($_GET['action'], 0, 3) != 'new')) { $oInfo = new objectInfo($orders_status); } if ( isset($oInfo) && (is_object($oInfo)) && ($orders_status['return_reason_id'] == $oInfo->return_reason_id) ) { echo ' <tr class="<API key>" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id . '&action=edit') . '\'">' . "\n"; } else { echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $orders_status['return_reason_id']) . '\'">' . "\n"; } if (<API key> == $orders_status['return_reason_id']) { echo ' <td class="dataTableContent"><b>' . $orders_status['return_reason_name'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n"; } else { echo ' <td class="dataTableContent">' . $orders_status['return_reason_name'] . '</td>' . "\n"; } ?> <td class="dataTableContent" align="right"><?php if ( isset($oInfo) && (is_object($oInfo)) && ($orders_status['return_reason_id'] == $oInfo->return_reason_id) ) { echo tep_image(DIR_WS_IMAGES . 'arrow_right_blue.png', ''); } else { echo '<a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $orders_status['return_reason_id']) . '">' . tep_image(DIR_WS_IMAGES . 'information.png', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td> </tr> <?php } ?> </table><table border="0" cellpadding="0" cellspacing="0" width="100%" class="data-table-foot"> <tr> <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" valign="top"><?php echo $orders_status_split->display_count($<API key>, <API key>, $_GET['page'], <API key>); ?></td> <td class="smallText" align="right"><?php echo $orders_status_split->display_links($<API key>, <API key>, <API key>, $_GET['page']); ?></td> </tr> <?php if (isset($_GET['action']) && substr($_GET['action'], 0, 3) != 'new') { ?> <tr> <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?>&nbsp;</td> </tr> <?php } ?> </table></td> </tr> </table></td> <?php $heading = array(); $contents = array(); $action = isset($_GET['action']) ? $_GET['action'] : ''; switch ($action) { case 'new': $heading[] = array('text' => '<b>' . <API key> . '</b>'); $contents = array('form' => tep_draw_form('status', <API key>, 'page=' . $_GET['page'] . '&action=insert')); $contents[] = array('text' => <API key>); $<API key> = ''; $languages = tep_get_languages(); for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { $<API key> .= '<br>' . tep_image(<API key> . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . <API key>('return_reason_name[' . $languages[$i]['id'] . ']'); } $contents[] = array('text' => '<br>' . <API key> . $<API key>); $contents[] = array('text' => '<br>' . <API key>('default') . ' ' . TEXT_SET_DEFAULT); $contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(<API key>, 'page=' . $_GET['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . tep_image_submit('button_insert.gif', IMAGE_INSERT)); break; case 'edit': $heading[] = array('text' => '<b>' . <API key> . '</b>'); $contents = array('form' => tep_draw_form('status', <API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id . '&action=save')); $contents[] = array('text' => <API key>); $<API key> = ''; $languages = tep_get_languages(); for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { $<API key> .= '<br>' . tep_image(<API key> . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . <API key>('return_reason_name[' . $languages[$i]['id'] . ']', <API key>($oInfo->return_reason_id, $languages[$i]['id'])); } $contents[] = array('text' => '<br>' . <API key> . $<API key>); if (<API key> != $oInfo->return_reason_id) $contents[] = array('text' => '<br>' . <API key>('default') . ' ' . TEXT_SET_DEFAULT); $contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . tep_image_submit('button_update.gif', IMAGE_UPDATE)); break; case 'delete': $heading[] = array('text' => '<b>' . <API key> . '</b>'); $contents = array('form' => tep_draw_form('status', <API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id . '&action=deleteconfirm')); $contents[] = array('text' => <API key>); $contents[] = array('text' => '<br><b>' . $oInfo->return_reason_name . '</b>'); if ($remove_status) $contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . tep_image_submit('button_delete.gif', IMAGE_DELETE)); break; default: if (isset($oInfo) && is_object($oInfo)) { $heading[] = array('text' => '<b>' . $oInfo->return_reason_name . '</b>'); $contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id . '&action=edit') . '">' . tep_image_button('button_page_edit.png', IMAGE_EDIT) . '</a><a href="' . tep_href_link(<API key>, 'page=' . $_GET['page'] . '&oID=' . $oInfo->return_reason_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); $<API key> = ''; $languages = tep_get_languages(); for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { $<API key> .= '<br>' . tep_image(<API key> . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . <API key>($oInfo->return_reason_id, $languages[$i]['id']); } $contents[] = array('text' => $<API key>); } break; } if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { echo ' <td width="25%" valign="top">' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo ' </td>' . "\n"; } ?> </tr> </table></td> </tr> </table></td> <!-- body_text_eof </tr> </table> </div> <!-- body_eof <!-- footer <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
#!/usr/bin/perl use warnings; use strict; use CGI; use Graphics::Magick; use POSIX qw(ceil); use autouse 'Data::Dumper' => qw(Dumper); use C4::Context; use C4::Auth; use C4::Output; use C4::Debug; use C4::Creators 1.000000; use C4::Patroncards 1.000000; my $cgi = CGI->new; my ($template, $loggedinuser, $cookie) = <API key>({ template_name => "patroncards/image-manage.tmpl", query => $cgi, type => "intranet", authnotrequired => 0, flagsrequired => {tools => '<API key>'}, # FIXME: establish flag for patron card creator debug => 0, }); my $image_name = $cgi->param('image_name') || ''; my $file_name = $cgi->param('uploadfile') || ''; my $upload_file = $cgi->upload('uploadfile') || ''; my $op = $cgi->param('op') || 'none'; my @image_ids = $cgi->param('image_id') if $cgi->param('image_id'); my $source_file = "$file_name"; # otherwise we end up with what amounts to a pointer to a filehandle rather than a user-friendly filename my $display_columns = { image => [ #{db column => {label => 'col label', is link? }}, {image_id => {label => 'ID', link_field => 0}}, {image_name => {label => 'Name', link_field => 0}}, {select => {label => 'Select', value => 'image_id'}}, ], }; my $table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name")); my $image_limit = C4::Context->preference('ImageLimit') || ''; my $errstr = ''; # NOTE: For error codes see error-messages.inc if ($op eq 'upload') { if (!$upload_file) { warn sprintf('An error occurred while attempting to upload file %s.', $source_file); $errstr = 301; $template->param( IMPORT_SUCCESSFUL => 0, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, error => 1, $errstr => 1, ); } else { my $image = Graphics::Magick->new; eval{$image->Read($cgi->tmpFileName($file_name));}; if ($@) { warn sprintf('An error occurred while creating the image object: %s',$@); $errstr = 202; $template->param( IMPORT_SUCCESSFUL => 0, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, error => 1, $errstr => 1, ); } else { my $errstr = ''; my $size = $image->Get('filesize'); $errstr = 302 if $size > 500000; $image->Set(magick => 'png'); # convert all images to png as this is a lossless format which is important for resizing operations later on my $err = put_image($image_name, $image->ImageToBlob()) || '0'; $errstr = 101 if $err == 1; $errstr = 303 if $err == 202; if ($errstr) { $template->param( IMPORT_SUCCESSFUL => 0, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, error => 1, $errstr => 1, image_limit => $image_limit, ); } else { $table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name")); # refresh table data after successfully performing save operation $template->param( IMPORT_SUCCESSFUL => 1, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, ); } } } } elsif ($op eq 'delete') { my $err = ''; my $errstr = ''; if (@image_ids) { $err = rm_image(\@image_ids); $errstr = 102 if $err; } else { warn sprintf('No image ids passed in to delete.'); $errstr = 202; } if ($errstr) { $template->param( DELETE_SUCCESSFULL => 0, IMAGE_IDS => join(', ', @image_ids), TABLE => $table, error => 1, $errstr => 1, image_ids => join(',',@image_ids), ); } else { $table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name")); # refresh table data after successfully performing delete operation $template->param( DELETE_SUCCESSFULL => 1, TABLE => $table, ); } } elsif ($op eq 'none') { $template->param( IMPORT_SUCCESSFUL => 0, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, ); } else { # to trap unsupported operations warn sprintf('Image upload interface called an unsupported operation: %s',$op); $errstr = 201; $template->param( IMPORT_SUCCESSFUL => 0, SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, error => 1, $errstr => 1, ); } <API key> $cgi, $cookie, $template->output; __END__ =head1 NAME image-upload.pl - Script for handling uploading of single images and importing them into the database. =head1 SYNOPSIS image-upload.pl =head1 DESCRIPTION This script is called and presents the user with an interface allowing him/her to upload a single image file. Files greater than 500K will be refused. =head1 AUTHOR Chris Nighswonger <cnighswonger AT foundations DOT edu> =head1 COPYRIGHT Copyright 2009 Foundations Bible College. =head1 LICENSE This file is part of Koha. Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. =head1 DISCLAIMER OF WARRANTY Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. =cut
#include <time.h> #include <unistd.h> int usleep (useconds_t useconds) { struct timespec ts = { .tv_sec = (long int) (useconds / 1000000), .tv_nsec = (long int) (useconds % 1000000) * 1000ul }; /* Note the usleep() is a cancellation point. But since we call nanosleep() which itself is a cancellation point we do not have to do anything here. */ return __nanosleep (&ts, NULL); }
{% extends "allianceauth/base.html" %} {% load bootstrap %} {% load staticfiles %} {% load i18n %} {% block page_title %}{% trans "Jabber Broadcast" %}{% endblock page_title %} {% block extra_css %}{% endblock extra_css %} {% block content %} <div class="col-lg-12"> <h1 class="page-header text-center">{% trans "Jabber Broadcast" %}</h1> <div class="container-fluid"> <div class="col-md-4 col-md-offset-4"> <div class="row"> {% if success %} <div class="alert alert-success" role="alert">{% trans "Broadcast Sent!!" %}</div> {% endif %} <form class="form-signin" role="form" action="" method="POST" onsubmit="submitbutton.disabled = true; return true;"> {% csrf_token %} {{ form|bootstrap }} <br/> <button class="btn btn-lg btn-primary btn-block" name="submitbutton" type="submit">{% trans "Broadcast" %} </button> </form> </div> </div> </div> </div> {% endblock content %}
#include <config.h> #include "testutils.h" #ifdef WITH_OPENVZ # include <stdio.h> # include <string.h> # include <unistd.h> # include "internal.h" # include "viralloc.h" # include "openvz/openvz_conf.h" # include "virstring.h" # define VIR_FROM_THIS VIR_FROM_OPENVZ static int testLocateConfFile(int vpsid ATTRIBUTE_UNUSED, char **conffile, const char *ext ATTRIBUTE_UNUSED) { return virAsprintf(conffile, "%s/openvzutilstest.conf", abs_srcdir); } struct testConfigParam { const char *param; const char *value; int ret; }; static struct testConfigParam configParams[] = { { "OSTEMPLATE", "rhel-5-lystor", 1 }, { "IP_ADDRESS", "194.44.18.88", 1 }, { "<API key>", NULL, 0 }, }; static int testReadConfigParam(const void *data ATTRIBUTE_UNUSED) { int result = -1; size_t i; char *conf = NULL; char *value = NULL; if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0) return -1; for (i = 0; i < ARRAY_CARDINALITY(configParams); ++i) { if (<API key>(conf, configParams[i].param, &value) != configParams[i].ret) { goto cleanup; } if (configParams[i].ret != 1) continue; if (STRNEQ(configParams[i].value, value)) { virtTestDifference(stderr, configParams[i].value, value); goto cleanup; } } result = 0; cleanup: VIR_FREE(conf); VIR_FREE(value); return result; } static int testReadNetworkConf(const void *data ATTRIBUTE_UNUSED) { int result = -1; virDomainDefPtr def = NULL; char *actual = NULL; virErrorPtr err = NULL; const char *expected = "<domain type='openvz'>\n" " <uuid><API key></uuid>\n" " <memory unit='KiB'>0</memory>\n" " <currentMemory unit='KiB'>0</currentMemory>\n" " <vcpu placement='static'>0</vcpu>\n" " <os>\n" " <type>exe</type>\n" " <init>/sbin/init</init>\n" " </os>\n" " <clock offset='utc'/>\n" " <on_poweroff>destroy</on_poweroff>\n" " <on_reboot>destroy</on_reboot>\n" " <on_crash>destroy</on_crash>\n" " <devices>\n" " <interface type='ethernet'>\n" " <mac address='00:00:00:00:00:00'/>\n" " <ip address='194.44.18.88' family='ipv4'/>\n" " </interface>\n" " <interface type='bridge'>\n" " <mac address='00:18:51:c1:05:ee'/>\n" " <target dev='veth105.10'/>\n" " </interface>\n" " </devices>\n" "</domain>\n"; if (!(def = virDomainDefNew()) || VIR_STRDUP(def->os.type, "exe") < 0 || VIR_STRDUP(def->os.init, "/sbin/init") < 0) goto cleanup; def->virtType = <API key>; if (<API key>(def, 1) < 0) { err = virGetLastError(); fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>"); goto cleanup; } actual = virDomainDefFormat(def, <API key>); if (actual == NULL) { err = virGetLastError(); fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>"); goto cleanup; } if (STRNEQ(expected, actual)) { virtTestDifference(stderr, expected, actual); goto cleanup; } result = 0; cleanup: VIR_FREE(actual); virDomainDefFree(def); return result; } static int mymain(void) { int result = 0; <API key> = testLocateConfFile; # define DO_TEST(_name) \ do { \ if (virtTestRun("OpenVZ "#_name, test##_name, \ NULL) < 0) { \ result = -1; \ } \ } while (0) DO_TEST(ReadConfigParam); DO_TEST(ReadNetworkConf); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } VIRT_TEST_MAIN(mymain) #else int main(void) { return EXIT_AM_SKIP; } #endif /* WITH_OPENVZ */
#include <fenv.h> #include <fpu_control.h> #include <assert.h> #include <unistd.h> #include <ldsodefs.h> #include <dl-procinfo.h> /* All exceptions, including the x86-specific "denormal operand" exception. */ #define FE_ALL_EXCEPT_X86 (FE_ALL_EXCEPT | __FE_DENORM) int __fesetenv (const fenv_t *envp) { fenv_t temp; /* The memory block used by fstenv/fldenv has a size of 28 bytes. */ assert (sizeof (fenv_t) == 28); /* Install the environment specified by ENVP. But there are a few values which we do not want to come from the saved environment. Therefore, we get the current environment and replace the values we want to use from the environment specified by the parameter. */ __asm__ ("fnstenv %0" : "=m" (*&temp)); if (envp == FE_DFL_ENV) { temp.__control_word |= FE_ALL_EXCEPT_X86; temp.__control_word &= ~FE_TOWARDZERO; temp.__control_word |= _FPU_EXTENDED; temp.__status_word &= ~FE_ALL_EXCEPT_X86; } else if (envp == FE_NOMASK_ENV) { temp.__control_word &= ~(FE_ALL_EXCEPT | FE_TOWARDZERO); /* Keep the "denormal operand" exception masked. */ temp.__control_word |= __FE_DENORM; temp.__control_word |= _FPU_EXTENDED; temp.__status_word &= ~FE_ALL_EXCEPT_X86; } else { temp.__control_word &= ~(FE_ALL_EXCEPT_X86 | FE_TOWARDZERO | _FPU_EXTENDED); temp.__control_word |= (envp->__control_word & (FE_ALL_EXCEPT_X86 | FE_TOWARDZERO | _FPU_EXTENDED)); temp.__status_word &= ~FE_ALL_EXCEPT_X86; temp.__status_word |= envp->__status_word & FE_ALL_EXCEPT_X86; } temp.__eip = 0; temp.__cs_selector = 0; temp.__opcode = 0; temp.__data_offset = 0; temp.__data_selector = 0; __asm__ ("fldenv %0" : : "m" (temp)); if ((GLRO(dl_hwcap) & HWCAP_I386_XMM) != 0) { unsigned int mxcsr; __asm__ ("stmxcsr %0" : "=m" (mxcsr)); if (envp == FE_DFL_ENV) { /* Clear SSE exceptions. */ mxcsr &= ~FE_ALL_EXCEPT_X86; /* Set mask for SSE MXCSR. */ mxcsr |= (FE_ALL_EXCEPT_X86 << 7); /* Set rounding to FE_TONEAREST. */ mxcsr &= ~0x6000; mxcsr |= (FE_TONEAREST << 3); /* Clear the FZ and DAZ bits. */ mxcsr &= ~0x8040; } else if (envp == FE_NOMASK_ENV) { /* Clear SSE exceptions. */ mxcsr &= ~FE_ALL_EXCEPT_X86; /* Do not mask exceptions. */ mxcsr &= ~(FE_ALL_EXCEPT << 7); /* Keep the "denormal operand" exception masked. */ mxcsr |= (__FE_DENORM << 7); /* Set rounding to FE_TONEAREST. */ mxcsr &= ~0x6000; mxcsr |= (FE_TONEAREST << 3); /* Clear the FZ and DAZ bits. */ mxcsr &= ~0x8040; } else mxcsr = envp->__eip; __asm__ ("ldmxcsr %0" : : "m" (mxcsr)); } /* Success. */ return 0; } #include <shlib-compat.h> #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) strong_alias (__fesetenv, __old_fesetenv) compat_symbol (libm, __old_fesetenv, fesetenv, GLIBC_2_1); #endif libm_hidden_def (__fesetenv) libm_hidden_ver (__fesetenv, fesetenv) versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);
package com.caucho.ejb.cfg; import com.caucho.config.ConfigException; import com.caucho.config.types.<API key>; import com.caucho.config.types.Signature; import com.caucho.util.L10N; import com.caucho.vfs.Path; import java.util.*; import javax.annotation.PostConstruct; /** * Configuration for an ejb bean. */ public class EjbJar extends <API key> { private static final L10N L = new L10N(EjbJar.class); private final EjbConfig _config; private String _ejbModuleName; private Path _rootPath; private boolean _isMetadataComplete; private boolean _isSkip; public EjbJar(EjbConfig config, String ejbModuleName, Path rootPath) { _config = config; _ejbModuleName = ejbModuleName; _rootPath = rootPath; } public String getModuleName() { return _ejbModuleName; } public void setModuleName(String moduleName) { _ejbModuleName = moduleName; } public void setVersion(String version) { } public void setSchemaLocation(String value) { } public void setSkip(boolean isSkip) { _isSkip = isSkip; } public boolean isSkip() { return _isSkip; } public void setMetadataComplete(boolean isMetadataComplete) { _isMetadataComplete = isMetadataComplete; } public boolean isMetadataComplete() { return _isMetadataComplete; } public EjbEnterpriseBeans <API key>() throws ConfigException { return new EjbEnterpriseBeans(_config, this, _ejbModuleName); } public InterceptorsConfig createInterceptors() throws ConfigException { return new InterceptorsConfig(_config); } public Relationships createRelationships() throws ConfigException { return new Relationships(_config); } public AssemblyDescriptor <API key>() throws ConfigException { return new AssemblyDescriptor(this, _config); } public void addQueryFunction(QueryFunction fun) { } public void setBooleanLiteral(BooleanLiteral literal) { } <API key> <API key>() { return new <API key>(this, _config); } MethodPermission <API key>() { return new MethodPermission(_config); } public String toString() { return getClass().getSimpleName() + "[" + _rootPath.getFullPath() + "]"; } public class MethodPermission { EjbConfig _config; MethodSignature _method; ArrayList<String> _roles; MethodPermission(EjbConfig config) { _config = config; } public void setDescription(String description) { } public void setUnchecked(boolean unchecked) { } public void setRoleName(String roleName) { if (_roles == null) _roles = new ArrayList<String>(); _roles.add(roleName); } public void setMethod(MethodSignature method) { _method = method; } @PostConstruct public void init() throws ConfigException { if (isSkip()) return; EjbBean bean = _config.getBeanConfig(_method.getEJBName()); if (bean == null) throw new ConfigException(L.l("'{0}' is an unknown bean.", _method.getEJBName())); EjbMethodPattern method = bean.createMethod(_method); if (_roles != null) method.setRoles(_roles); } } public static class QueryFunction { FunctionSignature _sig; String _sql; public void setSignature(Signature sig) throws ConfigException { _sig = new FunctionSignature(sig.getSignature()); } public FunctionSignature getSignature() { return _sig; } public void setSQL(String sql) throws ConfigException { _sql = sql; } public String getSQL() { return _sql; } @PostConstruct public void init() { _sig.setSQL(_sql); } } public static class Relationships { EjbConfig _config; Relationships(EjbConfig config) { _config = config; } } }
#include "fdiskP.h" /* * Don't use this function derectly, use <API key>() */ int fdisk_probe_labels(struct fdisk_context *cxt) { size_t i; cxt->label = NULL; for (i = 0; i < cxt->nlabels; i++) { struct fdisk_label *lb = cxt->labels[i]; struct fdisk_label *org = cxt->label; int rc; if (!lb->op->probe) continue; if (lb->disabled) { DBG(CXT, ul_debugobj(cxt, "%s: disabled -- ignore", lb->name)); continue; } DBG(CXT, ul_debugobj(cxt, "probing for %s", lb->name)); cxt->label = lb; rc = lb->op->probe(cxt); cxt->label = org; if (rc != 1) { if (lb->op->deinit) lb->op->deinit(lb); /* for sure */ continue; } <API key>(cxt, lb); return 0; } DBG(CXT, ul_debugobj(cxt, "no label found")); return 1; /* not found */ } /** * <API key>: * @cxt: fdisk context * * Returns: return 1 if there is label on the device. */ int <API key>(struct fdisk_context *cxt) { return cxt && cxt->label; } /** * <API key>: * @cxt: fdisk context * @l: disklabel type * * Returns: return 1 if there is @l disklabel on the device. */ int <API key>(struct fdisk_context *cxt, enum fdisk_labeltype l) { return cxt && cxt->label && cxt->label->id == l; } /** * <API key>: * @cxt: fdisk context * * Write in-memory changes to disk * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label || cxt->readonly) return -EINVAL; if (!cxt->label->op->write) return -ENOSYS; return cxt->label->op->write(cxt); } int <API key>(struct fdisk_context *cxt) { assert(cxt); return cxt->label && cxt->label->flags & <API key> ? 1 : 0; } int <API key>(struct fdisk_context *cxt) { int rc; assert(cxt); rc = (<API key>(cxt) && (!cxt->geom.heads || !cxt->geom.sectors || !cxt->geom.cylinders)); if (rc && !<API key>(cxt)) fdisk_warnx(cxt, _("Incomplete geometry setting.")); return rc; } /** * fdisk_get_columns: * @cxt: fdisk context * @all: 1 or 0 * @cols: returns allocated array with FDISK_COL_* IDs * @ncols: returns number of items in cols * * This function returns the default or all columns for the current label. The * library uses the columns for list operations (see <API key>() and * <API key>()). Note that the set of the default columns depends * on <API key>() function. If the details are eanable then * this function usually returns more columns. * * Returns 0 on success, otherwise, a corresponding error. */ int fdisk_get_columns(struct fdisk_context *cxt, int all, int **cols, size_t *ncols) { size_t i, n; int *c; assert(cxt); if (!cxt->label) return -EINVAL; if (!cxt->label->columns || !cxt->label->ncolumns) return -ENOSYS; c = calloc(cxt->label->ncolumns, sizeof(int)); if (!c) return -ENOMEM; for (n = 0, i = 0; i < cxt->label->ncolumns; i++) { int id = cxt->label->columns[i].id; if (!all && ((<API key>(cxt) && (cxt->label->columns[i].flags & <API key>)) || (!<API key>(cxt) && (cxt->label->columns[i].flags & FDISK_COLFL_DETAIL)) || (id == FDISK_COL_SECTORS && <API key>(cxt)) || (id == FDISK_COL_CYLINDERS && !<API key>(cxt)))) continue; c[n++] = id; } if (cols) *cols = c; else free(c); if (ncols) *ncols = n; return 0; } const struct fdisk_column *<API key>( struct fdisk_label *lb, int id) { size_t i; assert(lb); assert(id > 0); for (i = 0; i < lb->ncolumns; i++) { if (lb->columns[i].id == id) return &lb->columns[i]; } return NULL; } /** * <API key>: * @cxt: fdisk context * * Verifies the partition table. * * Returns: 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->verify) return -ENOSYS; if (<API key>(cxt)) return -EINVAL; return cxt->label->op->verify(cxt); } /** * <API key>: * @cxt: fdisk context * * Lists details about disklabel, but no partitions. * * This function uses libfdisk ASK interface to print data. The details about * partitions table are printed by FDISK_ASKTYPE_INFO. * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->list) return -ENOSYS; return cxt->label->op->list(cxt); } /** * <API key>: * @cxt: fdisk context * @name: label name * * Creates a new disk label of type @name. If @name is NULL, then it * will create a default system label type, either SUN or DOS. * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt, const char *name) { int haslabel = 0; struct fdisk_label *lb; if (!cxt) return -EINVAL; if (!name) { /* use default label creation */ #ifdef __sparc__ name = "sun"; #else name = "dos"; #endif } if (cxt->label) { fdisk_deinit_label(cxt->label); haslabel = 1; } lb = <API key>(cxt, name); if (!lb || lb->disabled) return -EINVAL; if (!lb->op->create) return -ENOSYS; <API key>(cxt, lb); if (haslabel && !cxt->parent) <API key>(cxt); DBG(CXT, ul_debugobj(cxt, "create a new %s label", lb->name)); return cxt->label->op->create(cxt); } int <API key>(struct fdisk_context *cxt, int n, const char **name, off_t *offset, size_t *size) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->locate) return -ENOSYS; DBG(CXT, ul_debugobj(cxt, "locating %d chunk of %s.", n, cxt->label->name)); return cxt->label->op->locate(cxt, n, name, offset, size); } /** * <API key>: * @cxt: fdisk context * @id: returns pointer to allocated string * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt, char **id) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->get_id) return -ENOSYS; DBG(CXT, ul_debugobj(cxt, "asking for disk %s ID", cxt->label->name)); return cxt->label->op->get_id(cxt, id); } /** * <API key>: * @cxt: fdisk context * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->set_id) return -ENOSYS; DBG(CXT, ul_debugobj(cxt, "setting %s disk ID", cxt->label->name)); return cxt->label->op->set_id(cxt); } /** * <API key>: * @cxt: fdisk context * @partnum: partition number * @t: new type * * Returns 0 on success, < 0 on error. */ int <API key>(struct fdisk_context *cxt, size_t partnum, struct fdisk_parttype *t) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->part_set_type) return -ENOSYS; DBG(CXT, ul_debugobj(cxt, "partition: %zd: set type", partnum)); return cxt->label->op->part_set_type(cxt, partnum, t); } /** * <API key>: * @cxt: fdisk context * * Returns: number of partition types supported by the current label */ size_t <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label) return 0; return cxt->label->nparttypes; } /** * <API key>: * @cxt: fdisk context * @partnum: partition number * @status: flags * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt, size_t partnum, unsigned long flag) { int rc; if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->part_toggle_flag) return -ENOSYS; rc = cxt->label->op->part_toggle_flag(cxt, partnum, flag); DBG(CXT, ul_debugobj(cxt, "partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc)); return rc; } /** * <API key> * @cxt: fdisk context * * Sort partitions according to the partition start sector. * * Returns 0 on success, otherwise, a corresponding error. */ int <API key>(struct fdisk_context *cxt) { if (!cxt || !cxt->label) return -EINVAL; if (!cxt->label->op->reorder) return -ENOSYS; return cxt->label->op->reorder(cxt); } /* * Resets the current used label driver to initial state */ void fdisk_deinit_label(struct fdisk_label *lb) { assert(lb); /* private label information */ if (lb->op->deinit) lb->op->deinit(lb); } void <API key>(struct fdisk_label *lb, int changed) { assert(lb); lb->changed = changed ? 1 : 0; } int <API key>(struct fdisk_label *lb) { assert(lb); return lb ? lb->changed : 0; } void <API key>(struct fdisk_label *lb, int disabled) { assert(lb); DBG(LABEL, ul_debug("%s label %s", lb->name, disabled ? "DISABLED" : "ENABLED")); lb->disabled = disabled ? 1 : 0; } int <API key>(struct fdisk_label *lb) { assert(lb); return lb ? lb->disabled : 0; }
#include <linux/libra_sdioif.h> #include <linux/delay.h> #include <linux/mmc/sdio.h> #include <linux/mmc/mmc.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h> /* Libra SDIO function device */ static struct sdio_func *libra_sdio_func; static struct mmc_host *libra_mmc_host; static int <API key>; /* SDIO Card ID / Device ID */ static unsigned short libra_sdio_card_id; /* completion variables */ struct completion gCard_rem_event_var; EXPORT_SYMBOL(gCard_rem_event_var); struct completion gShutdown_event_var; EXPORT_SYMBOL(gShutdown_event_var); static suspend_handler_t *libra_suspend_hldr; static resume_handler_t *libra_resume_hldr; static <API key> *<API key>; static shutdown_handler_t *<API key>; int <API key>(struct sdio_func *func, u8 enable) { unsigned char reg = 0; int err = 0; sdio_claim_host(func); /* Read the value into reg */ libra_sdiocmd52(func, SDIO_CCCR_IENx, &reg, 0, &err); if (err) printk(KERN_ERR "%s: Could not read SDIO_CCCR_IENx register " "err=%d\n", __func__, err); if (libra_mmc_host) { if (enable) { reg |= 1 << func->num; reg |= 1; } else { reg &= ~(1 << func->num); } libra_sdiocmd52(func, SDIO_CCCR_IENx, &reg, 1, &err); if (err) printk(KERN_ERR "%s: Could not enable/disable irq " "err=%d\n", __func__, err); } sdio_release_host(func); return err; } EXPORT_SYMBOL(<API key>); /** * <API key>() - Function to configure the SDIO device param * @<API key> Rx handler * @func_drv_fn Function driver function for special setup * @funcdrv_timeout Function Enable timeout * @blksize Block size * * Configure SDIO device, enable function and set block size */ int <API key>(sdio_irq_handler_t <API key>, void (*func_drv_fn)(int *status), unsigned int funcdrv_timeout, unsigned int blksize) { int err_ret = 0; struct sdio_func *func = libra_sdio_func; if (libra_sdio_func == NULL) { printk(KERN_ERR "%s: Error SDIO card not detected\n", __func__); goto cfg_error; } sdio_claim_host(func); /* Currently block sizes are set here. */ func->max_blksize = blksize; if (sdio_set_block_size(func, blksize)) { printk(KERN_ERR "%s: Unable to set the block size.\n", __func__); sdio_release_host(func); goto cfg_error; } /* Function driver specific configuration. */ if (func_drv_fn) { (*func_drv_fn)(&err_ret); if (err_ret) { printk(KERN_ERR "%s: function driver provided configure function error=%d\n", __func__, err_ret); sdio_release_host(func); goto cfg_error; } } /* We set this based on the function card. */ func->enable_timeout = funcdrv_timeout; err_ret = sdio_enable_func(func); if (err_ret != 0) { printk(KERN_ERR "%s: Unable to enable function %d\n", __func__, err_ret); sdio_release_host(func); goto cfg_error; } if (sdio_claim_irq(func, <API key>)) { sdio_disable_func(func); printk(KERN_ERR "%s: Unable to claim irq.\n", __func__); sdio_release_host(func); goto cfg_error; } <API key>(func, 0); sdio_release_host(func); return 0; cfg_error: return -1; } EXPORT_SYMBOL(<API key>); int <API key>( suspend_handler_t *<API key>, resume_handler_t *<API key>) { libra_suspend_hldr = <API key>; libra_resume_hldr = <API key>; return 0; } EXPORT_SYMBOL(<API key>); /* * <API key>() - Function to reset the SDIO device param */ void <API key>(struct sdio_func *func) { if (NULL == libra_sdio_func) return; sdio_claim_host(func); sdio_release_irq(func); sdio_disable_func(func); sdio_release_host(func); } EXPORT_SYMBOL(<API key>); int <API key>(struct sdio_func *func, u8 enable) { if (libra_mmc_host && libra_mmc_host->ops && libra_mmc_host->ops->enable_sdio_irq) { libra_mmc_host->ops->enable_sdio_irq(libra_mmc_host, enable); return 0; } printk(KERN_ERR "%s: Could not enable disable irq\n", __func__); return -EINVAL; } EXPORT_SYMBOL(<API key>); int <API key>(struct sdio_func *func, u8 disable) { if (libra_mmc_host) { if (disable) libra_mmc_host->caps &= ~MMC_CAP_SDIO_IRQ; else libra_mmc_host->caps |= MMC_CAP_SDIO_IRQ; return 0; } printk(KERN_ERR "%s: Could not change sdio capabilities to polling\n", __func__); return -EINVAL; } EXPORT_SYMBOL(<API key>); /* * <API key>() - Function to release IRQ */ void <API key>(struct sdio_func *func) { if (NULL == libra_sdio_func) return; sdio_release_irq(func); } EXPORT_SYMBOL(<API key>); /* * <API key>() - Function to disable sdio func */ void <API key>(struct sdio_func *func) { if (NULL == libra_sdio_func) return; sdio_disable_func(func); } EXPORT_SYMBOL(<API key>); /* * Return the SDIO Function device */ struct sdio_func *<API key>(void) { return libra_sdio_func; } EXPORT_SYMBOL(<API key>); /* * Set function driver as the private data for the function device */ void <API key>(struct sdio_func *sdio_func_dev, void *padapter) { if (NULL == libra_sdio_func) return; sdio_set_drvdata(sdio_func_dev, padapter); } EXPORT_SYMBOL(<API key>); /* * Return private data of the function device. */ void *<API key>(struct sdio_func *sdio_func_dev) { return sdio_get_drvdata(sdio_func_dev); } EXPORT_SYMBOL(<API key>); /* * Function driver claims the SDIO device */ void libra_claim_host(struct sdio_func *sdio_func_dev, pid_t *curr_claimed, pid_t current_pid, atomic_t *claim_count) { if (NULL == libra_sdio_func) return; if (*curr_claimed == current_pid) { atomic_inc(claim_count); return; } /* Go ahead and claim the host if not locked by anybody. */ sdio_claim_host(sdio_func_dev); *curr_claimed = current_pid; atomic_inc(claim_count); } EXPORT_SYMBOL(libra_claim_host); /* * Function driver releases the SDIO device */ void libra_release_host(struct sdio_func *sdio_func_dev, pid_t *curr_claimed, pid_t current_pid, atomic_t *claim_count) { if (NULL == libra_sdio_func) return; if (*curr_claimed != current_pid) { /* Dont release */ return; } atomic_dec(claim_count); if (atomic_read(claim_count) == 0) { *curr_claimed = 0; sdio_release_host(sdio_func_dev); } } EXPORT_SYMBOL(libra_release_host); void libra_sdiocmd52(struct sdio_func *sdio_func_dev, unsigned int addr, u8 *byte_var, int write, int *err_ret) { if (write) sdio_writeb(sdio_func_dev, byte_var[0], addr, err_ret); else byte_var[0] = sdio_readb(sdio_func_dev, addr, err_ret); } EXPORT_SYMBOL(libra_sdiocmd52); u8 libra_sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr, int count) { return sdio_readsb(func, dst, addr, count); } EXPORT_SYMBOL(libra_sdio_readsb); int <API key>(struct sdio_func *func, void *dst, unsigned int addr, int count) { return sdio_memcpy_fromio(func, dst, addr, count); } EXPORT_SYMBOL(<API key>); int libra_sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, int count) { return sdio_writesb(func, addr, src, count); } EXPORT_SYMBOL(libra_sdio_writesb); int <API key>(struct sdio_func *func, unsigned int addr, void *src, int count) { return sdio_memcpy_toio(func, addr, src, count); } EXPORT_SYMBOL(<API key>); int <API key>(void) { if (libra_mmc_host) { if (!strcmp(libra_mmc_host->class_dev.class->name, "mmc_host") && (<API key> == libra_mmc_host->index)) { mmc_detect_change(libra_mmc_host, 0); return 0; } } printk(KERN_ERR "%s: Could not trigger card change\n", __func__); return -EINVAL; } EXPORT_SYMBOL(<API key>); int <API key>(void) { if (libra_mmc_host) { if (!strcmp(libra_mmc_host->class_dev.class->name, "mmc_host") && (<API key> == libra_mmc_host->index)) { libra_mmc_host->caps |= MMC_CAP_NEEDS_POLL; mmc_detect_change(libra_mmc_host, 0); return 0; } } printk(KERN_ERR "%s: Could not trigger SDIO scan\n", __func__); return -1; } EXPORT_SYMBOL(<API key>); void <API key>(struct sdio_func *func, unsigned int clk_freq) { struct mmc_host *host = func->card->host; host->ios.clock = clk_freq; host->ops->set_ios(host, &host->ios); } EXPORT_SYMBOL(<API key>); /* * API to get SDIO Device Card ID */ void <API key>(struct sdio_func *func, unsigned short *card_id) { if (card_id) *card_id = libra_sdio_card_id; } EXPORT_SYMBOL(<API key>); /* * SDIO Probe */ static int libra_sdio_probe(struct sdio_func *func, const struct sdio_device_id *sdio_dev_id) { libra_mmc_host = func->card->host; <API key> = libra_mmc_host->index; libra_sdio_func = func; libra_sdio_card_id = sdio_dev_id->device; printk(KERN_INFO "%s: success with block size of %d device_id=0x%x\n", __func__, func->cur_blksize, sdio_dev_id->device); /* Turn off SDIO polling from now on */ libra_mmc_host->caps &= ~MMC_CAP_NEEDS_POLL; return 0; } static void libra_sdio_remove(struct sdio_func *func) { if (<API key>) <API key>(); libra_sdio_func = NULL; printk(KERN_INFO "%s : Module removed.\n", __func__); } #ifdef CONFIG_PM static int libra_sdio_suspend(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); int ret = 0; ret = <API key>(func, MMC_PM_KEEP_POWER); if (ret) { printk(KERN_ERR "%s: Error Host doesn't support the keep power capability\n" , __func__); return ret; } if (libra_suspend_hldr) { /* Disable SDIO IRQ when driver is being suspended */ <API key>(func, 0); ret = libra_suspend_hldr(func); if (ret) { printk(KERN_ERR "%s: Libra driver is not able to suspend\n" , __func__); /* Error - Restore SDIO IRQ */ <API key>(func, 1); return ret; } } return <API key>(func, <API key>); } static int libra_sdio_resume(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); if (libra_resume_hldr) { libra_resume_hldr(func); /* Restore SDIO IRQ */ <API key>(func, 1); } return 0; } #else #define libra_sdio_suspend 0 #define libra_sdio_resume 0 #endif static void libra_sdio_shutdown(struct device *dev) { if (<API key>) { <API key>(); printk(KERN_INFO "%s : Notified shutdown event to Libra driver.\n", __func__); } } int <API key>( shutdown_handler_t *libra_shutdown_hdlr) { <API key> = libra_shutdown_hdlr; return 0; } EXPORT_SYMBOL(<API key>); int <API key>( <API key> *<API key>) { <API key> = <API key>; return 0; } EXPORT_SYMBOL(<API key>); static struct sdio_device_id libra_sdioid[] = { {.class = 0, .vendor = LIBRA_MAN_ID, .device = <API key>}, {.class = 0, .vendor = VOLANS_MAN_ID, .device = <API key>}, {} }; static const struct dev_pm_ops libra_sdio_pm_ops = { .suspend = libra_sdio_suspend, .resume = libra_sdio_resume, }; static struct sdio_driver libra_sdiofn_driver = { .name = "libra_sdiofn", .id_table = libra_sdioid, .probe = libra_sdio_probe, .remove = libra_sdio_remove, .drv.pm = &libra_sdio_pm_ops, .drv.shutdown = libra_sdio_shutdown, }; static int __init libra_sdioif_init(void) { libra_sdio_func = NULL; libra_mmc_host = NULL; <API key> = -1; libra_suspend_hldr = NULL; libra_resume_hldr = NULL; <API key> = NULL; <API key> = NULL; <API key>(&libra_sdiofn_driver); printk(KERN_INFO "%s: Loaded Successfully\n", __func__); return 0; } static void __exit libra_sdioif_exit(void) { unsigned int attempts = 0; if (!<API key>()) { do { ++attempts; msleep(500); } while (libra_sdio_func != NULL && attempts < 3); } if (libra_sdio_func != NULL) printk(KERN_ERR "%s: Card removal not detected\n", __func__); <API key>(&libra_sdiofn_driver); libra_sdio_func = NULL; libra_mmc_host = NULL; <API key> = -1; printk(KERN_INFO "%s: Unloaded Successfully\n", __func__); } module_init(libra_sdioif_init); module_exit(libra_sdioif_exit); MODULE_LICENSE("GPL v2"); MODULE_VERSION("1.0"); MODULE_DESCRIPTION("WLAN SDIODriver");
function test() { return (function foo(){}).name === 'foo' && (function(){}).name === ''; } if (!test()) throw new Error("Test failed");
FD40.ready(function($) { var jQuery = $;// Catalan jQuery.timeago.settings.strings = { prefixAgo: "fa", prefixFromNow: "d'aqui a", suffixAgo: null, suffixFromNow: null, seconds: "menys d'1 minut", minute: "1 minut", minutes: "uns %d minuts", hour: "1 hora", hours: "unes %d hores", day: "1 dia", days: "%d dies", month: "aproximadament un mes", months: "%d mesos", year: "aproximadament un any", years: "%d anys" }; });
#include <linux/module.h> #include <linux/init.h> #include <linux/of.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> int __devinit <API key>(struct device *dev, struct mtd_info *mtd, struct device_node *node, struct mtd_partition **pparts) { const char *partname; struct device_node *pp; int nr_parts, i; /* First count the subnodes */ pp = NULL; nr_parts = 0; while ((pp = of_get_next_child(node, pp))) nr_parts++; if (nr_parts == 0) return 0; *pparts = kzalloc(nr_parts * sizeof(**pparts), GFP_KERNEL); if (!*pparts) return -ENOMEM; pp = NULL; i = 0; while ((pp = of_get_next_child(node, pp))) { const u32 *reg; int len; reg = of_get_property(pp, "reg", &len); if (!reg || (len != 2 * sizeof(u32))) { of_node_put(pp); dev_err(dev, "Invalid 'reg' on %s\n", node->full_name); kfree(*pparts); *pparts = NULL; return -EINVAL; } (*pparts)[i].offset = reg[0]; (*pparts)[i].size = reg[1]; partname = of_get_property(pp, "label", &len); if (!partname) partname = of_get_property(pp, "name", &len); (*pparts)[i].name = (char *)partname; if (of_get_property(pp, "read-only", &len)) (*pparts)[i].mask_flags = MTD_WRITEABLE; i++; } return nr_parts; } EXPORT_SYMBOL(<API key>);
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="pt"> <head> <!-- Generated by javadoc (version 1.7.0_11) on Fri Jan 25 09:33:25 BRST 2013 --> <title>ThemeForm (Cyclos 3 Documentation)</title> <meta name="date" content="2013-01-25"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><! if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ThemeForm (Cyclos 3 Documentation)"; } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar_top"> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/SelectThemeAction.html" title="class in nl.strohalm.cyclos.controls.customization.themes"><span class="strong">Prev Class</span></a></li> <li>Next Class</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html" target="_top">Frames</a></li> <li><a href="ThemeForm.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#<API key>.strohalm.cyclos.controls.BaseBindingForm">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_top"> </a></div> <div class="header"> <div class="subTitle">nl.strohalm.cyclos.controls.customization.themes</div> <h2 title="Class ThemeForm" class="title">Class ThemeForm</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li>org.apache.struts.action.ActionForm</li> <li> <ul class="inheritance"> <li><a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html" title="class in nl.strohalm.cyclos.controls">nl.strohalm.cyclos.controls.BaseBindingForm</a></li> <li> <ul class="inheritance"> <li>nl.strohalm.cyclos.controls.customization.themes.ThemeForm</li> </ul> </li> </ul> </li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Implemented Interfaces:</dt> <dd>java.io.Serializable</dd> </dl> <hr> <br> <pre>public class <span class="strong">ThemeForm</span> extends <a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html" title="class in nl.strohalm.cyclos.controls">BaseBindingForm</a></pre> <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../serialized-form.html#nl.strohalm.cyclos.controls.customization.themes.ThemeForm">Serialized Form</a></dd></dl> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="field_summary"> </a> <h3>Field Summary</h3> <ul class="blockList"> <li class="blockList"><a name="<API key>.strohalm.cyclos.controls.BaseBindingForm"> </a> <h3>Fields inherited from class&nbsp;nl.strohalm.cyclos.controls.<a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html" title="class in nl.strohalm.cyclos.controls">BaseBindingForm</a></h3> <code><a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html#values">values</a></code></li> </ul> <ul class="blockList"> <li class="blockList"><a name="<API key>.apache.struts.action.ActionForm"> </a> <h3>Fields inherited from class&nbsp;org.apache.struts.action.ActionForm</h3> <code><API key>, servlet</code></li> </ul> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="constructor_summary"> </a> <h3>Constructor Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#ThemeForm()">ThemeForm</a></strong>()</code>&nbsp;</td> </tr> </table> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method_summary"> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#getFilename()">getFilename</a></strong>()</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>java.util.Map&lt;java.lang.String,java.lang.Object&gt;</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#getTheme()">getTheme</a></strong>()</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>java.lang.Object</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#getTheme(java.lang.String)">getTheme</a></strong>(java.lang.String&nbsp;key)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#setFilename(java.lang.String)">setFilename</a></strong>(java.lang.String&nbsp;filename)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#setTheme(java.util.Map)">setTheme</a></strong>(java.util.Map&lt;java.lang.String,java.lang.Object&gt;&nbsp;map)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><strong><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html#setTheme(java.lang.String, java.lang.Object)">setTheme</a></strong>(java.lang.String&nbsp;key, java.lang.Object&nbsp;value)</code>&nbsp;</td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="<API key>.strohalm.cyclos.controls.BaseBindingForm"> </a> <h3>Methods inherited from class&nbsp;nl.strohalm.cyclos.controls.<a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html" title="class in nl.strohalm.cyclos.controls">BaseBindingForm</a></h3> <code><a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html#getValues()">getValues</a>, <a href="../../../../../../nl/strohalm/cyclos/controls/BaseBindingForm.html#setValues(java.util.Map)">setValues</a></code></li> </ul> <ul class="blockList"> <li class="blockList"><a name="<API key>.apache.struts.action.ActionForm"> </a> <h3>Methods inherited from class&nbsp;org.apache.struts.action.ActionForm</h3> <code><API key>, getServlet, getServletWrapper, reset, reset, <API key>, setServlet, validate, validate</code></li> </ul> <ul class="blockList"> <li class="blockList"><a name="<API key>.lang.Object"> </a> <h3>Methods inherited from class&nbsp;java.lang.Object</h3> <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="constructor_detail"> </a> <h3>Constructor Detail</h3> <a name="ThemeForm()"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>ThemeForm</h4> <pre>public&nbsp;ThemeForm()</pre> </li> </ul> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method_detail"> </a> <h3>Method Detail</h3> <a name="getFilename()"> </a> <ul class="blockList"> <li class="blockList"> <h4>getFilename</h4> <pre>public&nbsp;java.lang.String&nbsp;getFilename()</pre> </li> </ul> <a name="getTheme()"> </a> <ul class="blockList"> <li class="blockList"> <h4>getTheme</h4> <pre>public&nbsp;java.util.Map&lt;java.lang.String,java.lang.Object&gt;&nbsp;getTheme()</pre> </li> </ul> <a name="getTheme(java.lang.String)"> </a> <ul class="blockList"> <li class="blockList"> <h4>getTheme</h4> <pre>public&nbsp;java.lang.Object&nbsp;getTheme(java.lang.String&nbsp;key)</pre> </li> </ul> <a name="setFilename(java.lang.String)"> </a> <ul class="blockList"> <li class="blockList"> <h4>setFilename</h4> <pre>public&nbsp;void&nbsp;setFilename(java.lang.String&nbsp;filename)</pre> </li> </ul> <a name="setTheme(java.util.Map)"> </a> <ul class="blockList"> <li class="blockList"> <h4>setTheme</h4> <pre>public&nbsp;void&nbsp;setTheme(java.util.Map&lt;java.lang.String,java.lang.Object&gt;&nbsp;map)</pre> </li> </ul> <a name="setTheme(java.lang.String, java.lang.Object)"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>setTheme</h4> <pre>public&nbsp;void&nbsp;setTheme(java.lang.String&nbsp;key, java.lang.Object&nbsp;value)</pre> </li> </ul> </li> </ul> </li> </ul> </div> </div> <div class="bottomNav"><a name="navbar_bottom"> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../nl/strohalm/cyclos/controls/customization/themes/SelectThemeAction.html" title="class in nl.strohalm.cyclos.controls.customization.themes"><span class="strong">Prev Class</span></a></li> <li>Next Class</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?nl/strohalm/cyclos/controls/customization/themes/ThemeForm.html" target="_top">Frames</a></li> <li><a href="ThemeForm.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#<API key>.strohalm.cyclos.controls.BaseBindingForm">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> </a></div> </body> </html>
tinyMCEPopup.requireLangPack();var ColorPicker={settings:{},init:function(){var self=this,ed=tinyMCEPopup.editor,color=tinyMCEPopup.getWindowArg('input_color')||'#FFFFFF';$('#tmp_color').val(color).colorpicker($.extend(this.settings,{dialog:false,insert:function(){return ColorPicker.insert();},close:function(){return tinyMCEPopup.close();}}));$('button#insert').button({icons:{primary:'ui-icon-check'}});$('#jce').css('display','block');},insert:function(){var color=$("#colorpicker_color").val(),f=tinyMCEPopup.getWindowArg('func');tinyMCEPopup.restoreSelection();if(f) f(color);tinyMCEPopup.close();}};tinyMCEPopup.onInit.add(ColorPicker.init,ColorPicker);
<?php namespace Drupal\webform; use Drupal\Core\Archiver\ArchiveTar; use Drupal\Core\Config\<API key>; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\<API key>; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; use Drupal\Core\StreamWrapper\<API key>; use Drupal\Core\StreamWrapper\<API key>; use Drupal\Core\StringTranslation\<API key>; use Drupal\webform\Entity\WebformSubmission; use Drupal\webform\Plugin\<API key>; use Drupal\webform\Plugin\<API key>; /** * Webform submission exporter. */ class <API key> implements <API key> { use <API key>; /** * The configuration object factory. * * @var \Drupal\Core\Config\<API key> */ protected $configFactory; /** * File system service. * * @var \Drupal\Core\File\FileSystemInterface */ protected $fileSystem; /** * Webform submission storage. * * @var \Drupal\webform\<API key> */ protected $entityStorage; /** * The stream wrapper manager. * * @var \Drupal\Core\StreamWrapper\<API key> */ protected $<API key>; /** * Webform element manager. * * @var \Drupal\webform\Plugin\<API key> */ protected $elementManager; /** * Results exporter manager. * * @var \Drupal\webform\Plugin\<API key> */ protected $exporterManager; /** * The webform. * * @var \Drupal\webform\WebformInterface */ protected $webform; /** * The source entity. * * @var \Drupal\Core\Entity\EntityInterface */ protected $sourceEntity; /** * The results exporter. * * @var \Drupal\webform\Plugin\<API key> */ protected $exporter; /** * Default export options. * * @var array */ protected $defaultOptions; /** * Webform element types. * * @var array */ protected $elementTypes; /** * Constructs a <API key> object. * * @param \Drupal\Core\Config\<API key> $config_factory * The configuration object factory. * @param \Drupal\Core\File\FileSystemInterface $file_system * File system service. * @param \Drupal\Core\Entity\<API key> $entity_type_manager * The entity type manager. * @param \Drupal\Core\StreamWrapper\<API key> $<API key> * The stream wrapper manager. * @param \Drupal\webform\Plugin\<API key> $element_manager * The webform element manager. * @param \Drupal\webform\Plugin\<API key> $exporter_manager * The results exporter manager. */ public function __construct(<API key> $config_factory, FileSystemInterface $file_system, <API key> $entity_type_manager, <API key> $<API key>, <API key> $element_manager, <API key> $exporter_manager) { $this->configFactory = $config_factory; $this->fileSystem = $file_system; $this->entityStorage = $entity_type_manager->getStorage('webform_submission'); $this-><API key> = $<API key>; $this->elementManager = $element_manager; $this->exporterManager = $exporter_manager; } /** * {@inheritdoc} */ public function setWebform(WebformInterface $webform = NULL) { $this->webform = $webform; $this->defaultOptions = NULL; $this->elementTypes = NULL; } /** * {@inheritdoc} */ public function getWebform() { return $this->webform; } /** * {@inheritdoc} */ public function setSourceEntity(EntityInterface $entity = NULL) { $this->sourceEntity = $entity; } /** * {@inheritdoc} */ public function getSourceEntity() { return $this->sourceEntity; } /** * {@inheritdoc} */ public function getWebformOptions() { $name = $this-><API key>(); return $this->getWebform()->getState($name, []); } /** * {@inheritdoc} */ public function setWebformOptions(array $options = []) { $name = $this-><API key>(); $this->getWebform()->setState($name, $options); } /** * {@inheritdoc} */ public function <API key>() { $name = $this-><API key>(); $this->getWebform()->deleteState($name); } /** * Get options name for current webform and source entity. * * @return string * Settings name as 'webform.export.{entity_type}.{entity_id}'. */ protected function <API key>() { if ($entity = $this->getSourceEntity()) { return 'results.export.' . $entity->getEntityTypeId() . '.' . $entity->id(); } else { return 'results.export'; } } /** * {@inheritdoc} */ public function setExporter(array $export_options = []) { $export_options += $this-><API key>(); $export_options['webform'] = $this->getWebform(); $export_options['source_entity'] = $this->getSourceEntity(); $this->exporter = $this->exporterManager->createInstance($export_options['exporter'], $export_options); return $this->exporter; } /** * {@inheritdoc} */ public function getExporter() { return $this->exporter; } /** * {@inheritdoc} */ public function getExportOptions() { return $this->getExporter()->getConfiguration(); } // Default options and webform. /** * {@inheritdoc} */ public function <API key>() { if (isset($this->defaultOptions)) { return $this->defaultOptions; } $this->defaultOptions = [ 'exporter' => 'delimited', 'delimiter' => ',', 'multiple_delimiter' => ';', 'excel' => FALSE, 'file_name' => 'submission-[webform_submission:serial]', 'header_format' => 'label', 'header_prefix' => TRUE, '<API key>' => ': ', '<API key>' => '__', 'excluded_columns' => [ 'uuid' => 'uuid', 'token' => 'token', 'webform_id' => 'webform_id', ], 'entity_type' => '', 'entity_id' => '', 'range_type' => 'all', 'range_latest' => '', 'range_start' => '', 'range_end' => '', 'state' => 'all', 'sticky' => '', 'download' => TRUE, 'files' => FALSE, ]; // Append element handler default options. $element_types = $this-><API key>(); $element_handlers = $this->elementManager->getInstances(); foreach ($element_handlers as $element_type => $element_handler) { if (empty($element_types) || isset($element_types[$element_type])) { $this->defaultOptions += $element_handler-><API key>(); } } return $this->defaultOptions; } /** * {@inheritdoc} */ public function <API key>(array &$form, FormStateInterface $form_state, array $export_options = []) { $export_options += $this-><API key>(); $this->setExporter($export_options); $webform = $this->getWebform(); // Get exporter and build #states. $exporter_plugins = $this->exporterManager->getInstances($export_options); $states_archive = ['invisible' => []]; $states_options = ['invisible' => []]; foreach ($exporter_plugins as $plugin_id => $exporter_plugin) { if ($exporter_plugin->isArchive()) { if ($states_archive['invisible']) { $states_archive['invisible'][] = 'or'; } $states_archive['invisible'][] = [':input[name="exporter"]' => ['value' => $plugin_id]]; } if (!$exporter_plugin->hasOptions()) { if ($states_options['invisible']) { $states_options['invisible'][] = 'or'; } $states_options['invisible'][] = [':input[name="exporter"]' => ['value' => $plugin_id]]; } } $form['export']['format'] = [ '#type' => 'details', '#title' => $this->t('Format options'), '#open' => TRUE, ]; $form['export']['format']['exporter'] = [ '#type' => 'select', '#title' => $this->t('Export format'), '#options' => $this->exporterManager->getOptions(), '#default_value' => $export_options['exporter'], // Below .js-webform-exporter is used for exporter configuration form // #states. // @see \Drupal\webform\Plugin\WebformExporterBase::<API key> '#attributes' => ['class' => ['js-webform-exporter']], ]; foreach ($exporter_plugins as $plugin_id => $exporter) { $subform_state = SubformState::createForSubform($form['export']['format'], $form, $form_state); $form['export']['format'] = $exporter-><API key>($form['export']['format'], $subform_state); } // Element. $form['export']['element'] = [ '#type' => 'details', '#title' => $this->t('Element options'), '#open' => TRUE, '#states' => $states_options, ]; $form['export']['element']['multiple_delimiter'] = [ '#type' => 'select', '#title' => $this->t('Element multiple values delimiter'), '#description' => $this->t('This is the delimiter when an element has multiple values.'), '#required' => TRUE, '#options' => [ ';' => $this->t('Semicolon (;)'), ',' => $this->t('Comma (,)'), '|' => $this->t('Pipe (|)'), '.' => $this->t('Period (.)'), ' ' => $this->t('Space ()'), ], '#default_value' => $export_options['multiple_delimiter'], ]; // Header. $form['export']['header'] = [ '#type' => 'details', '#title' => $this->t('Header options'), '#open' => TRUE, '#states' => $states_options, ]; $form['export']['header']['header_format'] = [ '#type' => 'radios', '#title' => $this->t('Column header format'), '#description' => $this->t('Choose whether to show the element label or element key in each column header.'), '#required' => TRUE, '#options' => [ 'label' => $this->t('Element titles (label)'), 'key' => $this->t('Element keys (key)'), ], '#default_value' => $export_options['header_format'], ]; $form['export']['header']['header_prefix'] = [ '#type' => 'checkbox', '#title' => $this->t("Include an element's title with all sub elements and values in each column header."), '#return_value' => TRUE, '#default_value' => $export_options['header_prefix'], ]; $form['export']['header']['<API key>'] = [ '#type' => 'textfield', '#title' => $this->t('Column header label delimiter'), '#required' => TRUE, '#default_value' => $export_options['<API key>'], ]; $form['export']['header']['<API key>'] = [ '#type' => 'textfield', '#title' => $this->t('Column header key delimiter'), '#required' => TRUE, '#default_value' => $export_options['<API key>'], ]; if ($webform) { $form['export']['header']['<API key>']['#states'] = [ 'visible' => [ ':input[name="header_prefix"]' => ['checked' => TRUE], ':input[name="header_format"]' => ['value' => 'label'], ], ]; $form['export']['header']['<API key>']['#states'] = [ 'visible' => [ ':input[name="header_prefix"]' => ['checked' => TRUE], ':input[name="header_format"]' => ['value' => 'key'], ], ]; } // Build element specific export webforms. // Grouping everything in $form['export']['elements'] so that element handlers can // assign #weight to its export options webform. $form['export']['elements'] = [ '#type' => 'container', '#attributes' => ['class' => ['form-item']], '#states' => $states_options, ]; $element_types = $this-><API key>(); $element_handlers = $this->elementManager->getInstances(); foreach ($element_handlers as $element_type => $element_handler) { if (empty($element_types) || isset($element_types[$element_type])) { $subform_state = SubformState::createForSubform($form['export']['elements'], $form, $form_state); $element_handler-><API key>($form['export']['elements'], $subform_state, $export_options); } } // All the remain options are only applicable to a webform's export. // @see Drupal\webform\Form\<API key> if (!$webform) { return; } // Elements. $form['export']['columns'] = [ '#type' => 'details', '#title' => $this->t('Column options'), '#description' => $this->t('The selected columns will be included in the export.'), '#states' => $states_options, ]; $form['export']['columns']['excluded_columns'] = [ '#type' => '<API key>', '#webform_id' => $webform->id(), '#default_value' => $export_options['excluded_columns'], ]; // Download options. $form['export']['download'] = [ '#type' => 'details', '#title' => $this->t('Download options'), '#open' => TRUE, ]; $form['export']['download']['download'] = [ '#type' => 'checkbox', '#title' => $this->t('Download export file'), '#description' => $this->t('If checked, the export file will be automatically download to your local machine. If unchecked, the export file will be displayed as plain text within your browser.'), '#return_value' => TRUE, '#default_value' => $export_options['download'], '#access' => !$this->requiresBatch(), '#states' => $states_archive, ]; $form['export']['download']['files'] = [ '#type' => 'checkbox', '#title' => $this->t('Download uploaded files'), '#description' => $this->t('If checked, the exported file and any submission file uploads will be download in a gzipped tar file.'), '#return_value' => TRUE, '#default_value' => ($webform->hasManagedFile()) ? $export_options['files'] : 0, '#access' => $webform->hasManagedFile(), '#states' => [ 'invisible' => [ ':input[name="download"]' => ['checked' => FALSE], ], ], ]; $source_entity = $this->getSourceEntity(); if (!$source_entity) { $entity_types = $this->entityStorage-><API key>($webform); if ($entity_types) { $form['export']['download']['submitted'] = [ '#type' => 'item', '#input' => FALSE, '#title' => $this->t('Submitted to'), '#description' => $this->t('Select the entity type and then enter the entity id.'), '#field_prefix' => '<div class="container-inline">', '#field_suffix' => '</div>', ]; $form['export']['download']['submitted']['entity_type'] = [ '#type' => 'select', '#title' => $this->t('Entity type'), '#title_display' => 'Invisible', '#options' => ['' => $this->t('All')] + $entity_types, '#default_value' => $export_options['entity_type'], ]; $form['export']['download']['submitted']['entity_id'] = [ '#type' => 'number', '#title' => $this->t('Entity id'), '#title_display' => 'Invisible', '#min' => 1, '#size' => 10, '#default_value' => $export_options['entity_id'], '#states' => [ 'invisible' => [ ':input[name="entity_type"]' => ['value' => ''], ], ], ]; } } $form['export']['download']['range_type'] = [ '#type' => 'select', '#title' => $this->t('Limit to'), '#options' => [ 'all' => $this->t('All'), 'latest' => $this->t('Latest'), 'serial' => $this->t('Submission number'), 'sid' => $this->t('Submission ID'), 'date' => $this->t('Date'), ], '#default_value' => $export_options['range_type'], ]; $form['export']['download']['latest'] = [ '#type' => 'container', '#attributes' => ['class' => ['container-inline']], '#states' => [ 'visible' => [ ':input[name="range_type"]' => ['value' => 'latest'], ], ], 'range_latest' => [ '#type' => 'number', '#title' => $this->t('Number of submissions'), '#min' => 1, '#default_value' => $export_options['range_latest'], ], ]; $ranges = [ 'serial' => ['#type' => 'number'], 'sid' => ['#type' => 'number'], 'date' => ['#type' => 'date'], ]; foreach ($ranges as $key => $range_element) { $form['export']['download'][$key] = [ '#type' => 'container', '#attributes' => ['class' => ['container-inline']], '#tree' => TRUE, '#states' => [ 'visible' => [ ':input[name="range_type"]' => ['value' => $key], ], ], ]; $form['export']['download'][$key]['range_start'] = $range_element + [ '#title' => $this->t('From'), '#parents' => [$key, 'range_start'], '#default_value' => $export_options['range_start'], ]; $form['export']['download'][$key]['range_end'] = $range_element + [ '#title' => $this->t('To'), '#parents' => [$key, 'range_end'], '#default_value' => $export_options['range_end'], ]; } $form['export']['download']['sticky'] = [ '#type' => 'checkbox', '#title' => $this->t('Starred/flagged submissions'), '#description' => $this->t('If checked, only starred/flagged submissions will be downloaded. If unchecked, all submissions will downloaded.'), '#return_value' => TRUE, '#default_value' => $export_options['sticky'], ]; // If drafts are allowed, provide options to filter download based on // submission state. $form['export']['download']['state'] = [ '#type' => 'radios', '#title' => $this->t('Submission state'), '#default_value' => $export_options['state'], '#options' => [ 'all' => $this->t('Completed and draft submissions'), 'completed' => $this->t('Completed submissions only'), 'draft' => $this->t('Drafts only'), ], '#access' => ($webform->getSetting('draft') != WebformInterface::DRAFT_NONE), ]; } /** * {@inheritdoc} */ public function getValuesFromInput(array $values) { if (isset($values['range_type'])) { $range_type = $values['range_type']; $values['range_type'] = $range_type; if (isset($values[$range_type])) { $values += $values[$range_type]; } } // Make sure only support options are returned. $values = array_intersect_key($values, $this-><API key>()); return $values; } // Generate and write. /** * {@inheritdoc} */ public function generate() { $entity_ids = $this->getQuery()->execute(); $webform_submissions = WebformSubmission::loadMultiple($entity_ids); $this->writeHeader(); $this->writeRecords($webform_submissions); $this->writeFooter(); } /** * {@inheritdoc} */ public function writeHeader() { // If building a new archive make sure to delete the exist archive. if ($this->isArchive()) { @unlink($this->getArchiveFilePath()); } $this->getExporter()->createExport(); $this->getExporter()->writeHeader(); $this->getExporter()->closeExport(); } /** * {@inheritdoc} */ public function writeRecords(array $webform_submissions) { $export_options = $this->getExportOptions(); $webform = $this->getWebform(); $is_archive = ($this->isArchive() && $export_options['files']); $files_directories = []; if ($is_archive) { $archiver = new ArchiveTar($this->getArchiveFilePath(), 'gz'); $stream_wrappers = array_keys($this-><API key>->getNames(<API key>::WRITE_VISIBLE)); foreach ($stream_wrappers as $stream_wrapper) { $files_directory = $this->fileSystem->realpath($stream_wrapper . '://webform/' . $webform->id()); $files_directories[] = $files_directory; } } $this->getExporter()->openExport(); foreach ($webform_submissions as $webform_submission) { if ($is_archive) { foreach ($files_directories as $files_directory) { $<API key> = $files_directory . '/' . $webform_submission->id(); if (file_exists($<API key>)) { $file_name = $this-><API key>($webform_submission); $archiver->addModify($<API key>, $file_name, $<API key>); } } } $this->getExporter()->writeSubmission($webform_submission); } $this->getExporter()->closeExport(); } /** * {@inheritdoc} */ public function writeFooter() { $this->getExporter()->openExport(); $this->getExporter()->writeFooter(); $this->getExporter()->closeExport(); } /** * {@inheritdoc} */ public function <API key>() { $export_file_path = $this->getExportFilePath(); if (file_exists($export_file_path)) { $archive_file_path = $this->getArchiveFilePath(); $archiver = new ArchiveTar($archive_file_path, 'gz'); $archiver->addModify($export_file_path, $this->getBaseFileName(), $this-><API key>()); @unlink($export_file_path); } } /** * {@inheritdoc} */ public function getQuery() { $export_options = $this->getExportOptions(); $webform = $this->getWebform(); $source_entity = $this->getSourceEntity(); $query = $this->entityStorage->getQuery()->condition('webform_id', $webform->id()); // Filter by source entity or submitted to. if ($source_entity) { $query->condition('entity_type', $source_entity->getEntityTypeId()); $query->condition('entity_id', $source_entity->id()); } elseif ($export_options['entity_type']) { $query->condition('entity_type', $export_options['entity_type']); if ($export_options['entity_id']) { $query->condition('entity_id', $export_options['entity_id']); } } // Filter by sid or date range. switch ($export_options['range_type']) { case 'serial': if ($export_options['range_start']) { $query->condition('serial', $export_options['range_start'], '>='); } if ($export_options['range_end']) { $query->condition('serial', $export_options['range_end'], '<='); } break; case 'sid': if ($export_options['range_start']) { $query->condition('sid', $export_options['range_start'], '>='); } if ($export_options['range_end']) { $query->condition('sid', $export_options['range_end'], '<='); } break; case 'date': if ($export_options['range_start']) { $query->condition('created', strtotime($export_options['range_start']), '>='); } if ($export_options['range_end']) { $query->condition('created', strtotime('+1 day', strtotime($export_options['range_end'])), '<'); } break; } // Filter by (completion) state. switch ($export_options['state']) { case 'draft': $query->condition('in_draft', 1); break; case 'completed': $query->condition('in_draft', 0); break; } // Filter by sticky. if ($export_options['sticky']) { $query->condition('sticky', 1); } // Filter by latest. if ($export_options['range_type'] == 'latest' && $export_options['range_latest']) { // Clone the query and use it to get latest sid starting sid. $latest_query = clone $query; $latest_query->sort('sid', 'DESC'); $latest_query->range(0, (int) $export_options['range_latest']); if ($<API key> = $latest_query->execute()) { $query->condition('sid', end($<API key>), '>='); } } // Sort by sid with the oldest one first. $query->sort('sid', 'ASC'); return $query; } /** * Get element types from a webform. * * @return array * An array of element types from a webform. */ protected function <API key>() { if (isset($this->elementTypes)) { return $this->elementTypes; } // If the webform is not set which only occurs on the admin settings webform, // return an empty array. if (!isset($this->webform)) { return []; } $this->elementTypes = []; $elements = $this->webform-><API key>(); // Always include 'entity_autocomplete' export settings which is used to // expand a webform submission's entity references. $this->elementTypes['entity_autocomplete'] = 'entity_autocomplete'; foreach ($elements as $element) { if (isset($element['#type'])) { $type = $this->elementManager->getElementPluginId($element); $this->elementTypes[$type] = $type; } } return $this->elementTypes; } // Summary and download. /** * {@inheritdoc} */ public function getTotal() { return $this->getQuery()->count()->execute(); } /** * {@inheritdoc} */ public function getBatchLimit() { return $this->configFactory->get('webform.settings')->get('batch.<API key>') ?: 500; } /** * {@inheritdoc} */ public function requiresBatch() { return ($this->getTotal() > $this->getBatchLimit()) ? TRUE : FALSE; } /** * {@inheritdoc} */ public function <API key>() { return file_directory_temp(); } /** * {@inheritdoc} */ public function <API key>(<API key> $webform_submission) { return $this->getExporter()-><API key>($webform_submission); } /** * {@inheritdoc} */ protected function getBaseFileName() { return $this->getExporter()->getBaseFileName(); } /** * {@inheritdoc} */ public function getExportFilePath() { return $this->getExporter()->getExportFilePath(); } /** * {@inheritdoc} */ public function getExportFileName() { return $this->getExporter()->getExportFileName(); } /** * {@inheritdoc} */ public function getArchiveFilePath() { return $this->getExporter()->getArchiveFilePath(); } /** * {@inheritdoc} */ public function getArchiveFileName() { return $this->getExporter()->getArchiveFileName(); } /** * {@inheritdoc} */ public function isArchive() { if ($this->getExporter()->isArchive()) { return TRUE; } else { $export_options = $this->getExportOptions(); return ($export_options['download'] && $export_options['files']); } } /** * {@inheritdoc} */ public function isBatch() { return ($this->isArchive() || ($this->getTotal() >= $this->getBatchLimit())); } }
.size 8000 .text@48 inc a ldff(45), a jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld a, 30 ldff(00), a ld a, 01 ldff(4d), a stop, 00 ld a, ff ldff(45), a ld b, 03 call lwaitly_b ld c, 41 lbegin_waitm0: ldff a, (c) and a, b jrnz lbegin_waitm0 ld a, 80 ldff(68), a ld a, ff ld c, 69 ldff(c), a ldff(c), a ldff(c), a ldff(c), a ldff(c), a ldff(c), a xor a, a ldff(c), a ldff(c), a ld a, 40 ldff(41), a ld a, 02 ldff(ff), a ei ld a, b inc a inc a ldff(45), a ld c, 0f .text@1000 lstatint: nop .text@10d2 ld a, ff ldff(45), a ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
// Class: DummyAnimInstance // Authors: Li, Xizhi // Emails: LiXizhi@yeah.net // Company: ParaEngine #include "ParaEngine.h" #include "ParaXModel/AnimTable.h" #include "DummyAnimInstance.h" /** @def default walking speed when no model is found. */ #define DEFAULT_WALK_SPEED 4.f using namespace ParaEngine; ParaEngine::CDummyAnimInstance::CDummyAnimInstance() { // since it is a singleton, we will never reference count it. addref(); } CDummyAnimInstance* ParaEngine::CDummyAnimInstance::GetInstance() { static CDummyAnimInstance s_instance; return &s_instance; } void ParaEngine::CDummyAnimInstance::LoadAnimation(int nAnimID, float * fSpeed, bool bAppend /*= false*/) { if (fSpeed) { if (nAnimID == ANIM_STAND) *fSpeed = 0.f; else if (nAnimID == ANIM_WALK) *fSpeed = DEFAULT_WALK_SPEED; else if (nAnimID == ANIM_RUN) *fSpeed = DEFAULT_WALK_SPEED*1.5f; else if (nAnimID == ANIM_FLY) *fSpeed = DEFAULT_WALK_SPEED*2.f; else *fSpeed = 0.f; } } bool ParaEngine::CDummyAnimInstance::HasAnimId(int nAnimID) { return (nAnimID == ANIM_STAND || nAnimID == ANIM_WALK || nAnimID == ANIM_RUN || nAnimID == ANIM_FLY); } void ParaEngine::CDummyAnimInstance::GetSpeedOf(const char * sName, float * fSpeed) { int nAnimID = CAnimTable::GetAnimIDByName(sName); if (fSpeed) { if (nAnimID == ANIM_STAND) *fSpeed = 0.f; else if (nAnimID == ANIM_WALK) *fSpeed = DEFAULT_WALK_SPEED; else if (nAnimID == ANIM_RUN) *fSpeed = DEFAULT_WALK_SPEED*1.5f; else if (nAnimID == ANIM_FLY) *fSpeed = DEFAULT_WALK_SPEED*2.f; else *fSpeed = 0.f; } }
package emu.project64.input; import java.util.Set; import emu.project64.AndroidDevice; import emu.project64.input.map.TouchMap; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.graphics.Point; import android.os.Vibrator; import android.util.SparseIntArray; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; /** * A class for generating N64 controller commands from a touchscreen. */ public class TouchController extends AbstractController implements OnTouchListener { public interface <API key> { /** * Called after the analog stick values have changed. * * @param axisFractionX The x-axis fraction, between -1 and 1, inclusive. * @param axisFractionY The y-axis fraction, between -1 and 1, inclusive. */ public void onAnalogChanged( float axisFractionX, float axisFractionY ); /** * Called after auto-hold button state changed. * * @param pressed The auto-hold state. * @param index The index of the auto-hold mask. */ public void onAutoHold( boolean pressed, int index ); } public static final int <API key> = 0; public static final int <API key> = 1; public static final int <API key> = 2; /** The number of milliseconds to wait before auto-holding (long-press method). */ private static final int <API key> = 1000; /** The pattern vibration when auto-hold is engaged. */ private static final long[] <API key> = { 0, 50, 50, 50 }; /** The number of milliseconds of vibration when pressing a key. */ private static final int <API key> = 50; /** The maximum number of pointers to query. */ private static final int MAX_POINTER_IDS = 256; /** The state change listener. */ private final <API key> mListener; /** The map from screen coordinates to N64 controls. */ private final TouchMap mTouchMap; /** The map from pointer ids to N64 controls. */ private final SparseIntArray mPointerMap = new SparseIntArray(); /** The method used for auto-holding buttons. */ private final int mAutoHoldMethod; /** The set of auto-holdable buttons. */ private final Set<Integer> mAutoHoldables; /** Whether touchscreen feedback is enabled. */ private final boolean <API key>; /** The touch state of each pointer. True indicates down, false indicates up. */ private final boolean[] mTouchState = new boolean[MAX_POINTER_IDS]; /** The x-coordinate of each pointer, between 0 and (screenwidth-1), inclusive. */ private final int[] mPointerX = new int[MAX_POINTER_IDS]; /** The y-coordinate of each pointer, between 0 and (screenheight-1), inclusive. */ private final int[] mPointerY = new int[MAX_POINTER_IDS]; /** The pressed start time of each pointer. */ private final long[] mStartTime = new long[MAX_POINTER_IDS]; /** The time between press and release of each pointer. */ private final long[] mElapsedTime = new long[MAX_POINTER_IDS]; /** * The identifier of the pointer associated with the analog stick. -1 indicates the stick has * been released. */ private int mAnalogPid = -1; /** The touch event source to listen to, or 0 to listen to all sources. */ private int mSourceFilter = 0; private Vibrator mVibrator = null; public TouchController( TouchMap touchMap, View view, <API key> listener, Vibrator vibrator, int autoHoldMethod, boolean touchscreenFeedback, Set<Integer> autoHoldableButtons ) { mListener = listener; mTouchMap = touchMap; mVibrator = vibrator; mAutoHoldMethod = autoHoldMethod; <API key> = touchscreenFeedback; mAutoHoldables = autoHoldableButtons; view.setOnTouchListener( this ); } /** * Sets the touch event source filter. * * @param source The source to listen to, or 0 to listen to all sources. */ public void setSourceFilter( int source ) { mSourceFilter = source; } /* * (non-Javadoc) * * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent) */ @SuppressLint( "<API key>" ) @Override @TargetApi( 9 ) public boolean onTouch( View view, MotionEvent event ) { // Filter by source, if applicable int source = AndroidDevice.IS_GINGERBREAD ? event.getSource() : 0; if( mSourceFilter != 0 && mSourceFilter != source ) return false; int action = event.getAction(); int actionCode = action & MotionEvent.ACTION_MASK; int pid = -1; switch( actionCode ) { case MotionEvent.ACTION_POINTER_DOWN: // A non-primary touch has been made pid = event.getPointerId( action >> MotionEvent.<API key> ); mStartTime[pid] = System.currentTimeMillis(); mTouchState[pid] = true; break; case MotionEvent.ACTION_POINTER_UP: // A non-primary touch has been released pid = event.getPointerId( action >> MotionEvent.<API key> ); mElapsedTime[pid] = System.currentTimeMillis() - mStartTime[pid]; mTouchState[pid] = false; break; case MotionEvent.ACTION_DOWN: // A touch gesture has started (e.g. analog stick movement) for( int i = 0; i < event.getPointerCount(); i++ ) { pid = event.getPointerId( i ); mStartTime[pid] = System.currentTimeMillis(); mTouchState[pid] = true; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: // A touch gesture has ended or canceled (e.g. analog stick movement) for( int i = 0; i < event.getPointerCount(); i++ ) { pid = event.getPointerId( i ); mElapsedTime[pid] = System.currentTimeMillis() - mStartTime[pid]; mTouchState[pid] = false; } break; default: break; } // Update the coordinates of down pointers and record max PID for speed int maxPid = -1; for( int i = 0; i < event.getPointerCount(); i++ ) { pid = event.getPointerId( i ); if( pid > maxPid ) maxPid = pid; if( mTouchState[pid] ) { mPointerX[pid] = (int) event.getX( i ); mPointerY[pid] = (int) event.getY( i ); } } // Process each touch processTouches( mTouchState, mPointerX, mPointerY, mElapsedTime, maxPid ); return true; } /** * Sets the N64 controller state based on where the screen is (multi-) touched. Values outside * the ranges listed below are safe. * * @param touchstate The touch state of each pointer. True indicates down, false indicates up. * @param pointerX The x-coordinate of each pointer, between 0 and (screenwidth-1), inclusive. * @param pointerY The y-coordinate of each pointer, between 0 and (screenheight-1), inclusive. * @param maxPid Maximum ID of the pointers that have changed (speed optimization). */ private void processTouches( boolean[] touchstate, int[] pointerX, int[] pointerY, long[] elapsedTime, int maxPid ) { boolean analogMoved = false; // Process each pointer in sequence for( int pid = 0; pid <= maxPid; pid++ ) { // Release analog if its pointer is not touching the screen if( pid == mAnalogPid && !touchstate[pid] ) { analogMoved = true; mAnalogPid = -1; mState.axisFractionX = 0; mState.axisFractionY = 0; } // Process button inputs if( pid != mAnalogPid ) processButtonTouch( touchstate[pid], pointerX[pid], pointerY[pid], elapsedTime[pid], pid ); // Process analog inputs if( touchstate[pid] && processAnalogTouch( pid, pointerX[pid], pointerY[pid] ) ) analogMoved = true; } // Call the super method to send the input to the core notifyChanged(); // Update the skin if the virtual analog stick moved if( analogMoved && mListener != null ) mListener.onAnalogChanged( mState.axisFractionX, mState.axisFractionY ); } /** * Process a touch as if intended for a button. Values outside the ranges listed below are safe. * * @param touched Whether the button is pressed or not. * @param xLocation The x-coordinate of the touch, between 0 and (screenwidth-1), inclusive. * @param yLocation The y-coordinate of the touch, between 0 and (screenheight-1), inclusive. * @param pid The identifier of the touch pointer. */ private void processButtonTouch( boolean touched, int xLocation, int yLocation, long timeElapsed, int pid ) { // Determine the index of the button that was pressed int index = touched ? mTouchMap.getButtonPress( xLocation, yLocation ) : mPointerMap.get( pid, TouchMap.UNMAPPED ); // Update the pointer map if( !touched ) { // Finger lifted off screen, forget what this pointer was touching mPointerMap.delete( pid ); } else { // Determine where the finger came from if is was slid int prevIndex = mPointerMap.get( pid, TouchMap.UNMAPPED ); // Finger touched somewhere on screen, remember what this pointer is touching mPointerMap.put( pid, index ); if( prevIndex != index ) { // Finger slid from somewhere else, act accordingly // There are three possibilities: // - old button --> new button // - nothing --> new button // - old button --> nothing // Reset this pointer's start time mStartTime[pid] = System.currentTimeMillis(); if( prevIndex != TouchMap.UNMAPPED ) { // Slid off a valid button if( !isAutoHoldable( prevIndex ) || mAutoHoldMethod == <API key> ) { // Slid off a non-auto-hold button setTouchState( prevIndex, false ); } else { // Slid off an auto-hold button switch( mAutoHoldMethod ) { case <API key>: // Using long-press method, release auto-hold button if( mListener != null ) mListener.onAutoHold( false, prevIndex ); setTouchState( prevIndex, false ); break; case <API key>: // Using slide-off method, engage auto-hold button if( mVibrator != null ) { mVibrator.cancel(); mVibrator.vibrate( <API key>, -1 ); } if( mListener != null ) mListener.onAutoHold( true, prevIndex ); setTouchState( prevIndex, true ); break; } } } } } if( index != TouchMap.UNMAPPED ) { // Finger is on a valid button // Provide simple vibration feedback for any valid button when first touched if( touched && <API key> && mVibrator != null ) { boolean firstTouched; if( index < NUM_N64_BUTTONS ) { // Single button pressed firstTouched = !mState.buttons[index]; } else { // Two d-pad buttons pressed simultaneously switch( index ) { case TouchMap.DPD_RU: firstTouched = !( mState.buttons[DPD_R] && mState.buttons[DPD_U] ); break; case TouchMap.DPD_RD: firstTouched = !( mState.buttons[DPD_R] && mState.buttons[DPD_D] ); break; case TouchMap.DPD_LD: firstTouched = !( mState.buttons[DPD_L] && mState.buttons[DPD_D] ); break; case TouchMap.DPD_LU: firstTouched = !( mState.buttons[DPD_L] && mState.buttons[DPD_U] ); break; default: firstTouched = false; break; } } if( firstTouched ) { mVibrator.cancel(); mVibrator.vibrate( <API key> ); } } // Set the controller state accordingly if( touched || !isAutoHoldable( index ) || mAutoHoldMethod == <API key> ) { // Finger just touched a button (any kind) OR // Finger just lifted off non-auto-holdable button setTouchState( index, touched ); // Do not provide auto-hold feedback yet } else { // Finger just lifted off an auto-holdable button switch( mAutoHoldMethod ) { case <API key>: // Release auto-hold button if using slide-off method if( mListener != null ) mListener.onAutoHold( false, index ); setTouchState( index, false ); break; case <API key>: if( timeElapsed < <API key> ) { // Release auto-hold if short-pressed if( mListener != null ) mListener.onAutoHold( false, index ); setTouchState( index, false ); } else { // Engage auto-hold if long-pressed if( mVibrator != null ) { mVibrator.cancel(); mVibrator.vibrate( <API key>, -1 ); } if( mListener != null ) mListener.onAutoHold( true, index ); setTouchState( index, true ); } break; } } } } /** * Checks if the button mapped to an N64 command is auto-holdable. * * @param commandIndex The index to the N64 command. * * @return True if the button mapped to the command is auto-holdable. */ private boolean isAutoHoldable( int commandIndex ) { return mAutoHoldables != null && mAutoHoldables.contains( commandIndex ); } /** * Sets the state of a button, and handles the D-Pad diagonals. * * @param index Which button is affected. * @param touched Whether the button is pressed or not. */ private void setTouchState( int index, boolean touched ) { // Set the button state if( index < AbstractController.NUM_N64_BUTTONS ) { // A single button was pressed mState.buttons[index] = touched; } else { // Two d-pad buttons pressed simultaneously switch( index ) { case TouchMap.DPD_RU: mState.buttons[DPD_R] = touched; mState.buttons[DPD_U] = touched; break; case TouchMap.DPD_RD: mState.buttons[DPD_R] = touched; mState.buttons[DPD_D] = touched; break; case TouchMap.DPD_LD: mState.buttons[DPD_L] = touched; mState.buttons[DPD_D] = touched; break; case TouchMap.DPD_LU: mState.buttons[DPD_L] = touched; mState.buttons[DPD_U] = touched; break; default: break; } } } /** * Process a touch as if intended for the analog stick. Values outside the ranges listed below * are safe. * * @param pointerId The pointer identifier. * @param xLocation The x-coordinate of the touch, between 0 and (screenwidth-1), inclusive. * @param yLocation The y-coordinate of the touch, between 0 and (screenheight-1), inclusive. * * @return True, if the analog state changed. */ private boolean processAnalogTouch( int pointerId, int xLocation, int yLocation ) { // Get the cartesian displacement of the analog stick Point point = mTouchMap.<API key>( xLocation, yLocation ); // Compute the pythagorean displacement of the stick int dX = point.x; int dY = point.y; float displacement = (float) Math.sqrt( ( dX * dX ) + ( dY * dY ) ); // "Capture" the analog control if( mTouchMap.isInCaptureRange( displacement ) ) mAnalogPid = pointerId; if( pointerId == mAnalogPid ) { // User is controlling the analog stick // Limit range of motion to an octagon (like the real N64 controller) point = mTouchMap.<API key>( dX, dY ); dX = point.x; dY = point.y; displacement = (float) Math.sqrt( ( dX * dX ) + ( dY * dY ) ); // Fraction of full-throttle, between 0 and 1, inclusive float p = mTouchMap.getAnalogStrength( displacement ); // Store the axis values in the super fields (screen y is inverted) mState.axisFractionX = p * dX / displacement; mState.axisFractionY = -p * dY / displacement; // Analog state changed return true; } // Analog state did not change return false; } }
<?php // Moodle is free software: you can redistribute it and/or modify // (at your option) any later version. // Moodle is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the namespace src\loader\utils; defined('MOODLE_INTERNAL') || die(); class curl { // This is just a dummy file to avoid failures in CI. }
int r; void turn(int i, int j, int x, int y, int z,int x0, int y0, int L, int W, int H) { if (z==0) { int R = x*x+y*y; if (R<r) r=R; } else { if(i>=0 && i< 2) turn(i+1, j, x0+L+z, y, x0+L-x, x0+L, y0, H, W, L); if(j>=0 && j< 2) turn(i, j+1, x, y0+W+z, y0+W-y, x0, y0+W, L, H, W); if(i<=0 && i>-2) turn(i-1, j, x0-z, y, x-x0, x0-H, y0, H, W, L); if(j<=0 && j>-2) turn(i, j-1, x, y0-z, y-y0, x0, y0-H, L, H, W); } } int main(){ int L, H, W, x1, y1, z1, x2, y2, z2; cin >> L >> W >> H >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; if (z1!=0 && z1!=H) if (y1==0 || y1==W) swap(y1,z1), std::swap(y2,z2), std::swap(W,H); else swap(x1,z1), std::swap(x2,z2), std::swap(L,H); if (z1==H) z1=0, z2=H-z2; r=0x3fffffff; turn(0,0,x2-x1,y2-y1,z2,-x1,-y1,L,W,H); cout<<r<<endl; }
// common.h // This file is part of a Software Defined Radio. // This program is free software; you can redistribute it and/or // as published by the Free Software Foundation; either version 2 // This program is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // You may contact us via email at: sales@flex-radio.com. // Paper mail may be sent to: // FlexRadio Systems // 12100 Technology Blvd. // Austin, TX 78727 // USA #ifndef _common_h #define _common_h #ifndef BOOLEAN typedef unsigned char BOOLEAN; #endif #ifndef TRUE #define TRUE 1 #define true 1 #endif #ifndef FALSE #define FALSE 0 #define false 0 #endif typedef unsigned char uint8; typedef char int8; typedef unsigned short uint16; typedef short int16; typedef unsigned int uint32; typedef int int32; typedef unsigned long long uint64; typedef long long int64; #endif // _common_h
/* testsuite.h - failif */ process test_addargs(bool8); process test_bigargs(bool8); process test_schedule(bool8 verbose); process test_preempt(bool8 verbose); process test_recursion(bool8 verbose); process test_semaphore(bool8 verbose); process test_semaphore2(bool8 verbose); process test_semaphore3(bool8 verbose); process test_semaphore4(bool8 verbose); process test_semaphore5(bool8 verbose); process test_libStdio(bool8 verbose); void testPass(bool8, const char *); void testFail(bool8, const char *); void testSkip(bool8, const char *); void testPrint(bool8, const char *); #define failif(cond, failmsg) \ if ( cond ) { testFail(verbose, failmsg); passed = FALSE; } \ else { testPass(verbose, ""); } /* Define the strcuture of an entry in the table of test cases */ struct testcase { char *name; /* Name of test case */ process (*test) (bool8);/* Test case function */ }; extern int ntests; /* total number of tests */ extern struct testcase testtab[]; /* table of test cases */ #define TESTSTK 8192 /* size of process stack used for test */
package com.mucommander.commons.file.filter; /** * <code>PathFilter</code> is a {@link FileFilter} that operates on absolute file paths. * * @see AbstractPathFilter * @author Maxence Bernard */ public interface PathFilter extends <API key> { }
<?php // Text $_['text_title'] = 'Credit or Debit Card (Processed securely by Perpetual Payments)'; $_['text_credit_card'] = 'Credit Card Details'; $_['text_transaction'] = 'Transaction ID:'; $_['text_avs'] = 'AVS/CVV:'; $_['text_avs_full_match'] = 'Full match'; $_['text_avs_not_match'] = 'Not matched'; $_['text_authorisation'] = 'Authorisation code:'; // Entry $_['entry_cc_number'] = 'Card Number'; $_['entry_cc_start_date'] = 'Card Valid From Date'; $_['<API key>'] = 'Card Expiry Date'; $_['entry_cc_cvv2'] = 'Card Security Code (CVV2)'; $_['entry_cc_issue'] = 'Card Issue Number'; // Help $_['help_start_date'] = '(if available)'; $_['help_issue'] = '(for Maestro and Solo cards only)';
/** * @file Visual mapping. */ define(function (require) { var zrUtil = require('zrender/core/util'); var zrColor = require('zrender/tool/color'); var linearMap = require('../util/number').linearMap; var each = zrUtil.each; var isObject = zrUtil.isObject; var <API key> = -1; /** * @param {Object} option * @param {string} [option.type] See visualHandlers. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed' * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent], * required when mappingMethod is 'linear' * @param {Array.<Object>=} [option.pieceList] [ * {value: someValue}, * {interval: [min1, max1], visual: {...}}, * {interval: [min2, max2]} * ], * required when mappingMethod is 'piecewise'. * Visual for only each piece can be specified. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2'] * required when mappingMethod is 'category'. * If no option.categories, categories is set * as [0, 1, 2, ...]. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'. * @param {(Array|Object|*)} [option.visual] Visual data. * when mappingMethod is 'category', * visual data can be array or object * (like: {cate1: '#222', none: '#fff'}) * or primary types (which represents * defualt category visual), otherwise visual * can be array or primary (which will be * normalized to array). * */ var VisualMapping = function (option) { var mappingMethod = option.mappingMethod; var visualType = option.type; /** * @readOnly * @type {Object} */ var thisOption = this.option = zrUtil.clone(option); /** * @readOnly * @type {string} */ this.type = visualType; /** * @readOnly * @type {string} */ this.mappingMethod = mappingMethod; /** * @private * @type {Function} */ this._normalizeData = normalizers[mappingMethod]; var visualHandler = visualHandlers[visualType]; /** * @public * @type {Function} */ this.applyVisual = visualHandler.applyVisual; /** * @public * @type {Function} */ this.getColorMapper = visualHandler.getColorMapper; /** * @private * @type {Function} */ this._doMap = visualHandler._doMap[mappingMethod]; if (mappingMethod === 'piecewise') { <API key>(thisOption); <API key>(thisOption); } else if (mappingMethod === 'category') { thisOption.categories ? <API key>(thisOption) // categories is ordinal when thisOption.categories not specified, // which need no more preprocess except normalize visual. : <API key>(thisOption, true); } else { zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent); <API key>(thisOption); } }; VisualMapping.prototype = { constructor: VisualMapping, mapValueToVisual: function (value) { var normalized = this._normalizeData(value); return this._doMap(normalized, value); }, getNormalizer: function () { return zrUtil.bind(this._normalizeData, this); } }; var visualHandlers = VisualMapping.visualHandlers = { color: { applyVisual: makeApplyVisual('color'), /** * Create a mapper function * @return {Function} */ getColorMapper: function () { var thisOption = this.option; return zrUtil.bind( thisOption.mappingMethod === 'category' ? function (value, isNormalized) { !isNormalized && (value = this._normalizeData(value)); return doMapCategory.call(this, value); } : function (value, isNormalized, out) { // If output rgb array // which will be much faster and useful in pixel manipulation var returnRGBArray = !!out; !isNormalized && (value = this._normalizeData(value)); out = zrColor.fastMapToColor(value, thisOption.parsedVisual, out); return returnRGBArray ? out : zrColor.stringify(out, 'rgba'); }, this ); }, _doMap: { linear: function (normalized) { return zrColor.stringify( zrColor.fastMapToColor(normalized, this.option.parsedVisual), 'rgba' ); }, category: doMapCategory, piecewise: function (normalized, value) { var result = getSpecifiedVisual.call(this, value); if (result == null) { result = zrColor.stringify( zrColor.fastMapToColor(normalized, this.option.parsedVisual), 'rgba' ); } return result; }, fixed: doMapFixed } }, colorHue: <API key>(function (color, value) { return zrColor.modifyHSL(color, value); }), colorSaturation: <API key>(function (color, value) { return zrColor.modifyHSL(color, null, value); }), colorLightness: <API key>(function (color, value) { return zrColor.modifyHSL(color, null, null, value); }), colorAlpha: <API key>(function (color, value) { return zrColor.modifyAlpha(color, value); }), opacity: { applyVisual: makeApplyVisual('opacity'), _doMap: makeDoMap([0, 1]) }, symbol: { applyVisual: function (value, getter, setter) { var symbolCfg = this.mapValueToVisual(value); if (zrUtil.isString(symbolCfg)) { setter('symbol', symbolCfg); } else if (isObject(symbolCfg)) { for (var name in symbolCfg) { if (symbolCfg.hasOwnProperty(name)) { setter(name, symbolCfg[name]); } } } }, _doMap: { linear: doMapToArray, category: doMapCategory, piecewise: function (normalized, value) { var result = getSpecifiedVisual.call(this, value); if (result == null) { result = doMapToArray.call(this, normalized); } return result; }, fixed: doMapFixed } }, symbolSize: { applyVisual: makeApplyVisual('symbolSize'), _doMap: makeDoMap([0, 1]) } }; function <API key>(thisOption) { var pieceList = thisOption.pieceList; thisOption.hasSpecialVisual = false; zrUtil.each(pieceList, function (piece, index) { piece.originIndex = index; // piece.visual is "result visual value" but not // a visual range, so it does not need to be normalized. if (piece.visual != null) { thisOption.hasSpecialVisual = true; } }); } function <API key>(thisOption) { // Hash categories. var categories = thisOption.categories; var visual = thisOption.visual; var categoryMap = thisOption.categoryMap = {}; each(categories, function (cate, index) { categoryMap[cate] = index; }); // Process visual map input. if (!zrUtil.isArray(visual)) { var visualArr = []; if (zrUtil.isObject(visual)) { each(visual, function (v, cate) { var index = categoryMap[cate]; visualArr[index != null ? index : <API key>] = v; }); } else { // Is primary type, represents default visual. visualArr[<API key>] = visual; } visual = setVisualToOption(thisOption, visualArr); } // Remove categories that has no visual, // then we can mapping them to <API key>. for (var i = categories.length - 1; i >= 0; i if (visual[i] == null) { delete categoryMap[categories[i]]; categories.pop(); } } } function <API key>(thisOption, isCategory) { var visual = thisOption.visual; var visualArr = []; if (zrUtil.isObject(visual)) { each(visual, function (v) { visualArr.push(v); }); } else if (visual != null) { visualArr.push(visual); } var doNotNeedPair = {color: 1, symbol: 1}; if (!isCategory && visualArr.length === 1 && !doNotNeedPair.hasOwnProperty(thisOption.type) ) { visualArr[1] = visualArr[0]; } setVisualToOption(thisOption, visualArr); } function <API key>(applyValue) { return { applyVisual: function (value, getter, setter) { value = this.mapValueToVisual(value); // Must not be array value setter('color', applyValue(getter('color'), value)); }, _doMap: makeDoMap([0, 1]) }; } function doMapToArray(normalized) { var visual = this.option.visual; return visual[ Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true)) ] || {}; } function makeApplyVisual(visualType) { return function (value, getter, setter) { setter(visualType, this.mapValueToVisual(value)); }; } function doMapCategory(normalized) { var visual = this.option.visual; return visual[ (this.option.loop && normalized !== <API key>) ? normalized % visual.length : normalized ]; } function doMapFixed() { return this.option.visual[0]; } function makeDoMap(sourceExtent) { return { linear: function (normalized) { return linearMap(normalized, sourceExtent, this.option.visual, true); }, category: doMapCategory, piecewise: function (normalized, value) { var result = getSpecifiedVisual.call(this, value); if (result == null) { result = linearMap(normalized, sourceExtent, this.option.visual, true); } return result; }, fixed: doMapFixed }; } function getSpecifiedVisual(value) { var thisOption = this.option; var pieceList = thisOption.pieceList; if (thisOption.hasSpecialVisual) { var pieceIndex = VisualMapping.findPieceIndex(value, pieceList); var piece = pieceList[pieceIndex]; if (piece && piece.visual) { return piece.visual[this.type]; } } } function setVisualToOption(thisOption, visualArr) { thisOption.visual = visualArr; if (thisOption.type === 'color') { thisOption.parsedVisual = zrUtil.map(visualArr, function (item) { return zrColor.parse(item); }); } return visualArr; } /** * Normalizers by mapping methods. */ var normalizers = { linear: function (value) { return linearMap(value, this.option.dataExtent, [0, 1], true); }, piecewise: function (value) { var pieceList = this.option.pieceList; var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true); if (pieceIndex != null) { return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true); } }, category: function (value) { var index = this.option.categories ? this.option.categoryMap[value] : value; // ordinal return index == null ? <API key> : index; }, fixed: zrUtil.noop }; /** * List available visual types. * * @public * @return {Array.<string>} */ VisualMapping.listVisualTypes = function () { var visualTypes = []; zrUtil.each(visualHandlers, function (handler, key) { visualTypes.push(key); }); return visualTypes; }; /** * @public */ VisualMapping.addVisualHandler = function (name, handler) { visualHandlers[name] = handler; }; /** * @public */ VisualMapping.isValidType = function (visualType) { return visualHandlers.hasOwnProperty(visualType); }; /** * Convinent method. * Visual can be Object or Array or primary type. * * @public */ VisualMapping.eachVisual = function (visual, callback, context) { if (zrUtil.isObject(visual)) { zrUtil.each(visual, callback, context); } else { callback.call(context, visual); } }; VisualMapping.mapVisual = function (visual, callback, context) { var isPrimary; var newVisual = zrUtil.isArray(visual) ? [] : zrUtil.isObject(visual) ? {} : (isPrimary = true, null); VisualMapping.eachVisual(visual, function (v, key) { var newVal = callback.call(context, v, key); isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal); }); return newVisual; }; /** * @public * @param {Object} obj * @return {Oject} new object containers visual values. * If no visuals, return null. */ VisualMapping.retrieveVisuals = function (obj) { var ret = {}; var hasVisual; obj && each(visualHandlers, function (h, visualType) { if (obj.hasOwnProperty(visualType)) { ret[visualType] = obj[visualType]; hasVisual = true; } }); return hasVisual ? ret : null; }; /** * Give order to visual types, considering colorSaturation, colorAlpha depends on color. * * @public * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...} * IF Array, like: ['color', 'symbol', 'colorSaturation'] * @return {Array.<string>} Sorted visual types. */ VisualMapping.prepareVisualTypes = function (visualTypes) { if (isObject(visualTypes)) { var types = []; each(visualTypes, function (item, type) { types.push(type); }); visualTypes = types; } else if (zrUtil.isArray(visualTypes)) { visualTypes = visualTypes.slice(); } else { return []; } visualTypes.sort(function (type1, type2) { // color should be front of colorSaturation, colorAlpha, ... // symbol and symbolSize do not matter. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0) ? 1 : -1; }); return visualTypes; }; /** * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'. * Other visuals are only depends on themself. * * @public * @param {string} visualType1 * @param {string} visualType2 * @return {boolean} */ VisualMapping.dependsOn = function (visualType1, visualType2) { return visualType2 === 'color' ? !!(visualType1 && visualType1.indexOf(visualType2) === 0) : visualType1 === visualType2; }; /** * @param {number} value * @param {Array.<Object>} pieceList [{value: ..., interval: [min, max]}, ...] * Always from small to big. * @param {boolean} [<API key>=false] * @return {number} index */ VisualMapping.findPieceIndex = function (value, pieceList, <API key>) { var possibleI; var abs = Infinity; // value has the higher priority. for (var i = 0, len = pieceList.length; i < len; i++) { var pieceValue = pieceList[i].value; if (pieceValue != null) { if (pieceValue === value // FIXME // It is supposed to compare value according to value type of dimension, // but currently value type can exactly be string or number. // Compromise for numeric-like string (like '12'), especially // in the case that visualMap.categories is ['22', '33']. || (typeof pieceValue === 'string' && pieceValue === value + '') ) { return i; } <API key> && updatePossible(pieceValue, i); } } for (var i = 0, len = pieceList.length; i < len; i++) { var piece = pieceList[i]; var interval = piece.interval; var close = piece.close; if (interval) { if (interval[0] === -Infinity) { if (littleThan(close[1], value, interval[1])) { return i; } } else if (interval[1] === Infinity) { if (littleThan(close[0], interval[0], value)) { return i; } } else if ( littleThan(close[0], interval[0], value) && littleThan(close[1], value, interval[1]) ) { return i; } <API key> && updatePossible(interval[0], i); <API key> && updatePossible(interval[1], i); } } if (<API key>) { return value === Infinity ? pieceList.length - 1 : value === -Infinity ? 0 : possibleI; } function updatePossible(val, index) { var newAbs = Math.abs(val - value); if (newAbs < abs) { abs = newAbs; possibleI = index; } } }; function littleThan(close, a, b) { return close ? a <= b : a < b; } return VisualMapping; });
package org.eclipse.jdt.internal.codeassist.impl; import java.util.Iterator; import java.util.Map; import org.eclipse.jdt.core.compiler.CharOperation; public class AssistOptions { /** * Option IDs */ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.visibilityCheck"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.<API key>"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.fieldPrefixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.localPrefixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.argumentPrefixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.fieldSuffixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.localSuffixes"; //$NON-NLS-1$ public static final String <API key> = "org.eclipse.jdt.core.codeComplete.argumentSuffixes"; //$NON-NLS-1$ public static final String ENABLED = "enabled"; //$NON-NLS-1$ public static final String DISABLED = "disabled"; //$NON-NLS-1$ public boolean checkVisibility = false; public boolean <API key> = false; public char[][] fieldPrefixes = null; public char[][] staticFieldPrefixes = null; public char[][] localPrefixes = null; public char[][] argumentPrefixes = null; public char[][] fieldSuffixes = null; public char[][] staticFieldSuffixes = null; public char[][] localSuffixes = null; public char[][] argumentSuffixes = null; /** * Initializing the assist options with default settings */ public AssistOptions() { // Initializing the assist options with default settings } /** * Initializing the assist options with external settings */ public AssistOptions(Map settings) { if (settings == null) return; // filter options which are related to the assist component Iterator entries = settings.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry)entries.next(); if (!(entry.getKey() instanceof String)) continue; if (!(entry.getValue() instanceof String)) continue; String optionID = (String) entry.getKey(); String optionValue = (String) entry.getValue(); if (optionID.equals(<API key>)) { if (optionValue.equals(ENABLED)) { this.checkVisibility = true; } else if (optionValue.equals(DISABLED)) { this.checkVisibility = false; } continue; } else if (optionID.equals(<API key>)) { if (optionValue.equals(ENABLED)) { this.<API key> = true; } else if (optionValue.equals(DISABLED)) { this.<API key> = false; } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.fieldPrefixes = null; } else { this.fieldPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.staticFieldPrefixes = null; } else { this.staticFieldPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.localPrefixes = null; } else { this.localPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.argumentPrefixes = null; } else { this.argumentPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.fieldSuffixes = null; } else { this.fieldSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.staticFieldSuffixes = null; } else { this.staticFieldSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.localSuffixes = null; } else { this.localSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } else if(optionID.equals(<API key>)){ if (optionValue.length() == 0) { this.argumentSuffixes = null; } else { this.argumentSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray()); } continue; } } } }
#include <libopencm3/cm3/systick.h> #include <libopencm3/stm32/timer.h> #include <libopencm3/stm32/usart.h> #include <libopencm3/stm32/pwr.h> #include <libopencm3/stm32/f2/rcc.h> #include <libopencm3/stm32/f2/rtc.h> #include <libopencm3/cm3/nvic.h> #include <libopencm3/stm32/iwdg.h> #include "common.h" #include "rtc.h" #include "../common/devo/devo.h" //The following is from an unreleased libopencm3 //We should remove it eventually #if 1 void iwdg_start(void); void iwdg_set_period_ms(u32 period); bool iwdg_reload_busy(void); bool iwdg_prescaler_busy(void); void iwdg_reset(void); #endif volatile u32 msecs; volatile u32 msecTimer1; volatile u32 msecTimer2; volatile u32 wdg_time; u16 (*timer_callback)(void); volatile u8 msec_callbacks; volatile u32 msec_cbtime[NUM_MSEC_CALLBACKS]; void CLOCK_Init() { /* 60MHz / 8 => 7500000 counts per second */ <API key>(<API key>); /* 7500000/7500 = 1000 overflows per second - every 1ms one interrupt */ systick_set_reload(7500); nvic_set_priority(NVIC_SYSTICK_IRQ, 0x0); //Highest priority /* We trigger exti2 right before the watchdog fires to do a stack dump */ nvic_set_priority(NVIC_EXTI2_IRQ, 0x01); //Highest priority <API key>(); msecs = 0; msec_callbacks = 0; /* Start counting. */ <API key>(); /* Setup timer for Transmitter */ timer_callback = NULL; /* Enable TIM5 clock. */ <API key>(&RCC_APB1ENR, RCC_APB1ENR_TIM5EN); /* Enable TIM5 interrupt. */ nvic_enable_irq(NVIC_TIM5_IRQ); nvic_set_priority(NVIC_TIM5_IRQ, 16); //High priority <API key>(TIM5); /* Reset TIM5 peripheral. */ timer_reset(TIM5); /* Timer global mode: * - No divider * - Alignment edge * - Direction up */ timer_set_mode(TIM5, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); /* timer updates each microsecond */ timer_set_prescaler(TIM5, 60 - 1); timer_set_period(TIM5, 65535); /* Disable preload. */ <API key>(TIM5); /* Continous mode. */ <API key>(TIM5); /* Disable outputs. */ <API key>(TIM5, TIM_OC1); <API key>(TIM5, TIM_OC2); <API key>(TIM5, TIM_OC3); <API key>(TIM5, TIM_OC4); /* Enable CCP1 */ <API key>(TIM5, TIM_OC1); <API key>(TIM5, TIM_OC1); <API key>(TIM5, TIM_OC1); timer_set_oc_mode(TIM5, TIM_OC1, TIM_OCM_FROZEN); /* Disable CCP1 interrupt. */ timer_disable_irq(TIM5, TIM_DIER_CC1IE); <API key>(TIM5); /* Enable EXTI1 interrupt. */ /* We are enabling only the interrupt * We'll manually trigger this via <API key> */ nvic_enable_irq(NVIC_EXTI1_IRQ); nvic_set_priority(NVIC_EXTI1_IRQ, 64); //Medium priority /* Enable DMA Channel1 with same priority as EXTI1 */ //FIXME //nvic_enable_irq(<API key>); //nvic_set_priority(<API key>, 65); //Medium priority /* wait for system to start up and stabilize */ while(msecs < 100) ; } void CLOCK_StartTimer(unsigned us, u16 (*cb)(void)) { if(! cb) return; timer_callback = cb; /* Counter enable. */ u16 t = timer_get_counter(TIM5); /* Set the capture compare value for OC1. */ timer_set_oc_value(TIM5, TIM_OC1, us + t); timer_clear_flag(TIM5, TIM_SR_CC1IF); timer_enable_irq(TIM5, TIM_DIER_CC1IE); } void CLOCK_StartWatchdog() { iwdg_set_period_ms(3000); iwdg_start(); wdg_time = msecs; <API key>(NVIC_EXTI2_IRQ); nvic_enable_irq(NVIC_EXTI2_IRQ); } void CLOCK_ResetWatchdog() { iwdg_reset(); wdg_time = msecs; } void CLOCK_StopTimer() { timer_disable_irq(TIM5, TIM_DIER_CC1IE); timer_callback = NULL; } void tim5_isr() { if(timer_callback) { #ifdef TIMING_DEBUG debug_timing(4, 0); #endif u16 us = timer_callback(); #ifdef TIMING_DEBUG debug_timing(4, 1); #endif timer_clear_flag(TIM5, TIM_SR_CC1IF); if (us) { timer_set_oc_value(TIM5, TIM_OC1, us + TIM_CCR1(TIM5)); return; } } CLOCK_StopTimer(); } u32 CLOCK_getms() { return msecs; } void <API key>(int cb, u32 msec) { msec_cbtime[cb] = msecs + msec; msec_callbacks |= (1 << cb); } void <API key>(int cb) { msec_callbacks &= ~(1 << cb); } void exti1_isr() { //ADC_StartCapture(); //ADC completion will trigger update ADC_Filter(); medium_priority_cb(); } void sys_tick_handler(void) { msecs++; if(msecTimer1) msecTimer1 if(msecTimer2) msecTimer2 if(msecs - wdg_time > 2000) { <API key>(NVIC_EXTI2_IRQ); return; } if(msec_callbacks & (1 << MEDIUM_PRIORITY)) { if (msecs == msec_cbtime[MEDIUM_PRIORITY]) { //medium priority tasks execute in interrupt and main loop context <API key>(NVIC_EXTI1_IRQ); priority_ready |= 1 << MEDIUM_PRIORITY; msec_cbtime[MEDIUM_PRIORITY] = msecs + <API key>; } } if(msec_callbacks & (1 << LOW_PRIORITY)) { if (msecs == msec_cbtime[LOW_PRIORITY]) { //Low priority tasks execute in the main loop priority_ready |= 1 << LOW_PRIORITY; msec_cbtime[LOW_PRIORITY] = msecs + LOW_PRIORITY_MSEC; } } if(msec_callbacks & (1 << TIMER_SOUND)) { if (msecs == msec_cbtime[TIMER_SOUND]) { u16 ms = SOUND_Callback(); if(! ms) msec_callbacks &= ~(1 << TIMER_SOUND); else msec_cbtime[TIMER_SOUND] = msecs + ms; } } } // initialize RTC void RTC_Init() { <API key>(&RCC_APB1ENR, RCC_APB1ENR_PWREN); <API key>(); rcc_osc_on(LSE); <API key>(LSE); RCC_BDCR |= RCC_BDCR_SRC_LSE; //Set source to LSE RCC_BDCR |= RCC_BDCR_RTCEN; //Enable RTC <API key>(); rtc_set_prescaler(255, 127); } static const u16 daysInYear[2][13] = { { 0,31,59,90,120,151,181,212,243,273,304,334,365}, { 0,31,60,91,121,152,182,213,244,274,305,335,366} }; // set date value (deviation epoch = seconds since 1.1.2012, 00:00:00) void RTC_SetValue(u32 value) { value += 4382 * 60 * 60 * 24; //convert date from 1.1.2012, 00:00:00 to 1.1.2000, 00:00:00 uint32_t date = 0, time = 0; const uint32_t SEC = value % 60; const uint32_t MIN = (value / 60) % 60; const uint32_t HR = (value / 60 / 60) % 24; uint32_t DAYS = (value / 60 / 60 / 24); uint32_t DAY = 0; uint32_t YEAR = (4*DAYS) / 1461; // = days/365.25 uint32_t LEAP = (YEAR % 4 == 0) ? 1 : 0; uint32_t WEEKDAY = DAYS / 7 + 7; //1/1/2000 was a Saturday uint32_t MONTH = 0; //Convert time to bcd time |= (SEC % 10) << 0; //seconds ones time |= (SEC / 10) << 4; //seconds tens time |= (MIN % 10) << 8; //minutes ones time |= (MIN / 10) << 12; //minutes tens time |= (HR % 10) << 16; //hours ones time |= (HR / 10) << 20; //hours tens //Convert date to bcd DAYS -= (uint32_t)(YEAR * 365 + YEAR / 4); DAYS -= (DAYS > daysInYear[LEAP][2]) ? 1 : 0; //leap year correction for RTC_STARTYEAR for (MONTH=0; MONTH<12; MONTH++) { if (DAYS < daysInYear[LEAP][MONTH + 1]) break; } DAY = DAYS - daysInYear[LEAP][MONTH]; date |= (DAY % 10) << 0; //date in ones date |= (DAY / 10) << 4; //date in tens date |= (MONTH % 10) << 8; //month in ones date |= (MONTH / 10) << 12; //month in tens date |= (WEEKDAY) << 13; //weekday date |= (YEAR % 10) << 16; //year in ones date |= (YEAR / 10) << 20; //year in tens //Unlock rtc_unlock(); //Enter Init mode RTC_ISR = 0xFFFFFFFF; for(int i = 0; i < 0x10000; i++) if((RTC_ISR & RTC_ISR_INITF) == 0) break; //SetDate RTC_DR = date; RTC_TR = time; // Exit Init mode RTC_ISR &= (uint32_t)~RTC_ISR_INIT; //Wait for synch <API key>(); //Lock rtc_lock(); } // get date value (deviation epoch = seconds since 1.1.2012, 00:00:00) u32 RTC_GetValue() { u32 value = 0; uint32_t time = RTC_TR; uint32_t date = RTC_DR; const uint32_t YEAR = (((date >> 20) & 0x0f) * 10) + ((date >> 16) & 0x0f) - 12; const uint32_t MONTH = (((date >> 12) & 0x01) * 10) + ((date >> 8) & 0x0f); const uint32_t DAY = (((date >> 4) & 0x03) * 10) + ((date >> 0) & 0x0f); const uint32_t HOUR = (((time >> 20) & 0x03) * 10) + ((time >> 16) & 0x0f); const uint32_t MIN = (((time >> 12) & 0x07) * 10) + ((time >> 8) & 0x0f); const uint32_t SEC = (((time >> 4) & 0x07) * 10) + ((time >> 0) & 0x0f); value += (DAY-1 + daysInYear[YEAR%4 == 0 ? 1 : 0][MONTH-1] + YEAR * 365 + YEAR/4 + ((YEAR != 0 && MONTH > 2) ? 1 : 0)) * (60*60*24); value += HOUR*60*60 + MIN*60+SEC; return value; } void rtc_gettime(struct gtm * t) { uint32_t time = RTC_TR; uint32_t date = RTC_DR; const uint32_t YEAR = (((date >> 20) & 0x0f) * 10) + ((date >> 16) & 0x0f); const uint32_t MONTH = (((date >> 12) & 0x01) * 10) + ((date >> 8) & 0x0f); const uint32_t DAY = (((date >> 4) & 0x03) * 10) + ((date >> 0) & 0x0f); const uint32_t HOUR = (((time >> 20) & 0x03) * 10) + ((time >> 16) & 0x0f); const uint32_t MIN = (((time >> 12) & 0x07) * 10) + ((time >> 8) & 0x0f); const uint32_t SEC = (((time >> 4) & 0x07) * 10) + ((time >> 0) & 0x0f); t->tm_hour = HOUR; t->tm_min = MIN; t->tm_sec = SEC; t->tm_year = YEAR + 100; t->tm_mon = MONTH; t->tm_mday = DAY; }
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_29) on Wed Jan 11 13:02:06 MST 2012 --> <TITLE> Uses of Class org.imgscalr.Scalr.Mode (imgscalr v4.2 - Java Image Scaling Library) </TITLE> <META NAME="date" CONTENT="2012-01-11"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.imgscalr.Scalr.Mode (imgscalr v4.2 - Java Image Scaling Library)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../org/imgscalr/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/imgscalr/\class-useScalr.Mode.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Scalr.Mode.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <CENTER> <H2> <B>Uses of Class<br>org.imgscalr.Scalr.Mode</B></H2> </CENTER> <A NAME="org.imgscalr"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A> in <A HREF="../../../org/imgscalr/package-summary.html">org.imgscalr</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="<API key>"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../org/imgscalr/package-summary.html">org.imgscalr</A> that return <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A></CODE></FONT></TD> <TD><CODE><B>Scalr.Mode.</B><B><A HREF="../../../org/imgscalr/Scalr.Mode.html <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the enum constant of this type with the specified name.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>[]</CODE></FONT></TD> <TD><CODE><B>Scalr.Mode.</B><B><A HREF="../../../org/imgscalr/Scalr.Mode.html#values()">values</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an array containing the constants of this enum type, in the order they are declared.</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="<API key>"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../org/imgscalr/package-summary.html">org.imgscalr</A> with parameters of type <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html?is-external=true" title="class or interface in java.awt.image">BufferedImage</A></CODE></FONT></TD> <TD><CODE><B>Scalr.</B><B><A HREF="../../../org/imgscalr/Scalr.html <A HREF="../../../org/imgscalr/Scalr.Method.html" title="enum in org.imgscalr">Scalr.Method</A>&nbsp;scalingMethod, <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetSize, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resize a given image (maintaining its original proportion) to a width and height no bigger than <code>targetSize</code> (or fitting the image to the given WIDTH or HEIGHT explicitly, depending on the <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><CODE>Scalr.Mode</CODE></A> specified) using the given scaling method and apply the given <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image"><CODE>BufferedImageOp</CODE></A>s (if any) to the result before returning it.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http: <TD><CODE><B>AsyncScalr.</B><B><A HREF="../../../org/imgscalr/AsyncScalr.html <A HREF="../../../org/imgscalr/Scalr.Method.html" title="enum in org.imgscalr">Scalr.Method</A>&nbsp;scalingMethod, <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetSize, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html?is-external=true" title="class or interface in java.awt.image">BufferedImage</A></CODE></FONT></TD> <TD><CODE><B>Scalr.</B><B><A HREF="../../../org/imgscalr/Scalr.html <A HREF="../../../org/imgscalr/Scalr.Method.html" title="enum in org.imgscalr">Scalr.Method</A>&nbsp;scalingMethod, <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetWidth, int&nbsp;targetHeight, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resize a given image (maintaining its original proportion) to the target width and height (or fitting the image to the given WIDTH or HEIGHT explicitly, depending on the <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><CODE>Scalr.Mode</CODE></A> specified) using the given scaling method and apply the given <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image"><CODE>BufferedImageOp</CODE></A>s (if any) to the result before returning it.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http: <TD><CODE><B>AsyncScalr.</B><B><A HREF="../../../org/imgscalr/AsyncScalr.html <A HREF="../../../org/imgscalr/Scalr.Method.html" title="enum in org.imgscalr">Scalr.Method</A>&nbsp;scalingMethod, <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetWidth, int&nbsp;targetHeight, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html?is-external=true" title="class or interface in java.awt.image">BufferedImage</A></CODE></FONT></TD> <TD><CODE><B>Scalr.</B><B><A HREF="../../../org/imgscalr/Scalr.html <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetSize, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resize a given image (maintaining its original proportion) to a width and height no bigger than <code>targetSize</code> (or fitting the image to the given WIDTH or HEIGHT explicitly, depending on the <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><CODE>Scalr.Mode</CODE></A> specified) and apply the given <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image"><CODE>BufferedImageOp</CODE></A>s (if any) to the result before returning it.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http: <TD><CODE><B>AsyncScalr.</B><B><A HREF="../../../org/imgscalr/AsyncScalr.html <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetSize, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html?is-external=true" title="class or interface in java.awt.image">BufferedImage</A></CODE></FONT></TD> <TD><CODE><B>Scalr.</B><B><A HREF="../../../org/imgscalr/Scalr.html <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetWidth, int&nbsp;targetHeight, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resize a given image (maintaining its original proportion) to the target width and height (or fitting the image to the given WIDTH or HEIGHT explicitly, depending on the <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><CODE>Scalr.Mode</CODE></A> specified) and apply the given <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image"><CODE>BufferedImageOp</CODE></A>s (if any) to the result before returning it.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="http: <TD><CODE><B>AsyncScalr.</B><B><A HREF="../../../org/imgscalr/AsyncScalr.html <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr">Scalr.Mode</A>&nbsp;resizeMode, int&nbsp;targetWidth, int&nbsp;targetHeight, <A HREF="http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImageOp.html?is-external=true" title="class or interface in java.awt.image">BufferedImageOp</A>...&nbsp;ops)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../org/imgscalr/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../org/imgscalr/Scalr.Mode.html" title="enum in org.imgscalr"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> Copyright 2011 The Buzz Media, LLC</EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/imgscalr/\class-useScalr.Mode.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Scalr.Mode.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> </BODY> </HTML>
var express = require('express') var app = module.exports = express() app.get('/404', require('lib/site/layout')) app.get('*', function (req, res) { res.redirect('/404') })
package axoloti.menus; import axoloti.MainFrame; import java.io.File; import java.io.FilenameFilter; import java.util.Arrays; import javax.swing.JMenu; import javax.swing.JMenuItem; /** * * @author jtaelman */ public class PopulatePatchMenu { static void PopulatePatchMenu(JMenu parent, String path, String ext) { File dir = new File(path); if (!dir.isDirectory()) { JMenuItem mi = new JMenuItem("no help patches found"); mi.setEnabled(false); parent.add(mi); return; } final String extension = ext; File[] files = dir.listFiles(new java.io.FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory(); } }); Arrays.sort(files); for (File subdir : files) { JMenu fm = new JMenu(subdir.getName()); PopulatePatchMenu(fm, subdir.getPath(), extension); if (fm.getItemCount() > 0) { parent.add(fm); } } String filenames[] = dir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return (name.endsWith(extension)); } }); Arrays.sort(filenames); for (String fn : filenames) { String fn2 = fn.substring(0, fn.length() - 4); JMenuItem fm = new JMenuItem(fn2); fm.setActionCommand("open:" + path + File.separator + fn); fm.addActionListener(MainFrame.mainframe); parent.add(fm); } } }
#define PETSCMAT_DLL #include "src/mat/impls/aij/seq/aij.h" EXTERN PetscErrorCode Mat_CheckInode(Mat,PetscTruth); EXTERN_C_BEGIN EXTERN PetscErrorCode PETSCMAT_DLLEXPORT <API key>(Mat,IS*,IS*); EXTERN PetscErrorCode PETSCMAT_DLLEXPORT <API key>(Mat,PetscInt*,PetscInt*[],PetscInt*); EXTERN_C_END #undef __FUNCT__ #define __FUNCT__ "MatView_Inode" PetscErrorCode MatView_Inode(Mat A,PetscViewer viewer) { Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; PetscErrorCode ierr; PetscTruth iascii; PetscViewerFormat format; PetscFunctionBegin; ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);CHKERRQ(ierr); if (iascii) { ierr = <API key>(viewer,&format);CHKERRQ(ierr); if (format == <API key> || format == <API key>) { if (a->inode.size) { ierr = <API key>(viewer,"using I-node routines: found %D nodes, limit used is %D\n", a->inode.node_count,a->inode.limit);CHKERRQ(ierr); } else { ierr = <API key>(viewer,"not using I-node routines\n");CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "<API key>" PetscErrorCode <API key>(Mat A, MatAssemblyType mode) { Mat_SeqAIJ *a = (Mat_SeqAIJ*)A->data; PetscErrorCode ierr; PetscTruth samestructure; PetscFunctionBegin; /* info.nz_unneeded of zero denotes no structural change was made to the matrix during Assembly */ samestructure = (PetscTruth)(!A->info.nz_unneeded); /* check for identical nodes. If found, use inode functions */ ierr = Mat_CheckInode(A,samestructure);CHKERRQ(ierr); a->inode.ibdiagvalid = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatDestroy_Inode" PetscErrorCode MatDestroy_Inode(Mat A) { PetscErrorCode ierr; Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; PetscFunctionBegin; ierr = PetscFree(a->inode.size);CHKERRQ(ierr); ierr = PetscFree2(a->inode.ibdiag,a->inode.bdiag);CHKERRQ(ierr); ierr = <API key>((PetscObject)A,"<API key>","",PETSC_NULL);CHKERRQ(ierr); ierr = <API key>((PetscObject)A,"<API key>","",PETSC_NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } /* MatCreate_Inode is not DLLEXPORTed because it is not a constructor for a complete type. */ /* It is also not registered as a type for use within MatSetType. */ /* It is intended as a helper for the MATSEQAIJ class, so classes which desire Inodes should */ /* inherit off of MATSEQAIJ instead by calling MatSetType(MATSEQAIJ) in their constructor. */ /* Maybe this is a bad idea. (?) */ #undef __FUNCT__ #define __FUNCT__ "MatCreate_Inode" PetscErrorCode MatCreate_Inode(Mat B) { Mat_SeqAIJ *b=(Mat_SeqAIJ*)B->data; PetscErrorCode ierr; PetscTruth no_inode,no_unroll; PetscFunctionBegin; no_inode = PETSC_FALSE; no_unroll = PETSC_FALSE; b->inode.node_count = 0; b->inode.size = 0; b->inode.limit = 5; b->inode.max_limit = 5; b->inode.ibdiagvalid = PETSC_FALSE; b->inode.ibdiag = 0; b->inode.bdiag = 0; ierr = PetscOptionsBegin(((PetscObject)B)->comm,((PetscObject)B)->prefix,"Options for SEQAIJ matrix","Mat");CHKERRQ(ierr); ierr = PetscOptionsTruth("-mat_no_unroll","Do not optimize for inodes (slower)",PETSC_NULL,no_unroll,&no_unroll,PETSC_NULL);CHKERRQ(ierr); if (no_unroll) {ierr = PetscInfo(B,"Not using Inode routines due to -mat_no_unroll\n");CHKERRQ(ierr);} ierr = PetscOptionsTruth("-mat_no_inode","Do not optimize for inodes (slower)",PETSC_NULL,no_inode,&no_inode,PETSC_NULL);CHKERRQ(ierr); if (no_inode) {ierr = PetscInfo(B,"Not using Inode routines due to -mat_no_inode\n");CHKERRQ(ierr);} ierr = PetscOptionsInt("-mat_inode_limit","Do not use inodes larger then this value",PETSC_NULL,b->inode.limit,&b->inode.limit,PETSC_NULL);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); b->inode.use = (PetscTruth)(!(no_unroll || no_inode)); if (b->inode.limit > b->inode.max_limit) b->inode.limit = b->inode.max_limit; ierr = <API key>((PetscObject)B,"<API key>", "<API key>", <API key>);CHKERRQ(ierr); ierr = <API key>((PetscObject)B,"<API key>", "<API key>", <API key>);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatSetOption_Inode" PetscErrorCode MatSetOption_Inode(Mat A,MatOption op,PetscTruth flg) { Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; PetscFunctionBegin; switch(op) { case MAT_USE_INODES: a->inode.use = flg; break; default: break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatDuplicate_Inode" PetscErrorCode MatDuplicate_Inode(Mat A,MatDuplicateOption cpvalues,Mat *C) { Mat B=*C; Mat_SeqAIJ *c=(Mat_SeqAIJ*)B->data,*a=(Mat_SeqAIJ*)A->data; PetscErrorCode ierr; PetscInt m=A->rmap.n; PetscFunctionBegin; c->inode.use = a->inode.use; c->inode.limit = a->inode.limit; c->inode.max_limit = a->inode.max_limit; if (a->inode.size){ ierr = PetscMalloc((m+1)*sizeof(PetscInt),&c->inode.size);CHKERRQ(ierr); c->inode.node_count = a->inode.node_count; ierr = PetscMemcpy(c->inode.size,a->inode.size,(m+1)*sizeof(PetscInt));CHKERRQ(ierr); } else { c->inode.size = 0; c->inode.node_count = 0; } c->inode.ibdiagvalid = PETSC_FALSE; c->inode.ibdiag = 0; c->inode.bdiag = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "<API key>" PetscErrorCode <API key>(Mat A,IS isrow,IS iscol,MatFactorInfo *info,Mat *fact) { PetscErrorCode ierr; PetscFunctionBegin; /* check for identical nodes. If found, use inode functions */ ierr = Mat_CheckInode(*fact,PETSC_FALSE);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "<API key>" PetscErrorCode <API key>(Mat A,IS isrow,IS iscol,MatFactorInfo *info,Mat *fact) { PetscErrorCode ierr; PetscFunctionBegin; /* check for identical nodes. If found, use inode functions */ ierr = Mat_CheckInode(*fact,PETSC_FALSE);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "<API key>" PetscErrorCode <API key>(Mat A,IS isrow,IS iscol,MatFactorInfo *info,Mat *fact) { PetscErrorCode ierr; PetscFunctionBegin; /* check for identical nodes. If found, use inode functions */ ierr = Mat_CheckInode(*fact,PETSC_FALSE);CHKERRQ(ierr); PetscFunctionReturn(0); }