code
stringlengths
4
1.01M
/* SPDX-License-Identifier: GPL-2.0-only */ /* * OMAP54xx PRM instance offset macros * * Copyright (C) 2013 Texas Instruments Incorporated - https://www.ti.com * * Paul Walmsley (paul@pwsan.com) * Rajendra Nayak (rnayak@ti.com) * Benoit Cousson (b-cousson@ti.com) * * This file is automatically generated from the OMAP hardware databases. * We respectfully ask that any modifications to this file be coordinated * with the public linux-omap@vger.kernel.org mailing list and the * authors above to ensure that the autogeneration scripts are kept * up-to-date with the file contents. */ #ifndef __ARCH_ARM_MACH_OMAP2_PRM54XX_H #define __ARCH_ARM_MACH_OMAP2_PRM54XX_H #include "prm44xx_54xx.h" #include "prm.h" #define OMAP54XX_PRM_BASE 0x4ae06000 #define OMAP54XX_PRM_REGADDR(inst, reg) \ OMAP2_L4_IO_ADDRESS(OMAP54XX_PRM_BASE + (inst) + (reg)) /* PRM instances */ #define OMAP54XX_PRM_OCP_SOCKET_INST 0x0000 #define OMAP54XX_PRM_CKGEN_INST 0x0100 #define OMAP54XX_PRM_MPU_INST 0x0300 #define OMAP54XX_PRM_DSP_INST 0x0400 #define OMAP54XX_PRM_ABE_INST 0x0500 #define OMAP54XX_PRM_COREAON_INST 0x0600 #define OMAP54XX_PRM_CORE_INST 0x0700 #define OMAP54XX_PRM_IVA_INST 0x1200 #define OMAP54XX_PRM_CAM_INST 0x1300 #define OMAP54XX_PRM_DSS_INST 0x1400 #define OMAP54XX_PRM_GPU_INST 0x1500 #define OMAP54XX_PRM_L3INIT_INST 0x1600 #define OMAP54XX_PRM_CUSTEFUSE_INST 0x1700 #define OMAP54XX_PRM_WKUPAON_INST 0x1800 #define OMAP54XX_PRM_WKUPAON_CM_INST 0x1900 #define OMAP54XX_PRM_EMU_INST 0x1a00 #define OMAP54XX_PRM_EMU_CM_INST 0x1b00 #define OMAP54XX_PRM_DEVICE_INST 0x1c00 #define OMAP54XX_PRM_INSTR_INST 0x1f00 /* PRM clockdomain register offsets (from instance start) */ #define OMAP54XX_PRM_WKUPAON_CM_WKUPAON_CDOFFS 0x0000 #define OMAP54XX_PRM_EMU_CM_EMU_CDOFFS 0x0000 /* PRM */ /* PRM.OCP_SOCKET_PRM register offsets */ #define OMAP54XX_REVISION_PRM_OFFSET 0x0000 #define OMAP54XX_PRM_IRQSTATUS_MPU_OFFSET 0x0010 #define OMAP54XX_PRM_IRQSTATUS_MPU_2_OFFSET 0x0014 #define OMAP54XX_PRM_IRQENABLE_MPU_OFFSET 0x0018 #define OMAP54XX_PRM_IRQENABLE_MPU_2_OFFSET 0x001c #define OMAP54XX_PRM_IRQSTATUS_IPU_OFFSET 0x0020 #define OMAP54XX_PRM_IRQENABLE_IPU_OFFSET 0x0028 #define OMAP54XX_PRM_IRQSTATUS_DSP_OFFSET 0x0030 #define OMAP54XX_PRM_IRQENABLE_DSP_OFFSET 0x0038 #define OMAP54XX_CM_PRM_PROFILING_CLKCTRL_OFFSET 0x0040 #define OMAP54XX_CM_PRM_PROFILING_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_OCP_SOCKET_INST, 0x0040) #define OMAP54XX_PRM_DEBUG_OUT_OFFSET 0x0084 #define OMAP54XX_PRM_DEBUG_TRANS_CFG_OFFSET 0x0090 #define OMAP54XX_PRM_DEBUG_OFF_TRANS_OFFSET 0x0094 #define OMAP54XX_PRM_DEBUG_CORE_RET_TRANS_OFFSET 0x0098 #define OMAP54XX_PRM_DEBUG_MPU_RET_TRANS_OFFSET 0x009c #define OMAP54XX_PRM_DEBUG_MM_RET_TRANS_OFFSET 0x00a0 #define OMAP54XX_PRM_DEBUG_WKUPAON_FD_TRANS_OFFSET 0x00a4 /* PRM.CKGEN_PRM register offsets */ #define OMAP54XX_CM_CLKSEL_ABE_DSS_SYS_OFFSET 0x0000 #define OMAP54XX_CM_CLKSEL_ABE_DSS_SYS OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_CKGEN_INST, 0x0000) #define OMAP54XX_CM_CLKSEL_WKUPAON_OFFSET 0x0008 #define OMAP54XX_CM_CLKSEL_WKUPAON OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_CKGEN_INST, 0x0008) #define OMAP54XX_CM_CLKSEL_ABE_PLL_REF_OFFSET 0x000c #define OMAP54XX_CM_CLKSEL_ABE_PLL_REF OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_CKGEN_INST, 0x000c) #define OMAP54XX_CM_CLKSEL_SYS_OFFSET 0x0010 #define OMAP54XX_CM_CLKSEL_SYS OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_CKGEN_INST, 0x0010) /* PRM.MPU_PRM register offsets */ #define OMAP54XX_PM_MPU_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_MPU_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_MPU_MPU_CONTEXT_OFFSET 0x0024 /* PRM.DSP_PRM register offsets */ #define OMAP54XX_PM_DSP_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_DSP_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_DSP_RSTCTRL_OFFSET 0x0010 #define OMAP54XX_RM_DSP_RSTST_OFFSET 0x0014 #define OMAP54XX_RM_DSP_DSP_CONTEXT_OFFSET 0x0024 /* PRM.ABE_PRM register offsets */ #define OMAP54XX_PM_ABE_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_ABE_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_ABE_AESS_CONTEXT_OFFSET 0x002c #define OMAP54XX_PM_ABE_MCPDM_WKDEP_OFFSET 0x0030 #define OMAP54XX_RM_ABE_MCPDM_CONTEXT_OFFSET 0x0034 #define OMAP54XX_PM_ABE_DMIC_WKDEP_OFFSET 0x0038 #define OMAP54XX_RM_ABE_DMIC_CONTEXT_OFFSET 0x003c #define OMAP54XX_PM_ABE_MCASP_WKDEP_OFFSET 0x0040 #define OMAP54XX_RM_ABE_MCASP_CONTEXT_OFFSET 0x0044 #define OMAP54XX_PM_ABE_MCBSP1_WKDEP_OFFSET 0x0048 #define OMAP54XX_RM_ABE_MCBSP1_CONTEXT_OFFSET 0x004c #define OMAP54XX_PM_ABE_MCBSP2_WKDEP_OFFSET 0x0050 #define OMAP54XX_RM_ABE_MCBSP2_CONTEXT_OFFSET 0x0054 #define OMAP54XX_PM_ABE_MCBSP3_WKDEP_OFFSET 0x0058 #define OMAP54XX_RM_ABE_MCBSP3_CONTEXT_OFFSET 0x005c #define OMAP54XX_PM_ABE_SLIMBUS1_WKDEP_OFFSET 0x0060 #define OMAP54XX_RM_ABE_SLIMBUS1_CONTEXT_OFFSET 0x0064 #define OMAP54XX_PM_ABE_TIMER5_WKDEP_OFFSET 0x0068 #define OMAP54XX_RM_ABE_TIMER5_CONTEXT_OFFSET 0x006c #define OMAP54XX_PM_ABE_TIMER6_WKDEP_OFFSET 0x0070 #define OMAP54XX_RM_ABE_TIMER6_CONTEXT_OFFSET 0x0074 #define OMAP54XX_PM_ABE_TIMER7_WKDEP_OFFSET 0x0078 #define OMAP54XX_RM_ABE_TIMER7_CONTEXT_OFFSET 0x007c #define OMAP54XX_PM_ABE_TIMER8_WKDEP_OFFSET 0x0080 #define OMAP54XX_RM_ABE_TIMER8_CONTEXT_OFFSET 0x0084 #define OMAP54XX_PM_ABE_WD_TIMER3_WKDEP_OFFSET 0x0088 #define OMAP54XX_RM_ABE_WD_TIMER3_CONTEXT_OFFSET 0x008c /* PRM.COREAON_PRM register offsets */ #define OMAP54XX_PM_COREAON_SMARTREFLEX_MPU_WKDEP_OFFSET 0x0028 #define OMAP54XX_RM_COREAON_SMARTREFLEX_MPU_CONTEXT_OFFSET 0x002c #define OMAP54XX_PM_COREAON_SMARTREFLEX_MM_WKDEP_OFFSET 0x0030 #define OMAP54XX_RM_COREAON_SMARTREFLEX_MM_CONTEXT_OFFSET 0x0034 #define OMAP54XX_PM_COREAON_SMARTREFLEX_CORE_WKDEP_OFFSET 0x0038 #define OMAP54XX_RM_COREAON_SMARTREFLEX_CORE_CONTEXT_OFFSET 0x003c /* PRM.CORE_PRM register offsets */ #define OMAP54XX_PM_CORE_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_CORE_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_L3MAIN1_L3_MAIN_1_CONTEXT_OFFSET 0x0024 #define OMAP54XX_RM_L3MAIN2_L3_MAIN_2_CONTEXT_OFFSET 0x0124 #define OMAP54XX_RM_L3MAIN2_GPMC_CONTEXT_OFFSET 0x012c #define OMAP54XX_RM_L3MAIN2_OCMC_RAM_CONTEXT_OFFSET 0x0134 #define OMAP54XX_RM_IPU_RSTCTRL_OFFSET 0x0210 #define OMAP54XX_RM_IPU_RSTST_OFFSET 0x0214 #define OMAP54XX_RM_IPU_IPU_CONTEXT_OFFSET 0x0224 #define OMAP54XX_RM_DMA_DMA_SYSTEM_CONTEXT_OFFSET 0x0324 #define OMAP54XX_RM_EMIF_DMM_CONTEXT_OFFSET 0x0424 #define OMAP54XX_RM_EMIF_EMIF_OCP_FW_CONTEXT_OFFSET 0x042c #define OMAP54XX_RM_EMIF_EMIF1_CONTEXT_OFFSET 0x0434 #define OMAP54XX_RM_EMIF_EMIF2_CONTEXT_OFFSET 0x043c #define OMAP54XX_RM_EMIF_EMIF_DLL_CONTEXT_OFFSET 0x0444 #define OMAP54XX_RM_C2C_C2C_CONTEXT_OFFSET 0x0524 #define OMAP54XX_RM_C2C_MODEM_ICR_CONTEXT_OFFSET 0x052c #define OMAP54XX_RM_C2C_C2C_OCP_FW_CONTEXT_OFFSET 0x0534 #define OMAP54XX_RM_L4CFG_L4_CFG_CONTEXT_OFFSET 0x0624 #define OMAP54XX_RM_L4CFG_SPINLOCK_CONTEXT_OFFSET 0x062c #define OMAP54XX_RM_L4CFG_MAILBOX_CONTEXT_OFFSET 0x0634 #define OMAP54XX_RM_L4CFG_SAR_ROM_CONTEXT_OFFSET 0x063c #define OMAP54XX_RM_L4CFG_OCP2SCP2_CONTEXT_OFFSET 0x0644 #define OMAP54XX_RM_L3INSTR_L3_MAIN_3_CONTEXT_OFFSET 0x0724 #define OMAP54XX_RM_L3INSTR_L3_INSTR_CONTEXT_OFFSET 0x072c #define OMAP54XX_RM_L3INSTR_OCP_WP_NOC_CONTEXT_OFFSET 0x0744 #define OMAP54XX_RM_MIPIEXT_LLI_CONTEXT_OFFSET 0x0824 #define OMAP54XX_RM_MIPIEXT_LLI_OCP_FW_CONTEXT_OFFSET 0x082c #define OMAP54XX_RM_MIPIEXT_MPHY_CONTEXT_OFFSET 0x0834 #define OMAP54XX_PM_L4PER_TIMER10_WKDEP_OFFSET 0x0928 #define OMAP54XX_RM_L4PER_TIMER10_CONTEXT_OFFSET 0x092c #define OMAP54XX_PM_L4PER_TIMER11_WKDEP_OFFSET 0x0930 #define OMAP54XX_RM_L4PER_TIMER11_CONTEXT_OFFSET 0x0934 #define OMAP54XX_PM_L4PER_TIMER2_WKDEP_OFFSET 0x0938 #define OMAP54XX_RM_L4PER_TIMER2_CONTEXT_OFFSET 0x093c #define OMAP54XX_PM_L4PER_TIMER3_WKDEP_OFFSET 0x0940 #define OMAP54XX_RM_L4PER_TIMER3_CONTEXT_OFFSET 0x0944 #define OMAP54XX_PM_L4PER_TIMER4_WKDEP_OFFSET 0x0948 #define OMAP54XX_RM_L4PER_TIMER4_CONTEXT_OFFSET 0x094c #define OMAP54XX_PM_L4PER_TIMER9_WKDEP_OFFSET 0x0950 #define OMAP54XX_RM_L4PER_TIMER9_CONTEXT_OFFSET 0x0954 #define OMAP54XX_RM_L4PER_ELM_CONTEXT_OFFSET 0x095c #define OMAP54XX_PM_L4PER_GPIO2_WKDEP_OFFSET 0x0960 #define OMAP54XX_RM_L4PER_GPIO2_CONTEXT_OFFSET 0x0964 #define OMAP54XX_PM_L4PER_GPIO3_WKDEP_OFFSET 0x0968 #define OMAP54XX_RM_L4PER_GPIO3_CONTEXT_OFFSET 0x096c #define OMAP54XX_PM_L4PER_GPIO4_WKDEP_OFFSET 0x0970 #define OMAP54XX_RM_L4PER_GPIO4_CONTEXT_OFFSET 0x0974 #define OMAP54XX_PM_L4PER_GPIO5_WKDEP_OFFSET 0x0978 #define OMAP54XX_RM_L4PER_GPIO5_CONTEXT_OFFSET 0x097c #define OMAP54XX_PM_L4PER_GPIO6_WKDEP_OFFSET 0x0980 #define OMAP54XX_RM_L4PER_GPIO6_CONTEXT_OFFSET 0x0984 #define OMAP54XX_RM_L4PER_HDQ1W_CONTEXT_OFFSET 0x098c #define OMAP54XX_PM_L4PER_I2C1_WKDEP_OFFSET 0x09a0 #define OMAP54XX_RM_L4PER_I2C1_CONTEXT_OFFSET 0x09a4 #define OMAP54XX_PM_L4PER_I2C2_WKDEP_OFFSET 0x09a8 #define OMAP54XX_RM_L4PER_I2C2_CONTEXT_OFFSET 0x09ac #define OMAP54XX_PM_L4PER_I2C3_WKDEP_OFFSET 0x09b0 #define OMAP54XX_RM_L4PER_I2C3_CONTEXT_OFFSET 0x09b4 #define OMAP54XX_PM_L4PER_I2C4_WKDEP_OFFSET 0x09b8 #define OMAP54XX_RM_L4PER_I2C4_CONTEXT_OFFSET 0x09bc #define OMAP54XX_RM_L4PER_L4_PER_CONTEXT_OFFSET 0x09c0 #define OMAP54XX_PM_L4PER_MCSPI1_WKDEP_OFFSET 0x09f0 #define OMAP54XX_RM_L4PER_MCSPI1_CONTEXT_OFFSET 0x09f4 #define OMAP54XX_PM_L4PER_MCSPI2_WKDEP_OFFSET 0x09f8 #define OMAP54XX_RM_L4PER_MCSPI2_CONTEXT_OFFSET 0x09fc #define OMAP54XX_PM_L4PER_MCSPI3_WKDEP_OFFSET 0x0a00 #define OMAP54XX_RM_L4PER_MCSPI3_CONTEXT_OFFSET 0x0a04 #define OMAP54XX_PM_L4PER_MCSPI4_WKDEP_OFFSET 0x0a08 #define OMAP54XX_RM_L4PER_MCSPI4_CONTEXT_OFFSET 0x0a0c #define OMAP54XX_PM_L4PER_GPIO7_WKDEP_OFFSET 0x0a10 #define OMAP54XX_RM_L4PER_GPIO7_CONTEXT_OFFSET 0x0a14 #define OMAP54XX_PM_L4PER_GPIO8_WKDEP_OFFSET 0x0a18 #define OMAP54XX_RM_L4PER_GPIO8_CONTEXT_OFFSET 0x0a1c #define OMAP54XX_PM_L4PER_MMC3_WKDEP_OFFSET 0x0a20 #define OMAP54XX_RM_L4PER_MMC3_CONTEXT_OFFSET 0x0a24 #define OMAP54XX_PM_L4PER_MMC4_WKDEP_OFFSET 0x0a28 #define OMAP54XX_RM_L4PER_MMC4_CONTEXT_OFFSET 0x0a2c #define OMAP54XX_PM_L4PER_UART1_WKDEP_OFFSET 0x0a40 #define OMAP54XX_RM_L4PER_UART1_CONTEXT_OFFSET 0x0a44 #define OMAP54XX_PM_L4PER_UART2_WKDEP_OFFSET 0x0a48 #define OMAP54XX_RM_L4PER_UART2_CONTEXT_OFFSET 0x0a4c #define OMAP54XX_PM_L4PER_UART3_WKDEP_OFFSET 0x0a50 #define OMAP54XX_RM_L4PER_UART3_CONTEXT_OFFSET 0x0a54 #define OMAP54XX_RM_L4PER_UART4_CONTEXT_OFFSET 0x0a58 #define OMAP54XX_PM_L4PER_UART4_WKDEP_OFFSET 0x0a5c #define OMAP54XX_PM_L4PER_MMC5_WKDEP_OFFSET 0x0a60 #define OMAP54XX_RM_L4PER_MMC5_CONTEXT_OFFSET 0x0a64 #define OMAP54XX_PM_L4PER_I2C5_WKDEP_OFFSET 0x0a68 #define OMAP54XX_RM_L4PER_I2C5_CONTEXT_OFFSET 0x0a6c #define OMAP54XX_PM_L4PER_UART5_WKDEP_OFFSET 0x0a70 #define OMAP54XX_RM_L4PER_UART5_CONTEXT_OFFSET 0x0a74 #define OMAP54XX_PM_L4PER_UART6_WKDEP_OFFSET 0x0a78 #define OMAP54XX_RM_L4PER_UART6_CONTEXT_OFFSET 0x0a7c #define OMAP54XX_RM_L4SEC_AES1_CONTEXT_OFFSET 0x0aa4 #define OMAP54XX_RM_L4SEC_AES2_CONTEXT_OFFSET 0x0aac #define OMAP54XX_RM_L4SEC_DES3DES_CONTEXT_OFFSET 0x0ab4 #define OMAP54XX_RM_L4SEC_FPKA_CONTEXT_OFFSET 0x0abc #define OMAP54XX_RM_L4SEC_RNG_CONTEXT_OFFSET 0x0ac4 #define OMAP54XX_RM_L4SEC_SHA2MD5_CONTEXT_OFFSET 0x0acc #define OMAP54XX_RM_L4SEC_DMA_CRYPTO_CONTEXT_OFFSET 0x0adc /* PRM.IVA_PRM register offsets */ #define OMAP54XX_PM_IVA_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_IVA_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_IVA_RSTCTRL_OFFSET 0x0010 #define OMAP54XX_RM_IVA_RSTST_OFFSET 0x0014 #define OMAP54XX_RM_IVA_IVA_CONTEXT_OFFSET 0x0024 #define OMAP54XX_RM_IVA_SL2_CONTEXT_OFFSET 0x002c /* PRM.CAM_PRM register offsets */ #define OMAP54XX_PM_CAM_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_CAM_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_CAM_ISS_CONTEXT_OFFSET 0x0024 #define OMAP54XX_RM_CAM_FDIF_CONTEXT_OFFSET 0x002c #define OMAP54XX_RM_CAM_CAL_CONTEXT_OFFSET 0x0034 /* PRM.DSS_PRM register offsets */ #define OMAP54XX_PM_DSS_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_DSS_PWRSTST_OFFSET 0x0004 #define OMAP54XX_PM_DSS_DSS_WKDEP_OFFSET 0x0020 #define OMAP54XX_RM_DSS_DSS_CONTEXT_OFFSET 0x0024 #define OMAP54XX_RM_DSS_BB2D_CONTEXT_OFFSET 0x0034 /* PRM.GPU_PRM register offsets */ #define OMAP54XX_PM_GPU_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_GPU_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_GPU_GPU_CONTEXT_OFFSET 0x0024 /* PRM.L3INIT_PRM register offsets */ #define OMAP54XX_PM_L3INIT_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_L3INIT_PWRSTST_OFFSET 0x0004 #define OMAP54XX_PM_L3INIT_MMC1_WKDEP_OFFSET 0x0028 #define OMAP54XX_RM_L3INIT_MMC1_CONTEXT_OFFSET 0x002c #define OMAP54XX_PM_L3INIT_MMC2_WKDEP_OFFSET 0x0030 #define OMAP54XX_RM_L3INIT_MMC2_CONTEXT_OFFSET 0x0034 #define OMAP54XX_PM_L3INIT_HSI_WKDEP_OFFSET 0x0038 #define OMAP54XX_RM_L3INIT_HSI_CONTEXT_OFFSET 0x003c #define OMAP54XX_PM_L3INIT_UNIPRO2_WKDEP_OFFSET 0x0040 #define OMAP54XX_RM_L3INIT_UNIPRO2_CONTEXT_OFFSET 0x0044 #define OMAP54XX_PM_L3INIT_USB_HOST_HS_WKDEP_OFFSET 0x0058 #define OMAP54XX_RM_L3INIT_USB_HOST_HS_CONTEXT_OFFSET 0x005c #define OMAP54XX_PM_L3INIT_USB_TLL_HS_WKDEP_OFFSET 0x0068 #define OMAP54XX_RM_L3INIT_USB_TLL_HS_CONTEXT_OFFSET 0x006c #define OMAP54XX_RM_L3INIT_IEEE1500_2_OCP_CONTEXT_OFFSET 0x007c #define OMAP54XX_PM_L3INIT_SATA_WKDEP_OFFSET 0x0088 #define OMAP54XX_RM_L3INIT_SATA_CONTEXT_OFFSET 0x008c #define OMAP54XX_RM_L3INIT_OCP2SCP1_CONTEXT_OFFSET 0x00e4 #define OMAP54XX_RM_L3INIT_OCP2SCP3_CONTEXT_OFFSET 0x00ec #define OMAP54XX_PM_L3INIT_USB_OTG_SS_WKDEP_OFFSET 0x00f0 #define OMAP54XX_RM_L3INIT_USB_OTG_SS_CONTEXT_OFFSET 0x00f4 /* PRM.CUSTEFUSE_PRM register offsets */ #define OMAP54XX_PM_CUSTEFUSE_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_CUSTEFUSE_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_CUSTEFUSE_EFUSE_CTRL_CUST_CONTEXT_OFFSET 0x0024 /* PRM.WKUPAON_PRM register offsets */ #define OMAP54XX_RM_WKUPAON_L4_WKUP_CONTEXT_OFFSET 0x0024 #define OMAP54XX_RM_WKUPAON_WD_TIMER1_CONTEXT_OFFSET 0x002c #define OMAP54XX_PM_WKUPAON_WD_TIMER2_WKDEP_OFFSET 0x0030 #define OMAP54XX_RM_WKUPAON_WD_TIMER2_CONTEXT_OFFSET 0x0034 #define OMAP54XX_PM_WKUPAON_GPIO1_WKDEP_OFFSET 0x0038 #define OMAP54XX_RM_WKUPAON_GPIO1_CONTEXT_OFFSET 0x003c #define OMAP54XX_PM_WKUPAON_TIMER1_WKDEP_OFFSET 0x0040 #define OMAP54XX_RM_WKUPAON_TIMER1_CONTEXT_OFFSET 0x0044 #define OMAP54XX_PM_WKUPAON_TIMER12_WKDEP_OFFSET 0x0048 #define OMAP54XX_RM_WKUPAON_TIMER12_CONTEXT_OFFSET 0x004c #define OMAP54XX_RM_WKUPAON_COUNTER_32K_CONTEXT_OFFSET 0x0054 #define OMAP54XX_RM_WKUPAON_SAR_RAM_CONTEXT_OFFSET 0x0064 #define OMAP54XX_PM_WKUPAON_KBD_WKDEP_OFFSET 0x0078 #define OMAP54XX_RM_WKUPAON_KBD_CONTEXT_OFFSET 0x007c /* PRM.WKUPAON_CM register offsets */ #define OMAP54XX_CM_WKUPAON_CLKSTCTRL_OFFSET 0x0000 #define OMAP54XX_CM_WKUPAON_L4_WKUP_CLKCTRL_OFFSET 0x0020 #define OMAP54XX_CM_WKUPAON_L4_WKUP_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0020) #define OMAP54XX_CM_WKUPAON_WD_TIMER1_CLKCTRL_OFFSET 0x0028 #define OMAP54XX_CM_WKUPAON_WD_TIMER1_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0028) #define OMAP54XX_CM_WKUPAON_WD_TIMER2_CLKCTRL_OFFSET 0x0030 #define OMAP54XX_CM_WKUPAON_WD_TIMER2_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0030) #define OMAP54XX_CM_WKUPAON_GPIO1_CLKCTRL_OFFSET 0x0038 #define OMAP54XX_CM_WKUPAON_GPIO1_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0038) #define OMAP54XX_CM_WKUPAON_TIMER1_CLKCTRL_OFFSET 0x0040 #define OMAP54XX_CM_WKUPAON_TIMER1_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0040) #define OMAP54XX_CM_WKUPAON_TIMER12_CLKCTRL_OFFSET 0x0048 #define OMAP54XX_CM_WKUPAON_TIMER12_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0048) #define OMAP54XX_CM_WKUPAON_COUNTER_32K_CLKCTRL_OFFSET 0x0050 #define OMAP54XX_CM_WKUPAON_COUNTER_32K_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0050) #define OMAP54XX_CM_WKUPAON_SAR_RAM_CLKCTRL_OFFSET 0x0060 #define OMAP54XX_CM_WKUPAON_SAR_RAM_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0060) #define OMAP54XX_CM_WKUPAON_KBD_CLKCTRL_OFFSET 0x0078 #define OMAP54XX_CM_WKUPAON_KBD_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0078) #define OMAP54XX_CM_WKUPAON_SCRM_CLKCTRL_OFFSET 0x0090 #define OMAP54XX_CM_WKUPAON_SCRM_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0090) #define OMAP54XX_CM_WKUPAON_IO_SRCOMP_CLKCTRL_OFFSET 0x0098 #define OMAP54XX_CM_WKUPAON_IO_SRCOMP_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_WKUPAON_CM_INST, 0x0098) /* PRM.EMU_PRM register offsets */ #define OMAP54XX_PM_EMU_PWRSTCTRL_OFFSET 0x0000 #define OMAP54XX_PM_EMU_PWRSTST_OFFSET 0x0004 #define OMAP54XX_RM_EMU_DEBUGSS_CONTEXT_OFFSET 0x0024 /* PRM.EMU_CM register offsets */ #define OMAP54XX_CM_EMU_CLKSTCTRL_OFFSET 0x0000 #define OMAP54XX_CM_EMU_DYNAMICDEP_OFFSET 0x0008 #define OMAP54XX_CM_EMU_DEBUGSS_CLKCTRL_OFFSET 0x0020 #define OMAP54XX_CM_EMU_DEBUGSS_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_EMU_CM_INST, 0x0020) #define OMAP54XX_CM_EMU_MPU_EMU_DBG_CLKCTRL_OFFSET 0x0028 #define OMAP54XX_CM_EMU_MPU_EMU_DBG_CLKCTRL OMAP54XX_PRM_REGADDR(OMAP54XX_PRM_EMU_CM_INST, 0x0028) /* PRM.DEVICE_PRM register offsets */ #define OMAP54XX_PRM_RSTCTRL_OFFSET 0x0000 #define OMAP54XX_PRM_RSTST_OFFSET 0x0004 #define OMAP54XX_PRM_RSTTIME_OFFSET 0x0008 #define OMAP54XX_PRM_CLKREQCTRL_OFFSET 0x000c #define OMAP54XX_PRM_VOLTCTRL_OFFSET 0x0010 #define OMAP54XX_PRM_PWRREQCTRL_OFFSET 0x0014 #define OMAP54XX_PRM_PSCON_COUNT_OFFSET 0x0018 #define OMAP54XX_PRM_IO_COUNT_OFFSET 0x001c #define OMAP54XX_PRM_IO_PMCTRL_OFFSET 0x0020 #define OMAP54XX_PRM_VOLTSETUP_WARMRESET_OFFSET 0x0024 #define OMAP54XX_PRM_VOLTSETUP_CORE_OFF_OFFSET 0x0028 #define OMAP54XX_PRM_VOLTSETUP_MPU_OFF_OFFSET 0x002c #define OMAP54XX_PRM_VOLTSETUP_MM_OFF_OFFSET 0x0030 #define OMAP54XX_PRM_VOLTSETUP_CORE_RET_SLEEP_OFFSET 0x0034 #define OMAP54XX_PRM_VOLTSETUP_MPU_RET_SLEEP_OFFSET 0x0038 #define OMAP54XX_PRM_VOLTSETUP_MM_RET_SLEEP_OFFSET 0x003c #define OMAP54XX_PRM_VP_CORE_CONFIG_OFFSET 0x0040 #define OMAP54XX_PRM_VP_CORE_STATUS_OFFSET 0x0044 #define OMAP54XX_PRM_VP_CORE_VLIMITTO_OFFSET 0x0048 #define OMAP54XX_PRM_VP_CORE_VOLTAGE_OFFSET 0x004c #define OMAP54XX_PRM_VP_CORE_VSTEPMAX_OFFSET 0x0050 #define OMAP54XX_PRM_VP_CORE_VSTEPMIN_OFFSET 0x0054 #define OMAP54XX_PRM_VP_MPU_CONFIG_OFFSET 0x0058 #define OMAP54XX_PRM_VP_MPU_STATUS_OFFSET 0x005c #define OMAP54XX_PRM_VP_MPU_VLIMITTO_OFFSET 0x0060 #define OMAP54XX_PRM_VP_MPU_VOLTAGE_OFFSET 0x0064 #define OMAP54XX_PRM_VP_MPU_VSTEPMAX_OFFSET 0x0068 #define OMAP54XX_PRM_VP_MPU_VSTEPMIN_OFFSET 0x006c #define OMAP54XX_PRM_VP_MM_CONFIG_OFFSET 0x0070 #define OMAP54XX_PRM_VP_MM_STATUS_OFFSET 0x0074 #define OMAP54XX_PRM_VP_MM_VLIMITTO_OFFSET 0x0078 #define OMAP54XX_PRM_VP_MM_VOLTAGE_OFFSET 0x007c #define OMAP54XX_PRM_VP_MM_VSTEPMAX_OFFSET 0x0080 #define OMAP54XX_PRM_VP_MM_VSTEPMIN_OFFSET 0x0084 #define OMAP54XX_PRM_VC_SMPS_CORE_CONFIG_OFFSET 0x0088 #define OMAP54XX_PRM_VC_SMPS_MM_CONFIG_OFFSET 0x008c #define OMAP54XX_PRM_VC_SMPS_MPU_CONFIG_OFFSET 0x0090 #define OMAP54XX_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET 0x0094 #define OMAP54XX_PRM_VC_VAL_CMD_VDD_MM_L_OFFSET 0x0098 #define OMAP54XX_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET 0x009c #define OMAP54XX_PRM_VC_VAL_BYPASS_OFFSET 0x00a0 #define OMAP54XX_PRM_VC_CORE_ERRST_OFFSET 0x00a4 #define OMAP54XX_PRM_VC_MM_ERRST_OFFSET 0x00a8 #define OMAP54XX_PRM_VC_MPU_ERRST_OFFSET 0x00ac #define OMAP54XX_PRM_VC_BYPASS_ERRST_OFFSET 0x00b0 #define OMAP54XX_PRM_VC_CFG_I2C_MODE_OFFSET 0x00b4 #define OMAP54XX_PRM_VC_CFG_I2C_CLK_OFFSET 0x00b8 #define OMAP54XX_PRM_SRAM_COUNT_OFFSET 0x00bc #define OMAP54XX_PRM_SRAM_WKUP_SETUP_OFFSET 0x00c0 #define OMAP54XX_PRM_SLDO_CORE_SETUP_OFFSET 0x00c4 #define OMAP54XX_PRM_SLDO_CORE_CTRL_OFFSET 0x00c8 #define OMAP54XX_PRM_SLDO_MPU_SETUP_OFFSET 0x00cc #define OMAP54XX_PRM_SLDO_MPU_CTRL_OFFSET 0x00d0 #define OMAP54XX_PRM_SLDO_MM_SETUP_OFFSET 0x00d4 #define OMAP54XX_PRM_SLDO_MM_CTRL_OFFSET 0x00d8 #define OMAP54XX_PRM_ABBLDO_MPU_SETUP_OFFSET 0x00dc #define OMAP54XX_PRM_ABBLDO_MPU_CTRL_OFFSET 0x00e0 #define OMAP54XX_PRM_ABBLDO_MM_SETUP_OFFSET 0x00e4 #define OMAP54XX_PRM_ABBLDO_MM_CTRL_OFFSET 0x00e8 #define OMAP54XX_PRM_BANDGAP_SETUP_OFFSET 0x00ec #define OMAP54XX_PRM_DEVICE_OFF_CTRL_OFFSET 0x00f0 #define OMAP54XX_PRM_PHASE1_CNDP_OFFSET 0x00f4 #define OMAP54XX_PRM_PHASE2A_CNDP_OFFSET 0x00f8 #define OMAP54XX_PRM_PHASE2B_CNDP_OFFSET 0x00fc #define OMAP54XX_PRM_MODEM_IF_CTRL_OFFSET 0x0100 #define OMAP54XX_PRM_VOLTST_MPU_OFFSET 0x0110 #define OMAP54XX_PRM_VOLTST_MM_OFFSET 0x0114 #endif
/* * fs/f2fs/inode.c * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * http://www.samsung.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/fs.h> #include <linux/f2fs_fs.h> #include <linux/buffer_head.h> #include <linux/writeback.h> #include <linux/bitops.h> #include "f2fs.h" #include "node.h" #include <trace/events/f2fs.h> void f2fs_set_inode_flags(struct inode *inode) { unsigned int flags = F2FS_I(inode)->i_flags; unsigned int new_fl = 0; if (flags & FS_SYNC_FL) new_fl |= S_SYNC; if (flags & FS_APPEND_FL) new_fl |= S_APPEND; if (flags & FS_IMMUTABLE_FL) new_fl |= S_IMMUTABLE; if (flags & FS_NOATIME_FL) new_fl |= S_NOATIME; if (flags & FS_DIRSYNC_FL) new_fl |= S_DIRSYNC; set_mask_bits(&inode->i_flags, S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC, new_fl); } static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri) { if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { if (ri->i_addr[0]) inode->i_rdev = old_decode_dev(le32_to_cpu(ri->i_addr[0])); else inode->i_rdev = new_decode_dev(le32_to_cpu(ri->i_addr[1])); } } static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri) { if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { if (old_valid_dev(inode->i_rdev)) { ri->i_addr[0] = cpu_to_le32(old_encode_dev(inode->i_rdev)); ri->i_addr[1] = 0; } else { ri->i_addr[0] = 0; ri->i_addr[1] = cpu_to_le32(new_encode_dev(inode->i_rdev)); ri->i_addr[2] = 0; } } } static void __recover_inline_status(struct inode *inode, struct page *ipage) { void *inline_data = inline_data_addr(ipage); __le32 *start = inline_data; __le32 *end = start + MAX_INLINE_DATA / sizeof(__le32); while (start < end) { if (*start++) { f2fs_wait_on_page_writeback(ipage, NODE); set_inode_flag(F2FS_I(inode), FI_DATA_EXIST); set_raw_inline(F2FS_I(inode), F2FS_INODE(ipage)); set_page_dirty(ipage); return; } } return; } static int do_read_inode(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_inode_info *fi = F2FS_I(inode); struct page *node_page; struct f2fs_inode *ri; /* Check if ino is within scope */ if (check_nid_range(sbi, inode->i_ino)) { f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu", (unsigned long) inode->i_ino); WARN_ON(1); return -EINVAL; } node_page = get_node_page(sbi, inode->i_ino); if (IS_ERR(node_page)) return PTR_ERR(node_page); ri = F2FS_INODE(node_page); inode->i_mode = le16_to_cpu(ri->i_mode); i_uid_write(inode, le32_to_cpu(ri->i_uid)); i_gid_write(inode, le32_to_cpu(ri->i_gid)); set_nlink(inode, le32_to_cpu(ri->i_links)); inode->i_size = le64_to_cpu(ri->i_size); inode->i_blocks = le64_to_cpu(ri->i_blocks); inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime); inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime); inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime); inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec); inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec); inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec); inode->i_generation = le32_to_cpu(ri->i_generation); fi->i_current_depth = le32_to_cpu(ri->i_current_depth); fi->i_xattr_nid = le32_to_cpu(ri->i_xattr_nid); fi->i_flags = le32_to_cpu(ri->i_flags); fi->flags = 0; fi->i_advise = ri->i_advise; fi->i_pino = le32_to_cpu(ri->i_pino); fi->i_dir_level = ri->i_dir_level; get_extent_info(&fi->ext, ri->i_ext); get_inline_info(fi, ri); /* check data exist */ if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) __recover_inline_status(inode, node_page); /* get rdev by using inline_info */ __get_inode_rdev(inode, ri); f2fs_put_page(node_page, 1); stat_inc_inline_inode(inode); stat_inc_inline_dir(inode); return 0; } struct inode *f2fs_iget(struct super_block *sb, unsigned long ino) { struct f2fs_sb_info *sbi = F2FS_SB(sb); struct inode *inode; int ret = 0; inode = iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) { trace_f2fs_iget(inode); return inode; } if (ino == F2FS_NODE_INO(sbi) || ino == F2FS_META_INO(sbi)) goto make_now; ret = do_read_inode(inode); if (ret) goto bad_inode; make_now: if (ino == F2FS_NODE_INO(sbi)) { inode->i_mapping->a_ops = &f2fs_node_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO); } else if (ino == F2FS_META_INO(sbi)) { inode->i_mapping->a_ops = &f2fs_meta_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO); } else if (S_ISREG(inode->i_mode)) { inode->i_op = &f2fs_file_inode_operations; inode->i_fop = &f2fs_file_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &f2fs_dir_inode_operations; inode->i_fop = &f2fs_dir_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_HIGH_ZERO); } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &f2fs_symlink_inode_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { inode->i_op = &f2fs_special_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); } else { ret = -EIO; goto bad_inode; } unlock_new_inode(inode); trace_f2fs_iget(inode); return inode; bad_inode: iget_failed(inode); trace_f2fs_iget_exit(inode, ret); return ERR_PTR(ret); } void update_inode(struct inode *inode, struct page *node_page) { struct f2fs_inode *ri; f2fs_wait_on_page_writeback(node_page, NODE); ri = F2FS_INODE(node_page); ri->i_mode = cpu_to_le16(inode->i_mode); ri->i_advise = F2FS_I(inode)->i_advise; ri->i_uid = cpu_to_le32(i_uid_read(inode)); ri->i_gid = cpu_to_le32(i_gid_read(inode)); ri->i_links = cpu_to_le32(inode->i_nlink); ri->i_size = cpu_to_le64(i_size_read(inode)); ri->i_blocks = cpu_to_le64(inode->i_blocks); set_raw_extent(&F2FS_I(inode)->ext, &ri->i_ext); set_raw_inline(F2FS_I(inode), ri); ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec); ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec); ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); ri->i_current_depth = cpu_to_le32(F2FS_I(inode)->i_current_depth); ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid); ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino); ri->i_generation = cpu_to_le32(inode->i_generation); ri->i_dir_level = F2FS_I(inode)->i_dir_level; __set_inode_rdev(inode, ri); set_cold_node(inode, node_page); set_page_dirty(node_page); clear_inode_flag(F2FS_I(inode), FI_DIRTY_INODE); } void update_inode_page(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct page *node_page; retry: node_page = get_node_page(sbi, inode->i_ino); if (IS_ERR(node_page)) { int err = PTR_ERR(node_page); if (err == -ENOMEM) { cond_resched(); goto retry; } else if (err != -ENOENT) { f2fs_stop_checkpoint(sbi); } return; } update_inode(inode, node_page); f2fs_put_page(node_page, 1); } int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); if (inode->i_ino == F2FS_NODE_INO(sbi) || inode->i_ino == F2FS_META_INO(sbi)) return 0; if (!is_inode_flag_set(F2FS_I(inode), FI_DIRTY_INODE)) return 0; /* * We need to lock here to prevent from producing dirty node pages * during the urgent cleaning time when runing out of free sections. */ f2fs_lock_op(sbi); update_inode_page(inode); f2fs_unlock_op(sbi); if (wbc) f2fs_balance_fs(sbi); return 0; } /* * Called at the last iput() if i_nlink is zero */ void f2fs_evict_inode(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); nid_t xnid = F2FS_I(inode)->i_xattr_nid; /* some remained atomic pages should discarded */ if (f2fs_is_atomic_file(inode)) commit_inmem_pages(inode, true); trace_f2fs_evict_inode(inode); truncate_inode_pages_final(&inode->i_data); if (inode->i_ino == F2FS_NODE_INO(sbi) || inode->i_ino == F2FS_META_INO(sbi)) goto out_clear; f2fs_bug_on(sbi, get_dirty_pages(inode)); remove_dirty_dir_inode(inode); if (inode->i_nlink || is_bad_inode(inode)) goto no_delete; sb_start_intwrite(inode->i_sb); set_inode_flag(F2FS_I(inode), FI_NO_ALLOC); i_size_write(inode, 0); if (F2FS_HAS_BLOCKS(inode)) f2fs_truncate(inode); f2fs_lock_op(sbi); remove_inode_page(inode); f2fs_unlock_op(sbi); sb_end_intwrite(inode->i_sb); no_delete: stat_dec_inline_dir(inode); stat_dec_inline_inode(inode); invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino); if (xnid) invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid); if (is_inode_flag_set(F2FS_I(inode), FI_APPEND_WRITE)) add_dirty_inode(sbi, inode->i_ino, APPEND_INO); if (is_inode_flag_set(F2FS_I(inode), FI_UPDATE_WRITE)) add_dirty_inode(sbi, inode->i_ino, UPDATE_INO); out_clear: clear_inode(inode); } /* caller should call f2fs_lock_op() */ void handle_failed_inode(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); clear_nlink(inode); make_bad_inode(inode); unlock_new_inode(inode); i_size_write(inode, 0); if (F2FS_HAS_BLOCKS(inode)) f2fs_truncate(inode); remove_inode_page(inode); clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA); clear_inode_flag(F2FS_I(inode), FI_INLINE_DENTRY); alloc_nid_failed(sbi, inode->i_ino); f2fs_unlock_op(sbi); /* iput will drop the inode object */ iput(inode); }
-- Digging Through Bones (10922) SET @LETOLL := 22458; SET @RESEARCHER := 22464; SET @B_SIFTER := 22466; SET @SG_TRIGGER := 22457; SET @RESEARCHER1 := 78837; -- Faulty spawn, it needs to be spawned by a script. DELETE FROM `creature` WHERE `guid`=85488; DELETE FROM `creature_text` WHERE `entry`=@LETOLL; INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES (@LETOLL,0,0,"'Aright, listen up! Form a circle around me and move out!",12,0,100,0,0,0,''), (@LETOLL,1,0,"Aright, $R, just keep us safe from harm while we work. We'll pay you when we return.",12,0,100,0,0,0,''), (@LETOLL,2,0,"The dig site is just north of here.",12,0,100,0,0,0,''), (@LETOLL,3,0,"We're here! Start diggin'!",12,0,100,0,0,0,''), (@LETOLL,4,0,"I think there's somethin' buried here, beneath the sand!",12,0,100,396,0,0,''), (@LETOLL,5,0,"Almost got it!",12,0,100,396,0,0,''), (@LETOLL,6,0,"By Brann's brittle bananas! What is it?! It... It looks like a drum.",12,0,100,396,0,0,''), (@LETOLL,7,0,"Have ye gone mad? You expect me to leave behind a drum without first beatin' on it? Not this son of Ironforge! No sir!",12,0,100,0,0,0,''), (@LETOLL,8,0,"Shut yer yaps! I'm gonna bang on this drum and that's that!",12,0,100,0,0,0,''), (@LETOLL,9,0,"IN YOUR FACE! I told you there was somethin' here!",12,0,100,0,0,0,''), (@LETOLL,10,0,"Don't just stand there! Help him out!",12,0,100,0,0,0,''), (@LETOLL,11,0,"You've been a tremendous help, $R! Let's get out of here before more of those things show up! I'll let Dwarfowitz know you did the job asked of ya' admirably.",12,0,100,0,0,0,''); DELETE FROM `creature_text` WHERE `entry`=@RESEARCHER; INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES (@RESEARCHER,0,0,"Wow... a drum.",12,0,100,0,0,0,''), (@RESEARCHER,1,0,"This discovery will surely rock the foundation of modern archaeology.",12,0,100,0,0,0,''), (@RESEARCHER,2,0,"Yea, great. Can we leave now? This desert is giving me hives.",12,0,100,0,0,0,''), (@RESEARCHER,3,0,"This reminds me of that one time where you made us search Silithus for evidence of sand gnomes.",12,0,100,0,0,0,''), (@RESEARCHER,4,0,"Or that time when you told us that you'd discovered the cure for the plague of the 20th century. What is that even? 20th century?",12,0,100,0,0,0,''), (@RESEARCHER,5,0,"I don't think it can top the one time where he told us that he'd heard that Arthas's cousin's skeleton was frozen beneath a glacier in Winterspring. I'll never forgive you for that one, Letoll. I mean honestly... Arthas's cousin?",12,0,100,0,0,0,''), (@RESEARCHER,6,0,"I dunno. It can't possibly beat the time he tried to convince us that we're all actually a figment of some being's imagination and that they only use us for their own personal amusement. That went over well during dinner with the family.",12,0,100,0,0,0,''), (@RESEARCHER,7,0,"Say, do you guys hear that?",12,0,100,0,0,0,''); DELETE FROM `waypoints` WHERE `entry` IN (@LETOLL,@RESEARCHER,@LETOLL*100); INSERT INTO `waypoints` (`entry`,`pointid`,`position_x`,`position_y`,`position_z`,`point_comment`) VALUES (@LETOLL,1,-3728.1,5385.5,-3.41,''), (@LETOLL,2,-3735.9,5392.8,-4.8,''), (@LETOLL,3,-3729.7,5381,-4.9,''), (@LETOLL,4,-3704.6, 5372.74, -9.33,''), (@LETOLL,5,-3704.8,5374.7,-8.9,''), (@LETOLL,6,-3623.2,5403.2,-11.5,''), (@LETOLL,7,-3554.6,5455.2,-11.3,''), (@LETOLL,8,-3557.7,5468.9,-8.1,''), (@LETOLL,9,-3548.9,5458.3,-12.3,''), (@RESEARCHER,1,-3725.1,5381.9,-4.4,''), (@RESEARCHER,2,-3735.7,5390.7,-5.7,''), (@RESEARCHER,3,-3728.4,5384.1,-3.4,''), (@RESEARCHER,4,-3703.1,5371.4,-10.1,''), (@RESEARCHER,5,-3619.6,5400.8,-12.1,''), (@RESEARCHER,6,-3554.2,5451.1,-11.8,''), (@RESEARCHER,7,-3563.1,5462.8,-6.5,''), (@RESEARCHER,8,-3551.1,5454,-11.9,''); UPDATE `creature_template` SET `AIname`='SmartAI' WHERE `entry` IN (@LETOLL,@RESEARCHER,@B_SIFTER); DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid` IN (@LETOLL,-@RESEARCHER1,@B_SIFTER); DELETE FROM `smart_scripts` WHERE `source_type`=9 AND `entryorguid` IN (@LETOLL*100+2,@LETOLL*100+1,@LETOLL*100,@RESEARCHER*100); INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES (@LETOLL,0,0,1,19,0,100,0,10922,0,0,0,53,0,@LETOLL,0,0,0,0,1,0,0,0,0,0,0,0,'On quest accept - Start WP'), (@LETOLL,0,1,0,61,0,100,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'Say line 0'), (@LETOLL,0,2,3,40,0,100,0,1,@LETOLL,0,0,54,10000,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Pause WP'), (@LETOLL,0,3,10,61,0,100,0,0,0,0,0,80,@LETOLL*100,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Start Timed Event'), (@LETOLL,0,4,5,40,0,100,0,8,@LETOLL,0,0,17,233,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Set emote digging'), (@LETOLL,0,5,0,61,0,100,0,0,0,0,0,45,0,2,0,0,0,0,10,78837,@RESEARCHER,0,0,0,0,0,'On Link - Set Data'), (@LETOLL,0,6,7,40,0,100,0,9,@LETOLL,0,0,17,467,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Set emote digging'), (@LETOLL,0,7,8,61,0,100,0,0,0,0,0,45,0,3,0,0,0,0,10,78837,@RESEARCHER,0,0,0,0,0,'On Link - Set Data'), (@LETOLL,0,8,0,61,0,100,0,0,0,0,0,80,@LETOLL*100+1,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Start Timed Event'), (@LETOLL,0,9,0,40,0,100,0,7,@LETOLL,0,0,1,3,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Say line 3'), (@LETOLL,0,10,0,61,0,100,0,0,0,0,0,81,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'Set npc flag'), (@LETOLL,0,11,0,40,0,100,0,7,@LETOLL,0,0,54,3000,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Pause WP'), -- (-@RESEARCHER1,0,0,0,38,0,100,0,0,1,0,0,53,0,@RESEARCHER,0,0,0,0,1,0,0,0,0,0,0,0,'On Data - Start WP'), (-@RESEARCHER1,0,1,2,40,0,100,0,6,@RESEARCHER,0,0,54,3000,0,0,0,0,0,1,0,0,0,0,0,0,0,' On Data - Start WP'), (-@RESEARCHER1,0,2,0,61,0,100,0,0,0,0,0,17,233,0,0,0,0,0,1,0,0,0,0,0,0,0,'On link - Start digging'), (-@RESEARCHER1,0,3,4,40,0,100,0,7,@RESEARCHER,0,0,54,3000,0,0,0,0,0,1,0,0,0,0,0,0,0,'Pause WP'), (-@RESEARCHER1,0,4,0,61,0,100,0,0,0,0,0,17,233,0,0,0,0,0,1,0,0,0,0,0,0,0,'On link - Start digging'), (-@RESEARCHER1,0,5,6,40,0,100,0,8,@RESEARCHER,0,0,54,35500,0,0,0,0,0,1,0,0,0,0,0,0,0,'On WP reached - Pause WP'), (-@RESEARCHER1,0,6,0,61,0,100,0,0,0,0,0,80,@RESEARCHER*100,0,0,0,0,0,1,0,0,0,0,0,0,0,'ON WP reached - Start Timed Event'), (-@RESEARCHER1,0,7,0,11,0,100,0,0,0,0,0,17,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Respawn - Set Emote State none'), -- (@LETOLL*100,9,0,0,0,0,100,0,3000,3000,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 1'), (@LETOLL*100,9,1,0,0,0,100,0,7000,7000,0,0,1,2,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 2'), (@LETOLL*100,9,2,0,0,0,100,0,500,500,0,0,45,0,1,0,0,0,0,10,78837,@RESEARCHER,0,0,0,0,0,'On Script - Set Data'), -- (@LETOLL*100+1,9,0,0,0,0,100,0,0,0,0,0,1,4,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 4'), (@LETOLL*100+1,9,1,0,0,0,100,0,2000,2000,0,0,1,5,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 5'), (@LETOLL*100+1,9,2,0,0,0,100,0,5000,5000,0,0,1,6,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 6'), -- (@RESEARCHER*100,9,0,0,0,0,100,0,5000,5000,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 0'), (@RESEARCHER*100,9,1,0,0,0,100,0,0,0,0,0,17,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Set emote state none'), (@RESEARCHER*100,9,2,0,0,0,100,0,4000,4000,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 1'), (@RESEARCHER*100,9,3,0,0,0,100,0,7000,7000,0,0,1,2,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 2'), -- (@LETOLL*100+1,9,3,0,0,0,100,0,0,0,0,0,17,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Set emote state none'), (@LETOLL*100+1,9,4,0,0,0,100,0,22000,22000,0,0,1,7,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 7'), -- (@RESEARCHER*100,9,4,0,0,0,100,0,12000,12000,0,0,1,3,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 3'), (@RESEARCHER*100,9,5,0,0,0,100,0,6000,6000,0,0,1,4,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 4'), (@RESEARCHER*100,9,6,0,0,0,100,0,6000,6000,0,0,1,5,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 5'), (@RESEARCHER*100,9,7,0,0,0,100,0,17000,17000,0,0,1,6,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 6'), -- (@LETOLL*100+1,9,5,0,0,0,100,0,34000,34000,0,0,1,8,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 8'), -- (@RESEARCHER*100,9,8,0,0,0,100,0,6000,6000,0,0,1,7,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 7'), (@RESEARCHER*100,9,9,0,0,0,100,0,15000,15000,0,0,41,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Despawn'), -- (@LETOLL*100+1,9,6,0,0,0,100,0,7000,7000,0,0,1,9,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 9'), (@LETOLL*100+1,9,7,0,0,0,100,0,500,500,0,0,12,@B_SIFTER,1,60000,0,0,0,8,0,0,0,-3550,5456.1,-12.3,0,'On Script - Summon worm'), (@LETOLL*100+1,9,8,0,0,0,100,0,8000,8000,0,0,1,10,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 10'), (@LETOLL*100+1,9,9,0,0,0,100,0,8000,8000,0,0,1,11,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Say line 11'), (@LETOLL*100+1,9,10,0,0,0,100,0,6000,6000,0,0,15,10922,0,0,0,0,0,18,20,0,0,0,0,0,0,'On Script - Give quest credit'), (@LETOLL*100+1,9,11,0,0,0,100,0,3000,3000,0,0,81,2,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Restore npcflags'), (@LETOLL*100+1,9,12,0,0,0,100,0,1000,1000,0,0,78,0,0,0,0,0,0,1,0,0,0,0,0,0,0,' On Script - Stop Script'), (@LETOLL*100+1,9,13,0,0,0,100,0,16000,16000,0,0,41,0,0,0,0,0,0,1,0,0,0,0,0,0,0,'On Script - Despawn'), -- (@B_SIFTER,0,0,0,0,0,100,0,2000,6000,12000,17000,11,31747,0,0,0,0,0,2,0,0,0,0,0,0,0,'- IC - Cast Poison'), (@B_SIFTER,0,1,0,0,0,100,0,5000,25000,35000,40000,11,32738,0,0,0,0,0,2,0,0,0,0,0,0,0,'- IC - Cast Bore');
/****************************************************************************** Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The full GNU General Public License is included in this distribution in the file called LICENSE. Contact Information: James P. Ketrenos <ipw2100-admin@linux.intel.com> Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 ******************************************************************************/ #include <linux/compiler.h> #include <linux/errno.h> #include <linux/if_arp.h> #include <linux/in6.h> #include <linux/in.h> #include <linux/ip.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/proc_fs.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/tcp.h> #include <linux/types.h> #include <linux/wireless.h> #include <linux/etherdevice.h> #include <asm/uaccess.h> #include <net/ieee80211.h> /* 802.11 Data Frame ,-------------------------------------------------------------------. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | | | tion | (BSSID) | | | ence | data | | `--------------------------------------------------| |------' Total: 28 non-data bytes `----.----' | .- 'Frame data' expands, if WEP enabled, to <----------' | V ,-----------------------. Bytes | 4 | 0-2296 | 4 | |-----|-----------|-----| Desc. | IV | Encrypted | ICV | | | Packet | | `-----| |-----' `-----.-----' | .- 'Encrypted Packet' expands to | V ,---------------------------------------------------. Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | |------|------|---------|----------|------|---------| Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | | DSAP | SSAP | | | | Packet | | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | `---------------------------------------------------- Total: 8 non-data bytes 802.3 Ethernet Data Frame ,-----------------------------------------. Bytes | 6 | 6 | 2 | Variable | 4 | |-------|-------|------|-----------|------| Desc. | Dest. | Source| Type | IP Packet | fcs | | MAC | MAC | | | | `-----------------------------------------' Total: 18 non-data bytes In the event that fragmentation is required, the incoming payload is split into N parts of size ieee->fts. The first fragment contains the SNAP header and the remaining packets are just data. If encryption is enabled, each fragment payload size is reduced by enough space to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP) So if you have 1500 bytes of payload with ieee->fts set to 500 without encryption it will take 3 frames. With WEP it will take 4 frames as the payload of each frame is reduced to 492 bytes. * SKB visualization * * ,- skb->data * | * | ETHERNET HEADER ,-<-- PAYLOAD * | | 14 bytes from skb->data * | 2 bytes for Type --> ,T. | (sizeof ethhdr) * | | | | * |,-Dest.--. ,--Src.---. | | | * | 6 bytes| | 6 bytes | | | | * v | | | | | | * 0 | v 1 | v | v 2 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * ^ | ^ | ^ | * | | | | | | * | | | | `T' <---- 2 bytes for Type * | | | | * | | '---SNAP--' <-------- 6 bytes for SNAP * | | * `-IV--' <-------------------- 4 bytes for IV (WEP) * * SNAP HEADER * */ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; static int ieee80211_copy_snap(u8 * data, __be16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; snap = (struct ieee80211_snap_hdr *)data; snap->dsap = 0xaa; snap->ssap = 0xaa; snap->ctrl = 0x03; if (h_proto == htons(ETH_P_AARP) || h_proto == htons(ETH_P_IPX)) oui = P802_1H_OUI; else oui = RFC1042_OUI; snap->oui[0] = oui[0]; snap->oui[1] = oui[1]; snap->oui[2] = oui[2]; memcpy(data + SNAP_SIZE, &h_proto, sizeof(u16)); return SNAP_SIZE + sizeof(u16); } static int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) { struct lib80211_crypt_data *crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; int res; if (crypt == NULL) return -1; /* To encrypt, frame format is: * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */ atomic_inc(&crypt->refcnt); res = 0; if (crypt->ops && crypt->ops->encrypt_mpdu) res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv); atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_INFO "%s: Encryption failed: len=%d.\n", ieee->dev->name, frag->len); ieee->ieee_stats.tx_discards++; return -1; } return 0; } void ieee80211_txb_free(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; for (i = 0; i < txb->nr_frags; i++) if (txb->fragments[i]) dev_kfree_skb_any(txb->fragments[i]); kfree(txb); } static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, int headroom, gfp_t gfp_mask) { struct ieee80211_txb *txb; int i; txb = kmalloc(sizeof(struct ieee80211_txb) + (sizeof(u8 *) * nr_frags), gfp_mask); if (!txb) return NULL; memset(txb, 0, sizeof(struct ieee80211_txb)); txb->nr_frags = nr_frags; txb->frag_size = txb_size; for (i = 0; i < nr_frags; i++) { txb->fragments[i] = __dev_alloc_skb(txb_size + headroom, gfp_mask); if (unlikely(!txb->fragments[i])) { i--; break; } skb_reserve(txb->fragments[i], headroom); } if (unlikely(i != nr_frags)) { while (i >= 0) dev_kfree_skb_any(txb->fragments[i--]); kfree(txb); return NULL; } return txb; } static int ieee80211_classify(struct sk_buff *skb) { struct ethhdr *eth; struct iphdr *ip; eth = (struct ethhdr *)skb->data; if (eth->h_proto != htons(ETH_P_IP)) return 0; ip = ip_hdr(skb); switch (ip->tos & 0xfc) { case 0x20: return 2; case 0x40: return 1; case 0x60: return 3; case 0x80: return 4; case 0xa0: return 5; case 0xc0: return 6; case 0xe0: return 7; default: return 0; } } /* Incoming skb is converted to a txb which consists of * a block of 802.11 fragment packets (stored as skbs) */ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); struct ieee80211_txb *txb = NULL; struct ieee80211_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size, rts_required; unsigned long flags; struct net_device_stats *stats = &ieee->stats; int encrypt, host_encrypt, host_encrypt_msdu, host_build_iv; __be16 ether_type; int bytes, fc, hdr_len; struct sk_buff *skb_frag; struct ieee80211_hdr_3addrqos header = {/* Ensure zero initialized */ .duration_id = 0, .seq_ctl = 0, .qos_ctl = 0 }; u8 dest[ETH_ALEN], src[ETH_ALEN]; struct lib80211_crypt_data *crypt; int priority = skb->priority; int snapped = 0; if (ieee->is_queue_full && (*ieee->is_queue_full) (dev, priority)) return NETDEV_TX_BUSY; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother * creating it... */ if (!ieee->hard_start_xmit) { printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name); goto success; } if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } ether_type = ((struct ethhdr *)skb->data)->h_proto; crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; encrypt = !(ether_type == htons(ETH_P_PAE) && ieee->ieee802_1x) && ieee->sec.encrypt; host_encrypt = ieee->host_encrypt && encrypt && crypt; host_encrypt_msdu = ieee->host_encrypt_msdu && encrypt && crypt; host_build_iv = ieee->host_build_iv && encrypt && crypt; if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != htons(ETH_P_PAE)) { stats->tx_dropped++; goto success; } /* Save source and destination addresses */ skb_copy_from_linear_data(skb, dest, ETH_ALEN); skb_copy_from_linear_data_offset(skb, ETH_ALEN, src, ETH_ALEN); if (host_encrypt || host_build_iv) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_PROTECTED; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */ memcpy(header.addr1, ieee->bssid, ETH_ALEN); memcpy(header.addr2, src, ETH_ALEN); memcpy(header.addr3, dest, ETH_ALEN); } else if (ieee->iw_mode == IW_MODE_ADHOC) { /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */ memcpy(header.addr1, dest, ETH_ALEN); memcpy(header.addr2, src, ETH_ALEN); memcpy(header.addr3, ieee->bssid, ETH_ALEN); } hdr_len = IEEE80211_3ADDR_LEN; if (ieee->is_qos_active && ieee->is_qos_active(dev, skb)) { fc |= IEEE80211_STYPE_QOS_DATA; hdr_len += 2; skb->priority = ieee80211_classify(skb); header.qos_ctl |= cpu_to_le16(skb->priority & IEEE80211_QCTL_TID); } header.frame_ctl = cpu_to_le16(fc); /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); /* Encrypt msdu first on the whole data packet. */ if ((host_encrypt || host_encrypt_msdu) && crypt && crypt->ops && crypt->ops->encrypt_msdu) { int res = 0; int len = bytes + hdr_len + crypt->ops->extra_msdu_prefix_len + crypt->ops->extra_msdu_postfix_len; struct sk_buff *skb_new = dev_alloc_skb(len); if (unlikely(!skb_new)) goto failed; skb_reserve(skb_new, crypt->ops->extra_msdu_prefix_len); memcpy(skb_put(skb_new, hdr_len), &header, hdr_len); snapped = 1; ieee80211_copy_snap(skb_put(skb_new, SNAP_SIZE + sizeof(u16)), ether_type); skb_copy_from_linear_data(skb, skb_put(skb_new, skb->len), skb->len); res = crypt->ops->encrypt_msdu(skb_new, hdr_len, crypt->priv); if (res < 0) { IEEE80211_ERROR("msdu encryption failed\n"); dev_kfree_skb_any(skb_new); goto failed; } dev_kfree_skb_any(skb); skb = skb_new; bytes += crypt->ops->extra_msdu_prefix_len + crypt->ops->extra_msdu_postfix_len; skb_pull(skb, hdr_len); } if (host_encrypt || ieee->host_open_frag) { /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || is_broadcast_ether_addr(dest)) frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account * for it when determining the amount of payload space. */ bytes_per_frag = frag_size - hdr_len; if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; /* Each fragment may need to have room for encryptiong * pre/postfix */ if (host_encrypt) bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len + crypt->ops->extra_mpdu_postfix_len; /* Number of fragments is the total * bytes_per_frag / payload_per_fragment */ nr_frags = bytes / bytes_per_frag; bytes_last_frag = bytes % bytes_per_frag; if (bytes_last_frag) nr_frags++; else bytes_last_frag = bytes_per_frag; } else { nr_frags = 1; bytes_per_frag = bytes_last_frag = bytes; frag_size = bytes + hdr_len; } rts_required = (frag_size > ieee->rts && ieee->config & CFG_IEEE80211_RTS); if (rts_required) nr_frags++; /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ txb = ieee80211_alloc_txb(nr_frags, frag_size, ieee->tx_headroom, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } txb->encrypted = encrypt; if (host_encrypt) txb->payload_size = frag_size * (nr_frags - 1) + bytes_last_frag; else txb->payload_size = bytes; if (rts_required) { skb_frag = txb->fragments[0]; frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); /* * Set header frame_ctl to the RTS. */ header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); memcpy(frag_hdr, &header, hdr_len); /* * Restore header frame_ctl to the original data setting. */ header.frame_ctl = cpu_to_le16(fc); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); txb->rts_included = 1; i = 1; } else i = 0; for (; i < nr_frags; i++) { skb_frag = txb->fragments[i]; if (host_encrypt || host_build_iv) skb_reserve(skb_frag, crypt->ops->extra_mpdu_prefix_len); frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16(fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } if (i == 0 && !snapped) { ieee80211_copy_snap(skb_put (skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } skb_copy_from_linear_data(skb, skb_put(skb_frag, bytes), bytes); /* Advance the SKB... */ skb_pull(skb, bytes); /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (host_encrypt) ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); else if (host_build_iv) { atomic_inc(&crypt->refcnt); if (crypt->ops->build_iv) crypt->ops->build_iv(skb_frag, hdr_len, ieee->sec.keys[ieee->sec.active_key], ieee->sec.key_sizes[ieee->sec.active_key], crypt->priv); atomic_dec(&crypt->refcnt); } if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { int ret = (*ieee->hard_start_xmit) (txb, dev, priority); if (ret == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } ieee80211_txb_free(txb); } return 0; failed: spin_unlock_irqrestore(&ieee->lock, flags); netif_stop_queue(dev); stats->tx_errors++; return 1; } EXPORT_SYMBOL(ieee80211_txb_free);
/* * Copyright (C) 2005,2006,2007,2008 IBM Corporation * * Authors: * Kylene Hall <kjhall@us.ibm.com> * Reiner Sailer <sailer@us.ibm.com> * Mimi Zohar <zohar@us.ibm.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. * * File: ima_fs.c * implemenents security file system for reporting * current measurement list and IMA statistics */ #include <linux/fcntl.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/seq_file.h> #include <linux/rculist.h> #include <linux/rcupdate.h> #include <linux/parser.h> #include "ima.h" static int valid_policy = 1; #define TMPBUFLEN 12 static ssize_t ima_show_htable_value(char __user *buf, size_t count, loff_t *ppos, atomic_long_t *val) { char tmpbuf[TMPBUFLEN]; ssize_t len; len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val)); return simple_read_from_buffer(buf, count, ppos, tmpbuf, len); } static ssize_t ima_show_htable_violations(struct file *filp, char __user *buf, size_t count, loff_t *ppos) { return ima_show_htable_value(buf, count, ppos, &ima_htable.violations); } static const struct file_operations ima_htable_violations_ops = { .read = ima_show_htable_violations, .llseek = generic_file_llseek, }; static ssize_t ima_show_measurements_count(struct file *filp, char __user *buf, size_t count, loff_t *ppos) { return ima_show_htable_value(buf, count, ppos, &ima_htable.len); } static const struct file_operations ima_measurements_count_ops = { .read = ima_show_measurements_count, .llseek = generic_file_llseek, }; /* returns pointer to hlist_node */ static void *ima_measurements_start(struct seq_file *m, loff_t *pos) { loff_t l = *pos; struct ima_queue_entry *qe; /* we need a lock since pos could point beyond last element */ rcu_read_lock(); list_for_each_entry_rcu(qe, &ima_measurements, later) { if (!l--) { rcu_read_unlock(); return qe; } } rcu_read_unlock(); return NULL; } static void *ima_measurements_next(struct seq_file *m, void *v, loff_t *pos) { struct ima_queue_entry *qe = v; /* lock protects when reading beyond last element * against concurrent list-extension */ rcu_read_lock(); qe = list_entry_rcu(qe->later.next, struct ima_queue_entry, later); rcu_read_unlock(); (*pos)++; return (&qe->later == &ima_measurements) ? NULL : qe; } static void ima_measurements_stop(struct seq_file *m, void *v) { } void ima_putc(struct seq_file *m, void *data, int datalen) { while (datalen--) seq_putc(m, *(char *)data++); } /* print format: * 32bit-le=pcr# * char[20]=template digest * 32bit-le=template name size * char[n]=template name * [eventdata length] * eventdata[n]=template specific data */ static int ima_measurements_show(struct seq_file *m, void *v) { /* the list never shrinks, so we don't need a lock here */ struct ima_queue_entry *qe = v; struct ima_template_entry *e; int namelen; u32 pcr = CONFIG_IMA_MEASURE_PCR_IDX; bool is_ima_template = false; int i; /* get entry */ e = qe->entry; if (e == NULL) return -1; /* * 1st: PCRIndex * PCR used is always the same (config option) in * little-endian format */ ima_putc(m, &pcr, sizeof pcr); /* 2nd: template digest */ ima_putc(m, e->digest, TPM_DIGEST_SIZE); /* 3rd: template name size */ namelen = strlen(e->template_desc->name); ima_putc(m, &namelen, sizeof namelen); /* 4th: template name */ ima_putc(m, e->template_desc->name, namelen); /* 5th: template length (except for 'ima' template) */ if (strcmp(e->template_desc->name, IMA_TEMPLATE_IMA_NAME) == 0) is_ima_template = true; if (!is_ima_template) ima_putc(m, &e->template_data_len, sizeof(e->template_data_len)); /* 6th: template specific data */ for (i = 0; i < e->template_desc->num_fields; i++) { enum ima_show_type show = IMA_SHOW_BINARY; struct ima_template_field *field = e->template_desc->fields[i]; if (is_ima_template && strcmp(field->field_id, "d") == 0) show = IMA_SHOW_BINARY_NO_FIELD_LEN; if (is_ima_template && strcmp(field->field_id, "n") == 0) show = IMA_SHOW_BINARY_OLD_STRING_FMT; field->field_show(m, show, &e->template_data[i]); } return 0; } static const struct seq_operations ima_measurments_seqops = { .start = ima_measurements_start, .next = ima_measurements_next, .stop = ima_measurements_stop, .show = ima_measurements_show }; static int ima_measurements_open(struct inode *inode, struct file *file) { return seq_open(file, &ima_measurments_seqops); } static const struct file_operations ima_measurements_ops = { .open = ima_measurements_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; void ima_print_digest(struct seq_file *m, u8 *digest, int size) { int i; for (i = 0; i < size; i++) seq_printf(m, "%02x", *(digest + i)); } /* print in ascii */ static int ima_ascii_measurements_show(struct seq_file *m, void *v) { /* the list never shrinks, so we don't need a lock here */ struct ima_queue_entry *qe = v; struct ima_template_entry *e; int i; /* get entry */ e = qe->entry; if (e == NULL) return -1; /* 1st: PCR used (config option) */ seq_printf(m, "%2d ", CONFIG_IMA_MEASURE_PCR_IDX); /* 2nd: SHA1 template hash */ ima_print_digest(m, e->digest, TPM_DIGEST_SIZE); /* 3th: template name */ seq_printf(m, " %s", e->template_desc->name); /* 4th: template specific data */ for (i = 0; i < e->template_desc->num_fields; i++) { seq_puts(m, " "); if (e->template_data[i].len == 0) continue; e->template_desc->fields[i]->field_show(m, IMA_SHOW_ASCII, &e->template_data[i]); } seq_puts(m, "\n"); return 0; } static const struct seq_operations ima_ascii_measurements_seqops = { .start = ima_measurements_start, .next = ima_measurements_next, .stop = ima_measurements_stop, .show = ima_ascii_measurements_show }; static int ima_ascii_measurements_open(struct inode *inode, struct file *file) { return seq_open(file, &ima_ascii_measurements_seqops); } static const struct file_operations ima_ascii_measurements_ops = { .open = ima_ascii_measurements_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static ssize_t ima_write_policy(struct file *file, const char __user *buf, size_t datalen, loff_t *ppos) { char *data = NULL; ssize_t result; if (datalen >= PAGE_SIZE) datalen = PAGE_SIZE - 1; /* No partial writes. */ result = -EINVAL; if (*ppos != 0) goto out; result = -ENOMEM; data = kmalloc(datalen + 1, GFP_KERNEL); if (!data) goto out; *(data + datalen) = '\0'; result = -EFAULT; if (copy_from_user(data, buf, datalen)) goto out; result = ima_parse_add_rule(data); out: if (result < 0) valid_policy = 0; kfree(data); return result; } static struct dentry *ima_dir; static struct dentry *binary_runtime_measurements; static struct dentry *ascii_runtime_measurements; static struct dentry *runtime_measurements_count; static struct dentry *violations; static struct dentry *ima_policy; static atomic_t policy_opencount = ATOMIC_INIT(1); /* * ima_open_policy: sequentialize access to the policy file */ static int ima_open_policy(struct inode * inode, struct file * filp) { /* No point in being allowed to open it if you aren't going to write */ if (!(filp->f_flags & O_WRONLY)) return -EACCES; if (atomic_dec_and_test(&policy_opencount)) return 0; return -EBUSY; } /* * ima_release_policy - start using the new measure policy rules. * * Initially, ima_measure points to the default policy rules, now * point to the new policy rules, and remove the securityfs policy file, * assuming a valid policy. */ static int ima_release_policy(struct inode *inode, struct file *file) { if (!valid_policy) { ima_delete_rules(); valid_policy = 1; atomic_set(&policy_opencount, 1); return 0; } ima_update_policy(); securityfs_remove(ima_policy); ima_policy = NULL; return 0; } static const struct file_operations ima_measure_policy_ops = { .open = ima_open_policy, .write = ima_write_policy, .release = ima_release_policy, .llseek = generic_file_llseek, }; int __init ima_fs_init(void) { ima_dir = securityfs_create_dir("ima", NULL); if (IS_ERR(ima_dir)) return -1; binary_runtime_measurements = securityfs_create_file("binary_runtime_measurements", S_IRUSR | S_IRGRP, ima_dir, NULL, &ima_measurements_ops); if (IS_ERR(binary_runtime_measurements)) goto out; ascii_runtime_measurements = securityfs_create_file("ascii_runtime_measurements", S_IRUSR | S_IRGRP, ima_dir, NULL, &ima_ascii_measurements_ops); if (IS_ERR(ascii_runtime_measurements)) goto out; runtime_measurements_count = securityfs_create_file("runtime_measurements_count", S_IRUSR | S_IRGRP, ima_dir, NULL, &ima_measurements_count_ops); if (IS_ERR(runtime_measurements_count)) goto out; violations = securityfs_create_file("violations", S_IRUSR | S_IRGRP, ima_dir, NULL, &ima_htable_violations_ops); if (IS_ERR(violations)) goto out; ima_policy = securityfs_create_file("policy", S_IWUSR, ima_dir, NULL, &ima_measure_policy_ops); if (IS_ERR(ima_policy)) goto out; return 0; out: securityfs_remove(violations); securityfs_remove(runtime_measurements_count); securityfs_remove(ascii_runtime_measurements); securityfs_remove(binary_runtime_measurements); securityfs_remove(ima_dir); securityfs_remove(ima_policy); return -1; }
/*! UIkit 2.11.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /* ======================================================================== Component: Base ========================================================================== */ /* * 1. Normalizes default `font-family` and sets `font-size` here to support `rem` units * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom * 3. Style */ html { /* 1 */ font: normal 14px / 20px "Helvetica Neue", Helvetica, Arial, sans-serif; /* 2 */ -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; /* 3 */ background: #ffffff; color: #444444; } /* * Removes default margin. */ body { margin: 0; } /* Links ========================================================================== */ /* * Remove the gray background color from active links in IE 10. */ a { background: transparent; } /* * Improves readability when focused and also mouse hovered in all browsers. */ a:active, a:hover { outline: 0; } /* * Style */ a, .uk-link { color: #0077dd; text-decoration: none; cursor: pointer; } a:hover, .uk-link:hover { color: #005599; text-decoration: underline; } /* Text-level semantics ========================================================================== */ /* * Addresses styling not present in Chrome, Safari, Opera and IE 8/9/10. */ abbr[title] { border-bottom: 1px dotted; } /* * Addresses style set to `bolder` in Firefox */ b, strong { font-weight: bold; } /* * 1. Address odd `em`-unit font size rendering in all browsers. * 2. Consolas has a better baseline in running text compared to `Courier` */ :not(pre) > code, :not(pre) > kbd, :not(pre) > samp { /* 1 */ font-size: 12px; /* 2 */ font-family: Consolas, monospace, serif; /* 3 */ color: #dd0055; white-space: nowrap; } /* * Emphasize */ em { color: #dd0055; } /* * Insert */ ins { background: #ffffaa; color: #444444; text-decoration: none; } /* * Mark * Note: Addresses styling not present in IE 8/9. */ mark { background: #ffffaa; color: #444444; } /* * Quote */ q { font-style: italic; } /* * Addresses inconsistent and variable font size in all browsers. */ small { font-size: 80%; } /* * Prevents `sub` and `sup` affecting `line-height` in all browsers. */ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sup { top: -0.5em; } sub { bottom: -0.25em; } /* Images ========================================================================== */ /* * 1. Responsiveness: Sets a maximum width relative to the parent and auto scales the height * 2. Corrects `max-width` behavior if padding and border are used * 3. Remove border when inside `a` element in IE 8/9/10. * 4. Remove the gap between images and the bottom of their containers */ img { /* 1 */ max-width: 100%; height: auto; /* 2 */ -moz-box-sizing: border-box; box-sizing: border-box; /* 3 */ border: 0; /* 4 */ vertical-align: middle; } /* * Preserve original image dimensions */ .uk-img-preserve, .uk-img-preserve img { max-width: none; } /* * Correct overflow not hidden in IE 9/10/11. */ svg:not(:root) { overflow: hidden; } /* Block elements ========================================================================== */ /* * Reset margin */ blockquote, figure { margin: 0; } /* * Margins */ p, ul, ol, dl, blockquote, pre, address, fieldset, figure { margin: 0 0 15px 0; } * + p, * + ul, * + ol, * + dl, * + blockquote, * + pre, * + address, * + fieldset, * + figure { margin-top: 15px; } /* Headings ========================================================================== */ h1, h2, h3, h4, h5, h6 { margin: 0 0 15px 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: normal; color: #444444; text-transform: none; } /* * Margins */ * + h1, * + h2, * + h3, * + h4, * + h5, * + h6 { margin-top: 25px; } /* * Sizes */ h1, .uk-h1 { font-size: 36px; line-height: 42px; } h2, .uk-h2 { font-size: 24px; line-height: 30px; } h3, .uk-h3 { font-size: 18px; line-height: 24px; } h4, .uk-h4 { font-size: 16px; line-height: 22px; } h5, .uk-h5 { font-size: 14px; line-height: 20px; } h6, .uk-h6 { font-size: 12px; line-height: 18px; } /* Lists ========================================================================== */ ul, ol { padding-left: 30px; } /* * Reset margin for nested lists */ ul > li > ul, ul > li > ol, ol > li > ol, ol > li > ul { margin: 0; } /* Description lists ========================================================================== */ dt { font-weight: bold; } dd { margin-left: 0; } /* Horizontal rules ========================================================================== */ /* * 1. Address differences between Firefox and other browsers. * 2. Style */ hr { /* 1 */ -moz-box-sizing: content-box; box-sizing: content-box; height: 0; /* 2 */ margin: 15px 0; border: 0; border-top: 1px solid #dddddd; } /* Address ========================================================================== */ address { font-style: normal; } /* Blockquotes ========================================================================== */ blockquote { padding-left: 15px; border-left: 5px solid #dddddd; font-size: 16px; line-height: 22px; font-style: italic; } /* Preformatted text ========================================================================== */ /* * 1. Contain overflow in all browsers. */ pre { padding: 10px; background: #f5f5f5; font: 12px / 18px Consolas, monospace, serif; color: #444444; -moz-tab-size: 4; tab-size: 4; /* 1 */ overflow: auto; } /* Selection pseudo-element ========================================================================== */ ::-moz-selection { background: #3399ff; color: #ffffff; text-shadow: none; } ::selection { background: #3399ff; color: #ffffff; text-shadow: none; } /* HTML5 elements ========================================================================== */ /* * Corrects `block` display not defined in IE 8/9. */ article, aside, details, figcaption, figure, footer, header, main, nav, section, summary { display: block; } /* * Addresses inconsistent vertical alignment of `progress` in Chrome, Firefox and Opera. */ progress { vertical-align: baseline; } /* * Prevent displaying `audio` without controls in Chrome, Safari and Opera */ audio:not([controls]) { display: none; } /* * Address `[hidden]` styling not present in IE 8/9. * Hide the `template` element in IE and Safari */ [hidden], template { display: none; } /* Iframe ========================================================================== */ iframe { border: 0; } /* Fix viewport for IE10 snap mode ========================================================================== */ @media screen and (max-width: 400px) { @-ms-viewport { width: device-width; } } /* ======================================================================== Component: Grid ========================================================================== */ /* * Micro clearfix */ .uk-grid:before, .uk-grid:after { content: " "; display: table; } .uk-grid:after { clear: both; } /* * 1. Needed for the gutter * 2. Makes grid more robust so that it can be used with other block elements like lists */ .uk-grid { /* 1 */ margin: 0 0 0 -25px; /* 2 */ padding: 0; list-style: none; } /* * Grid cell * 1. Makes grid more robust so that it can be used with other block elements * 2. Create horizontal gutter * 3. `float` is set by default so columns always behave the same and create a new block format context */ .uk-grid > * { /* 1 */ margin: 0; /* 2 */ padding-left: 25px; /* 3 */ float: left; } /* * Remove margin from the last-child */ .uk-grid > * > :last-child { margin-bottom: 0; } /* Grid gutter ========================================================================== */ /* * Vertical gutter */ .uk-grid + .uk-grid { margin-top: 25px; } /* * This class is set by JavaScript and applies a vertical gutter if the columns stack or float into the next row * Higher specificity to override margin */ .uk-grid > .uk-grid-margin { margin-top: 25px; } /* * Vertical gutter for panels */ .uk-grid > * > .uk-panel + .uk-panel { margin-top: 25px; } /* * Larger gutter for large screens */ /* Large screen and bigger */ @media (min-width: 1220px) { /* Horizontal gutter */ .uk-grid:not(.uk-grid-preserve) { margin-left: -35px; } .uk-grid:not(.uk-grid-preserve) > * { padding-left: 35px; } /* Vertical gutter */ .uk-grid:not(.uk-grid-preserve) + .uk-grid { margin-top: 35px; } .uk-grid:not(.uk-grid-preserve) > .uk-grid-margin { margin-top: 35px; } /* Vertical gutter for panels */ .uk-grid:not(.uk-grid-preserve) > * > .uk-panel + .uk-panel { margin-top: 35px; } } /* * Small gutter * Higher specificity to override large gutter */ .uk-grid.uk-grid-small { margin-left: -10px; } .uk-grid.uk-grid-small > * { padding-left: 10px; } .uk-grid.uk-grid-small + .uk-grid-small { margin-top: 10px; } .uk-grid.uk-grid-small > .uk-grid-margin { margin-top: 10px; } .uk-grid.uk-grid-small > * > .uk-panel + .uk-panel { margin-top: 10px; } /* Modifier: `uk-grid-divider` ========================================================================== */ /* * Horizontal divider * Does not work with `uk-push-*`, `uk-pull-*` and not if the columns float into the next row */ .uk-grid-divider:not(:empty) { margin-left: -25px; margin-right: -25px; } .uk-grid-divider > * { padding-left: 25px; padding-right: 25px; } .uk-grid-divider > [class*='uk-width-1-']:not(.uk-width-1-1):nth-child(n+2), .uk-grid-divider > [class*='uk-width-2-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-3-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-4-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-5-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-6-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-7-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-8-']:nth-child(n+2), .uk-grid-divider > [class*='uk-width-9-']:nth-child(n+2) { border-left: 1px solid #dddddd; } /* Tablet and bigger */ @media (min-width: 768px) { .uk-grid-divider > [class*='uk-width-medium-']:not(.uk-width-medium-1-1):nth-child(n+2) { border-left: 1px solid #dddddd; } } /* Desktop and bigger */ @media (min-width: 960px) { .uk-grid-divider > [class*='uk-width-large-']:not(.uk-width-large-1-1):nth-child(n+2) { border-left: 1px solid #dddddd; } } /* Large screen and bigger */ @media (min-width: 1220px) { /* * Large gutter */ .uk-grid-divider:not(.uk-grid-preserve):not(:empty) { margin-left: -35px; margin-right: -35px; } .uk-grid-divider:not(.uk-grid-preserve) > * { padding-left: 35px; padding-right: 35px; } .uk-grid-divider:not(.uk-grid-preserve):empty { margin-top: 35px; margin-bottom: 35px; } } /* * Vertical divider */ .uk-grid-divider:empty { margin-top: 25px; margin-bottom: 25px; border-top: 1px solid #dddddd; } /* Even grid cell widths ========================================================================== */ [class*='uk-grid-width'] > * { -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; } .uk-grid-width-1-2 > * { width: 50%; } .uk-grid-width-1-3 > * { width: 33.333%; } .uk-grid-width-1-4 > * { width: 25%; } .uk-grid-width-1-5 > * { width: 20%; } .uk-grid-width-1-6 > * { width: 16.666%; } .uk-grid-width-1-10 > * { width: 10%; } /* Phone landscape and bigger */ @media (min-width: 480px) { .uk-grid-width-small-1-2 > * { width: 50%; } .uk-grid-width-small-1-3 > * { width: 33.333%; } .uk-grid-width-small-1-4 > * { width: 25%; } .uk-grid-width-small-1-5 > * { width: 20%; } .uk-grid-width-small-1-6 > * { width: 16.666%; } .uk-grid-width-small-1-10 > * { width: 10%; } } /* Tablet and bigger */ @media (min-width: 768px) { .uk-grid-width-medium-1-2 > * { width: 50%; } .uk-grid-width-medium-1-3 > * { width: 33.333%; } .uk-grid-width-medium-1-4 > * { width: 25%; } .uk-grid-width-medium-1-5 > * { width: 20%; } .uk-grid-width-medium-1-6 > * { width: 16.666%; } .uk-grid-width-medium-1-10 > * { width: 10%; } } /* Desktop and bigger */ @media (min-width: 960px) { .uk-grid-width-large-1-2 > * { width: 50%; } .uk-grid-width-large-1-3 > * { width: 33.333%; } .uk-grid-width-large-1-4 > * { width: 25%; } .uk-grid-width-large-1-5 > * { width: 20%; } .uk-grid-width-large-1-6 > * { width: 16.666%; } .uk-grid-width-large-1-10 > * { width: 10%; } } /* Large screen and bigger */ @media (min-width: 1220px) { .uk-grid-width-xlarge-1-2 > * { width: 50%; } .uk-grid-width-xlarge-1-3 > * { width: 33.333%; } .uk-grid-width-xlarge-1-4 > * { width: 25%; } .uk-grid-width-xlarge-1-5 > * { width: 20%; } .uk-grid-width-xlarge-1-6 > * { width: 16.666%; } .uk-grid-width-xlarge-1-10 > * { width: 10%; } } /* Sub-objects: `uk-width-*` ========================================================================== */ [class*='uk-width'] { -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; } /* * Widths */ /* Whole */ .uk-width-1-1 { width: 100%; } /* Halves */ .uk-width-1-2, .uk-width-2-4, .uk-width-3-6, .uk-width-5-10 { width: 50%; } /* Thirds */ .uk-width-1-3, .uk-width-2-6 { width: 33.333%; } .uk-width-2-3, .uk-width-4-6 { width: 66.666%; } /* Quarters */ .uk-width-1-4 { width: 25%; } .uk-width-3-4 { width: 75%; } /* Fifths */ .uk-width-1-5, .uk-width-2-10 { width: 20%; } .uk-width-2-5, .uk-width-4-10 { width: 40%; } .uk-width-3-5, .uk-width-6-10 { width: 60%; } .uk-width-4-5, .uk-width-8-10 { width: 80%; } /* Sixths */ .uk-width-1-6 { width: 16.666%; } .uk-width-5-6 { width: 83.333%; } /* Tenths */ .uk-width-1-10 { width: 10%; } .uk-width-3-10 { width: 30%; } .uk-width-7-10 { width: 70%; } .uk-width-9-10 { width: 90%; } /* Phone landscape and bigger */ @media (min-width: 480px) { /* Whole */ .uk-width-small-1-1 { width: 100%; } /* Halves */ .uk-width-small-1-2, .uk-width-small-2-4, .uk-width-small-3-6, .uk-width-small-5-10 { width: 50%; } /* Thirds */ .uk-width-small-1-3, .uk-width-small-2-6 { width: 33.333%; } .uk-width-small-2-3, .uk-width-small-4-6 { width: 66.666%; } /* Quarters */ .uk-width-small-1-4 { width: 25%; } .uk-width-small-3-4 { width: 75%; } /* Fifths */ .uk-width-small-1-5, .uk-width-small-2-10 { width: 20%; } .uk-width-small-2-5, .uk-width-small-4-10 { width: 40%; } .uk-width-small-3-5, .uk-width-small-6-10 { width: 60%; } .uk-width-small-4-5, .uk-width-small-8-10 { width: 80%; } /* Sixths */ .uk-width-small-1-6 { width: 16.666%; } .uk-width-small-5-6 { width: 83.333%; } /* Tenths */ .uk-width-small-1-10 { width: 10%; } .uk-width-small-3-10 { width: 30%; } .uk-width-small-7-10 { width: 70%; } .uk-width-small-9-10 { width: 90%; } } /* Tablet and bigger */ @media (min-width: 768px) { /* Whole */ .uk-width-medium-1-1 { width: 100%; } /* Halves */ .uk-width-medium-1-2, .uk-width-medium-2-4, .uk-width-medium-3-6, .uk-width-medium-5-10 { width: 50%; } /* Thirds */ .uk-width-medium-1-3, .uk-width-medium-2-6 { width: 33.333%; } .uk-width-medium-2-3, .uk-width-medium-4-6 { width: 66.666%; } /* Quarters */ .uk-width-medium-1-4 { width: 25%; } .uk-width-medium-3-4 { width: 75%; } /* Fifths */ .uk-width-medium-1-5, .uk-width-medium-2-10 { width: 20%; } .uk-width-medium-2-5, .uk-width-medium-4-10 { width: 40%; } .uk-width-medium-3-5, .uk-width-medium-6-10 { width: 60%; } .uk-width-medium-4-5, .uk-width-medium-8-10 { width: 80%; } /* Sixths */ .uk-width-medium-1-6 { width: 16.666%; } .uk-width-medium-5-6 { width: 83.333%; } /* Tenths */ .uk-width-medium-1-10 { width: 10%; } .uk-width-medium-3-10 { width: 30%; } .uk-width-medium-7-10 { width: 70%; } .uk-width-medium-9-10 { width: 90%; } } /* Desktop and bigger */ @media (min-width: 960px) { /* Whole */ .uk-width-large-1-1 { width: 100%; } /* Halves */ .uk-width-large-1-2, .uk-width-large-2-4, .uk-width-large-3-6, .uk-width-large-5-10 { width: 50%; } /* Thirds */ .uk-width-large-1-3, .uk-width-large-2-6 { width: 33.333%; } .uk-width-large-2-3, .uk-width-large-4-6 { width: 66.666%; } /* Quarters */ .uk-width-large-1-4 { width: 25%; } .uk-width-large-3-4 { width: 75%; } /* Fifths */ .uk-width-large-1-5, .uk-width-large-2-10 { width: 20%; } .uk-width-large-2-5, .uk-width-large-4-10 { width: 40%; } .uk-width-large-3-5, .uk-width-large-6-10 { width: 60%; } .uk-width-large-4-5, .uk-width-large-8-10 { width: 80%; } /* Sixths */ .uk-width-large-1-6 { width: 16.666%; } .uk-width-large-5-6 { width: 83.333%; } /* Tenths */ .uk-width-large-1-10 { width: 10%; } .uk-width-large-3-10 { width: 30%; } .uk-width-large-7-10 { width: 70%; } .uk-width-large-9-10 { width: 90%; } } /* Sub-object: `uk-push-*` and `uk-pull-*` ========================================================================== */ /* * Source ordering * Works only with `uk-width-medium-*` */ /* Tablet and bigger */ @media (min-width: 768px) { [class*='uk-push-'], [class*='uk-pull-'] { position: relative; } /* * Push */ /* Halves */ .uk-push-1-2, .uk-push-2-4, .uk-push-3-6, .uk-push-5-10 { left: 50%; } /* Thirds */ .uk-push-1-3, .uk-push-2-6 { left: 33.333%; } .uk-push-2-3, .uk-push-4-6 { left: 66.666%; } /* Quarters */ .uk-push-1-4 { left: 25%; } .uk-push-3-4 { left: 75%; } /* Fifths */ .uk-push-1-5, .uk-push-2-10 { left: 20%; } .uk-push-2-5, .uk-push-4-10 { left: 40%; } .uk-push-3-5, .uk-push-6-10 { left: 60%; } .uk-push-4-5, .uk-push-8-10 { left: 80%; } /* Sixths */ .uk-push-1-6 { left: 16.666%; } .uk-push-5-6 { left: 83.333%; } /* Tenths */ .uk-push-1-10 { left: 10%; } .uk-push-3-10 { left: 30%; } .uk-push-7-10 { left: 70%; } .uk-push-9-10 { left: 90%; } /* * Pull */ /* Halves */ .uk-pull-1-2, .uk-pull-2-4, .uk-pull-3-6, .uk-pull-5-10 { left: -50%; } /* Thirds */ .uk-pull-1-3, .uk-pull-2-6 { left: -33.333%; } .uk-pull-2-3, .uk-pull-4-6 { left: -66.666%; } /* Quarters */ .uk-pull-1-4 { left: -25%; } .uk-pull-3-4 { left: -75%; } /* Fifths */ .uk-pull-1-5, .uk-pull-2-10 { left: -20%; } .uk-pull-2-5, .uk-pull-4-10 { left: -40%; } .uk-pull-3-5, .uk-pull-6-10 { left: -60%; } .uk-pull-4-5, .uk-pull-8-10 { left: -80%; } /* Sixths */ .uk-pull-1-6 { left: -16.666%; } .uk-pull-5-6 { left: -83.333%; } /* Tenths */ .uk-pull-1-10 { left: -10%; } .uk-pull-3-10 { left: -30%; } .uk-pull-7-10 { left: -70%; } .uk-pull-9-10 { left: -90%; } } /* ======================================================================== Component: Panel ========================================================================== */ /* * 1. Needed for `a` elements * 2. Create position context for badges */ .uk-panel { /* 1 */ display: block; /* 2 */ position: relative; } /* * Micro clearfix to make panels more robust */ .uk-panel:before, .uk-panel:after { content: " "; display: table; } .uk-panel:after { clear: both; } /* * Remove margin from the last-child if not `uk-widget-title` */ .uk-panel > :not(.uk-panel-title):last-child { margin-bottom: 0; } /* Sub-object: `uk-panel-title` ========================================================================== */ .uk-panel-title { margin-top: 0; margin-bottom: 15px; font-size: 18px; line-height: 24px; font-weight: normal; text-transform: none; color: #444444; } /* Sub-object: `uk-panel-badge` ========================================================================== */ .uk-panel-badge { position: absolute; top: 0; right: 0; z-index: 1; } /* Modifier: `uk-panel-box` ========================================================================== */ .uk-panel-box { padding: 15px; background: #f5f5f5; color: #444444; } .uk-panel-box .uk-panel-title { color: #444444; } .uk-panel-box .uk-panel-badge { top: 10px; right: 10px; } .uk-panel-box .uk-panel-teaser { margin: -15px -15px 15px -15px; } /* * Nav in panel */ .uk-panel-box > .uk-nav-side { margin: 0 -15px; } /* * Sub-modifier: `uk-panel-box-primary` */ .uk-panel-box-primary { background-color: #ebf7fd; color: #2d7091; } .uk-panel-box-primary .uk-panel-title { color: #2d7091; } /* * Sub-modifier: `uk-panel-box-secondary` */ .uk-panel-box-secondary { background-color: #eeeeee; color: #444444; } .uk-panel-box-secondary .uk-panel-title { color: #444444; } /* Modifier: `uk-panel-header` ========================================================================== */ .uk-panel-header .uk-panel-title { padding-bottom: 10px; border-bottom: 1px solid #dddddd; color: #444444; } /* Modifier: `uk-panel-space` ========================================================================== */ .uk-panel-space { padding: 30px; } .uk-panel-space .uk-panel-badge { top: 30px; right: 30px; } /* Modifier: `uk-panel-divider` ========================================================================== */ .uk-panel + .uk-panel-divider { margin-top: 50px !important; } .uk-panel + .uk-panel-divider:before { content: ""; display: block; position: absolute; top: -25px; left: 0; right: 0; border-top: 1px solid #dddddd; } /* Large screen and bigger */ @media (min-width: 1220px) { .uk-panel + .uk-panel-divider { margin-top: 70px !important; } .uk-panel + .uk-panel-divider:before { top: -35px; } } /* ======================================================================== Component: Article ========================================================================== */ /* * Micro clearfix to make articles more robust */ .uk-article:before, .uk-article:after { content: " "; display: table; } .uk-article:after { clear: both; } /* * Remove margin from the last-child */ .uk-article > :last-child { margin-bottom: 0; } /* * Vertical gutter for articles */ .uk-article + .uk-article { margin-top: 25px; } /* Sub-object `uk-article-title` ========================================================================== */ .uk-article-title { font-size: 36px; line-height: 42px; font-weight: normal; text-transform: none; } .uk-article-title a { color: inherit; text-decoration: none; } /* Sub-object `uk-article-meta` ========================================================================== */ .uk-article-meta { font-size: 12px; line-height: 18px; color: #999999; } /* Sub-object `uk-article-lead` ========================================================================== */ .uk-article-lead { color: #444444; font-size: 18px; line-height: 24px; font-weight: normal; } /* Sub-object `uk-article-divider` ========================================================================== */ .uk-article-divider { margin-bottom: 25px; border-color: #dddddd; } * + .uk-article-divider { margin-top: 25px; } /* ======================================================================== Component: Comment ========================================================================== */ /* Sub-object `uk-comment-header` ========================================================================== */ .uk-comment-header { margin-bottom: 15px; } /* * Micro clearfix */ .uk-comment-header:before, .uk-comment-header:after { content: " "; display: table; } .uk-comment-header:after { clear: both; } /* Sub-object `uk-comment-avatar` ========================================================================== */ .uk-comment-avatar { margin-right: 15px; float: left; } /* Sub-object `uk-comment-title` ========================================================================== */ .uk-comment-title { margin: 5px 0 0 0; font-size: 16px; line-height: 22px; } /* Sub-object `uk-comment-meta` ========================================================================== */ .uk-comment-meta { margin: 2px 0 0 0; font-size: 11px; line-height: 16px; color: #999999; } /* Sub-object `uk-comment-body` ========================================================================== */ /* * Remove margin from the last-child */ .uk-comment-body > :last-child { margin-bottom: 0; } /* Sub-object `uk-comment-list` ========================================================================== */ .uk-comment-list { padding: 0; list-style: none; } .uk-comment-list .uk-comment + ul { margin: 15px 0 0 0; list-style: none; } .uk-comment-list > li:nth-child(n+2), .uk-comment-list .uk-comment + ul > li:nth-child(n+2) { margin-top: 15px; } /* Tablet and bigger */ @media (min-width: 768px) { .uk-comment-list .uk-comment + ul { padding-left: 100px; } } /* Modifier `uk-comment-primary` ========================================================================== */ /* ======================================================================== Component: Nav ========================================================================== */ .uk-nav, .uk-nav ul { margin: 0; padding: 0; list-style: none; } /* * Items */ .uk-nav li > a { display: block; text-decoration: none; } .uk-nav > li > a { padding: 5px 15px; } /* * Nested items */ .uk-nav ul { padding-left: 15px; } .uk-nav ul a { padding: 2px 0; } /* * Item subtitle */ .uk-nav li > a > div { font-size: 12px; line-height: 18px; } /* Sub-object: `uk-nav-header` ========================================================================== */ .uk-nav-header { padding: 5px 15px; text-transform: uppercase; font-weight: bold; font-size: 12px; } .uk-nav-header:not(:first-child) { margin-top: 15px; } /* Sub-object: `uk-nav-divider` ========================================================================== */ .uk-nav-divider { margin: 9px 15px; } /* Sub-object: `uk-nav-sub` ========================================================================== */ /* * `ul` needed for higher specificity to override padding */ ul.uk-nav-sub { padding: 5px 0 5px 15px; } /* Modifier: `uk-nav-parent-icon` ========================================================================== */ .uk-nav-parent-icon > .uk-parent > a:after { content: "\f104"; width: 20px; margin-right: -10px; float: right; font-family: FontAwesome; text-align: center; } .uk-nav-parent-icon > .uk-parent.uk-open > a:after { content: "\f107"; } /* Modifier `uk-nav-side` ========================================================================== */ /* * Items */ .uk-nav-side > li > a { color: #444444; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-nav-side > li > a:hover, .uk-nav-side > li > a:focus { background: rgba(0, 0, 0, 0.05); color: #444444; /* 2 */ outline: none; } /* Active */ .uk-nav-side > li.uk-active > a { background: #00a8e6; color: #ffffff; } /* * Sub-object: `uk-nav-header` */ .uk-nav-side .uk-nav-header { color: #444444; } /* * Sub-object: `uk-nav-divider` */ .uk-nav-side .uk-nav-divider { border-top: 1px solid #dddddd; } /* * Nested items */ .uk-nav-side ul a { color: #0077dd; } .uk-nav-side ul a:hover { color: #005599; } /* Modifier `uk-nav-dropdown` ========================================================================== */ /* * Items */ .uk-nav-dropdown > li > a { color: #444444; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-nav-dropdown > li > a:hover, .uk-nav-dropdown > li > a:focus { background: #00a8e6; color: #ffffff; /* 2 */ outline: none; } /* * Sub-object: `uk-nav-header` */ .uk-nav-dropdown .uk-nav-header { color: #999999; } /* * Sub-object: `uk-nav-divider` */ .uk-nav-dropdown .uk-nav-divider { border-top: 1px solid #dddddd; } /* * Nested items */ .uk-nav-dropdown ul a { color: #0077dd; } .uk-nav-dropdown ul a:hover { color: #005599; } /* Modifier `uk-nav-navbar` ========================================================================== */ /* * Items */ .uk-nav-navbar > li > a { color: #444444; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-nav-navbar > li > a:hover, .uk-nav-navbar > li > a:focus { background: #00a8e6; color: #ffffff; /* 2 */ outline: none; } /* * Sub-object: `uk-nav-header` */ .uk-nav-navbar .uk-nav-header { color: #999999; } /* * Sub-object: `uk-nav-divider` */ .uk-nav-navbar .uk-nav-divider { border-top: 1px solid #dddddd; } /* * Nested items */ .uk-nav-navbar ul a { color: #0077dd; } .uk-nav-navbar ul a:hover { color: #005599; } /* Modifier `uk-nav-offcanvas` ========================================================================== */ /* * Items */ .uk-nav-offcanvas > li > a { color: #cccccc; padding: 10px 15px; } /* * Hover * No hover on touch devices because it behaves buggy in fixed offcanvas * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-nav-offcanvas > .uk-open > a, html:not(.uk-touch) .uk-nav-offcanvas > li > a:hover, html:not(.uk-touch) .uk-nav-offcanvas > li > a:focus { background: #404040; color: #ffffff; /* 2 */ outline: none; } /* * Active * `html .uk-nav` needed for higher specificity to override hover */ html .uk-nav.uk-nav-offcanvas > li.uk-active > a { background: #1a1a1a; color: #ffffff; } /* * Sub-object: `uk-nav-header` */ .uk-nav-offcanvas .uk-nav-header { color: #777777; } /* * Sub-object: `uk-nav-divider` */ .uk-nav-offcanvas .uk-nav-divider { border-top: 1px solid #1a1a1a; } /* * Nested items * No hover on touch devices because it behaves buggy in fixed offcanvas */ .uk-nav-offcanvas ul a { color: #cccccc; } html:not(.uk-touch) .uk-nav-offcanvas ul a:hover { color: #ffffff; } /* ======================================================================== Component: Navbar ========================================================================== */ .uk-navbar { background: #eeeeee; color: #444444; } /* * Micro clearfix */ .uk-navbar:before, .uk-navbar:after { content: " "; display: table; } .uk-navbar:after { clear: both; } /* Sub-object: `uk-navbar-nav` ========================================================================== */ .uk-navbar-nav { margin: 0; padding: 0; list-style: none; float: left; } /* * 1. Create position context for dropdowns */ .uk-navbar-nav > li { float: left; /* 1 */ position: relative; } /* * 1. Dimensions * 2. Style */ .uk-navbar-nav > li > a { display: block; -moz-box-sizing: border-box; box-sizing: border-box; text-decoration: none; /* 1 */ height: 40px; padding: 0 15px; line-height: 40px; /* 2 */ color: #444444; font-size: 14px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: normal; } /* Appear not as link */ .uk-navbar-nav > li > a[href='#'] { cursor: text; } /* * Hover * 1. Apply hover style also to focus state * 2. Also apply if dropdown is opened * 3. Remove default focus style */ .uk-navbar-nav > li:hover > a, .uk-navbar-nav > li > a:focus, .uk-navbar-nav > li.uk-open > a { background-color: #f5f5f5; color: #444444; /* 3 */ outline: none; } /* OnClick */ .uk-navbar-nav > li > a:active { background-color: #dddddd; color: #444444; } /* Active */ .uk-navbar-nav > li.uk-active > a { background-color: #f5f5f5; color: #444444; } /* Sub-objects: `uk-navbar-nav-subtitle` ========================================================================== */ .uk-navbar-nav .uk-navbar-nav-subtitle { line-height: 28px; } .uk-navbar-nav-subtitle > div { margin-top: -6px; font-size: 10px; line-height: 12px; } /* Sub-objects: `uk-navbar-content`, `uk-navbar-brand`, `uk-navbar-toggle` ========================================================================== */ /* * Imitate navbar items */ .uk-navbar-content, .uk-navbar-brand, .uk-navbar-toggle { -moz-box-sizing: border-box; box-sizing: border-box; display: block; height: 40px; padding: 0 15px; float: left; } /* * Helper to center all child elements vertically */ .uk-navbar-content:before, .uk-navbar-brand:before, .uk-navbar-toggle:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; } /* Sub-objects: `uk-navbar-content` ========================================================================== */ /* * Better sibling spacing */ .uk-navbar-content + .uk-navbar-content:not(.uk-navbar-center) { padding-left: 0; } /* * Link colors */ .uk-navbar-content > a:not([class]) { color: #0077dd; } .uk-navbar-content > a:not([class]):hover { color: #005599; } /* Sub-objects: `uk-navbar-brand` ========================================================================== */ .uk-navbar-brand { font-size: 18px; color: #444444; text-decoration: none; } /* * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-navbar-brand:hover, .uk-navbar-brand:focus { color: #444444; text-decoration: none; /* 2 */ outline: none; } /* Sub-object: `uk-navbar-toggle` ========================================================================== */ .uk-navbar-toggle { font-size: 18px; color: #444444; text-decoration: none; } /* * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-navbar-toggle:hover, .uk-navbar-toggle:focus { color: #444444; text-decoration: none; /* 2 */ outline: none; } /* * 1. Center icon vertically */ .uk-navbar-toggle:after { content: "\f0c9"; font-family: FontAwesome; /* 1 */ vertical-align: middle; } .uk-navbar-toggle-alt:after { content: "\f002"; } /* Sub-object: `uk-navbar-center` ========================================================================== */ /* * The element with this class needs to be last child in the navbar * 1. This hack is needed because other float elements shift centered text */ .uk-navbar-center { float: none; text-align: center; /* 1 */ max-width: 50%; margin-left: auto; margin-right: auto; } /* Sub-object: `uk-navbar-flip` ========================================================================== */ .uk-navbar-flip { float: right; } /* ======================================================================== Component: Subnav ========================================================================== */ /* * 1. Remove default list style * 2. Remove whitespace between child elements when using `inline-block` */ .uk-subnav { /* 1 */ padding: 0; list-style: none; /* 2 */ font-size: 0.001px; } /* Items ========================================================================== */ /* * 1. Create position context for dropdowns * 2. Reset whitespace hack */ .uk-subnav > li { /* 1 */ position: relative; /* 2 */ font-size: 1rem; vertical-align: top; } .uk-subnav > li, .uk-subnav > li > a, .uk-subnav > li > span { display: inline-block; } .uk-subnav > li:nth-child(n+2) { margin-left: 10px; } /* * Items */ .uk-subnav > li > a { color: #0077dd; } .uk-subnav > li > a:hover { color: #005599; } /* * Active */ /* * Disabled */ .uk-subnav > li > span { color: #999999; } /* Modifier: 'subnav-line' ========================================================================== */ .uk-subnav-line > li:nth-child(n+2):before { content: ""; display: inline-block; height: 10px; margin-right: 10px; border-left: 1px solid #dddddd; } /* Modifier: 'subnav-pill' ========================================================================== */ .uk-subnav-pill > li > a, .uk-subnav-pill > li > span { padding: 3px 9px; text-decoration: none; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-subnav-pill > li > a:hover, .uk-subnav-pill > li > a:focus { background: #eeeeee; color: #444444; /* 2 */ outline: none; } /* * Active * `li` needed for higher specificity to override hover */ .uk-subnav-pill > li.uk-active > a { background: #00a8e6; color: #ffffff; } /* ======================================================================== Component: Breadcrumb ========================================================================== */ /* * 1. Remove default list style * 2. Remove whitespace between child elements when using `inline-block` */ .uk-breadcrumb { /* 1 */ padding: 0; list-style: none; /* 2 */ font-size: 0.001px; } /* Items ========================================================================== */ /* * Reset whitespace hack */ .uk-breadcrumb > li { font-size: 1rem; vertical-align: top; } .uk-breadcrumb > li, .uk-breadcrumb > li > a, .uk-breadcrumb > li > span { display: inline-block; } .uk-breadcrumb > li:nth-child(n+2):before { content: "/"; display: inline-block; margin: 0 8px; } /* * Disabled */ .uk-breadcrumb > li:not(.uk-active) > span { color: #999999; } /* ======================================================================== Component: Pagination ========================================================================== */ /* * 1. Remove default list style * 2. Center pagination by default * 3. Remove whitespace between child elements when using `inline-block` */ .uk-pagination { /* 1 */ padding: 0; list-style: none; /* 2 */ text-align: center; /* 3 */ font-size: 0.001px; } /* * Micro clearfix * Needed if `uk-pagination-previous` or `uk-pagination-next` sub-objects are used */ .uk-pagination:before, .uk-pagination:after { content: " "; display: table; } .uk-pagination:after { clear: both; } /* Items ========================================================================== */ /* * 1. Reset whitespace hack * 2. Remove the gap at the bottom of it container */ .uk-pagination > li { display: inline-block; /* 1 */ font-size: 1rem; /* 2 */ vertical-align: top; } .uk-pagination > li:nth-child(n+2) { margin-left: 5px; } /* * 1. Makes pagination more robust against different box-sizing use * 2. Reset text-align to center if alignment modifier is used */ .uk-pagination > li > a, .uk-pagination > li > span { display: inline-block; min-width: 16px; padding: 3px 5px; line-height: 20px; text-decoration: none; /* 1 */ -moz-box-sizing: content-box; box-sizing: content-box; /* 2 */ text-align: center; } /* * Links */ .uk-pagination > li > a { background: #eeeeee; color: #444444; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-pagination > li > a:hover, .uk-pagination > li > a:focus { background-color: #f5f5f5; color: #444444; /* 2 */ outline: none; } /* OnClick */ .uk-pagination > li > a:active { background-color: #dddddd; color: #444444; } /* * Active */ .uk-pagination > .uk-active > span { background: #00a8e6; color: #ffffff; } /* * Disabled */ .uk-pagination > .uk-disabled > span { background-color: #f5f5f5; color: #999999; } /* Previous and next navigation ========================================================================== */ .uk-pagination-previous { float: left; } .uk-pagination-next { float: right; } /* Alignment modifiers ========================================================================== */ .uk-pagination-left { text-align: left; } .uk-pagination-right { text-align: right; } /* ======================================================================== Component: Tab ========================================================================== */ .uk-tab { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid #dddddd; } /* * Micro clearfix on the deepest container */ .uk-tab:before, .uk-tab:after { content: " "; display: table; } .uk-tab:after { clear: both; } /* * Items * 1. Create position context for dropdowns */ .uk-tab > li { margin-bottom: -1px; float: left; /* 1 */ position: relative; } .uk-tab > li > a { display: block; padding: 8px 12px 8px 12px; border: 1px solid transparent; border-bottom-width: 0; color: #0077dd; text-decoration: none; } .uk-tab > li:nth-child(n+2) > a { margin-left: 5px; } /* * Hover * 1. Apply hover style also to focus state * 2. Also apply if dropdown is opened * 3. Remove default focus style */ .uk-tab > li > a:hover, .uk-tab > li > a:focus, .uk-tab > li.uk-open > a { border-color: #f5f5f5; background: #f5f5f5; color: #005599; /* 2 */ outline: none; } .uk-tab > li:not(.uk-active) > a:hover, .uk-tab > li:not(.uk-active) > a:focus, .uk-tab > li.uk-open:not(.uk-active) > a { margin-bottom: 1px; padding-bottom: 7px; } /* Active */ .uk-tab > li.uk-active > a { border-color: #dddddd; border-bottom-color: transparent; background: #ffffff; color: #444444; } /* Disabled */ .uk-tab > li.uk-disabled > a { color: #999999; cursor: auto; } .uk-tab > li.uk-disabled > a:hover, .uk-tab > li.uk-disabled > a:focus, .uk-tab > li.uk-disabled.uk-active > a { background: none; border-color: transparent; } /* Modifier: 'tab-flip' ========================================================================== */ .uk-tab-flip > li { float: right; } .uk-tab-flip > li:nth-child(n+2) > a { margin-left: 0; margin-right: 5px; } /* Modifier: 'tab-responsive' ========================================================================== */ .uk-tab > li.uk-tab-responsive > a { margin-left: 0; margin-right: 0; } /* * Icon */ .uk-tab-responsive > a:before { content: "\f0c9\00a0"; font-family: FontAwesome; } /* Modifier: 'tab-center' ========================================================================== */ .uk-tab-center { border-bottom: 1px solid #dddddd; } .uk-tab-center-bottom { border-bottom: none; border-top: 1px solid #dddddd; } .uk-tab-center:before, .uk-tab-center:after { content: " "; display: table; } .uk-tab-center:after { clear: both; } /* * 1. Using `right` to prevent vertical scrollbar caused by centering if to many tabs */ .uk-tab-center .uk-tab { position: relative; right: 50%; border: none; float: right; } .uk-tab-center .uk-tab > li { position: relative; right: -50%; } .uk-tab-center .uk-tab > li > a { text-align: center; } /* Modifier: 'tab-bottom' ========================================================================== */ .uk-tab-bottom { border-top: 1px solid #dddddd; border-bottom: none; } .uk-tab-bottom > li { margin-top: -1px; margin-bottom: 0; } .uk-tab-bottom > li > a { padding-top: 8px; padding-bottom: 8px; border-bottom-width: 1px; border-top-width: 0; } .uk-tab-bottom > li:not(.uk-active) > a:hover, .uk-tab-bottom > li:not(.uk-active) > a:focus, .uk-tab-bottom > li.uk-open:not(.uk-active) > a { margin-bottom: 0; margin-top: 1px; padding-bottom: 8px; padding-top: 7px; } .uk-tab-bottom > li.uk-active > a { border-top-color: transparent; border-bottom-color: #dddddd; } /* Modifier: 'tab-grid' ========================================================================== */ /* * 1. Create position context to prevent hidden border because of negative `z-index` */ .uk-tab-grid { margin-left: -5px; border-bottom: none; /* 1 */ position: relative; z-index: 0; } .uk-tab-grid:before { display: block; position: absolute; left: 5px; right: 0; bottom: -1px; border-top: 1px solid #dddddd; /* 1 */ z-index: -1; } .uk-tab-grid > li:first-child > a { margin-left: 5px; } .uk-tab-grid > li > a { text-align: center; } /* * If `uk-tab-bottom` */ .uk-tab-grid.uk-tab-bottom { border-top: none; } .uk-tab-grid.uk-tab-bottom:before { top: -1px; bottom: auto; } /* Modifier: 'tab-left', 'tab-right' ========================================================================== */ /* Tablet and bigger */ @media (min-width: 768px) { .uk-tab-left, .uk-tab-right { border-bottom: none; } .uk-tab-left > li, .uk-tab-right > li { margin-bottom: 0; float: none; } .uk-tab-left > li > a, .uk-tab-right > li > a { padding-top: 8px; padding-bottom: 8px; } .uk-tab-left > li:nth-child(n+2) > a, .uk-tab-right > li:nth-child(n+2) > a { margin-left: 0; margin-top: 5px; } .uk-tab-left > li.uk-active > a, .uk-tab-right > li.uk-active > a { border-color: #dddddd; } /* * Modifier: 'tab-left' */ .uk-tab-left { border-right: 1px solid #dddddd; } .uk-tab-left > li { margin-right: -1px; } .uk-tab-left > li > a { border-bottom-width: 1px; border-right-width: 0; } .uk-tab-left > li:not(.uk-active) > a:hover, .uk-tab-left > li:not(.uk-active) > a:focus { margin-bottom: 0; margin-right: 1px; padding-bottom: 8px; padding-right: 11px; } .uk-tab-left > li.uk-active > a { border-right-color: transparent; } /* * Modifier: 'tab-right' */ .uk-tab-right { border-left: 1px solid #dddddd; } .uk-tab-right > li { margin-left: -1px; } .uk-tab-right > li > a { border-bottom-width: 1px; border-left-width: 0; } .uk-tab-right > li:not(.uk-active) > a:hover, .uk-tab-right > li:not(.uk-active) > a:focus { margin-bottom: 0; margin-left: 1px; padding-bottom: 8px; padding-left: 11px; } .uk-tab-right > li.uk-active > a { border-left-color: transparent; } } /* ======================================================================== Component: List ========================================================================== */ .uk-list { padding: 0; list-style: none; } /* * Micro clearfix to make list more robust */ .uk-list > li:before, .uk-list > li:after { content: " "; display: table; } .uk-list > li:after { clear: both; } /* * Remove margin from the last-child */ .uk-list > li > :last-child { margin-bottom: 0; } /* * Nested lists */ .uk-list ul { margin: 0; padding-left: 20px; list-style: none; } /* Modifier: `uk-list-line` ========================================================================== */ .uk-list-line > li:nth-child(n+2) { margin-top: 5px; padding-top: 5px; border-top: 1px solid #dddddd; } /* Modifier: `uk-list-striped` ========================================================================== */ .uk-list-striped > li { padding: 5px 5px; } .uk-list-striped > li:nth-of-type(odd) { background: #f5f5f5; } /* Modifier: `uk-list-space` ========================================================================== */ .uk-list-space > li:nth-child(n+2) { margin-top: 10px; } /* ======================================================================== Component: Description list ========================================================================== */ /* Modifier: `uk-description-list-horizontal` ========================================================================== */ /* Tablet and bigger */ @media (min-width: 768px) { .uk-description-list-horizontal { overflow: hidden; } .uk-description-list-horizontal > dt { width: 160px; float: left; clear: both; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .uk-description-list-horizontal > dd { margin-left: 180px; } } /* Modifier: `uk-description-list-line` ========================================================================== */ .uk-description-list-line > dt { font-weight: normal; } .uk-description-list-line > dt:nth-child(n+2) { margin-top: 5px; padding-top: 5px; border-top: 1px solid #dddddd; } .uk-description-list-line > dd { color: #999999; } /* ======================================================================== Component: Table ========================================================================== */ /* * 1. Remove most spacing between table cells. * 2. Block element behavior * 3. Style */ .uk-table { /* 1 */ border-collapse: collapse; border-spacing: 0; /* 2 */ width: 100%; /* 3 */ margin-bottom: 15px; } /* * Add margin if adjacent element */ * + .uk-table { margin-top: 15px; } .uk-table th, .uk-table td { padding: 8px 8px; } /* * Set alignment */ .uk-table th { text-align: left; } .uk-table td { vertical-align: top; } .uk-table thead th { vertical-align: bottom; } /* * Caption and footer */ .uk-table caption, .uk-table tfoot { font-size: 12px; font-style: italic; } .uk-table caption { text-align: left; color: #999999; } /* Sub-modifier: `uk-table-middle` ========================================================================== */ .uk-table-middle, .uk-table-middle td { vertical-align: middle !important; } /* Modifier: `uk-table-striped` ========================================================================== */ .uk-table-striped tbody tr:nth-of-type(odd) { background: #f5f5f5; } /* Modifier: `uk-table-condensed` ========================================================================== */ .uk-table-condensed td { padding: 4px 8px; } /* Modifier: `uk-table-hover` ========================================================================== */ .uk-table-hover tbody tr:hover { background: #eeeeee; } /* ======================================================================== Component: Form ========================================================================== */ /* * 1. Define consistent box sizing. * Default is `content-box` with following exceptions set to `border-box` * `button`, `select`, `input[type="checkbox"]` and `input[type="radio"]` * `input[type="search"]` in Chrome, Safari and Opera * `input[type="color"]` in Firefox * 2. Address margins set differently in Firefox/IE and Chrome/Safari/Opera. * 3. Remove `border-radius` in iOS. * 4. Correct `font` properties and `color` not being inherited. */ .uk-form input, .uk-form select, .uk-form textarea { /* 1 */ -moz-box-sizing: border-box; box-sizing: border-box; /* 2 */ margin: 0; /* 3 */ border-radius: 0; /* 4 */ font: inherit; color: inherit; } /* * Address inconsistent `text-transform` inheritance which is only inherit in Firefox */ .uk-form select { text-transform: none; } /* * 1. Correct `font` properties not being inherited. * 2. Don't inherit the `font-weight` and use `bold` instead. * NOTE: Both declarations don't work in Chrome, Safari and Opera. */ .uk-form optgroup { /* 1 */ font: inherit; /* 2 */ font-weight: bold; } /* * Removes inner padding and border in Firefox 4+. */ .uk-form input::-moz-focus-inner { border: 0; padding: 0; } /* * Removes excess padding in IE 8/9/10. */ .uk-form input[type="checkbox"], .uk-form input[type="radio"] { padding: 0; } /* * Improves consistency of cursor style for clickable elements */ .uk-form input[type="checkbox"]:not(:disabled), .uk-form input[type="radio"]:not(:disabled) { cursor: pointer; } /* * Remove default style in iOS. */ .uk-form textarea, .uk-form input:not([type]), .uk-form input[type="text"], .uk-form input[type="password"], .uk-form input[type="email"], .uk-form input[type="url"], .uk-form input[type="search"], .uk-form input[type="tel"], .uk-form input[type="number"], .uk-form input[type="datetime"] { -webkit-appearance: none; } /* * Remove inner padding and search cancel button in Chrome, Safari and Opera on OS X. */ .uk-form input[type="search"]::-webkit-search-cancel-button, .uk-form input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } /* * Fix the cursor style for Chrome's increment/decrement buttons. For certain * `font-size` values of the `input`, it causes the cursor style of the * decrement button to change from `default` to `text`. */ .uk-form input[type="number"]::-webkit-inner-spin-button, .uk-form input[type="number"]::-webkit-outer-spin-button { height: auto; } /* * Define consistent border, margin, and padding. */ .uk-form fieldset { border: none; margin: 0; padding: 0; } /* * 1. Remove default vertical scrollbar in IE 8/9/10/11. * 2. Improve readability and alignment in all browsers. */ .uk-form textarea { /* 1 */ overflow: auto; /* 2 */ vertical-align: top; } /* * Removes placeholder transparency in Firefox. */ .uk-form ::-moz-placeholder { opacity: 1; } /* * Removes `box-shadow` for invalid controls in Firefox. */ .uk-form :invalid { box-shadow: none; } /* * Vertical alignment */ .uk-form input:not([type="radio"]):not([type="checkbox"]), .uk-form select { vertical-align: middle; } /* Style ========================================================================== */ /* * Remove margin from the last-child */ .uk-form > :last-child { margin-bottom: 0; } /* * Controls * Except for `range`, `radio`, `checkbox`, `file`, `submit`, `reset`, `button` and `image` * 1. Must be `height` because `min-height` is not working in OSX * 2. Responsiveness: Sets a maximum width relative to the parent to scale on narrower viewports * 3. Vertical `padding` needed for `select` elements in Firefox * 4. Style */ .uk-form select, .uk-form textarea, .uk-form input:not([type]), .uk-form input[type="text"], .uk-form input[type="password"], .uk-form input[type="datetime"], .uk-form input[type="datetime-local"], .uk-form input[type="date"], .uk-form input[type="month"], .uk-form input[type="time"], .uk-form input[type="week"], .uk-form input[type="number"], .uk-form input[type="email"], .uk-form input[type="url"], .uk-form input[type="search"], .uk-form input[type="tel"], .uk-form input[type="color"] { /* 1 */ height: 30px; /* 2 */ max-width: 100%; /* 3 */ padding: 4px 6px; /* 4 */ border: 1px solid #dddddd; background: #ffffff; color: #444444; -webkit-transition: all linear 0.2s; transition: all linear 0.2s; } .uk-form select:focus, .uk-form textarea:focus, .uk-form input:not([type]):focus, .uk-form input[type="text"]:focus, .uk-form input[type="password"]:focus, .uk-form input[type="datetime"]:focus, .uk-form input[type="datetime-local"]:focus, .uk-form input[type="date"]:focus, .uk-form input[type="month"]:focus, .uk-form input[type="time"]:focus, .uk-form input[type="week"]:focus, .uk-form input[type="number"]:focus, .uk-form input[type="email"]:focus, .uk-form input[type="url"]:focus, .uk-form input[type="search"]:focus, .uk-form input[type="tel"]:focus, .uk-form input[type="color"]:focus { border-color: #99baca; outline: 0; background: #f5fbfe; color: #444444; } .uk-form select:disabled, .uk-form textarea:disabled, .uk-form input:not([type]):disabled, .uk-form input[type="text"]:disabled, .uk-form input[type="password"]:disabled, .uk-form input[type="datetime"]:disabled, .uk-form input[type="datetime-local"]:disabled, .uk-form input[type="date"]:disabled, .uk-form input[type="month"]:disabled, .uk-form input[type="time"]:disabled, .uk-form input[type="week"]:disabled, .uk-form input[type="number"]:disabled, .uk-form input[type="email"]:disabled, .uk-form input[type="url"]:disabled, .uk-form input[type="search"]:disabled, .uk-form input[type="tel"]:disabled, .uk-form input[type="color"]:disabled { border-color: #dddddd; background-color: #f5f5f5; color: #999999; } /* * Placeholder */ .uk-form :-ms-input-placeholder { color: #999999 !important; } .uk-form ::-moz-placeholder { color: #999999; } .uk-form ::-webkit-input-placeholder { color: #999999; } .uk-form :disabled:-ms-input-placeholder { color: #999999 !important; } .uk-form :disabled::-moz-placeholder { color: #999999; } .uk-form :disabled::-webkit-input-placeholder { color: #999999; } /* * Legend * 1. Behave like block element * 2. Correct `color` not being inherited in IE 8/9/10/11. * 3. Remove padding * 4. `margin-bottom` is not working in Safari and Opera. * Using `padding` and :after instead to create the border * 5. Style */ .uk-form legend { /* 1 */ width: 100%; /* 2 */ border: 0; /* 3 */ padding: 0; /* 4 */ padding-bottom: 15px; /* 5 */ font-size: 18px; line-height: 30px; } /* 4 */ .uk-form legend:after { content: ""; display: block; border-bottom: 1px solid #dddddd; } /* Size modifiers * Higher specificity needed to override defaults ========================================================================== */ select.uk-form-small, textarea.uk-form-small, input[type].uk-form-small, input:not([type]).uk-form-small { height: 25px; padding: 3px 3px; font-size: 12px; } select.uk-form-large, textarea.uk-form-large, input[type].uk-form-large, input:not([type]).uk-form-large { height: 40px; padding: 8px 6px; font-size: 16px; } /* Reset height * Must be after size modifiers ========================================================================== */ .uk-form textarea, .uk-form select[multiple], .uk-form select[size] { height: auto; } /* Validation states * Using !important to keep the selector simple ========================================================================== */ /* * Error state */ .uk-form-danger { border-color: #dc8d99 !important; background: #fff7f8 !important; color: #d85030 !important; } /* * Success state */ .uk-form-success { border-color: #8ec73b !important; background: #fafff2 !important; color: #659f13 !important; } /* Style modifiers * Using !important to keep the selector simple ========================================================================== */ /* * Blank form */ .uk-form-blank { border-color: transparent !important; border-style: dashed !important; background: none !important; } .uk-form-blank:focus { border-color: #dddddd !important; } /* Size sub-modifiers ========================================================================== */ /* * Fixed widths * Different widths for mini sized `input` and `select` elements */ input.uk-form-width-mini { width: 40px; } select.uk-form-width-mini { width: 65px; } .uk-form-width-small { width: 130px; } .uk-form-width-medium { width: 200px; } .uk-form-width-large { width: 500px; } /* Sub-objects: `uk-form-row` * Groups labels and controls in rows ========================================================================== */ /* * Micro clearfix * Needed for `uk-form-horizontal` modifier */ .uk-form-row:before, .uk-form-row:after { content: " "; display: table; } .uk-form-row:after { clear: both; } /* * Vertical gutter */ .uk-form-row + .uk-form-row { margin-top: 15px; } /* Help text * Sub-object: `uk-form-help-inline`, `uk-form-help-block` ========================================================================== */ .uk-form-help-inline { display: inline-block; margin: 0 0 0 10px; } .uk-form-help-block { margin: 5px 0 0 0; } /* Controls content * Sub-object: `uk-form-controls`, `uk-form-controls-condensed` ========================================================================== */ /* * Remove margins */ .uk-form-controls > :first-child { margin-top: 0; } .uk-form-controls > :last-child { margin-bottom: 0; } /* * Group controls and text into blocks with a small spacing between blocks */ .uk-form-controls-condensed { margin: 5px 0; } /* Modifier: `uk-form-stacked` * Requires sub-object: `uk-form-label` ========================================================================== */ .uk-form-stacked .uk-form-label { display: block; margin-bottom: 5px; font-weight: bold; } /* Modifier: `uk-form-horizontal` * Requires sub-objects: `uk-form-label`, `uk-form-controls` ========================================================================== */ /* Tablet portrait and smaller */ @media (max-width: 959px) { /* Behave like `uk-form-stacked` */ .uk-form-horizontal .uk-form-label { display: block; margin-bottom: 5px; font-weight: bold; } } /* Desktop and bigger */ @media (min-width: 960px) { .uk-form-horizontal .uk-form-label { width: 200px; margin-top: 5px; float: left; } .uk-form-horizontal .uk-form-controls { margin-left: 215px; } /* Better vertical alignment if controls are checkboxes and radio buttons with text */ .uk-form-horizontal .uk-form-controls-text { padding-top: 5px; } } /* Sub-object: `uk-form-icon` ========================================================================== */ /* * 1. Container width fits its content * 2. Create position context * 3. Prevent `inline-block` consequences */ .uk-form-icon { /* 1 */ display: inline-block; /* 2 */ position: relative; /* 3 */ max-width: 100%; } /* * 1. Make form element clickable through icon */ .uk-form-icon > [class*='uk-icon-'] { position: absolute; top: 50%; width: 30px; margin-top: -7px; font-size: 14px; color: #999999; text-align: center; /* 1 */ pointer-events: none; } .uk-form-icon:not(.uk-form-icon-flip) > input { padding-left: 30px !important; } /* * Sub-modifier: `uk-form-icon-flip` */ .uk-form-icon-flip > [class*='uk-icon-'] { right: 0; } .uk-form-icon-flip > input { padding-right: 30px !important; } /* ======================================================================== Component: Button ========================================================================== */ /* * Removes inner padding and border in Firefox 4+. */ .uk-button::-moz-focus-inner { border: 0; padding: 0; } /* * 1. Correct inability to style clickable `input` types in iOS. * 2. Remove margins in Chrome, Safari and Opera. * 3. Remove borders for `button`. * 4. Address `overflow` set to `hidden` in IE 8/9/10/11. * 5. Correct `font` properties and `color` not being inherited for `button`. * 6. Address inconsistent `text-transform` inheritance which is only inherit in Firefox and IE * 7. Style * 8. `line-height` is used to create a height * 9. `min-height` is necessary for `input` elements in Firefox and Opera because `line-height` is not working. * 10. Reset button group whitespace hack * 11. Required for `a`. */ .uk-button { /* 1 */ -webkit-appearance: none; /* 2 */ margin: 0; /* 3 */ border: none; /* 4 */ overflow: visible; /* 5 */ font: inherit; color: #444444; /* 6 */ text-transform: none; /* 7 */ display: inline-block; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 12px; background: #eeeeee; vertical-align: middle; /* 8 */ line-height: 30px; /* 9 */ min-height: 30px; /* 10 */ font-size: 1rem; /* 11 */ text-decoration: none; text-align: center; } .uk-button:not(:disabled) { cursor: pointer; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style * 3. Required for `a` elements */ .uk-button:hover, .uk-button:focus { background-color: #f5f5f5; color: #444444; /* 2 */ outline: none; /* 3 */ text-decoration: none; } /* Active */ .uk-button:active, .uk-button.uk-active { background-color: #dddddd; color: #444444; } /* Color modifiers ========================================================================== */ /* * Modifier: `uk-button-primary` */ .uk-button-primary { background-color: #00a8e6; color: #ffffff; } /* Hover */ .uk-button-primary:hover, .uk-button-primary:focus { background-color: #35b3ee; color: #ffffff; } /* Active */ .uk-button-primary:active, .uk-button-primary.uk-active { background-color: #0091ca; color: #ffffff; } /* * Modifier: `uk-button-success` */ .uk-button-success { background-color: #8cc14c; color: #ffffff; } /* Hover */ .uk-button-success:hover, .uk-button-success:focus { background-color: #8ec73b; color: #ffffff; } /* Active */ .uk-button-success:active, .uk-button-success.uk-active { background-color: #72ae41; color: #ffffff; } /* * Modifier: `uk-button-danger` */ .uk-button-danger { background-color: #da314b; color: #ffffff; } /* Hover */ .uk-button-danger:hover, .uk-button-danger:focus { background-color: #e4354f; color: #ffffff; } /* Active */ .uk-button-danger:active, .uk-button-danger.uk-active { background-color: #c91032; color: #ffffff; } /* Disabled state * Overrides also the color modifiers ========================================================================== */ /* Equal for all button types */ .uk-button:disabled { background-color: #f5f5f5; color: #999999; } /* Modifier: `uk-button-link` ========================================================================== */ /* Reset */ .uk-button-link, .uk-button-link:hover, .uk-button-link:focus, .uk-button-link:active, .uk-button-link.uk-active, .uk-button-link:disabled { border-color: transparent; background: none; } /* Color */ .uk-button-link { color: #0077dd; } .uk-button-link:hover, .uk-button-link:focus, .uk-button-link:active, .uk-button-link.uk-active { color: #005599; text-decoration: underline; } .uk-button-link:disabled { color: #999999; } /* Focus */ .uk-button-link:focus { outline: 1px dotted; } /* Size modifiers ========================================================================== */ .uk-button-mini { min-height: 20px; padding: 0 6px; line-height: 20px; font-size: 11px; } .uk-button-small { min-height: 25px; padding: 0 10px; line-height: 25px; font-size: 12px; } .uk-button-large { min-height: 40px; padding: 0 15px; line-height: 40px; font-size: 16px; } /* Sub-object `uk-button-group` ========================================================================== */ /* * 1. Behave like buttons * 2. Create position context for dropdowns * 3. Remove whitespace between child elements when using `inline-block` * 4. Prevent buttons from wrapping * 5. Remove whitespace between child elements when using `inline-block` */ .uk-button-group { /* 1 */ display: inline-block; vertical-align: middle; /* 2 */ position: relative; /* 3 */ font-size: 0.001px; /* 4 */ white-space: nowrap; } .uk-button-group > * { display: inline-block; } /* 5 */ .uk-button-group .uk-button { vertical-align: top; } /* Sub-object: `uk-button-dropdown` ========================================================================== */ /* * 1. Behave like buttons * 2. Create position context for dropdowns */ .uk-button-dropdown { /* 1 */ display: inline-block; vertical-align: middle; /* 2 */ position: relative; } /* ======================================================================== Component: Icon ========================================================================== */ @font-face { font-family: 'FontAwesome'; src: url("../fonts/fontawesome-webfont.eot"); src: url("../fonts/fontawesome-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/fontawesome-webfont.woff") format("woff"), url("../fonts/fontawesome-webfont.ttf") format("truetype"); font-weight: normal; font-style: normal; } /* * 1. Allow margin * 2. Prevent inherit font style * 4. Correct line-height * 5. Better font rendering */ [class*='uk-icon-'] { font-family: FontAwesome; /* 1 */ display: inline-block; /* 2 */ font-weight: normal; font-style: normal; /* 4 */ line-height: 1; /* 5 */ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } /* Size modifiers ========================================================================== */ .uk-icon-small:before { font-size: 150%; vertical-align: -10%; } .uk-icon-medium:before { font-size: 200%; vertical-align: -16%; } .uk-icon-large:before { font-size: 250%; vertical-align: -22%; } /* Modifier: `uk-icon-spin` ========================================================================== */ .uk-icon-spin { display: inline-block; -webkit-animation: uk-rotate 2s infinite linear; animation: uk-rotate 2s infinite linear; } /* Modifier: `uk-icon-button` ========================================================================== */ .uk-icon-button { -moz-box-sizing: border-box; box-sizing: border-box; display: inline-block; width: 35px; height: 35px; border-radius: 100%; background: #eeeeee; line-height: 35px; color: #444444; font-size: 18px; text-align: center; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style */ .uk-icon-button:hover, .uk-icon-button:focus { background-color: #f5f5f5; color: #444444; text-decoration: none; /* 2 */ outline: none; } /* Active */ .uk-icon-button:active { background-color: #dddddd; color: #444444; } /* Icon mapping ========================================================================== */ .uk-icon-glass:before { content: "\f000"; } .uk-icon-music:before { content: "\f001"; } .uk-icon-search:before { content: "\f002"; } .uk-icon-envelope-o:before { content: "\f003"; } .uk-icon-heart:before { content: "\f004"; } .uk-icon-star:before { content: "\f005"; } .uk-icon-star-o:before { content: "\f006"; } .uk-icon-user:before { content: "\f007"; } .uk-icon-film:before { content: "\f008"; } .uk-icon-th-large:before { content: "\f009"; } .uk-icon-th:before { content: "\f00a"; } .uk-icon-th-list:before { content: "\f00b"; } .uk-icon-check:before { content: "\f00c"; } .uk-icon-remove:before, .uk-icon-close:before, .uk-icon-times:before { content: "\f00d"; } .uk-icon-search-plus:before { content: "\f00e"; } .uk-icon-search-minus:before { content: "\f010"; } .uk-icon-power-off:before { content: "\f011"; } .uk-icon-signal:before { content: "\f012"; } .uk-icon-gear:before, .uk-icon-cog:before { content: "\f013"; } .uk-icon-trash-o:before { content: "\f014"; } .uk-icon-home:before { content: "\f015"; } .uk-icon-file-o:before { content: "\f016"; } .uk-icon-clock-o:before { content: "\f017"; } .uk-icon-road:before { content: "\f018"; } .uk-icon-download:before { content: "\f019"; } .uk-icon-arrow-circle-o-down:before { content: "\f01a"; } .uk-icon-arrow-circle-o-up:before { content: "\f01b"; } .uk-icon-inbox:before { content: "\f01c"; } .uk-icon-play-circle-o:before { content: "\f01d"; } .uk-icon-rotate-right:before, .uk-icon-repeat:before { content: "\f01e"; } .uk-icon-refresh:before { content: "\f021"; } .uk-icon-list-alt:before { content: "\f022"; } .uk-icon-lock:before { content: "\f023"; } .uk-icon-flag:before { content: "\f024"; } .uk-icon-headphones:before { content: "\f025"; } .uk-icon-volume-off:before { content: "\f026"; } .uk-icon-volume-down:before { content: "\f027"; } .uk-icon-volume-up:before { content: "\f028"; } .uk-icon-qrcode:before { content: "\f029"; } .uk-icon-barcode:before { content: "\f02a"; } .uk-icon-tag:before { content: "\f02b"; } .uk-icon-tags:before { content: "\f02c"; } .uk-icon-book:before { content: "\f02d"; } .uk-icon-bookmark:before { content: "\f02e"; } .uk-icon-print:before { content: "\f02f"; } .uk-icon-camera:before { content: "\f030"; } .uk-icon-font:before { content: "\f031"; } .uk-icon-bold:before { content: "\f032"; } .uk-icon-italic:before { content: "\f033"; } .uk-icon-text-height:before { content: "\f034"; } .uk-icon-text-width:before { content: "\f035"; } .uk-icon-align-left:before { content: "\f036"; } .uk-icon-align-center:before { content: "\f037"; } .uk-icon-align-right:before { content: "\f038"; } .uk-icon-align-justify:before { content: "\f039"; } .uk-icon-list:before { content: "\f03a"; } .uk-icon-dedent:before, .uk-icon-outdent:before { content: "\f03b"; } .uk-icon-indent:before { content: "\f03c"; } .uk-icon-video-camera:before { content: "\f03d"; } .uk-icon-photo:before, .uk-icon-image:before, .uk-icon-picture-o:before { content: "\f03e"; } .uk-icon-pencil:before { content: "\f040"; } .uk-icon-map-marker:before { content: "\f041"; } .uk-icon-adjust:before { content: "\f042"; } .uk-icon-tint:before { content: "\f043"; } .uk-icon-edit:before, .uk-icon-pencil-square-o:before { content: "\f044"; } .uk-icon-share-square-o:before { content: "\f045"; } .uk-icon-check-square-o:before { content: "\f046"; } .uk-icon-arrows:before { content: "\f047"; } .uk-icon-step-backward:before { content: "\f048"; } .uk-icon-fast-backward:before { content: "\f049"; } .uk-icon-backward:before { content: "\f04a"; } .uk-icon-play:before { content: "\f04b"; } .uk-icon-pause:before { content: "\f04c"; } .uk-icon-stop:before { content: "\f04d"; } .uk-icon-forward:before { content: "\f04e"; } .uk-icon-fast-forward:before { content: "\f050"; } .uk-icon-step-forward:before { content: "\f051"; } .uk-icon-eject:before { content: "\f052"; } .uk-icon-chevron-left:before { content: "\f053"; } .uk-icon-chevron-right:before { content: "\f054"; } .uk-icon-plus-circle:before { content: "\f055"; } .uk-icon-minus-circle:before { content: "\f056"; } .uk-icon-times-circle:before { content: "\f057"; } .uk-icon-check-circle:before { content: "\f058"; } .uk-icon-question-circle:before { content: "\f059"; } .uk-icon-info-circle:before { content: "\f05a"; } .uk-icon-crosshairs:before { content: "\f05b"; } .uk-icon-times-circle-o:before { content: "\f05c"; } .uk-icon-check-circle-o:before { content: "\f05d"; } .uk-icon-ban:before { content: "\f05e"; } .uk-icon-arrow-left:before { content: "\f060"; } .uk-icon-arrow-right:before { content: "\f061"; } .uk-icon-arrow-up:before { content: "\f062"; } .uk-icon-arrow-down:before { content: "\f063"; } .uk-icon-mail-forward:before, .uk-icon-share:before { content: "\f064"; } .uk-icon-expand:before { content: "\f065"; } .uk-icon-compress:before { content: "\f066"; } .uk-icon-plus:before { content: "\f067"; } .uk-icon-minus:before { content: "\f068"; } .uk-icon-asterisk:before { content: "\f069"; } .uk-icon-exclamation-circle:before { content: "\f06a"; } .uk-icon-gift:before { content: "\f06b"; } .uk-icon-leaf:before { content: "\f06c"; } .uk-icon-fire:before { content: "\f06d"; } .uk-icon-eye:before { content: "\f06e"; } .uk-icon-eye-slash:before { content: "\f070"; } .uk-icon-warning:before, .uk-icon-exclamation-triangle:before { content: "\f071"; } .uk-icon-plane:before { content: "\f072"; } .uk-icon-calendar:before { content: "\f073"; } .uk-icon-random:before { content: "\f074"; } .uk-icon-comment:before { content: "\f075"; } .uk-icon-magnet:before { content: "\f076"; } .uk-icon-chevron-up:before { content: "\f077"; } .uk-icon-chevron-down:before { content: "\f078"; } .uk-icon-retweet:before { content: "\f079"; } .uk-icon-shopping-cart:before { content: "\f07a"; } .uk-icon-folder:before { content: "\f07b"; } .uk-icon-folder-open:before { content: "\f07c"; } .uk-icon-arrows-v:before { content: "\f07d"; } .uk-icon-arrows-h:before { content: "\f07e"; } .uk-icon-bar-chart-o:before, .uk-icon-bar-chart:before { content: "\f080"; } .uk-icon-twitter-square:before { content: "\f081"; } .uk-icon-facebook-square:before { content: "\f082"; } .uk-icon-camera-retro:before { content: "\f083"; } .uk-icon-key:before { content: "\f084"; } .uk-icon-gears:before, .uk-icon-cogs:before { content: "\f085"; } .uk-icon-comments:before { content: "\f086"; } .uk-icon-thumbs-o-up:before { content: "\f087"; } .uk-icon-thumbs-o-down:before { content: "\f088"; } .uk-icon-star-half:before { content: "\f089"; } .uk-icon-heart-o:before { content: "\f08a"; } .uk-icon-sign-out:before { content: "\f08b"; } .uk-icon-linkedin-square:before { content: "\f08c"; } .uk-icon-thumb-tack:before { content: "\f08d"; } .uk-icon-external-link:before { content: "\f08e"; } .uk-icon-sign-in:before { content: "\f090"; } .uk-icon-trophy:before { content: "\f091"; } .uk-icon-github-square:before { content: "\f092"; } .uk-icon-upload:before { content: "\f093"; } .uk-icon-lemon-o:before { content: "\f094"; } .uk-icon-phone:before { content: "\f095"; } .uk-icon-square-o:before { content: "\f096"; } .uk-icon-bookmark-o:before { content: "\f097"; } .uk-icon-phone-square:before { content: "\f098"; } .uk-icon-twitter:before { content: "\f099"; } .uk-icon-facebook:before { content: "\f09a"; } .uk-icon-github:before { content: "\f09b"; } .uk-icon-unlock:before { content: "\f09c"; } .uk-icon-credit-card:before { content: "\f09d"; } .uk-icon-rss:before { content: "\f09e"; } .uk-icon-hdd-o:before { content: "\f0a0"; } .uk-icon-bullhorn:before { content: "\f0a1"; } .uk-icon-bell:before { content: "\f0f3"; } .uk-icon-certificate:before { content: "\f0a3"; } .uk-icon-hand-o-right:before { content: "\f0a4"; } .uk-icon-hand-o-left:before { content: "\f0a5"; } .uk-icon-hand-o-up:before { content: "\f0a6"; } .uk-icon-hand-o-down:before { content: "\f0a7"; } .uk-icon-arrow-circle-left:before { content: "\f0a8"; } .uk-icon-arrow-circle-right:before { content: "\f0a9"; } .uk-icon-arrow-circle-up:before { content: "\f0aa"; } .uk-icon-arrow-circle-down:before { content: "\f0ab"; } .uk-icon-globe:before { content: "\f0ac"; } .uk-icon-wrench:before { content: "\f0ad"; } .uk-icon-tasks:before { content: "\f0ae"; } .uk-icon-filter:before { content: "\f0b0"; } .uk-icon-briefcase:before { content: "\f0b1"; } .uk-icon-arrows-alt:before { content: "\f0b2"; } .uk-icon-group:before, .uk-icon-users:before { content: "\f0c0"; } .uk-icon-chain:before, .uk-icon-link:before { content: "\f0c1"; } .uk-icon-cloud:before { content: "\f0c2"; } .uk-icon-flask:before { content: "\f0c3"; } .uk-icon-cut:before, .uk-icon-scissors:before { content: "\f0c4"; } .uk-icon-copy:before, .uk-icon-files-o:before { content: "\f0c5"; } .uk-icon-paperclip:before { content: "\f0c6"; } .uk-icon-save:before, .uk-icon-floppy-o:before { content: "\f0c7"; } .uk-icon-square:before { content: "\f0c8"; } .uk-icon-navicon:before, .uk-icon-reorder:before, .uk-icon-bars:before { content: "\f0c9"; } .uk-icon-list-ul:before { content: "\f0ca"; } .uk-icon-list-ol:before { content: "\f0cb"; } .uk-icon-strikethrough:before { content: "\f0cc"; } .uk-icon-underline:before { content: "\f0cd"; } .uk-icon-table:before { content: "\f0ce"; } .uk-icon-magic:before { content: "\f0d0"; } .uk-icon-truck:before { content: "\f0d1"; } .uk-icon-pinterest:before { content: "\f0d2"; } .uk-icon-pinterest-square:before { content: "\f0d3"; } .uk-icon-google-plus-square:before { content: "\f0d4"; } .uk-icon-google-plus:before { content: "\f0d5"; } .uk-icon-money:before { content: "\f0d6"; } .uk-icon-caret-down:before { content: "\f0d7"; } .uk-icon-caret-up:before { content: "\f0d8"; } .uk-icon-caret-left:before { content: "\f0d9"; } .uk-icon-caret-right:before { content: "\f0da"; } .uk-icon-columns:before { content: "\f0db"; } .uk-icon-unsorted:before, .uk-icon-sort:before { content: "\f0dc"; } .uk-icon-sort-down:before, .uk-icon-sort-desc:before { content: "\f0dd"; } .uk-icon-sort-up:before, .uk-icon-sort-asc:before { content: "\f0de"; } .uk-icon-envelope:before { content: "\f0e0"; } .uk-icon-linkedin:before { content: "\f0e1"; } .uk-icon-rotate-left:before, .uk-icon-undo:before { content: "\f0e2"; } .uk-icon-legal:before, .uk-icon-gavel:before { content: "\f0e3"; } .uk-icon-dashboard:before, .uk-icon-tachometer:before { content: "\f0e4"; } .uk-icon-comment-o:before { content: "\f0e5"; } .uk-icon-comments-o:before { content: "\f0e6"; } .uk-icon-flash:before, .uk-icon-bolt:before { content: "\f0e7"; } .uk-icon-sitemap:before { content: "\f0e8"; } .uk-icon-umbrella:before { content: "\f0e9"; } .uk-icon-paste:before, .uk-icon-clipboard:before { content: "\f0ea"; } .uk-icon-lightbulb-o:before { content: "\f0eb"; } .uk-icon-exchange:before { content: "\f0ec"; } .uk-icon-cloud-download:before { content: "\f0ed"; } .uk-icon-cloud-upload:before { content: "\f0ee"; } .uk-icon-user-md:before { content: "\f0f0"; } .uk-icon-stethoscope:before { content: "\f0f1"; } .uk-icon-suitcase:before { content: "\f0f2"; } .uk-icon-bell-o:before { content: "\f0a2"; } .uk-icon-coffee:before { content: "\f0f4"; } .uk-icon-cutlery:before { content: "\f0f5"; } .uk-icon-file-text-o:before { content: "\f0f6"; } .uk-icon-building-o:before { content: "\f0f7"; } .uk-icon-hospital-o:before { content: "\f0f8"; } .uk-icon-ambulance:before { content: "\f0f9"; } .uk-icon-medkit:before { content: "\f0fa"; } .uk-icon-fighter-jet:before { content: "\f0fb"; } .uk-icon-beer:before { content: "\f0fc"; } .uk-icon-h-square:before { content: "\f0fd"; } .uk-icon-plus-square:before { content: "\f0fe"; } .uk-icon-angle-double-left:before { content: "\f100"; } .uk-icon-angle-double-right:before { content: "\f101"; } .uk-icon-angle-double-up:before { content: "\f102"; } .uk-icon-angle-double-down:before { content: "\f103"; } .uk-icon-angle-left:before { content: "\f104"; } .uk-icon-angle-right:before { content: "\f105"; } .uk-icon-angle-up:before { content: "\f106"; } .uk-icon-angle-down:before { content: "\f107"; } .uk-icon-desktop:before { content: "\f108"; } .uk-icon-laptop:before { content: "\f109"; } .uk-icon-tablet:before { content: "\f10a"; } .uk-icon-mobile-phone:before, .uk-icon-mobile:before { content: "\f10b"; } .uk-icon-circle-o:before { content: "\f10c"; } .uk-icon-quote-left:before { content: "\f10d"; } .uk-icon-quote-right:before { content: "\f10e"; } .uk-icon-spinner:before { content: "\f110"; } .uk-icon-circle:before { content: "\f111"; } .uk-icon-mail-reply:before, .uk-icon-reply:before { content: "\f112"; } .uk-icon-github-alt:before { content: "\f113"; } .uk-icon-folder-o:before { content: "\f114"; } .uk-icon-folder-open-o:before { content: "\f115"; } .uk-icon-smile-o:before { content: "\f118"; } .uk-icon-frown-o:before { content: "\f119"; } .uk-icon-meh-o:before { content: "\f11a"; } .uk-icon-gamepad:before { content: "\f11b"; } .uk-icon-keyboard-o:before { content: "\f11c"; } .uk-icon-flag-o:before { content: "\f11d"; } .uk-icon-flag-checkered:before { content: "\f11e"; } .uk-icon-terminal:before { content: "\f120"; } .uk-icon-code:before { content: "\f121"; } .uk-icon-mail-reply-all:before, .uk-icon-reply-all:before { content: "\f122"; } .uk-icon-star-half-empty:before, .uk-icon-star-half-full:before, .uk-icon-star-half-o:before { content: "\f123"; } .uk-icon-location-arrow:before { content: "\f124"; } .uk-icon-crop:before { content: "\f125"; } .uk-icon-code-fork:before { content: "\f126"; } .uk-icon-unlink:before, .uk-icon-chain-broken:before { content: "\f127"; } .uk-icon-question:before { content: "\f128"; } .uk-icon-info:before { content: "\f129"; } .uk-icon-exclamation:before { content: "\f12a"; } .uk-icon-superscript:before { content: "\f12b"; } .uk-icon-subscript:before { content: "\f12c"; } .uk-icon-eraser:before { content: "\f12d"; } .uk-icon-puzzle-piece:before { content: "\f12e"; } .uk-icon-microphone:before { content: "\f130"; } .uk-icon-microphone-slash:before { content: "\f131"; } .uk-icon-shield:before { content: "\f132"; } .uk-icon-calendar-o:before { content: "\f133"; } .uk-icon-fire-extinguisher:before { content: "\f134"; } .uk-icon-rocket:before { content: "\f135"; } .uk-icon-maxcdn:before { content: "\f136"; } .uk-icon-chevron-circle-left:before { content: "\f137"; } .uk-icon-chevron-circle-right:before { content: "\f138"; } .uk-icon-chevron-circle-up:before { content: "\f139"; } .uk-icon-chevron-circle-down:before { content: "\f13a"; } .uk-icon-html5:before { content: "\f13b"; } .uk-icon-css3:before { content: "\f13c"; } .uk-icon-anchor:before { content: "\f13d"; } .uk-icon-unlock-alt:before { content: "\f13e"; } .uk-icon-bullseye:before { content: "\f140"; } .uk-icon-ellipsis-h:before { content: "\f141"; } .uk-icon-ellipsis-v:before { content: "\f142"; } .uk-icon-rss-square:before { content: "\f143"; } .uk-icon-play-circle:before { content: "\f144"; } .uk-icon-ticket:before { content: "\f145"; } .uk-icon-minus-square:before { content: "\f146"; } .uk-icon-minus-square-o:before { content: "\f147"; } .uk-icon-level-up:before { content: "\f148"; } .uk-icon-level-down:before { content: "\f149"; } .uk-icon-check-square:before { content: "\f14a"; } .uk-icon-pencil-square:before { content: "\f14b"; } .uk-icon-external-link-square:before { content: "\f14c"; } .uk-icon-share-square:before { content: "\f14d"; } .uk-icon-compass:before { content: "\f14e"; } .uk-icon-toggle-down:before, .uk-icon-caret-square-o-down:before { content: "\f150"; } .uk-icon-toggle-up:before, .uk-icon-caret-square-o-up:before { content: "\f151"; } .uk-icon-toggle-right:before, .uk-icon-caret-square-o-right:before { content: "\f152"; } .uk-icon-euro:before, .uk-icon-eur:before { content: "\f153"; } .uk-icon-gbp:before { content: "\f154"; } .uk-icon-dollar:before, .uk-icon-usd:before { content: "\f155"; } .uk-icon-rupee:before, .uk-icon-inr:before { content: "\f156"; } .uk-icon-cny:before, .uk-icon-rmb:before, .uk-icon-yen:before, .uk-icon-jpy:before { content: "\f157"; } .uk-icon-ruble:before, .uk-icon-rouble:before, .uk-icon-rub:before { content: "\f158"; } .uk-icon-won:before, .uk-icon-krw:before { content: "\f159"; } .uk-icon-bitcoin:before, .uk-icon-btc:before { content: "\f15a"; } .uk-icon-file:before { content: "\f15b"; } .uk-icon-file-text:before { content: "\f15c"; } .uk-icon-sort-alpha-asc:before { content: "\f15d"; } .uk-icon-sort-alpha-desc:before { content: "\f15e"; } .uk-icon-sort-amount-asc:before { content: "\f160"; } .uk-icon-sort-amount-desc:before { content: "\f161"; } .uk-icon-sort-numeric-asc:before { content: "\f162"; } .uk-icon-sort-numeric-desc:before { content: "\f163"; } .uk-icon-thumbs-up:before { content: "\f164"; } .uk-icon-thumbs-down:before { content: "\f165"; } .uk-icon-youtube-square:before { content: "\f166"; } .uk-icon-youtube:before { content: "\f167"; } .uk-icon-xing:before { content: "\f168"; } .uk-icon-xing-square:before { content: "\f169"; } .uk-icon-youtube-play:before { content: "\f16a"; } .uk-icon-dropbox:before { content: "\f16b"; } .uk-icon-stack-overflow:before { content: "\f16c"; } .uk-icon-instagram:before { content: "\f16d"; } .uk-icon-flickr:before { content: "\f16e"; } .uk-icon-adn:before { content: "\f170"; } .uk-icon-bitbucket:before { content: "\f171"; } .uk-icon-bitbucket-square:before { content: "\f172"; } .uk-icon-tumblr:before { content: "\f173"; } .uk-icon-tumblr-square:before { content: "\f174"; } .uk-icon-long-arrow-down:before { content: "\f175"; } .uk-icon-long-arrow-up:before { content: "\f176"; } .uk-icon-long-arrow-left:before { content: "\f177"; } .uk-icon-long-arrow-right:before { content: "\f178"; } .uk-icon-apple:before { content: "\f179"; } .uk-icon-windows:before { content: "\f17a"; } .uk-icon-android:before { content: "\f17b"; } .uk-icon-linux:before { content: "\f17c"; } .uk-icon-dribbble:before { content: "\f17d"; } .uk-icon-skype:before { content: "\f17e"; } .uk-icon-foursquare:before { content: "\f180"; } .uk-icon-trello:before { content: "\f181"; } .uk-icon-female:before { content: "\f182"; } .uk-icon-male:before { content: "\f183"; } .uk-icon-gittip:before { content: "\f184"; } .uk-icon-sun-o:before { content: "\f185"; } .uk-icon-moon-o:before { content: "\f186"; } .uk-icon-archive:before { content: "\f187"; } .uk-icon-bug:before { content: "\f188"; } .uk-icon-vk:before { content: "\f189"; } .uk-icon-weibo:before { content: "\f18a"; } .uk-icon-renren:before { content: "\f18b"; } .uk-icon-pagelines:before { content: "\f18c"; } .uk-icon-stack-exchange:before { content: "\f18d"; } .uk-icon-arrow-circle-o-right:before { content: "\f18e"; } .uk-icon-arrow-circle-o-left:before { content: "\f190"; } .uk-icon-toggle-left:before, .uk-icon-caret-square-o-left:before { content: "\f191"; } .uk-icon-dot-circle-o:before { content: "\f192"; } .uk-icon-wheelchair:before { content: "\f193"; } .uk-icon-vimeo-square:before { content: "\f194"; } .uk-icon-turkish-lira:before, .uk-icon-try:before { content: "\f195"; } .uk-icon-plus-square-o:before { content: "\f196"; } .uk-icon-space-shuttle:before { content: "\f197"; } .uk-icon-slack:before { content: "\f198"; } .uk-icon-envelope-square:before { content: "\f199"; } .uk-icon-wordpress:before { content: "\f19a"; } .uk-icon-openid:before { content: "\f19b"; } .uk-icon-institution:before, .uk-icon-bank:before, .uk-icon-university:before { content: "\f19c"; } .uk-icon-mortar-board:before, .uk-icon-graduation-cap:before { content: "\f19d"; } .uk-icon-yahoo:before { content: "\f19e"; } .uk-icon-google:before { content: "\f1a0"; } .uk-icon-reddit:before { content: "\f1a1"; } .uk-icon-reddit-square:before { content: "\f1a2"; } .uk-icon-stumbleupon-circle:before { content: "\f1a3"; } .uk-icon-stumbleupon:before { content: "\f1a4"; } .uk-icon-delicious:before { content: "\f1a5"; } .uk-icon-digg:before { content: "\f1a6"; } .uk-icon-pied-piper:before { content: "\f1a7"; } .uk-icon-pied-piper-alt:before { content: "\f1a8"; } .uk-icon-drupal:before { content: "\f1a9"; } .uk-icon-joomla:before { content: "\f1aa"; } .uk-icon-language:before { content: "\f1ab"; } .uk-icon-fax:before { content: "\f1ac"; } .uk-icon-building:before { content: "\f1ad"; } .uk-icon-child:before { content: "\f1ae"; } .uk-icon-paw:before { content: "\f1b0"; } .uk-icon-spoon:before { content: "\f1b1"; } .uk-icon-cube:before { content: "\f1b2"; } .uk-icon-cubes:before { content: "\f1b3"; } .uk-icon-behance:before { content: "\f1b4"; } .uk-icon-behance-square:before { content: "\f1b5"; } .uk-icon-steam:before { content: "\f1b6"; } .uk-icon-steam-square:before { content: "\f1b7"; } .uk-icon-recycle:before { content: "\f1b8"; } .uk-icon-automobile:before, .uk-icon-car:before { content: "\f1b9"; } .uk-icon-cab:before, .uk-icon-taxi:before { content: "\f1ba"; } .uk-icon-tree:before { content: "\f1bb"; } .uk-icon-spotify:before { content: "\f1bc"; } .uk-icon-deviantart:before { content: "\f1bd"; } .uk-icon-soundcloud:before { content: "\f1be"; } .uk-icon-database:before { content: "\f1c0"; } .uk-icon-file-pdf-o:before { content: "\f1c1"; } .uk-icon-file-word-o:before { content: "\f1c2"; } .uk-icon-file-excel-o:before { content: "\f1c3"; } .uk-icon-file-powerpoint-o:before { content: "\f1c4"; } .uk-icon-file-photo-o:before, .uk-icon-file-picture-o:before, .uk-icon-file-image-o:before { content: "\f1c5"; } .uk-icon-file-zip-o:before, .uk-icon-file-archive-o:before { content: "\f1c6"; } .uk-icon-file-sound-o:before, .uk-icon-file-audio-o:before { content: "\f1c7"; } .uk-icon-file-movie-o:before, .uk-icon-file-video-o:before { content: "\f1c8"; } .uk-icon-file-code-o:before { content: "\f1c9"; } .uk-icon-vine:before { content: "\f1ca"; } .uk-icon-codepen:before { content: "\f1cb"; } .uk-icon-jsfiddle:before { content: "\f1cc"; } .uk-icon-life-bouy:before, .uk-icon-life-buoy:before, .uk-icon-life-saver:before, .uk-icon-support:before, .uk-icon-life-ring:before { content: "\f1cd"; } .uk-icon-circle-o-notch:before { content: "\f1ce"; } .uk-icon-ra:before, .uk-icon-rebel:before { content: "\f1d0"; } .uk-icon-ge:before, .uk-icon-empire:before { content: "\f1d1"; } .uk-icon-git-square:before { content: "\f1d2"; } .uk-icon-git:before { content: "\f1d3"; } .uk-icon-hacker-news:before { content: "\f1d4"; } .uk-icon-tencent-weibo:before { content: "\f1d5"; } .uk-icon-qq:before { content: "\f1d6"; } .uk-icon-wechat:before, .uk-icon-weixin:before { content: "\f1d7"; } .uk-icon-send:before, .uk-icon-paper-plane:before { content: "\f1d8"; } .uk-icon-send-o:before, .uk-icon-paper-plane-o:before { content: "\f1d9"; } .uk-icon-history:before { content: "\f1da"; } .uk-icon-circle-thin:before { content: "\f1db"; } .uk-icon-header:before { content: "\f1dc"; } .uk-icon-paragraph:before { content: "\f1dd"; } .uk-icon-sliders:before { content: "\f1de"; } .uk-icon-share-alt:before { content: "\f1e0"; } .uk-icon-share-alt-square:before { content: "\f1e1"; } .uk-icon-bomb:before { content: "\f1e2"; } .uk-icon-soccer-ball-o:before, .uk-icon-futbol-o:before { content: "\f1e3"; } .uk-icon-tty:before { content: "\f1e4"; } .uk-icon-binoculars:before { content: "\f1e5"; } .uk-icon-plug:before { content: "\f1e6"; } .uk-icon-slideshare:before { content: "\f1e7"; } .uk-icon-twitch:before { content: "\f1e8"; } .uk-icon-yelp:before { content: "\f1e9"; } .uk-icon-newspaper-o:before { content: "\f1ea"; } .uk-icon-wifi:before { content: "\f1eb"; } .uk-icon-calculator:before { content: "\f1ec"; } .uk-icon-paypal:before { content: "\f1ed"; } .uk-icon-google-wallet:before { content: "\f1ee"; } .uk-icon-cc-visa:before { content: "\f1f0"; } .uk-icon-cc-mastercard:before { content: "\f1f1"; } .uk-icon-cc-discover:before { content: "\f1f2"; } .uk-icon-cc-amex:before { content: "\f1f3"; } .uk-icon-cc-paypal:before { content: "\f1f4"; } .uk-icon-cc-stripe:before { content: "\f1f5"; } .uk-icon-bell-slash:before { content: "\f1f6"; } .uk-icon-bell-slash-o:before { content: "\f1f7"; } .uk-icon-trash:before { content: "\f1f8"; } .uk-icon-copyright:before { content: "\f1f9"; } .uk-icon-at:before { content: "\f1fa"; } .uk-icon-eyedropper:before { content: "\f1fb"; } .uk-icon-paint-brush:before { content: "\f1fc"; } .uk-icon-birthday-cake:before { content: "\f1fd"; } .uk-icon-area-chart:before { content: "\f1fe"; } .uk-icon-pie-chart:before { content: "\f200"; } .uk-icon-line-chart:before { content: "\f201"; } .uk-icon-lastfm:before { content: "\f202"; } .uk-icon-lastfm-square:before { content: "\f203"; } .uk-icon-toggle-off:before { content: "\f204"; } .uk-icon-toggle-on:before { content: "\f205"; } .uk-icon-bicycle:before { content: "\f206"; } .uk-icon-bus:before { content: "\f207"; } .uk-icon-ioxhost:before { content: "\f208"; } .uk-icon-angellist:before { content: "\f209"; } .uk-icon-cc:before { content: "\f20a"; } .uk-icon-shekel:before, .uk-icon-sheqel:before, .uk-icon-ils:before { content: "\f20b"; } .uk-icon-meanpath:before { content: "\f20c"; } /* ======================================================================== Component: Close ========================================================================== */ /* * Removes inner padding and border in Firefox 4+. */ .uk-close::-moz-focus-inner { border: 0; padding: 0; } /* * 1. Correct inability to style clickable `input` types in iOS. * 2. Remove margins in Chrome, Safari and Opera. * 3. Remove borders for `button`. * 4. Address `overflow` set to `hidden` in IE 8/9/10/11. * 5. Correct `font` properties and `color` not being inherited for `button`. * 6. Address inconsistent `text-transform` inheritance which is only inherit in Firefox and IE * 7. Remove default `button` padding and background color * 8. Style */ .uk-close { /* 1 */ -webkit-appearance: none; /* 2 */ margin: 0; /* 3 */ border: none; /* 4 */ overflow: visible; /* 5 */ font: inherit; color: inherit; /* 6 */ text-transform: none; /* 7. */ padding: 0; background: transparent; /* 8 */ display: inline-block; -moz-box-sizing: content-box; box-sizing: content-box; width: 20px; line-height: 20px; text-align: center; vertical-align: middle; opacity: 0.3; } /* Icon */ .uk-close:after { display: block; content: "\f00d"; font-family: FontAwesome; } /* * Hover * 1. Apply hover style also to focus state * 2. Remove default focus style * 3. Required for `a` elements */ .uk-close:hover, .uk-close:focus { opacity: 0.5; /* 2 */ outline: none; /* 3 */ color: inherit; text-decoration: none; cursor: pointer; } /* Modifier ========================================================================== */ .uk-close-alt { padding: 2px; border-radius: 50%; background: #eeeeee; opacity: 1; } /* Hover */ .uk-close-alt:hover, .uk-close-alt:focus { opacity: 1; } /* Icon */ .uk-close-alt:after { opacity: 0.5; } .uk-close-alt:hover:after, .uk-close-alt:focus:after { opacity: 0.8; } /* ======================================================================== Component: Badge ========================================================================== */ .uk-badge { display: inline-block; padding: 0 5px; background: #00a8e6; font-size: 10px; font-weight: bold; line-height: 14px; color: #ffffff; text-align: center; vertical-align: middle; text-transform: none; } /* * Keep color when badge is a link */ a.uk-badge:hover { color: #ffffff; } /* Modifier: `uk-badge-notification`; ========================================================================== */ .uk-badge-notification { -moz-box-sizing: border-box; box-sizing: border-box; min-width: 18px; border-radius: 500px; font-size: 12px; line-height: 18px; } /* Color modifier ========================================================================== */ /* * Modifier: `uk-badge-success` */ .uk-badge-success { background-color: #8cc14c; } /* * Modifier: `uk-badge-warning` */ .uk-badge-warning { background-color: #faa732; } /* * Modifier: `uk-badge-danger` */ .uk-badge-danger { background-color: #da314b; } /* ======================================================================== Component: Alert ========================================================================== */ .uk-alert { margin-bottom: 15px; padding: 10px; background: #ebf7fd; color: #2d7091; } /* * Add margin if adjacent element */ * + .uk-alert { margin-top: 15px; } /* * Remove margin from the last-child */ .uk-alert > :last-child { margin-bottom: 0; } /* * Keep color for headings if the default heading color is changed */ .uk-alert h1, .uk-alert h2, .uk-alert h3, .uk-alert h4, .uk-alert h5, .uk-alert h6 { color: inherit; } /* Close in alert ========================================================================== */ .uk-alert > .uk-close:first-child { float: right; } /* * Remove margin from adjacent element */ .uk-alert > .uk-close:first-child + * { margin-top: 0; } /* Modifier: `uk-alert-success` ========================================================================== */ .uk-alert-success { background: #f2fae3; color: #659f13; } /* Modifier: `uk-alert-warning` ========================================================================== */ .uk-alert-warning { background: #fffceb; color: #e28327; } /* Modifier: `uk-alert-danger` ========================================================================== */ .uk-alert-danger { background: #fff1f0; color: #d85030; } /* Modifier: `uk-alert-large` ========================================================================== */ .uk-alert-large { padding: 20px; } .uk-alert-large > .uk-close:first-child { margin: -10px -10px 0 0; } /* ======================================================================== Component: Thumbnail ========================================================================== */ /* * 1. Container width fits its content * 2. Responsive behavior * 3. Corrects `max-width` behavior sed * 4. Required for `figure` element * 5. Style */ .uk-thumbnail { /* 1 */ display: inline-block; /* 2 */ max-width: 100%; /* 3 */ -moz-box-sizing: border-box; box-sizing: border-box; /* 3 */ margin: 0; /* 4 */ padding: 4px; border: 1px solid #dddddd; background: #ffffff; } /* * Hover state for `a` elements * 1. Apply hover style also to focus state * 2. Needed for caption * 3. Remove default focus style */ a.uk-thumbnail:hover, a.uk-thumbnail:focus { border-color: #aaaaaa; background-color: #ffffff; /* 2 */ text-decoration: none; /* 3 */ outline: none; } /* Caption ========================================================================== */ .uk-thumbnail-caption { padding-top: 4px; text-align: center; color: #444444; } /* Sizes ========================================================================== */ .uk-thumbnail-mini { width: 150px; } .uk-thumbnail-small { width: 200px; } .uk-thumbnail-medium { width: 300px; } .uk-thumbnail-large { width: 400px; } .uk-thumbnail-expand, .uk-thumbnail-expand > img { width: 100%; } /* ======================================================================== Component: Overlay ========================================================================== */ /* * 1. Container width fits its content * 2. Create position context * 3. Set max-width for responsive images to prevent `inline-block` consequences * 4. Remove the gap between the container and its child element * 5. Fixed wrong scaling calculation for images in Chrome */ .uk-overlay { /* 1 */ display: inline-block; /* 2 */ position: relative; /* 3 */ max-width: 100%; /* 4 */ vertical-align: middle; /* 5 */ overflow: hidden; } /* * Remove margin from content */ .uk-overlay > :first-child { margin-bottom: 0; } /* Sub-object `uk-overlay-area` ========================================================================== */ /* * 1. Set position * 2. Set style * 3. Fade-in transition */ .uk-overlay-area { /* 1 */ position: absolute; top: 0; bottom: 0; left: 0; right: 0; /* 2 */ background: rgba(0, 0, 0, 0.3); /* 3 */ opacity: 0; -webkit-transition: opacity 0.15s linear; transition: opacity 0.15s linear; -webkit-transform: translate3d(0, 0, 0); } /* * Hover * 1. `uk-hover` to support touch devices * 2. Use optional `uk-overlay-toggle` to trigger the overlay earlier */ .uk-overlay:hover .uk-overlay-area, .uk-overlay.uk-hover .uk-overlay-area, .uk-overlay-toggle:hover .uk-overlay-area, .uk-overlay-toggle.uk-hover .uk-overlay-area { opacity: 1; } /* * Icon */ .uk-overlay-area:empty:before { content: "\f002"; position: absolute; top: 50%; left: 50%; width: 50px; height: 50px; margin-top: -25px; margin-left: -25px; font-size: 50px; line-height: 1; font-family: FontAwesome; text-align: center; color: #ffffff; } /* Sub-object `uk-overlay-area-content` ========================================================================== */ /* * Remove whitespace between child elements when using `inline-block` * Needed for Firefox */ .uk-overlay-area:not(:empty) { font-size: 0.001px; } /* * 1. Needed for vertical alignment */ .uk-overlay-area:not(:empty):before { content: ''; display: inline-block; height: 100%; vertical-align: middle; } /* * 1. Set vertical alignment * 2. Reset whitespace hack * 3. Set horizontal alignment * 4. Set style */ .uk-overlay-area-content { /* 1 */ display: inline-block; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; vertical-align: middle; /* 2 */ font-size: 1rem; /* 3 */ text-align: center; /* 4 */ padding: 0 15px; color: #ffffff; } /* * Remove margin from the last-child */ .uk-overlay-area-content > :last-child { margin-bottom: 0; } /* * Links in overlay area */ .uk-overlay-area-content a:not([class]), .uk-overlay-area-content a:not([class]):hover { color: inherit; } /* Sub-object `uk-overlay-caption` ========================================================================== */ /* * 1. Set position * 2. Set style * 3. Fade-in transition */ .uk-overlay-caption { /* 1 */ position: absolute; bottom: 0; left: 0; right: 0; /* 2 */ padding: 15px; background: rgba(0, 0, 0, 0.5); color: #ffffff; /* 3 */ opacity: 0; -webkit-transition: opacity 0.15s linear; transition: opacity 0.15s linear; -webkit-transform: translate3d(0, 0, 0); } /* * Hover * 1. `uk-hover` to support touch devices * 2. Use optional `uk-overlay-toggle` to trigger the overlay earlier */ .uk-overlay:hover .uk-overlay-caption, .uk-overlay.uk-hover .uk-overlay-caption, .uk-overlay-toggle:hover .uk-overlay-caption, .uk-overlay-toggle.uk-hover .uk-overlay-caption { opacity: 1; } /* ======================================================================== Component: Progress ========================================================================== */ /* * 1. Clearing * 2. Vertical alignment if text is used */ .uk-progress { -moz-box-sizing: border-box; box-sizing: border-box; height: 20px; margin-bottom: 15px; background: #eeeeee; /* 1 */ overflow: hidden; /* 2 */ line-height: 20px; } /* * Add margin if adjacent element */ * + .uk-progress { margin-top: 15px; } /* Sub-object: `uk-progress-bar` ========================================================================== */ /* * 1. Transition * 2. Needed for text */ .uk-progress-bar { width: 0; height: 100%; background: #00a8e6; float: left; /* 1 */ -webkit-transition: width 0.6s ease; transition: width 0.6s ease; /* 2 */ font-size: 12px; color: #ffffff; text-align: center; } /* Size modifiers ========================================================================== */ /* Mini */ .uk-progress-mini { height: 6px; } /* Small */ .uk-progress-small { height: 12px; } /* Color modifiers ========================================================================== */ .uk-progress-success .uk-progress-bar { background-color: #8cc14c; } .uk-progress-warning .uk-progress-bar { background-color: #faa732; } .uk-progress-danger .uk-progress-bar { background-color: #da314b; } /* Modifier: `uk-progress-striped` ========================================================================== */ .uk-progress-striped .uk-progress-bar { background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-size: 30px 30px; } /* * Animation */ .uk-progress-striped.uk-active .uk-progress-bar { -webkit-animation: uk-progress-bar-stripes 2s linear infinite; animation: uk-progress-bar-stripes 2s linear infinite; } @-webkit-keyframes uk-progress-bar-stripes { 0% { background-position: 0 0; } 100% { background-position: 30px 0; } } @keyframes uk-progress-bar-stripes { 0% { background-position: 0 0; } 100% { background-position: 30px 0; } } /* ======================================================================== Component: Animation ========================================================================== */ [class*='uk-animation-'] { -webkit-animation-duration: 0.5s; animation-duration: 0.5s; -webkit-animation-timing-function: ease-out; animation-timing-function: ease-out; -webkit-animation-fill-mode: both; animation-fill-mode: both; } /* Hide animated element if scrollspy is used */ @media screen { [data-uk-scrollspy*='uk-animation-'] { opacity: 0; } } /* * Fade * Higher specificity (!important) needed because of reverse modifier */ .uk-animation-fade { -webkit-animation-name: uk-fade; animation-name: uk-fade; -webkit-animation-duration: 0.8s; animation-duration: 0.8s; -webkit-animation-timing-function: linear !important; animation-timing-function: linear !important; } /* * Fade with scale */ .uk-animation-scale-up { -webkit-animation-name: uk-fade-scale-02; animation-name: uk-fade-scale-02; } .uk-animation-scale-down { -webkit-animation-name: uk-fade-scale-18; animation-name: uk-fade-scale-18; } /* * Fade with slide */ .uk-animation-slide-top { -webkit-animation-name: uk-fade-top; animation-name: uk-fade-top; } .uk-animation-slide-bottom { -webkit-animation-name: uk-fade-bottom; animation-name: uk-fade-bottom; } .uk-animation-slide-left { -webkit-animation-name: uk-fade-left; animation-name: uk-fade-left; } .uk-animation-slide-right { -webkit-animation-name: uk-fade-right; animation-name: uk-fade-right; } /* * Scale */ .uk-animation-scale { -webkit-animation-name: uk-scale-12; animation-name: uk-scale-12; } /* * Shake */ .uk-animation-shake { -webkit-animation-name: uk-shake; animation-name: uk-shake; } /* Direction modifiers ========================================================================== */ .uk-animation-reverse { -webkit-animation-direction: reverse; animation-direction: reverse; -webkit-animation-timing-function: ease-out; animation-timing-function: ease-out; } /* Duration modifiers ========================================================================== */ .uk-animation-10 { -webkit-animation-duration: 10s; animation-duration: 10s; } /* Origin modifiers ========================================================================== */ .uk-animation-top-left { -webkit-transform-origin: 0 0; transform-origin: 0 0; } .uk-animation-top-center { -webkit-transform-origin: 50% 0; transform-origin: 50% 0; } .uk-animation-top-right { -webkit-transform-origin: 100% 0; transform-origin: 100% 0; } .uk-animation-middle-left { -webkit-transform-origin: 0 50%; transform-origin: 0 50%; } .uk-animation-middle-right { -webkit-transform-origin: 100% 50%; transform-origin: 100% 50%; } .uk-animation-bottom-left { -webkit-transform-origin: 0 100%; transform-origin: 0 100%; } .uk-animation-bottom-center { -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; } .uk-animation-bottom-right { -webkit-transform-origin: 100% 100%; transform-origin: 100% 100%; } /* Keyframes: Fade * Used by dropdown, datepicker and slideshow component ========================================================================== */ @-webkit-keyframes uk-fade { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes uk-fade { 0% { opacity: 0; } 100% { opacity: 1; } } /* Keyframes: Fade with slide ========================================================================== */ /* * Top */ @-webkit-keyframes uk-fade-top { 0% { opacity: 0; -webkit-transform: translateY(-100%); } 100% { opacity: 1; -webkit-transform: translateY(0); } } @keyframes uk-fade-top { 0% { opacity: 0; transform: translateY(-100%); } 100% { opacity: 1; transform: translateY(0); } } /* * Bottom */ @-webkit-keyframes uk-fade-bottom { 0% { opacity: 0; -webkit-transform: translateY(100%); } 100% { opacity: 1; -webkit-transform: translateY(0); } } @keyframes uk-fade-bottom { 0% { opacity: 0; transform: translateY(100%); } 100% { opacity: 1; transform: translateY(0); } } /* * Left */ @-webkit-keyframes uk-fade-left { 0% { opacity: 0; -webkit-transform: translateX(-100%); } 100% { opacity: 1; -webkit-transform: translateX(0); } } @keyframes uk-fade-left { 0% { opacity: 0; transform: translateX(-100%); } 100% { opacity: 1; transform: translateX(0); } } /* * Right */ @-webkit-keyframes uk-fade-right { 0% { opacity: 0; -webkit-transform: translateX(100%); } 100% { opacity: 1; -webkit-transform: translateX(0); } } @keyframes uk-fade-right { 0% { opacity: 0; transform: translateX(100%); } 100% { opacity: 1; transform: translateX(0); } } /* Keyframes: Fade with scale ========================================================================== */ /* * Scale by 0.2 */ @-webkit-keyframes uk-fade-scale-02 { 0% { opacity: 0; -webkit-transform: scale(0.2); } 100% { opacity: 1; -webkit-transform: scale(1); } } @keyframes uk-fade-scale-02 { 0% { opacity: 0; transform: scale(0.2); } 100% { opacity: 1; transform: scale(1); } } /* * Scale by 1.5 * Used by slideshow component */ @-webkit-keyframes uk-fade-scale-15 { 0% { opacity: 0; -webkit-transform: scale(1.5); } 100% { opacity: 1; -webkit-transform: scale(1); } } @keyframes uk-fade-scale-15 { 0% { opacity: 0; transform: scale(1.5); } 100% { opacity: 1; transform: scale(1); } } /* * Scale by 1.8 */ @-webkit-keyframes uk-fade-scale-18 { 0% { opacity: 0; -webkit-transform: scale(1.8); } 100% { opacity: 1; -webkit-transform: scale(1); } } @keyframes uk-fade-scale-18 { 0% { opacity: 0; transform: scale(1.8); } 100% { opacity: 1; transform: scale(1); } } /* Keyframes: Slide * Used by slideshow component ========================================================================== */ /* * Left */ @-webkit-keyframes uk-slide-left { 0% { -webkit-transform: translateX(-100%); } 100% { -webkit-transform: translateX(0); } } @keyframes uk-slide-left { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } } /* * Right */ @-webkit-keyframes uk-slide-right { 0% { -webkit-transform: translateX(100%); } 100% { -webkit-transform: translateX(0); } } @keyframes uk-slide-right { 0% { transform: translateX(100%); } 100% { transform: translateX(0); } } /* * Left third */ @-webkit-keyframes uk-slide-left-33 { 0% { -webkit-transform: translateX(33%); } 100% { -webkit-transform: translateX(0); } } @keyframes uk-slide-left-33 { 0% { transform: translateX(33%); } 100% { transform: translateX(0); } } /* * Right third */ @-webkit-keyframes uk-slide-right-33 { 0% { -webkit-transform: translateX(-33%); } 100% { -webkit-transform: translateX(0); } } @keyframes uk-slide-right-33 { 0% { transform: translateX(-33%); } 100% { transform: translateX(0); } } /* Keyframes: Scale ========================================================================== */ @-webkit-keyframes uk-scale-12 { 0% { -webkit-transform: scale(1.2); } 100% { -webkit-transform: scale(1); } } @keyframes uk-scale-12 { 0% { transform: scale(1.2); } 100% { transform: scale(1); } } /* Keyframes: Rotate * Used by icon and search component ========================================================================== */ @-webkit-keyframes uk-rotate { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(359deg); } } @keyframes uk-rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(359deg); } } /* Keyframes: Shake ========================================================================== */ @-webkit-keyframes uk-shake { 0%, 100% { -webkit-transform: translateX(0); } 10% { -webkit-transform: translateX(-9px); } 20% { -webkit-transform: translateX(8px); } 30% { -webkit-transform: translateX(-7px); } 40% { -webkit-transform: translateX(6px); } 50% { -webkit-transform: translateX(-5px); } 60% { -webkit-transform: translateX(4px); } 70% { -webkit-transform: translateX(-3px); } 80% { -webkit-transform: translateX(2px); } 90% { -webkit-transform: translateX(-1px); } } @keyframes uk-shake { 0%, 100% { transform: translateX(0); } 10% { transform: translateX(-9px); } 20% { transform: translateX(8px); } 30% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 50% { transform: translateX(-5px); } 60% { transform: translateX(4px); } 70% { transform: translateX(-3px); } 80% { transform: translateX(2px); } 90% { transform: translateX(-1px); } } /* Keyframes: Fade with slide fixed * Used by dropdown and search component ========================================================================== */ /* * Top fixed */ @-webkit-keyframes uk-slide-top-fixed { 0% { opacity: 0; -webkit-transform: translateY(-10px); } 100% { opacity: 1; -webkit-transform: translateY(0); } } @keyframes uk-slide-top-fixed { 0% { opacity: 0; transform: translateY(-10px); } 100% { opacity: 1; transform: translateY(0); } } /* * Bottom fixed */ @-webkit-keyframes uk-slide-bottom-fixed { 0% { opacity: 0; -webkit-transform: translateY(10px); } 100% { opacity: 1; -webkit-transform: translateY(0); } } @keyframes uk-slide-bottom-fixed { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } } /* ======================================================================== Component: Dropdown ========================================================================== */ /* * 1. Hide by default * 2. Set position * 3. Box-sizing is needed for `uk-dropdown-justify` * 4. Set style * 5. Reset button group whitespace hack */ .uk-dropdown { /* 1 */ display: none; /* 2 */ position: absolute; top: 100%; left: 0; z-index: 1020; /* 3 */ -moz-box-sizing: border-box; box-sizing: border-box; /* 4 */ width: 200px; margin-top: 5px; padding: 15px; background: #f5f5f5; color: #444444; /* 5 */ font-size: 1rem; vertical-align: top; } /* * 1. Show dropdown * 2. Set animation * 3. Needed for scale animation */ .uk-open > .uk-dropdown { /* 1 */ display: block; /* 2 */ -webkit-animation: uk-fade 0.2s ease-in-out; animation: uk-fade 0.2s ease-in-out; /* 3 */ -webkit-transform-origin: 0 0; transform-origin: 0 0; } /* Alignment modifiers ========================================================================== */ /* * Modifier `uk-dropdown-flip` */ .uk-dropdown-flip { left: auto; right: 0; } /* * Modifier `uk-dropdown-up` */ .uk-dropdown-up { top: auto; bottom: 100%; margin-top: auto; margin-bottom: 5px; } /* Nav in dropdown ========================================================================== */ .uk-dropdown .uk-nav { margin: 0 -15px; } /* Grid and panel in dropdown ========================================================================== */ /* * Vertical gutter */ /* * Grid * Higher specificity to override large gutter */ .uk-grid .uk-dropdown-grid + .uk-dropdown-grid { margin-top: 15px; } /* Panels */ .uk-dropdown-grid > [class*='uk-width-'] > .uk-panel + .uk-panel { margin-top: 15px; } /* Tablet and bigger */ @media (min-width: 768px) { /* * Horizontal gutter */ .uk-dropdown:not(.uk-dropdown-stack) > .uk-dropdown-grid { margin-left: -15px; margin-right: -15px; } .uk-dropdown:not(.uk-dropdown-stack) > .uk-dropdown-grid > [class*='uk-width-'] { padding-left: 15px; padding-right: 15px; } /* * Column divider */ .uk-dropdown:not(.uk-dropdown-stack) > .uk-dropdown-grid > [class*='uk-width-']:nth-child(n+2) { border-left: 1px solid #dddddd; } /* * Width multiplier for dropdown columns */ .uk-dropdown-width-2:not(.uk-dropdown-stack) { width: 400px; } .uk-dropdown-width-3:not(.uk-dropdown-stack) { width: 600px; } .uk-dropdown-width-4:not(.uk-dropdown-stack) { width: 800px; } .uk-dropdown-width-5:not(.uk-dropdown-stack) { width: 1000px; } } /* Phone landscape and smaller */ @media (max-width: 767px) { /* * Stack columns and take full width */ .uk-dropdown-grid > [class*='uk-width-'] { width: 100%; } /* * Vertical gutter */ .uk-dropdown-grid > [class*='uk-width-']:nth-child(n+2) { margin-top: 15px; } } /* * Stack grid columns */ .uk-dropdown-stack > .uk-dropdown-grid > [class*='uk-width-'] { width: 100%; } .uk-dropdown-stack > .uk-dropdown-grid > [class*='uk-width-']:nth-child(n+2) { margin-top: 15px; } /* Modifier `uk-dropdown-small` ========================================================================== */ /* * Set min-width and text expands dropdown if needed */ .uk-dropdown-small { min-width: 150px; width: auto; padding: 5px; white-space: nowrap; } /* * Nav in dropdown */ .uk-dropdown-small .uk-nav { margin: 0 -5px; } /* Modifier: `uk-dropdown-navbar` ========================================================================== */ .uk-dropdown-navbar { margin-top: 0; background: #f5f5f5; color: #444444; } .uk-open > .uk-dropdown-navbar { -webkit-animation: uk-slide-top-fixed 0.2s ease-in-out; animation: uk-slide-top-fixed 0.2s ease-in-out; } /* Modifier `uk-dropdown-scrollable` ========================================================================== */ /* * Usefull for long lists */ .uk-dropdown-scrollable { overflow-y: auto; max-height: 200px; } /* ======================================================================== Component: Modal ========================================================================== */ /* * This is the modal overlay and modal dialog container * 1. Hide by default * 2. Set fixed position * 3. Allow scrolling for the modal dialog * 4. Mask the background page * 5. Fade-in transition */ .uk-modal { /* 1 */ display: none; /* 2 */ position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1010; /* 3 */ overflow-y: auto; -webkit-overflow-scrolling: touch; /* 4 */ background: rgba(0, 0, 0, 0.6); /* 5 */ opacity: 0; -webkit-transition: opacity 0.15s linear; transition: opacity 0.15s linear; } /* * Open state */ .uk-modal.uk-open { opacity: 1; } /* * Prevents duplicated scrollbar caused by 4. */ .uk-modal-page, .uk-modal-page body { overflow: hidden; } /* Sub-object: `uk-modal-dialog` ========================================================================== */ /* * 1. Create position context for `uk-modal-dialog-frameless` * 2. Set box sizing * 3. Set style * 4. Slide-in transition */ .uk-modal-dialog { /* 1 */ position: relative; /* 2 */ -moz-box-sizing: border-box; box-sizing: border-box; margin: 50px auto; padding: 20px; width: 600px; max-width: 100%; max-width: calc(100% - 20px); /* 3 */ background: #ffffff; /* 4 */ opacity: 0; -webkit-transform: translateY(-100px); transform: translateY(-100px); -webkit-transition: opacity 0.3s linear, -webkit-transform 0.3s ease-out; transition: opacity 0.3s linear, transform 0.3s ease-out; } /* Phone landscape and smaller */ @media (max-width: 767px) { /* * Fit in small screen */ .uk-modal-dialog { width: auto; margin: 10px; } } /* * Open state */ .uk-open .uk-modal-dialog { /* 4 */ opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); } /* * Remove margin from the last-child */ .uk-modal-dialog > :last-child { margin-bottom: 0; } /* Close in modal ========================================================================== */ .uk-modal-dialog > .uk-close:first-child { margin: -10px -10px 0 0; float: right; } /* * Remove margin from adjacent element */ .uk-modal-dialog > .uk-close:first-child + * { margin-top: 0; } /* Modifier: `uk-modal-dialog-frameless` ========================================================================== */ .uk-modal-dialog-frameless { padding: 0; } /* * Close in modal */ .uk-modal-dialog-frameless > .uk-close:first-child { position: absolute; top: -12px; right: -12px; margin: 0; float: none; } /* Phone landscape and smaller */ @media (max-width: 767px) { .uk-modal-dialog-frameless > .uk-close:first-child { top: -7px; right: -7px; } } /* Modifier: `uk-modal-dialog-large` ========================================================================== */ /* Tablet and bigger */ @media (min-width: 768px) { .uk-modal-dialog-large { width: 930px; } } /* Large screen and bigger */ @media (min-width: 1220px) { .uk-modal-dialog-large { width: 1130px; } } /* ======================================================================== Component: Off-canvas ========================================================================== */ /* * This is the offcanvas overlay and bar container * 1. Hide by default * 2. Set fixed position * 3. Mask the background page */ .uk-offcanvas { /* 1 */ display: none; /* 2 */ position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; /* 3 */ background: rgba(0, 0, 0, 0.1); } .uk-offcanvas.uk-active { display: block; } /* Sub-object `uk-offcanvas-page` ========================================================================== */ /* * Prepares the whole HTML page to slide-out * 1. Fix the main page and disallow scrolling * 2. Side-out transition */ .uk-offcanvas-page { /* 1 */ position: fixed; /* 2 */ -webkit-transition: margin-left 0.3s ease-in-out; transition: margin-left 0.3s ease-in-out; } /* Sub-object `uk-offcanvas-bar` ========================================================================== */ /* * This is the offcanvas bar * 1. Set fixed position * 2. Size and style * 3. Allow scrolling * 4. Side-out transition */ .uk-offcanvas-bar { /* 1 */ position: fixed; top: 0; bottom: 0; left: 0; -webkit-transform: translateX(-100%); transform: translateX(-100%); z-index: 1001; /* 2 */ width: 270px; max-width: 100%; background: #333333; /* 3 */ overflow-y: auto; -webkit-overflow-scrolling: touch; /* 4 */ -webkit-transition: -webkit-transform 0.3s ease-in-out; transition: transform 0.3s ease-in-out; } .uk-offcanvas.uk-active .uk-offcanvas-bar.uk-offcanvas-bar-show { -webkit-transform: translateX(0%); transform: translateX(0%); } /* Modifier `uk-offcanvas-bar-flip` ========================================================================== */ .uk-offcanvas-bar-flip { left: auto; right: 0; -webkit-transform: translateX(100%); transform: translateX(100%); } /* Panel in offcanvas ========================================================================== */ .uk-offcanvas .uk-panel { margin: 20px 15px; color: #777777; } .uk-offcanvas .uk-panel-title { color: #cccccc; } .uk-offcanvas .uk-panel a:not([class]) { color: #cccccc; } .uk-offcanvas .uk-panel a:not([class]):hover { color: #ffffff; } /* ======================================================================== Component: Switcher ========================================================================== */ .uk-switcher { margin: 0; padding: 0; list-style: none; } /* * Items */ .uk-switcher > *:not(.uk-active) { display: none; } /* ======================================================================== Component: Tooltip ========================================================================== */ /* * 1. Hide by default * 2. Set fixed position * 3. Set dimensions * 4. Set style */ .uk-tooltip { /* 1 */ display: none; /* 2 */ position: absolute; z-index: 1030; /* 3 */ -moz-box-sizing: border-box; box-sizing: border-box; max-width: 200px; padding: 5px 8px; /* 4 */ background: #333333; color: rgba(255, 255, 255, 0.7); font-size: 12px; line-height: 18px; text-align: center; } /* Triangle ========================================================================== */ /* * 1. Dashed is less antialised than solid */ .uk-tooltip:after { content: ""; display: block; position: absolute; width: 0; height: 0; /* 1 */ border: 5px dashed #333333; } /* Direction modifiers ========================================================================== */ /* * Top */ .uk-tooltip-top:after, .uk-tooltip-top-left:after, .uk-tooltip-top-right:after { bottom: -5px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; border-top-color: #333333; } /* * Bottom */ .uk-tooltip-bottom:after, .uk-tooltip-bottom-left:after, .uk-tooltip-bottom-right:after { top: -5px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent; border-bottom-color: #333333; } /* * Top/Bottom center */ .uk-tooltip-top:after, .uk-tooltip-bottom:after { left: 50%; margin-left: -5px; } /* * Top/Bottom left */ .uk-tooltip-top-left:after, .uk-tooltip-bottom-left:after { left: 10px; } /* * Top/Bottom right */ .uk-tooltip-top-right:after, .uk-tooltip-bottom-right:after { right: 10px; } /* * Left */ .uk-tooltip-left:after { right: -5px; top: 50%; margin-top: -5px; border-left-style: solid; border-right: none; border-top-color: transparent; border-bottom-color: transparent; border-left-color: #333333; } /* * Right */ .uk-tooltip-right:after { left: -5px; top: 50%; margin-top: -5px; border-right-style: solid; border-left: none; border-top-color: transparent; border-bottom-color: transparent; border-right-color: #333333; } /* ======================================================================== Component: Text ========================================================================== */ /* Size modifiers ========================================================================== */ .uk-text-small { font-size: 11px; line-height: 16px; } .uk-text-large { font-size: 18px; line-height: 24px; font-weight: normal; } /* Weight modifiers ========================================================================== */ .uk-text-bold { font-weight: bold; } /* Color modifiers ========================================================================== */ .uk-text-muted { color: #999999 !important; } .uk-text-primary { color: #2d7091 !important; } .uk-text-success { color: #659f13 !important; } .uk-text-warning { color: #e28327 !important; } .uk-text-danger { color: #d85030 !important; } /* Alignment modifiers ========================================================================== */ .uk-text-left { text-align: left !important; } .uk-text-right { text-align: right !important; } .uk-text-center { text-align: center !important; } .uk-text-justify { text-align: justify !important; } .uk-text-top { vertical-align: top !important; } .uk-text-middle { vertical-align: middle !important; } .uk-text-bottom { vertical-align: bottom !important; } /* Only tablets portrait */ @media (max-width: 959px) { .uk-text-center-medium { text-align: center !important; } } /* Phone landscape and smaller */ @media (max-width: 767px) { .uk-text-center-small { text-align: center !important; } } /* Wrap modifiers ========================================================================== */ /* * Prevent text from wrapping onto multiple lines */ .uk-text-nowrap { white-space: nowrap; } /* * Prevent text from wrapping onto multiple lines, and truncate with an ellipsis */ .uk-text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* * Break strings if their length exceeds the width of their container */ .uk-text-break { word-wrap: break-word; -webkit-hyphens: auto; -ms-hyphens: auto; -moz-hyphens: auto; hyphens: auto; } /* ======================================================================== Component: Utility ========================================================================== */ /* Container ========================================================================== */ .uk-container { -moz-box-sizing: border-box; box-sizing: border-box; max-width: 980px; padding: 0 25px; } /* Large screen and bigger */ @media (min-width: 1220px) { .uk-container { max-width: 1200px; padding: 0 35px; } } /* * Micro clearfix */ .uk-container:before, .uk-container:after { content: " "; display: table; } .uk-container:after { clear: both; } /* * Center container */ .uk-container-center { margin-left: auto; margin-right: auto; } /* Clearing ========================================================================== */ /* * Micro clearfix */ .uk-clearfix:before, .uk-clearfix:after { content: " "; display: table; } .uk-clearfix:after { clear: both; } /* * Create a new block formatting context */ .uk-nbfc { overflow: hidden; } .uk-nbfc-alt { display: table-cell; width: 10000px; } /* Alignment of block elements ========================================================================== */ /* * Float blocks * 1. Prevent content overflow on small devices */ .uk-float-left { float: left; } .uk-float-right { float: right; } /* 1 */ [class*='uk-float-'] { max-width: 100%; } /* Alignment of images and objects ========================================================================== */ /* * Alignment */ [class*='uk-align-'] { display: block; margin-bottom: 15px; } .uk-align-left { margin-right: 15px; float: left; } .uk-align-right { margin-left: 15px; float: right; } /* Tablet and bigger */ @media (min-width: 768px) { .uk-align-medium-left { margin-right: 15px; margin-bottom: 15px; float: left; } .uk-align-medium-right { margin-left: 15px; margin-bottom: 15px; float: right; } } .uk-align-center { margin-left: auto; margin-right: auto; } /* Vertical alignment ========================================================================== */ /* * Remove whitespace between child elements when using `inline-block` */ .uk-vertical-align { font-size: 0.001px; } /* * The `uk-vertical-align` container needs a specific height */ .uk-vertical-align:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; } /* * Sub-object which can have any height * 1. Reset whitespace hack */ .uk-vertical-align-middle, .uk-vertical-align-bottom { display: inline-block; max-width: 100%; /* 1 */ font-size: 1rem; } .uk-vertical-align-middle { vertical-align: middle; } .uk-vertical-align-bottom { vertical-align: bottom; } /* Height ========================================================================== */ /* * More robust if padding and border are used */ [class*='uk-height'] { -moz-box-sizing: border-box; box-sizing: border-box; } /* * Useful to extend the `html` and `body` element to the full height of the page. */ .uk-height-1-1 { height: 100%; } /* * Useful to create image teasers */ .uk-height-viewport { height: 100vh; min-height: 600px; } /* Responsive objects * Note: Images are already responsive by default, see Base component ========================================================================== */ /* * 1. Corrects `max-width` and `max-height` behavior if padding and border are used */ .uk-responsive-width, .uk-responsive-height { -moz-box-sizing: border-box; box-sizing: border-box; } /* * Responsiveness: Sets a maximum width relative to the parent and auto scales the height */ .uk-responsive-width { max-width: 100%; height: auto; } /* * Responsiveness: Sets a maximum height relative to the parent and auto scales the width * Only works if the parent element has a fixed height. */ .uk-responsive-height { max-height: 100%; width: auto; } /* Margin ========================================================================== */ /* * Create a block with the same margin of a paragraph * Add margin if adjacent element */ .uk-margin { margin-bottom: 15px; } * + .uk-margin { margin-top: 15px; } .uk-margin-top { margin-top: 15px !important; } .uk-margin-bottom { margin-bottom: 15px !important; } .uk-margin-left { margin-left: 15px !important; } .uk-margin-right { margin-right: 15px !important; } /* * Larger margins */ .uk-margin-large { margin-bottom: 50px; } * + .uk-margin-large { margin-top: 50px; } .uk-margin-large-top { margin-top: 50px !important; } .uk-margin-large-bottom { margin-bottom: 50px !important; } .uk-margin-large-left { margin-left: 50px !important; } .uk-margin-large-right { margin-right: 50px !important; } /* * Smaller margins */ .uk-margin-small { margin-bottom: 5px; } * + .uk-margin-small { margin-top: 5px; } .uk-margin-small-top { margin-top: 5px !important; } .uk-margin-small-bottom { margin-bottom: 5px !important; } .uk-margin-small-left { margin-left: 5px !important; } .uk-margin-small-right { margin-right: 5px !important; } /* * Remove margins */ .uk-margin-remove { margin: 0 !important; } .uk-margin-top-remove { margin-top: 0 !important; } .uk-margin-bottom-remove { margin-bottom: 0 !important; } /* Border ========================================================================== */ .uk-border-circle { border-radius: 50%; } .uk-border-rounded { border-radius: 5px; } /* Headings ========================================================================== */ /* Tablet and bigger */ @media (min-width: 768px) { .uk-heading-large { font-size: 52px; line-height: 64px; } } /* Link ========================================================================== */ /* * Let links appear in default text color */ .uk-link-muted, .uk-link-muted a { color: #444444; } .uk-link-muted:hover, .uk-link-muted a:hover { color: #444444; } /* * Reset link style */ .uk-link-reset, .uk-link-reset a, .uk-link-reset:hover, .uk-link-reset a:hover { color: inherit; text-decoration: none; } /* Scrollable ========================================================================== */ /* * Enable scrolling for preformatted text */ .uk-scrollable-text { height: 300px; overflow-y: scroll; -webkit-overflow-scrolling: touch; resize: both; } /* * Box with scrolling enabled */ .uk-scrollable-box { -moz-box-sizing: border-box; box-sizing: border-box; height: 170px; padding: 10px; border: 1px solid #dddddd; overflow: auto; -webkit-overflow-scrolling: touch; resize: both; } .uk-scrollable-box > :last-child { margin-bottom: 0; } /* Overflow ========================================================================== */ /* * Enable scrollbars if content is clipped */ .uk-overflow-container { overflow: auto; -webkit-overflow-scrolling: touch; } .uk-overflow-container > :last-child { margin-bottom: 0; } /* Position ========================================================================== */ .uk-position-absolute { position: absolute !important; } .uk-position-relative { position: relative !important; } .uk-position-cover { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } /* Display ========================================================================== */ /* * Display */ .uk-display-block { display: block !important; } .uk-display-inline { display: inline !important; } .uk-display-inline-block { display: inline-block !important; } /* * Visibility * Avoids setting display to `block` so it works also with `inline-block` and `table` */ /* Desktop and bigger */ @media (min-width: 960px) { .uk-visible-small { display: none !important; } .uk-visible-medium { display: none !important; } .uk-hidden-large { display: none !important; } } /* Tablets portrait */ @media (min-width: 768px) and (max-width: 959px) { .uk-visible-small { display: none !important; } .uk-visible-large { display: none !important ; } .uk-hidden-medium { display: none !important; } } /* Phone landscape and smaller*/ @media (max-width: 767px) { .uk-visible-medium { display: none !important; } .uk-visible-large { display: none !important; } .uk-hidden-small { display: none !important; } } /* Remove from the flow and screen readers on any device */ .uk-hidden { display: none !important; visibility: hidden !important; } /* It's hidden, but still affects layout */ .uk-invisible { visibility: hidden !important; } /* Show on hover */ .uk-visible-hover:hover .uk-hidden, .uk-visible-hover:hover .uk-invisible { display: block !important; visibility: visible !important; } .uk-visible-hover-inline:hover .uk-hidden, .uk-visible-hover-inline:hover .uk-invisible { display: inline-block !important; visibility: visible !important; } /* ======================================================================== Component: Print ========================================================================== */ @media print { * { background: transparent !important; color: black !important; box-shadow: none !important; text-shadow: none !important; } a, a:visited { text-decoration: underline; } pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } thead { display: table-header-group; } tr, img { page-break-inside: avoid; } img { max-width: 100% !important; } @page { margin: 0.5cm; } p, h2, h3 { orphans: 3; widows: 3; } h2, h3 { page-break-after: avoid; } }
// SPDX-License-Identifier: GPL-2.0 /* * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on * sys_sparc32 * * Copyright (C) 2000 VA Linux Co * Copyright (C) 2000 Don Dugger <n0ano@valinux.com> * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com> * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 2000 Hewlett-Packard Co. * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com> * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port) * * These routines maintain argument size conversion between 32bit and 64bit * environment. In 2.5 most of this should be moved to a generic directory. * * This file assumes that there is a hole at the end of user address space. * * Some of the functions are LE specific currently. These are * hopefully all marked. This should be fixed. */ #include <linux/kernel.h> #include <linux/sched.h> #include <linux/fs.h> #include <linux/file.h> #include <linux/signal.h> #include <linux/syscalls.h> #include <linux/times.h> #include <linux/utsname.h> #include <linux/mm.h> #include <linux/uio.h> #include <linux/poll.h> #include <linux/personality.h> #include <linux/stat.h> #include <linux/rwsem.h> #include <linux/compat.h> #include <linux/vfs.h> #include <linux/ptrace.h> #include <linux/highuid.h> #include <linux/sysctl.h> #include <linux/slab.h> #include <linux/sched/task.h> #include <asm/mman.h> #include <asm/types.h> #include <linux/uaccess.h> #include <linux/atomic.h> #include <asm/vgtod.h> #include <asm/ia32.h> #define AA(__x) ((unsigned long)(__x)) SYSCALL_DEFINE3(ia32_truncate64, const char __user *, filename, unsigned long, offset_low, unsigned long, offset_high) { return ksys_truncate(filename, ((loff_t) offset_high << 32) | offset_low); } SYSCALL_DEFINE3(ia32_ftruncate64, unsigned int, fd, unsigned long, offset_low, unsigned long, offset_high) { return ksys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low); } /* warning: next two assume little endian */ SYSCALL_DEFINE5(ia32_pread64, unsigned int, fd, char __user *, ubuf, u32, count, u32, poslo, u32, poshi) { return ksys_pread64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo)); } SYSCALL_DEFINE5(ia32_pwrite64, unsigned int, fd, const char __user *, ubuf, u32, count, u32, poslo, u32, poshi) { return ksys_pwrite64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo)); } /* * Some system calls that need sign extended arguments. This could be * done by a generic wrapper. */ SYSCALL_DEFINE6(ia32_fadvise64_64, int, fd, __u32, offset_low, __u32, offset_high, __u32, len_low, __u32, len_high, int, advice) { return ksys_fadvise64_64(fd, (((u64)offset_high)<<32) | offset_low, (((u64)len_high)<<32) | len_low, advice); } SYSCALL_DEFINE4(ia32_readahead, int, fd, unsigned int, off_lo, unsigned int, off_hi, size_t, count) { return ksys_readahead(fd, ((u64)off_hi << 32) | off_lo, count); } SYSCALL_DEFINE6(ia32_sync_file_range, int, fd, unsigned int, off_low, unsigned int, off_hi, unsigned int, n_low, unsigned int, n_hi, int, flags) { return ksys_sync_file_range(fd, ((u64)off_hi << 32) | off_low, ((u64)n_hi << 32) | n_low, flags); } SYSCALL_DEFINE5(ia32_fadvise64, int, fd, unsigned int, offset_lo, unsigned int, offset_hi, size_t, len, int, advice) { return ksys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo, len, advice); } SYSCALL_DEFINE6(ia32_fallocate, int, fd, int, mode, unsigned int, offset_lo, unsigned int, offset_hi, unsigned int, len_lo, unsigned int, len_hi) { return ksys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo, ((u64)len_hi << 32) | len_lo); } #ifdef CONFIG_IA32_EMULATION /* * Another set for IA32/LFS -- x86_64 struct stat is different due to * support for 64bit inode numbers. */ static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat) { typeof(ubuf->st_uid) uid = 0; typeof(ubuf->st_gid) gid = 0; SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid)); SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid)); if (!user_write_access_begin(ubuf, sizeof(struct stat64))) return -EFAULT; unsafe_put_user(huge_encode_dev(stat->dev), &ubuf->st_dev, Efault); unsafe_put_user(stat->ino, &ubuf->__st_ino, Efault); unsafe_put_user(stat->ino, &ubuf->st_ino, Efault); unsafe_put_user(stat->mode, &ubuf->st_mode, Efault); unsafe_put_user(stat->nlink, &ubuf->st_nlink, Efault); unsafe_put_user(uid, &ubuf->st_uid, Efault); unsafe_put_user(gid, &ubuf->st_gid, Efault); unsafe_put_user(huge_encode_dev(stat->rdev), &ubuf->st_rdev, Efault); unsafe_put_user(stat->size, &ubuf->st_size, Efault); unsafe_put_user(stat->atime.tv_sec, &ubuf->st_atime, Efault); unsafe_put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec, Efault); unsafe_put_user(stat->mtime.tv_sec, &ubuf->st_mtime, Efault); unsafe_put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec, Efault); unsafe_put_user(stat->ctime.tv_sec, &ubuf->st_ctime, Efault); unsafe_put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec, Efault); unsafe_put_user(stat->blksize, &ubuf->st_blksize, Efault); unsafe_put_user(stat->blocks, &ubuf->st_blocks, Efault); user_access_end(); return 0; Efault: user_write_access_end(); return -EFAULT; } COMPAT_SYSCALL_DEFINE2(ia32_stat64, const char __user *, filename, struct stat64 __user *, statbuf) { struct kstat stat; int ret = vfs_stat(filename, &stat); if (!ret) ret = cp_stat64(statbuf, &stat); return ret; } COMPAT_SYSCALL_DEFINE2(ia32_lstat64, const char __user *, filename, struct stat64 __user *, statbuf) { struct kstat stat; int ret = vfs_lstat(filename, &stat); if (!ret) ret = cp_stat64(statbuf, &stat); return ret; } COMPAT_SYSCALL_DEFINE2(ia32_fstat64, unsigned int, fd, struct stat64 __user *, statbuf) { struct kstat stat; int ret = vfs_fstat(fd, &stat); if (!ret) ret = cp_stat64(statbuf, &stat); return ret; } COMPAT_SYSCALL_DEFINE4(ia32_fstatat64, unsigned int, dfd, const char __user *, filename, struct stat64 __user *, statbuf, int, flag) { struct kstat stat; int error; error = vfs_fstatat(dfd, filename, &stat, flag); if (error) return error; return cp_stat64(statbuf, &stat); } /* * Linux/i386 didn't use to be able to handle more than * 4 system call parameters, so these system calls used a memory * block for parameter passing.. */ struct mmap_arg_struct32 { unsigned int addr; unsigned int len; unsigned int prot; unsigned int flags; unsigned int fd; unsigned int offset; }; COMPAT_SYSCALL_DEFINE1(ia32_mmap, struct mmap_arg_struct32 __user *, arg) { struct mmap_arg_struct32 a; if (copy_from_user(&a, arg, sizeof(a))) return -EFAULT; if (a.offset & ~PAGE_MASK) return -EINVAL; return ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset>>PAGE_SHIFT); } /* * The 32-bit clone ABI is CONFIG_CLONE_BACKWARDS */ COMPAT_SYSCALL_DEFINE5(ia32_clone, unsigned long, clone_flags, unsigned long, newsp, int __user *, parent_tidptr, unsigned long, tls_val, int __user *, child_tidptr) { struct kernel_clone_args args = { .flags = (clone_flags & ~CSIGNAL), .pidfd = parent_tidptr, .child_tid = child_tidptr, .parent_tid = parent_tidptr, .exit_signal = (clone_flags & CSIGNAL), .stack = newsp, .tls = tls_val, }; return kernel_clone(&args); } #endif /* CONFIG_IA32_EMULATION */
If you want to give me some feedback or make a suggestion, create an [issue on GitHub](https://github.com/filp/whoops/issues/new). If you want to get your hands dirty, great! Here's a couple of steps/guidelines: - See [a list of possible features to add](https://github.com/filp/whoops/wiki/Possible-features-to-add) for ideas on what can be improved. - Add tests for your changes (in `tests/`). - Remember to stick to the existing code style as best as possible. When in doubt, follow `PSR-2`. - Before investing a lot of time coding, create an issue to get our opinion on your big changes. - Update the documentation, if applicable. - If you want to add an integration to a web framework, please [review our guidelines for that](docs/Framework%20Integration.md#contributing-an-integration-with-a-framework). In `PrettyPageHandler` we are using a Zepto library, but if you are only familiar with jQuery, note that it is pretty much identical.
<div class="bs-docs-section"> <h1 id="tabs" class="page-header">Togglable tabs <small>tab.js</small></h1> <h2 id="tabs-examples">Example tabs</h2> <p>Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus.</p> <div class="bs-example bs-example-tabs"> <ul id="myTab" class="nav nav-tabs" role="tablist"> <li class="active"><a href="#home" role="tab" data-toggle="tab">Home</a></li> <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li> <li class="dropdown"> <a href="#" id="myTabDrop1" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu" role="menu" aria-labelledby="myTabDrop1"> <li><a href="#dropdown1" tabindex="-1" role="tab" data-toggle="tab">@fat</a></li> <li><a href="#dropdown2" tabindex="-1" role="tab" data-toggle="tab">@mdo</a></li> </ul> </li> </ul> <div id="myTabContent" class="tab-content"> <div class="tab-pane fade in active" id="home"> <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p> </div> <div class="tab-pane fade" id="profile"> <p>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p> </div> <div class="tab-pane fade" id="dropdown1"> <p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p> </div> <div class="tab-pane fade" id="dropdown2"> <p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p> </div> </div> </div><!-- /example --> <div class="bs-callout bs-callout-info"> <h4>Extends tabbed navigation</h4> <p>This plugin extends the <a href="../components/#nav-tabs">tabbed navigation component</a> to add tabbable areas.</p> </div> <h2 id="tabs-usage">Usage</h2> <p>Enable tabbable tabs via JavaScript (each tab needs to be activated individually):</p> {% highlight js %} $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) {% endhighlight %} <p>You can activate individual tabs in several ways:</p> {% highlight js %} $('#myTab a[href="#profile"]').tab('show') // Select tab by name $('#myTab a:first').tab('show') // Select first tab $('#myTab a:last').tab('show') // Select last tab $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) {% endhighlight %} <h3>Markup</h3> <p>You can activate a tab or pill navigation without writing any JavaScript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the Bootstrap <a href="../components/#nav-tabs">tab styling</a>, while adding the <code>nav</code> and <code>nav-pills</code> classes will apply <a href="../components/#nav-pills">pill styling</a>.</p> {% highlight html %} <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li class="active"><a href="#home" role="tab" data-toggle="tab">Home</a></li> <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li> <li><a href="#messages" role="tab" data-toggle="tab">Messages</a></li> <li><a href="#settings" role="tab" data-toggle="tab">Settings</a></li> </ul> <!-- Tab panes --> <div class="tab-content"> <div class="tab-pane active" id="home">...</div> <div class="tab-pane" id="profile">...</div> <div class="tab-pane" id="messages">...</div> <div class="tab-pane" id="settings">...</div> </div> {% endhighlight %} <h3>Fade effect</h3> <p>To make tabs fade in, add <code>.fade</code> to each <code>.tab-pane</code>. The first tab pane must also have <code>.in</code> to properly fade in initial content.</p> {% highlight html %} <div class="tab-content"> <div class="tab-pane fade in active" id="home">...</div> <div class="tab-pane fade" id="profile">...</div> <div class="tab-pane fade" id="messages">...</div> <div class="tab-pane fade" id="settings">...</div> </div> {% endhighlight %} <h3>Methods</h3> <h4>$().tab</h4> <p> Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM. </p> {% highlight html %} <ul class="nav nav-tabs" role="tablist" id="myTab"> <li class="active"><a href="#home" role="tab" data-toggle="tab">Home</a></li> <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li> <li><a href="#messages" role="tab" data-toggle="tab">Messages</a></li> <li><a href="#settings" role="tab" data-toggle="tab">Settings</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="home">...</div> <div class="tab-pane" id="profile">...</div> <div class="tab-pane" id="messages">...</div> <div class="tab-pane" id="settings">...</div> </div> <script> $(function () { $('#myTab a:last').tab('show') }) </script> {% endhighlight %} <h3>Events</h3> <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width: 150px;">Event Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>show.bs.tab</td> <td>This event fires on tab show, but before the new tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td> </tr> <tr> <td>shown.bs.tab</td> <td>This event fires on tab show after a tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td> </tr> </tbody> </table> </div><!-- /.table-responsive --> {% highlight js %} $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { e.target // activated tab e.relatedTarget // previous tab }) {% endhighlight %} </div>
<?php /** * @package Joomla.Site * @subpackage Layout * * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('JPATH_BASE') or die; JHtml::_('bootstrap.framework'); $canEdit = $displayData['params']->get('access-edit'); ?> <div class="icons"> <?php if (empty($displayData['print'])) : ?> <?php if ($canEdit || $displayData['params']->get('show_print_icon') || $displayData['params']->get('show_email_icon')) : ?> <div class="btn-group pull-right"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span><span class="caret"></span> </a> <?php // Note the actions class is deprecated. Use dropdown-menu instead. ?> <ul class="dropdown-menu"> <?php if ($displayData['params']->get('show_print_icon')) : ?> <li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $displayData['item'], $displayData['params']); ?> </li> <?php endif; ?> <?php if ($displayData['params']->get('show_email_icon')) : ?> <li class="email-icon"> <?php echo JHtml::_('icon.email', $displayData['item'], $displayData['params']); ?> </li> <?php endif; ?> <?php if ($canEdit) : ?> <li class="edit-icon"> <?php echo JHtml::_('icon.edit', $displayData['item'], $displayData['params']); ?> </li> <?php endif; ?> </ul> </div> <?php endif; ?> <?php else : ?> <div class="pull-right"> <?php echo JHtml::_('icon.print_screen', $displayData['item'], $displayData['params']); ?> </div> <?php endif; ?> </div>
/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/msm_adsp.h> #include <linux/uaccess.h> #include <linux/fs.h> #include <linux/android_pmem.h> #include <linux/slab.h> #include <linux/pm_qos_params.h> #include <linux/delay.h> #include <linux/wait.h> #include <mach/msm_adsp.h> #include <mach/clk.h> #include <mach/camera.h> #include "msm_vfe7x27a.h" #define QDSP_CMDQUEUE 25 #define VFE_RESET_CMD 0 #define VFE_START_CMD 1 #define VFE_STOP_CMD 2 #define VFE_FRAME_ACK 20 #define STATS_AF_ACK 21 #define STATS_WE_ACK 22 #define MSG_STOP_ACK 1 #define MSG_SNAPSHOT 2 #define MSG_OUTPUT1 6 #define MSG_OUTPUT2 7 #define MSG_STATS_AF 8 #define MSG_STATS_WE 9 #define MSG_OUTPUT_S 23 #define MSG_OUTPUT_T 22 #define MSG_SOF 15 #define VFE_ADSP_EVENT 0xFFFF #define SNAPSHOT_MASK_MODE 0x00000002 #define MSM_AXI_QOS_PREVIEW 122000 #define MSM_AXI_QOS_SNAPSHOT 192000 static struct msm_adsp_module *qcam_mod; static struct msm_adsp_module *vfe_mod; static struct msm_vfe_callback *resp; static void *extdata; static uint32_t extlen; struct mutex vfe_lock; static void *vfe_syncdata; static uint8_t vfestopped; static struct stop_event stopevent; unsigned long paddr_s_y; unsigned long paddr_s_cbcr; unsigned long paddr_t_y; unsigned long paddr_t_cbcr; static uint32_t op_mode; static void vfe_7x_convert(struct msm_vfe_phy_info *pinfo, enum vfe_resp_msg type, void *data, void **ext, int32_t *elen) { switch (type) { case VFE_MSG_OUTPUT_P: { pinfo->p0_phy = ((struct vfe_endframe *)data)->y_address; pinfo->p1_phy = ((struct vfe_endframe *)data)->cbcr_address; pinfo->p2_phy = pinfo->p0_phy; pinfo->output_id = OUTPUT_TYPE_P; CDBG("vfe_7x_convert, y_phy = 0x%x, cbcr_phy = 0x%x\n", pinfo->p0_phy, pinfo->p1_phy); memcpy(((struct vfe_frame_extra *)extdata), &((struct vfe_endframe *)data)->extra, sizeof(struct vfe_frame_extra)); *ext = extdata; *elen = extlen; pinfo->frame_id = ((struct vfe_frame_extra *)extdata)->frame_id; } break; case VFE_MSG_OUTPUT_S: { pinfo->p0_phy = paddr_s_y; pinfo->p1_phy = paddr_s_cbcr; pinfo->p2_phy = pinfo->p0_phy; pinfo->output_id = OUTPUT_TYPE_S; CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n", pinfo->p0_phy, pinfo->p1_phy); } break; case VFE_MSG_OUTPUT_T: { pinfo->p0_phy = paddr_t_y; pinfo->p1_phy = paddr_t_cbcr; pinfo->p2_phy = pinfo->p0_phy; pinfo->output_id = OUTPUT_TYPE_T; CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n", pinfo->p0_phy, pinfo->p1_phy); } break; case VFE_MSG_STATS_AF: case VFE_MSG_STATS_WE: pinfo->sbuf_phy = *(uint32_t *)data; pinfo->frame_id = *(((uint32_t *)data) + 1); CDBG("frame id = %d\n", pinfo->frame_id); break; default: break; } } static void vfe_7x_ops(void *driver_data, unsigned id, size_t len, void (*getevent)(void *ptr, size_t len)) { uint32_t evt_buf[3]; struct msm_vfe_resp *rp; void *data; CDBG("%s:id=%d\n", __func__, id); len = (id == VFE_ADSP_EVENT) ? 0 : len; data = resp->vfe_alloc(sizeof(struct msm_vfe_resp) + len, vfe_syncdata, GFP_ATOMIC); if (!data) { pr_err("%s: rp: cannot allocate buffer\n", __func__); return; } rp = data; rp->evt_msg.len = len; if (id == VFE_ADSP_EVENT) { /* event */ rp->type = VFE_EVENT; rp->evt_msg.type = MSM_CAMERA_EVT; getevent(evt_buf, sizeof(evt_buf)); rp->evt_msg.msg_id = evt_buf[0]; CDBG("%s:event:msg_id=%d\n", __func__, rp->evt_msg.msg_id); resp->vfe_resp(rp, MSM_CAM_Q_VFE_EVT, vfe_syncdata, GFP_ATOMIC); } else { /* messages */ rp->evt_msg.type = MSM_CAMERA_MSG; rp->evt_msg.msg_id = id; rp->evt_msg.data = rp + 1; getevent(rp->evt_msg.data, len); CDBG("%s:messages:msg_id=%d\n", __func__, rp->evt_msg.msg_id); switch (rp->evt_msg.msg_id) { case MSG_SNAPSHOT: msm_camio_set_perf_lvl(S_PREVIEW); vfe_7x_ops(driver_data, MSG_OUTPUT_S, len, getevent); vfe_7x_ops(driver_data, MSG_OUTPUT_T, len, getevent); rp->type = VFE_MSG_SNAPSHOT; break; case MSG_OUTPUT_S: rp->type = VFE_MSG_OUTPUT_S; vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_S, rp->evt_msg.data, &(rp->extdata), &(rp->extlen)); break; case MSG_OUTPUT_T: rp->type = VFE_MSG_OUTPUT_T; vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_T, rp->evt_msg.data, &(rp->extdata), &(rp->extlen)); break; case MSG_OUTPUT1: case MSG_OUTPUT2: if (op_mode & SNAPSHOT_MASK_MODE) { resp->vfe_free(data); return; } rp->type = VFE_MSG_OUTPUT_P; vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_P, rp->evt_msg.data, &(rp->extdata), &(rp->extlen)); break; case MSG_STATS_AF: rp->type = VFE_MSG_STATS_AF; vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_AF, rp->evt_msg.data, NULL, NULL); break; case MSG_STATS_WE: rp->type = VFE_MSG_STATS_WE; vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_WE, rp->evt_msg.data, NULL, NULL); CDBG("MSG_STATS_WE: phy = 0x%x\n", rp->phy.sbuf_phy); break; case MSG_STOP_ACK: rp->type = VFE_MSG_GENERAL; stopevent.state = 1; wake_up(&stopevent.wait); break; default: rp->type = VFE_MSG_GENERAL; break; } if (id != MSG_SOF) resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, vfe_syncdata, GFP_ATOMIC); } } static struct msm_adsp_ops vfe_7x_sync = { .event = vfe_7x_ops, }; static int vfe_7x_enable(struct camera_enable_cmd *enable) { int rc = -EFAULT; static int cnt; if (!strcmp(enable->name, "QCAMTASK")) rc = msm_adsp_enable(qcam_mod); else if (!strcmp(enable->name, "VFETASK")) rc = msm_adsp_enable(vfe_mod); if (!cnt) { msm_camio_set_perf_lvl(S_INIT); cnt++; } return rc; } static int vfe_7x_disable(struct camera_enable_cmd *enable, struct platform_device *dev __attribute__((unused))) { int rc = -EFAULT; if (!strcmp(enable->name, "QCAMTASK")) rc = msm_adsp_disable(qcam_mod); else if (!strcmp(enable->name, "VFETASK")) rc = msm_adsp_disable(vfe_mod); return rc; } static int vfe_7x_stop(void) { int rc = 0; uint32_t stopcmd = VFE_STOP_CMD; rc = msm_adsp_write(vfe_mod, QDSP_CMDQUEUE, &stopcmd, sizeof(uint32_t)); if (rc < 0) { CDBG("%s:%d: failed rc = %d\n", __func__, __LINE__, rc); return rc; } stopevent.state = 0; rc = wait_event_timeout(stopevent.wait, stopevent.state != 0, msecs_to_jiffies(stopevent.timeout)); return rc; } static void vfe_7x_release(struct platform_device *pdev) { mutex_lock(&vfe_lock); vfe_syncdata = NULL; mutex_unlock(&vfe_lock); if (!vfestopped) { CDBG("%s:%d:Calling vfe_7x_stop()\n", __func__, __LINE__); vfe_7x_stop(); } else vfestopped = 0; msm_adsp_disable(qcam_mod); msm_adsp_disable(vfe_mod); msm_adsp_put(qcam_mod); msm_adsp_put(vfe_mod); msm_camio_disable(pdev); kfree(extdata); extlen = 0; msm_camio_set_perf_lvl(S_EXIT); } static int vfe_7x_init(struct msm_vfe_callback *presp, struct platform_device *dev) { int rc = 0; init_waitqueue_head(&stopevent.wait); stopevent.timeout = 200; stopevent.state = 0; if (presp && presp->vfe_resp) resp = presp; else return -EFAULT; /* Bring up all the required GPIOs and Clocks */ rc = msm_camio_enable(dev); if (rc < 0) return rc; extlen = sizeof(struct vfe_frame_extra); extdata = kmalloc(extlen, GFP_ATOMIC); if (!extdata) { rc = -ENOMEM; goto init_fail; } rc = msm_adsp_get("QCAMTASK", &qcam_mod, &vfe_7x_sync, NULL); if (rc) { rc = -EBUSY; goto get_qcam_fail; } rc = msm_adsp_get("VFETASK", &vfe_mod, &vfe_7x_sync, NULL); if (rc) { rc = -EBUSY; goto get_vfe_fail; } return 0; get_vfe_fail: msm_adsp_put(qcam_mod); get_qcam_fail: kfree(extdata); init_fail: extlen = 0; return rc; } static int vfe_7x_config_axi(int mode, struct axidata *ad, struct axiout *ao) { struct msm_pmem_region *regptr; unsigned long *bptr; int cnt; int rc = 0; if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) { regptr = ad->region; CDBG("bufnum1 = %d\n", ad->bufnum1); if (mode == OUTPUT_1_AND_2) { paddr_t_y = regptr->paddr + regptr->info.planar0_off; paddr_t_cbcr = regptr->paddr + regptr->info.planar1_off; } CDBG("config_axi1: O1, phy = 0x%lx, y_off = %d, cbcr_off =%d\n", regptr->paddr, regptr->info.planar0_off, regptr->info.planar1_off); bptr = &ao->output1buffer1_y_phy; for (cnt = 0; cnt < ad->bufnum1; cnt++) { *bptr = regptr->paddr + regptr->info.planar0_off; bptr++; *bptr = regptr->paddr + regptr->info.planar1_off; bptr++; regptr++; } regptr--; for (cnt = 0; cnt < (8 - ad->bufnum1); cnt++) { *bptr = regptr->paddr + regptr->info.planar0_off; bptr++; *bptr = regptr->paddr + regptr->info.planar1_off; bptr++; } } if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) { regptr = &(ad->region[ad->bufnum1]); CDBG("bufnum2 = %d\n", ad->bufnum2); paddr_s_y = regptr->paddr + regptr->info.planar0_off; paddr_s_cbcr = regptr->paddr + regptr->info.planar1_off; CDBG("config_axi2: O2, phy = 0x%lx, y_off = %d, cbcr_off =%d\n", regptr->paddr, regptr->info.planar0_off, regptr->info.planar1_off); bptr = &ao->output2buffer1_y_phy; for (cnt = 0; cnt < ad->bufnum2; cnt++) { *bptr = regptr->paddr + regptr->info.planar0_off; bptr++; *bptr = regptr->paddr + regptr->info.planar1_off; bptr++; regptr++; } regptr--; for (cnt = 0; cnt < (8 - ad->bufnum2); cnt++) { *bptr = regptr->paddr + regptr->info.planar0_off; bptr++; *bptr = regptr->paddr + regptr->info.planar1_off; bptr++; } } return rc; } static int vfe_7x_config(struct msm_vfe_cfg_cmd *cmd, void *data) { struct msm_pmem_region *regptr; unsigned char buf[256]; struct vfe_stats_ack sack; struct axidata *axid; uint32_t i; uint32_t *_mode; struct vfe_stats_we_cfg *scfg = NULL; struct vfe_stats_af_cfg *sfcfg = NULL; struct axiout *axio = NULL; void *cmd_data = NULL; void *cmd_data_alloc = NULL; long rc = 0; struct msm_vfe_command_7k *vfecmd; vfecmd = kmalloc(sizeof(struct msm_vfe_command_7k), GFP_ATOMIC); if (!vfecmd) { pr_err("vfecmd alloc failed!\n"); return -ENOMEM; } if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE && cmd->cmd_type != CMD_STATS_BUF_RELEASE && cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) { if (copy_from_user(vfecmd, (void __user *)(cmd->value), sizeof(struct msm_vfe_command_7k))) { rc = -EFAULT; goto config_failure; } } switch (cmd->cmd_type) { case CMD_STATS_AEC_AWB_ENABLE: case CMD_STATS_AXI_CFG: { axid = data; if (!axid) { rc = -EFAULT; goto config_failure; } scfg = kmalloc(sizeof(struct vfe_stats_we_cfg), GFP_ATOMIC); if (!scfg) { rc = -ENOMEM; goto config_failure; } if (copy_from_user(scfg, (void __user *)(vfecmd->value), vfecmd->length)) { rc = -EFAULT; goto config_done; } CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n", axid->bufnum1, scfg->wb_expstatsenable); if (axid->bufnum1 > 0) { regptr = axid->region; for (i = 0; i < axid->bufnum1; i++) { CDBG("STATS_ENABLE, phy = 0x%lx\n", regptr->paddr); scfg->wb_expstatoutputbuffer[i] = (void *)regptr->paddr; regptr++; } cmd_data = scfg; } else { rc = -EINVAL; goto config_done; } } break; case CMD_STATS_AF_ENABLE: case CMD_STATS_AF_AXI_CFG: { axid = data; if (!axid) { rc = -EFAULT; goto config_failure; } sfcfg = kmalloc(sizeof(struct vfe_stats_af_cfg), GFP_ATOMIC); if (!sfcfg) { rc = -ENOMEM; goto config_failure; } if (copy_from_user(sfcfg, (void __user *)(vfecmd->value), vfecmd->length)) { rc = -EFAULT; goto config_done; } CDBG("AF_ENABLE: bufnum = %d, enabling = %d\n", axid->bufnum1, sfcfg->af_enable); if (axid->bufnum1 > 0) { regptr = &axid->region[0]; for (i = 0; i < axid->bufnum1; i++) { CDBG("STATS_ENABLE, phy = 0x%lx\n", regptr->paddr); sfcfg->af_outbuf[i] = (void *)regptr->paddr; regptr++; } cmd_data = sfcfg; } else { rc = -EINVAL; goto config_done; } } break; case CMD_FRAME_BUF_RELEASE: { struct msm_frame *b; unsigned long p; struct vfe_outputack fack; if (!data) { rc = -EFAULT; goto config_failure; } b = (struct msm_frame *)(cmd->value); p = *(unsigned long *)data; fack.header = VFE_FRAME_ACK; fack.output2newybufferaddress = (void *)(p + b->planar0_off); fack.output2newcbcrbufferaddress = (void *)(p + b->planar1_off); vfecmd->queue = QDSP_CMDQUEUE; vfecmd->length = sizeof(struct vfe_outputack); cmd_data = &fack; } break; case CMD_SNAP_BUF_RELEASE: break; case CMD_STATS_BUF_RELEASE: { CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n"); if (!data) { rc = -EFAULT; goto config_failure; } sack.header = STATS_WE_ACK; sack.bufaddr = (void *)*(uint32_t *)data; vfecmd->queue = QDSP_CMDQUEUE; vfecmd->length = sizeof(struct vfe_stats_ack); cmd_data = &sack; } break; case CMD_STATS_AF_BUF_RELEASE: { CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n"); if (!data) { rc = -EFAULT; goto config_failure; } sack.header = STATS_AF_ACK; sack.bufaddr = (void *)*(uint32_t *)data; vfecmd->queue = QDSP_CMDQUEUE; vfecmd->length = sizeof(struct vfe_stats_ack); cmd_data = &sack; } break; case CMD_GENERAL: case CMD_STATS_DISABLE: { if (vfecmd->length > 256) { cmd_data_alloc = cmd_data = kmalloc(vfecmd->length, GFP_ATOMIC); if (!cmd_data) { rc = -ENOMEM; goto config_failure; } } else cmd_data = buf; if (copy_from_user(cmd_data, (void __user *)(vfecmd->value), vfecmd->length)) { rc = -EFAULT; goto config_done; } if (vfecmd->queue == QDSP_CMDQUEUE) { switch (*(uint32_t *)cmd_data) { case VFE_RESET_CMD: msm_camio_vfe_blk_reset(); vfestopped = 0; break; case VFE_START_CMD: _mode = (uint32_t *)cmd_data; op_mode = *(++_mode); if (op_mode & SNAPSHOT_MASK_MODE) msm_camio_set_perf_lvl(S_CAPTURE); else msm_camio_set_perf_lvl(S_PREVIEW); vfestopped = 0; break; case VFE_STOP_CMD: vfestopped = 1; goto config_send; default: break; } } /* QDSP_CMDQUEUE */ } break; case CMD_AXI_CFG_PREVIEW: case CMD_RAW_PICT_AXI_CFG: { axid = data; if (!axid) { rc = -EFAULT; goto config_failure; } axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC); if (!axio) { rc = -ENOMEM; goto config_failure; } if (copy_from_user(axio, (void __user *)(vfecmd->value), sizeof(struct axiout))) { rc = -EFAULT; goto config_done; } vfe_7x_config_axi(OUTPUT_2, axid, axio); cmd_data = axio; } break; case CMD_AXI_CFG_SNAP: { axid = data; if (!axid) { rc = -EFAULT; goto config_failure; } axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC); if (!axio) { rc = -ENOMEM; goto config_failure; } if (copy_from_user(axio, (void __user *)(vfecmd->value), sizeof(struct axiout))) { rc = -EFAULT; goto config_done; } vfe_7x_config_axi(OUTPUT_1_AND_2, axid, axio); cmd_data = axio; } break; default: break; } if (vfestopped) goto config_done; config_send: CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data); rc = msm_adsp_write(vfe_mod, vfecmd->queue, cmd_data, vfecmd->length); config_done: kfree(cmd_data_alloc); config_failure: kfree(scfg); kfree(axio); kfree(vfecmd); return rc; } void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data) { mutex_init(&vfe_lock); fptr->vfe_init = vfe_7x_init; fptr->vfe_enable = vfe_7x_enable; fptr->vfe_config = vfe_7x_config; fptr->vfe_disable = vfe_7x_disable; fptr->vfe_release = vfe_7x_release; vfe_syncdata = data; } void msm_camvpe_fn_init(struct msm_camvpe_fn *fptr, void *data) { fptr->vpe_reg = NULL; fptr->send_frame_to_vpe = NULL; fptr->vpe_config = NULL; fptr->vpe_cfg_update = NULL; fptr->dis = NULL; }
# -*- coding: utf-8 -*- from django.contrib import admin from django.db import models class Band(models.Model): name = models.CharField(max_length=100) bio = models.TextField() rank = models.IntegerField() class Meta: ordering = ('name',) class Song(models.Model): band = models.ForeignKey(Band) name = models.CharField(max_length=100) duration = models.IntegerField() other_interpreters = models.ManyToManyField(Band, related_name='covers') class Meta: ordering = ('name',) class SongInlineDefaultOrdering(admin.StackedInline): model = Song class SongInlineNewOrdering(admin.StackedInline): model = Song ordering = ('duration', ) class DynOrderingBandAdmin(admin.ModelAdmin): def get_ordering(self, request): if request.user.is_superuser: return ['rank'] else: return ['name']
package bolt import ( "errors" "fmt" "hash/fnv" "log" "os" "runtime" "runtime/debug" "strings" "sync" "time" "unsafe" ) // The largest step that can be taken when remapping the mmap. const maxMmapStep = 1 << 30 // 1GB // The data file format version. const version = 2 // Represents a marker value to indicate that a file is a Bolt DB. const magic uint32 = 0xED0CDAED // IgnoreNoSync specifies whether the NoSync field of a DB is ignored when // syncing changes to a file. This is required as some operating systems, // such as OpenBSD, do not have a unified buffer cache (UBC) and writes // must be synchronized using the msync(2) syscall. const IgnoreNoSync = runtime.GOOS == "openbsd" // Default values if not set in a DB instance. const ( DefaultMaxBatchSize int = 1000 DefaultMaxBatchDelay = 10 * time.Millisecond DefaultAllocSize = 16 * 1024 * 1024 ) // DB represents a collection of buckets persisted to a file on disk. // All data access is performed through transactions which can be obtained through the DB. // All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called. type DB struct { // When enabled, the database will perform a Check() after every commit. // A panic is issued if the database is in an inconsistent state. This // flag has a large performance impact so it should only be used for // debugging purposes. StrictMode bool // Setting the NoSync flag will cause the database to skip fsync() // calls after each commit. This can be useful when bulk loading data // into a database and you can restart the bulk load in the event of // a system failure or database corruption. Do not set this flag for // normal use. // // If the package global IgnoreNoSync constant is true, this value is // ignored. See the comment on that constant for more details. // // THIS IS UNSAFE. PLEASE USE WITH CAUTION. NoSync bool // When true, skips the truncate call when growing the database. // Setting this to true is only safe on non-ext3/ext4 systems. // Skipping truncation avoids preallocation of hard drive space and // bypasses a truncate() and fsync() syscall on remapping. // // https://github.com/boltdb/bolt/issues/284 NoGrowSync bool // If you want to read the entire database fast, you can set MmapFlag to // syscall.MAP_POPULATE on Linux 2.6.23+ for sequential read-ahead. MmapFlags int // MaxBatchSize is the maximum size of a batch. Default value is // copied from DefaultMaxBatchSize in Open. // // If <=0, disables batching. // // Do not change concurrently with calls to Batch. MaxBatchSize int // MaxBatchDelay is the maximum delay before a batch starts. // Default value is copied from DefaultMaxBatchDelay in Open. // // If <=0, effectively disables batching. // // Do not change concurrently with calls to Batch. MaxBatchDelay time.Duration // AllocSize is the amount of space allocated when the database // needs to create new pages. This is done to amortize the cost // of truncate() and fsync() when growing the data file. AllocSize int path string file *os.File dataref []byte // mmap'ed readonly, write throws SEGV data *[maxMapSize]byte datasz int filesz int // current on disk file size meta0 *meta meta1 *meta pageSize int opened bool rwtx *Tx txs []*Tx freelist *freelist stats Stats batchMu sync.Mutex batch *batch rwlock sync.Mutex // Allows only one writer at a time. metalock sync.Mutex // Protects meta page access. mmaplock sync.RWMutex // Protects mmap access during remapping. statlock sync.RWMutex // Protects stats access. ops struct { writeAt func(b []byte, off int64) (n int, err error) } // Read only mode. // When true, Update() and Begin(true) return ErrDatabaseReadOnly immediately. readOnly bool } // Path returns the path to currently open database file. func (db *DB) Path() string { return db.path } // GoString returns the Go string representation of the database. func (db *DB) GoString() string { return fmt.Sprintf("bolt.DB{path:%q}", db.path) } // String returns the string representation of the database. func (db *DB) String() string { return fmt.Sprintf("DB<%q>", db.path) } // Open creates and opens a database at the given path. // If the file does not exist then it will be created automatically. // Passing in nil options will cause Bolt to open the database with the default options. func Open(path string, mode os.FileMode, options *Options) (*DB, error) { var db = &DB{opened: true} // Set default options if no options are provided. if options == nil { options = DefaultOptions } db.NoGrowSync = options.NoGrowSync db.MmapFlags = options.MmapFlags // Set default values for later DB operations. db.MaxBatchSize = DefaultMaxBatchSize db.MaxBatchDelay = DefaultMaxBatchDelay db.AllocSize = DefaultAllocSize flag := os.O_RDWR if options.ReadOnly { flag = os.O_RDONLY db.readOnly = true } // Open data file and separate sync handler for metadata writes. db.path = path var err error if db.file, err = os.OpenFile(db.path, flag|os.O_CREATE, mode); err != nil { _ = db.close() return nil, err } // Lock file so that other processes using Bolt in read-write mode cannot // use the database at the same time. This would cause corruption since // the two processes would write meta pages and free pages separately. // The database file is locked exclusively (only one process can grab the lock) // if !options.ReadOnly. // The database file is locked using the shared lock (more than one process may // hold a lock at the same time) otherwise (options.ReadOnly is set). if err := flock(db.file, !db.readOnly, options.Timeout); err != nil { _ = db.close() return nil, err } // Default values for test hooks db.ops.writeAt = db.file.WriteAt // Initialize the database if it doesn't exist. if info, err := db.file.Stat(); err != nil { return nil, err } else if info.Size() == 0 { // Initialize new files with meta pages. if err := db.init(); err != nil { return nil, err } } else { // Read the first meta page to determine the page size. var buf [0x1000]byte if _, err := db.file.ReadAt(buf[:], 0); err == nil { m := db.pageInBuffer(buf[:], 0).meta() if err := m.validate(); err != nil { return nil, err } db.pageSize = int(m.pageSize) } } // Memory map the data file. if err := db.mmap(options.InitialMmapSize); err != nil { _ = db.close() return nil, err } // Read in the freelist. db.freelist = newFreelist() db.freelist.read(db.page(db.meta().freelist)) // Mark the database as opened and return. return db, nil } // mmap opens the underlying memory-mapped file and initializes the meta references. // minsz is the minimum size that the new mmap can be. func (db *DB) mmap(minsz int) error { db.mmaplock.Lock() defer db.mmaplock.Unlock() info, err := db.file.Stat() if err != nil { return fmt.Errorf("mmap stat error: %s", err) } else if int(info.Size()) < db.pageSize*2 { return fmt.Errorf("file size too small") } // Ensure the size is at least the minimum size. var size = int(info.Size()) if size < minsz { size = minsz } size, err = db.mmapSize(size) if err != nil { return err } // Dereference all mmap references before unmapping. if db.rwtx != nil { db.rwtx.root.dereference() } // Unmap existing data before continuing. if err := db.munmap(); err != nil { return err } // Memory-map the data file as a byte slice. if err := mmap(db, size); err != nil { return err } // Save references to the meta pages. db.meta0 = db.page(0).meta() db.meta1 = db.page(1).meta() // Validate the meta pages. if err := db.meta0.validate(); err != nil { return err } if err := db.meta1.validate(); err != nil { return err } return nil } // munmap unmaps the data file from memory. func (db *DB) munmap() error { if err := munmap(db); err != nil { return fmt.Errorf("unmap error: " + err.Error()) } return nil } // mmapSize determines the appropriate size for the mmap given the current size // of the database. The minimum size is 32KB and doubles until it reaches 1GB. // Returns an error if the new mmap size is greater than the max allowed. func (db *DB) mmapSize(size int) (int, error) { // Double the size from 32KB until 1GB. for i := uint(15); i <= 30; i++ { if size <= 1<<i { return 1 << i, nil } } // Verify the requested size is not above the maximum allowed. if size > maxMapSize { return 0, fmt.Errorf("mmap too large") } // If larger than 1GB then grow by 1GB at a time. sz := int64(size) if remainder := sz % int64(maxMmapStep); remainder > 0 { sz += int64(maxMmapStep) - remainder } // Ensure that the mmap size is a multiple of the page size. // This should always be true since we're incrementing in MBs. pageSize := int64(db.pageSize) if (sz % pageSize) != 0 { sz = ((sz / pageSize) + 1) * pageSize } // If we've exceeded the max size then only grow up to the max size. if sz > maxMapSize { sz = maxMapSize } return int(sz), nil } // init creates a new database file and initializes its meta pages. func (db *DB) init() error { // Set the page size to the OS page size. db.pageSize = os.Getpagesize() // Create two meta pages on a buffer. buf := make([]byte, db.pageSize*4) for i := 0; i < 2; i++ { p := db.pageInBuffer(buf[:], pgid(i)) p.id = pgid(i) p.flags = metaPageFlag // Initialize the meta page. m := p.meta() m.magic = magic m.version = version m.pageSize = uint32(db.pageSize) m.freelist = 2 m.root = bucket{root: 3} m.pgid = 4 m.txid = txid(i) } // Write an empty freelist at page 3. p := db.pageInBuffer(buf[:], pgid(2)) p.id = pgid(2) p.flags = freelistPageFlag p.count = 0 // Write an empty leaf page at page 4. p = db.pageInBuffer(buf[:], pgid(3)) p.id = pgid(3) p.flags = leafPageFlag p.count = 0 // Write the buffer to our data file. if _, err := db.ops.writeAt(buf, 0); err != nil { return err } if err := fdatasync(db); err != nil { return err } return nil } // Close releases all database resources. // All transactions must be closed before closing the database. func (db *DB) Close() error { db.rwlock.Lock() defer db.rwlock.Unlock() db.metalock.Lock() defer db.metalock.Unlock() db.mmaplock.RLock() defer db.mmaplock.RUnlock() return db.close() } func (db *DB) close() error { db.opened = false db.freelist = nil db.path = "" // Clear ops. db.ops.writeAt = nil // Close the mmap. if err := db.munmap(); err != nil { return err } // Close file handles. if db.file != nil { // No need to unlock read-only file. if !db.readOnly { // Unlock the file. if err := funlock(db.file); err != nil { log.Printf("bolt.Close(): funlock error: %s", err) } } // Close the file descriptor. if err := db.file.Close(); err != nil { return fmt.Errorf("db file close: %s", err) } db.file = nil } return nil } // Begin starts a new transaction. // Multiple read-only transactions can be used concurrently but only one // write transaction can be used at a time. Starting multiple write transactions // will cause the calls to block and be serialized until the current write // transaction finishes. // // Transactions should not be dependent on one another. Opening a read // transaction and a write transaction in the same goroutine can cause the // writer to deadlock because the database periodically needs to re-mmap itself // as it grows and it cannot do that while a read transaction is open. // // If a long running read transaction (for example, a snapshot transaction) is // needed, you might want to set DB.InitialMmapSize to a large enough value // to avoid potential blocking of write transaction. // // IMPORTANT: You must close read-only transactions after you are finished or // else the database will not reclaim old pages. func (db *DB) Begin(writable bool) (*Tx, error) { if writable { return db.beginRWTx() } return db.beginTx() } func (db *DB) beginTx() (*Tx, error) { // Lock the meta pages while we initialize the transaction. We obtain // the meta lock before the mmap lock because that's the order that the // write transaction will obtain them. db.metalock.Lock() // Obtain a read-only lock on the mmap. When the mmap is remapped it will // obtain a write lock so all transactions must finish before it can be // remapped. db.mmaplock.RLock() // Exit if the database is not open yet. if !db.opened { db.mmaplock.RUnlock() db.metalock.Unlock() return nil, ErrDatabaseNotOpen } // Create a transaction associated with the database. t := &Tx{} t.init(db) // Keep track of transaction until it closes. db.txs = append(db.txs, t) n := len(db.txs) // Unlock the meta pages. db.metalock.Unlock() // Update the transaction stats. db.statlock.Lock() db.stats.TxN++ db.stats.OpenTxN = n db.statlock.Unlock() return t, nil } func (db *DB) beginRWTx() (*Tx, error) { // If the database was opened with Options.ReadOnly, return an error. if db.readOnly { return nil, ErrDatabaseReadOnly } // Obtain writer lock. This is released by the transaction when it closes. // This enforces only one writer transaction at a time. db.rwlock.Lock() // Once we have the writer lock then we can lock the meta pages so that // we can set up the transaction. db.metalock.Lock() defer db.metalock.Unlock() // Exit if the database is not open yet. if !db.opened { db.rwlock.Unlock() return nil, ErrDatabaseNotOpen } // Create a transaction associated with the database. t := &Tx{writable: true} t.init(db) db.rwtx = t // Free any pages associated with closed read-only transactions. var minid txid = 0xFFFFFFFFFFFFFFFF for _, t := range db.txs { if t.meta.txid < minid { minid = t.meta.txid } } if minid > 0 { db.freelist.release(minid - 1) } return t, nil } // removeTx removes a transaction from the database. func (db *DB) removeTx(tx *Tx) { // Release the read lock on the mmap. db.mmaplock.RUnlock() // Use the meta lock to restrict access to the DB object. db.metalock.Lock() // Remove the transaction. for i, t := range db.txs { if t == tx { db.txs = append(db.txs[:i], db.txs[i+1:]...) break } } n := len(db.txs) // Unlock the meta pages. db.metalock.Unlock() // Merge statistics. db.statlock.Lock() db.stats.OpenTxN = n db.stats.TxStats.add(&tx.stats) db.statlock.Unlock() } // Update executes a function within the context of a read-write managed transaction. // If no error is returned from the function then the transaction is committed. // If an error is returned then the entire transaction is rolled back. // Any error that is returned from the function or returned from the commit is // returned from the Update() method. // // Attempting to manually commit or rollback within the function will cause a panic. func (db *DB) Update(fn func(*Tx) error) error { t, err := db.Begin(true) if err != nil { return err } // Make sure the transaction rolls back in the event of a panic. defer func() { if t.db != nil { t.rollback() } }() // Mark as a managed tx so that the inner function cannot manually commit. t.managed = true // If an error is returned from the function then rollback and return error. err = fn(t) t.managed = false if err != nil { _ = t.Rollback() return err } return t.Commit() } // View executes a function within the context of a managed read-only transaction. // Any error that is returned from the function is returned from the View() method. // // Attempting to manually rollback within the function will cause a panic. func (db *DB) View(fn func(*Tx) error) error { t, err := db.Begin(false) if err != nil { return err } // Make sure the transaction rolls back in the event of a panic. defer func() { if t.db != nil { t.rollback() } }() // Mark as a managed tx so that the inner function cannot manually rollback. t.managed = true // If an error is returned from the function then pass it through. err = fn(t) t.managed = false if err != nil { _ = t.Rollback() return err } if err := t.Rollback(); err != nil { return err } return nil } // Batch calls fn as part of a batch. It behaves similar to Update, // except: // // 1. concurrent Batch calls can be combined into a single Bolt // transaction. // // 2. the function passed to Batch may be called multiple times, // regardless of whether it returns error or not. // // This means that Batch function side effects must be idempotent and // take permanent effect only after a successful return is seen in // caller. // // The maximum batch size and delay can be adjusted with DB.MaxBatchSize // and DB.MaxBatchDelay, respectively. // // Batch is only useful when there are multiple goroutines calling it. func (db *DB) Batch(fn func(*Tx) error) error { errCh := make(chan error, 1) db.batchMu.Lock() if (db.batch == nil) || (db.batch != nil && len(db.batch.calls) >= db.MaxBatchSize) { // There is no existing batch, or the existing batch is full; start a new one. db.batch = &batch{ db: db, } db.batch.timer = time.AfterFunc(db.MaxBatchDelay, db.batch.trigger) } db.batch.calls = append(db.batch.calls, call{fn: fn, err: errCh}) if len(db.batch.calls) >= db.MaxBatchSize { // wake up batch, it's ready to run go db.batch.trigger() } db.batchMu.Unlock() err := <-errCh if err == trySolo { err = db.Update(fn) } return err } type call struct { fn func(*Tx) error err chan<- error } type batch struct { db *DB timer *time.Timer start sync.Once calls []call } // trigger runs the batch if it hasn't already been run. func (b *batch) trigger() { b.start.Do(b.run) } // run performs the transactions in the batch and communicates results // back to DB.Batch. func (b *batch) run() { b.db.batchMu.Lock() b.timer.Stop() // Make sure no new work is added to this batch, but don't break // other batches. if b.db.batch == b { b.db.batch = nil } b.db.batchMu.Unlock() retry: for len(b.calls) > 0 { var failIdx = -1 err := b.db.Update(func(tx *Tx) error { for i, c := range b.calls { if err := safelyCall(c.fn, tx); err != nil { failIdx = i return err } } return nil }) if failIdx >= 0 { // take the failing transaction out of the batch. it's // safe to shorten b.calls here because db.batch no longer // points to us, and we hold the mutex anyway. c := b.calls[failIdx] b.calls[failIdx], b.calls = b.calls[len(b.calls)-1], b.calls[:len(b.calls)-1] // tell the submitter re-run it solo, continue with the rest of the batch c.err <- trySolo continue retry } // pass success, or bolt internal errors, to all callers for _, c := range b.calls { if c.err != nil { c.err <- err } } break retry } } // trySolo is a special sentinel error value used for signaling that a // transaction function should be re-run. It should never be seen by // callers. var trySolo = errors.New("batch function returned an error and should be re-run solo") type panicked struct { reason interface{} } func (p panicked) Error() string { if err, ok := p.reason.(error); ok { return err.Error() } return fmt.Sprintf("panic: %v", p.reason) } func safelyCall(fn func(*Tx) error, tx *Tx) (err error) { defer func() { if p := recover(); p != nil { err = panicked{p} } }() return fn(tx) } // Sync executes fdatasync() against the database file handle. // // This is not necessary under normal operation, however, if you use NoSync // then it allows you to force the database file to sync against the disk. func (db *DB) Sync() error { return fdatasync(db) } // Stats retrieves ongoing performance stats for the database. // This is only updated when a transaction closes. func (db *DB) Stats() Stats { db.statlock.RLock() defer db.statlock.RUnlock() return db.stats } // This is for internal access to the raw data bytes from the C cursor, use // carefully, or not at all. func (db *DB) Info() *Info { return &Info{uintptr(unsafe.Pointer(&db.data[0])), db.pageSize} } // page retrieves a page reference from the mmap based on the current page size. func (db *DB) page(id pgid) *page { pos := id * pgid(db.pageSize) return (*page)(unsafe.Pointer(&db.data[pos])) } // pageInBuffer retrieves a page reference from a given byte array based on the current page size. func (db *DB) pageInBuffer(b []byte, id pgid) *page { return (*page)(unsafe.Pointer(&b[id*pgid(db.pageSize)])) } // meta retrieves the current meta page reference. func (db *DB) meta() *meta { if db.meta0.txid > db.meta1.txid { return db.meta0 } return db.meta1 } // allocate returns a contiguous block of memory starting at a given page. func (db *DB) allocate(count int) (*page, error) { // Allocate a temporary buffer for the page. buf := make([]byte, count*db.pageSize) p := (*page)(unsafe.Pointer(&buf[0])) p.overflow = uint32(count - 1) // Use pages from the freelist if they are available. if p.id = db.freelist.allocate(count); p.id != 0 { return p, nil } // Resize mmap() if we're at the end. p.id = db.rwtx.meta.pgid var minsz = int((p.id+pgid(count))+1) * db.pageSize if minsz >= db.datasz { if err := db.mmap(minsz); err != nil { return nil, fmt.Errorf("mmap allocate error: %s", err) } } // Move the page id high water mark. db.rwtx.meta.pgid += pgid(count) return p, nil } // grow grows the size of the database to the given sz. func (db *DB) grow(sz int) error { // Ignore if the new size is less than available file size. if sz <= db.filesz { return nil } // If the data is smaller than the alloc size then only allocate what's needed. // Once it goes over the allocation size then allocate in chunks. if db.datasz < db.AllocSize { sz = db.datasz } else { sz += db.AllocSize } // Truncate and fsync to ensure file size metadata is flushed. // https://github.com/boltdb/bolt/issues/284 if !db.NoGrowSync && !db.readOnly { if err := db.file.Truncate(int64(sz)); err != nil { return fmt.Errorf("file resize error: %s", err) } if err := db.file.Sync(); err != nil { return fmt.Errorf("file sync error: %s", err) } } db.filesz = sz return nil } func (db *DB) IsReadOnly() bool { return db.readOnly } // Options represents the options that can be set when opening a database. type Options struct { // Timeout is the amount of time to wait to obtain a file lock. // When set to zero it will wait indefinitely. This option is only // available on Darwin and Linux. Timeout time.Duration // Sets the DB.NoGrowSync flag before memory mapping the file. NoGrowSync bool // Open database in read-only mode. Uses flock(..., LOCK_SH |LOCK_NB) to // grab a shared lock (UNIX). ReadOnly bool // Sets the DB.MmapFlags flag before memory mapping the file. MmapFlags int // InitialMmapSize is the initial mmap size of the database // in bytes. Read transactions won't block write transaction // if the InitialMmapSize is large enough to hold database mmap // size. (See DB.Begin for more information) // // If <=0, the initial map size is 0. // If initialMmapSize is smaller than the previous database size, // it takes no effect. InitialMmapSize int } // DefaultOptions represent the options used if nil options are passed into Open(). // No timeout is used which will cause Bolt to wait indefinitely for a lock. var DefaultOptions = &Options{ Timeout: 0, NoGrowSync: false, } // Stats represents statistics about the database. type Stats struct { // Freelist stats FreePageN int // total number of free pages on the freelist PendingPageN int // total number of pending pages on the freelist FreeAlloc int // total bytes allocated in free pages FreelistInuse int // total bytes used by the freelist // Transaction stats TxN int // total number of started read transactions OpenTxN int // number of currently open read transactions TxStats TxStats // global, ongoing stats. } // Sub calculates and returns the difference between two sets of database stats. // This is useful when obtaining stats at two different points and time and // you need the performance counters that occurred within that time span. func (s *Stats) Sub(other *Stats) Stats { if other == nil { return *s } var diff Stats diff.FreePageN = s.FreePageN diff.PendingPageN = s.PendingPageN diff.FreeAlloc = s.FreeAlloc diff.FreelistInuse = s.FreelistInuse diff.TxN = other.TxN - s.TxN diff.TxStats = s.TxStats.Sub(&other.TxStats) return diff } func (s *Stats) add(other *Stats) { s.TxStats.add(&other.TxStats) } type Info struct { Data uintptr PageSize int } type meta struct { magic uint32 version uint32 pageSize uint32 flags uint32 root bucket freelist pgid pgid pgid txid txid checksum uint64 } // validate checks the marker bytes and version of the meta page to ensure it matches this binary. func (m *meta) validate() error { if m.checksum != 0 && m.checksum != m.sum64() { return ErrChecksum } else if m.magic != magic { return ErrInvalid } else if m.version != version { return ErrVersionMismatch } return nil } // copy copies one meta object to another. func (m *meta) copy(dest *meta) { *dest = *m } // write writes the meta onto a page. func (m *meta) write(p *page) { if m.root.root >= m.pgid { panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid)) } else if m.freelist >= m.pgid { panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid)) } // Page id is either going to be 0 or 1 which we can determine by the transaction ID. p.id = pgid(m.txid % 2) p.flags |= metaPageFlag // Calculate the checksum. m.checksum = m.sum64() m.copy(p.meta()) } // generates the checksum for the meta. func (m *meta) sum64() uint64 { var h = fnv.New64a() _, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:]) return h.Sum64() } // _assert will panic with a given formatted message if the given condition is false. func _assert(condition bool, msg string, v ...interface{}) { if !condition { panic(fmt.Sprintf("assertion failed: "+msg, v...)) } } func warn(v ...interface{}) { fmt.Fprintln(os.Stderr, v...) } func warnf(msg string, v ...interface{}) { fmt.Fprintf(os.Stderr, msg+"\n", v...) } func printstack() { stack := strings.Join(strings.Split(string(debug.Stack()), "\n")[2:], "\n") fmt.Fprintln(os.Stderr, stack) }
/* * Intel Skylake I2S Machine Driver * * Copyright (C) 2014-2015, Intel Corporation. All rights reserved. * * Modified from: * Intel Broadwell Wildcatpoint SST Audio * * Copyright (C) 2013, Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/module.h> #include <linux/platform_device.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> #include <sound/jack.h> #include <sound/pcm_params.h> #include "../../codecs/rt286.h" static struct snd_soc_jack skylake_headset; /* Headset jack detection DAPM pins */ static struct snd_soc_jack_pin skylake_headset_pins[] = { { .pin = "Mic Jack", .mask = SND_JACK_MICROPHONE, }, { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE, }, }; static const struct snd_kcontrol_new skylake_controls[] = { SOC_DAPM_PIN_SWITCH("Speaker"), SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Mic Jack"), }; static const struct snd_soc_dapm_widget skylake_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_SPK("Speaker", NULL), SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_MIC("DMIC2", NULL), SND_SOC_DAPM_MIC("SoC DMIC", NULL), }; static const struct snd_soc_dapm_route skylake_rt286_map[] = { /* speaker */ {"Speaker", NULL, "SPOR"}, {"Speaker", NULL, "SPOL"}, /* HP jack connectors - unknown if we have jack deteck */ {"Headphone Jack", NULL, "HPO Pin"}, /* other jacks */ {"MIC1", NULL, "Mic Jack"}, /* digital mics */ {"DMIC1 Pin", NULL, "DMIC2"}, {"DMIC AIF", NULL, "SoC DMIC"}, /* CODEC BE connections */ { "AIF1 Playback", NULL, "ssp0 Tx"}, { "ssp0 Tx", NULL, "codec0_out"}, { "ssp0 Tx", NULL, "codec1_out"}, { "codec0_in", NULL, "ssp0 Rx" }, { "codec1_in", NULL, "ssp0 Rx" }, { "ssp0 Rx", NULL, "AIF1 Capture" }, { "dmic01_hifi", NULL, "DMIC01 Rx" }, { "DMIC01 Rx", NULL, "Capture" }, { "hif1", NULL, "iDisp Tx"}, { "iDisp Tx", NULL, "iDisp_out"}, }; static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; int ret; ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0, &skylake_headset, skylake_headset_pins, ARRAY_SIZE(skylake_headset_pins)); if (ret) return ret; rt286_mic_detect(codec, &skylake_headset); return 0; } static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* The output is 48KHz, stereo, 16bits */ rate->min = rate->max = 48000; channels->min = channels->max = 2; params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); return 0; } static int skylake_rt286_hw_params(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->codec_dai; int ret; ret = snd_soc_dai_set_sysclk(codec_dai, RT286_SCLK_S_PLL, 24000000, SND_SOC_CLOCK_IN); if (ret < 0) dev_err(rtd->dev, "set codec sysclk failed: %d\n", ret); return ret; } static struct snd_soc_ops skylake_rt286_ops = { .hw_params = skylake_rt286_hw_params, }; /* skylake digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link skylake_rt286_dais[] = { /* Front End DAI links */ { .name = "Skl Audio Port", .stream_name = "Audio", .cpu_dai_name = "System Pin", .platform_name = "0000:00:1f.3", .nonatomic = 1, .dynamic = 1, .codec_name = "snd-soc-dummy", .codec_dai_name = "snd-soc-dummy-dai", .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .dpcm_playback = 1, }, { .name = "Skl Audio Capture Port", .stream_name = "Audio Record", .cpu_dai_name = "System Pin", .platform_name = "0000:00:1f.3", .nonatomic = 1, .dynamic = 1, .codec_name = "snd-soc-dummy", .codec_dai_name = "snd-soc-dummy-dai", .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .dpcm_capture = 1, }, { .name = "Skl Audio Reference cap", .stream_name = "refcap", .cpu_dai_name = "Reference Pin", .codec_name = "snd-soc-dummy", .codec_dai_name = "snd-soc-dummy-dai", .platform_name = "0000:00:1f.3", .init = NULL, .dpcm_capture = 1, .ignore_suspend = 1, .nonatomic = 1, .dynamic = 1, }, /* Back End DAI links */ { /* SSP0 - Codec */ .name = "SSP0-Codec", .be_id = 0, .cpu_dai_name = "SSP0 Pin", .platform_name = "0000:00:1f.3", .no_pcm = 1, .codec_name = "i2c-INT343A:00", .codec_dai_name = "rt286-aif1", .init = skylake_rt286_codec_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ignore_suspend = 1, .ignore_pmdown_time = 1, .be_hw_params_fixup = skylake_ssp0_fixup, .ops = &skylake_rt286_ops, .dpcm_playback = 1, .dpcm_capture = 1, }, { .name = "dmic01", .be_id = 1, .cpu_dai_name = "DMIC01 Pin", .codec_name = "dmic-codec", .codec_dai_name = "dmic-hifi", .platform_name = "0000:00:1f.3", .ignore_suspend = 1, .dpcm_capture = 1, .no_pcm = 1, }, }; /* skylake audio machine driver for SPT + RT286S */ static struct snd_soc_card skylake_rt286 = { .name = "skylake-rt286", .owner = THIS_MODULE, .dai_link = skylake_rt286_dais, .num_links = ARRAY_SIZE(skylake_rt286_dais), .controls = skylake_controls, .num_controls = ARRAY_SIZE(skylake_controls), .dapm_widgets = skylake_widgets, .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), .dapm_routes = skylake_rt286_map, .num_dapm_routes = ARRAY_SIZE(skylake_rt286_map), .fully_routed = true, }; static int skylake_audio_probe(struct platform_device *pdev) { skylake_rt286.dev = &pdev->dev; return devm_snd_soc_register_card(&pdev->dev, &skylake_rt286); } static struct platform_driver skylake_audio = { .probe = skylake_audio_probe, .driver = { .name = "skl_alc286s_i2s", }, }; module_platform_driver(skylake_audio) /* Module information */ MODULE_AUTHOR("Omair Mohammed Abdullah <omair.m.abdullah@intel.com>"); MODULE_DESCRIPTION("Intel SST Audio for Skylake"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:skl_alc286s_i2s");
/* Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or http://ckeditor.com/license */ CKEDITOR.plugins.setLang("specialchar","et",{euro:"Euromärk",lsquo:"Alustav ühekordne jutumärk",rsquo:"Lõpetav ühekordne jutumärk",ldquo:"Alustav kahekordne jutumärk",rdquo:"Lõpetav kahekordne jutumärk",ndash:"Enn-kriips",mdash:"Emm-kriips",iexcl:"Pööratud hüüumärk",cent:"Sendimärk",pound:"Naela märk",curren:"Valuutamärk",yen:"Jeeni märk",brvbar:"Katkestatud kriips",sect:"Lõigu märk",uml:"Täpid",copy:"Autoriõiguse märk",ordf:"Feminine ordinal indicator",laquo:"Left-pointing double angle quotation mark", not:"Ei-märk",reg:"Registered sign",macr:"Macron",deg:"Kraadimärk",sup2:"Ülaindeks kaks",sup3:"Ülaindeks kolm",acute:"Acute accent",micro:"Mikro-märk",para:"Pilcrow sign",middot:"Keskpunkt",cedil:"Cedilla",sup1:"Ülaindeks üks",ordm:"Masculine ordinal indicator",raquo:"Right-pointing double angle quotation mark",frac14:"Vulgar fraction one quarter",frac12:"Vulgar fraction one half",frac34:"Vulgar fraction three quarters",iquest:"Inverted question mark",Agrave:"Latin capital letter A with grave accent", Aacute:"Latin capital letter A with acute accent",Acirc:"Latin capital letter A with circumflex",Atilde:"Ladina suur A tildega",Auml:"Latin capital letter A with diaeresis",Aring:"Latin capital letter A with ring above",AElig:"Latin Capital letter Æ",Ccedil:"Latin capital letter C with cedilla",Egrave:"Latin capital letter E with grave accent",Eacute:"Latin capital letter E with acute accent",Ecirc:"Latin capital letter E with circumflex",Euml:"Latin capital letter E with diaeresis",Igrave:"Latin capital letter I with grave accent", Iacute:"Latin capital letter I with acute accent",Icirc:"Latin capital letter I with circumflex",Iuml:"Latin capital letter I with diaeresis",ETH:"Latin capital letter Eth",Ntilde:"Latin capital letter N with tilde",Ograve:"Latin capital letter O with grave accent",Oacute:"Latin capital letter O with acute accent",Ocirc:"Latin capital letter O with circumflex",Otilde:"Latin capital letter O with tilde",Ouml:"Täppidega ladina suur O",times:"Multiplication sign",Oslash:"Latin capital letter O with stroke", Ugrave:"Latin capital letter U with grave accent",Uacute:"Latin capital letter U with acute accent",Ucirc:"Kandilise katusega suur ladina U",Uuml:"Täppidega ladina suur U",Yacute:"Latin capital letter Y with acute accent",THORN:"Latin capital letter Thorn",szlig:"Ladina väike terav s",agrave:"Latin small letter a with grave accent",aacute:"Latin small letter a with acute accent",acirc:"Kandilise katusega ladina väike a",atilde:"Tildega ladina väike a",auml:"Täppidega ladina väike a",aring:"Latin small letter a with ring above", aelig:"Latin small letter æ",ccedil:"Latin small letter c with cedilla",egrave:"Latin small letter e with grave accent",eacute:"Latin small letter e with acute accent",ecirc:"Latin small letter e with circumflex",euml:"Latin small letter e with diaeresis",igrave:"Latin small letter i with grave accent",iacute:"Latin small letter i with acute accent",icirc:"Latin small letter i with circumflex",iuml:"Latin small letter i with diaeresis",eth:"Latin small letter eth",ntilde:"Latin small letter n with tilde", ograve:"Latin small letter o with grave accent",oacute:"Latin small letter o with acute accent",ocirc:"Latin small letter o with circumflex",otilde:"Latin small letter o with tilde",ouml:"Latin small letter o with diaeresis",divide:"Jagamismärk",oslash:"Latin small letter o with stroke",ugrave:"Latin small letter u with grave accent",uacute:"Latin small letter u with acute accent",ucirc:"Latin small letter u with circumflex",uuml:"Latin small letter u with diaeresis",yacute:"Latin small letter y with acute accent", thorn:"Latin small letter thorn",yuml:"Latin small letter y with diaeresis",OElig:"Latin capital ligature OE",oelig:"Latin small ligature oe",372:"Latin capital letter W with circumflex",374:"Latin capital letter Y with circumflex",373:"Latin small letter w with circumflex",375:"Latin small letter y with circumflex",sbquo:"Single low-9 quotation mark",8219:"Single high-reversed-9 quotation mark",bdquo:"Double low-9 quotation mark",hellip:"Horizontal ellipsis",trade:"Kaubamärgi märk",9658:"Black right-pointing pointer", bull:"Kuul",rarr:"Nool paremale",rArr:"Topeltnool paremale",hArr:"Topeltnool vasakule",diams:"Black diamond suit",asymp:"Ligikaudu võrdne"});
<?php /** * @package Joomla.Site * @subpackage mod_articles_news * * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; ?> <ul class="newsflash-vert<?php echo $params->get('moduleclass_sfx'); ?>"> <?php for ($i = 0, $n = count($list); $i < $n; $i ++) : ?> <?php $item = $list[$i]; ?> <li class="newsflash-item"> <?php require JModuleHelper::getLayoutPath('mod_articles_news', '_item'); ?> <?php if ($n > 1 && (($i < $n - 1) || $params->get('showLastSeparator'))) : ?> <span class="article-separator">&#160;</span> <?php endif; ?> </li> <?php endfor; ?> </ul>
CKEDITOR.plugins.setLang("autoembed","en-au",{embeddingInProgress:"Trying to embed pasted URL...",embeddingFailed:"This URL could not be automatically embedded."});
/* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * * Copyright (C) 2002-2010 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning <charles@aleph1.co.uk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include "yaffs_verify.h" #include "yaffs_trace.h" #include "yaffs_bitmap.h" #include "yaffs_getblockinfo.h" #include "yaffs_nand.h" int yaffs_skip_verification(yaffs_dev_t *dev) { dev=dev; return !(yaffs_trace_mask & (YAFFS_TRACE_VERIFY | YAFFS_TRACE_VERIFY_FULL)); } static int yaffs_skip_full_verification(yaffs_dev_t *dev) { dev=dev; return !(yaffs_trace_mask & (YAFFS_TRACE_VERIFY_FULL)); } static int yaffs_skip_nand_verification(yaffs_dev_t *dev) { dev=dev; return !(yaffs_trace_mask & (YAFFS_TRACE_VERIFY_NAND)); } static const char *block_stateName[] = { "Unknown", "Needs scanning", "Scanning", "Empty", "Allocating", "Full", "Dirty", "Checkpoint", "Collecting", "Dead" }; void yaffs_verify_blk(yaffs_dev_t *dev, yaffs_block_info_t *bi, int n) { int actuallyUsed; int inUse; if (yaffs_skip_verification(dev)) return; /* Report illegal runtime states */ if (bi->block_state >= YAFFS_NUMBER_OF_BLOCK_STATES) T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has undefined state %d"TENDSTR), n, bi->block_state)); switch (bi->block_state) { case YAFFS_BLOCK_STATE_UNKNOWN: case YAFFS_BLOCK_STATE_SCANNING: case YAFFS_BLOCK_STATE_NEEDS_SCANNING: T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has bad run-state %s"TENDSTR), n, block_stateName[bi->block_state])); } /* Check pages in use and soft deletions are legal */ actuallyUsed = bi->pages_in_use - bi->soft_del_pages; if (bi->pages_in_use < 0 || bi->pages_in_use > dev->param.chunks_per_block || bi->soft_del_pages < 0 || bi->soft_del_pages > dev->param.chunks_per_block || actuallyUsed < 0 || actuallyUsed > dev->param.chunks_per_block) T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has illegal values pages_in_used %d soft_del_pages %d"TENDSTR), n, bi->pages_in_use, bi->soft_del_pages)); /* Check chunk bitmap legal */ inUse = yaffs_count_chunk_bits(dev, n); if (inUse != bi->pages_in_use) T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has inconsistent values pages_in_use %d counted chunk bits %d"TENDSTR), n, bi->pages_in_use, inUse)); } void yaffs_verify_collected_blk(yaffs_dev_t *dev, yaffs_block_info_t *bi, int n) { yaffs_verify_blk(dev, bi, n); /* After collection the block should be in the erased state */ if (bi->block_state != YAFFS_BLOCK_STATE_COLLECTING && bi->block_state != YAFFS_BLOCK_STATE_EMPTY) { T(YAFFS_TRACE_ERROR, (TSTR("Block %d is in state %d after gc, should be erased"TENDSTR), n, bi->block_state)); } } void yaffs_verify_blocks(yaffs_dev_t *dev) { int i; int nBlocksPerState[YAFFS_NUMBER_OF_BLOCK_STATES]; int nIllegalBlockStates = 0; if (yaffs_skip_verification(dev)) return; memset(nBlocksPerState, 0, sizeof(nBlocksPerState)); for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) { yaffs_block_info_t *bi = yaffs_get_block_info(dev, i); yaffs_verify_blk(dev, bi, i); if (bi->block_state < YAFFS_NUMBER_OF_BLOCK_STATES) nBlocksPerState[bi->block_state]++; else nIllegalBlockStates++; } T(YAFFS_TRACE_VERIFY, (TSTR(""TENDSTR))); T(YAFFS_TRACE_VERIFY, (TSTR("Block summary"TENDSTR))); T(YAFFS_TRACE_VERIFY, (TSTR("%d blocks have illegal states"TENDSTR), nIllegalBlockStates)); if (nBlocksPerState[YAFFS_BLOCK_STATE_ALLOCATING] > 1) T(YAFFS_TRACE_VERIFY, (TSTR("Too many allocating blocks"TENDSTR))); for (i = 0; i < YAFFS_NUMBER_OF_BLOCK_STATES; i++) T(YAFFS_TRACE_VERIFY, (TSTR("%s %d blocks"TENDSTR), block_stateName[i], nBlocksPerState[i])); if (dev->blocks_in_checkpt != nBlocksPerState[YAFFS_BLOCK_STATE_CHECKPOINT]) T(YAFFS_TRACE_VERIFY, (TSTR("Checkpoint block count wrong dev %d count %d"TENDSTR), dev->blocks_in_checkpt, nBlocksPerState[YAFFS_BLOCK_STATE_CHECKPOINT])); if (dev->n_erased_blocks != nBlocksPerState[YAFFS_BLOCK_STATE_EMPTY]) T(YAFFS_TRACE_VERIFY, (TSTR("Erased block count wrong dev %d count %d"TENDSTR), dev->n_erased_blocks, nBlocksPerState[YAFFS_BLOCK_STATE_EMPTY])); if (nBlocksPerState[YAFFS_BLOCK_STATE_COLLECTING] > 1) T(YAFFS_TRACE_VERIFY, (TSTR("Too many collecting blocks %d (max is 1)"TENDSTR), nBlocksPerState[YAFFS_BLOCK_STATE_COLLECTING])); T(YAFFS_TRACE_VERIFY, (TSTR(""TENDSTR))); } /* * Verify the object header. oh must be valid, but obj and tags may be NULL in which * case those tests will not be performed. */ void yaffs_verify_oh(yaffs_obj_t *obj, yaffs_obj_header *oh, yaffs_ext_tags *tags, int parentCheck) { if (obj && yaffs_skip_verification(obj->my_dev)) return; if (!(tags && obj && oh)) { T(YAFFS_TRACE_VERIFY, (TSTR("Verifying object header tags %p obj %p oh %p"TENDSTR), tags, obj, oh)); return; } if (oh->type <= YAFFS_OBJECT_TYPE_UNKNOWN || oh->type > YAFFS_OBJECT_TYPE_MAX) T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header type is illegal value 0x%x"TENDSTR), tags->obj_id, oh->type)); if (tags->obj_id != obj->obj_id) T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header mismatch obj_id %d"TENDSTR), tags->obj_id, obj->obj_id)); /* * Check that the object's parent ids match if parentCheck requested. * * Tests do not apply to the root object. */ if (parentCheck && tags->obj_id > 1 && !obj->parent) T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header mismatch parent_id %d obj->parent is NULL"TENDSTR), tags->obj_id, oh->parent_obj_id)); if (parentCheck && obj->parent && oh->parent_obj_id != obj->parent->obj_id && (oh->parent_obj_id != YAFFS_OBJECTID_UNLINKED || obj->parent->obj_id != YAFFS_OBJECTID_DELETED)) T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header mismatch parent_id %d parent_obj_id %d"TENDSTR), tags->obj_id, oh->parent_obj_id, obj->parent->obj_id)); if (tags->obj_id > 1 && oh->name[0] == 0) /* Null name */ T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header name is NULL"TENDSTR), obj->obj_id)); if (tags->obj_id > 1 && ((__u8)(oh->name[0])) == 0xff) /* Trashed name */ T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d header name is 0xFF"TENDSTR), obj->obj_id)); } #if 0 /* Not being used, but don't want to throw away yet */ int yaffs_verify_tnode_worker(yaffs_obj_t *obj, yaffs_tnode_t *tn, __u32 level, int chunk_offset) { int i; yaffs_dev_t *dev = obj->my_dev; int ok = 1; if (tn) { if (level > 0) { for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++) { if (tn->internal[i]) { ok = yaffs_verify_tnode_worker(obj, tn->internal[i], level - 1, (chunk_offset<<YAFFS_TNODES_INTERNAL_BITS) + i); } } } else if (level == 0) { yaffs_ext_tags tags; __u32 obj_id = obj->obj_id; chunk_offset <<= YAFFS_TNODES_LEVEL0_BITS; for (i = 0; i < YAFFS_NTNODES_LEVEL0; i++) { __u32 theChunk = yaffs_get_group_base(dev, tn, i); if (theChunk > 0) { /* T(~0,(TSTR("verifying (%d:%d) %d"TENDSTR),tags.obj_id,tags.chunk_id,theChunk)); */ yaffs_rd_chunk_tags_nand(dev, theChunk, NULL, &tags); if (tags.obj_id != obj_id || tags.chunk_id != chunk_offset) { T(~0, (TSTR("Object %d chunk_id %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR), obj_id, chunk_offset, theChunk, tags.obj_id, tags.chunk_id)); } } chunk_offset++; } } } return ok; } #endif void yaffs_verify_file(yaffs_obj_t *obj) { int requiredTallness; int actualTallness; __u32 lastChunk; __u32 x; __u32 i; yaffs_dev_t *dev; yaffs_ext_tags tags; yaffs_tnode_t *tn; __u32 obj_id; if (!obj) return; if (yaffs_skip_verification(obj->my_dev)) return; dev = obj->my_dev; obj_id = obj->obj_id; /* Check file size is consistent with tnode depth */ lastChunk = obj->variant.file_variant.file_size / dev->data_bytes_per_chunk + 1; x = lastChunk >> YAFFS_TNODES_LEVEL0_BITS; requiredTallness = 0; while (x > 0) { x >>= YAFFS_TNODES_INTERNAL_BITS; requiredTallness++; } actualTallness = obj->variant.file_variant.top_level; /* Check that the chunks in the tnode tree are all correct. * We do this by scanning through the tnode tree and * checking the tags for every chunk match. */ if (yaffs_skip_nand_verification(dev)) return; for (i = 1; i <= lastChunk; i++) { tn = yaffs_find_tnode_0(dev, &obj->variant.file_variant, i); if (tn) { __u32 theChunk = yaffs_get_group_base(dev, tn, i); if (theChunk > 0) { /* T(~0,(TSTR("verifying (%d:%d) %d"TENDSTR),obj_id,i,theChunk)); */ yaffs_rd_chunk_tags_nand(dev, theChunk, NULL, &tags); if (tags.obj_id != obj_id || tags.chunk_id != i) { T(~0, (TSTR("Object %d chunk_id %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR), obj_id, i, theChunk, tags.obj_id, tags.chunk_id)); } } } } } void yaffs_verify_link(yaffs_obj_t *obj) { if (obj && yaffs_skip_verification(obj->my_dev)) return; /* Verify sane equivalent object */ } void yaffs_verify_symlink(yaffs_obj_t *obj) { if (obj && yaffs_skip_verification(obj->my_dev)) return; /* Verify symlink string */ } void yaffs_verify_special(yaffs_obj_t *obj) { if (obj && yaffs_skip_verification(obj->my_dev)) return; } void yaffs_verify_obj(yaffs_obj_t *obj) { yaffs_dev_t *dev; __u32 chunkMin; __u32 chunkMax; __u32 chunk_idOk; __u32 chunkInRange; __u32 chunkShouldNotBeDeleted; __u32 chunkValid; if (!obj) return; if (obj->being_created) return; dev = obj->my_dev; if (yaffs_skip_verification(dev)) return; /* Check sane object header chunk */ chunkMin = dev->internal_start_block * dev->param.chunks_per_block; chunkMax = (dev->internal_end_block+1) * dev->param.chunks_per_block - 1; chunkInRange = (((unsigned)(obj->hdr_chunk)) >= chunkMin && ((unsigned)(obj->hdr_chunk)) <= chunkMax); chunk_idOk = chunkInRange || (obj->hdr_chunk == 0); chunkValid = chunkInRange && yaffs_check_chunk_bit(dev, obj->hdr_chunk / dev->param.chunks_per_block, obj->hdr_chunk % dev->param.chunks_per_block); chunkShouldNotBeDeleted = chunkInRange && !chunkValid; if (!obj->fake && (!chunk_idOk || chunkShouldNotBeDeleted)) { T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d has chunk_id %d %s %s"TENDSTR), obj->obj_id, obj->hdr_chunk, chunk_idOk ? "" : ",out of range", chunkShouldNotBeDeleted ? ",marked as deleted" : "")); } if (chunkValid && !yaffs_skip_nand_verification(dev)) { yaffs_ext_tags tags; yaffs_obj_header *oh; __u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__); oh = (yaffs_obj_header *)buffer; yaffs_rd_chunk_tags_nand(dev, obj->hdr_chunk, buffer, &tags); yaffs_verify_oh(obj, oh, &tags, 1); yaffs_release_temp_buffer(dev, buffer, __LINE__); } /* Verify it has a parent */ if (obj && !obj->fake && (!obj->parent || obj->parent->my_dev != dev)) { T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d has parent pointer %p which does not look like an object"TENDSTR), obj->obj_id, obj->parent)); } /* Verify parent is a directory */ if (obj->parent && obj->parent->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) { T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d's parent is not a directory (type %d)"TENDSTR), obj->obj_id, obj->parent->variant_type)); } switch (obj->variant_type) { case YAFFS_OBJECT_TYPE_FILE: yaffs_verify_file(obj); break; case YAFFS_OBJECT_TYPE_SYMLINK: yaffs_verify_symlink(obj); break; case YAFFS_OBJECT_TYPE_DIRECTORY: yaffs_verify_dir(obj); break; case YAFFS_OBJECT_TYPE_HARDLINK: yaffs_verify_link(obj); break; case YAFFS_OBJECT_TYPE_SPECIAL: yaffs_verify_special(obj); break; case YAFFS_OBJECT_TYPE_UNKNOWN: default: T(YAFFS_TRACE_VERIFY, (TSTR("Obj %d has illegaltype %d"TENDSTR), obj->obj_id, obj->variant_type)); break; } } void yaffs_verify_objects(yaffs_dev_t *dev) { yaffs_obj_t *obj; int i; struct ylist_head *lh; if (yaffs_skip_verification(dev)) return; /* Iterate through the objects in each hash entry */ for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) { ylist_for_each(lh, &dev->obj_bucket[i].list) { if (lh) { obj = ylist_entry(lh, yaffs_obj_t, hash_link); yaffs_verify_obj(obj); } } } } void yaffs_verify_obj_in_dir(yaffs_obj_t *obj) { struct ylist_head *lh; yaffs_obj_t *listObj; int count = 0; if (!obj) { T(YAFFS_TRACE_ALWAYS, (TSTR("No object to verify" TENDSTR))); YBUG(); return; } if (yaffs_skip_verification(obj->my_dev)) return; if (!obj->parent) { T(YAFFS_TRACE_ALWAYS, (TSTR("Object does not have parent" TENDSTR))); YBUG(); return; } if (obj->parent->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) { T(YAFFS_TRACE_ALWAYS, (TSTR("Parent is not directory" TENDSTR))); YBUG(); } /* Iterate through the objects in each hash entry */ ylist_for_each(lh, &obj->parent->variant.dir_variant.children) { if (lh) { listObj = ylist_entry(lh, yaffs_obj_t, siblings); yaffs_verify_obj(listObj); if (obj == listObj) count++; } } if (count != 1) { T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory %d times" TENDSTR), count)); YBUG(); } } void yaffs_verify_dir(yaffs_obj_t *directory) { struct ylist_head *lh; yaffs_obj_t *listObj; if (!directory) { YBUG(); return; } if (yaffs_skip_full_verification(directory->my_dev)) return; if (directory->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) { T(YAFFS_TRACE_ALWAYS, (TSTR("Directory has wrong type: %d" TENDSTR), directory->variant_type)); YBUG(); } /* Iterate through the objects in each hash entry */ ylist_for_each(lh, &directory->variant.dir_variant.children) { if (lh) { listObj = ylist_entry(lh, yaffs_obj_t, siblings); if (listObj->parent != directory) { T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory list has wrong parent %p" TENDSTR), listObj->parent)); YBUG(); } yaffs_verify_obj_in_dir(listObj); } } } static int yaffs_free_verification_failures; void yaffs_verify_free_chunks(yaffs_dev_t *dev) { int counted; int difference; if (yaffs_skip_verification(dev)) return; counted = yaffs_count_free_chunks(dev); difference = dev->n_free_chunks - counted; if (difference) { T(YAFFS_TRACE_ALWAYS, (TSTR("Freechunks verification failure %d %d %d" TENDSTR), dev->n_free_chunks, counted, difference)); yaffs_free_verification_failures++; } } int yaffs_verify_file_sane(yaffs_obj_t *in) { #if 0 int chunk; int n_chunks; int fSize; int failed = 0; int obj_id; yaffs_tnode_t *tn; yaffs_tags_t localTags; yaffs_tags_t *tags = &localTags; int theChunk; int is_deleted; if (in->variant_type != YAFFS_OBJECT_TYPE_FILE) return YAFFS_FAIL; obj_id = in->obj_id; fSize = in->variant.file_variant.file_size; n_chunks = (fSize + in->my_dev->data_bytes_per_chunk - 1) / in->my_dev->data_bytes_per_chunk; for (chunk = 1; chunk <= n_chunks; chunk++) { tn = yaffs_find_tnode_0(in->my_dev, &in->variant.file_variant, chunk); if (tn) { theChunk = yaffs_get_group_base(dev, tn, chunk); if (yaffs_check_chunk_bits (dev, theChunk / dev->param.chunks_per_block, theChunk % dev->param.chunks_per_block)) { yaffs_rd_chunk_tags_nand(in->my_dev, theChunk, tags, &is_deleted); if (yaffs_tags_match (tags, in->obj_id, chunk, is_deleted)) { /* found it; */ } } else { failed = 1; } } else { /* T(("No level 0 found for %d\n", chunk)); */ } } return failed ? YAFFS_FAIL : YAFFS_OK; #else in=in; return YAFFS_OK; #endif }
/* * Kernel Probes (KProbes) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Copyright (C) IBM Corporation, 2002, 2004 * * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel * Probes initial implementation ( includes contributions from * Rusty Russell). * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes * interface to access function arguments. * 2004-Oct Jim Keniston <jkenisto@us.ibm.com> and Prasanna S Panchamukhi * <prasanna@in.ibm.com> adapted for x86_64 from i386. * 2005-Mar Roland McGrath <roland@redhat.com> * Fixed to handle %rip-relative addressing mode correctly. * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi * <prasanna@in.ibm.com> added function-return probes. * 2005-May Rusty Lynch <rusty.lynch@intel.com> * Added function return probes functionality * 2006-Feb Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp> added * kprobe-booster and kretprobe-booster for i386. * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com> added kprobe-booster * and kretprobe-booster for x86-64 * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com>, Arjan van de Ven * <arjan@infradead.org> and Jim Keniston <jkenisto@us.ibm.com> * unified x86 kprobes code. */ #include <linux/kprobes.h> #include <linux/ptrace.h> #include <linux/string.h> #include <linux/slab.h> #include <linux/hardirq.h> #include <linux/preempt.h> #include <linux/module.h> #include <linux/kdebug.h> #include <linux/kallsyms.h> #include <linux/ftrace.h> #include <asm/cacheflush.h> #include <asm/desc.h> #include <asm/pgtable.h> #include <asm/uaccess.h> #include <asm/alternative.h> #include <asm/insn.h> #include <asm/debugreg.h> #include "kprobes-common.h" void jprobe_return_end(void); DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); #define stack_addr(regs) ((unsigned long *)kernel_stack_pointer(regs)) #define W(row, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf)\ (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \ (b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) | \ (b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) | \ (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \ << (row % 32)) /* * Undefined/reserved opcodes, conditional jump, Opcode Extension * Groups, and some special opcodes can not boost. * This is non-const and volatile to keep gcc from statically * optimizing it out, as variable_test_bit makes gcc think only * *(unsigned long*) is used. */ static volatile u32 twobyte_is_boostable[256 / 32] = { /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ /* ---------------------------------------------- */ W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */ W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */ W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */ W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */ W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */ W(0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 50 */ W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1) | /* 60 */ W(0x70, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) , /* 70 */ W(0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 80 */ W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */ W(0xa0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* a0 */ W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1) , /* b0 */ W(0xc0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */ W(0xd0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) , /* d0 */ W(0xe0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* e0 */ W(0xf0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0) /* f0 */ /* ----------------------------------------------- */ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ }; #undef W struct kretprobe_blackpoint kretprobe_blacklist[] = { {"__switch_to", }, /* This function switches only current task, but doesn't switch kernel stack.*/ {NULL, NULL} /* Terminator */ }; const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist); static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op) { struct __arch_relative_insn { u8 op; s32 raddr; } __attribute__((packed)) *insn; insn = (struct __arch_relative_insn *)from; insn->raddr = (s32)((long)(to) - ((long)(from) + 5)); insn->op = op; } /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/ void __kprobes synthesize_reljump(void *from, void *to) { __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE); } /* Insert a call instruction at address 'from', which calls address 'to'.*/ void __kprobes synthesize_relcall(void *from, void *to) { __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE); } /* * Skip the prefixes of the instruction. */ static kprobe_opcode_t *__kprobes skip_prefixes(kprobe_opcode_t *insn) { insn_attr_t attr; attr = inat_get_opcode_attribute((insn_byte_t)*insn); while (inat_is_legacy_prefix(attr)) { insn++; attr = inat_get_opcode_attribute((insn_byte_t)*insn); } #ifdef CONFIG_X86_64 if (inat_is_rex_prefix(attr)) insn++; #endif return insn; } /* * Returns non-zero if opcode is boostable. * RIP relative instructions are adjusted at copying time in 64 bits mode */ int __kprobes can_boost(kprobe_opcode_t *opcodes) { kprobe_opcode_t opcode; kprobe_opcode_t *orig_opcodes = opcodes; if (search_exception_tables((unsigned long)opcodes)) return 0; /* Page fault may occur on this address. */ retry: if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) return 0; opcode = *(opcodes++); /* 2nd-byte opcode */ if (opcode == 0x0f) { if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) return 0; return test_bit(*opcodes, (unsigned long *)twobyte_is_boostable); } switch (opcode & 0xf0) { #ifdef CONFIG_X86_64 case 0x40: goto retry; /* REX prefix is boostable */ #endif case 0x60: if (0x63 < opcode && opcode < 0x67) goto retry; /* prefixes */ /* can't boost Address-size override and bound */ return (opcode != 0x62 && opcode != 0x67); case 0x70: return 0; /* can't boost conditional jump */ case 0xc0: /* can't boost software-interruptions */ return (0xc1 < opcode && opcode < 0xcc) || opcode == 0xcf; case 0xd0: /* can boost AA* and XLAT */ return (opcode == 0xd4 || opcode == 0xd5 || opcode == 0xd7); case 0xe0: /* can boost in/out and absolute jmps */ return ((opcode & 0x04) || opcode == 0xea); case 0xf0: if ((opcode & 0x0c) == 0 && opcode != 0xf1) goto retry; /* lock/rep(ne) prefix */ /* clear and set flags are boostable */ return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe)); default: /* segment override prefixes are boostable */ if (opcode == 0x26 || opcode == 0x36 || opcode == 0x3e) goto retry; /* prefixes */ /* CS override prefix and call are not boostable */ return (opcode != 0x2e && opcode != 0x9a); } } static unsigned long __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) { struct kprobe *kp; kp = get_kprobe((void *)addr); /* There is no probe, return original address */ if (!kp) return addr; /* * Basically, kp->ainsn.insn has an original instruction. * However, RIP-relative instruction can not do single-stepping * at different place, __copy_instruction() tweaks the displacement of * that instruction. In that case, we can't recover the instruction * from the kp->ainsn.insn. * * On the other hand, kp->opcode has a copy of the first byte of * the probed instruction, which is overwritten by int3. And * the instruction at kp->addr is not modified by kprobes except * for the first byte, we can recover the original instruction * from it and kp->opcode. */ memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); buf[0] = kp->opcode; return (unsigned long)buf; } /* * Recover the probed instruction at addr for further analysis. * Caller must lock kprobes by kprobe_mutex, or disable preemption * for preventing to release referencing kprobes. */ unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr) { unsigned long __addr; __addr = __recover_optprobed_insn(buf, addr); if (__addr != addr) return __addr; return __recover_probed_insn(buf, addr); } /* Check if paddr is at an instruction boundary */ static int __kprobes can_probe(unsigned long paddr) { unsigned long addr, __addr, offset = 0; struct insn insn; kprobe_opcode_t buf[MAX_INSN_SIZE]; if (!kallsyms_lookup_size_offset(paddr, NULL, &offset)) return 0; /* Decode instructions */ addr = paddr - offset; while (addr < paddr) { /* * Check if the instruction has been modified by another * kprobe, in which case we replace the breakpoint by the * original instruction in our buffer. * Also, jump optimization will change the breakpoint to * relative-jump. Since the relative-jump itself is * normally used, we just go through if there is no kprobe. */ __addr = recover_probed_instruction(buf, addr); kernel_insn_init(&insn, (void *)__addr); insn_get_length(&insn); /* * Another debugging subsystem might insert this breakpoint. * In that case, we can't recover it. */ if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; addr += insn.length; } return (addr == paddr); } /* * Returns non-zero if opcode modifies the interrupt flag. */ static int __kprobes is_IF_modifier(kprobe_opcode_t *insn) { /* Skip prefixes */ insn = skip_prefixes(insn); switch (*insn) { case 0xfa: /* cli */ case 0xfb: /* sti */ case 0xcf: /* iret/iretd */ case 0x9d: /* popf/popfd */ return 1; } return 0; } /* * Copy an instruction and adjust the displacement if the instruction * uses the %rip-relative addressing mode. * If it does, Return the address of the 32-bit displacement word. * If not, return null. * Only applicable to 64-bit x86. */ int __kprobes __copy_instruction(u8 *dest, u8 *src) { struct insn insn; kprobe_opcode_t buf[MAX_INSN_SIZE]; kernel_insn_init(&insn, (void *)recover_probed_instruction(buf, (unsigned long)src)); insn_get_length(&insn); /* Another subsystem puts a breakpoint, failed to recover */ if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; memcpy(dest, insn.kaddr, insn.length); #ifdef CONFIG_X86_64 if (insn_rip_relative(&insn)) { s64 newdisp; u8 *disp; kernel_insn_init(&insn, dest); insn_get_displacement(&insn); /* * The copied instruction uses the %rip-relative addressing * mode. Adjust the displacement for the difference between * the original location of this instruction and the location * of the copy that will actually be run. The tricky bit here * is making sure that the sign extension happens correctly in * this calculation, since we need a signed 32-bit result to * be sign-extended to 64 bits when it's added to the %rip * value and yield the same 64-bit result that the sign- * extension of the original signed 32-bit displacement would * have given. */ newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest; BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */ disp = (u8 *) dest + insn_offset_displacement(&insn); *(s32 *) disp = (s32) newdisp; } #endif return insn.length; } static void __kprobes arch_copy_kprobe(struct kprobe *p) { /* Copy an instruction with recovering if other optprobe modifies it.*/ __copy_instruction(p->ainsn.insn, p->addr); /* * __copy_instruction can modify the displacement of the instruction, * but it doesn't affect boostable check. */ if (can_boost(p->ainsn.insn)) p->ainsn.boostable = 0; else p->ainsn.boostable = -1; /* Also, displacement change doesn't affect the first byte */ p->opcode = p->ainsn.insn[0]; } int __kprobes arch_prepare_kprobe(struct kprobe *p) { if (alternatives_text_reserved(p->addr, p->addr)) return -EINVAL; if (!can_probe((unsigned long)p->addr)) return -EILSEQ; /* insn: must be on special executable page on x86. */ p->ainsn.insn = get_insn_slot(); if (!p->ainsn.insn) return -ENOMEM; arch_copy_kprobe(p); return 0; } void __kprobes arch_arm_kprobe(struct kprobe *p) { text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1); } void __kprobes arch_disarm_kprobe(struct kprobe *p) { text_poke(p->addr, &p->opcode, 1); } void __kprobes arch_remove_kprobe(struct kprobe *p) { if (p->ainsn.insn) { free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1)); p->ainsn.insn = NULL; } } static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) { kcb->prev_kprobe.kp = kprobe_running(); kcb->prev_kprobe.status = kcb->kprobe_status; kcb->prev_kprobe.old_flags = kcb->kprobe_old_flags; kcb->prev_kprobe.saved_flags = kcb->kprobe_saved_flags; } static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) { __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); kcb->kprobe_status = kcb->prev_kprobe.status; kcb->kprobe_old_flags = kcb->prev_kprobe.old_flags; kcb->kprobe_saved_flags = kcb->prev_kprobe.saved_flags; } static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb) { __this_cpu_write(current_kprobe, p); kcb->kprobe_saved_flags = kcb->kprobe_old_flags = (regs->flags & (X86_EFLAGS_TF | X86_EFLAGS_IF)); if (is_IF_modifier(p->ainsn.insn)) kcb->kprobe_saved_flags &= ~X86_EFLAGS_IF; } static void __kprobes clear_btf(void) { if (test_thread_flag(TIF_BLOCKSTEP)) { unsigned long debugctl = get_debugctlmsr(); debugctl &= ~DEBUGCTLMSR_BTF; update_debugctlmsr(debugctl); } } static void __kprobes restore_btf(void) { if (test_thread_flag(TIF_BLOCKSTEP)) { unsigned long debugctl = get_debugctlmsr(); debugctl |= DEBUGCTLMSR_BTF; update_debugctlmsr(debugctl); } } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs) { unsigned long *sara = stack_addr(regs); ri->ret_addr = (kprobe_opcode_t *) *sara; /* Replace the return addr with trampoline addr */ *sara = (unsigned long) &kretprobe_trampoline; } static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb, int reenter) { if (setup_detour_execution(p, regs, reenter)) return; #if !defined(CONFIG_PREEMPT) if (p->ainsn.boostable == 1 && !p->post_handler) { /* Boost up -- we can execute copied instructions directly */ if (!reenter) reset_current_kprobe(); /* * Reentering boosted probe doesn't reset current_kprobe, * nor set current_kprobe, because it doesn't use single * stepping. */ regs->ip = (unsigned long)p->ainsn.insn; preempt_enable_no_resched(); return; } #endif if (reenter) { save_previous_kprobe(kcb); set_current_kprobe(p, regs, kcb); kcb->kprobe_status = KPROBE_REENTER; } else kcb->kprobe_status = KPROBE_HIT_SS; /* Prepare real single stepping */ clear_btf(); regs->flags |= X86_EFLAGS_TF; regs->flags &= ~X86_EFLAGS_IF; /* single step inline if the instruction is an int3 */ if (p->opcode == BREAKPOINT_INSTRUCTION) regs->ip = (unsigned long)p->addr; else regs->ip = (unsigned long)p->ainsn.insn; } /* * We have reentered the kprobe_handler(), since another probe was hit while * within the handler. We save the original kprobes variables and just single * step on the instruction of the new probe without calling any user handlers. */ static int __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb) { switch (kcb->kprobe_status) { case KPROBE_HIT_SSDONE: case KPROBE_HIT_ACTIVE: kprobes_inc_nmissed_count(p); setup_singlestep(p, regs, kcb, 1); break; case KPROBE_HIT_SS: /* A probe has been hit in the codepath leading up to, or just * after, single-stepping of a probed instruction. This entire * codepath should strictly reside in .kprobes.text section. * Raise a BUG or we'll continue in an endless reentering loop * and eventually a stack overflow. */ printk(KERN_WARNING "Unrecoverable kprobe detected at %p.\n", p->addr); dump_kprobe(p); BUG(); default: /* impossible cases */ WARN_ON(1); return 0; } return 1; } #ifdef KPROBES_CAN_USE_FTRACE static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb) { /* * Emulate singlestep (and also recover regs->ip) * as if there is a 5byte nop */ regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE; if (unlikely(p->post_handler)) { kcb->kprobe_status = KPROBE_HIT_SSDONE; p->post_handler(p, regs, 0); } __this_cpu_write(current_kprobe, NULL); } #endif /* * Interrupts are disabled on entry as trap3 is an interrupt gate and they * remain disabled throughout this function. */ static int __kprobes kprobe_handler(struct pt_regs *regs) { kprobe_opcode_t *addr; struct kprobe *p; struct kprobe_ctlblk *kcb; addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t)); /* * We don't want to be preempted for the entire * duration of kprobe processing. We conditionally * re-enable preemption at the end of this function, * and also in reenter_kprobe() and setup_singlestep(). */ preempt_disable(); kcb = get_kprobe_ctlblk(); p = get_kprobe(addr); if (p) { if (kprobe_running()) { if (reenter_kprobe(p, regs, kcb)) return 1; } else { set_current_kprobe(p, regs, kcb); kcb->kprobe_status = KPROBE_HIT_ACTIVE; /* * If we have no pre-handler or it returned 0, we * continue with normal processing. If we have a * pre-handler and it returned non-zero, it prepped * for calling the break_handler below on re-entry * for jprobe processing, so get out doing nothing * more here. */ if (!p->pre_handler || !p->pre_handler(p, regs)) setup_singlestep(p, regs, kcb, 0); return 1; } } else if (*addr != BREAKPOINT_INSTRUCTION) { /* * The breakpoint instruction was removed right * after we hit it. Another cpu has removed * either a probepoint or a debugger breakpoint * at this address. In either case, no further * handling of this interrupt is appropriate. * Back up over the (now missing) int3 and run * the original instruction. */ regs->ip = (unsigned long)addr; preempt_enable_no_resched(); return 1; } else if (kprobe_running()) { p = __this_cpu_read(current_kprobe); if (p->break_handler && p->break_handler(p, regs)) { #ifdef KPROBES_CAN_USE_FTRACE if (kprobe_ftrace(p)) { skip_singlestep(p, regs, kcb); return 1; } #endif setup_singlestep(p, regs, kcb, 0); return 1; } } /* else: not a kprobe fault; let the kernel handle it */ preempt_enable_no_resched(); return 0; } /* * When a retprobed function returns, this code saves registers and * calls trampoline_handler() runs, which calls the kretprobe's handler. */ static void __used __kprobes kretprobe_trampoline_holder(void) { asm volatile ( ".global kretprobe_trampoline\n" "kretprobe_trampoline: \n" #ifdef CONFIG_X86_64 /* We don't bother saving the ss register */ " pushq %rsp\n" " pushfq\n" SAVE_REGS_STRING " movq %rsp, %rdi\n" " call trampoline_handler\n" /* Replace saved sp with true return address. */ " movq %rax, 152(%rsp)\n" RESTORE_REGS_STRING " popfq\n" #else " pushf\n" SAVE_REGS_STRING " movl %esp, %eax\n" " call trampoline_handler\n" /* Move flags to cs */ " movl 56(%esp), %edx\n" " movl %edx, 52(%esp)\n" /* Replace saved flags with true return address. */ " movl %eax, 56(%esp)\n" RESTORE_REGS_STRING " popf\n" #endif " ret\n"); } /* * Called from kretprobe_trampoline */ static __used __kprobes void *trampoline_handler(struct pt_regs *regs) { struct kretprobe_instance *ri = NULL; struct hlist_head *head, empty_rp; struct hlist_node *node, *tmp; unsigned long flags, orig_ret_address = 0; unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; kprobe_opcode_t *correct_ret_addr = NULL; INIT_HLIST_HEAD(&empty_rp); kretprobe_hash_lock(current, &head, &flags); /* fixup registers */ #ifdef CONFIG_X86_64 regs->cs = __KERNEL_CS; #else regs->cs = __KERNEL_CS | get_kernel_rpl(); regs->gs = 0; #endif regs->ip = trampoline_address; regs->orig_ax = ~0UL; /* * It is possible to have multiple instances associated with a given * task either because multiple functions in the call path have * return probes installed on them, and/or more than one * return probe was registered for a target function. * * We can handle this because: * - instances are always pushed into the head of the list * - when multiple return probes are registered for the same * function, the (chronologically) first instance's ret_addr * will be the real return address, and all the rest will * point to kretprobe_trampoline. */ hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { if (ri->task != current) /* another task is sharing our hash bucket */ continue; orig_ret_address = (unsigned long)ri->ret_addr; if (orig_ret_address != trampoline_address) /* * This is the real return address. Any other * instances associated with this task are for * other calls deeper on the call stack */ break; } kretprobe_assert(ri, orig_ret_address, trampoline_address); correct_ret_addr = ri->ret_addr; hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { if (ri->task != current) /* another task is sharing our hash bucket */ continue; orig_ret_address = (unsigned long)ri->ret_addr; if (ri->rp && ri->rp->handler) { __this_cpu_write(current_kprobe, &ri->rp->kp); get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE; ri->ret_addr = correct_ret_addr; ri->rp->handler(ri, regs); __this_cpu_write(current_kprobe, NULL); } recycle_rp_inst(ri, &empty_rp); if (orig_ret_address != trampoline_address) /* * This is the real return address. Any other * instances associated with this task are for * other calls deeper on the call stack */ break; } kretprobe_hash_unlock(current, &flags); hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_del(&ri->hlist); kfree(ri); } return (void *)orig_ret_address; } /* * Called after single-stepping. p->addr is the address of the * instruction whose first byte has been replaced by the "int 3" * instruction. To avoid the SMP problems that can occur when we * temporarily put back the original opcode to single-step, we * single-stepped a copy of the instruction. The address of this * copy is p->ainsn.insn. * * This function prepares to return from the post-single-step * interrupt. We have to fix up the stack as follows: * * 0) Except in the case of absolute or indirect jump or call instructions, * the new ip is relative to the copied instruction. We need to make * it relative to the original instruction. * * 1) If the single-stepped instruction was pushfl, then the TF and IF * flags are set in the just-pushed flags, and may need to be cleared. * * 2) If the single-stepped instruction was a call, the return address * that is atop the stack is the address following the copied instruction. * We need to make it the address following the original instruction. * * If this is the first time we've single-stepped the instruction at * this probepoint, and the instruction is boostable, boost it: add a * jump instruction after the copied instruction, that jumps to the next * instruction after the probepoint. */ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb) { unsigned long *tos = stack_addr(regs); unsigned long copy_ip = (unsigned long)p->ainsn.insn; unsigned long orig_ip = (unsigned long)p->addr; kprobe_opcode_t *insn = p->ainsn.insn; /* Skip prefixes */ insn = skip_prefixes(insn); regs->flags &= ~X86_EFLAGS_TF; switch (*insn) { case 0x9c: /* pushfl */ *tos &= ~(X86_EFLAGS_TF | X86_EFLAGS_IF); *tos |= kcb->kprobe_old_flags; break; case 0xc2: /* iret/ret/lret */ case 0xc3: case 0xca: case 0xcb: case 0xcf: case 0xea: /* jmp absolute -- ip is correct */ /* ip is already adjusted, no more changes required */ p->ainsn.boostable = 1; goto no_change; case 0xe8: /* call relative - Fix return addr */ *tos = orig_ip + (*tos - copy_ip); break; #ifdef CONFIG_X86_32 case 0x9a: /* call absolute -- same as call absolute, indirect */ *tos = orig_ip + (*tos - copy_ip); goto no_change; #endif case 0xff: if ((insn[1] & 0x30) == 0x10) { /* * call absolute, indirect * Fix return addr; ip is correct. * But this is not boostable */ *tos = orig_ip + (*tos - copy_ip); goto no_change; } else if (((insn[1] & 0x31) == 0x20) || ((insn[1] & 0x31) == 0x21)) { /* * jmp near and far, absolute indirect * ip is correct. And this is boostable */ p->ainsn.boostable = 1; goto no_change; } default: break; } if (p->ainsn.boostable == 0) { if ((regs->ip > copy_ip) && (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) { /* * These instructions can be executed directly if it * jumps back to correct address. */ synthesize_reljump((void *)regs->ip, (void *)orig_ip + (regs->ip - copy_ip)); p->ainsn.boostable = 1; } else { p->ainsn.boostable = -1; } } regs->ip += orig_ip - copy_ip; no_change: restore_btf(); } /* * Interrupts are disabled on entry as trap1 is an interrupt gate and they * remain disabled throughout this function. */ static int __kprobes post_kprobe_handler(struct pt_regs *regs) { struct kprobe *cur = kprobe_running(); struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); if (!cur) return 0; resume_execution(cur, regs, kcb); regs->flags |= kcb->kprobe_saved_flags; if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) { kcb->kprobe_status = KPROBE_HIT_SSDONE; cur->post_handler(cur, regs, 0); } /* Restore back the original saved kprobes variables and continue. */ if (kcb->kprobe_status == KPROBE_REENTER) { restore_previous_kprobe(kcb); goto out; } reset_current_kprobe(); out: preempt_enable_no_resched(); /* * if somebody else is singlestepping across a probe point, flags * will have TF set, in which case, continue the remaining processing * of do_debug, as if this is not a probe hit. */ if (regs->flags & X86_EFLAGS_TF) return 0; return 1; } int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) { struct kprobe *cur = kprobe_running(); struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); switch (kcb->kprobe_status) { case KPROBE_HIT_SS: case KPROBE_REENTER: /* * We are here because the instruction being single * stepped caused a page fault. We reset the current * kprobe and the ip points back to the probe address * and allow the page fault handler to continue as a * normal page fault. */ regs->ip = (unsigned long)cur->addr; regs->flags |= kcb->kprobe_old_flags; if (kcb->kprobe_status == KPROBE_REENTER) restore_previous_kprobe(kcb); else reset_current_kprobe(); preempt_enable_no_resched(); break; case KPROBE_HIT_ACTIVE: case KPROBE_HIT_SSDONE: /* * We increment the nmissed count for accounting, * we can also use npre/npostfault count for accounting * these specific fault cases. */ kprobes_inc_nmissed_count(cur); /* * We come here because instructions in the pre/post * handler caused the page_fault, this could happen * if handler tries to access user space by * copy_from_user(), get_user() etc. Let the * user-specified handler try to fix it first. */ if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) return 1; /* * In case the user-specified fault handler returned * zero, try to fix up. */ if (fixup_exception(regs)) return 1; /* * fixup routine could not handle it, * Let do_page_fault() fix it. */ break; default: break; } return 0; } /* * Wrapper routine for handling exceptions. */ int __kprobes kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *data) { struct die_args *args = data; int ret = NOTIFY_DONE; if (args->regs && user_mode_vm(args->regs)) return ret; switch (val) { case DIE_INT3: if (kprobe_handler(args->regs)) ret = NOTIFY_STOP; break; case DIE_DEBUG: if (post_kprobe_handler(args->regs)) { /* * Reset the BS bit in dr6 (pointed by args->err) to * denote completion of processing */ (*(unsigned long *)ERR_PTR(args->err)) &= ~DR_STEP; ret = NOTIFY_STOP; } break; case DIE_GPF: /* * To be potentially processing a kprobe fault and to * trust the result from kprobe_running(), we have * be non-preemptible. */ if (!preemptible() && kprobe_running() && kprobe_fault_handler(args->regs, args->trapnr)) ret = NOTIFY_STOP; break; default: break; } return ret; } int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) { struct jprobe *jp = container_of(p, struct jprobe, kp); unsigned long addr; struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); kcb->jprobe_saved_regs = *regs; kcb->jprobe_saved_sp = stack_addr(regs); addr = (unsigned long)(kcb->jprobe_saved_sp); /* * As Linus pointed out, gcc assumes that the callee * owns the argument space and could overwrite it, e.g. * tailcall optimization. So, to be absolutely safe * we also save and restore enough stack bytes to cover * the argument area. */ memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr, MIN_STACK_SIZE(addr)); regs->flags &= ~X86_EFLAGS_IF; trace_hardirqs_off(); regs->ip = (unsigned long)(jp->entry); return 1; } void __kprobes jprobe_return(void) { struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); asm volatile ( #ifdef CONFIG_X86_64 " xchg %%rbx,%%rsp \n" #else " xchgl %%ebx,%%esp \n" #endif " int3 \n" " .globl jprobe_return_end\n" " jprobe_return_end: \n" " nop \n"::"b" (kcb->jprobe_saved_sp):"memory"); } int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) { struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); u8 *addr = (u8 *) (regs->ip - 1); struct jprobe *jp = container_of(p, struct jprobe, kp); if ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) { if (stack_addr(regs) != kcb->jprobe_saved_sp) { struct pt_regs *saved_regs = &kcb->jprobe_saved_regs; printk(KERN_ERR "current sp %p does not match saved sp %p\n", stack_addr(regs), kcb->jprobe_saved_sp); printk(KERN_ERR "Saved registers for jprobe %p\n", jp); show_regs(saved_regs); printk(KERN_ERR "Current registers\n"); show_regs(regs); BUG(); } *regs = kcb->jprobe_saved_regs; memcpy((kprobe_opcode_t *)(kcb->jprobe_saved_sp), kcb->jprobes_stack, MIN_STACK_SIZE(kcb->jprobe_saved_sp)); preempt_enable_no_resched(); return 1; } return 0; } #ifdef KPROBES_CAN_USE_FTRACE /* Ftrace callback handler for kprobes */ void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *ops, struct pt_regs *regs) { struct kprobe *p; struct kprobe_ctlblk *kcb; unsigned long flags; /* Disable irq for emulating a breakpoint and avoiding preempt */ local_irq_save(flags); p = get_kprobe((kprobe_opcode_t *)ip); if (unlikely(!p) || kprobe_disabled(p)) goto end; kcb = get_kprobe_ctlblk(); if (kprobe_running()) { kprobes_inc_nmissed_count(p); } else { /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */ regs->ip = ip + sizeof(kprobe_opcode_t); __this_cpu_write(current_kprobe, p); kcb->kprobe_status = KPROBE_HIT_ACTIVE; if (!p->pre_handler || !p->pre_handler(p, regs)) skip_singlestep(p, regs, kcb); /* * If pre_handler returns !0, it sets regs->ip and * resets current kprobe. */ } end: local_irq_restore(flags); } int __kprobes arch_prepare_kprobe_ftrace(struct kprobe *p) { p->ainsn.insn = NULL; p->ainsn.boostable = -1; return 0; } #endif int __init arch_init_kprobes(void) { return arch_init_optprobes(); } int __kprobes arch_trampoline_kprobe(struct kprobe *p) { return 0; }
// Copyright (c) 2010, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> // cfi_frame_info_unittest.cc: Unit tests for CFIFrameInfo, // CFIRuleParser, CFIFrameInfoParseHandler, and SimpleCFIWalker. #include <string.h> #include "breakpad_googletest_includes.h" #include "processor/cfi_frame_info.h" #include "google_breakpad/processor/memory_region.h" using google_breakpad::CFIFrameInfo; using google_breakpad::CFIFrameInfoParseHandler; using google_breakpad::CFIRuleParser; using google_breakpad::MemoryRegion; using google_breakpad::SimpleCFIWalker; using std::string; using testing::_; using testing::A; using testing::AtMost; using testing::DoAll; using testing::Return; using testing::SetArgumentPointee; using testing::Test; class MockMemoryRegion: public MemoryRegion { public: MOCK_CONST_METHOD0(GetBase, u_int64_t()); MOCK_CONST_METHOD0(GetSize, u_int32_t()); MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int8_t *)); MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int16_t *)); MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int32_t *)); MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int64_t *)); }; // Handy definitions for all tests. struct CFIFixture { // Set up the mock memory object to expect no references. void ExpectNoMemoryReferences() { EXPECT_CALL(memory, GetBase()).Times(0); EXPECT_CALL(memory, GetSize()).Times(0); EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int8_t *>())).Times(0); EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int16_t *>())).Times(0); EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int32_t *>())).Times(0); EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int64_t *>())).Times(0); } CFIFrameInfo cfi; MockMemoryRegion memory; CFIFrameInfo::RegisterValueMap<u_int64_t> registers, caller_registers; }; class Simple: public CFIFixture, public Test { }; // FindCallerRegs should fail if no .cfa rule is provided. TEST_F(Simple, NoCFA) { ExpectNoMemoryReferences(); cfi.SetRARule("0"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(".ra: 0", cfi.Serialize()); } // FindCallerRegs should fail if no .ra rule is provided. TEST_F(Simple, NoRA) { ExpectNoMemoryReferences(); cfi.SetCFARule("0"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(".cfa: 0", cfi.Serialize()); } TEST_F(Simple, SetCFAAndRARule) { ExpectNoMemoryReferences(); cfi.SetCFARule("330903416631436410"); cfi.SetRARule("5870666104170902211"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(2U, caller_registers.size()); ASSERT_EQ(330903416631436410ULL, caller_registers[".cfa"]); ASSERT_EQ(5870666104170902211ULL, caller_registers[".ra"]); ASSERT_EQ(".cfa: 330903416631436410 .ra: 5870666104170902211", cfi.Serialize()); } TEST_F(Simple, SetManyRules) { ExpectNoMemoryReferences(); cfi.SetCFARule("$temp1 68737028 = $temp2 61072337 = $temp1 $temp2 -"); cfi.SetRARule(".cfa 99804755 +"); cfi.SetRegisterRule("register1", ".cfa 54370437 *"); cfi.SetRegisterRule("vodkathumbscrewingly", "24076308 .cfa +"); cfi.SetRegisterRule("pubvexingfjordschmaltzy", ".cfa 29801007 -"); cfi.SetRegisterRule("uncopyrightables", "92642917 .cfa /"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(6U, caller_registers.size()); ASSERT_EQ(7664691U, caller_registers[".cfa"]); ASSERT_EQ(107469446U, caller_registers[".ra"]); ASSERT_EQ(416732599139967ULL, caller_registers["register1"]); ASSERT_EQ(31740999U, caller_registers["vodkathumbscrewingly"]); ASSERT_EQ(-22136316ULL, caller_registers["pubvexingfjordschmaltzy"]); ASSERT_EQ(12U, caller_registers["uncopyrightables"]); ASSERT_EQ(".cfa: $temp1 68737028 = $temp2 61072337 = $temp1 $temp2 - " ".ra: .cfa 99804755 + " "pubvexingfjordschmaltzy: .cfa 29801007 - " "register1: .cfa 54370437 * " "uncopyrightables: 92642917 .cfa / " "vodkathumbscrewingly: 24076308 .cfa +", cfi.Serialize()); } TEST_F(Simple, RulesOverride) { ExpectNoMemoryReferences(); cfi.SetCFARule("330903416631436410"); cfi.SetRARule("5870666104170902211"); cfi.SetCFARule("2828089117179001"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(2U, caller_registers.size()); ASSERT_EQ(2828089117179001ULL, caller_registers[".cfa"]); ASSERT_EQ(5870666104170902211ULL, caller_registers[".ra"]); ASSERT_EQ(".cfa: 2828089117179001 .ra: 5870666104170902211", cfi.Serialize()); } class Scope: public CFIFixture, public Test { }; // There should be no value for .cfa in scope when evaluating the CFA rule. TEST_F(Scope, CFALacksCFA) { ExpectNoMemoryReferences(); cfi.SetCFARule(".cfa"); cfi.SetRARule("0"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); } // There should be no value for .ra in scope when evaluating the CFA rule. TEST_F(Scope, CFALacksRA) { ExpectNoMemoryReferences(); cfi.SetCFARule(".ra"); cfi.SetRARule("0"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); } // The current frame's registers should be in scope when evaluating // the CFA rule. TEST_F(Scope, CFASeesCurrentRegs) { ExpectNoMemoryReferences(); registers[".baraminology"] = 0x06a7bc63e4f13893ULL; registers[".ornithorhynchus"] = 0x5e0bf850bafce9d2ULL; cfi.SetCFARule(".baraminology .ornithorhynchus +"); cfi.SetRARule("0"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(2U, caller_registers.size()); ASSERT_EQ(0x06a7bc63e4f13893ULL + 0x5e0bf850bafce9d2ULL, caller_registers[".cfa"]); } // .cfa should be in scope in the return address expression. TEST_F(Scope, RASeesCFA) { ExpectNoMemoryReferences(); cfi.SetCFARule("48364076"); cfi.SetRARule(".cfa"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(2U, caller_registers.size()); ASSERT_EQ(48364076U, caller_registers[".ra"]); } // There should be no value for .ra in scope when evaluating the CFA rule. TEST_F(Scope, RALacksRA) { ExpectNoMemoryReferences(); cfi.SetCFARule("0"); cfi.SetRARule(".ra"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); } // The current frame's registers should be in scope in the return // address expression. TEST_F(Scope, RASeesCurrentRegs) { ExpectNoMemoryReferences(); registers["noachian"] = 0x54dc4a5d8e5eb503ULL; cfi.SetCFARule("10359370"); cfi.SetRARule("noachian"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(2U, caller_registers.size()); ASSERT_EQ(0x54dc4a5d8e5eb503ULL, caller_registers[".ra"]); } // .cfa should be in scope for register rules. TEST_F(Scope, RegistersSeeCFA) { ExpectNoMemoryReferences(); cfi.SetCFARule("6515179"); cfi.SetRARule(".cfa"); cfi.SetRegisterRule("rogerian", ".cfa"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(3U, caller_registers.size()); ASSERT_EQ(6515179U, caller_registers["rogerian"]); } // The return address should not be in scope for register rules. TEST_F(Scope, RegsLackRA) { ExpectNoMemoryReferences(); cfi.SetCFARule("42740329"); cfi.SetRARule("27045204"); cfi.SetRegisterRule("$r1", ".ra"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); } // Register rules can see the current frame's register values. TEST_F(Scope, RegsSeeRegs) { ExpectNoMemoryReferences(); registers["$r1"] = 0x6ed3582c4bedb9adULL; registers["$r2"] = 0xd27d9e742b8df6d0ULL; cfi.SetCFARule("88239303"); cfi.SetRARule("30503835"); cfi.SetRegisterRule("$r1", "$r1 42175211 = $r2"); cfi.SetRegisterRule("$r2", "$r2 21357221 = $r1"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(4U, caller_registers.size()); ASSERT_EQ(0xd27d9e742b8df6d0ULL, caller_registers["$r1"]); ASSERT_EQ(0x6ed3582c4bedb9adULL, caller_registers["$r2"]); } // Each rule's temporaries are separate. TEST_F(Scope, SeparateTempsRA) { ExpectNoMemoryReferences(); cfi.SetCFARule("$temp1 76569129 = $temp1"); cfi.SetRARule("0"); ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); cfi.SetCFARule("$temp1 76569129 = $temp1"); cfi.SetRARule("$temp1"); ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); } class MockCFIRuleParserHandler: public CFIRuleParser::Handler { public: MOCK_METHOD1(CFARule, void(const string &)); MOCK_METHOD1(RARule, void(const string &)); MOCK_METHOD2(RegisterRule, void(const string &, const string &)); }; // A fixture class for testing CFIRuleParser. class CFIParserFixture { public: CFIParserFixture() : parser(&mock_handler) { // Expect no parsing results to be reported to mock_handler. Individual // tests can override this. EXPECT_CALL(mock_handler, CFARule(_)).Times(0); EXPECT_CALL(mock_handler, RARule(_)).Times(0); EXPECT_CALL(mock_handler, RegisterRule(_, _)).Times(0); } MockCFIRuleParserHandler mock_handler; CFIRuleParser parser; }; class Parser: public CFIParserFixture, public Test { }; TEST_F(Parser, Empty) { EXPECT_FALSE(parser.Parse("")); } TEST_F(Parser, LoneColon) { EXPECT_FALSE(parser.Parse(":")); } TEST_F(Parser, CFANoExpr) { EXPECT_FALSE(parser.Parse(".cfa:")); } TEST_F(Parser, CFANoColonNoExpr) { EXPECT_FALSE(parser.Parse(".cfa")); } TEST_F(Parser, RANoExpr) { EXPECT_FALSE(parser.Parse(".ra:")); } TEST_F(Parser, RANoColonNoExpr) { EXPECT_FALSE(parser.Parse(".ra")); } TEST_F(Parser, RegNoExpr) { EXPECT_FALSE(parser.Parse("reg:")); } TEST_F(Parser, NoName) { EXPECT_FALSE(parser.Parse("expr")); } TEST_F(Parser, NoNameTwo) { EXPECT_FALSE(parser.Parse("expr1 expr2")); } TEST_F(Parser, StartsWithExpr) { EXPECT_FALSE(parser.Parse("expr1 reg: expr2")); } TEST_F(Parser, CFA) { EXPECT_CALL(mock_handler, CFARule("spleen")).WillOnce(Return()); EXPECT_TRUE(parser.Parse(".cfa: spleen")); } TEST_F(Parser, RA) { EXPECT_CALL(mock_handler, RARule("notoriety")).WillOnce(Return()); EXPECT_TRUE(parser.Parse(".ra: notoriety")); } TEST_F(Parser, Reg) { EXPECT_CALL(mock_handler, RegisterRule("nemo", "mellifluous")) .WillOnce(Return()); EXPECT_TRUE(parser.Parse("nemo: mellifluous")); } TEST_F(Parser, CFARARegs) { EXPECT_CALL(mock_handler, CFARule("cfa expression")).WillOnce(Return()); EXPECT_CALL(mock_handler, RARule("ra expression")).WillOnce(Return()); EXPECT_CALL(mock_handler, RegisterRule("galba", "praetorian")) .WillOnce(Return()); EXPECT_CALL(mock_handler, RegisterRule("otho", "vitellius")) .WillOnce(Return()); EXPECT_TRUE(parser.Parse(".cfa: cfa expression .ra: ra expression " "galba: praetorian otho: vitellius")); } TEST_F(Parser, Whitespace) { EXPECT_CALL(mock_handler, RegisterRule("r1", "r1 expression")) .WillOnce(Return()); EXPECT_CALL(mock_handler, RegisterRule("r2", "r2 expression")) .WillOnce(Return()); EXPECT_TRUE(parser.Parse(" r1:\tr1\nexpression \tr2:\t\rr2\r\n " "expression \n")); } TEST_F(Parser, WhitespaceLoneColon) { EXPECT_FALSE(parser.Parse(" \n:\t ")); } TEST_F(Parser, EmptyName) { EXPECT_CALL(mock_handler, RegisterRule("reg", _)) .Times(AtMost(1)) .WillRepeatedly(Return()); EXPECT_FALSE(parser.Parse("reg: expr1 : expr2")); } TEST_F(Parser, RuleLoneColon) { EXPECT_CALL(mock_handler, RegisterRule("r1", "expr")) .Times(AtMost(1)) .WillRepeatedly(Return()); EXPECT_FALSE(parser.Parse(" r1: expr :")); } TEST_F(Parser, RegNoExprRule) { EXPECT_CALL(mock_handler, RegisterRule("r1", "expr")) .Times(AtMost(1)) .WillRepeatedly(Return()); EXPECT_FALSE(parser.Parse("r0: r1: expr")); } class ParseHandlerFixture: public CFIFixture { public: ParseHandlerFixture() : CFIFixture(), handler(&cfi) { } CFIFrameInfoParseHandler handler; }; class ParseHandler: public ParseHandlerFixture, public Test { }; TEST_F(ParseHandler, CFARARule) { handler.CFARule("reg-for-cfa"); handler.RARule("reg-for-ra"); registers["reg-for-cfa"] = 0x268a9a4a3821a797ULL; registers["reg-for-ra"] = 0x6301b475b8b91c02ULL; ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[".cfa"]); ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[".ra"]); } TEST_F(ParseHandler, RegisterRules) { handler.CFARule("reg-for-cfa"); handler.RARule("reg-for-ra"); handler.RegisterRule("reg1", "reg-for-reg1"); handler.RegisterRule("reg2", "reg-for-reg2"); registers["reg-for-cfa"] = 0x268a9a4a3821a797ULL; registers["reg-for-ra"] = 0x6301b475b8b91c02ULL; registers["reg-for-reg1"] = 0x06cde8e2ff062481ULL; registers["reg-for-reg2"] = 0xff0c4f76403173e2ULL; ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory, &caller_registers)); ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[".cfa"]); ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[".ra"]); ASSERT_EQ(0x06cde8e2ff062481ULL, caller_registers["reg1"]); ASSERT_EQ(0xff0c4f76403173e2ULL, caller_registers["reg2"]); } struct SimpleCFIWalkerFixture { struct RawContext { u_int64_t r0, r1, r2, r3, r4, sp, pc; }; enum Validity { R0_VALID = 0x01, R1_VALID = 0x02, R2_VALID = 0x04, R3_VALID = 0x08, R4_VALID = 0x10, SP_VALID = 0x20, PC_VALID = 0x40 }; typedef SimpleCFIWalker<u_int64_t, RawContext> CFIWalker; SimpleCFIWalkerFixture() : walker(register_map, sizeof(register_map) / sizeof(register_map[0])) { } static CFIWalker::RegisterSet register_map[7]; CFIFrameInfo call_frame_info; CFIWalker walker; MockMemoryRegion memory; RawContext callee_context, caller_context; }; SimpleCFIWalkerFixture::CFIWalker::RegisterSet SimpleCFIWalkerFixture::register_map[7] = { { "r0", NULL, true, R0_VALID, &RawContext::r0 }, { "r1", NULL, true, R1_VALID, &RawContext::r1 }, { "r2", NULL, false, R2_VALID, &RawContext::r2 }, { "r3", NULL, false, R3_VALID, &RawContext::r3 }, { "r4", NULL, true, R4_VALID, &RawContext::r4 }, { "sp", ".cfa", true, SP_VALID, &RawContext::sp }, { "pc", ".ra", true, PC_VALID, &RawContext::pc }, }; class SimpleWalker: public SimpleCFIWalkerFixture, public Test { }; TEST_F(SimpleWalker, Walk) { // Stack_top is the current stack pointer, pointing to the lowest // address of a frame that looks like this (all 64-bit words): // // sp -> saved r0 // garbage // return address // cfa -> // // r0 has been saved on the stack. // r1 has been saved in r2. // r2 and r3 are not recoverable. // r4 is not recoverable, even though it is a callee-saves register. // Some earlier frame's unwinder must have failed to recover it. u_int64_t stack_top = 0x83254944b20d5512ULL; // Saved r0. EXPECT_CALL(memory, GetMemoryAtAddress(stack_top, A<u_int64_t *>())) .WillRepeatedly(DoAll(SetArgumentPointee<1>(0xdc1975eba8602302ULL), Return(true))); // Saved return address. EXPECT_CALL(memory, GetMemoryAtAddress(stack_top + 16, A<u_int64_t *>())) .WillRepeatedly(DoAll(SetArgumentPointee<1>(0xba5ad6d9acce28deULL), Return(true))); call_frame_info.SetCFARule("sp 24 +"); call_frame_info.SetRARule(".cfa 8 - ^"); call_frame_info.SetRegisterRule("r0", ".cfa 24 - ^"); call_frame_info.SetRegisterRule("r1", "r2"); callee_context.r0 = 0x94e030ca79edd119ULL; callee_context.r1 = 0x937b4d7e95ce52d9ULL; callee_context.r2 = 0x5fe0027416b8b62aULL; // caller's r1 // callee_context.r3 is not valid in callee. // callee_context.r4 is not valid in callee. callee_context.sp = stack_top; callee_context.pc = 0x25b21b224311d280ULL; int callee_validity = R0_VALID | R1_VALID | R2_VALID | SP_VALID | PC_VALID; memset(&caller_context, 0, sizeof(caller_context)); int caller_validity; EXPECT_TRUE(walker.FindCallerRegisters(memory, call_frame_info, callee_context, callee_validity, &caller_context, &caller_validity)); EXPECT_EQ(R0_VALID | R1_VALID | SP_VALID | PC_VALID, caller_validity); EXPECT_EQ(0xdc1975eba8602302ULL, caller_context.r0); EXPECT_EQ(0x5fe0027416b8b62aULL, caller_context.r1); EXPECT_EQ(stack_top + 24, caller_context.sp); EXPECT_EQ(0xba5ad6d9acce28deULL, caller_context.pc); }
// ramda.js // https://github.com/CrossEye/ramda // (c) 2013-2014 Scott Sauyet and Michael Hurley // Ramda may be freely distributed under the MIT license. // Ramda // ----- // A practical functional library for Javascript programmers. Ramda is a collection of tools to make it easier to // use Javascript as a functional programming language. (The name is just a silly play on `lambda`.) // Basic Setup // ----------- // Uses a technique from the [Universal Module Definition][umd] to wrap this up for use in Node.js or in the browser, // with or without an AMD-style loader. // // [umd]: https://github.com/umdjs/umd/blob/master/returnExports.js (function(factory) { if (typeof exports === 'object') { module.exports = factory(this); } else if (typeof define === 'function' && define.amd) { define(factory); } else { this.R = this.ramda = factory(this); } }(function() { 'use strict'; // This object is what is actually returned, with all the exposed functions attached as properties. /** * A practical functional library for Javascript programmers. * * @namespace R */ // jscs:disable disallowQuotedKeysInObjects var R = {'version': '0.5.0'}; // jscs:enable disallowQuotedKeysInObjects // Internal Functions and Properties // --------------------------------- /** * An optimized, private array `slice` implementation. * * @private * @category Internal * @param {Arguments|Array} args The array or arguments object to consider. * @param {number} [from=0] The array index to slice from, inclusive. * @param {number} [to=args.length] The array index to slice to, exclusive. * @return {Array} A new, sliced array. * @example * * _slice([1, 2, 3, 4, 5], 1, 3); //=> [2, 3] * * var firstThreeArgs = function(a, b, c, d) { * return _slice(arguments, 0, 3); * }; * firstThreeArgs(1, 2, 3, 4); //=> [1, 2, 3] */ function _slice(args, from, to) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return _slice(args, 0, args.length); case 2: return _slice(args, from, args.length); default: var length = to - from, list = new Array(length), idx = -1; while (++idx < length) { list[idx] = args[from + idx]; } return list; } } /** * Private `concat` function to merge two array-like objects. * * @private * @category Internal * @param {Array|Arguments} [set1=[]] An array-like object. * @param {Array|Arguments} [set2=[]] An array-like object. * @return {Array} A new, merged array. * @example * * concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] */ var concat = function _concat(set1, set2) { set1 = set1 || []; set2 = set2 || []; var length1 = set1.length, length2 = set2.length, result = new Array(length1 + length2); for (var idx = 0; idx < length1; idx++) { result[idx] = set1[idx]; } for (idx = 0; idx < length2; idx++) { result[idx + length1] = set2[idx]; } return result; }; // Private reference to toString function. var toString = Object.prototype.toString; /** * Tests whether or not an object is an array. * * @private * @category Internal * @param {*} val The object to test. * @return {boolean} `true` if `val` is an array, `false` otherwise. * @example * * isArray([]); //=> true * isArray(true); //=> false * isArray({}); //=> false */ var isArray = Array.isArray || function _isArray(val) { return val && val.length >= 0 && toString.call(val) === '[object Array]'; }; /** * Tests whether or not an object is similar to an array. * * @func * @category Type * @category List * @param {*} val The object to test. * @return {boolean} `true` if `val` has a numeric length property; `false` otherwise. * @example * * R.isArrayLike([]); //=> true * R.isArrayLike(true); //=> false * R.isArrayLike({}); //=> false * R.isArrayLike({length: 10}); //=> true */ R.isArrayLike = function isArrayLike(x) { return isArray(x) || ( !!x && typeof x === 'object' && !(x instanceof String) && ( !!(x.nodeType === 1 && x.length) || x.length >= 0 ) ); }; var NO_ARGS_EXCEPTION = new TypeError('Function called with no arguments'); /** * Optimized internal two-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} curried function * @example * * var addTwo = function(a, b) { * return a + b; * }; * * var curriedAddTwo = curry2(addTwo); */ function curry2(fn) { return function(a, b) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return function(b) { return fn(a, b); }; default: return fn(a, b); } }; } /** * Optimized internal three-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} curried function * @example * * var addThree = function(a, b, c) { * return a + b + c; * }; * * var curriedAddThree = curry3(addThree); */ function curry3(fn) { return function(a, b, c) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return curry2(function(b, c) { return fn(a, b, c); }); case 2: return function(c) { return fn(a, b, c); }; default: return fn(a, b, c); } }; } if (typeof Object.defineProperty === 'function') { try { Object.defineProperty(R, '_', {writable: false, value: void 0}); } catch (e) {} } var _ = R._; void _;// This intentionally left `undefined`. /** * Converts a function into something like an infix operation, meaning that * when called with a single argument, that argument is applied to the * second position, sort of a curry-right. This allows for more natural * processing of functions which are really binary operators. * * @memberOf R * @category Functions * @param {function} fn The operation to adjust * @return {function} A new function that acts somewhat like an infix operator. * @example * * var div = R.op(function (a, b) { * return a / b; * }); * * div(6, 3); //=> 2 * div(6, _)(3); //=> 2 // note: `_` here is just an `undefined` value. You could use `void 0` instead * div(3)(6); //=> 2 */ var op = R.op = function op(fn) { var length = fn.length; if (length < 2) {throw new Error('Expected binary function.');} var left = curry(fn), right = curry(R.flip(fn)); return function(a, b) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return right(a); case 2: return (b === R._) ? left(a) : left.apply(null, arguments); default: return left.apply(null, arguments); } }; }; /** * Creates a new version of `fn` with given arity that, when invoked, * will return either: * - A new function ready to accept one or more of `fn`'s remaining arguments, if all of * `fn`'s expected arguments have not yet been provided * - `fn`'s result if all of its expected arguments have been provided * * This function is useful in place of `curry`, when the arity of the * function to curry cannot be determined from its signature, e.g. if it's * a variadic function. * * @func * @memberOf R * @category Function * @sig Number -> (* -> a) -> (* -> a) * @param {number} fnArity The arity for the returned function. * @param {Function} fn The function to curry. * @return {Function} A new, curried function. * @see R.curry * @example * * var addFourNumbers = function() { * return R.sum([].slice.call(arguments, 0, 4)); * }; * * var curriedAddFourNumbers = R.curryN(4, addFourNumbers); * var f = curriedAddFourNumbers(1, 2); * var g = f(3); * g(4);//=> 10 */ var curryN = R.curryN = function curryN(length, fn) { return (function recurry(args) { return arity(Math.max(length - (args && args.length || 0), 0), function() { if (arguments.length === 0) { throw NO_ARGS_EXCEPTION; } var newArgs = concat(args, arguments); if (newArgs.length >= length) { return fn.apply(this, newArgs); } else { return recurry(newArgs); } }); }([])); }; /** * Creates a new version of `fn` that, when invoked, will return either: * - A new function ready to accept one or more of `fn`'s remaining arguments, if all of * `fn`'s expected arguments have not yet been provided * - `fn`'s result if all of its expected arguments have been provided * * @func * @memberOf R * @category Function * @sig (* -> a) -> (* -> a) * @param {Function} fn The function to curry. * @return {Function} A new, curried function. * @see R.curryN * @example * * var addFourNumbers = function(a, b, c, d) { * return a + b + c + d; * }; * * var curriedAddFourNumbers = R.curry(addFourNumbers); * var f = curriedAddFourNumbers(1, 2); * var g = f(3); * g(4);//=> 10 */ var curry = R.curry = function curry(fn) { return curryN(fn.length, fn); }; /** * Private function that determines whether or not a provided object has a given method. * Does not ignore methods stored on the object's prototype chain. Used for dynamically * dispatching Ramda methods to non-Array objects. * * @private * @category Internal * @param {string} methodName The name of the method to check for. * @param {Object} obj The object to test. * @return {boolean} `true` has a given method, `false` otherwise. * @example * * var person = { name: 'John' }; * person.shout = function() { alert(this.name); }; * * hasMethod('shout', person); //=> true * hasMethod('foo', person); //=> false */ var hasMethod = function _hasMethod(methodName, obj) { return obj && !isArray(obj) && typeof obj[methodName] === 'function'; }; /** * Similar to hasMethod, this checks whether a function has a [methodname] * function. If it isn't an array it will execute that function otherwise it will * default to the ramda implementation. * * @private * @category Internal * @param {Function} fn ramda implemtation * @param {String} methodname property to check for a custom implementation * @return {Object} whatever the return value of the method is */ function checkForMethod(methodname, fn) { return function(a, b, c) { var length = arguments.length; var obj = arguments[length - 1], callBound = obj && !isArray(obj) && typeof obj[methodname] === 'function'; switch (arguments.length) { case 0: return fn(); case 1: return callBound ? obj[methodname]() : fn(a); case 2: return callBound ? obj[methodname](a) : fn(a, b); case 3: return callBound ? obj[methodname](a, b) : fn(a, b, c); } }; } /** * Wraps a function of any arity (including nullary) in a function that accepts exactly `n` * parameters. Any extraneous parameters will not be passed to the supplied function. * * @func * @memberOf R * @category Function * @sig Number -> (* -> a) -> (* -> a) * @param {number} n The desired arity of the new function. * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity `n`. * @example * * var takesTwoArgs = function(a, b) { * return [a, b]; * }; * takesTwoArgs.length; //=> 2 * takesTwoArgs(1, 2); //=> [1, 2] * * var takesOneArg = R.nAry(1, takesTwoArgs); * takesOneArg.length; //=> 1 * // Only `n` arguments are passed to the wrapped function * takesOneArg(1, 2); //=> [1, undefined] */ var nAry = R.nAry = function(n, fn) { switch (n) { case 0: return function() {return fn.call(this);}; case 1: return function(a0) {return fn.call(this, a0);}; case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; default: return fn; // TODO: or throw? } }; /** * Wraps a function of any arity (including nullary) in a function that accepts exactly 1 * parameter. Any extraneous parameters will not be passed to the supplied function. * * @func * @memberOf R * @category Function * @sig (* -> b) -> (a -> b) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 1. * @example * * var takesTwoArgs = function(a, b) { * return [a, b]; * }; * takesTwoArgs.length; //=> 2 * takesTwoArgs(1, 2); //=> [1, 2] * * var takesOneArg = R.unary(takesTwoArgs); * takesOneArg.length; //=> 1 * // Only 1 argument is passed to the wrapped function * takesOneArg(1, 2); //=> [1, undefined] */ R.unary = function _unary(fn) { return nAry(1, fn); }; /** * Wraps a function of any arity (including nullary) in a function that accepts exactly 2 * parameters. Any extraneous parameters will not be passed to the supplied function. * * @func * @memberOf R * @category Function * @sig (* -> c) -> (a, b -> c) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 2. * @example * * var takesThreeArgs = function(a, b, c) { * return [a, b, c]; * }; * takesThreeArgs.length; //=> 3 * takesThreeArgs(1, 2, 3); //=> [1, 2, 3] * * var takesTwoArgs = R.binary(takesThreeArgs); * takesTwoArgs.length; //=> 2 * // Only 2 arguments are passed to the wrapped function * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] */ var binary = R.binary = function _binary(fn) { return nAry(2, fn); }; /** * Wraps a function of any arity (including nullary) in a function that accepts exactly `n` * parameters. Unlike `nAry`, which passes only `n` arguments to the wrapped function, * functions produced by `arity` will pass all provided arguments to the wrapped function. * * @func * @memberOf R * @sig (Number, (* -> *)) -> (* -> *) * @category Function * @param {number} n The desired arity of the returned function. * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is * guaranteed to be of arity `n`. * @example * * var takesTwoArgs = function(a, b) { * return [a, b]; * }; * takesTwoArgs.length; //=> 2 * takesTwoArgs(1, 2); //=> [1, 2] * * var takesOneArg = R.arity(1, takesTwoArgs); * takesOneArg.length; //=> 1 * // All arguments are passed through to the wrapped function * takesOneArg(1, 2); //=> [1, 2] */ var arity = R.arity = function(n, fn) { switch (n) { case 0: return function() {return fn.apply(this, arguments);}; case 1: return function(a0) {void a0; return fn.apply(this, arguments);}; case 2: return function(a0, a1) {void a1; return fn.apply(this, arguments);}; case 3: return function(a0, a1, a2) {void a2; return fn.apply(this, arguments);}; case 4: return function(a0, a1, a2, a3) {void a3; return fn.apply(this, arguments);}; case 5: return function(a0, a1, a2, a3, a4) {void a4; return fn.apply(this, arguments);}; case 6: return function(a0, a1, a2, a3, a4, a5) {void a5; return fn.apply(this, arguments);}; case 7: return function(a0, a1, a2, a3, a4, a5, a6) {void a6; return fn.apply(this, arguments);}; case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {void a7; return fn.apply(this, arguments);}; case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {void a8; return fn.apply(this, arguments);}; case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {void a9; return fn.apply(this, arguments);}; default: return fn; // TODO: or throw? } }; /** * Turns a named method of an object (or object prototype) into a function that can be * called directly. Passing the optional `len` parameter restricts the returned function to * the initial `len` parameters of the method. * * The returned function is curried and accepts `len + 1` parameters (or `method.length + 1` * when `len` is not specified), and the final parameter is the target object. * * @func * @memberOf R * @category Function * @sig (String, Object, Number) -> (* -> *) * @param {string} name The name of the method to wrap. * @param {Object} obj The object to search for the `name` method. * @param [len] The desired arity of the wrapped method. * @return {Function} A new function or `undefined` if the specified method is not found. * @example * * var charAt = R.invoker('charAt', String.prototype); * charAt(6, 'abcdefghijklm'); //=> 'g' * * var join = R.invoker('join', Array.prototype); * var firstChar = charAt(0); * join('', R.map(firstChar, ['light', 'ampliifed', 'stimulated', 'emission', 'radiation'])); * //=> 'laser' */ var invoker = R.invoker = function _invoker(name, obj, len) { var method = obj[name]; var length = len === void 0 ? method.length : len; return method && curryN(length + 1, function() { if (arguments.length) { var target = Array.prototype.pop.call(arguments); var targetMethod = target[name]; if (targetMethod == method) { return targetMethod.apply(target, arguments); } } }); }; /** * Accepts a function `fn` and any number of transformer functions and returns a new * function. When the new function is invoked, it calls the function `fn` with parameters * consisting of the result of calling each supplied handler on successive arguments to the * new function. For example: * * ```javascript * var useWithExample = R.useWith(someFn, transformerFn1, transformerFn2); * * // This invocation: * useWithExample('x', 'y'); * // Is functionally equivalent to: * someFn(transformerFn1('x'), transformerFn2('y')) * ``` * * If more arguments are passed to the returned function than transformer functions, those * arguments are passed directly to `fn` as additional parameters. If you expect additional * arguments that don't need to be transformed, although you can ignore them, it's best to * pass an identity function so that the new function reports the correct arity. * * @func * @memberOf R * @category Function * @sig ((* -> *), (* -> *)...) -> (* -> *) * @param {Function} fn The function to wrap. * @param {...Function} transformers A variable number of transformer functions * @return {Function} The wrapped function. * @example * * var double = function(y) { return y * 2; }; * var square = function(x) { return x * x; }; * var add = function(a, b) { return a + b; }; * // Adds any number of arguments together * var addAll = function() { * return R.reduce(add, 0, arguments); * }; * * // Basic example * var addDoubleAndSquare = R.useWith(addAll, double, square); * * //≅ addAll(double(10), square(5)); * addDoubleAndSquare(10, 5); //=> 45 * * // Example of passing more arguments than transformers * //≅ addAll(double(10), square(5), 100); * addDoubleAndSquare(10, 5, 100); //=> 145 * * // But if you're expecting additional arguments that don't need transformation, it's best * // to pass transformer functions so the resulting function has the correct arity * var addDoubleAndSquareWithExtraParams = R.useWith(addAll, double, square, R.identity); * //≅ addAll(double(10), square(5), R.identity(100)); * addDoubleAndSquare(10, 5, 100); //=> 145 */ var useWith = R.useWith = function _useWith(fn /*, transformers */) { var transformers = _slice(arguments, 1); var tlen = transformers.length; return curry(arity(tlen, function() { var args = [], idx = -1; while (++idx < tlen) { args.push(transformers[idx](arguments[idx])); } return fn.apply(this, args.concat(_slice(arguments, tlen))); })); }; /** * Iterate over an input `list`, calling a provided function `fn` for each element in the * list. * * `fn` receives one argument: *(value)*. * * Note: `R.forEach` does not skip deleted or unassigned indices (sparse arrays), unlike * the native `Array.prototype.forEach` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description * * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns the original * array. In some libraries this function is named `each`. * * @func * @memberOf R * @category List * @sig (a -> *) -> [a] -> [a] * @param {Function} fn The function to invoke. Receives one argument, `value`. * @param {Array} list The list to iterate over. * @return {Array} The original list. * @example * * var printXPlusFive = function(x) { console.log(x + 5); }; * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] * //-> 6 * //-> 7 * //-> 8 */ function forEach(fn, list) { var idx = -1, len = list.length; while (++idx < len) { fn(list[idx]); } // i can't bear not to return *something* return list; } R.forEach = curry2(forEach); /** * Like `forEach`, but but passes additional parameters to the predicate function. * * `fn` receives three arguments: *(value, index, list)*. * * Note: `R.forEach.idx` does not skip deleted or unassigned indices (sparse arrays), * unlike the native `Array.prototype.forEach` method. For more details on this behavior, * see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description * * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns the original * array. In some libraries this function is named `each`. * * @func * @memberOf R * @category List * @sig (a, i, [a] -> ) -> [a] -> [a] * @param {Function} fn The function to invoke. Receives three arguments: * (`value`, `index`, `list`). * @param {Array} list The list to iterate over. * @return {Array} The original list. * @alias forEach.idx * @example * * // Note that having access to the original `list` allows for * // mutation. While you *can* do this, it's very un-functional behavior: * var plusFive = function(num, idx, list) { list[idx] = num + 5 }; * R.forEach.idx(plusFive, [1, 2, 3]); //=> [6, 7, 8] */ R.forEach.idx = curry2(function forEachIdx(fn, list) { var idx = -1, len = list.length; while (++idx < len) { fn(list[idx], idx, list); } // i can't bear not to return *something* return list; }); /** * Creates a shallow copy of an array. * * @func * @memberOf R * @category Array * @sig [a] -> [a] * @param {Array} list The list to clone. * @return {Array} A new copy of the original list. * @example * * var numbers = [1, 2, 3]; * var numbersClone = R.clone(numbers); //=> [1, 2, 3] * numbers === numbersClone; //=> false * * // Note that this is a shallow clone--it does not clone complex values: * var objects = [{}, {}, {}]; * var objectsClone = R.clone(objects); * objects[0] === objectsClone[0]; //=> true */ var clone = R.clone = function _clone(list) { return _slice(list); }; // Core Functions // -------------- // /** * Reports whether an array is empty. * * @func * @memberOf R * @category Array * @sig [a] -> Boolean * @param {Array} list The array to consider. * @return {boolean} `true` if the `list` argument has a length of 0 or * if `list` is a falsy value (e.g. undefined). * @example * * R.isEmpty([1, 2, 3]); //=> false * R.isEmpty([]); //=> true * R.isEmpty(); //=> true * R.isEmpty(null); //=> true */ function isEmpty(list) { return !list || !list.length; } R.isEmpty = isEmpty; /** * Returns a new list with the given element at the front, followed by the contents of the * list. * * @func * @memberOf R * @category Array * @sig a -> [a] -> [a] * @param {*} el The item to add to the head of the output list. * @param {Array} list The array to add to the tail of the output list. * @return {Array} A new array. * @example * * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] */ R.prepend = curry2(function prepend(el, list) { return concat([el], list); }); /** * @func * @memberOf R * @category Array * @see R.prepend */ R.cons = R.prepend; /** * Returns the first element in a list. * In some libraries this function is named `first`. * * @func * @memberOf R * @category Array * @sig [a] -> a * @param {Array} [list=[]] The array to consider. * @return {*} The first element of the list, or `undefined` if the list is empty. * @example * * R.head(['fi', 'fo', 'fum']); //=> 'fi' */ R.head = function head(list) { list = list || []; return list[0]; }; /** * @func * @memberOf R * @category Array * @see R.head */ R.car = R.head; /** * Returns the last element from a list. * * @func * @memberOf R * @category Array * @sig [a] -> a * @param {Array} [list=[]] The array to consider. * @return {*} The last element of the list, or `undefined` if the list is empty. * @example * * R.last(['fi', 'fo', 'fum']); //=> 'fum' */ R.last = function _last(list) { list = list || []; return list[list.length - 1]; }; /** * Returns all but the first element of a list. If the list provided has the `tail` method, * it will instead return `list.tail()`. * * @func * @memberOf R * @category Array * @sig [a] -> [a] * @param {Array} [list=[]] The array to consider. * @return {Array} A new array containing all but the first element of the input list, or an * empty list if the input list is a falsy value (e.g. `undefined`). * @example * * R.tail(['fi', 'fo', 'fum']); //=> ['fo', 'fum'] */ R.tail = checkForMethod('tail', function(list) { list = list || []; return (list.length > 1) ? _slice(list, 1) : []; }); /** * @func * @memberOf R * @category Array * @see R.tail */ R.cdr = R.tail; /** * Returns a new list containing the contents of the given list, followed by the given * element. * * @func * @memberOf R * @category Array * @sig a -> [a] -> [a] * @param {*} el The element to add to the end of the new list. * @param {Array} list The list whose contents will be added to the beginning of the output * list. * @return {Array} A new list containing the contents of the old list followed by `el`. * @example * * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] * R.append('tests', []); //=> ['tests'] * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] */ var append = R.append = curry2(function _append(el, list) { return concat(list, [el]); }); /** * @func * @memberOf R * @category Array * @see R.append */ R.push = R.append; /** * Returns a new list consisting of the elements of the first list followed by the elements * of the second. * * @func * @memberOf R * @category Array * @sig [a] -> [a] -> [a] * @param {Array} list1 The first list to merge. * @param {Array} list2 The second set to merge. * @return {Array} A new array consisting of the contents of `list1` followed by the * contents of `list2`. If, instead of an {Array} for `list1`, you pass an * object with a `concat` method on it, `concat` will call `list1.concat` * and it the value of `list2`. * @example * * R.concat([], []); //=> [] * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] * R.concat('ABC', 'DEF'); // 'ABCDEF' */ R.concat = curry2(function(set1, set2) { if (isArray(set2)) { return concat(set1, set2); } else if (R.is(String, set1)) { return set1.concat(set2); } else if (hasMethod('concat', set2)) { return set2.concat(set1); } else { throw new TypeError("can't concat " + typeof set2); } }); /** * A function that does nothing but return the parameter supplied to it. Good as a default * or placeholder function. * * @func * @memberOf R * @category Core * @sig a -> a * @param {*} x The value to return. * @return {*} The input value, `x`. * @example * * R.identity(1); //=> 1 * * var obj = {}; * R.identity(obj) === obj; //=> true */ var identity = R.identity = function _I(x) { return x; }; /** * @func * @memberOf R * @category Core * @see R.identity */ R.I = R.identity; /** * Calls an input function `n` times, returning an array containing the results of those * function calls. * * `fn` is passed one argument: The current value of `n`, which begins at `0` and is * gradually incremented to `n - 1`. * * @func * @memberOf R * @category List * @sig (i -> a) -> i -> [a] * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`. * @param {number} n A value between `0` and `n - 1`. Increments after each function call. * @return {Array} An array containing the return values of all calls to `fn`. * @example * * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4] */ R.times = curry2(function _times(fn, n) { var list = new Array(n); var idx = -1; while (++idx < n) { list[idx] = fn(idx); } return list; }); /** * Returns a fixed list of size `n` containing a specified identical value. * * @func * @memberOf R * @category Array * @sig a -> n -> [a] * @param {*} value The value to repeat. * @param {number} n The desired size of the output list. * @return {Array} A new array containing `n` `value`s. * @example * * R.repeatN('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] * * var obj = {}; * var repeatedObjs = R.repeatN(obj, 5); //=> [{}, {}, {}, {}, {}] * repeatedObjs[0] === repeatedObjs[1]; //=> true */ R.repeatN = curry2(function _repeatN(value, n) { return R.times(R.always(value), n); }); // Function functions :-) // ---------------------- // // These functions make new functions out of old ones. // -------- /** * Basic, right-associative composition function. Accepts two functions and returns the * composite function; this composite function represents the operation `var h = f(g(x))`, * where `f` is the first argument, `g` is the second argument, and `x` is whatever * argument(s) are passed to `h`. * * This function's main use is to build the more general `compose` function, which accepts * any number of functions. * * @private * @category Function * @param {Function} f A function. * @param {Function} g A function. * @return {Function} A new function that is the equivalent of `f(g(x))`. * @example * * var double = function(x) { return x * 2; }; * var square = function(x) { return x * x; }; * var squareThenDouble = internalCompose(double, square); * * squareThenDouble(5); //≅ double(square(5)) => 50 */ function internalCompose(f, g) { return function() { return f.call(this, g.apply(this, arguments)); }; } /** * Creates a new function that runs each of the functions supplied as parameters in turn, * passing the return value of each function invocation to the next function invocation, * beginning with whatever arguments were passed to the initial invocation. * * Note that `compose` is a right-associative function, which means the functions provided * will be invoked in order from right to left. In the example `var h = compose(f, g)`, * the function `h` is equivalent to `f( g(x) )`, where `x` represents the arguments * originally passed to `h`. * * @func * @memberOf R * @category Function * @sig ((y -> z), (x -> y), ..., (b -> c), (a... -> b)) -> (a... -> z) * @param {...Function} functions A variable number of functions. * @return {Function} A new function which represents the result of calling each of the * input `functions`, passing the result of each function call to the next, from * right to left. * @example * * var triple = function(x) { return x * 3; }; * var double = function(x) { return x * 2; }; * var square = function(x) { return x * x; }; * var squareThenDoubleThenTriple = R.compose(triple, double, square); * * //≅ triple(double(square(5))) * squareThenDoubleThenTriple(5); //=> 150 */ var compose = R.compose = function _compose() { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return arguments[0]; default: var idx = arguments.length - 1, fn = arguments[idx], length = fn.length; while (idx--) { fn = internalCompose(arguments[idx], fn); } return arity(length, fn); } }; /** * Creates a new function that runs each of the functions supplied as parameters in turn, * passing the return value of each function invocation to the next function invocation, * beginning with whatever arguments were passed to the initial invocation. * * `pipe` is the mirror version of `compose`. `pipe` is left-associative, which means that * each of the functions provided is executed in order from left to right. * * In some libraries this function is named `sequence`. * @func * @memberOf R * @category Function * @sig ((a... -> b), (b -> c), ..., (x -> y), (y -> z)) -> (a... -> z) * @param {...Function} functions A variable number of functions. * @return {Function} A new function which represents the result of calling each of the * input `functions`, passing the result of each function call to the next, from * right to left. * @example * * var triple = function(x) { return x * 3; }; * var double = function(x) { return x * 2; }; * var square = function(x) { return x * x; }; * var squareThenDoubleThenTriple = R.pipe(square, double, triple); * * //≅ triple(double(square(5))) * squareThenDoubleThenTriple(5); //=> 150 */ R.pipe = function _pipe() { return compose.apply(this, _slice(arguments).reverse()); }; /** * Returns a new function much like the supplied one, except that the first two arguments' * order is reversed. * * @func * @memberOf R * @category Function * @sig (a -> b -> c -> ... -> z) -> (b -> a -> c -> ... -> z) * @param {Function} fn The function to invoke with its first two parameters reversed. * @return {*} The result of invoking `fn` with its first two parameters' order reversed. * @example * * var mergeThree = function(a, b, c) { * return ([]).concat(a, b, c); * }; * * mergeThree(1, 2, 3); //=> [1, 2, 3] * * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] */ var flip = R.flip = function _flip(fn) { return function(a, b) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return function(b) { return fn.apply(this, [b, a].concat(_slice(arguments, 1))); }; default: return fn.apply(this, concat([b, a], _slice(arguments, 2))); } }; }; /** * Accepts as its arguments a function and any number of values and returns a function that, * when invoked, calls the original function with all of the values prepended to the * original function's arguments list. In some libraries this function is named `applyLeft`. * * @func * @memberOf R * @category Function * @sig (a -> b -> ... -> i -> j -> ... -> m -> n) -> a -> b-> ... -> i -> (j -> ... -> m -> n) * @param {Function} fn The function to invoke. * @param {...*} [args] Arguments to prepend to `fn` when the returned function is invoked. * @return {Function} A new function wrapping `fn`. When invoked, it will call `fn` * with `args` prepended to `fn`'s arguments list. * @example * * var multiply = function(a, b) { return a * b; }; * var double = R.lPartial(multiply, 2); * double(2); //=> 4 * * var greet = function(salutation, title, firstName, lastName) { * return salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; * }; * var sayHello = R.lPartial(greet, 'Hello'); * var sayHelloToMs = R.lPartial(sayHello, 'Ms.'); * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' */ R.lPartial = function _lPartial(fn /*, args */) { var args = _slice(arguments, 1); return arity(Math.max(fn.length - args.length, 0), function() { return fn.apply(this, concat(args, arguments)); }); }; /** * Accepts as its arguments a function and any number of values and returns a function that, * when invoked, calls the original function with all of the values appended to the original * function's arguments list. * * Note that `rPartial` is the opposite of `lPartial`: `rPartial` fills `fn`'s arguments * from the right to the left. In some libraries this function is named `applyRight`. * * @func * @memberOf R * @category Function * @sig (a -> b-> ... -> i -> j -> ... -> m -> n) -> j -> ... -> m -> n -> (a -> b-> ... -> i) * @param {Function} fn The function to invoke. * @param {...*} [args] Arguments to append to `fn` when the returned function is invoked. * @return {Function} A new function wrapping `fn`. When invoked, it will call `fn` with * `args` appended to `fn`'s arguments list. * @example * * var greet = function(salutation, title, firstName, lastName) { * return salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; * }; * var greetMsJaneJones = R.rPartial(greet, 'Ms.', 'Jane', 'Jones'); * * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' */ R.rPartial = function _rPartial(fn) { var args = _slice(arguments, 1); return arity(Math.max(fn.length - args.length, 0), function() { return fn.apply(this, concat(arguments, args)); }); }; /** * Creates a new function that, when invoked, caches the result of calling `fn` for a given * argument set and returns the result. Subsequent calls to the memoized `fn` with the same * argument set will not result in an additional call to `fn`; instead, the cached result * for that set of arguments will be returned. * * Note that this version of `memoize` effectively handles only string and number * parameters. Also note that it does not work on variadic functions. * * @func * @memberOf R * @category Function * @sig (a... -> b) -> (a... -> b) * @param {Function} fn The function to be wrapped by `memoize`. * @return {Function} Returns a memoized version of `fn`. * @example * * var numberOfCalls = 0; * var trackedAdd = function(a, b) { * numberOfCalls += 1; * return a + b; * }; * var memoTrackedAdd = R.memoize(trackedAdd); * * memoTrackedAdd(1, 2); //=> 3 * numberOfCalls; //=> 1 * memoTrackedAdd(1, 2); //=> 3 * numberOfCalls; //=> 1 * memoTrackedAdd(2, 3); //=> 5 * numberOfCalls; //=> 2 * * // Note that argument order matters * memoTrackedAdd(2, 1); //=> 3 * numberOfCalls; //=> 3 */ R.memoize = function _memoize(fn) { if (!fn.length) { return once(fn); } var cache = {}; return function() { if (!arguments.length) {return;} var position = foldl(function(cache, arg) { return cache[arg] || (cache[arg] = {}); }, cache, _slice(arguments, 0, arguments.length - 1)); var arg = arguments[arguments.length - 1]; return (position[arg] || (position[arg] = fn.apply(this, arguments))); }; }; /** * Accepts a function `fn` and returns a function that guards invocation of `fn` such that * `fn` can only ever be called once, no matter how many times the returned function is * invoked. * * @func * @memberOf R * @category Function * @sig (a... -> b) -> (a... -> b) * @param {Function} fn The function to wrap in a call-only-once wrapper. * @return {Function} The wrapped function. * @example * * var addOneOnce = R.once(function(x){ return x + 1; }); * addOneOnce(10); //=> 11 * addOneOnce(addOneOnce(50)); //=> 11 */ var once = R.once = function _once(fn) { var called = false, result; return function() { if (called) { return result; } called = true; result = fn.apply(this, arguments); return result; }; }; /** * Wrap a function inside another to allow you to make adjustments to the parameters, or do * other processing either before the internal function is called or with its results. * * @func * @memberOf R * @category Function * ((* -> *) -> ((* -> *), a...) -> (*, a... -> *) * @param {Function} fn The function to wrap. * @param {Function} wrapper The wrapper function. * @return {Function} The wrapped function. * @example * * var slashify = R.wrap(R.flip(add)('/'), function(f, x) { * return R.match(/\/$/, x) ? x : f(x); * }); * * slashify('a'); //=> 'a/' * slashify('a/'); //=> 'a/' */ R.wrap = function _wrap(fn, wrapper) { return function() { return wrapper.apply(this, concat([fn], arguments)); }; }; /** * Wraps a constructor function inside a curried function that can be called with the same * arguments and returns the same type. The arity of the function returned is specified * to allow using variadic constructor functions. * * NOTE: Does not work with some built-in objects such as Date. * * @func * @memberOf R * @category Function * @sig Number -> (* -> {*}) -> (* -> {*}) * @param {number} n The arity of the constructor function. * @param {Function} Fn The constructor function to wrap. * @return {Function} A wrapped, curried constructor function. * @example * * // Variadic constructor function * var Widget = function() { * this.children = Array.prototype.slice.call(arguments); * // ... * }; * Widget.prototype = { * // ... * }; * var allConfigs = { * // ... * }; * R.map(R.constructN(1, Widget), allConfigs); // a list of Widgets */ var constructN = R.constructN = curry2(function _constructN(n, Fn) { var f = function() { var Temp = function() {}, inst, ret; Temp.prototype = Fn.prototype; inst = new Temp(); ret = Fn.apply(inst, arguments); return Object(ret) === ret ? ret : inst; }; return n > 1 ? curry(nAry(n, f)) : f; }); /** * Wraps a constructor function inside a curried function that can be called with the same * arguments and returns the same type. * * NOTE: Does not work with some built-in objects such as Date. * * @func * @memberOf R * @category Function * @sig (* -> {*}) -> (* -> {*}) * @param {Function} Fn The constructor function to wrap. * @return {Function} A wrapped, curried constructor function. * @example * * // Constructor function * var Widget = function(config) { * // ... * }; * Widget.prototype = { * // ... * }; * var allConfigs = { * // ... * }; * R.map(R.construct(Widget), allConfigs); // a list of Widgets */ R.construct = function _construct(Fn) { return constructN(Fn.length, Fn); }; /** * Accepts three functions and returns a new function. When invoked, this new function will * invoke the first function, `after`, passing as its arguments the results of invoking the * second and third functions with whatever arguments are passed to the new function. * * For example, a function produced by `converge` is equivalent to: * * ```javascript * var h = R.converge(e, f, g); * h(1, 2); //≅ e( f(1, 2), g(1, 2) ) * ``` * * @func * @memberOf R * @category Function * @sig ((a, b -> c) -> (((* -> a), (* -> b), ...) -> c) * @param {Function} after A function. `after` will be invoked with the return values of * `fn1` and `fn2` as its arguments. * @param {Function} fn1 A function. It will be invoked with the arguments passed to the * returned function. Afterward, its resulting value will be passed to `after` as * its first argument. * @param {Function} fn2 A function. It will be invoked with the arguments passed to the * returned function. Afterward, its resulting value will be passed to `after` as * its second argument. * @return {Function} A new function. * @example * * var add = function(a, b) { return a + b; }; * var multiply = function(a, b) { return a * b; }; * var subtract = function(a, b) { return a - b; }; * * //≅ multiply( add(1, 2), subtract(1, 2) ); * R.converge(multiply, add, subtract)(1, 2); //=> -3 */ R.converge = function(after) { var fns = _slice(arguments, 1); return function() { var args = arguments; return after.apply(this, map(function(fn) { return fn.apply(this, args); }, fns)); }; }; // List Functions // -------------- // // These functions operate on logical lists, here plain arrays. Almost all of these are curried, and the list // parameter comes last, so you can create a new function by supplying the preceding arguments, leaving the // list parameter off. For instance: // // // skip third parameter // var checkAllPredicates = reduce(andFn, alwaysTrue); // // ... given suitable definitions of odd, lt20, gt5 // var test = checkAllPredicates([odd, lt20, gt5]); // // test(7) => true, test(9) => true, test(10) => false, // // test(3) => false, test(21) => false, // -------- /** * Returns a single item by iterating through the list, successively calling the iterator * function and passing it an accumulator value and the current value from the array, and * then passing the result to the next call. * * The iterator function receives two values: *(acc, value)* * * Note: `R.reduce` does not skip deleted or unassigned indices (sparse arrays), unlike * the native `Array.prototype.reduce` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * * @func * @memberOf R * @category List * @sig (a,b -> a) -> a -> [b] -> a * @param {Function} fn The iterator function. Receives two values, the accumulator and the * current element from the array. * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @example * * var numbers = [1, 2, 3]; * var add = function(a, b) { * return a + b; * }; * * R.reduce(add, 10, numbers); //=> 16 */ R.reduce = curry3(function _reduce(fn, acc, list) { var idx = -1, len = list.length; while (++idx < len) { acc = fn(acc, list[idx]); } return acc; }); /** * @func * @memberOf R * @category List * @see R.reduce */ var foldl = R.foldl = R.reduce; /** * Like `reduce`, but passes additional parameters to the predicate function. * * The iterator function receives four values: *(acc, value, index, list)* * * Note: `R.reduce.idx` does not skip deleted or unassigned indices (sparse arrays), * unlike the native `Array.prototype.reduce` method. For more details on this behavior, * see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * * @func * @memberOf R * @category List * @sig (a,b,i,[b] -> a) -> a -> [b] -> a * @param {Function} fn The iterator function. Receives four values: the accumulator, the * current element from `list`, that element's index, and the entire `list` itself. * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @alias reduce.idx * @example * * var letters = ['a', 'b', 'c']; * var objectify = function(accObject, elem, idx, list) { * accObject[elem] = idx; * return accObject; * }; * * R.reduce.idx(objectify, {}, letters); //=> { 'a': 0, 'b': 1, 'c': 2 } */ R.reduce.idx = curry3(function _reduceIdx(fn, acc, list) { var idx = -1, len = list.length; while (++idx < len) { acc = fn(acc, list[idx], idx, list); } return acc; }); /** * @func * @memberOf R * @category List * @alias foldl.idx * @see R.reduce.idx */ R.foldl.idx = R.reduce.idx; /** * Returns a single item by iterating through the list, successively calling the iterator * function and passing it an accumulator value and the current value from the array, and * then passing the result to the next call. * * Similar to `reduce`, except moves through the input list from the right to the left. * * The iterator function receives two values: *(acc, value)* * * Note: `R.reduce` does not skip deleted or unassigned indices (sparse arrays), unlike * the native `Array.prototype.reduce` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * * @func * @memberOf R * @category List * @sig (a,b -> a) -> a -> [b] -> a * @param {Function} fn The iterator function. Receives two values, the accumulator and the * current element from the array. * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @example * * var pairs = [ ['a', 1], ['b', 2], ['c', 3] ]; * var flattenPairs = function(acc, pair) { * return acc.concat(pair); * }; * * R.reduceRight(flattenPairs, [], pairs); //=> [ 'c', 3, 'b', 2, 'a', 1 ] */ R.reduceRight = curry3(checkForMethod('reduceRight', function _reduceRight(fn, acc, list) { var idx = list.length; while (idx--) { acc = fn(acc, list[idx]); } return acc; })); /** * @func * @memberOf R * @category List * @see R.reduceRight */ R.foldr = R.reduceRight; /** * Like `reduceRight`, but passes additional parameters to the predicate function. Moves through * the input list from the right to the left. * * The iterator function receives four values: *(acc, value, index, list)*. * * Note: `R.reduceRight.idx` does not skip deleted or unassigned indices (sparse arrays), * unlike the native `Array.prototype.reduce` method. For more details on this behavior, * see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * * @func * @memberOf R * @category List * @sig (a,b,i,[b] -> a -> [b] -> a * @param {Function} fn The iterator function. Receives four values: the accumulator, the * current element from `list`, that element's index, and the entire `list` itself. * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @alias reduceRight.idx * @example * * var letters = ['a', 'b', 'c']; * var objectify = function(accObject, elem, idx, list) { * accObject[elem] = idx; * return accObject; * }; * * R.reduceRight.idx(objectify, {}, letters); //=> { 'c': 2, 'b': 1, 'a': 0 } */ R.reduceRight.idx = curry3(function _reduceRightIdx(fn, acc, list) { var idx = list.length; while (idx--) { acc = fn(acc, list[idx], idx, list); } return acc; }); /** * @func * @memberOf R * @category List * @alias foldr.idx * @see R.reduceRight.idx */ R.foldr.idx = R.reduceRight.idx; /** * Builds a list from a seed value. Accepts an iterator function, which returns either false * to stop iteration or an array of length 2 containing the value to add to the resulting * list and the seed to be used in the next call to the iterator function. * * The iterator function receives one argument: *(seed)*. * * @func * @memberOf R * @category List * @sig (a -> [b]) -> * -> [b] * @param {Function} fn The iterator function. receives one argument, `seed`, and returns * either false to quit iteration or an array of length two to proceed. The element * at index 0 of this array will be added to the resulting array, and the element * at index 1 will be passed to the next call to `fn`. * @param {*} seed The seed value. * @return {Array} The final list. * @example * * var f = function(n) { return n > 50 ? false : [-n, n + 10] }; * R.unfoldr(f, 10); //=> [-10, -20, -30, -40, -50] */ R.unfoldr = curry2(function _unfoldr(fn, seed) { var pair = fn(seed); var result = []; while (pair && pair.length) { result.push(pair[0]); pair = fn(pair[1]); } return result; }); /** * Returns a new list, constructed by applying the supplied function to every element of the * supplied list. * * Note: `R.map` does not skip deleted or unassigned indices (sparse arrays), unlike the * native `Array.prototype.map` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#Description * * @func * @memberOf R * @category List * @sig (a -> b) -> [a] -> [b] * @param {Function} fn The function to be called on every element of the input `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. * @example * * var double = function(x) { * return x * 2; * }; * * R.map(double, [1, 2, 3]); //=> [2, 4, 6] */ function map(fn, list) { var idx = -1, len = list.length, result = new Array(len); while (++idx < len) { result[idx] = fn(list[idx]); } return result; } R.map = curry2(checkForMethod('map', map)); /** * Like `map`, but but passes additional parameters to the mapping function. * `fn` receives three arguments: *(value, index, list)*. * * Note: `R.map.idx` does not skip deleted or unassigned indices (sparse arrays), unlike * the native `Array.prototype.map` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#Description * * @func * @memberOf R * @category List * @sig (a,i,[b] -> b) -> [a] -> [b] * @param {Function} fn The function to be called on every element of the input `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. * @alias map.idx * @example * * var squareEnds = function(elt, idx, list) { * if (idx === 0 || idx === list.length - 1) { * return elt * elt; * } * return elt; * }; * * R.map.idx(squareEnds, [8, 5, 3, 0, 9]); //=> [64, 5, 3, 0, 81] */ R.map.idx = curry2(function _mapIdx(fn, list) { var idx = -1, len = list.length, result = new Array(len); while (++idx < len) { result[idx] = fn(list[idx], idx, list); } return result; }); /** * Map, but for objects. Creates an object with the same keys as `obj` and values * generated by running each property of `obj` through `fn`. `fn` is passed one argument: * *(value)*. * * @func * @memberOf R * @category List * @sig (v -> v) -> {k: v} -> {k: v} * @param {Function} fn A function called for each property in `obj`. Its return value will * become a new property on the return object. * @param {Object} obj The object to iterate over. * @return {Object} A new object with the same keys as `obj` and values that are the result * of running each property through `fn`. * @example * * var values = { x: 1, y: 2, z: 3 }; * var double = function(num) { * return num * 2; * }; * * R.mapObj(double, values); //=> { x: 2, y: 4, z: 6 } */ // TODO: consider mapObj.key in parallel with mapObj.idx. Also consider folding together with `map` implementation. R.mapObj = curry2(function _mapObject(fn, obj) { return foldl(function(acc, key) { acc[key] = fn(obj[key]); return acc; }, {}, keys(obj)); }); /** * Like `mapObj`, but but passes additional arguments to the predicate function. The * predicate function is passed three arguments: *(value, key, obj)*. * * @func * @memberOf R * @category List * @sig (v, k, {k: v} -> v) -> {k: v} -> {k: v} * @param {Function} fn A function called for each property in `obj`. Its return value will * become a new property on the return object. * @param {Object} obj The object to iterate over. * @return {Object} A new object with the same keys as `obj` and values that are the result * of running each property through `fn`. * @alias mapObj.idx * @example * * var values = { x: 1, y: 2, z: 3 }; * var prependKeyAndDouble = function(num, key, obj) { * return key + (num * 2); * }; * * R.mapObj.idx(prependKeyAndDouble, values); //=> { x: 'x2', y: 'y4', z: 'z6' } */ R.mapObj.idx = curry2(function mapObjectIdx(fn, obj) { return foldl(function(acc, key) { acc[key] = fn(obj[key], key, obj); return acc; }, {}, keys(obj)); }); /** * ap applies a list of functions to a list of values. * * @func * @memberOf R * @category Function * @sig [f] -> [a] -> [f a] * @param {Array} fns An array of functions * @param {Array} vs An array of values * @return the value of applying each the function `fns` to each value in `vs` * @example * * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6] */ R.ap = curry2(function _ap(fns, vs) { return hasMethod('ap', fns) ? fns.ap(vs) : foldl(function(acc, fn) { return concat(acc, map(fn, vs)); }, [], fns); }); /** * * `of` wraps any object in an Array. This implementation is compatible with the * Fantasy-land Applicative spec, and will work with types that implement that spec. * Note this `of` is different from the ES6 `of`; See * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of * * @func * @memberOf R * @category Function * @sig a -> [a] * @param {*} x any value * @return [x] * @example * * R.of(1); //=> [1] * R.of([2]); //=> [[2]] * R.of({}); //=> [{}] */ R.of = function _of(x, container) { return (hasMethod('of', container)) ? container.of(x) : [x]; }; /** * `empty` wraps any object in an array. This implementation is compatible with the * Fantasy-land Monoid spec, and will work with types that implement that spec. * * @func * @memberOf R * @category Function * @sig * -> [] * @return {Array} an empty array * @example * * R.empty([1,2,3,4,5]); //=> [] */ R.empty = function _empty(x) { return (hasMethod('empty', x)) ? x.empty() : []; }; /** * `chain` maps a function over a list and concatenates the results. * This implementation is compatible with the * Fantasy-land Chain spec, and will work with types that implement that spec. * `chain` is also known as `flatMap` in some libraries * * @func * @memberOf R * @category List * @sig (a -> [b]) -> [a] -> [b] * @param {Function} fn * @param {Array} list * @return {Array} * @example * * var duplicate = function(n) { * return [n, n]; * }; * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3] * */ R.chain = curry2(checkForMethod('chain', function _chain(f, list) { return unnest(map(f, list)); })); /** * Returns the number of elements in the array by returning `list.length`. * * @func * @memberOf R * @category List * @sig [a] -> Number * @param {Array} list The array to inspect. * @return {number} The size of the array. * @example * * R.size([]); //=> 0 * R.size([1, 2, 3]); //=> 3 */ R.size = function _size(list) { return list.length; }; /** * @func * @memberOf R * @category List * @see R.size */ R.length = R.size; /** * Returns a new list containing only those items that match a given predicate function. * The predicate function is passed one argument: *(value)*. * * Note that `R.filter` does not skip deleted or unassigned indices, unlike the native * `Array.prototype.filter` method. For more details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Description * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} The new filtered array. * @example * * var isEven = function(n) { * return n % 2 === 0; * }; * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] */ var filter = function _filter(fn, list) { var idx = -1, len = list.length, result = []; while (++idx < len) { if (fn(list[idx])) { result.push(list[idx]); } } return result; }; R.filter = curry2(checkForMethod('filter', filter)); /** * Like `filter`, but passes additional parameters to the predicate function. The predicate * function is passed three arguments: *(value, index, list)*. * * @func * @memberOf R * @category List * @sig (a, i, [a] -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} The new filtered array. * @alias filter.idx * @example * * var lastTwo = function(val, idx, list) { * return list.length - idx <= 2; * }; * R.filter.idx(lastTwo, [8, 6, 7, 5, 3, 0, 9]); //=> [0, 9] */ function filterIdx(fn, list) { var idx = -1, len = list.length, result = []; while (++idx < len) { if (fn(list[idx], idx, list)) { result.push(list[idx]); } } return result; } R.filter.idx = curry2(filterIdx); /** * Similar to `filter`, except that it keeps only values for which the given predicate * function returns falsy. The predicate function is passed one argument: *(value)*. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} The new filtered array. * @example * * var isOdd = function(n) { * return n % 2 === 1; * }; * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] */ var reject = function _reject(fn, list) { return filter(not(fn), list); }; R.reject = curry2(reject); /** * Like `reject`, but passes additional parameters to the predicate function. The predicate * function is passed three arguments: *(value, index, list)*. * * @func * @memberOf R * @category List * @sig (a, i, [a] -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} The new filtered array. * @alias reject.idx * @example * * var lastTwo = function(val, idx, list) { * return list.length - idx <= 2; * }; * * R.reject.idx(lastTwo, [8, 6, 7, 5, 3, 0, 9]); //=> [8, 6, 7, 5, 3] */ R.reject.idx = curry2(function _rejectIdx(fn, list) { return filterIdx(not(fn), list); }); /** * Returns a new list containing the first `n` elements of a given list, passing each value * to the supplied predicate function, and terminating when the predicate function returns * `false`. Excludes the element that caused the predicate function to fail. The predicate * function is passed one argument: *(value)*. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} A new array. * @example * * var isNotFour = function(x) { * return !(x === 4); * }; * * R.takeWhile(isNotFour, [1, 2, 3, 4]); //=> [1, 2, 3] */ R.takeWhile = curry2(checkForMethod('takeWhile', function(fn, list) { var idx = -1, len = list.length; while (++idx < len && fn(list[idx])) {} return _slice(list, 0, idx); })); /** * Returns a new list containing the first `n` elements of the given list. If * `n > * list.length`, returns a list of `list.length` elements. * * @func * @memberOf R * @category List * @sig Number -> [a] -> [a] * @param {number} n The number of elements to return. * @param {Array} list The array to query. * @return {Array} A new array containing the first elements of `list`. */ R.take = curry2(checkForMethod('take', function(n, list) { return _slice(list, 0, Math.min(n, list.length)); })); /** * Returns a new list containing the last `n` elements of a given list, passing each value * to the supplied predicate function, beginning when the predicate function returns * `true`. Excludes the element that caused the predicate function to fail. The predicate * function is passed one argument: *(value)*. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> [a] * @param {Function} fn The function called per iteration. * @param {Array} list The collection to iterate over. * @return {Array} A new array. * @example * * var isTwo = function(x) { * return x === 2; * }; * * R.skipUntil(isTwo, [1, 2, 3, 4]); //=> [2, 3, 4] */ R.skipUntil = curry2(function _skipUntil(fn, list) { var idx = -1, len = list.length; while (++idx < len && !fn(list[idx])) {} return _slice(list, idx); }); /** * Returns a new list containing all but the first `n` elements of the given `list`. * * @func * @memberOf R * @category List * @sig Number -> [a] -> [a] * @param {number} n The number of elements of `list` to skip. * @param {Array} list The array to consider. * @return {Array} The last `n` elements of `list`. * @example * * R.skip(3, [1,2,3,4,5,6,7]); //=> [4,5,6,7] */ R.skip = curry2(checkForMethod('skip', function _skip(n, list) { if (n < list.length) { return _slice(list, n); } else { return []; } })); /** * Returns the first element of the list which matches the predicate, or `undefined` if no * element matches. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> a | undefined * @param {Function} fn The predicate function used to determine if the element is the * desired one. * @param {Array} list The array to consider. * @return {Object} The element found, or `undefined`. * @example * * var xs = [{a: 1}, {a: 2}, {a: 3}]; * R.find(R.propEq('a', 2))(xs); //=> {a: 2} * R.find(R.propEq('a', 4))(xs); //=> undefined */ R.find = curry2(function find(fn, list) { var idx = -1; var len = list.length; while (++idx < len) { if (fn(list[idx])) { return list[idx]; } } }); /** * Returns the index of the first element of the list which matches the predicate, or `-1` * if no element matches. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> Number * @param {Function} fn The predicate function used to determine if the element is the * desired one. * @param {Array} list The array to consider. * @return {number} The index of the element found, or `-1`. * @example * * var xs = [{a: 1}, {a: 2}, {a: 3}]; * R.findIndex(R.propEq('a', 2))(xs); //=> 1 * R.findIndex(R.propEq('a', 4))(xs); //=> -1 */ R.findIndex = curry2(function _findIndex(fn, list) { var idx = -1; var len = list.length; while (++idx < len) { if (fn(list[idx])) { return idx; } } return -1; }); /** * Returns the last element of the list which matches the predicate, or `undefined` if no * element matches. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> a | undefined * @param {Function} fn The predicate function used to determine if the element is the * desired one. * @param {Array} list The array to consider. * @return {Object} The element found, or `undefined`. * @example * * var xs = [{a: 1, b: 0}, {a:1, b: 1}]; * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} * R.findLast(R.propEq('a', 4))(xs); //=> undefined */ R.findLast = curry2(function _findLast(fn, list) { var idx = list.length; while (idx--) { if (fn(list[idx])) { return list[idx]; } } }); /** * Returns the index of the last element of the list which matches the predicate, or * `-1` if no element matches. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> Number * @param {Function} fn The predicate function used to determine if the element is the * desired one. * @param {Array} list The array to consider. * @return {number} The index of the element found, or `-1`. * @example * * var xs = [{a: 1, b: 0}, {a:1, b: 1}]; * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 */ R.findLastIndex = curry2(function _findLastIndex(fn, list) { var idx = list.length; while (idx--) { if (fn(list[idx])) { return idx; } } return -1; }); /** * Returns `true` if all elements of the list match the predicate, `false` if there are any * that don't. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> Boolean * @param {Function} fn The predicate function. * @param {Array} list The array to consider. * @return {boolean} `true` if the predicate is satisfied by every element, `false` * otherwise * @example * * var lessThan2 = R.flip(R.lt)(2); * var lessThan3 = R.flip(R.lt)(3); * var xs = R.range(1, 3); * xs; //=> [1, 2] * R.every(lessThan2)(xs); //=> false * R.every(lessThan3)(xs); //=> true */ function every(fn, list) { var idx = -1; while (++idx < list.length) { if (!fn(list[idx])) { return false; } } return true; } R.every = curry2(every); /** * Returns `true` if at least one of elements of the list match the predicate, `false` * otherwise. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> Boolean * @param {Function} fn The predicate function. * @param {Array} list The array to consider. * @return {boolean} `true` if the predicate is satisfied by at least one element, `false` * otherwise * @example * * var lessThan0 = R.flip(R.lt)(0); * var lessThan2 = R.flip(R.lt)(2); * var xs = R.range(1, 3); * xs; //=> [1, 2] * R.some(lessThan0)(xs); //=> false * R.some(lessThan2)(xs); //=> true */ function some(fn, list) { var idx = -1; while (++idx < list.length) { if (fn(list[idx])) { return true; } } return false; } R.some = curry2(some); /** * Internal implementation of `indexOf`. * Returns the position of the first occurrence of an item in an array * (by strict equality), * or -1 if the item is not included in the array. * * @private * @category Internal * @param {Array} The array to search * @param {*} item the item to find in the Array * @param {Number} from (optional) the index to start searching the Array * @return {Number} the index of the found item, or -1 * */ var indexOf = function _indexOf(list, item, from) { var idx = 0, length = list.length; if (typeof from == 'number') { idx = from < 0 ? Math.max(0, length + from) : from; } for (; idx < length; idx++) { if (list[idx] === item) { return idx; } } return -1; }; /** * Internal implementation of `lastIndexOf`. * Returns the position of the last occurrence of an item in an array * (by strict equality), * or -1 if the item is not included in the array. * * @private * @category Internal * @param {Array} The array to search * @param {*} item the item to find in the Array * @param {Number} from (optional) the index to start searching the Array * @return {Number} the index of the found item, or -1 * */ var lastIndexOf = function _lastIndexOf(list, item, from) { var idx = list.length; if (typeof from == 'number') { idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1); } while (--idx >= 0) { if (list[idx] === item) { return idx; } } return -1; }; /** * Returns the position of the first occurrence of an item in an array * (by strict equality), * or -1 if the item is not included in the array. * * @func * @memberOf R * @category List * @sig a -> [a] -> Number * @param {*} target The item to find. * @param {Array} list The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. * * @example * * R.indexOf(3, [1,2,3,4]); //=> 2 * R.indexOf(10, [1,2,3,4]); //=> -1 */ R.indexOf = curry2(function _indexOf(target, list) { return indexOf(list, target); }); /** * Returns the position of the first occurrence of an item (by strict equality) in * an array, or -1 if the item is not included in the array. However, * `indexOf.from` will only search the tail of the array, starting from the * `fromIdx` parameter. * * @func * @memberOf R * @category List * @sig a -> Number -> [a] -> Number * @param {*} target The item to find. * @param {Array} list The array to search in. * @param {Number} fromIdx the index to start searching from * @return {Number} the index of the target, or -1 if the target is not found. * * @example * * R.indexOf.from(3, 2, [-1,0,1,2,3,4]); //=> 4 * R.indexOf.from(10, 2, [1,2,3,4]); //=> -1 */ R.indexOf.from = curry3(function indexOfFrom(target, fromIdx, list) { return indexOf(list, target, fromIdx); }); /** * Returns the position of the last occurrence of an item (by strict equality) in * an array, or -1 if the item is not included in the array. * * @func * @memberOf R * @category List * @sig a -> [a] -> Number * @param {*} target The item to find. * @param {Array} list The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. * * @example * * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 * R.lastIndexOf(10, [1,2,3,4]); //=> -1 */ R.lastIndexOf = curry2(function _lastIndexOf(target, list) { return lastIndexOf(list, target); }); /** * Returns the position of the last occurrence of an item (by strict equality) in * an array, or -1 if the item is not included in the array. However, * `lastIndexOf.from` will only search the tail of the array, starting from the * `fromIdx` parameter. * * @func * @memberOf R * @category List * @sig a -> Number -> [a] -> Number * @param {*} target The item to find. * @param {Array} list The array to search in. * @param {Number} fromIdx the index to start searching from * @return {Number} the index of the target, or -1 if the target is not found. * * @example * * R.lastIndexOf.from(3, 2, [-1,3,3,0,1,2,3,4]); //=> 2 * R.lastIndexOf.from(10, 2, [1,2,3,4]); //=> -1 */ R.lastIndexOf.from = curry3(function lastIndexOfFrom(target, fromIdx, list) { return lastIndexOf(list, target, fromIdx); }); /** * Returns `true` if the specified item is somewhere in the list, `false` otherwise. * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking. * * @func * @memberOf R * @category List * @sig a -> [a] -> Boolean * @param {Object} a The item to compare against. * @param {Array} list The array to consider. * @return {boolean} `true` if the item is in the list, `false` otherwise. * @example * * R.contains(3)([1, 2, 3]); //=> true * R.contains(4)([1, 2, 3]); //=> false * R.contains({})([{}, {}]); //=> false * var obj = {}; * R.contains(obj)([{}, obj, {}]); //=> true */ function contains(a, list) { return indexOf(list, a) > -1; } R.contains = curry2(contains); /** * Returns `true` if the `x` is found in the `list`, using `pred` as an * equality predicate for `x`. * * @func * @memberOf R * @category List * @sig (x, a -> Boolean) -> x -> [a] -> Boolean * @param {Function} pred :: x -> x -> Bool * @param {*} x the item to find * @param {Array} list the list to iterate over * @return {Boolean} `true` if `x` is in `list`, else `false` * @example * * var xs = [{x: 12}, {x: 11}, {x: 10}]; * R.containsWith(function(a, b) { return a.x === b.x; }, {x: 10}, xs); //=> true * R.containsWith(function(a, b) { return a.x === b.x; }, {x: 1}, xs); //=> false */ function containsWith(pred, x, list) { var idx = -1, len = list.length; while (++idx < len) { if (pred(x, list[idx])) { return true; } } return false; } R.containsWith = curry3(containsWith); /** * Returns a new list containing only one copy of each element in the original list. * Equality is strict here, meaning reference equality for objects and non-coercing equality * for primitives. * * @func * @memberOf R * @category List * @sig [a] -> [a] * @param {Array} list The array to consider. * @return {Array} The list of unique items. * @example * * R.uniq([1, 1, 2, 1]); //=> [1, 2] * R.uniq([{}, {}]); //=> [{}, {}] * R.uniq([1, '1']); //=> [1, '1'] */ var uniq = R.uniq = function uniq(list) { var idx = -1, len = list.length; var result = [], item; while (++idx < len) { item = list[idx]; if (!contains(item, result)) { result.push(item); } } return result; }; /** * Returns `true` if all elements are unique, otherwise `false`. * Uniqueness is determined using strict equality (`===`). * * @func * @memberOf R * @category List * @sig [a] -> Boolean * @param {Array} list The array to consider. * @return {boolean} `true` if all elements are unique, else `false`. * @example * * R.isSet(['1', 1]); //=> true * R.isSet([1, 1]); //=> false * R.isSet([{}, {}]); //=> true */ R.isSet = function _isSet(list) { var len = list.length; var idx = -1; while (++idx < len) { if (indexOf(list, list[idx], idx + 1) >= 0) { return false; } } return true; }; /** * Returns a new list containing only one copy of each element in the original list, based * upon the value returned by applying the supplied predicate to two list elements. Prefers * the first item if two items compare equal based on the predicate. * * @func * @memberOf R * @category List * @sig (x, a -> Boolean) -> [a] -> [a] * @param {Function} pred :: x -> x -> Bool * @param {Array} list The array to consider. * @return {Array} The list of unique items. * @example * * var strEq = function(a, b) { return ('' + a) === ('' + b) }; * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2] * R.uniqWith(strEq)([{}, {}]); //=> [{}] * R.uniqWith(strEq)([1, '1', 1]); //=> [1] * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] */ var uniqWith = R.uniqWith = curry2(function _uniqWith(pred, list) { var idx = -1, len = list.length; var result = [], item; while (++idx < len) { item = list[idx]; if (!containsWith(pred, item, result)) { result.push(item); } } return result; }); /** * Returns a new list by plucking the same named property off all objects in the list supplied. * * @func * @memberOf R * @category List * @sig String -> {*} -> [*] * @param {string|number} key The key name to pluck off of each object. * @param {Array} list The array to consider. * @return {Array} The list of values for the given key. * @example * * R.pluck('a')([{a: 1}, {a: 2}]); //=> [1, 2] * R.pluck(0)([[1, 2], [3, 4]]); //=> [1, 3] */ var pluck = R.pluck = curry2(function _pluck(p, list) { return map(prop(p), list); }); /** * `makeFlat` is a helper function that returns a one-level or fully recursive function * based on the flag passed in. * * @private */ // TODO: document, even for internals... var makeFlat = function _makeFlat(recursive) { return function __flatt(list) { var value, result = [], idx = -1, j, ilen = list.length, jlen; while (++idx < ilen) { if (R.isArrayLike(list[idx])) { value = (recursive) ? __flatt(list[idx]) : list[idx]; j = -1; jlen = value.length; while (++j < jlen) { result.push(value[j]); } } else { result.push(list[idx]); } } return result; }; }; /** * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting * them in a new array, depth-first. * * @func * @memberOf R * @category List * @sig [a] -> [b] * @param {Array} list The array to consider. * @return {Array} The flattened list. * @example * * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] */ R.flatten = makeFlat(true); /** * Returns a new list by pulling every item at the first level of nesting out, and putting * them in a new array. * * @func * @memberOf R * @category List * @sig [a] -> [b] * @param {Array} list The array to consider. * @return {Array} The flattened list. * @example * * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] */ var unnest = R.unnest = makeFlat(false); /** * Creates a new list out of the two supplied by applying the function to * each equally-positioned pair in the lists. The returned list is * truncated to the length of the shorter of the two input lists. * * @function * @memberOf R * @category List * @sig (a,b -> c) -> a -> b -> [c] * @param {Function} fn The function used to combine the two elements into one value. * @param {Array} list1 The first array to consider. * @param {Array} list2 The second array to consider. * @return {Array} The list made by combining same-indexed elements of `list1` and `list2` * using `fn`. * @example * * var f = function(x, y) { * // ... * }; * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] */ R.zipWith = curry3(function _zipWith(fn, a, b) { var rv = [], idx = -1, len = Math.min(a.length, b.length); while (++idx < len) { rv[idx] = fn(a[idx], b[idx]); } return rv; }); /** * Creates a new list out of the two supplied by pairing up * equally-positioned items from both lists. The returned list is * truncated to the length of the shorter of the two input lists. * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. * * @func * @memberOf R * @category List * @sig a -> b -> [[a,b]] * @param {Array} list1 The first array to consider. * @param {Array} list2 The second array to consider. * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`. * @example * * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] */ R.zip = curry2(function _zip(a, b) { var rv = []; var idx = -1; var len = Math.min(a.length, b.length); while (++idx < len) { rv[idx] = [a[idx], b[idx]]; } return rv; }); /** * Creates a new object out of a list of keys and a list of values. * * @func * @memberOf R * @category List * @sig k -> v -> {k: v} * @param {Array} keys The array that will be properties on the output object. * @param {Array} values The list of values on the output object. * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`. * @example * * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} */ R.zipObj = curry2(function _zipObj(keys, values) { var idx = -1, len = keys.length, out = {}; while (++idx < len) { out[keys[idx]] = values[idx]; } return out; }); /** * Creates a new object out of a list key-value pairs. * * @func * @memberOf R * @category List * @sig [[k,v]] -> {k: v} * @param {Array} An array of two-element arrays that will be the keys and values of the ouput object. * @return {Object} The object made by pairing up `keys` and `values`. * @example * * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} */ R.fromPairs = function _fromPairs(pairs) { var idx = -1, len = pairs.length, out = {}; while (++idx < len) { if (isArray(pairs[idx]) && pairs[idx].length) { out[pairs[idx][0]] = pairs[idx][1]; } } return out; }; /** * Creates a new list out of the two supplied by applying the function * to each possible pair in the lists. * * @see R.xprod * @func * @memberOf R * @category List * @sig (a,b -> c) -> a -> b -> [c] * @param {Function} fn The function to join pairs with. * @param {Array} as The first list. * @param {Array} bs The second list. * @return {Array} The list made by combining each possible pair from * `as` and `bs` using `fn`. * @example * * var f = function(x, y) { * // ... * }; * R.xprodWith(f, [1, 2], ['a', 'b']); * // [f(1, 'a'), f(1, 'b'), f(2, 'a'), f(2, 'b')]; */ R.xprodWith = curry3(function _xprodWith(fn, a, b) { if (isEmpty(a) || isEmpty(b)) { return []; } // Better to push them all or to do `new Array(ilen * jlen)` and // calculate indices? var idx = -1, ilen = a.length, j, jlen = b.length, result = []; while (++idx < ilen) { j = -1; while (++j < jlen) { result.push(fn(a[idx], b[j])); } } return result; }); /** * Creates a new list out of the two supplied by creating each possible * pair from the lists. * * @func * @memberOf R * @category List * @sig a -> b -> [[a,b]] * @param {Array} as The first list. * @param {Array} bs The second list. * @return {Array} The list made by combining each possible pair from * `as` and `bs` into pairs (`[a, b]`). * @example * * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] */ R.xprod = curry2(function _xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) if (isEmpty(a) || isEmpty(b)) { return []; } var idx = -1; var ilen = a.length; var j; var jlen = b.length; // Better to push them all or to do `new Array(ilen * jlen)` and calculate indices? var result = []; while (++idx < ilen) { j = -1; while (++j < jlen) { result.push([a[idx], b[j]]); } } return result; }); /** * Returns a new list with the same elements as the original list, just * in the reverse order. * * @func * @memberOf R * @category List * @sig [a] -> [a] * @param {Array} list The list to reverse. * @return {Array} A copy of the list in reverse order. * @example * * R.reverse([1, 2, 3]); //=> [3, 2, 1] * R.reverse([1, 2]); //=> [2, 1] * R.reverse([1]); //=> [1] * R.reverse([]); //=> [] */ R.reverse = function _reverse(list) { return clone(list || []).reverse(); }; /** * Returns a list of numbers from `from` (inclusive) to `to` * (exclusive). * * @func * @memberOf R * @category List * @sig Number -> Number -> [Number] * @param {number} from The first number in the list. * @param {number} to One more than the last number in the list. * @return {Array} The list of numbers in tthe set `[a, b)`. * @example * * R.range(1, 5); //=> [1, 2, 3, 4] * R.range(50, 53); //=> [50, 51, 52] */ R.range = curry2(function _range(from, to) { if (from >= to) { return []; } var idx = 0, result = new Array(Math.floor(to) - Math.ceil(from)); for (; from < to; idx++, from++) { result[idx] = from; } return result; }); /** * Returns a string made by inserting the `separator` between each * element and concatenating all the elements into a single string. * * @func * @memberOf R * @category List * @sig String -> [a] -> String * @param {string|number} separator The string used to separate the elements. * @param {Array} xs The elements to join into a string. * @return {string} The string made by concatenating `xs` with `separator`. * @example * * var spacer = R.join(' '); * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' * R.join('|', [1, 2, 3]); //=> '1|2|3' */ R.join = invoker('join', Array.prototype); /** * Returns the elements from `xs` starting at `a` and ending at `b - 1`. * * @func * @memberOf R * @category List * @sig Number -> Number -> [a] -> [a] * @param {number} a The starting index. * @param {number} b One more than the ending index. * @param {Array} xs The list to take elements from. * @return {Array} The items from `a` to `b - 1` from `xs`. * @example * * var xs = R.range(0, 10); * R.slice(2, 5)(xs); //=> [2, 3, 4] */ R.slice = invoker('slice', Array.prototype); /** * Returns the elements from `xs` starting at `a` going to the end of `xs`. * * @func * @memberOf R * @category List * @sig Number -> [a] -> [a] * @param {number} a The starting index. * @param {Array} xs The list to take elements from. * @return {Array} The items from `a` to the end of `xs`. * @example * * var xs = R.range(0, 10); * R.slice.from(2)(xs); //=> [2, 3, 4, 5, 6, 7, 8, 9] * * var ys = R.range(4, 8); * var tail = R.slice.from(1); * tail(ys); //=> [5, 6, 7] */ R.slice.from = curry2(function(a, xs) { return xs.slice(a, xs.length); }); /** * Removes the sub-list of `list` starting at index `start` and containing * `count` elements. _Note that this is not destructive_: it returns a * copy of the list with the changes. * <small>No lists have been harmed in the application of this function.</small> * * @func * @memberOf R * @category List * @sig Number -> Number -> [a] -> [a] * @param {Number} start The position to start removing elements * @param {Number} count The number of elements to remove * @param {Array} list The list to remove from * @return {Array} a new Array with `count` elements from `start` removed * @example * * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] */ R.remove = curry3(function _remove(start, count, list) { return concat(_slice(list, 0, Math.min(start, list.length)), _slice(list, Math.min(list.length, start + count))); }); /** * Inserts the supplied element into the list, at index `index`. _Note * that this is not destructive_: it returns a copy of the list with the changes. * <small>No lists have been harmed in the application of this function.</small> * * @func * @memberOf R * @category List * @sig Number -> a -> [a] -> [a] * @param {Number} index The position to insert the element * @param {*} elt The element to insert into the Array * @param {Array} list The list to insert into * @return {Array} a new Array with `elt` inserted at `index` * @example * * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] */ R.insert = curry3(function _insert(idx, elt, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; return concat(append(elt, _slice(list, 0, idx)), _slice(list, idx)); }); /** * Inserts the sub-list into the list, at index `index`. _Note that this * is not destructive_: it returns a copy of the list with the changes. * <small>No lists have been harmed in the application of this function.</small> * * @func * @memberOf R * @category List * @sig Number -> [a] -> [a] -> [a] * @param {Number} index The position to insert the sublist * @param {Array} elts The sub-list to insert into the Array * @param {Array} list The list to insert the sub-list into * @return {Array} a new Array with `elts` inserted starting at `index` * @example * * R.insert.all(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] */ R.insert.all = curry3(function _insertAll(idx, elts, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; return concat(concat(_slice(list, 0, idx), elts), _slice(list, idx)); }); /** * Makes a comparator function out of a function that reports whether the first element is less than the second. * * @func * @memberOf R * @category Function * @sig (a, b -> Boolean) -> (a, b -> Number) * @param {Function} pred A predicate function of arity two. * @return {Function} a Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` * @example * * var cmp = R.comparator(function(a, b) { * return a.age < b.age; * }); * var people = [ * // ... * ]; * R.sort(cmp, people); */ var comparator = R.comparator = function _comparator(pred) { return function(a, b) { return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; }; }; /** * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero * if they are equal. Please note that this is a **copy** of the list. It does not modify the original. * * @func * @memberOf R * @category List * @sig (a,a -> Number) -> [a] -> [a] * @param {Function} comparator A sorting function :: a -> b -> Int * @param {Array} list The list to sort * @return {Array} a new array with its elements sorted by the comparator function. * @example * * var diff = function(a, b) { return a - b; }; * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] */ R.sort = curry2(function sort(comparator, list) { return clone(list).sort(comparator); }); /** * Splits a list into sublists stored in an object, based on the result of calling a String-returning function * on each element, and grouping the results according to values returned. * * @func * @memberOf R * @category List * @sig (a -> s) -> [a] -> {s: a} * @param {Function} fn Function :: a -> String * @param {Array} list The array to group * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements * that produced that key when passed to `fn`. * @example * * var byGrade = R.groupBy(function(student) { * var score = student.score; * return (score < 65) ? 'F' : (score < 70) ? 'D' : * (score < 80) ? 'C' : (score < 90) ? 'B' : 'A'; * }); * var students = [{name: 'Abby', score: 84}, * {name: 'Eddy', score: 58}, * // ... * {name: 'Jack', score: 69}]; * byGrade(students); * // { * // 'A': [{name: 'Dianne', score: 99}], * // 'B': [{name: 'Abby', score: 84}] * // // ..., * // 'F': [{name: 'Eddy', score: 58}] * // } */ R.groupBy = curry2(function _groupBy(fn, list) { return foldl(function(acc, elt) { var key = fn(elt); acc[key] = append(elt, acc[key] || (acc[key] = [])); return acc; }, {}, list); }); /** * Takes a predicate and a list and returns the pair of lists of * elements which do and do not satisfy the predicate, respectively. * * @func * @memberOf R * @category List * @sig (a -> Boolean) -> [a] -> [[a],[a]] * @param {Function} pred Function :: a -> Boolean * @param {Array} list The array to partition * @return {Array} A nested array, containing first an array of elements that satisfied the predicate, * and second an array of elements that did not satisfy. * @example * * R.partition(R.contains('s'), ['sss', 'ttt', 'foo', 'bars']); * //=> [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ] */ R.partition = curry2(function _partition(pred, list) { return foldl(function(acc, elt) { acc[pred(elt) ? 0 : 1].push(elt); return acc; }, [[], []], list); }); // Object Functions // ---------------- // // These functions operate on plain Javascript object, adding simple functions to test properties on these // objects. Many of these are of most use in conjunction with the list functions, operating on lists of // objects. // -------- /** * Runs the given function with the supplied object, then returns the object. * * @func * @memberOf R * @category Function * @sig a -> (a -> *) -> a * @param {*} x * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away. * @return {*} x * @example * * var sayX = function(x) { console.log('x is ' + x); }; * R.tap(100, sayX); //=> 100 * //-> 'x is 100') */ R.tap = curry2(function _tap(x, fn) { if (typeof fn === 'function') { fn(x); } return x; }); /** * Tests if two items are equal. Equality is strict here, meaning reference equality for objects and * non-coercing equality for primitives. * * @func * @memberOf R * @category Relation * @sig a -> b -> Boolean * @param {*} a * @param {*} b * @return {Boolean} * @example * * var o = {}; * R.eq(o, o); //=> true * R.eq(o, {}); //=> false * R.eq(1, 1); //=> true * R.eq(1, '1'); //=> false */ R.eq = curry2(function _eq(a, b) { return a === b; }); /** * Returns a function that when supplied an object returns the indicated property of that object, if it exists. * * @func * @memberOf R * @category Object * @sig s -> {s: a} -> a * @param {String} p The property name * @param {Object} obj The object to query * @return {*} The value at obj.p * @example * * R.prop('x', {x: 100}); //=> 100 * R.prop('x', {}); //=> undefined * * var fifth = R.prop(4); // indexed from 0, remember * fifth(['Bashful', 'Doc', 'Dopey', 'Grumpy', 'Happy', 'Sleepy', 'Sneezy']); * //=> 'Happy' */ var prop = R.prop = function prop(p, obj) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return function _prop(obj) { return obj[p]; }; } return obj[p]; }; /** * @func * @memberOf R * @category Object * @see R.prop */ R.get = R.prop; /** * Returns the value at the specified property. * The only difference from `prop` is the parameter order. * * @func * @memberOf R * @see R.prop * @category Object * @sig {s: a} -> s -> a * @param {Object} obj The object to query * @param {String} prop The property name * @return {*} The value at obj.p * @example * * R.props({x: 100}, 'x'); //=> 100 */ R.props = flip(R.prop); /** * An internal reference to `Object.prototype.hasOwnProperty` * @private */ var hasOwnProperty = Object.prototype.hasOwnProperty; /** * If the given object has an own property with the specified name, * returns the value of that property. * Otherwise returns the provided default value. * * @func * @memberOf R * @category Object * @sig s -> v -> {s: x} -> x | v * @param {String} p The name of the property to return. * @param {*} val The default value. * @returns {*} The value of given property or default value. * @example * * var alice = { * name: 'ALICE', * age: 101 * }; * var favorite = R.prop('favoriteLibrary'); * var favoriteWithDefault = R.propOrDefault('favoriteLibrary', 'Ramda'); * * favorite(alice); //=> undefined * favoriteWithDefault(alice); //=> 'Ramda' */ R.propOrDefault = curry3(function _propOrDefault(p, val, obj) { return hasOwnProperty.call(obj, p) ? obj[p] : val; }); /** * Calls the specified function on the supplied object. Any additional arguments * after `fn` and `obj` are passed in to `fn`. If no additional arguments are passed to `func`, * `fn` is invoked with no arguments. * * @func * @memberOf R * @category Object * @sig k -> {k : v} -> v(*) * @param {String} fn The name of the property mapped to the function to invoke * @param {Object} obj The object * @return {*} The value of invoking `obj.fn` * @example * * R.func('add', R, 1, 2); //=> 3 * * var obj = { f: function() { return 'f called'; } }; * R.func('f', obj); //=> 'f called' */ R.func = function _func(funcName, obj) { switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return function(obj) { return obj[funcName].apply(obj, _slice(arguments, 1)); }; default: return obj[funcName].apply(obj, _slice(arguments, 2)); } }; /** * Returns a function that always returns the given value. * * @func * @memberOf R * @category Function * @sig a -> (* -> a) * @param {*} val The value to wrap in a function * @return {Function} A Function :: * -> val * @example * * var t = R.always('Tee'); * t(); //=> 'Tee' */ var always = R.always = function _always(val) { return function() { return val; }; }; /** * Internal reference to Object.keys * * @private * @param {Object} * @return {Array} */ var nativeKeys = Object.keys; /** * Returns a list containing the names of all the enumerable own * properties of the supplied object. * Note that the order of the output array is not guaranteed to be * consistent across different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [k] * @param {Object} obj The object to extract properties from * @return {Array} An array of the object's own properties * @example * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] */ var keys = R.keys = (function() { // cover IE < 9 keys issues var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; return function _keys(obj) { if (!R.is(Object, obj)) { return []; } if (nativeKeys) { return nativeKeys(Object(obj)); } var prop, ks = [], nIdx; for (prop in obj) { if (hasOwnProperty.call(obj, prop)) { ks.push(prop); } } if (hasEnumBug) { nIdx = nonEnumerableProps.length; while (nIdx--) { prop = nonEnumerableProps[nIdx]; if (hasOwnProperty.call(obj, prop) && !R.contains(prop, ks)) { ks.push(prop); } } } return ks; }; }()); /** * Returns a list containing the names of all the * properties of the supplied object, including prototype properties. * Note that the order of the output array is not guaranteed to be * consistent across different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [k] * @param {Object} obj The object to extract properties from * @return {Array} An array of the object's own and prototype properties * @example * * var F = function() { this.x = 'X'; }; * F.prototype.y = 'Y'; * var f = new F(); * R.keysIn(f); //=> ['x', 'y'] */ R.keysIn = function _keysIn(obj) { var prop, ks = []; for (prop in obj) { ks.push(prop); } return ks; }; /** * @private * @param {Function} fn The strategy for extracting keys from an object * @return {Function} A function that takes an object and returns an array of * key-value arrays. */ var pairWith = function(fn) { return function(obj) { return R.map(function(key) { return [key, obj[key]]; }, fn(obj)); }; }; /** * Converts an object into an array of key, value arrays. * Only the object's own properties are used. * Note that the order of the output array is not guaranteed to be * consistent across different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [[k,v]] * @param {Object} obj The object to extract from * @return {Array} An array of key, value arrays from the object's own properties * @example * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] */ R.toPairs = pairWith(R.keys); /** * Converts an object into an array of key, value arrays. * The object's own properties and prototype properties are used. * Note that the order of the output array is not guaranteed to be * consistent across different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [[k,v]] * @param {Object} obj The object to extract from * @return {Array} An array of key, value arrays from the object's own * and prototype properties * @example * * var F = function() { this.x = 'X'; }; * F.prototype.y = 'Y'; * var f = new F(); * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] */ R.toPairsIn = pairWith(R.keysIn); /** * Returns a list of all the enumerable own properties of the supplied object. * Note that the order of the output array is not guaranteed across * different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [v] * @param {Object} obj The object to extract values from * @return {Array} An array of the values of the object's own properties * @example * * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] */ R.values = function _values(obj) { var props = keys(obj), length = props.length, vals = new Array(length); for (var idx = 0; idx < length; idx++) { vals[idx] = obj[props[idx]]; } return vals; }; /** * Returns a list of all the properties, including prototype properties, * of the supplied object. * Note that the order of the output array is not guaranteed to be * consistent across different JS platforms. * * @func * @memberOf R * @category Object * @sig {k: v} -> [v] * @param {Object} obj The object to extract values from * @return {Array} An array of the values of the object's own and prototype properties * @example * * var F = function() { this.x = 'X'; }; * F.prototype.y = 'Y'; * var f = new F(); * R.valuesIn(f); //=> ['X', 'Y'] */ R.valuesIn = function _valuesIn(obj) { var prop, vs = []; for (prop in obj) { vs.push(obj[prop]); } return vs; }; /** * Internal helper function for making a partial copy of an object * * @private * */ // TODO: document, even for internals... function pickWith(test, obj) { var copy = {}, props = keys(obj), prop, val; for (var idx = 0, len = props.length; idx < len; idx++) { prop = props[idx]; val = obj[prop]; if (test(val, prop, obj)) { copy[prop] = val; } } return copy; } /** * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the * property is ignored. * * @func * @memberOf R * @category Object * @sig [k] -> {k: v} -> {k: v} * @param {Array} names an array of String propery names to copy onto a new object * @param {Object} obj The object to copy from * @return {Object} A new object with only properties from `names` on it. * @example * * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} */ R.pick = curry2(function pick(names, obj) { return pickWith(function(val, key) { return contains(key, names); }, obj); }); /** * Returns a partial copy of an object omitting the keys specified. * * @func * @memberOf R * @category Object * @sig [k] -> {k: v} -> {k: v} * @param {Array} names an array of String propery names to omit from the new object * @param {Object} obj The object to copy from * @return {Object} A new object with properties from `names` not on it. * @example * * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} */ R.omit = curry2(function omit(names, obj) { return pickWith(function(val, key) { return !contains(key, names); }, obj); }); /** * Returns a partial copy of an object containing only the keys that * satisfy the supplied predicate. * * @func * @memberOf R * @category Object * @sig (v, k -> Boolean) -> {k: v} -> {k: v} * @param {Function} pred A predicate to determine whether or not a key * should be included on the output object. * @param {Object} obj The object to copy from * @return {Object} A new object with only properties that satisfy `pred` * on it. * @see R.pick * @example * * var isUpperCase = function(val, key) { return key.toUpperCase() === key; } * R.pickWith(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} */ R.pickWith = curry2(pickWith); /** * Internal implementation of `pickAll` * * @private * @see R.pickAll */ // TODO: document, even for internals... var pickAll = function _pickAll(names, obj) { var copy = {}; forEach(function(name) { copy[name] = obj[name]; }, names); return copy; }; /** * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist. * * @func * @memberOf R * @category Object * @sig [k] -> {k: v} -> {k: v} * @param {Array} names an array of String propery names to copy onto a new object * @param {Object} obj The object to copy from * @return {Object} A new object with only properties from `names` on it. * @see R.pick * @example * * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} */ R.pickAll = curry2(pickAll); /** * Assigns own enumerable properties of the other object to the destination * object prefering items in other. * * @private * @memberOf R * @category Object * @param {Object} object The destination object. * @param {Object} other The other object to merge with destination. * @returns {Object} Returns the destination object. * @example * * extend({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); * //=> { 'name': 'fred', 'age': 40 } */ function extend(destination, other) { var props = keys(other), idx = -1, length = props.length; while (++idx < length) { destination[props[idx]] = other[props[idx]]; } return destination; } /** * Create a new object with the own properties of a * merged with the own properties of object b. * This function will *not* mutate passed-in objects. * * @func * @memberOf R * @category Object * @sig {k: v} -> {k: v} -> {k: v} * @param {Object} a source object * @param {Object} b object with higher precendence in output * @returns {Object} Returns the destination object. * @example * * R.mixin({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); * //=> { 'name': 'fred', 'age': 40 } */ R.mixin = curry2(function _mixin(a, b) { return extend(extend({}, a), b); }); /** * Creates a shallow copy of an object's own properties. * * @func * @memberOf R * @category Object * @sig {*} -> {*} * @param {Object} obj The object to clone * @returns {Object} A new object * @example * * R.cloneObj({a: 1, b: 2, c: [1, 2, 3]}); // {a: 1, b: 2, c: [1, 2, 3]} */ R.cloneObj = function(obj) { return extend({}, obj); }; /** * Reports whether two functions have the same value for the specified property. Useful as a curried predicate. * * @func * @memberOf R * @category Object * @sig k -> {k: v} -> {k: v} -> Boolean * @param {String} prop The name of the property to compare * @param {Object} obj1 * @param {Object} obj2 * @return {Boolean} * * @example * * var o1 = { a: 1, b: 2, c: 3, d: 4 }; * var o2 = { a: 10, b: 20, c: 3, d: 40 }; * R.eqProps('a', o1, o2); //=> false * R.eqProps('c', o1, o2); //=> true */ R.eqProps = curry3(function eqProps(prop, obj1, obj2) { return obj1[prop] === obj2[prop]; }); /** * internal helper for `where` * * @private * @see R.where */ function satisfiesSpec(spec, parsedSpec, testObj) { if (spec === testObj) { return true; } if (testObj == null) { return false; } parsedSpec.fn = parsedSpec.fn || []; parsedSpec.obj = parsedSpec.obj || []; var key, val, idx = -1, fnLen = parsedSpec.fn.length, j = -1, objLen = parsedSpec.obj.length; while (++idx < fnLen) { key = parsedSpec.fn[idx]; val = spec[key]; // if (!hasOwnProperty.call(testObj, key)) { // return false; // } if (!(key in testObj)) { return false; } if (!val(testObj[key], testObj)) { return false; } } while (++j < objLen) { key = parsedSpec.obj[j]; if (spec[key] !== testObj[key]) { return false; } } return true; } /** * Takes a spec object and a test object and returns true if the test satisfies the spec. * Any property on the spec that is not a function is interpreted as an equality * relation. * * If the spec has a property mapped to a function, then `where` evaluates the function, passing in * the test object's value for the property in question, as well as the whole test object. * * `where` is well suited to declarativley expressing constraints for other functions, e.g., * `filter`, `find`, `pickWith`, etc. * * @func * @memberOf R * @category Object * @sig {k: v} -> {k: v} -> Boolean * @param {Object} spec * @param {Object} testObj * @return {Boolean} * @example * * var spec = {x: 2}; * R.where(spec, {w: 10, x: 2, y: 300}); //=> true * R.where(spec, {x: 1, y: 'moo', z: true}); //=> false * * var spec2 = {x: function(val, obj) { return val + obj.y > 10; }}; * R.where(spec2, {x: 2, y: 7}); //=> false * R.where(spec2, {x: 3, y: 8}); //=> true * * var xs = [{x: 2, y: 1}, {x: 10, y: 2}, {x: 8, y: 3}, {x: 10, y: 4}]; * R.filter(R.where({x: 10}), xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}] */ R.where = function where(spec, testObj) { var parsedSpec = R.groupBy(function(key) { return typeof spec[key] === 'function' ? 'fn' : 'obj'; }, keys(spec)); switch (arguments.length) { case 0: throw NO_ARGS_EXCEPTION; case 1: return function(testObj) { return satisfiesSpec(spec, parsedSpec, testObj); }; } return satisfiesSpec(spec, parsedSpec, testObj); }; // Miscellaneous Functions // ----------------------- // // A few functions in need of a good home. // -------- /** * Expose the functions from ramda as properties of another object. * If the provided object is the global object then the ramda * functions become global functions. * Warning: This function *will* mutate the object provided. * * @func * @memberOf R * @category Object * @sig -> {*} -> {*} * @param {Object} obj The object to attach ramda functions * @return {Object} a reference to the mutated object * @example * * var x = {} * R.installTo(x); // x now contains ramda functions * R.installTo(this); // add ramda functions to `this` object */ R.installTo = function(obj) { return extend(obj, R); }; /** * See if an object (`val`) is an instance of the supplied constructor. * This function will check up the inheritance chain, if any. * * @func * @memberOf R * @category type * @sig (* -> {*}) -> a -> Boolean * @param {Object} ctor A constructor * @param {*} val The value to test * @return {Boolean} * @example * * R.is(Object, {}); //=> true * R.is(Number, 1); //=> true * R.is(Object, 1); //=> false * R.is(String, 's'); //=> true * R.is(String, new String('')); //=> true * R.is(Object, new String('')); //=> true * R.is(Object, 's'); //=> false * R.is(Number, {}); //=> false */ R.is = curry2(function is(ctor, val) { return val != null && val.constructor === ctor || val instanceof ctor; }); /** * A function that always returns `0`. Any passed in parameters are ignored. * * @func * @memberOf R * @category function * @sig * -> 0 * @see R.always * @return {Number} 0. Always zero. * @example * * R.alwaysZero(); //=> 0 */ R.alwaysZero = always(0); /** * A function that always returns `false`. Any passed in parameters are ignored. * * @func * @memberOf R * @category function * @sig * -> false * @see R.always * @return {Boolean} false * @example * * R.alwaysFalse(); //=> false */ R.alwaysFalse = always(false); /** * A function that always returns `true`. Any passed in parameters are ignored. * * @func * @memberOf R * @category function * @sig * -> true * @see R.always * @return {Boolean} true * @example * * R.alwaysTrue(); //=> true */ R.alwaysTrue = always(true); // Logic Functions // --------------- // // These functions are very simple wrappers around the built-in logical operators, useful in building up // more complex functional forms. // -------- /** * * A function wrapping calls to the two functions in an `&&` operation, returning `true` or `false`. Note that * this is short-circuited, meaning that the second function will not be invoked if the first returns a false-y * value. * * @func * @memberOf R * @category logic * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) * @param {Function} f a predicate * @param {Function} g another predicate * @return {Function} a function that applies its arguments to `f` and `g` and ANDs their outputs together. * @example * * var gt10 = function(x) { return x > 10; }; * var even = function(x) { return x % 2 === 0 }; * var f = R.and(gt10, even); * f(100); //=> true * f(101); //=> false */ R.and = curry2(function and(f, g) { return function _and() { return !!(f.apply(this, arguments) && g.apply(this, arguments)); }; }); /** * A function wrapping calls to the two functions in an `||` operation, returning `true` or `false`. Note that * this is short-circuited, meaning that the second function will not be invoked if the first returns a truth-y * value. * * @func * @memberOf R * @category logic * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) * @param {Function} f a predicate * @param {Function} g another predicate * @return {Function} a function that applies its arguments to `f` and `g` and ORs their outputs together. * @example * * var gt10 = function(x) { return x > 10; }; * var even = function(x) { return x % 2 === 0 }; * var f = R.or(gt10, even); * f(101); //=> true * f(8); //=> true */ R.or = curry2(function or(f, g) { return function _or() { return !!(f.apply(this, arguments) || g.apply(this, arguments)); }; }); /** * A function wrapping a call to the given function in a `!` operation. It will return `true` when the * underlying function would return a false-y value, and `false` when it would return a truth-y one. * * @func * @memberOf R * @category logic * @sig (*... -> Boolean) -> (*... -> Boolean) * @param {Function} f a predicate * @return {Function} a function that applies its arguments to `f` and logically inverts its output. * @example * * var gt10 = function(x) { return x > 10; }; * var f = R.not(gt10); * f(11); //=> false * f(9); //=> true */ var not = R.not = function _not(f) { return function() {return !f.apply(this, arguments);}; }; /** * Create a predicate wrapper which will call a pick function (all/any) for each predicate * * @private * @see R.every * @see R.some */ // TODO: document, even for internals... var predicateWrap = function _predicateWrap(predPicker) { return function(preds /* , args */) { var predIterator = function() { var args = arguments; return predPicker(function(predicate) { return predicate.apply(null, args); }, preds); }; return arguments.length > 1 ? // Call function imediately if given arguments predIterator.apply(null, _slice(arguments, 1)) : // Return a function which will call the predicates with the provided arguments arity(max(pluck('length', preds)), predIterator); }; }; /** * Given a list of predicates, returns a new predicate that will be true exactly when all of them are. * * @func * @memberOf R * @category logic * @sig [(*... -> Boolean)] -> (*... -> Boolean) * @param {Array} list An array of predicate functions * @param {*} optional Any arguments to pass into the predicates * @return {Function} a function that applies its arguments to each of * the predicates, returning `true` if all are satisfied. * @example * * var gt10 = function(x) { return x > 10; }; * var even = function(x) { return x % 2 === 0}; * var f = R.allPredicates([gt10, even]); * f(11); //=> false * f(12); //=> true */ R.allPredicates = predicateWrap(every); /** * Given a list of predicates returns a new predicate that will be true exactly when any one of them is. * * @func * @memberOf R * @category logic * @sig [(*... -> Boolean)] -> (*... -> Boolean) * @param {Array} list An array of predicate functions * @param {*} optional Any arguments to pass into the predicates * @return {Function} a function that applies its arguments to each of the predicates, returning * `true` if all are satisfied.. * @example * * var gt10 = function(x) { return x > 10; }; * var even = function(x) { return x % 2 === 0}; * var f = R.anyPredicates([gt10, even]); * f(11); //=> true * f(8); //=> true * f(9); //=> false */ R.anyPredicates = predicateWrap(some); // Arithmetic Functions // -------------------- // // These functions wrap up the certain core arithmetic operators // -------- /** * Adds two numbers (or strings). Equivalent to `a + b` but curried. * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @sig String -> String -> String * @param {number|string} a The first value. * @param {number|string} b The second value. * @return {number|string} The result of `a + b`. * @example * * var increment = R.add(1); * increment(10); //=> 11 * R.add(2, 3); //=> 5 * R.add(7)(10); //=> 17 */ var add = R.add = curry2(function _add(a, b) { return a + b; }); /** * Multiplies two numbers. Equivalent to `a * b` but curried. * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @param {number} a The first value. * @param {number} b The second value. * @return {number} The result of `a * b`. * @example * * var double = R.multiply(2); * var triple = R.multiply(3); * double(3); //=> 6 * triple(4); //=> 12 * R.multiply(2, 5); //=> 10 */ var multiply = R.multiply = curry2(function _multiply(a, b) { return a * b; }); /** * Subtracts two numbers. Equivalent to `a - b` but curried. * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @param {number} a The first value. * @param {number} b The second value. * @return {number} The result of `a - b`. * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.subtract(10, 8); //=> 2 * * var minus5 = R.subtract(5); * minus5(17); //=> 12 * * // note: In this example, `_` is just an `undefined` value. You could use `void 0` instead * var complementaryAngle = R.subtract(90, _); * complementaryAngle(30); //=> 60 * complementaryAngle(72); //=> 18 */ R.subtract = op(function _subtract(a, b) { return a - b; }); /** * Divides two numbers. Equivalent to `a / b`. * While at times the curried version of `divide` might be useful, * probably the curried version of `divideBy` will be more useful. * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @param {number} a The first value. * @param {number} b The second value. * @return {number} The result of `a / b`. * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.divide(71, 100); //=> 0.71 * * // note: In this example, `_` is just an `undefined` value. You could use `void 0` instead * var half = R.divide(2); * half(42); //=> 21 * * var reciprocal = R.divide(1, _); * reciprocal(4); //=> 0.25 */ R.divide = op(function _divide(a, b) { return a / b; }); /** * Divides the second parameter by the first and returns the remainder. * Note that this functions preserves the JavaScript-style behavior for * modulo. For mathematical modulo see `mathMod` * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @param {number} a The value to the divide. * @param {number} b The pseudo-modulus * @return {number} The result of `b % a`. * @note Operator: this is right-curried by default, but can be called via sections * @see R.mathMod * @example * * R.modulo(17, 3); //=> 2 * // JS behavior: * R.modulo(-17, 3); //=> -2 * R.modulo(17, -3); //=> 2 * * var isOdd = R.modulo(2); * isOdd(42); //=> 0 * isOdd(21); //=> 1 */ R.modulo = op(function _modulo(a, b) { return a % b; }); /** * Determine if the passed argument is an integer. * * @private * @param {*} n * @category type * @return {Boolean} */ // TODO: document, even for internals... var isInteger = Number.isInteger || function isInteger(n) { return (n << 0) === n; }; /** * mathMod behaves like the modulo operator should mathematically, unlike the `%` * operator (and by extension, R.modulo). So while "-17 % 5" is -2, * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN * when the modulus is zero or negative. * * @func * @memberOf R * @category math * @sig Number -> Number -> Number * @param {number} m The dividend. * @param {number} p the modulus. * @return {number} The result of `b mod a`. * @see R.moduloBy * @example * * R.mathMod(-17, 5); //=> 3 * R.mathMod(17, 5); //=> 2 * R.mathMod(17, -5); //=> NaN * R.mathMod(17, 0); //=> NaN * R.mathMod(17.2, 5); //=> NaN * R.mathMod(17, 5.3); //=> NaN * * var clock = R.mathMod(12); * clock(15); //=> 3 * clock(24); //=> 0 * * // note: In this example, `_` is just an `undefined` value. You could use `void 0` instead * var seventeenMod = R.mathMod(17, _); * seventeenMod(3); //=> 2 * seventeenMod(4); //=> 1 * seventeenMod(10); //=> 7 */ R.mathMod = op(function _mathMod(m, p) { if (!isInteger(m)) { return NaN; } if (!isInteger(p) || p < 1) { return NaN; } return ((m % p) + p) % p; }); /** * Adds together all the elements of a list. * * @func * @memberOf R * @category math * @sig [Number] -> Number * @param {Array} list An array of numbers * @return {number} The sum of all the numbers in the list. * @see reduce * @example * * R.sum([2,4,6,8,100,1]); //=> 121 */ R.sum = foldl(add, 0); /** * Multiplies together all the elements of a list. * * @func * @memberOf R * @category math * @sig [Number] -> Number * @param {Array} list An array of numbers * @return {number} The product of all the numbers in the list. * @see reduce * @example * * R.product([2,4,6,8,100,1]); //=> 38400 */ R.product = foldl(multiply, 1); /** * Returns true if the first parameter is less than the second. * * @func * @memberOf R * @category math * @sig Number -> Number -> Boolean * @param {Number} a * @param {Number} b * @return {Boolean} a < b * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.lt(2, 6); //=> true * R.lt(2, 0); //=> false * R.lt(2, 2); //=> false * R.lt(5)(10); //=> false // default currying is right-sectioned * R.lt(5, _)(10); //=> true // left-sectioned currying */ R.lt = op(function _lt(a, b) { return a < b; }); /** * Returns true if the first parameter is less than or equal to the second. * * @func * @memberOf R * @category math * @sig Number -> Number -> Boolean * @param {Number} a * @param {Number} b * @return {Boolean} a <= b * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.lte(2, 6); //=> true * R.lte(2, 0); //=> false * R.lte(2, 2); //=> true */ R.lte = op(function _lte(a, b) { return a <= b; }); /** * Returns true if the first parameter is greater than the second. * * @func * @memberOf R * @category math * @sig Number -> Number -> Boolean * @param {Number} a * @param {Number} b * @return {Boolean} a > b * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.gt(2, 6); //=> false * R.gt(2, 0); //=> true * R.gt(2, 2); //=> false */ R.gt = op(function _gt(a, b) { return a > b; }); /** * Returns true if the first parameter is greater than or equal to the second. * * @func * @memberOf R * @category math * @sig Number -> Number -> Boolean * @param {Number} a * @param {Number} b * @return {Boolean} a >= b * @note Operator: this is right-curried by default, but can be called via sections * @example * * R.gte(2, 6); //=> false * R.gte(2, 0); //=> true * R.gte(2, 2); //=> true */ R.gte = op(function _gte(a, b) { return a >= b; }); /** * Determines the largest of a list of numbers (or elements that can be cast to numbers) * * @func * @memberOf R * @category math * @sig [Number] -> Number * @see R.maxWith * @param {Array} list A list of numbers * @return {Number} The greatest number in the list * @example * * R.max([7, 3, 9, 2, 4, 9, 3]); //=> 9 */ var max = R.max = function _max(list) { return foldl(binary(Math.max), -Infinity, list); }; /** * Determines the largest of a list of items as determined by pairwise comparisons from the supplied comparator * * @func * @memberOf R * @category math * @sig (a -> Number) -> [a] -> a * @param {Function} keyFn A comparator function for elements in the list * @param {Array} list A list of comparable elements * @return {*} The greatest element in the list. `undefined` if the list is empty. * @see R.max * @example * * function cmp(obj) { return obj.x; } * var a = {x: 1}, b = {x: 2}, c = {x: 3}; * R.maxWith(cmp, [a, b, c]); //=> {x: 3} */ R.maxWith = curry2(function _maxWith(keyFn, list) { if (!(list && list.length > 0)) { return; } var idx = 0, winner = list[idx], max = keyFn(winner), testKey; while (++idx < list.length) { testKey = keyFn(list[idx]); if (testKey > max) { max = testKey; winner = list[idx]; } } return winner; }); /** * Determines the smallest of a list of numbers (or elements that can be cast to numbers) * * @func * @memberOf R * @category math * @sig [Number] -> Number * @param {Array} list A list of numbers * @return {Number} The greatest number in the list * @see R.minWith * @example * * R.min([7, 3, 9, 2, 4, 9, 3]); //=> 2 */ R.min = function _min(list) { return foldl(binary(Math.min), Infinity, list); }; /** * Determines the smallest of a list of items as determined by pairwise comparisons from the supplied comparator * * @func * @memberOf R * @category math * @sig (a -> Number) -> [a] -> a * @param {Function} keyFn A comparator function for elements in the list * @param {Array} list A list of comparable elements * @see R.min * @return {*} The greatest element in the list. `undefined` if the list is empty. * @example * * function cmp(obj) { return obj.x; } * var a = {x: 1}, b = {x: 2}, c = {x: 3}; * R.minWith(cmp, [a, b, c]); //=> {x: 1} */ // TODO: combine this with maxWith? R.minWith = curry2(function _minWith(keyFn, list) { if (!(list && list.length > 0)) { return; } var idx = 0, winner = list[idx], min = keyFn(list[idx]), testKey; while (++idx < list.length) { testKey = keyFn(list[idx]); if (testKey < min) { min = testKey; winner = list[idx]; } } return winner; }); // String Functions // ---------------- // // Much of the String.prototype API exposed as simple functions. // -------- /** * returns a subset of a string between one index and another. * * @func * @memberOf R * @category string * @sig Number -> Number -> String -> String * @param {Number} indexA An integer between 0 and the length of the string. * @param {Number} indexB An integer between 0 and the length of the string. * @param {String} The string to extract from * @return {String} the extracted substring * @see R.invoker * @example * * R.substring(2, 5, 'abcdefghijklm'); //=> 'cde' */ var substring = R.substring = invoker('substring', String.prototype); /** * The trailing substring of a String starting with the nth character: * * @func * @memberOf R * @category string * @sig Number -> String -> String * @param {Number} indexA An integer between 0 and the length of the string. * @param {String} The string to extract from * @return {String} the extracted substring * @see R.invoker * @example * * R.substringFrom(8, 'abcdefghijklm'); //=> 'ijklm' */ R.substringFrom = flip(substring)(void 0); /** * The leading substring of a String ending before the nth character: * * @func * @memberOf R * @category string * @sig Number -> String -> String * @param {Number} indexA An integer between 0 and the length of the string. * @param {String} The string to extract from * @return {String} the extracted substring * @see R.invoker * @example * * R.substringTo(8, 'abcdefghijklm'); //=> 'abcdefgh' */ R.substringTo = substring(0); /** * The character at the nth position in a String: * * @func * @memberOf R * @category string * @sig Number -> String -> String * @param {Number} index An integer between 0 and the length of the string. * @param {String} str The string to extract a char from * @return {String} the character at `index` of `str` * @see R.invoker * @example * * R.charAt(8, 'abcdefghijklm'); //=> 'i' */ R.charAt = invoker('charAt', String.prototype); /** * The ascii code of the character at the nth position in a String: * * @func * @memberOf R * @category string * @sig Number -> String -> Number * @param {Number} index An integer between 0 and the length of the string. * @param {String} str The string to extract a charCode from * @return {Number} the code of the character at `index` of `str` * @see R.invoker * @example * * R.charCodeAt(8, 'abcdefghijklm'); //=> 105 * // (... 'a' ~ 97, 'b' ~ 98, ... 'i' ~ 105) */ R.charCodeAt = invoker('charCodeAt', String.prototype); /** * Tests a regular expression agains a String * * @func * @memberOf R * @category string * @sig RegExp -> String -> [String] | null * @param {RegExp} rx A regular expression. * @param {String} str The string to match against * @return {Array} The list of matches, or null if no matches found * @see R.invoker * @example * * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] */ R.match = invoker('match', String.prototype); /** * Finds the first index of a substring in a string, returning -1 if it's not present * * @func * @memberOf R * @category string * @sig String -> String -> Number * @param {String} c A string to find. * @param {String} str The string to search in * @return {Number} The first index of `c` or -1 if not found * @see R.invoker * @example * * R.strIndexOf('c', 'abcdefg'); //=> 2 */ R.strIndexOf = curry2(function _strIndexOf(c, str) { return str.indexOf(c); }); /** * * Finds the last index of a substring in a string, returning -1 if it's not present * * @func * @memberOf R * @category string * @sig String -> String -> Number * @param {String} c A string to find. * @param {String} str The string to search in * @return {Number} The last index of `c` or -1 if not found * @see R.invoker * @example * * R.strLastIndexOf('a', 'banana split'); //=> 5 */ R.strLastIndexOf = curry2(function(c, str) { return str.lastIndexOf(c); }); /** * The upper case version of a string. * * @func * @memberOf R * @category string * @sig String -> String * @param {string} str The string to upper case. * @return {string} The upper case version of `str`. * @example * * R.toUpperCase('abc'); //=> 'ABC' */ R.toUpperCase = invoker('toUpperCase', String.prototype); /** * The lower case version of a string. * * @func * @memberOf R * @category string * @sig String -> String * @param {string} str The string to lower case. * @return {string} The lower case version of `str`. * @example * * R.toLowerCase('XYZ'); //=> 'xyz' */ R.toLowerCase = invoker('toLowerCase', String.prototype); /** * Splits a string into an array of strings based on the given * separator. * * @func * @memberOf R * @category string * @sig String -> String -> [String] * @param {string} sep The separator string. * @param {string} str The string to separate into an array. * @return {Array} The array of strings from `str` separated by `str`. * @example * * var pathComponents = R.split('/'); * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] * * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] */ R.split = invoker('split', String.prototype, 1); /** * internal path function * Takes an array, paths, indicating the deep set of keys * to find. * * @private * @memberOf R * @category string * @param {Array} paths An array of strings to map to object properties * @param {Object} obj The object to find the path in * @return {Array} The value at the end of the path or `undefined`. * @example * * path(['a', 'b'], {a: {b: 2}}); //=> 2 */ function path(paths, obj) { var idx = -1, length = paths.length, val; if (obj == null) { return; } val = obj; while (val != null && ++idx < length) { val = val[paths[idx]]; } return val; } /** * Retrieve a nested path on an object seperated by the specified * separator value. * * @func * @memberOf R * @category string * @sig String -> String -> {*} -> * * @param {string} sep The separator to use in `path`. * @param {string} path The path to use. * @return {*} The data at `path`. * @example * * R.pathOn('/', 'a/b/c', {a: {b: {c: 3}}}); //=> 3 */ R.pathOn = curry3(function pathOn(sep, str, obj) { return path(str.split(sep), obj); }); /** * Retrieve a nested path on an object seperated by periods * * @func * @memberOf R * @category string * @sig String -> {*} -> * * @param {string} path The dot path to use. * @return {*} The data at `path`. * @example * * R.path('a.b', {a: {b: 2}}); //=> 2 */ R.path = R.pathOn('.'); // Data Analysis and Grouping Functions // ------------------------------------ // // Functions performing SQL-like actions on lists of objects. These do // not have any SQL-like optimizations performed on them, however. // -------- /** * Reasonable analog to SQL `select` statement. * * @func * @memberOf R * @category object * @category relation * @string [k] -> [{k: v}] -> [{k: v}] * @param {Array} props The property names to project * @param {Array} objs The objects to query * @return {Array} An array of objects with just the `props` properties. * @example * * var abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; * var fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; * var kids = [abby, fred]; * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] */ R.project = useWith(map, R.pickAll, identity); // passing `identity` gives correct arity /** * Determines whether the given property of an object has a specific * value according to strict equality (`===`). Most likely used to * filter a list: * * @func * @memberOf R * @category relation * @sig k -> v -> {k: v} -> Boolean * @param {string|number} name The property name (or index) to use. * @param {*} val The value to compare the property with. * @return {boolean} `true` if the properties are equal, `false` otherwise. * @example * * var abby = {name: 'Abby', age: 7, hair: 'blond'}; * var fred = {name: 'Fred', age: 12, hair: 'brown'}; * var rusty = {name: 'Rusty', age: 10, hair: 'brown'}; * var alois = {name: 'Alois', age: 15, disposition: 'surly'}; * var kids = [abby, fred, rusty, alois]; * var hasBrownHair = R.propEq('hair', 'brown'); * R.filter(hasBrownHair, kids); //=> [fred, rusty] */ R.propEq = curry3(function propEq(name, val, obj) { return obj[name] === val; }); /** * Combines two lists into a set (i.e. no duplicates) composed of the * elements of each list. * * @func * @memberOf R * @category relation * @sig [a] -> [a] -> [a] * @param {Array} as The first list. * @param {Array} bs The second list. * @return {Array} The first and second lists concatenated, with * duplicates removed. * @example * * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] */ R.union = compose(uniq, R.concat); /** * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is * determined according to the value returned by applying the supplied predicate to two list elements. * * @func * @memberOf R * @category relation * @sig (a,a -> Boolean) -> [a] -> [a] -> [a] * @param {Function} pred * @param {Array} list1 The first list. * @param {Array} list2 The second list. * @return {Array} The first and second lists concatenated, with * duplicates removed. * @see R.union * @example * * function cmp(x, y) { return x.a === y.a; } * var l1 = [{a: 1}, {a: 2}]; * var l2 = [{a: 1}, {a: 4}]; * R.unionWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] */ R.unionWith = curry3(function _unionWith(pred, list1, list2) { return uniqWith(pred, concat(list1, list2)); }); /** * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. * * @func * @memberOf R * @category relation * @sig [a] -> [a] -> [a] * @param {Array} list1 The first list. * @param {Array} list2 The second list. * @return {Array} The elements in `list1` that are not in `list2` * @see R.differenceWith * @example * * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2] * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] */ R.difference = curry2(function _difference(first, second) { return uniq(reject(flip(contains)(second), first)); }); /** * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. * Duplication is determined according to the value returned by applying the supplied predicate to two list * elements. * * @func * @memberOf R * @category relation * @sig (a,a -> Boolean) -> [a] -> [a] -> [a] * @param {Function} pred * @param {Array} list1 The first list. * @param {Array} list2 The second list. * @see R.difference * @return {Array} The elements in `list1` that are not in `list2` * @example * * function cmp(x, y) { return x.a === y.a; } * var l1 = [{a: 1}, {a: 2}, {a: 3}]; * var l2 = [{a: 3}, {a: 4}]; * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] * */ R.differenceWith = curry3(function differenceWith(pred, first, second) { return uniqWith(pred)(reject(flip(R.containsWith(pred))(second), first)); }); /** * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists. * * @func * @memberOf R * @category relation * @sig [a] -> [a] -> [a] * @param {Array} list1 The first list. * @param {Array} list2 The second list. * @see R.intersectionWith * @return {Array} The list of elements found in both `list1` and `list2` * @example * * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] */ R.intersection = curry2(function intersection(list1, list2) { return uniq(filter(flip(contains)(list1), list2)); }); /** * Combines two lists into a set (i.e. no duplicates) composed of those * elements common to both lists. Duplication is determined according * to the value returned by applying the supplied predicate to two list * elements. * * @func * @memberOf R * @category relation * @sig (a,a -> Boolean) -> [a] -> [a] -> [a] * @param {Function} pred A predicate function that determines whether * the two supplied elements are equal. * Signatrue: a -> a -> Boolean * @param {Array} list1 One list of items to compare * @param {Array} list2 A second list of items to compare * @see R.intersection * @return {Array} A new list containing those elements common to both lists. * @example * * var buffaloSpringfield = [ * {id: 824, name: 'Richie Furay'}, * {id: 956, name: 'Dewey Martin'}, * {id: 313, name: 'Bruce Palmer'}, * {id: 456, name: 'Stephen Stills'}, * {id: 177, name: 'Neil Young'} * ]; * var csny = [ * {id: 204, name: 'David Crosby'}, * {id: 456, name: 'Stephen Stills'}, * {id: 539, name: 'Graham Nash'}, * {id: 177, name: 'Neil Young'} * ]; * * var sameId = function(o1, o2) {return o1.id === o2.id;}; * * R.intersectionWith(sameId, buffaloSpringfield, csny); * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] */ R.intersectionWith = curry3(function intersectionWith(pred, list1, list2) { var results = [], idx = -1; while (++idx < list1.length) { if (containsWith(pred, list1[idx], list2)) { results[results.length] = list1[idx]; } } return uniqWith(pred, results); }); /** * Creates a new list whose elements each have two properties: `val` is * the value of the corresponding item in the list supplied, and `key` * is the result of applying the supplied function to that item. * * @private * @func * @memberOf R * @category relation * @param {Function} fn An arbitrary unary function returning a potential * object key. Signature: Any -> String * @param {Array} list The list of items to process * @return {Array} A new list with the described structure. * @example * * var people = [ * {first: 'Fred', last: 'Flintstone', age: 23}, * {first: 'Betty', last: 'Rubble', age: 21}, * {first: 'George', last: 'Jetson', age: 29} * ]; * * var fullName = function(p) {return p.first + ' ' + p.last;}; * * keyValue(fullName, people); //=> * // [ * // { * // key: 'Fred Flintstone', * // val: {first: 'Fred', last: 'Flintstone', age: 23} * // }, { * // key: 'Betty Rubble', * // val: {first: 'Betty', last: 'Rubble', age: 21} * // }, { * // key: 'George Jetson', * // val: {first: 'George', last: 'Jetson', age: 29} * // } * // ]; */ function keyValue(fn, list) { // TODO: Should this be made public? return map(function(item) {return {key: fn(item), val: item};}, list); } /** * Sorts the list according to a key generated by the supplied function. * * @func * @memberOf R * @category relation * @sig (a -> String) -> [a] -> [a] * @param {Function} fn The function mapping `list` items to keys. * @param {Array} list The list to sort. * @return {Array} A new list sorted by the keys generated by `fn`. * @example * * var sortByFirstItem = R.sortBy(prop(0)); * var sortByNameCaseInsensitive = R.sortBy(compose(R.toLowerCase, prop('name'))); * var pairs = [[-1, 1], [-2, 2], [-3, 3]]; * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] * var alice = { * name: 'ALICE', * age: 101 * }; * var bob = { * name: 'Bob', * age: -10 * }; * var clara = { * name: 'clara', * age: 314.159 * }; * var people = [clara, bob, alice]; * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] */ R.sortBy = curry2(function sortBy(fn, list) { return pluck('val', keyValue(fn, list).sort(comparator(function(a, b) {return a.key < b.key;}))); }); /** * Counts the elements of a list according to how many match each value * of a key generated by the supplied function. Returns an object * mapping the keys produced by `fn` to the number of occurrences in * the list. Note that all keys are coerced to strings because of how * JavaScript objects work. * * @func * @memberOf R * @category relation * @sig (a -> String) -> [a] -> {*} * @param {Function} fn The function used to map values to keys. * @param {Array} list The list to count elements from. * @return {Object} An object mapping keys to number of occurrences in the list. * @example * * var numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; * var letters = R.split('', 'abcABCaaaBBc'); * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1} * R.countBy(R.toLowerCase)(letters); //=> {'a': 5, 'b': 4, 'c': 3} */ R.countBy = curry2(function countBy(fn, list) { return foldl(function(counts, obj) { counts[obj.key] = (counts[obj.key] || 0) + 1; return counts; }, {}, keyValue(fn, list)); }); /** * @private * @param {Function} fn The strategy for extracting function names from an object * @return {Function} A function that takes an object and returns an array of function names * */ var functionsWith = function(fn) { return function(obj) { return R.filter(function(key) { return typeof obj[key] === 'function'; }, fn(obj)); }; }; /** * Returns a list of function names of object's own functions * * @func * @memberOf R * @category Object * @sig {*} -> [String] * @param {Object} obj The objects with functions in it * @return {Array} returns a list of the object's own properites that map to functions * @example * * R.functions(R); // returns list of ramda's own function names * * var F = function() { this.x = function(){}; this.y = 1; } * F.prototype.z = function() {}; * F.prototype.a = 100; * R.functions(new F()); //=> ["x"] */ R.functions = functionsWith(R.keys); /** * Returns a list of function names of object's own and prototype functions * * @func * @memberOf R * @category Object * @sig {*} -> [String] * @param {Object} obj The objects with functions in it * @return {Array} returns a list of the object's own properites and prototype * properties that map to functions * @example * * R.functionsIn(R); // returns list of ramda's own and prototype function names * * var F = function() { this.x = function(){}; this.y = 1; } * F.prototype.z = function() {}; * F.prototype.a = 100; * R.functionsIn(new F()); //=> ["x", "z"] */ R.functionsIn = functionsWith(R.keysIn); // All the functional goodness, wrapped in a nice little package, just for you! return R; }));
/* * YAFFS: Yet another Flash File System . A NAND-flash specific file system. * * Copyright (C) 2002-2010 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning <charles@aleph1.co.uk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1 as * published by the Free Software Foundation. * * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ #ifndef __YAFFS_TAGS_VALIDITY_H__ #define __YAFFS_TAGS_VALIDITY_H__ #include "yaffs_guts.h" void yaffs_init_tags(yaffs_ext_tags *tags); int yaffs_validate_tags(yaffs_ext_tags *tags); #endif
/* * linux/fs/nfs/nfs3proc.c * * Client-side NFSv3 procedures stubs. * * Copyright (C) 1997, Olaf Kirch */ #include <linux/mm.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/sunrpc/clnt.h> #include <linux/slab.h> #include <linux/nfs.h> #include <linux/nfs3.h> #include <linux/nfs_fs.h> #include <linux/nfs_page.h> #include <linux/lockd/bind.h> #include <linux/nfs_mount.h> #include <linux/freezer.h> #include <linux/xattr.h> #include "iostat.h" #include "internal.h" #include "nfs3_fs.h" #define NFSDBG_FACILITY NFSDBG_PROC /* A wrapper to handle the EJUKEBOX error messages */ static int nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) { int res; do { res = rpc_call_sync(clnt, msg, flags); if (res != -EJUKEBOX) break; freezable_schedule_timeout_killable_unsafe(NFS_JUKEBOX_RETRY_TIME); res = -ERESTARTSYS; } while (!fatal_signal_pending(current)); return res; } #define rpc_call_sync(clnt, msg, flags) nfs3_rpc_wrapper(clnt, msg, flags) static int nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode) { if (task->tk_status != -EJUKEBOX) return 0; if (task->tk_status == -EJUKEBOX) nfs_inc_stats(inode, NFSIOS_DELAY); task->tk_status = 0; rpc_restart_call(task); rpc_delay(task, NFS_JUKEBOX_RETRY_TIME); return 1; } static int do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle, struct nfs_fsinfo *info) { struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_FSINFO], .rpc_argp = fhandle, .rpc_resp = info, }; int status; dprintk("%s: call fsinfo\n", __func__); nfs_fattr_init(info->fattr); status = rpc_call_sync(client, &msg, 0); dprintk("%s: reply fsinfo: %d\n", __func__, status); if (status == 0 && !(info->fattr->valid & NFS_ATTR_FATTR)) { msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; msg.rpc_resp = info->fattr; status = rpc_call_sync(client, &msg, 0); dprintk("%s: reply getattr: %d\n", __func__, status); } return status; } /* * Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb */ static int nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info) { int status; status = do_proc_get_root(server->client, fhandle, info); if (status && server->nfs_client->cl_rpcclient != server->client) status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info); return status; } /* * One function for each procedure in the NFS protocol. */ static int nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label) { struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR], .rpc_argp = fhandle, .rpc_resp = fattr, }; int status; dprintk("NFS call getattr\n"); nfs_fattr_init(fattr); status = rpc_call_sync(server->client, &msg, 0); dprintk("NFS reply getattr: %d\n", status); return status; } static int nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, struct iattr *sattr) { struct inode *inode = dentry->d_inode; struct nfs3_sattrargs arg = { .fh = NFS_FH(inode), .sattr = sattr, }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_SETATTR], .rpc_argp = &arg, .rpc_resp = fattr, }; int status; dprintk("NFS call setattr\n"); if (sattr->ia_valid & ATTR_FILE) msg.rpc_cred = nfs_file_cred(sattr->ia_file); nfs_fattr_init(fattr); status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); if (status == 0) nfs_setattr_update_inode(inode, sattr); dprintk("NFS reply setattr: %d\n", status); return status; } static int nfs3_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label) { struct nfs3_diropargs arg = { .fh = NFS_FH(dir), .name = name->name, .len = name->len }; struct nfs3_diropres res = { .fh = fhandle, .fattr = fattr }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_LOOKUP], .rpc_argp = &arg, .rpc_resp = &res, }; int status; dprintk("NFS call lookup %s\n", name->name); res.dir_attr = nfs_alloc_fattr(); if (res.dir_attr == NULL) return -ENOMEM; nfs_fattr_init(fattr); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_refresh_inode(dir, res.dir_attr); if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; msg.rpc_argp = fhandle; msg.rpc_resp = fattr; status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); } nfs_free_fattr(res.dir_attr); dprintk("NFS reply lookup: %d\n", status); return status; } static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) { struct nfs3_accessargs arg = { .fh = NFS_FH(inode), }; struct nfs3_accessres res; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], .rpc_argp = &arg, .rpc_resp = &res, .rpc_cred = entry->cred, }; int mode = entry->mask; int status = -ENOMEM; dprintk("NFS call access\n"); if (mode & MAY_READ) arg.access |= NFS3_ACCESS_READ; if (S_ISDIR(inode->i_mode)) { if (mode & MAY_WRITE) arg.access |= NFS3_ACCESS_MODIFY | NFS3_ACCESS_EXTEND | NFS3_ACCESS_DELETE; if (mode & MAY_EXEC) arg.access |= NFS3_ACCESS_LOOKUP; } else { if (mode & MAY_WRITE) arg.access |= NFS3_ACCESS_MODIFY | NFS3_ACCESS_EXTEND; if (mode & MAY_EXEC) arg.access |= NFS3_ACCESS_EXECUTE; } res.fattr = nfs_alloc_fattr(); if (res.fattr == NULL) goto out; status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); nfs_refresh_inode(inode, res.fattr); if (status == 0) { entry->mask = 0; if (res.access & NFS3_ACCESS_READ) entry->mask |= MAY_READ; if (res.access & (NFS3_ACCESS_MODIFY | NFS3_ACCESS_EXTEND | NFS3_ACCESS_DELETE)) entry->mask |= MAY_WRITE; if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE)) entry->mask |= MAY_EXEC; } nfs_free_fattr(res.fattr); out: dprintk("NFS reply access: %d\n", status); return status; } static int nfs3_proc_readlink(struct inode *inode, struct page *page, unsigned int pgbase, unsigned int pglen) { struct nfs_fattr *fattr; struct nfs3_readlinkargs args = { .fh = NFS_FH(inode), .pgbase = pgbase, .pglen = pglen, .pages = &page }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_READLINK], .rpc_argp = &args, }; int status = -ENOMEM; dprintk("NFS call readlink\n"); fattr = nfs_alloc_fattr(); if (fattr == NULL) goto out; msg.rpc_resp = fattr; status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); nfs_refresh_inode(inode, fattr); nfs_free_fattr(fattr); out: dprintk("NFS reply readlink: %d\n", status); return status; } struct nfs3_createdata { struct rpc_message msg; union { struct nfs3_createargs create; struct nfs3_mkdirargs mkdir; struct nfs3_symlinkargs symlink; struct nfs3_mknodargs mknod; } arg; struct nfs3_diropres res; struct nfs_fh fh; struct nfs_fattr fattr; struct nfs_fattr dir_attr; }; static struct nfs3_createdata *nfs3_alloc_createdata(void) { struct nfs3_createdata *data; data = kzalloc(sizeof(*data), GFP_KERNEL); if (data != NULL) { data->msg.rpc_argp = &data->arg; data->msg.rpc_resp = &data->res; data->res.fh = &data->fh; data->res.fattr = &data->fattr; data->res.dir_attr = &data->dir_attr; nfs_fattr_init(data->res.fattr); nfs_fattr_init(data->res.dir_attr); } return data; } static int nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data) { int status; status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0); nfs_post_op_update_inode(dir, data->res.dir_attr); if (status == 0) status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL); return status; } static void nfs3_free_createdata(struct nfs3_createdata *data) { kfree(data); } /* * Create a regular file. */ static int nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, int flags) { struct posix_acl *default_acl, *acl; struct nfs3_createdata *data; int status = -ENOMEM; dprintk("NFS call create %pd\n", dentry); data = nfs3_alloc_createdata(); if (data == NULL) goto out; data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_CREATE]; data->arg.create.fh = NFS_FH(dir); data->arg.create.name = dentry->d_name.name; data->arg.create.len = dentry->d_name.len; data->arg.create.sattr = sattr; data->arg.create.createmode = NFS3_CREATE_UNCHECKED; if (flags & O_EXCL) { data->arg.create.createmode = NFS3_CREATE_EXCLUSIVE; data->arg.create.verifier[0] = cpu_to_be32(jiffies); data->arg.create.verifier[1] = cpu_to_be32(current->pid); } status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); if (status) goto out; for (;;) { status = nfs3_do_create(dir, dentry, data); if (status != -ENOTSUPP) break; /* If the server doesn't support the exclusive creation * semantics, try again with simple 'guarded' mode. */ switch (data->arg.create.createmode) { case NFS3_CREATE_EXCLUSIVE: data->arg.create.createmode = NFS3_CREATE_GUARDED; break; case NFS3_CREATE_GUARDED: data->arg.create.createmode = NFS3_CREATE_UNCHECKED; break; case NFS3_CREATE_UNCHECKED: goto out; } nfs_fattr_init(data->res.dir_attr); nfs_fattr_init(data->res.fattr); } if (status != 0) goto out_release_acls; /* When we created the file with exclusive semantics, make * sure we set the attributes afterwards. */ if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) { dprintk("NFS call setattr (post-create)\n"); if (!(sattr->ia_valid & ATTR_ATIME_SET)) sattr->ia_valid |= ATTR_ATIME; if (!(sattr->ia_valid & ATTR_MTIME_SET)) sattr->ia_valid |= ATTR_MTIME; /* Note: we could use a guarded setattr here, but I'm * not sure this buys us anything (and I'd have * to revamp the NFSv3 XDR code) */ status = nfs3_proc_setattr(dentry, data->res.fattr, sattr); nfs_post_op_update_inode(dentry->d_inode, data->res.fattr); dprintk("NFS reply setattr (post-create): %d\n", status); if (status != 0) goto out_release_acls; } status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); out_release_acls: posix_acl_release(acl); posix_acl_release(default_acl); out: nfs3_free_createdata(data); dprintk("NFS reply create: %d\n", status); return status; } static int nfs3_proc_remove(struct inode *dir, struct qstr *name) { struct nfs_removeargs arg = { .fh = NFS_FH(dir), .name = *name, }; struct nfs_removeres res; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE], .rpc_argp = &arg, .rpc_resp = &res, }; int status = -ENOMEM; dprintk("NFS call remove %s\n", name->name); res.dir_attr = nfs_alloc_fattr(); if (res.dir_attr == NULL) goto out; status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_post_op_update_inode(dir, res.dir_attr); nfs_free_fattr(res.dir_attr); out: dprintk("NFS reply remove: %d\n", status); return status; } static void nfs3_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE]; } static void nfs3_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) { rpc_call_start(task); } static int nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) { struct nfs_removeres *res; if (nfs3_async_handle_jukebox(task, dir)) return 0; res = task->tk_msg.rpc_resp; nfs_post_op_update_inode(dir, res->dir_attr); return 1; } static void nfs3_proc_rename_setup(struct rpc_message *msg, struct inode *dir) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME]; } static void nfs3_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) { rpc_call_start(task); } static int nfs3_proc_rename_done(struct rpc_task *task, struct inode *old_dir, struct inode *new_dir) { struct nfs_renameres *res; if (nfs3_async_handle_jukebox(task, old_dir)) return 0; res = task->tk_msg.rpc_resp; nfs_post_op_update_inode(old_dir, res->old_fattr); nfs_post_op_update_inode(new_dir, res->new_fattr); return 1; } static int nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) { struct nfs3_linkargs arg = { .fromfh = NFS_FH(inode), .tofh = NFS_FH(dir), .toname = name->name, .tolen = name->len }; struct nfs3_linkres res; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_LINK], .rpc_argp = &arg, .rpc_resp = &res, }; int status = -ENOMEM; dprintk("NFS call link %s\n", name->name); res.fattr = nfs_alloc_fattr(); res.dir_attr = nfs_alloc_fattr(); if (res.fattr == NULL || res.dir_attr == NULL) goto out; status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); nfs_post_op_update_inode(dir, res.dir_attr); nfs_post_op_update_inode(inode, res.fattr); out: nfs_free_fattr(res.dir_attr); nfs_free_fattr(res.fattr); dprintk("NFS reply link: %d\n", status); return status; } static int nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, unsigned int len, struct iattr *sattr) { struct nfs3_createdata *data; int status = -ENOMEM; if (len > NFS3_MAXPATHLEN) return -ENAMETOOLONG; dprintk("NFS call symlink %pd\n", dentry); data = nfs3_alloc_createdata(); if (data == NULL) goto out; data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK]; data->arg.symlink.fromfh = NFS_FH(dir); data->arg.symlink.fromname = dentry->d_name.name; data->arg.symlink.fromlen = dentry->d_name.len; data->arg.symlink.pages = &page; data->arg.symlink.pathlen = len; data->arg.symlink.sattr = sattr; status = nfs3_do_create(dir, dentry, data); nfs3_free_createdata(data); out: dprintk("NFS reply symlink: %d\n", status); return status; } static int nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) { struct posix_acl *default_acl, *acl; struct nfs3_createdata *data; int status = -ENOMEM; dprintk("NFS call mkdir %pd\n", dentry); data = nfs3_alloc_createdata(); if (data == NULL) goto out; status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); if (status) goto out; data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR]; data->arg.mkdir.fh = NFS_FH(dir); data->arg.mkdir.name = dentry->d_name.name; data->arg.mkdir.len = dentry->d_name.len; data->arg.mkdir.sattr = sattr; status = nfs3_do_create(dir, dentry, data); if (status != 0) goto out_release_acls; status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); out_release_acls: posix_acl_release(acl); posix_acl_release(default_acl); out: nfs3_free_createdata(data); dprintk("NFS reply mkdir: %d\n", status); return status; } static int nfs3_proc_rmdir(struct inode *dir, struct qstr *name) { struct nfs_fattr *dir_attr; struct nfs3_diropargs arg = { .fh = NFS_FH(dir), .name = name->name, .len = name->len }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_RMDIR], .rpc_argp = &arg, }; int status = -ENOMEM; dprintk("NFS call rmdir %s\n", name->name); dir_attr = nfs_alloc_fattr(); if (dir_attr == NULL) goto out; msg.rpc_resp = dir_attr; status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_post_op_update_inode(dir, dir_attr); nfs_free_fattr(dir_attr); out: dprintk("NFS reply rmdir: %d\n", status); return status; } /* * The READDIR implementation is somewhat hackish - we pass the user buffer * to the encode function, which installs it in the receive iovec. * The decode function itself doesn't perform any decoding, it just makes * sure the reply is syntactically correct. * * Also note that this implementation handles both plain readdir and * readdirplus. */ static int nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, u64 cookie, struct page **pages, unsigned int count, int plus) { struct inode *dir = dentry->d_inode; __be32 *verf = NFS_I(dir)->cookieverf; struct nfs3_readdirargs arg = { .fh = NFS_FH(dir), .cookie = cookie, .verf = {verf[0], verf[1]}, .plus = plus, .count = count, .pages = pages }; struct nfs3_readdirres res = { .verf = verf, .plus = plus }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_READDIR], .rpc_argp = &arg, .rpc_resp = &res, .rpc_cred = cred }; int status = -ENOMEM; if (plus) msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS]; dprintk("NFS call readdir%s %d\n", plus? "plus" : "", (unsigned int) cookie); res.dir_attr = nfs_alloc_fattr(); if (res.dir_attr == NULL) goto out; status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_invalidate_atime(dir); nfs_refresh_inode(dir, res.dir_attr); nfs_free_fattr(res.dir_attr); out: dprintk("NFS reply readdir%s: %d\n", plus? "plus" : "", status); return status; } static int nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, dev_t rdev) { struct posix_acl *default_acl, *acl; struct nfs3_createdata *data; int status = -ENOMEM; dprintk("NFS call mknod %pd %u:%u\n", dentry, MAJOR(rdev), MINOR(rdev)); data = nfs3_alloc_createdata(); if (data == NULL) goto out; status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); if (status) goto out; data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD]; data->arg.mknod.fh = NFS_FH(dir); data->arg.mknod.name = dentry->d_name.name; data->arg.mknod.len = dentry->d_name.len; data->arg.mknod.sattr = sattr; data->arg.mknod.rdev = rdev; switch (sattr->ia_mode & S_IFMT) { case S_IFBLK: data->arg.mknod.type = NF3BLK; break; case S_IFCHR: data->arg.mknod.type = NF3CHR; break; case S_IFIFO: data->arg.mknod.type = NF3FIFO; break; case S_IFSOCK: data->arg.mknod.type = NF3SOCK; break; default: status = -EINVAL; goto out; } status = nfs3_do_create(dir, dentry, data); if (status != 0) goto out_release_acls; status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); out_release_acls: posix_acl_release(acl); posix_acl_release(default_acl); out: nfs3_free_createdata(data); dprintk("NFS reply mknod: %d\n", status); return status; } static int nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsstat *stat) { struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_FSSTAT], .rpc_argp = fhandle, .rpc_resp = stat, }; int status; dprintk("NFS call fsstat\n"); nfs_fattr_init(stat->fattr); status = rpc_call_sync(server->client, &msg, 0); dprintk("NFS reply fsstat: %d\n", status); return status; } static int do_proc_fsinfo(struct rpc_clnt *client, struct nfs_fh *fhandle, struct nfs_fsinfo *info) { struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_FSINFO], .rpc_argp = fhandle, .rpc_resp = info, }; int status; dprintk("NFS call fsinfo\n"); nfs_fattr_init(info->fattr); status = rpc_call_sync(client, &msg, 0); dprintk("NFS reply fsinfo: %d\n", status); return status; } /* * Bare-bones access to fsinfo: this is for nfs_get_root/nfs_get_sb via * nfs_create_server */ static int nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info) { int status; status = do_proc_fsinfo(server->client, fhandle, info); if (status && server->nfs_client->cl_rpcclient != server->client) status = do_proc_fsinfo(server->nfs_client->cl_rpcclient, fhandle, info); return status; } static int nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_pathconf *info) { struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_PATHCONF], .rpc_argp = fhandle, .rpc_resp = info, }; int status; dprintk("NFS call pathconf\n"); nfs_fattr_init(info->fattr); status = rpc_call_sync(server->client, &msg, 0); dprintk("NFS reply pathconf: %d\n", status); return status; } static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) { struct inode *inode = hdr->inode; if (nfs3_async_handle_jukebox(task, inode)) return -EAGAIN; nfs_invalidate_atime(inode); nfs_refresh_inode(inode, &hdr->fattr); return 0; } static void nfs3_proc_read_setup(struct nfs_pgio_header *hdr, struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; } static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_header *hdr) { rpc_call_start(task); return 0; } static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr) { struct inode *inode = hdr->inode; if (nfs3_async_handle_jukebox(task, inode)) return -EAGAIN; if (task->tk_status >= 0) nfs_post_op_update_inode_force_wcc(inode, hdr->res.fattr); return 0; } static void nfs3_proc_write_setup(struct nfs_pgio_header *hdr, struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; } static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) { rpc_call_start(task); } static int nfs3_commit_done(struct rpc_task *task, struct nfs_commit_data *data) { if (nfs3_async_handle_jukebox(task, data->inode)) return -EAGAIN; nfs_refresh_inode(data->inode, data->res.fattr); return 0; } static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT]; } static int nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) { struct inode *inode = file_inode(filp); return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); } static int nfs3_have_delegation(struct inode *inode, fmode_t flags) { return 0; } static int nfs3_return_delegation(struct inode *inode) { nfs_wb_all(inode); return 0; } static const struct inode_operations nfs3_dir_inode_operations = { .create = nfs_create, .lookup = nfs_lookup, .link = nfs_link, .unlink = nfs_unlink, .symlink = nfs_symlink, .mkdir = nfs_mkdir, .rmdir = nfs_rmdir, .mknod = nfs_mknod, .rename = nfs_rename, .permission = nfs_permission, .getattr = nfs_getattr, .setattr = nfs_setattr, #ifdef CONFIG_NFS_V3_ACL .listxattr = nfs3_listxattr, .getxattr = generic_getxattr, .setxattr = generic_setxattr, .removexattr = generic_removexattr, .get_acl = nfs3_get_acl, .set_acl = nfs3_set_acl, #endif }; static const struct inode_operations nfs3_file_inode_operations = { .permission = nfs_permission, .getattr = nfs_getattr, .setattr = nfs_setattr, #ifdef CONFIG_NFS_V3_ACL .listxattr = nfs3_listxattr, .getxattr = generic_getxattr, .setxattr = generic_setxattr, .removexattr = generic_removexattr, .get_acl = nfs3_get_acl, .set_acl = nfs3_set_acl, #endif }; const struct nfs_rpc_ops nfs_v3_clientops = { .version = 3, /* protocol version */ .dentry_ops = &nfs_dentry_operations, .dir_inode_ops = &nfs3_dir_inode_operations, .file_inode_ops = &nfs3_file_inode_operations, .file_ops = &nfs_file_operations, .getroot = nfs3_proc_get_root, .submount = nfs_submount, .try_mount = nfs_try_mount, .getattr = nfs3_proc_getattr, .setattr = nfs3_proc_setattr, .lookup = nfs3_proc_lookup, .access = nfs3_proc_access, .readlink = nfs3_proc_readlink, .create = nfs3_proc_create, .remove = nfs3_proc_remove, .unlink_setup = nfs3_proc_unlink_setup, .unlink_rpc_prepare = nfs3_proc_unlink_rpc_prepare, .unlink_done = nfs3_proc_unlink_done, .rename_setup = nfs3_proc_rename_setup, .rename_rpc_prepare = nfs3_proc_rename_rpc_prepare, .rename_done = nfs3_proc_rename_done, .link = nfs3_proc_link, .symlink = nfs3_proc_symlink, .mkdir = nfs3_proc_mkdir, .rmdir = nfs3_proc_rmdir, .readdir = nfs3_proc_readdir, .mknod = nfs3_proc_mknod, .statfs = nfs3_proc_statfs, .fsinfo = nfs3_proc_fsinfo, .pathconf = nfs3_proc_pathconf, .decode_dirent = nfs3_decode_dirent, .pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare, .read_setup = nfs3_proc_read_setup, .read_done = nfs3_read_done, .write_setup = nfs3_proc_write_setup, .write_done = nfs3_write_done, .commit_setup = nfs3_proc_commit_setup, .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare, .commit_done = nfs3_commit_done, .lock = nfs3_proc_lock, .clear_acl_cache = forget_all_cached_acls, .close_context = nfs_close_context, .have_delegation = nfs3_have_delegation, .return_delegation = nfs3_return_delegation, .alloc_client = nfs_alloc_client, .init_client = nfs_init_client, .free_client = nfs_free_client, .create_server = nfs3_create_server, .clone_server = nfs3_clone_server, };
/* This file is part of tgl-library This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright Ben Wiederhake 2015 */ #include "../config.h" #ifdef TGL_AVOID_OPENSSL /* Fail-fast when something becomes deprecated. */ #define GCRYPT_NO_DEPRECATED #include <assert.h> #include <gcrypt.h> #include "bn.h" #include "meta.h" // There is no "_ctx" equivalent in gcrypt. TGLC_WRAPPER_ASSOC(bn_ctx,int) TGLC_WRAPPER_ASSOC(bn,struct gcry_mpi) TGLC_bn_ctx *TGLC_bn_ctx_new (void) { /* Must not be the null pointer, but must never be dereferenced. Assume that "1" is an invalid address. */ return ((void *)1); } void TGLC_bn_ctx_free (TGLC_bn_ctx* ctx) { (void) ctx; } TGLC_bn *TGLC_bn_new (void) { // TODO: Determine how many bits should be pre-allocated. TGLC_bn *ret = wrap_bn (gcry_mpi_new (2048)); assert (ret); return ret; } void TGLC_bn_free (TGLC_bn *a) { gcry_mpi_release (unwrap_bn (a)); } void TGLC_bn_clear_free (TGLC_bn *a) { /* This only protects against accidental use-after-free. I don't see the point of clearing, since we're not operating in protected memory AND the most crucial fields are never cleared anyway. */ gcry_mpi_set_ui (unwrap_bn (a), 0); gcry_mpi_release (unwrap_bn (a)); } int TGLC_bn_cmp (const TGLC_bn *a, const TGLC_bn *b) { return gcry_mpi_cmp (unwrap_bn (a), unwrap_bn (b)); } int TGLC_bn_is_prime (const TGLC_bn *a, int checks, void (*callback) (int, int, void *), TGLC_bn_ctx *ctx, void *cb_arg) { assert (0 == checks); assert (NULL == callback); (void) ctx; assert (NULL == cb_arg); /* Second argument is ignored. * No really, here's what libgcrypt's source does: * (void)flags; */ gcry_error_t err = gcry_prime_check (unwrap_bn (a), 0); /* This is nasty. In essence, gcry returns a bool whether it is NOT a prime. */ return !err; } int TGLC_bn_bn2bin (const TGLC_bn *a, unsigned char *to) { const unsigned long num_bytes = TGLC_bn_num_bytes (a); gcry_error_t gcry_error = gcry_mpi_print (GCRYMPI_FMT_USG, to, num_bytes, NULL, unwrap_bn (a)); assert (!gcry_error); return num_bytes; } TGLC_bn *TGLC_bn_bin2bn(const unsigned char *s, int len, TGLC_bn *ret) { gcry_mpi_t ret_ptr = NULL; gcry_error_t gcry_error = gcry_mpi_scan (&ret_ptr, GCRYMPI_FMT_USG, s, len, NULL); assert (!gcry_error); assert (ret_ptr); if (!ret) { return wrap_bn (ret_ptr); } gcry_mpi_snatch (unwrap_bn (ret), ret_ptr); return ret; } int TGLC_bn_set_word (TGLC_bn *a, unsigned long w) { assert (a); gcry_mpi_set_ui (unwrap_bn (a), w); return 1; } unsigned long TGLC_bn_get_word (const TGLC_bn *a) { const unsigned long num_bytes = TGLC_bn_num_bytes (a); assert (sizeof (unsigned long) >= num_bytes); unsigned char tmp[sizeof (unsigned long)]; memset (tmp, 0, sizeof (unsigned long)); TGLC_bn_bn2bin (a, tmp + sizeof (unsigned long) - num_bytes); /* Inefficient, but runs a total of three times per connection. */ /* TODO: Optimize? */ unsigned long ret = 0; unsigned int i; for (i = 0; i < sizeof (unsigned long); ++i) { ret <<= 8; ret |= tmp[i]; } return ret; } int TGLC_bn_num_bits (const TGLC_bn *a) { return gcry_mpi_get_nbits (unwrap_bn (a)); } void TGLC_bn_sub (TGLC_bn *r, const TGLC_bn *a, const TGLC_bn *b) { gcry_mpi_sub (unwrap_bn (r), unwrap_bn (a), unwrap_bn (b)); } int TGLC_bn_div (TGLC_bn *dv, TGLC_bn *rem, const TGLC_bn *a, const TGLC_bn *d, TGLC_bn_ctx *ctx) { (void) ctx; gcry_mpi_div (unwrap_bn (dv), unwrap_bn (rem), unwrap_bn (a), unwrap_bn (d), 0); return 1; } int TGLC_bn_mod_exp (TGLC_bn *r, const TGLC_bn *a, const TGLC_bn *p, const TGLC_bn *m, TGLC_bn_ctx *ctx) { (void) ctx; gcry_mpi_powm (unwrap_bn (r), unwrap_bn (a), unwrap_bn (p), unwrap_bn (m)); return 1; } #endif
# # Cookbook Name:: apache2 # Recipe:: authz_groupfile # # Copyright 2008-2013, Opscode, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # apache_module 'authz_groupfile'
package fix import ( "reflect" "testing" ) func TestFixerVirtualBoxRename_impl(t *testing.T) { var _ Fixer = new(FixerVirtualBoxRename) } func TestFixerVirtualBoxRename_Fix(t *testing.T) { cases := []struct { Input map[string]interface{} Expected map[string]interface{} }{ { Input: map[string]interface{}{ "type": "virtualbox", }, Expected: map[string]interface{}{ "type": "virtualbox-iso", }, }, } for _, tc := range cases { var f FixerVirtualBoxRename input := map[string]interface{}{ "builders": []map[string]interface{}{tc.Input}, } expected := map[string]interface{}{ "builders": []map[string]interface{}{tc.Expected}, } output, err := f.Fix(input) if err != nil { t.Fatalf("err: %s", err) } if !reflect.DeepEqual(output, expected) { t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected) } } } func TestFixerVirtualBoxRenameFix_provisionerOverride(t *testing.T) { cases := []struct { Input map[string]interface{} Expected map[string]interface{} }{ { Input: map[string]interface{}{ "provisioners": []interface{}{ map[string]interface{}{ "override": map[string]interface{}{ "virtualbox": map[string]interface{}{}, }, }, }, }, Expected: map[string]interface{}{ "provisioners": []interface{}{ map[string]interface{}{ "override": map[string]interface{}{ "virtualbox-iso": map[string]interface{}{}, }, }, }, }, }, } for _, tc := range cases { var f FixerVirtualBoxRename output, err := f.Fix(tc.Input) if err != nil { t.Fatalf("err: %s", err) } if !reflect.DeepEqual(output, tc.Expected) { t.Fatalf("unexpected:\n\n%#v\nexpected:\n\n%#v\n", output, tc.Expected) } } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>GLM: matrix_transform.hpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">GLM &#160;<span id="projectnumber">0.9.5</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File&#160;List</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_8ceffd4ee35c3518d4e8bdc7e638efe8.html">Users</a></li><li class="navelem"><a class="el" href="dir_968fb7988749a6351e7b3d0c1783dec4.html">Groove</a></li><li class="navelem"><a class="el" href="dir_6e418c18ca640a0404613de005739e2e.html">Documents</a></li><li class="navelem"><a class="el" href="dir_e3ecd7863bd215c92a17f47e2ae3be43.html">GitHub</a></li><li class="navelem"><a class="el" href="dir_edf753475b928be648c1cf1c6443cf63.html">glm</a></li><li class="navelem"><a class="el" href="dir_e50778361fd4ab4de52181ed9eb2b726.html">glm</a></li><li class="navelem"><a class="el" href="dir_f7324829a002c536307b42a892c06451.html">gtc</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">matrix_transform.hpp</div> </div> </div><!--header--> <div class="contents"> <a href="a00080.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;</div> <div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<span class="preprocessor">#ifndef GLM_GTC_matrix_transform</span></div> <div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define GLM_GTC_matrix_transform</span></div> <div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;<span class="preprocessor"></span></div> <div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160;<span class="comment">// Dependency:</span></div> <div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;<span class="preprocessor">#include &quot;../mat4x4.hpp&quot;</span></div> <div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160;<span class="preprocessor">#include &quot;../vec2.hpp&quot;</span></div> <div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="preprocessor">#include &quot;../vec3.hpp&quot;</span></div> <div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;<span class="preprocessor">#include &quot;../vec4.hpp&quot;</span></div> <div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;</div> <div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;<span class="preprocessor">#if(defined(GLM_MESSAGES) &amp;&amp; !defined(GLM_EXT_INCLUDED))</span></div> <div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor"></span><span class="preprocessor"># pragma message(&quot;GLM: GLM_GTC_matrix_transform extension included&quot;)</span></div> <div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div> <div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;<span class="preprocessor"></span></div> <div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;<span class="keyword">namespace </span>glm</div> <div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;{</div> <div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160;</div> <div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga1501de0fa580dcc491b67e0685bbc7c2">translate</a>(</div> <div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; m,</div> <div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; v);</div> <div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; </div> <div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga61e65a3bb227c267d1a15113d1056fb1">rotate</a>(</div> <div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; m,</div> <div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; T <span class="keyword">const</span> &amp; <a class="code" href="a00179.html#ga23a3fc7ada5bbb665ff84c92c6e0542c">angle</a>,</div> <div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; <a class="code" href="a00179.html#ga8eef9f8c3f2e4836dccf09df975b20fb">axis</a>);</div> <div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160;</div> <div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#gabd40959f269abd16c256a4f59ab03d62">scale</a>(</div> <div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; m,</div> <div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; v);</div> <div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160;</div> <div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div> <div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, defaultp&gt; <a class="code" href="a00176.html#gac393e9262776e4980731c386123e4377">ortho</a>(</div> <div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; T <span class="keyword">const</span> &amp; left,</div> <div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; T <span class="keyword">const</span> &amp; right,</div> <div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; T <span class="keyword">const</span> &amp; bottom,</div> <div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; T <span class="keyword">const</span> &amp; top,</div> <div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; T <span class="keyword">const</span> &amp; zNear,</div> <div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; T <span class="keyword">const</span> &amp; zFar);</div> <div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160;</div> <div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div> <div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, defaultp&gt; <a class="code" href="a00176.html#gac393e9262776e4980731c386123e4377">ortho</a>(</div> <div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160; T <span class="keyword">const</span> &amp; left,</div> <div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; T <span class="keyword">const</span> &amp; right,</div> <div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; T <span class="keyword">const</span> &amp; bottom,</div> <div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; T <span class="keyword">const</span> &amp; top);</div> <div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160;</div> <div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga4e1138c8a4bcc3bbbb40090d8441b0a5">frustum</a>(</div> <div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; T <span class="keyword">const</span> &amp; left,</div> <div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; T <span class="keyword">const</span> &amp; right,</div> <div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; T <span class="keyword">const</span> &amp; bottom,</div> <div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; T <span class="keyword">const</span> &amp; top,</div> <div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; T <span class="keyword">const</span> &amp; near,</div> <div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; T <span class="keyword">const</span> &amp; far);</div> <div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160;</div> <div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga24983212d8d25b5b32e30d574dfccd1c">perspective</a>(</div> <div class="line"><a name="l00186"></a><span class="lineno"> 186</span>&#160; T <span class="keyword">const</span> &amp; fovy,</div> <div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160; T <span class="keyword">const</span> &amp; aspect,</div> <div class="line"><a name="l00188"></a><span class="lineno"> 188</span>&#160; T <span class="keyword">const</span> &amp; near,</div> <div class="line"><a name="l00189"></a><span class="lineno"> 189</span>&#160; T <span class="keyword">const</span> &amp; far);</div> <div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160;</div> <div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga7e820c9c692e28041be6d7c7042e4e4a">perspectiveFov</a>(</div> <div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; T <span class="keyword">const</span> &amp; fov,</div> <div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; T <span class="keyword">const</span> &amp; width,</div> <div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; T <span class="keyword">const</span> &amp; height,</div> <div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; T <span class="keyword">const</span> &amp; near,</div> <div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; T <span class="keyword">const</span> &amp; far);</div> <div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160;</div> <div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga7e5b5501b0113d0ed76ba4e3a8e5523c">infinitePerspective</a>(</div> <div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; T fovy, T aspect, T near);</div> <div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160;</div> <div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga460dc59dd0debb5113f4a118251bff61">tweakedInfinitePerspective</a>(</div> <div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; T fovy, T aspect, T near);</div> <div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160;</div> <div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U, precision P&gt;</div> <div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; GLM_FUNC_DECL detail::tvec3&lt;T, P&gt; <a class="code" href="a00176.html#ga41227b7b98882dcbaa8dab52df372c7b">project</a>(</div> <div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; obj,</div> <div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; model,</div> <div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; <a class="code" href="a00221.html#ga08294223071a96e777de7033cc708439">proj</a>,</div> <div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; detail::tvec4&lt;U, P&gt; <span class="keyword">const</span> &amp; viewport);</div> <div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160;</div> <div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U, precision P&gt;</div> <div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; GLM_FUNC_DECL detail::tvec3&lt;T, P&gt; <a class="code" href="a00176.html#ga4b0a9086d15e2a743ecd7b6128146af1">unProject</a>(</div> <div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; win,</div> <div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; model,</div> <div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; detail::tmat4x4&lt;T, P&gt; <span class="keyword">const</span> &amp; <a class="code" href="a00221.html#ga08294223071a96e777de7033cc708439">proj</a>,</div> <div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; detail::tvec4&lt;U, P&gt; <span class="keyword">const</span> &amp; viewport);</div> <div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160;</div> <div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P, <span class="keyword">typename</span> U&gt;</div> <div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga0fb64f04bf5ad52523fcd4b10b46aff6">pickMatrix</a>(</div> <div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; detail::tvec2&lt;T, P&gt; <span class="keyword">const</span> &amp; center,</div> <div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160; detail::tvec2&lt;T, P&gt; <span class="keyword">const</span> &amp; delta,</div> <div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; detail::tvec4&lt;U, P&gt; <span class="keyword">const</span> &amp; viewport);</div> <div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160;</div> <div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, precision P&gt;</div> <div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; GLM_FUNC_DECL detail::tmat4x4&lt;T, P&gt; <a class="code" href="a00176.html#ga454fdf3163c2779eeeeeb9d75907ce97">lookAt</a>(</div> <div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; eye,</div> <div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; center,</div> <div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160; detail::tvec3&lt;T, P&gt; <span class="keyword">const</span> &amp; up);</div> <div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160;</div> <div class="line"><a name="l00290"></a><span class="lineno"> 290</span>&#160;}<span class="comment">//namespace glm</span></div> <div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160;</div> <div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160;<span class="preprocessor">#include &quot;matrix_transform.inl&quot;</span></div> <div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160;</div> <div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160;<span class="preprocessor">#endif//GLM_GTC_matrix_transform</span></div> <div class="ttc" id="a00176_html_ga61e65a3bb227c267d1a15113d1056fb1"><div class="ttname"><a href="a00176.html#ga61e65a3bb227c267d1a15113d1056fb1">glm::rotate</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; rotate(detail::tmat4x4&lt; T, P &gt; const &amp;m, T const &amp;angle, detail::tvec3&lt; T, P &gt; const &amp;axis)</div><div class="ttdoc">Builds a rotation 4 * 4 matrix created from an axis vector and an angle. </div></div> <div class="ttc" id="a00221_html_ga08294223071a96e777de7033cc708439"><div class="ttname"><a href="a00221.html#ga08294223071a96e777de7033cc708439">glm::proj</a></div><div class="ttdeci">vecType proj(vecType const &amp;x, vecType const &amp;Normal)</div><div class="ttdoc">Projects x on Normal. </div></div> <div class="ttc" id="a00179_html_ga23a3fc7ada5bbb665ff84c92c6e0542c"><div class="ttname"><a href="a00179.html#ga23a3fc7ada5bbb665ff84c92c6e0542c">glm::angle</a></div><div class="ttdeci">GLM_FUNC_DECL T angle(detail::tquat&lt; T, P &gt; const &amp;x)</div><div class="ttdoc">Returns the quaternion rotation angle. </div></div> <div class="ttc" id="a00176_html_gabd40959f269abd16c256a4f59ab03d62"><div class="ttname"><a href="a00176.html#gabd40959f269abd16c256a4f59ab03d62">glm::scale</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; scale(detail::tmat4x4&lt; T, P &gt; const &amp;m, detail::tvec3&lt; T, P &gt; const &amp;v)</div><div class="ttdoc">Builds a scale 4 * 4 matrix created from 3 scalars. </div></div> <div class="ttc" id="a00176_html_ga460dc59dd0debb5113f4a118251bff61"><div class="ttname"><a href="a00176.html#ga460dc59dd0debb5113f4a118251bff61">glm::tweakedInfinitePerspective</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; tweakedInfinitePerspective(T fovy, T aspect, T near)</div><div class="ttdoc">Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics har...</div></div> <div class="ttc" id="a00176_html_ga1501de0fa580dcc491b67e0685bbc7c2"><div class="ttname"><a href="a00176.html#ga1501de0fa580dcc491b67e0685bbc7c2">glm::translate</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; translate(detail::tmat4x4&lt; T, P &gt; const &amp;m, detail::tvec3&lt; T, P &gt; const &amp;v)</div><div class="ttdoc">Builds a translation 4 * 4 matrix created from a vector of 3 components. </div></div> <div class="ttc" id="a00176_html_ga24983212d8d25b5b32e30d574dfccd1c"><div class="ttname"><a href="a00176.html#ga24983212d8d25b5b32e30d574dfccd1c">glm::perspective</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; perspective(T const &amp;fovy, T const &amp;aspect, T const &amp;near, T const &amp;far)</div><div class="ttdoc">Creates a matrix for a symetric perspective-view frustum. </div></div> <div class="ttc" id="a00176_html_ga0fb64f04bf5ad52523fcd4b10b46aff6"><div class="ttname"><a href="a00176.html#ga0fb64f04bf5ad52523fcd4b10b46aff6">glm::pickMatrix</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; pickMatrix(detail::tvec2&lt; T, P &gt; const &amp;center, detail::tvec2&lt; T, P &gt; const &amp;delta, detail::tvec4&lt; U, P &gt; const &amp;viewport)</div><div class="ttdoc">Define a picking region. </div></div> <div class="ttc" id="a00176_html_ga7e5b5501b0113d0ed76ba4e3a8e5523c"><div class="ttname"><a href="a00176.html#ga7e5b5501b0113d0ed76ba4e3a8e5523c">glm::infinitePerspective</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; infinitePerspective(T fovy, T aspect, T near)</div><div class="ttdoc">Creates a matrix for a symmetric perspective-view frustum with far plane at infinite. </div></div> <div class="ttc" id="a00176_html_gac393e9262776e4980731c386123e4377"><div class="ttname"><a href="a00176.html#gac393e9262776e4980731c386123e4377">glm::ortho</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, defaultp &gt; ortho(T const &amp;left, T const &amp;right, T const &amp;bottom, T const &amp;top, T const &amp;zNear, T const &amp;zFar)</div><div class="ttdoc">Creates a matrix for an orthographic parallel viewing volume. </div></div> <div class="ttc" id="a00179_html_ga8eef9f8c3f2e4836dccf09df975b20fb"><div class="ttname"><a href="a00179.html#ga8eef9f8c3f2e4836dccf09df975b20fb">glm::axis</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tvec3&lt; T, P &gt; axis(detail::tquat&lt; T, P &gt; const &amp;x)</div><div class="ttdoc">Returns the q rotation axis. </div></div> <div class="ttc" id="a00176_html_ga4b0a9086d15e2a743ecd7b6128146af1"><div class="ttname"><a href="a00176.html#ga4b0a9086d15e2a743ecd7b6128146af1">glm::unProject</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tvec3&lt; T, P &gt; unProject(detail::tvec3&lt; T, P &gt; const &amp;win, detail::tmat4x4&lt; T, P &gt; const &amp;model, detail::tmat4x4&lt; T, P &gt; const &amp;proj, detail::tvec4&lt; U, P &gt; const &amp;viewport)</div><div class="ttdoc">Map the specified window coordinates (win.x, win.y, win.z) into object coordinates. </div></div> <div class="ttc" id="a00176_html_ga7e820c9c692e28041be6d7c7042e4e4a"><div class="ttname"><a href="a00176.html#ga7e820c9c692e28041be6d7c7042e4e4a">glm::perspectiveFov</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; perspectiveFov(T const &amp;fov, T const &amp;width, T const &amp;height, T const &amp;near, T const &amp;far)</div><div class="ttdoc">Builds a perspective projection matrix based on a field of view. </div></div> <div class="ttc" id="a00176_html_ga454fdf3163c2779eeeeeb9d75907ce97"><div class="ttname"><a href="a00176.html#ga454fdf3163c2779eeeeeb9d75907ce97">glm::lookAt</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; lookAt(detail::tvec3&lt; T, P &gt; const &amp;eye, detail::tvec3&lt; T, P &gt; const &amp;center, detail::tvec3&lt; T, P &gt; const &amp;up)</div><div class="ttdoc">Build a look at view matrix. </div></div> <div class="ttc" id="a00176_html_ga4e1138c8a4bcc3bbbb40090d8441b0a5"><div class="ttname"><a href="a00176.html#ga4e1138c8a4bcc3bbbb40090d8441b0a5">glm::frustum</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tmat4x4&lt; T, P &gt; frustum(T const &amp;left, T const &amp;right, T const &amp;bottom, T const &amp;top, T const &amp;near, T const &amp;far)</div><div class="ttdoc">Creates a frustum matrix. </div></div> <div class="ttc" id="a00176_html_ga41227b7b98882dcbaa8dab52df372c7b"><div class="ttname"><a href="a00176.html#ga41227b7b98882dcbaa8dab52df372c7b">glm::project</a></div><div class="ttdeci">GLM_FUNC_DECL detail::tvec3&lt; T, P &gt; project(detail::tvec3&lt; T, P &gt; const &amp;obj, detail::tmat4x4&lt; T, P &gt; const &amp;model, detail::tmat4x4&lt; T, P &gt; const &amp;proj, detail::tvec4&lt; U, P &gt; const &amp;viewport)</div><div class="ttdoc">Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates. </div></div> </div><!-- fragment --></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.5 </small></address> </body> </html>
/* TabularData.java -- Tables of composite data structures. Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.management.openmbean; import java.util.Collection; import java.util.Set; /** * Provides an interface to a specific type of composite * data structure, where keys (the columns) map to the * {@link CompositeData} objects that form the rows of * the table. * * @author Andrew John Hughes (gnu_andrew@member.fsf.org) * @since 1.5 */ public interface TabularData { /** * Calculates the index the specified {@link CompositeData} value * would have, if it was to be added to this {@link TabularData} * instance. This method includes a check that the type of the * given value is the same as the row type of this instance, but not * a check for existing instances of the given value. The value * must also not be <code>null</code>. Possible indices are * returned by the {@link TabularType#getIndexNames()} method of * this instance's tabular type. The returned indices are the * values of the fields in the supplied {@link CompositeData} * instance that match the names given in the {@link TabularType}. * * @param val the {@link CompositeData} value whose index should * be calculated. * @return the index the value would take on, if it were to be added. * @throws NullPointerException if the value is <code>null</code>. * @throws InvalidOpenTypeException if the value does not match the * row type of this instance. */ Object[] calculateIndex(CompositeData val); /** * Removes all {@link CompositeData} values from the table. */ void clear(); /** * Returns true iff this instance of the {@link TabularData} class * contains a {@link CompositeData} value at the specified index. * In any other circumstance, including if the given key * is <code>null</code> or of the incorrect type, according to * the {@link TabularType} of this instance, this method returns * false. * * @param key the key to test for. * @return true if the key maps to a {@link CompositeData} value. */ boolean containsKey(Object[] key); /** * Returns true iff this instance of the {@link TabularData} class * contains the specified {@link CompositeData} value. * In any other circumstance, including if the given value * is <code>null</code> or of the incorrect type, according to * the {@link TabularType} of this instance, this method returns * false. * * @param val the value to test for. * @return true if the value exists. */ boolean containsValue(CompositeData val); /** * Compares the specified object with this object for equality. * The object is judged equivalent if it is non-null, and also * an instance of {@link TabularData} with the same row type, * and {@link CompositeData} values. The two compared instances may * be equivalent even if they represent different implementations * of {@link TabularData}. * * @param obj the object to compare for equality. * @return true if <code>obj</code> is equal to <code>this</code>. */ boolean equals(Object obj); /** * Retrieves the {@link CompositeData} value for the specified * key, or <code>null</code> if no such mapping exists. * * @param key the key whose value should be returned. * @return the matching {@link CompositeData} value, or * <code>null</code> if one does not exist. * @throws NullPointerException if the key is <code>null</code>. * @throws InvalidKeyException if the key does not match * the {@link TabularType} of this * instance. */ CompositeData get(Object[] key); /** * Returns the tabular type which corresponds to this instance * of {@link TabularData}. * * @return the tabular type for this instance. */ TabularType getTabularType(); /** * Returns the hash code of the composite data type. This is * computed as the sum of the hash codes of each value, together * with the hash code of the tabular type. These are the same * elements of the type that are compared as part of the {@link * #equals(java.lang.Object)} method, thus ensuring that the * hashcode is compatible with the equality test. * * @return the hash code of this instance. */ int hashCode(); /** * Returns true if this {@link TabularData} instance * contains no {@link CompositeData} values. * * @return true if the instance is devoid of rows. */ boolean isEmpty(); /** * Returns a {@link java.util.Set} view of the keys or * indices of this {@link TabularData} instance. * * @return a set containing the keys of this instance. */ Set<?> keySet(); /** * Adds the specified {@link CompositeData} value to the * table. The value must be non-null, of the same type * as the row type of this instance, and must not have * the same index as an existing value. The index is * calculated using the index names of the * {@link TabularType} for this instance. * * @param val the {@link CompositeData} value to add. * @throws NullPointerException if <code>val</code> is * <code>null</code>. * @throws InvalidOpenTypeException if the type of the * given value does not * match the row type. * @throws KeyAlreadyExistsException if the value has the * same calculated index * as an existing value. */ void put(CompositeData val); /** * Adds each of the specified {@link CompositeData} values * to the table. Each element of the array must meet the * conditions given for the {@link #put(CompositeData)} * method. In addition, the index of each value in the * array must be distinct from the index of the other * values in the array, as well as from the existing values * in the table. The operation should be atomic; if one * value can not be added, then none of the values should * be. If the array is <code>null</code> or empty, the * method simply returns. * * @param vals the {@link CompositeData} values to add. * @throws NullPointerException if a value from the array is * <code>null</code>. * @throws InvalidOpenTypeException if the type of a * given value does not * match the row type. * @throws KeyAlreadyExistsException if a value has the * same calculated index * as an existing value or * of one of the other * specified values. */ void putAll(CompositeData[] vals); /** * Removes the {@link CompositeData} value located at the * specified index. <code>null</code> is returned if the * value does not exist. Otherwise, the removed value is * returned. * * @param key the key of the value to remove. * @return the removed value, or <code>null</code> if * there is no value for the given key. * @throws NullPointerException if the key is <code>null</code>. * @throws InvalidOpenTypeException if the key does not match * the {@link TabularType} of this * instance. */ CompositeData remove(Object[] key); /** * Returns the number of {@link CompositeData} values or rows * in the table. * * @return the number of rows in the table. */ int size(); /** * Returns a textual representation of this instance. The * exact format is left up to the implementation, but it * should contain the name of the implementing class and * the tabular type. * * @return a {@link java.lang.String} representation of the * object. */ String toString(); /** * Returns the values associated with this instance. * * @return the values of this instance. */ Collection<?> values(); }
/* * linux/fs/ext4/ioctl.c * * Copyright (C) 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) */ #include <linux/fs.h> #include <linux/jbd2.h> #include <linux/capability.h> #include <linux/time.h> #include <linux/compat.h> #include <linux/mount.h> #include <linux/file.h> #include <asm/uaccess.h> #include "ext4_jbd2.h" #include "ext4.h" #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1) /** * Swap memory between @a and @b for @len bytes. * * @a: pointer to first memory area * @b: pointer to second memory area * @len: number of bytes to swap * */ static void memswap(void *a, void *b, size_t len) { unsigned char *ap, *bp; unsigned char tmp; ap = (unsigned char *)a; bp = (unsigned char *)b; while (len-- > 0) { tmp = *ap; *ap = *bp; *bp = tmp; ap++; bp++; } } /** * Swap i_data and associated attributes between @inode1 and @inode2. * This function is used for the primary swap between inode1 and inode2 * and also to revert this primary swap in case of errors. * * Therefore you have to make sure, that calling this method twice * will revert all changes. * * @inode1: pointer to first inode * @inode2: pointer to second inode */ static void swap_inode_data(struct inode *inode1, struct inode *inode2) { loff_t isize; struct ext4_inode_info *ei1; struct ext4_inode_info *ei2; ei1 = EXT4_I(inode1); ei2 = EXT4_I(inode2); memswap(&inode1->i_flags, &inode2->i_flags, sizeof(inode1->i_flags)); memswap(&inode1->i_version, &inode2->i_version, sizeof(inode1->i_version)); memswap(&inode1->i_blocks, &inode2->i_blocks, sizeof(inode1->i_blocks)); memswap(&inode1->i_bytes, &inode2->i_bytes, sizeof(inode1->i_bytes)); memswap(&inode1->i_atime, &inode2->i_atime, sizeof(inode1->i_atime)); memswap(&inode1->i_mtime, &inode2->i_mtime, sizeof(inode1->i_mtime)); memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data)); memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags)); memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize)); ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS); ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS); ext4_es_lru_del(inode1); ext4_es_lru_del(inode2); isize = i_size_read(inode1); i_size_write(inode1, i_size_read(inode2)); i_size_write(inode2, isize); } /** * Swap the information from the given @inode and the inode * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other * important fields of the inodes. * * @sb: the super block of the filesystem * @inode: the inode to swap with EXT4_BOOT_LOADER_INO * */ static long swap_inode_boot_loader(struct super_block *sb, struct inode *inode) { handle_t *handle; int err; struct inode *inode_bl; struct ext4_inode_info *ei_bl; struct ext4_sb_info *sbi = EXT4_SB(sb); if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) return -EINVAL; if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) return -EPERM; inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO); if (IS_ERR(inode_bl)) return PTR_ERR(inode_bl); ei_bl = EXT4_I(inode_bl); filemap_flush(inode->i_mapping); filemap_flush(inode_bl->i_mapping); /* Protect orig inodes against a truncate and make sure, * that only 1 swap_inode_boot_loader is running. */ lock_two_nondirectories(inode, inode_bl); truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode_bl->i_data, 0); /* Wait for all existing dio workers */ ext4_inode_block_unlocked_dio(inode); ext4_inode_block_unlocked_dio(inode_bl); inode_dio_wait(inode); inode_dio_wait(inode_bl); handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2); if (IS_ERR(handle)) { err = -EINVAL; goto journal_err_out; } /* Protect extent tree against block allocations via delalloc */ ext4_double_down_write_data_sem(inode, inode_bl); if (inode_bl->i_nlink == 0) { /* this inode has never been used as a BOOT_LOADER */ set_nlink(inode_bl, 1); i_uid_write(inode_bl, 0); i_gid_write(inode_bl, 0); inode_bl->i_flags = 0; ei_bl->i_flags = 0; inode_bl->i_version = 1; i_size_write(inode_bl, 0); inode_bl->i_mode = S_IFREG; if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) { ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS); ext4_ext_tree_init(handle, inode_bl); } else memset(ei_bl->i_data, 0, sizeof(ei_bl->i_data)); } swap_inode_data(inode, inode_bl); inode->i_ctime = inode_bl->i_ctime = ext4_current_time(inode); spin_lock(&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++; inode_bl->i_generation = sbi->s_next_generation++; spin_unlock(&sbi->s_next_gen_lock); ext4_discard_preallocations(inode); err = ext4_mark_inode_dirty(handle, inode); if (err < 0) { ext4_warning(inode->i_sb, "couldn't mark inode #%lu dirty (err %d)", inode->i_ino, err); /* Revert all changes: */ swap_inode_data(inode, inode_bl); } else { err = ext4_mark_inode_dirty(handle, inode_bl); if (err < 0) { ext4_warning(inode_bl->i_sb, "couldn't mark inode #%lu dirty (err %d)", inode_bl->i_ino, err); /* Revert all changes: */ swap_inode_data(inode, inode_bl); ext4_mark_inode_dirty(handle, inode); } } ext4_journal_stop(handle); ext4_double_up_write_data_sem(inode, inode_bl); journal_err_out: ext4_inode_resume_unlocked_dio(inode); ext4_inode_resume_unlocked_dio(inode_bl); unlock_two_nondirectories(inode, inode_bl); iput(inode_bl); return err; } long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct inode *inode = file_inode(filp); struct super_block *sb = inode->i_sb; struct ext4_inode_info *ei = EXT4_I(inode); unsigned int flags; ext4_debug("cmd = %u, arg = %lu\n", cmd, arg); switch (cmd) { case EXT4_IOC_GETFLAGS: ext4_get_inode_flags(ei); flags = ei->i_flags & EXT4_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT4_IOC_SETFLAGS: { handle_t *handle = NULL; int err, migrate = 0; struct ext4_iloc iloc; unsigned int oldflags, mask, i; unsigned int jflag; if (!inode_owner_or_capable(inode)) return -EACCES; if (get_user(flags, (int __user *) arg)) return -EFAULT; err = mnt_want_write_file(filp); if (err) return err; flags = ext4_mask_flags(inode->i_mode, flags); err = -EPERM; mutex_lock(&inode->i_mutex); /* Is it quota file? Do not allow user to mess with it */ if (IS_NOQUOTA(inode)) goto flags_out; oldflags = ei->i_flags; /* The JOURNAL_DATA flag is modifiable only by root */ jflag = flags & EXT4_JOURNAL_DATA_FL; /* * The IMMUTABLE and APPEND_ONLY flags can only be changed by * the relevant capability. * * This test looks nicer. Thanks to Pauline Middelink */ if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) { if (!capable(CAP_LINUX_IMMUTABLE)) goto flags_out; } /* * The JOURNAL_DATA flag can only be changed by * the relevant capability. */ if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { if (!capable(CAP_SYS_RESOURCE)) goto flags_out; } if ((flags ^ oldflags) & EXT4_EXTENTS_FL) migrate = 1; if (flags & EXT4_EOFBLOCKS_FL) { /* we don't support adding EOFBLOCKS flag */ if (!(oldflags & EXT4_EOFBLOCKS_FL)) { err = -EOPNOTSUPP; goto flags_out; } } else if (oldflags & EXT4_EOFBLOCKS_FL) ext4_truncate(inode); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); if (IS_ERR(handle)) { err = PTR_ERR(handle); goto flags_out; } if (IS_SYNC(inode)) ext4_handle_sync(handle); err = ext4_reserve_inode_write(handle, inode, &iloc); if (err) goto flags_err; for (i = 0, mask = 1; i < 32; i++, mask <<= 1) { if (!(mask & EXT4_FL_USER_MODIFIABLE)) continue; if (mask & flags) ext4_set_inode_flag(inode, i); else ext4_clear_inode_flag(inode, i); } ext4_set_inode_flags(inode); inode->i_ctime = ext4_current_time(inode); err = ext4_mark_iloc_dirty(handle, inode, &iloc); flags_err: ext4_journal_stop(handle); if (err) goto flags_out; if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) err = ext4_change_inode_journal_flag(inode, jflag); if (err) goto flags_out; if (migrate) { if (flags & EXT4_EXTENTS_FL) err = ext4_ext_migrate(inode); else err = ext4_ind_migrate(inode); } flags_out: mutex_unlock(&inode->i_mutex); mnt_drop_write_file(filp); return err; } case EXT4_IOC_GETVERSION: case EXT4_IOC_GETVERSION_OLD: return put_user(inode->i_generation, (int __user *) arg); case EXT4_IOC_SETVERSION: case EXT4_IOC_SETVERSION_OLD: { handle_t *handle; struct ext4_iloc iloc; __u32 generation; int err; if (!inode_owner_or_capable(inode)) return -EPERM; if (ext4_has_metadata_csum(inode->i_sb)) { ext4_warning(sb, "Setting inode version is not " "supported with metadata_csum enabled."); return -ENOTTY; } err = mnt_want_write_file(filp); if (err) return err; if (get_user(generation, (int __user *) arg)) { err = -EFAULT; goto setversion_out; } mutex_lock(&inode->i_mutex); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); if (IS_ERR(handle)) { err = PTR_ERR(handle); goto unlock_out; } err = ext4_reserve_inode_write(handle, inode, &iloc); if (err == 0) { inode->i_ctime = ext4_current_time(inode); inode->i_generation = generation; err = ext4_mark_iloc_dirty(handle, inode, &iloc); } ext4_journal_stop(handle); unlock_out: mutex_unlock(&inode->i_mutex); setversion_out: mnt_drop_write_file(filp); return err; } case EXT4_IOC_GROUP_EXTEND: { ext4_fsblk_t n_blocks_count; int err, err2=0; err = ext4_resize_begin(sb); if (err) return err; if (get_user(n_blocks_count, (__u32 __user *)arg)) { err = -EFAULT; goto group_extend_out; } if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { ext4_msg(sb, KERN_ERR, "Online resizing not supported with bigalloc"); err = -EOPNOTSUPP; goto group_extend_out; } err = mnt_want_write_file(filp); if (err) goto group_extend_out; err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count); if (EXT4_SB(sb)->s_journal) { jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); } if (err == 0) err = err2; mnt_drop_write_file(filp); group_extend_out: ext4_resize_end(sb); return err; } case EXT4_IOC_MOVE_EXT: { struct move_extent me; struct fd donor; int err; if (!(filp->f_mode & FMODE_READ) || !(filp->f_mode & FMODE_WRITE)) return -EBADF; if (copy_from_user(&me, (struct move_extent __user *)arg, sizeof(me))) return -EFAULT; me.moved_len = 0; donor = fdget(me.donor_fd); if (!donor.file) return -EBADF; if (!(donor.file->f_mode & FMODE_WRITE)) { err = -EBADF; goto mext_out; } if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { ext4_msg(sb, KERN_ERR, "Online defrag not supported with bigalloc"); err = -EOPNOTSUPP; goto mext_out; } err = mnt_want_write_file(filp); if (err) goto mext_out; err = ext4_move_extents(filp, donor.file, me.orig_start, me.donor_start, me.len, &me.moved_len); mnt_drop_write_file(filp); if (copy_to_user((struct move_extent __user *)arg, &me, sizeof(me))) err = -EFAULT; mext_out: fdput(donor); return err; } case EXT4_IOC_GROUP_ADD: { struct ext4_new_group_data input; int err, err2=0; err = ext4_resize_begin(sb); if (err) return err; if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, sizeof(input))) { err = -EFAULT; goto group_add_out; } if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { ext4_msg(sb, KERN_ERR, "Online resizing not supported with bigalloc"); err = -EOPNOTSUPP; goto group_add_out; } err = mnt_want_write_file(filp); if (err) goto group_add_out; err = ext4_group_add(sb, &input); if (EXT4_SB(sb)->s_journal) { jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); } if (err == 0) err = err2; mnt_drop_write_file(filp); if (!err && ext4_has_group_desc_csum(sb) && test_opt(sb, INIT_INODE_TABLE)) err = ext4_register_li_request(sb, input.group); group_add_out: ext4_resize_end(sb); return err; } case EXT4_IOC_MIGRATE: { int err; if (!inode_owner_or_capable(inode)) return -EACCES; err = mnt_want_write_file(filp); if (err) return err; /* * inode_mutex prevent write and truncate on the file. * Read still goes through. We take i_data_sem in * ext4_ext_swap_inode_data before we switch the * inode format to prevent read. */ mutex_lock(&(inode->i_mutex)); err = ext4_ext_migrate(inode); mutex_unlock(&(inode->i_mutex)); mnt_drop_write_file(filp); return err; } case EXT4_IOC_ALLOC_DA_BLKS: { int err; if (!inode_owner_or_capable(inode)) return -EACCES; err = mnt_want_write_file(filp); if (err) return err; err = ext4_alloc_da_blocks(inode); mnt_drop_write_file(filp); return err; } case EXT4_IOC_SWAP_BOOT: { int err; if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; err = mnt_want_write_file(filp); if (err) return err; err = swap_inode_boot_loader(sb, inode); mnt_drop_write_file(filp); return err; } case EXT4_IOC_RESIZE_FS: { ext4_fsblk_t n_blocks_count; int err = 0, err2 = 0; ext4_group_t o_group = EXT4_SB(sb)->s_groups_count; if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { ext4_msg(sb, KERN_ERR, "Online resizing not (yet) supported with bigalloc"); return -EOPNOTSUPP; } if (copy_from_user(&n_blocks_count, (__u64 __user *)arg, sizeof(__u64))) { return -EFAULT; } err = ext4_resize_begin(sb); if (err) return err; err = mnt_want_write_file(filp); if (err) goto resizefs_out; err = ext4_resize_fs(sb, n_blocks_count); if (EXT4_SB(sb)->s_journal) { jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); } if (err == 0) err = err2; mnt_drop_write_file(filp); if (!err && (o_group > EXT4_SB(sb)->s_groups_count) && ext4_has_group_desc_csum(sb) && test_opt(sb, INIT_INODE_TABLE)) err = ext4_register_li_request(sb, o_group); resizefs_out: ext4_resize_end(sb); return err; } case FITRIM: { struct request_queue *q = bdev_get_queue(sb->s_bdev); struct fstrim_range range; int ret = 0; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (!blk_queue_discard(q)) return -EOPNOTSUPP; if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) return -EFAULT; range.minlen = max((unsigned int)range.minlen, q->limits.discard_granularity); ret = ext4_trim_fs(sb, &range); if (ret < 0) return ret; if (copy_to_user((struct fstrim_range __user *)arg, &range, sizeof(range))) return -EFAULT; return 0; } case EXT4_IOC_PRECACHE_EXTENTS: return ext4_ext_precache(inode); default: return -ENOTTY; } } #ifdef CONFIG_COMPAT long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { /* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) { case EXT4_IOC32_GETFLAGS: cmd = EXT4_IOC_GETFLAGS; break; case EXT4_IOC32_SETFLAGS: cmd = EXT4_IOC_SETFLAGS; break; case EXT4_IOC32_GETVERSION: cmd = EXT4_IOC_GETVERSION; break; case EXT4_IOC32_SETVERSION: cmd = EXT4_IOC_SETVERSION; break; case EXT4_IOC32_GROUP_EXTEND: cmd = EXT4_IOC_GROUP_EXTEND; break; case EXT4_IOC32_GETVERSION_OLD: cmd = EXT4_IOC_GETVERSION_OLD; break; case EXT4_IOC32_SETVERSION_OLD: cmd = EXT4_IOC_SETVERSION_OLD; break; case EXT4_IOC32_GETRSVSZ: cmd = EXT4_IOC_GETRSVSZ; break; case EXT4_IOC32_SETRSVSZ: cmd = EXT4_IOC_SETRSVSZ; break; case EXT4_IOC32_GROUP_ADD: { struct compat_ext4_new_group_input __user *uinput; struct ext4_new_group_input input; mm_segment_t old_fs; int err; uinput = compat_ptr(arg); err = get_user(input.group, &uinput->group); err |= get_user(input.block_bitmap, &uinput->block_bitmap); err |= get_user(input.inode_bitmap, &uinput->inode_bitmap); err |= get_user(input.inode_table, &uinput->inode_table); err |= get_user(input.blocks_count, &uinput->blocks_count); err |= get_user(input.reserved_blocks, &uinput->reserved_blocks); if (err) return -EFAULT; old_fs = get_fs(); set_fs(KERNEL_DS); err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD, (unsigned long) &input); set_fs(old_fs); return err; } case EXT4_IOC_MOVE_EXT: case FITRIM: case EXT4_IOC_RESIZE_FS: case EXT4_IOC_PRECACHE_EXTENTS: break; default: return -ENOIOCTLCMD; } return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); } #endif
@REM @REM Licensed to the Apache Software Foundation (ASF) under one or more @REM contributor license agreements. See the NOTICE file distributed with @REM this work for additional information regarding copyright ownership. @REM The ASF licenses this file to You under the Apache License, Version 2.0 @REM (the "License"); you may not use this file except in compliance with @REM the License. You may obtain a copy of the License at @REM @REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, software @REM distributed under the License is distributed on an "AS IS" BASIS, @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @REM See the License for the specific language governing permissions and @REM limitations under the License. @echo off if "%OS%" == "Windows_NT" setlocal pushd "%~dp0" call cassandra.in.bat if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.BulkLoader if NOT DEFINED JAVA_HOME goto :err REM ***** JAVA options ***** set JAVA_OPTS=^ -Dlogback.configurationFile=logback-tools.xml set TOOLS_PARAMS= "%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* goto finally :err echo JAVA_HOME environment variable must be set! pause :finally ENDLOCAL
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef __gnu_CORBA_DynAn_gnuDynStruct__ #define __gnu_CORBA_DynAn_gnuDynStruct__ #pragma interface #include <gnu/CORBA/DynAn/RecordAny.h> #include <gcj/array.h> extern "Java" { namespace gnu { namespace CORBA { namespace DynAn { class RecordAny; class gnuDynAnyFactory; class gnuDynStruct; } } } namespace org { namespace omg { namespace CORBA { class ORB; class TypeCode; } namespace DynamicAny { class NameDynAnyPair; class NameValuePair; } } } } class gnu::CORBA::DynAn::gnuDynStruct : public ::gnu::CORBA::DynAn::RecordAny { public: gnuDynStruct(::org::omg::CORBA::TypeCode *, ::org::omg::CORBA::TypeCode *, ::gnu::CORBA::DynAn::gnuDynAnyFactory *, ::org::omg::CORBA::ORB *); public: // actually protected virtual ::gnu::CORBA::DynAn::RecordAny * newInstance(::org::omg::CORBA::TypeCode *, ::org::omg::CORBA::TypeCode *, ::gnu::CORBA::DynAn::gnuDynAnyFactory *, ::org::omg::CORBA::ORB *); public: virtual JArray< ::org::omg::DynamicAny::NameDynAnyPair * > * get_members_as_dyn_any(); virtual JArray< ::org::omg::DynamicAny::NameValuePair * > * get_members(); private: static const jlong serialVersionUID = 1LL; public: static ::java::lang::Class class$; }; #endif // __gnu_CORBA_DynAn_gnuDynStruct__
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html version: 3.3.0 build: 3167 */ YUI.add('dataschema-json', function(Y) { /** * Provides a DataSchema implementation which can be used to work with JSON data. * * @module dataschema * @submodule dataschema-json */ /** * JSON subclass for the DataSchema Utility. * @class DataSchema.JSON * @extends DataSchema.Base * @static */ var LANG = Y.Lang, SchemaJSON = { ///////////////////////////////////////////////////////////////////////////// // // DataSchema.JSON static methods // ///////////////////////////////////////////////////////////////////////////// /** * Utility function converts JSON locator strings into walkable paths * * @method DataSchema.JSON.getPath * @param locator {String} JSON value locator. * @return {String[]} Walkable path to data value. * @static */ getPath: function(locator) { var path = null, keys = [], i = 0; if (locator) { // Strip the ["string keys"] and [1] array indexes locator = locator. replace(/\[(['"])(.*?)\1\]/g, function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}). replace(/\[(\d+)\]/g, function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}). replace(/^\./,''); // remove leading dot // Validate against problematic characters. if (!/[^\w\.\$@]/.test(locator)) { path = locator.split('.'); for (i=path.length-1; i >= 0; --i) { if (path[i].charAt(0) === '@') { path[i] = keys[parseInt(path[i].substr(1),10)]; } } } else { } } return path; }, /** * Utility function to walk a path and return the value located there. * * @method DataSchema.JSON.getLocationValue * @param path {String[]} Locator path. * @param data {String} Data to traverse. * @return {Object} Data value at location. * @static */ getLocationValue: function (path, data) { var i = 0, len = path.length; for (;i<len;i++) { if( LANG.isObject(data) && (path[i] in data) ) { data = data[path[i]]; } else { data = undefined; break; } } return data; }, /** * Applies a given schema to given JSON data. * * @method apply * @param schema {Object} Schema to apply. * @param data {Object} JSON data. * @return {Object} Schema-parsed data. * @static */ apply: function(schema, data) { var data_in = data, data_out = {results:[],meta:{}}; // Convert incoming JSON strings if(!LANG.isObject(data)) { try { data_in = Y.JSON.parse(data); } catch(e) { data_out.error = e; return data_out; } } if(LANG.isObject(data_in) && schema) { // Parse results data if(!LANG.isUndefined(schema.resultListLocator)) { data_out = SchemaJSON._parseResults.call(this, schema, data_in, data_out); } // Parse meta data if(!LANG.isUndefined(schema.metaFields)) { data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out); } } else { data_out.error = new Error("JSON schema parse failure"); } return data_out; }, /** * Schema-parsed list of results from full data * * @method _parseResults * @param schema {Object} Schema to parse against. * @param json_in {Object} JSON to parse. * @param data_out {Object} In-progress parsed data to update. * @return {Object} Parsed data object. * @static * @protected */ _parseResults: function(schema, json_in, data_out) { var results = [], path, error; if(schema.resultListLocator) { path = SchemaJSON.getPath(schema.resultListLocator); if(path) { results = SchemaJSON.getLocationValue(path, json_in); if (results === undefined) { data_out.results = []; error = new Error("JSON results retrieval failure"); } else { if(LANG.isArray(results)) { // if no result fields are passed in, then just take the results array whole-hog // Sometimes you're getting an array of strings, or want the whole object, // so resultFields don't make sense. if (LANG.isArray(schema.resultFields)) { data_out = SchemaJSON._getFieldValues.call(this, schema.resultFields, results, data_out); } else { data_out.results = results; } } else { data_out.results = []; error = new Error("JSON Schema fields retrieval failure"); } } } else { error = new Error("JSON Schema results locator failure"); } if (error) { data_out.error = error; } } return data_out; }, /** * Get field data values out of list of full results * * @method _getFieldValues * @param fields {Array} Fields to find. * @param array_in {Array} Results to parse. * @param data_out {Object} In-progress parsed data to update. * @return {Object} Parsed data object. * @static * @protected */ _getFieldValues: function(fields, array_in, data_out) { var results = [], len = fields.length, i, j, field, key, locator, path, parser, simplePaths = [], complexPaths = [], fieldParsers = [], result, record; // First collect hashes of simple paths, complex paths, and parsers for (i=0; i<len; i++) { field = fields[i]; // A field can be a simple string or a hash key = field.key || field; // Find the key locator = field.locator || key; // Find the locator // Validate and store locators for later path = SchemaJSON.getPath(locator); if (path) { if (path.length === 1) { simplePaths[simplePaths.length] = {key:key, path:path[0]}; } else { complexPaths[complexPaths.length] = {key:key, path:path}; } } else { } // Validate and store parsers for later //TODO: use Y.DataSchema.parse? parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+'']; if (parser) { fieldParsers[fieldParsers.length] = {key:key, parser:parser}; } } // Traverse list of array_in, creating records of simple fields, // complex fields, and applying parsers as necessary for (i=array_in.length-1; i>=0; --i) { record = {}; result = array_in[i]; if(result) { // Cycle through simpleLocators for (j=simplePaths.length-1; j>=0; --j) { // Bug 1777850: The result might be an array instead of object record[simplePaths[j].key] = Y.DataSchema.Base.parse.call(this, (LANG.isUndefined(result[simplePaths[j].path]) ? result[j] : result[simplePaths[j].path]), simplePaths[j]); } // Cycle through complexLocators for (j=complexPaths.length - 1; j>=0; --j) { record[complexPaths[j].key] = Y.DataSchema.Base.parse.call(this, (SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] ); } // Cycle through fieldParsers for (j=fieldParsers.length-1; j>=0; --j) { key = fieldParsers[j].key; record[key] = fieldParsers[j].parser.call(this, record[key]); // Safety net if (LANG.isUndefined(record[key])) { record[key] = null; } } results[i] = record; } } data_out.results = results; return data_out; }, /** * Parses results data according to schema * * @method _parseMeta * @param metaFields {Object} Metafields definitions. * @param json_in {Object} JSON to parse. * @param data_out {Object} In-progress parsed data to update. * @return {Object} Schema-parsed meta data. * @static * @protected */ _parseMeta: function(metaFields, json_in, data_out) { if(LANG.isObject(metaFields)) { var key, path; for(key in metaFields) { if (metaFields.hasOwnProperty(key)) { path = SchemaJSON.getPath(metaFields[key]); if (path && json_in) { data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in); } } } } else { data_out.error = new Error("JSON meta data retrieval failure"); } return data_out; } }; Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base); }, '3.3.0' ,{requires:['dataschema-base','json']});
<?php /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category Zend * @package Zend_Gdata * @subpackage Health * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: ProfileListEntry.php 24779 2012-05-08 19:13:59Z adamlundrigan $ */ /** * @see Zend_Exception */ require_once 'Zend/Exception.php'; /** * @see Zend_Gdata_Entry */ require_once 'Zend/Gdata/Entry.php'; /** * Concrete class for working with Health profile list entries. * * @link http://code.google.com/apis/health/ * * @category Zend * @package Zend_Gdata * @subpackage Health * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Gdata_Health_ProfileListEntry extends Zend_Gdata_Entry { /** * Constructs a new Zend_Gdata_Health_ProfileListEntry object. * @param DOMElement $element (optional) The DOMElement on which to base this object. */ public function __construct($element = null) { throw new Zend_Exception( 'Google Health API has been discontinued by Google and was removed' . ' from Zend Framework in 1.12.0. For more information see: ' . 'http://googleblog.blogspot.ca/2011/06/update-on-google-health-and-google.html' ); } }
<?php class ModelAccountOrder extends Model { public function getOrder($order_id) { $order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$order_id . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND order_status_id > '0'"); if ($order_query->num_rows) { $country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'"); if ($country_query->num_rows) { $payment_iso_code_2 = $country_query->row['iso_code_2']; $payment_iso_code_3 = $country_query->row['iso_code_3']; } else { $payment_iso_code_2 = ''; $payment_iso_code_3 = ''; } $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'"); if ($zone_query->num_rows) { $payment_zone_code = $zone_query->row['code']; } else { $payment_zone_code = ''; } $country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'"); if ($country_query->num_rows) { $shipping_iso_code_2 = $country_query->row['iso_code_2']; $shipping_iso_code_3 = $country_query->row['iso_code_3']; } else { $shipping_iso_code_2 = ''; $shipping_iso_code_3 = ''; } $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'"); if ($zone_query->num_rows) { $shipping_zone_code = $zone_query->row['code']; } else { $shipping_zone_code = ''; } return array( 'order_id' => $order_query->row['order_id'], 'invoice_no' => $order_query->row['invoice_no'], 'invoice_prefix' => $order_query->row['invoice_prefix'], 'store_id' => $order_query->row['store_id'], 'store_name' => $order_query->row['store_name'], 'store_url' => $order_query->row['store_url'], 'customer_id' => $order_query->row['customer_id'], 'firstname' => $order_query->row['firstname'], 'lastname' => $order_query->row['lastname'], 'telephone' => $order_query->row['telephone'], 'fax' => $order_query->row['fax'], 'email' => $order_query->row['email'], 'payment_firstname' => $order_query->row['payment_firstname'], 'payment_lastname' => $order_query->row['payment_lastname'], 'payment_company' => $order_query->row['payment_company'], 'payment_address_1' => $order_query->row['payment_address_1'], 'payment_address_2' => $order_query->row['payment_address_2'], 'payment_postcode' => $order_query->row['payment_postcode'], 'payment_city' => $order_query->row['payment_city'], 'payment_zone_id' => $order_query->row['payment_zone_id'], 'payment_zone' => $order_query->row['payment_zone'], 'payment_zone_code' => $payment_zone_code, 'payment_country_id' => $order_query->row['payment_country_id'], 'payment_country' => $order_query->row['payment_country'], 'payment_iso_code_2' => $payment_iso_code_2, 'payment_iso_code_3' => $payment_iso_code_3, 'payment_address_format' => $order_query->row['payment_address_format'], 'payment_method' => $order_query->row['payment_method'], 'shipping_firstname' => $order_query->row['shipping_firstname'], 'shipping_lastname' => $order_query->row['shipping_lastname'], 'shipping_company' => $order_query->row['shipping_company'], 'shipping_address_1' => $order_query->row['shipping_address_1'], 'shipping_address_2' => $order_query->row['shipping_address_2'], 'shipping_postcode' => $order_query->row['shipping_postcode'], 'shipping_city' => $order_query->row['shipping_city'], 'shipping_zone_id' => $order_query->row['shipping_zone_id'], 'shipping_zone' => $order_query->row['shipping_zone'], 'shipping_zone_code' => $shipping_zone_code, 'shipping_country_id' => $order_query->row['shipping_country_id'], 'shipping_country' => $order_query->row['shipping_country'], 'shipping_iso_code_2' => $shipping_iso_code_2, 'shipping_iso_code_3' => $shipping_iso_code_3, 'shipping_address_format' => $order_query->row['shipping_address_format'], 'shipping_method' => $order_query->row['shipping_method'], 'comment' => $order_query->row['comment'], 'total' => $order_query->row['total'], 'order_status_id' => $order_query->row['order_status_id'], 'language_id' => $order_query->row['language_id'], 'currency_id' => $order_query->row['currency_id'], 'currency_code' => $order_query->row['currency_code'], 'currency_value' => $order_query->row['currency_value'], 'date_modified' => $order_query->row['date_modified'], 'date_added' => $order_query->row['date_added'], 'ip' => $order_query->row['ip'] ); } else { return false; } } public function getOrders($start = 0, $limit = 20) { if ($start < 0) { $start = 0; } if ($limit < 1) { $limit = 1; } $query = $this->db->query("SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added, o.total, o.currency_code, o.currency_value FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' AND o.store_id = '" . (int)$this->config->get('config_store_id') . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.order_id DESC LIMIT " . (int)$start . "," . (int)$limit); return $query->rows; } public function getOrderProduct($order_id, $order_product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'"); return $query->row; } public function getOrderProducts($order_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'"); return $query->rows; } public function getOrderOptions($order_id, $order_product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'"); return $query->rows; } public function getOrderVouchers($order_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$order_id . "'"); return $query->rows; } public function getOrderTotals($order_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order"); return $query->rows; } public function getOrderHistories($order_id) { $query = $this->db->query("SELECT date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added"); return $query->rows; } public function getTotalOrders() { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` o WHERE customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' AND o.store_id = '" . (int)$this->config->get('config_store_id') . "'"); return $query->row['total']; } public function getTotalOrderProductsByOrderId($order_id) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'"); return $query->row['total']; } public function getTotalOrderVouchersByOrderId($order_id) { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$order_id . "'"); return $query->row['total']; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Xml; namespace System.Runtime.Serialization.Json { internal class JsonUriDataContract : JsonDataContract { public JsonUriDataContract(UriDataContract traditionalUriDataContract) : base(traditionalUriDataContract) { } public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context) { if (context == null) { return TryReadNullAtTopLevel(jsonReader) ? null : jsonReader.ReadElementContentAsUri(); } else { return HandleReadValue(jsonReader.ReadElementContentAsUri(), context); } } } }
#import <UIKit/UIKit.h> @class RootViewController; @interface AppController : NSObject <UIApplicationDelegate> { UIWindow *window; RootViewController *viewController; } @end
#define XSTORMY16_ASHLSI3 #include "lib2funcs.c"
/* * Copyright (c) 2014 Samsung Electronics Co., Ltd. * http://www.samsung.com * * EXYNOS - Power Management support * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/init.h> #include <linux/suspend.h> #include <linux/syscore_ops.h> #include <linux/io.h> #include <linux/err.h> #include <linux/clk.h> #include <linux/interrupt.h> #include <asm/cacheflush.h> #include <asm/smp_scu.h> #include <asm/cputype.h> #include <asm/firmware.h> #include <plat/cpu.h> #include <plat/pm.h> #include <plat/pll.h> #include <plat/regs-srom.h> #include <mach/regs-irq.h> #include <mach/regs-gpio.h> #include <mach/regs-clock.h> #include <mach/regs-pmu.h> #include <mach/pm-core.h> #include <mach/pmu.h> #include <mach/smc.h> #include <mach/pmu_cal_sys.h> #define REG_INFORM0 (S5P_VA_SYSRAM_NS + 0x8) #define REG_INFORM1 (S5P_VA_SYSRAM_NS + 0xC) #define EXYNOS_WAKEUP_STAT_EINT (1 << 0) #define EXYNOS_WAKEUP_STAT_RTC_ALARM (1 << 1) #define SLEEP_MASK(r, m, v) \ { .reg = (r), .mask = (m), .val = (v) } struct sleep_mask_reg { void __iomem *reg; unsigned long mask; unsigned long val; }; static struct sleep_mask_reg enable_clk_regs[] = { SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC2, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC3, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC4, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOPC5, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOPC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOPC1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOPC2, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOPC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOPC1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP00, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP03, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP04, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP05, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP06, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP07, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_DISP, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_CAM10, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_CAM11, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_PERIC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_PERIC1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_PERIC2, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP0_PERIC3, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP02, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP03, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP04, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP05, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP06, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP07, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_DISP, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_CAM10, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_CAM11, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_PERIC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_PERIC1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_PERIC2, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP0_PERIC3, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP10, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP13, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP1_FSYS0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP1_FSYS1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_TOP1_FSYS11, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP12, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_TOP13, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP1_FSYS0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP1_FSYS1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_TOP1_FSYS11, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_SEL_TOP00, 0x00000001, 0x00000000), SLEEP_MASK(EXYNOS7420_MUX_SEL_TOP0_DISP, 0x00007000, 0x00003000), SLEEP_MASK(EXYNOS7420_MUX_SEL_TOP0_PERIC0, 0x00300370, 0x00100130), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_MIF0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_MIF1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_MIF2, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_MIF3, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_CCORE0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_CCORE1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_IMEM, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_IMEM0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_IMEM1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_PCLK_IMEM, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_PERIC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_PERIC0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_PERIC11, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_SCLK_PERIC10, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_BUS0, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_MUX_ENABLE_BUS1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ENABLE_ACLK_BUS1, 0xffffffff, 0xffffffff), SLEEP_MASK(EXYNOS7420_ATLAS_PWR_CTRL, 0x00034000, 0x00000000), SLEEP_MASK(EXYNOS7420_ATLAS_PWR_CTRL2, 0x03000000, 0x00000000), SLEEP_MASK(EXYNOS7420_APOLLO_PWR_CTRL, 0x00034000, 0x00000000), SLEEP_MASK(EXYNOS7420_APOLLO_PWR_CTRL2, 0x03000000, 0x00000000), }; static struct sleep_mask_reg enable_pmu_regs[] = { SLEEP_MASK(EXYNOS7420_PMU_SYNC_CTRL, 0xffffffff, 0x00000000), SLEEP_MASK(EXYNOS7420_CENTRAL_SEQ_MIF_OPTION, 0xffffffff, 0x00000000), SLEEP_MASK(EXYNOS7420_WAKEUP_MASK_MIF, 0xffffffff, 0x00000000), SLEEP_MASK(EXYNOS7420_ATLAS_NONCPU_OPTION, 0xffffffff, 0x00000011), SLEEP_MASK(EXYNOS7420_APOLLO_NONCPU_OPTION, 0xffffffff, 0x00000011), SLEEP_MASK(EXYNOS7420_MEMORY_TOP_OPTION, 0xffffffff, 0x00000001), SLEEP_MASK(EXYNOS7420_MEMORY_TOP_ALV_OPTION, 0xffffffff, 0x00000011), SLEEP_MASK(EXYNOS7420_RESET_CMU_TOP_OPTION, 0xffffffff, 0x00000000), SLEEP_MASK(EXYNOS7420_ATALS_OPTION, 0xffffffff, 0x80001101), SLEEP_MASK(EXYNOS7420_APOLLO_OPTION, 0xffffffff, 0x80001101), SLEEP_MASK(EXYNOS7420_BUS0_OPTION, 0xffffffff, 0x00001101), SLEEP_MASK(EXYNOS7420_FSYS0_OPTION, 0xffffffff, 0x00001101), SLEEP_MASK(EXYNOS7420_FSYS1_OPTION, 0xffffffff, 0x00001101), SLEEP_MASK(EXYNOS7420_G3D_OPTION, 0xffffffff, 0x00000181), SLEEP_MASK(EXYNOS7420_AUD_OPTION, 0xffffffff, 0x00000101), SLEEP_MASK(EXYNOS7420_SLEEP_RESET_OPTION, 0xffffffff, 0x00100000), SLEEP_MASK(EXYNOS7420_TOP_PWR_OPTION, 0xffffffff, 0x00000001), SLEEP_MASK(EXYNOS7420_LOGIC_RESET_OPTION, 0xffffffff, 0x00000000), SLEEP_MASK(EXYNOS7420_TOP_RETENTION_OPTION, 0xffffffff, 0x00000000), }; static void exynos_sleep_mask(struct sleep_mask_reg *ptr, unsigned int cnt) { unsigned long tmp; for (; cnt > 0; ptr++, cnt--) { tmp = __raw_readl(ptr->reg); __raw_writel((tmp & ~ptr->mask) | ptr->val, ptr->reg); } } static void exynos_show_wakeup_reason(void) { unsigned long wakeup_stat; wakeup_stat = __raw_readl(EXYNOS7420_WAKEUP_STAT); if (wakeup_stat & EXYNOS_WAKEUP_STAT_RTC_ALARM) pr_info("Resume caused by RTC alarm\n"); else pr_info("Resume caused by wakeup_stat=0x%08lx\n", wakeup_stat); } static void exynos_pm_wakeup_mask(void) { unsigned long eintmask, intmask; if (of_have_populated_dt()) eintmask = exynos_get_eint_wake_mask(); else eintmask = s3c_irqwake_eintmask; intmask = s3c_irqwake_intmask & ~WAKEUP_MASK_EVENT_MON_SW; S3C_PMDBG("sleep: irq wakeup mask: eint %08lx, int %08lx\n", eintmask, intmask); __raw_writel(eintmask, EXYNOS7420_EINT_WAKEUP_MASK); __raw_writel(intmask, EXYNOS7420_WAKEUP_MASK); __raw_writel(0xFFFF0000, EXYNOS7420_WAKEUP_MASK2); __raw_writel(0xFFFF0000, EXYNOS7420_WAKEUP_MASK3); } static int exynos_pm_suspend(void) { exynos_pm_wakeup_mask(); exynos_sys_powerdown_conf(SYS_SLEEP); exynos_central_sequencer_ctrl(true); if (!(__raw_readl(EXYNOS_PMU_DEBUG) & CLKOUT_DISABLE)) __raw_writel(0x1, EXYNOS5_XXTI_SYS_PWR_REG); return 0; } static void exynos_cpu_prepare(void) { /* INFORM0: set resume address, INFORM1: 0x00000BAD */ __raw_writel(EXYNOS_CHECK_SLEEP, REG_INFORM1); __raw_writel(virt_to_phys(s3c_cpu_resume), REG_INFORM0); exynos_sleep_mask(enable_clk_regs, ARRAY_SIZE(enable_clk_regs)); exynos_sleep_mask(enable_pmu_regs, ARRAY_SIZE(enable_pmu_regs)); } static int exynos_cpu_suspend(unsigned long arg) { flush_cache_all(); if (call_firmware_op(do_idle)) cpu_do_idle(); pr_info("sleep resumed to originator?"); return 1; /* abort suspend */ } static void exynos_pm_resume(void) { unsigned long tmp; /* * If PMU failed while entering sleep mode, WFI will be * ignored by PMU and then exiting cpu_do_idle(). * S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically * in this situation. */ tmp = __raw_readl(EXYNOS_CENTRAL_SEQ_CONFIGURATION); if (!(tmp & EXYNOS_CENTRAL_LOWPWR_CFG)) { exynos_central_sequencer_ctrl(false); pr_info("early wakeup from sleep"); /* No need to perform below restore code */ goto early_wakeup; } /* restore atlas LPI mask */ exynos_atlas_asyncbridge_ignore_lpi(); /* For release retention */ __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_AUD_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_MMC2_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_TOP_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_UART_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_MMC0_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_MMC1_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_EBIA_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_EBIB_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_SPI_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_MIF_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_UFS_OPTION); __raw_writel((1 << 28), EXYNOS7420_PAD_RETENTION_FSYSGENIO_OPTION); early_wakeup: exynos_show_wakeup_reason(); return; } static int exynos_pm_add(struct device *dev, struct subsys_interface *sif) { pm_cpu_prep = exynos_cpu_prepare; pm_cpu_sleep = exynos_cpu_suspend; return 0; } static struct subsys_interface exynos_pm_interface = { .name = "exynos_pm", .subsys = &exynos_subsys, .add_dev = exynos_pm_add, }; static struct syscore_ops exynos_pm_syscore_ops = { .suspend = exynos_pm_suspend, .resume = exynos_pm_resume, }; static __init int exynos_pm_drvinit(void) { s3c_pm_init(); return subsys_interface_register(&exynos_pm_interface); } arch_initcall(exynos_pm_drvinit); static __init int exynos_pm_syscore_init(void) { register_syscore_ops(&exynos_pm_syscore_ops); return 0; } arch_initcall(exynos_pm_syscore_init);
<?php /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category Zend * @package Zend_Gdata * @subpackage Gdata * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** * @see Zend_Gdata_Extension */ require_once 'Zend/Gdata/Extension.php'; /** * Implements the gd:reminder element used to set/retrieve notifications * * @category Zend * @package Zend_Gdata * @subpackage Gdata * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Gdata_Extension_Reminder extends Zend_Gdata_Extension { protected $_rootElement = 'reminder'; protected $_absoluteTime = null; protected $_method = null; protected $_days = null; protected $_hours = null; protected $_minutes = null; public function __construct($absoluteTime = null, $method = null, $days = null, $hours = null, $minutes = null) { parent::__construct(); $this->_absoluteTime = $absoluteTime; $this->_method = $method; $this->_days = $days; $this->_hours = $hours; $this->_minutes = $minutes; } public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) { $element = parent::getDOM($doc, $majorVersion, $minorVersion); if ($this->_absoluteTime !== null) { $element->setAttribute('absoluteTime', $this->_absoluteTime); } if ($this->_method !== null) { $element->setAttribute('method', $this->_method); } if ($this->_days !== null) { $element->setAttribute('days', $this->_days); } if ($this->_hours !== null) { $element->setAttribute('hours', $this->_hours); } if ($this->_minutes !== null) { $element->setAttribute('minutes', $this->_minutes); } return $element; } protected function takeAttributeFromDOM($attribute) { switch ($attribute->localName) { case 'absoluteTime': $this->_absoluteTime = $attribute->nodeValue; break; case 'method': $this->_method = $attribute->nodeValue; break; case 'days': $this->_days = $attribute->nodeValue; break; case 'hours': $this->_hours = $attribute->nodeValue; break; case 'minutes': $this->_minutes = $attribute->nodeValue; break; default: parent::takeAttributeFromDOM($attribute); } } public function __toString() { $s = ''; if ($this->_absoluteTime) $s = " at " . $this->_absoluteTime; else if ($this->_days) $s = " in " . $this->_days . " days"; else if ($this->_hours) $s = " in " . $this->_hours . " hours"; else if ($this->_minutes) $s = " in " . $this->_minutes . " minutes"; return $this->_method . $s; } public function getAbsoluteTime() { return $this->_absoluteTime; } public function setAbsoluteTime($value) { $this->_absoluteTime = $value; return $this; } public function getDays() { return $this->_days; } public function setDays($value) { $this->_days = $value; return $this; } public function getHours() { return $this->_hours; } public function setHours($value) { $this->_hours = $value; return $this; } public function getMinutes() { return $this->_minutes; } public function setMinutes($value) { $this->_minutes = $value; return $this; } public function getMethod() { return $this->_method; } public function setMethod($value) { $this->_method = $value; return $this; } }
class Ascii < Formula desc "List ASCII idiomatic names and octal/decimal code-point forms" homepage "http://www.catb.org/~esr/ascii/" url "http://www.catb.org/~esr/ascii/ascii-3.15.tar.gz" sha256 "ace1db8b64371d53d9ad420d341f2b542324ae70437e37b4b75646f12475ff5f" bottle do cellar :any_skip_relocation sha256 "b7b74752e577efa60d98732e688910980436e42fbbf1f77a041cb2af458789f5" => :yosemite sha256 "56cec53206fc55f1fcd63b09b69c1afe858f4097ac6a460b7c9c07fbdfeaa0ed" => :mavericks sha256 "1a25c357bde021b59904fc8184c45a5eb85ae6be507a1e100aa79d441ad07943" => :mountain_lion end head do url "git://thyrsus.com/repositories/ascii.git" depends_on "xmlto" => :build end def install ENV["XML_CATALOG_FILES"] = "#{etc}/xml/catalog" if build.head? bin.mkpath man1.mkpath system "make" system "make", "PREFIX=#{prefix}", "install" end test do assert_match "Official name: Line Feed", shell_output(bin/"ascii 0x0a") end end
/* crypto/x509/by_file.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <stdio.h> #include <time.h> #include <errno.h> #include "cryptlib.h" #include <openssl/lhash.h> #include <openssl/buffer.h> #include <openssl/x509.h> #include <openssl/pem.h> #ifndef OPENSSL_NO_STDIO static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); X509_LOOKUP_METHOD x509_file_lookup = { "Load file into cache", NULL, /* new */ NULL, /* free */ NULL, /* init */ NULL, /* shutdown */ by_file_ctrl, /* ctrl */ NULL, /* get_by_subject */ NULL, /* get_by_issuer_serial */ NULL, /* get_by_fingerprint */ NULL, /* get_by_alias */ }; X509_LOOKUP_METHOD *X509_LOOKUP_file(void) { return (&x509_file_lookup); } static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret) { int ok = 0; char *file; switch (cmd) { case X509_L_FILE_LOAD: if (argl == X509_FILETYPE_DEFAULT) { file = (char *)getenv(X509_get_default_cert_file_env()); if (file) ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0); else ok = (X509_load_cert_crl_file (ctx, X509_get_default_cert_file(), X509_FILETYPE_PEM) != 0); if (!ok) { X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS); } } else { if (argl == X509_FILETYPE_PEM) ok = (X509_load_cert_crl_file(ctx, argp, X509_FILETYPE_PEM) != 0); else ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0); } break; } return (ok); } int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) { int ret = 0; BIO *in = NULL; int i, count = 0; X509 *x = NULL; if (file == NULL) return (1); in = BIO_new(BIO_s_file_internal()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_SYS_LIB); goto err; } if (type == X509_FILETYPE_PEM) { for (;;) { x = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { ERR_clear_error(); break; } else { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_PEM_LIB); goto err; } } i = X509_STORE_add_cert(ctx->store_ctx, x); if (!i) goto err; count++; X509_free(x); x = NULL; } ret = count; } else if (type == X509_FILETYPE_ASN1) { x = d2i_X509_bio(in, NULL); if (x == NULL) { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_ASN1_LIB); goto err; } i = X509_STORE_add_cert(ctx->store_ctx, x); if (!i) goto err; ret = i; } else { X509err(X509_F_X509_LOAD_CERT_FILE, X509_R_BAD_X509_FILETYPE); goto err; } err: if (x != NULL) X509_free(x); if (in != NULL) BIO_free(in); return (ret); } int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) { int ret = 0; BIO *in = NULL; int i, count = 0; X509_CRL *x = NULL; if (file == NULL) return (1); in = BIO_new(BIO_s_file_internal()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_SYS_LIB); goto err; } if (type == X509_FILETYPE_PEM) { for (;;) { x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { ERR_clear_error(); break; } else { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_PEM_LIB); goto err; } } i = X509_STORE_add_crl(ctx->store_ctx, x); if (!i) goto err; count++; X509_CRL_free(x); x = NULL; } ret = count; } else if (type == X509_FILETYPE_ASN1) { x = d2i_X509_CRL_bio(in, NULL); if (x == NULL) { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_ASN1_LIB); goto err; } i = X509_STORE_add_crl(ctx->store_ctx, x); if (!i) goto err; ret = i; } else { X509err(X509_F_X509_LOAD_CRL_FILE, X509_R_BAD_X509_FILETYPE); goto err; } err: if (x != NULL) X509_CRL_free(x); if (in != NULL) BIO_free(in); return (ret); } int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) { STACK_OF(X509_INFO) *inf; X509_INFO *itmp; BIO *in; int i, count = 0; if (type != X509_FILETYPE_PEM) return X509_load_cert_file(ctx, file, type); in = BIO_new_file(file, "r"); if (!in) { X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_SYS_LIB); return 0; } inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL); BIO_free(in); if (!inf) { X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_PEM_LIB); return 0; } for (i = 0; i < sk_X509_INFO_num(inf); i++) { itmp = sk_X509_INFO_value(inf, i); if (itmp->x509) { X509_STORE_add_cert(ctx->store_ctx, itmp->x509); count++; } if (itmp->crl) { X509_STORE_add_crl(ctx->store_ctx, itmp->crl); count++; } } sk_X509_INFO_pop_free(inf, X509_INFO_free); return count; } #endif /* OPENSSL_NO_STDIO */
// mksyscall.pl -l32 -nacl syscall_nacl.go syscall_nacl_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // +build 386,nacl package syscall import "unsafe" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func naclClose(fd int) (err error) { _, _, e1 := Syscall(sys_close, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Exit(code int) (err error) { _, _, e1 := Syscall(sys_exit, uintptr(code), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func naclFstat(fd int, stat *Stat_t) (err error) { _, _, e1 := Syscall(sys_fstat, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func naclRead(fd int, b []byte) (n int, err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(sys_read, uintptr(fd), uintptr(_p0), uintptr(len(b))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func naclSeek(fd int, off *int64, whence int) (err error) { _, _, e1 := Syscall(sys_lseek, uintptr(fd), uintptr(unsafe.Pointer(off)), uintptr(whence)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func naclGetRandomBytes(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(sys_get_random_bytes, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } return }
// PR middle-end/42760 // { dg-do compile } template <typename T> struct A { static T b (T it) { return it; } }; template <typename T, typename U> static U baz (T x, T y, U z) { for (long n = y - x; n > 0; --n) { *z = *x; ++z; } }; template <typename T, typename U> U bar (T x, T y, U z) { baz (A <T>::b (x), A <T>::b (y), A <U>::b (z)); } struct C { __complex__ float v; }; template <class T> struct B { B (T y[]) { bar (y, y + 1, x); } operator T *() { return x; } T x[1]; }; B <C> foo () { C y[1]; return B <C> (y); };
/* Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package rest import ( "path" "testing" "k8s.io/client-go/pkg/api" ) func TestValidatesHostParameter(t *testing.T) { testCases := []struct { Host string APIPath string URL string Err bool }{ {"127.0.0.1", "", "http://127.0.0.1/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"127.0.0.1:8080", "", "http://127.0.0.1:8080/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"foo.bar.com", "", "http://foo.bar.com/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"http://host/prefix", "", "http://host/prefix/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"http://host", "", "http://host/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"http://host", "/", "http://host/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"http://host", "/other", "http://host/other/" + api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version, false}, {"host/server", "", "", true}, } for i, testCase := range testCases { u, versionedAPIPath, err := DefaultServerURL(testCase.Host, testCase.APIPath, api.Registry.GroupOrDie(api.GroupName).GroupVersion, false) switch { case err == nil && testCase.Err: t.Errorf("expected error but was nil") continue case err != nil && !testCase.Err: t.Errorf("unexpected error %v", err) continue case err != nil: continue } u.Path = path.Join(u.Path, versionedAPIPath) if e, a := testCase.URL, u.String(); e != a { t.Errorf("%d: expected host %s, got %s", i, e, a) continue } } }
/******************************************************************************* * Agere Systems Inc. * Wireless device driver for Linux (wlags49). * * Copyright (c) 1998-2003 Agere Systems Inc. * All rights reserved. * http://www.agere.com * * Initially developed by TriplePoint, Inc. * http://www.triplepoint.com * *------------------------------------------------------------------------------ * * This file contains handler functions registered with the net_device * structure. * *------------------------------------------------------------------------------ * * SOFTWARE LICENSE * * This software is provided subject to the following terms and conditions, * which you should read carefully before using the software. Using this * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * * Copyright © 2003 Agere Systems Inc. * All rights reserved. * * Redistribution and use in source or binary forms, with or without * modifications, are permitted provided that the following conditions are met: * * . Redistributions of source code must retain the above copyright notice, this * list of conditions and the following Disclaimer as comments in the code as * well as in the documentation and/or other materials provided with the * distribution. * * . Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following Disclaimer in the documentation * and/or other materials provided with the distribution. * * . Neither the name of Agere Systems Inc. nor the names of the contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * Disclaimer * * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * ******************************************************************************/ /******************************************************************************* * include files ******************************************************************************/ #include <wl_version.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/kernel.h> // #include <linux/sched.h> // #include <linux/ptrace.h> // #include <linux/slab.h> // #include <linux/ctype.h> // #include <linux/string.h> //#include <linux/timer.h> // #include <linux/interrupt.h> // #include <linux/in.h> // #include <linux/delay.h> // #include <linux/skbuff.h> // #include <asm/io.h> // #include <asm/system.h> // #include <asm/bitops.h> #include <linux/netdevice.h> #include <linux/ethtool.h> #include <linux/etherdevice.h> // #include <linux/skbuff.h> // #include <linux/if_arp.h> // #include <linux/ioport.h> #include <debug.h> #include <hcf.h> #include <dhf.h> // #include <hcfdef.h> #include <wl_if.h> #include <wl_internal.h> #include <wl_util.h> #include <wl_priv.h> #include <wl_main.h> #include <wl_netdev.h> #include <wl_wext.h> #ifdef USE_PROFILE #include <wl_profile.h> #endif /* USE_PROFILE */ #ifdef BUS_PCMCIA #include <wl_cs.h> #endif /* BUS_PCMCIA */ #ifdef BUS_PCI #include <wl_pci.h> #endif /* BUS_PCI */ /******************************************************************************* * global variables ******************************************************************************/ #if DBG extern dbg_info_t *DbgInfo; #endif /* DBG */ #if HCF_ENCAP #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN - 8) #else #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN) #endif //static int mtu = MTU_MAX; //MODULE_PARM(mtu, "i"); //MODULE_PARM_DESC(mtu, "MTU"); /******************************************************************************* * macros ******************************************************************************/ #define BLOCK_INPUT(buf, len) \ desc->buf_addr = buf; \ desc->BUF_SIZE = len; \ status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0) #define BLOCK_INPUT_DMA(buf, len) memcpy( buf, desc_next->buf_addr, pktlen ) /******************************************************************************* * function prototypes ******************************************************************************/ /******************************************************************************* * wl_init() ******************************************************************************* * * DESCRIPTION: * * We never need to do anything when a "Wireless" device is "initialized" * by the net software, because we only register already-found cards. * * PARAMETERS: * * dev - a pointer to the device's net_device structure * * RETURNS: * * 0 on success * errno value otherwise * ******************************************************************************/ int wl_init( struct net_device *dev ) { // unsigned long flags; // struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_init" ); DBG_ENTER( DbgInfo ); DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev ); /* Nothing to do, but grab the spinlock anyway just in case we ever need this routine */ // wl_lock( lp, &flags ); // wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return 0; } // wl_init /*============================================================================*/ /******************************************************************************* * wl_config() ******************************************************************************* * * DESCRIPTION: * * Implement the SIOCSIFMAP interface. * * PARAMETERS: * * dev - a pointer to the device's net_device structure * map - a pointer to the device's ifmap structure * * RETURNS: * * 0 on success * errno otherwise * ******************************************************************************/ int wl_config( struct net_device *dev, struct ifmap *map ) { DBG_FUNC( "wl_config" ); DBG_ENTER( DbgInfo ); DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev ); DBG_PARAM( DbgInfo, "map", "0x%p", map ); /* The only thing we care about here is a port change. Since this not needed, ignore the request. */ DBG_TRACE(DbgInfo, "%s: %s called.\n", dev->name, __func__); DBG_LEAVE( DbgInfo ); return 0; } // wl_config /*============================================================================*/ /******************************************************************************* * wl_stats() ******************************************************************************* * * DESCRIPTION: * * Return the current device statistics. * * PARAMETERS: * * dev - a pointer to the device's net_device structure * * RETURNS: * * a pointer to a net_device_stats structure containing the network * statistics. * ******************************************************************************/ struct net_device_stats *wl_stats( struct net_device *dev ) { #ifdef USE_WDS int count; #endif /* USE_WDS */ unsigned long flags; struct net_device_stats *pStats; struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ //DBG_FUNC( "wl_stats" ); //DBG_ENTER( DbgInfo ); //DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev ); pStats = NULL; wl_lock( lp, &flags ); #ifdef USE_RTS if( lp->useRTS == 1 ) { wl_unlock( lp, &flags ); //DBG_LEAVE( DbgInfo ); return NULL; } #endif /* USE_RTS */ /* Return the statistics for the appropriate device */ #ifdef USE_WDS for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( dev == lp->wds_port[count].dev ) { pStats = &( lp->wds_port[count].stats ); } } #endif /* USE_WDS */ /* If pStats is still NULL, then the device is not a WDS port */ if( pStats == NULL ) { pStats = &( lp->stats ); } wl_unlock( lp, &flags ); //DBG_LEAVE( DbgInfo ); return pStats; } // wl_stats /*============================================================================*/ /******************************************************************************* * wl_open() ******************************************************************************* * * DESCRIPTION: * * Open the device. * * PARAMETERS: * * dev - a pointer to the device's net_device structure * * RETURNS: * * 0 on success * errno otherwise * ******************************************************************************/ int wl_open(struct net_device *dev) { int status = HCF_SUCCESS; struct wl_private *lp = wl_priv(dev); unsigned long flags; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_open" ); DBG_ENTER( DbgInfo ); wl_lock( lp, &flags ); #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_TRACE( DbgInfo, "Skipping device open, in RTS mode\n" ); wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return -EIO; } #endif /* USE_RTS */ #ifdef USE_PROFILE parse_config( dev ); #endif if( lp->portState == WVLAN_PORT_STATE_DISABLED ) { DBG_TRACE( DbgInfo, "Enabling Port 0\n" ); status = wl_enable( lp ); if( status != HCF_SUCCESS ) { DBG_TRACE( DbgInfo, "Enable port 0 failed: 0x%x\n", status ); } } // Holding the lock too long, make a gap to allow other processes wl_unlock(lp, &flags); wl_lock( lp, &flags ); if ( strlen( lp->fw_image_filename ) ) { DBG_TRACE( DbgInfo, ";???? Kludgy way to force a download\n" ); status = wl_go( lp ); } else { status = wl_apply( lp ); } // Holding the lock too long, make a gap to allow other processes wl_unlock(lp, &flags); wl_lock( lp, &flags ); if( status != HCF_SUCCESS ) { // Unsuccessful, try reset of the card to recover status = wl_reset( dev ); } // Holding the lock too long, make a gap to allow other processes wl_unlock(lp, &flags); wl_lock( lp, &flags ); if( status == HCF_SUCCESS ) { netif_carrier_on( dev ); WL_WDS_NETIF_CARRIER_ON( lp ); lp->is_handling_int = WL_HANDLING_INT; // Start handling interrupts wl_act_int_on( lp ); netif_start_queue( dev ); WL_WDS_NETIF_START_QUEUE( lp ); } else { wl_hcf_error( dev, status ); /* Report the error */ netif_device_detach( dev ); /* Stop the device and queue */ } wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return status; } // wl_open /*============================================================================*/ /******************************************************************************* * wl_close() ******************************************************************************* * * DESCRIPTION: * * Close the device. * * PARAMETERS: * * dev - a pointer to the device's net_device structure * * RETURNS: * * 0 on success * errno otherwise * ******************************************************************************/ int wl_close( struct net_device *dev ) { struct wl_private *lp = wl_priv(dev); unsigned long flags; /*------------------------------------------------------------------------*/ DBG_FUNC("wl_close"); DBG_ENTER(DbgInfo); DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); /* Mark the adapter as busy */ netif_stop_queue( dev ); WL_WDS_NETIF_STOP_QUEUE( lp ); netif_carrier_off( dev ); WL_WDS_NETIF_CARRIER_OFF( lp ); /* Shutdown the adapter: Disable adapter interrupts Stop Tx/Rx Update statistics Set low power mode */ wl_lock( lp, &flags ); wl_act_int_off( lp ); lp->is_handling_int = WL_NOT_HANDLING_INT; // Stop handling interrupts #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_TRACE( DbgInfo, "Skipping device close, in RTS mode\n" ); wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return -EIO; } #endif /* USE_RTS */ /* Disable the ports */ wl_disable( lp ); wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return 0; } // wl_close /*============================================================================*/ static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); strncpy(info->version, DRV_VERSION_STR, sizeof(info->version) - 1); // strncpy(info.fw_version, priv->fw_name, // sizeof(info.fw_version) - 1); if (dev->dev.parent) { dev_set_name(dev->dev.parent, "%s", info->bus_info); //strncpy(info->bus_info, dev->dev.parent->bus_id, // sizeof(info->bus_info) - 1); } else { snprintf(info->bus_info, sizeof(info->bus_info) - 1, "PCMCIA FIXME"); // "PCMCIA 0x%lx", priv->hw.iobase); } } // wl_get_drvinfo static struct ethtool_ops wl_ethtool_ops = { .get_drvinfo = wl_get_drvinfo, .get_link = ethtool_op_get_link, }; /******************************************************************************* * wl_ioctl() ******************************************************************************* * * DESCRIPTION: * * The IOCTL handler for the device. * * PARAMETERS: * * dev - a pointer to the device's net_device struct. * rq - a pointer to the IOCTL request buffer. * cmd - the IOCTL command code. * * RETURNS: * * 0 on success * errno value otherwise * ******************************************************************************/ int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd ) { struct wl_private *lp = wl_priv(dev); unsigned long flags; int ret = 0; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_ioctl" ); DBG_ENTER(DbgInfo); DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); DBG_PARAM(DbgInfo, "rq", "0x%p", rq); DBG_PARAM(DbgInfo, "cmd", "0x%04x", cmd); wl_lock( lp, &flags ); wl_act_int_off( lp ); #ifdef USE_RTS if( lp->useRTS == 1 ) { /* Handle any RTS IOCTL here */ if( cmd == WL_IOCTL_RTS ) { DBG_TRACE( DbgInfo, "IOCTL: WL_IOCTL_RTS\n" ); ret = wvlan_rts( (struct rtsreq *)rq, dev->base_addr ); } else { DBG_TRACE( DbgInfo, "IOCTL not supported in RTS mode: 0x%X\n", cmd ); ret = -EOPNOTSUPP; } goto out_act_int_on_unlock; } #endif /* USE_RTS */ /* Only handle UIL IOCTL requests when the UIL has the system blocked. */ if( !(( lp->flags & WVLAN2_UIL_BUSY ) && ( cmd != WVLAN2_IOCTL_UIL ))) { #ifdef USE_UIL struct uilreq *urq = (struct uilreq *)rq; #endif /* USE_UIL */ switch( cmd ) { // ================== Private IOCTLs (up to 16) ================== #ifdef USE_UIL case WVLAN2_IOCTL_UIL: DBG_TRACE( DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL\n" ); ret = wvlan_uil( urq, lp ); break; #endif /* USE_UIL */ default: DBG_TRACE(DbgInfo, "IOCTL CODE NOT SUPPORTED: 0x%X\n", cmd ); ret = -EOPNOTSUPP; break; } } else { DBG_WARNING( DbgInfo, "DEVICE IS BUSY, CANNOT PROCESS REQUEST\n" ); ret = -EBUSY; } #ifdef USE_RTS out_act_int_on_unlock: #endif /* USE_RTS */ wl_act_int_on( lp ); wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return ret; } // wl_ioctl /*============================================================================*/ #ifdef CONFIG_NET_POLL_CONTROLLER void wl_poll(struct net_device *dev) { struct wl_private *lp = wl_priv(dev); unsigned long flags; struct pt_regs regs; wl_lock( lp, &flags ); wl_isr(dev->irq, dev, &regs); wl_unlock( lp, &flags ); } #endif /******************************************************************************* * wl_tx_timeout() ******************************************************************************* * * DESCRIPTION: * * The handler called when, for some reason, a Tx request is not completed. * * PARAMETERS: * * dev - a pointer to the device's net_device struct. * * RETURNS: * * N/A * ******************************************************************************/ void wl_tx_timeout( struct net_device *dev ) { #ifdef USE_WDS int count; #endif /* USE_WDS */ unsigned long flags; struct wl_private *lp = wl_priv(dev); struct net_device_stats *pStats = NULL; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_tx_timeout" ); DBG_ENTER( DbgInfo ); DBG_WARNING( DbgInfo, "%s: Transmit timeout.\n", dev->name ); wl_lock( lp, &flags ); #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_TRACE( DbgInfo, "Skipping tx_timeout handler, in RTS mode\n" ); wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return; } #endif /* USE_RTS */ /* Figure out which device (the "root" device or WDS port) this timeout is for */ #ifdef USE_WDS for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( dev == lp->wds_port[count].dev ) { pStats = &( lp->wds_port[count].stats ); /* Break the loop so that we can use the counter to access WDS information in the private structure */ break; } } #endif /* USE_WDS */ /* If pStats is still NULL, then the device is not a WDS port */ if( pStats == NULL ) { pStats = &( lp->stats ); } /* Accumulate the timeout error */ pStats->tx_errors++; wl_unlock( lp, &flags ); DBG_LEAVE( DbgInfo ); return; } // wl_tx_timeout /*============================================================================*/ /******************************************************************************* * wl_send() ******************************************************************************* * * DESCRIPTION: * * The routine which performs data transmits. * * PARAMETERS: * * lp - a pointer to the device's wl_private struct. * * RETURNS: * * 0 on success * 1 on error * ******************************************************************************/ int wl_send( struct wl_private *lp ) { int status; DESC_STRCT *desc; WVLAN_LFRAME *txF = NULL; struct list_head *element; int len; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_send" ); if( lp == NULL ) { DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" ); return FALSE; } if( lp->dev == NULL ) { DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" ); return FALSE; } /* Check for the availability of FIDs; if none are available, don't take any frames off the txQ */ if( lp->hcfCtx.IFB_RscInd == 0 ) { return FALSE; } /* Reclaim the TxQ Elements and place them back on the free queue */ if( !list_empty( &( lp->txQ[0] ))) { element = lp->txQ[0].next; txF = (WVLAN_LFRAME * )list_entry( element, WVLAN_LFRAME, node ); if( txF != NULL ) { lp->txF.skb = txF->frame.skb; lp->txF.port = txF->frame.port; txF->frame.skb = NULL; txF->frame.port = 0; list_del( &( txF->node )); list_add( element, &( lp->txFree )); lp->txQ_count--; if( lp->txQ_count < TX_Q_LOW_WATER_MARK ) { if( lp->netif_queue_on == FALSE ) { DBG_TX( DbgInfo, "Kickstarting Q: %d\n", lp->txQ_count ); netif_wake_queue( lp->dev ); WL_WDS_NETIF_WAKE_QUEUE( lp ); lp->netif_queue_on = TRUE; } } } } if( lp->txF.skb == NULL ) { return FALSE; } /* If the device has resources (FIDs) available, then Tx the packet */ /* Format the TxRequest and send it to the adapter */ len = lp->txF.skb->len < ETH_ZLEN ? ETH_ZLEN : lp->txF.skb->len; desc = &( lp->desc_tx ); desc->buf_addr = lp->txF.skb->data; desc->BUF_CNT = len; desc->next_desc_addr = NULL; status = hcf_send_msg( &( lp->hcfCtx ), desc, lp->txF.port ); if( status == HCF_SUCCESS ) { lp->dev->trans_start = jiffies; DBG_TX( DbgInfo, "Transmit...\n" ); if( lp->txF.port == HCF_PORT_0 ) { lp->stats.tx_packets++; lp->stats.tx_bytes += lp->txF.skb->len; } #ifdef USE_WDS else { lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_packets++; lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_bytes += lp->txF.skb->len; } #endif /* USE_WDS */ /* Free the skb and perform queue cleanup, as the buffer was transmitted successfully */ dev_kfree_skb( lp->txF.skb ); lp->txF.skb = NULL; lp->txF.port = 0; } return TRUE; } // wl_send /*============================================================================*/ /******************************************************************************* * wl_tx() ******************************************************************************* * * DESCRIPTION: * * The Tx handler function for the network layer. * * PARAMETERS: * * skb - a pointer to the sk_buff structure containing the data to transfer. * dev - a pointer to the device's net_device structure. * * RETURNS: * * 0 on success * 1 on error * ******************************************************************************/ int wl_tx( struct sk_buff *skb, struct net_device *dev, int port ) { unsigned long flags; struct wl_private *lp = wl_priv(dev); WVLAN_LFRAME *txF = NULL; struct list_head *element; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_tx" ); /* Grab the spinlock */ wl_lock( lp, &flags ); if( lp->flags & WVLAN2_UIL_BUSY ) { DBG_WARNING( DbgInfo, "UIL has device blocked\n" ); /* Start dropping packets here??? */ wl_unlock( lp, &flags ); return 1; } #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_PRINT( "RTS: we're getting a Tx...\n" ); wl_unlock( lp, &flags ); return 1; } #endif /* USE_RTS */ if( !lp->use_dma ) { /* Get an element from the queue */ element = lp->txFree.next; txF = (WVLAN_LFRAME *)list_entry( element, WVLAN_LFRAME, node ); if( txF == NULL ) { DBG_ERROR( DbgInfo, "Problem with list_entry\n" ); wl_unlock( lp, &flags ); return 1; } /* Fill out the frame */ txF->frame.skb = skb; txF->frame.port = port; /* Move the frame to the txQ */ /* NOTE: Here's where we would do priority queueing */ list_del( &( txF->node )); list_add( &( txF->node ), &( lp->txQ[0] )); lp->txQ_count++; if( lp->txQ_count >= DEFAULT_NUM_TX_FRAMES ) { DBG_TX( DbgInfo, "Q Full: %d\n", lp->txQ_count ); if( lp->netif_queue_on == TRUE ) { netif_stop_queue( lp->dev ); WL_WDS_NETIF_STOP_QUEUE( lp ); lp->netif_queue_on = FALSE; } } } wl_act_int_off( lp ); /* Disable Interrupts */ /* Send the data to the hardware using the appropriate method */ #ifdef ENABLE_DMA if( lp->use_dma ) { wl_send_dma( lp, skb, port ); } else #endif { wl_send( lp ); } /* Re-enable Interrupts, release the spinlock and return */ wl_act_int_on( lp ); wl_unlock( lp, &flags ); return 0; } // wl_tx /*============================================================================*/ /******************************************************************************* * wl_rx() ******************************************************************************* * * DESCRIPTION: * * The routine which performs data reception. * * PARAMETERS: * * dev - a pointer to the device's net_device structure. * * RETURNS: * * 0 on success * 1 on error * ******************************************************************************/ int wl_rx(struct net_device *dev) { int port; struct sk_buff *skb; struct wl_private *lp = wl_priv(dev); int status; hcf_16 pktlen; hcf_16 hfs_stat; DESC_STRCT *desc; /*------------------------------------------------------------------------*/ DBG_FUNC("wl_rx") DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); if(!( lp->flags & WVLAN2_UIL_BUSY )) { #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_PRINT( "RTS: We're getting an Rx...\n" ); return -EIO; } #endif /* USE_RTS */ /* Read the HFS_STAT register from the lookahead buffer */ hfs_stat = (hcf_16)(( lp->lookAheadBuf[HFS_STAT] ) | ( lp->lookAheadBuf[HFS_STAT + 1] << 8 )); /* Make sure the frame isn't bad */ if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS ) { DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n", lp->lookAheadBuf[HFS_STAT] ); return -EIO; } /* Determine what port this packet is for */ port = ( hfs_stat >> 8 ) & 0x0007; DBG_RX( DbgInfo, "Rx frame for port %d\n", port ); pktlen = lp->hcfCtx.IFB_RxLen; if (pktlen != 0) { skb = ALLOC_SKB(pktlen); if (skb != NULL) { /* Set the netdev based on the port */ switch( port ) { #ifdef USE_WDS case 1: case 2: case 3: case 4: case 5: case 6: skb->dev = lp->wds_port[port-1].dev; break; #endif /* USE_WDS */ case 0: default: skb->dev = dev; break; } desc = &( lp->desc_rx ); desc->next_desc_addr = NULL; /* #define BLOCK_INPUT(buf, len) \ desc->buf_addr = buf; \ desc->BUF_SIZE = len; \ status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0) */ GET_PACKET( skb->dev, skb, pktlen ); if( status == HCF_SUCCESS ) { netif_rx( skb ); if( port == 0 ) { lp->stats.rx_packets++; lp->stats.rx_bytes += pktlen; } #ifdef USE_WDS else { lp->wds_port[port-1].stats.rx_packets++; lp->wds_port[port-1].stats.rx_bytes += pktlen; } #endif /* USE_WDS */ dev->last_rx = jiffies; #ifdef WIRELESS_EXT #ifdef WIRELESS_SPY if( lp->spydata.spy_number > 0 ) { char *srcaddr = skb->mac.raw + MAC_ADDR_SIZE; wl_spy_gather( dev, srcaddr ); } #endif /* WIRELESS_SPY */ #endif /* WIRELESS_EXT */ } else { DBG_ERROR( DbgInfo, "Rx request to card FAILED\n" ); if( port == 0 ) { lp->stats.rx_dropped++; } #ifdef USE_WDS else { lp->wds_port[port-1].stats.rx_dropped++; } #endif /* USE_WDS */ dev_kfree_skb( skb ); } } else { DBG_ERROR( DbgInfo, "Could not alloc skb\n" ); if( port == 0 ) { lp->stats.rx_dropped++; } #ifdef USE_WDS else { lp->wds_port[port-1].stats.rx_dropped++; } #endif /* USE_WDS */ } } } return 0; } // wl_rx /*============================================================================*/ /******************************************************************************* * wl_multicast() ******************************************************************************* * * DESCRIPTION: * * Function to handle multicast packets * * PARAMETERS: * * dev - a pointer to the device's net_device structure. * * RETURNS: * * N/A * ******************************************************************************/ #ifdef NEW_MULTICAST void wl_multicast( struct net_device *dev ) { #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode //;?seems reasonable that even an AP-only driver could afford this small additional footprint int x; struct netdev_hw_addr *ha; struct wl_private *lp = wl_priv(dev); unsigned long flags; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_multicast" ); DBG_ENTER( DbgInfo ); DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev ); if( !wl_adapter_is_open( dev )) { DBG_LEAVE( DbgInfo ); return; } #if DBG if( DBG_FLAGS( DbgInfo ) & DBG_PARAM_ON ) { DBG_PRINT(" flags: %s%s%s\n", ( dev->flags & IFF_PROMISC ) ? "Promiscous " : "", ( dev->flags & IFF_MULTICAST ) ? "Multicast " : "", ( dev->flags & IFF_ALLMULTI ) ? "All-Multicast" : "" ); DBG_PRINT( " mc_count: %d\n", netdev_mc_count(dev)); netdev_for_each_mc_addr(ha, dev) DBG_PRINT(" %pM (%d)\n", ha->addr, dev->addr_len); } #endif /* DBG */ if(!( lp->flags & WVLAN2_UIL_BUSY )) { #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_TRACE( DbgInfo, "Skipping multicast, in RTS mode\n" ); DBG_LEAVE( DbgInfo ); return; } #endif /* USE_RTS */ wl_lock( lp, &flags ); wl_act_int_off( lp ); if ( CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_STA ) { if( dev->flags & IFF_PROMISC ) { /* Enable promiscuous mode */ lp->ltvRecord.len = 2; lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE; lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 ); DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); } else if ((netdev_mc_count(dev) > HCF_MAX_MULTICAST) || ( dev->flags & IFF_ALLMULTI )) { /* Shutting off this filter will enable all multicast frames to be sent up from the device; however, this is a static RID, so a call to wl_apply() is needed */ lp->ltvRecord.len = 2; lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR; lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 ); DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); wl_apply( lp ); } else if (!netdev_mc_empty(dev)) { /* Set the multicast addresses */ lp->ltvRecord.len = ( netdev_mc_count(dev) * 3 ) + 1; lp->ltvRecord.typ = CFG_GROUP_ADDR; x = 0; netdev_for_each_mc_addr(ha, dev) memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]), ha->addr, ETH_ALEN); DBG_PRINT( "Setting multicast list\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); } else { /* Disable promiscuous mode */ lp->ltvRecord.len = 2; lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE; lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 ); DBG_PRINT( "Disabling Promiscuous mode\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); /* Disable multicast mode */ lp->ltvRecord.len = 2; lp->ltvRecord.typ = CFG_GROUP_ADDR; DBG_PRINT( "Disabling Multicast mode\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); /* Turning on this filter will prevent all multicast frames from being sent up from the device; however, this is a static RID, so a call to wl_apply() is needed */ lp->ltvRecord.len = 2; lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR; lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 ); DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" ); hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); wl_apply( lp ); } } wl_act_int_on( lp ); wl_unlock( lp, &flags ); } DBG_LEAVE( DbgInfo ); #endif /* HCF_STA */ } // wl_multicast /*============================================================================*/ #else /* NEW_MULTICAST */ void wl_multicast( struct net_device *dev, int num_addrs, void *addrs ) { DBG_FUNC( "wl_multicast"); DBG_ENTER(DbgInfo); DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev ); DBG_PARAM( DbgInfo, "num_addrs", "%d", num_addrs ); DBG_PARAM( DbgInfo, "addrs", "0x%p", addrs ); #error Obsolete set multicast interface! DBG_LEAVE( DbgInfo ); } // wl_multicast /*============================================================================*/ #endif /* NEW_MULTICAST */ static const struct net_device_ops wl_netdev_ops = { .ndo_start_xmit = &wl_tx_port0, .ndo_set_config = &wl_config, .ndo_get_stats = &wl_stats, .ndo_set_rx_mode = &wl_multicast, .ndo_init = &wl_insert, .ndo_open = &wl_adapter_open, .ndo_stop = &wl_adapter_close, .ndo_do_ioctl = &wl_ioctl, .ndo_tx_timeout = &wl_tx_timeout, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = wl_poll, #endif }; /******************************************************************************* * wl_device_alloc() ******************************************************************************* * * DESCRIPTION: * * Create instances of net_device and wl_private for the new adapter * and register the device's entry points in the net_device structure. * * PARAMETERS: * * N/A * * RETURNS: * * a pointer to an allocated and initialized net_device struct for this * device. * ******************************************************************************/ struct net_device * wl_device_alloc( void ) { struct net_device *dev = NULL; struct wl_private *lp = NULL; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_device_alloc" ); DBG_ENTER( DbgInfo ); /* Alloc a net_device struct */ dev = alloc_etherdev(sizeof(struct wl_private)); if (!dev) return NULL; /* Initialize the 'next' pointer in the struct. Currently only used for PCI, but do it here just in case it's used for other buses in the future */ lp = wl_priv(dev); /* Check MTU */ if( dev->mtu > MTU_MAX ) { DBG_WARNING( DbgInfo, "%s: MTU set too high, limiting to %d.\n", dev->name, MTU_MAX ); dev->mtu = MTU_MAX; } /* Setup the function table in the device structure. */ dev->wireless_handlers = (struct iw_handler_def *)&wl_iw_handler_def; lp->wireless_data.spy_data = &lp->spy_data; dev->wireless_data = &lp->wireless_data; dev->netdev_ops = &wl_netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; dev->ethtool_ops = &wl_ethtool_ops; netif_stop_queue( dev ); /* Allocate virutal devices for WDS support if needed */ WL_WDS_DEVICE_ALLOC( lp ); DBG_LEAVE( DbgInfo ); return dev; } // wl_device_alloc /*============================================================================*/ /******************************************************************************* * wl_device_dealloc() ******************************************************************************* * * DESCRIPTION: * * Free instances of net_device and wl_private strcutres for an adapter * and perform basic cleanup. * * PARAMETERS: * * dev - a pointer to the device's net_device structure. * * RETURNS: * * N/A * ******************************************************************************/ void wl_device_dealloc( struct net_device *dev ) { // struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_device_dealloc" ); DBG_ENTER( DbgInfo ); /* Dealloc the WDS ports */ WL_WDS_DEVICE_DEALLOC( lp ); free_netdev( dev ); DBG_LEAVE( DbgInfo ); return; } // wl_device_dealloc /*============================================================================*/ /******************************************************************************* * wl_tx_port0() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_0. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_0. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port0( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 0\n" ); return wl_tx( skb, dev, HCF_PORT_0 ); #ifdef ENABLE_DMA return wl_tx_dma( skb, dev, HCF_PORT_0 ); #endif } // wl_tx_port0 /*============================================================================*/ #ifdef USE_WDS /******************************************************************************* * wl_tx_port1() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_1. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_1. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port1( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 1\n" ); return wl_tx( skb, dev, HCF_PORT_1 ); } // wl_tx_port1 /*============================================================================*/ /******************************************************************************* * wl_tx_port2() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_2. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_2. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port2( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 2\n" ); return wl_tx( skb, dev, HCF_PORT_2 ); } // wl_tx_port2 /*============================================================================*/ /******************************************************************************* * wl_tx_port3() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_3. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_3. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port3( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 3\n" ); return wl_tx( skb, dev, HCF_PORT_3 ); } // wl_tx_port3 /*============================================================================*/ /******************************************************************************* * wl_tx_port4() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_4. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_4. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port4( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 4\n" ); return wl_tx( skb, dev, HCF_PORT_4 ); } // wl_tx_port4 /*============================================================================*/ /******************************************************************************* * wl_tx_port5() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_5. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_5. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port5( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 5\n" ); return wl_tx( skb, dev, HCF_PORT_5 ); } // wl_tx_port5 /*============================================================================*/ /******************************************************************************* * wl_tx_port6() ******************************************************************************* * * DESCRIPTION: * * The handler routine for Tx over HCF_PORT_6. * * PARAMETERS: * * skb - a pointer to the sk_buff to transmit. * dev - a pointer to a net_device structure representing HCF_PORT_6. * * RETURNS: * * N/A * ******************************************************************************/ int wl_tx_port6( struct sk_buff *skb, struct net_device *dev ) { DBG_TX( DbgInfo, "Tx on Port 6\n" ); return wl_tx( skb, dev, HCF_PORT_6 ); } // wl_tx_port6 /*============================================================================*/ /******************************************************************************* * wl_wds_device_alloc() ******************************************************************************* * * DESCRIPTION: * * Create instances of net_device to represent the WDS ports, and register * the device's entry points in the net_device structure. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A, but will place pointers to the allocated and initialized net_device * structs in the private adapter structure. * ******************************************************************************/ void wl_wds_device_alloc( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_wds_device_alloc" ); DBG_ENTER( DbgInfo ); /* WDS support requires additional net_device structs to be allocated, so that user space apps can use these virtual devices to specify the port on which to Tx/Rx */ for( count = 0; count < NUM_WDS_PORTS; count++ ) { struct net_device *dev_wds = NULL; dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL ); memset( dev_wds, 0, sizeof( struct net_device )); ether_setup( dev_wds ); lp->wds_port[count].dev = dev_wds; /* Re-use wl_init for all the devices, as it currently does nothing, but is required. Re-use the stats/tx_timeout handler for all as well; the WDS port which is requesting these operations can be determined by the net_device pointer. Set the private member of all devices to point to the same net_device struct; that way, all information gets funnelled through the one "real" net_device. Name the WDS ports "wds<n>" */ lp->wds_port[count].dev->init = &wl_init; lp->wds_port[count].dev->get_stats = &wl_stats; lp->wds_port[count].dev->tx_timeout = &wl_tx_timeout; lp->wds_port[count].dev->watchdog_timeo = TX_TIMEOUT; lp->wds_port[count].dev->priv = lp; sprintf( lp->wds_port[count].dev->name, "wds%d", count ); } /* Register the Tx handlers */ lp->wds_port[0].dev->hard_start_xmit = &wl_tx_port1; lp->wds_port[1].dev->hard_start_xmit = &wl_tx_port2; lp->wds_port[2].dev->hard_start_xmit = &wl_tx_port3; lp->wds_port[3].dev->hard_start_xmit = &wl_tx_port4; lp->wds_port[4].dev->hard_start_xmit = &wl_tx_port5; lp->wds_port[5].dev->hard_start_xmit = &wl_tx_port6; WL_WDS_NETIF_STOP_QUEUE( lp ); DBG_LEAVE( DbgInfo ); return; } // wl_wds_device_alloc /*============================================================================*/ /******************************************************************************* * wl_wds_device_dealloc() ******************************************************************************* * * DESCRIPTION: * * Free instances of net_device structures used to support WDS. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_device_dealloc( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_wds_device_dealloc" ); DBG_ENTER( DbgInfo ); for( count = 0; count < NUM_WDS_PORTS; count++ ) { struct net_device *dev_wds = NULL; dev_wds = lp->wds_port[count].dev; if( dev_wds != NULL ) { if( dev_wds->flags & IFF_UP ) { dev_close( dev_wds ); dev_wds->flags &= ~( IFF_UP | IFF_RUNNING ); } free_netdev(dev_wds); lp->wds_port[count].dev = NULL; } } DBG_LEAVE( DbgInfo ); return; } // wl_wds_device_dealloc /*============================================================================*/ /******************************************************************************* * wl_wds_netif_start_queue() ******************************************************************************* * * DESCRIPTION: * * Used to start the netif queues of all the "virtual" network devices * which repesent the WDS ports. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_netif_start_queue( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ if( lp != NULL ) { for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( lp->wds_port[count].is_registered && lp->wds_port[count].netif_queue_on == FALSE ) { netif_start_queue( lp->wds_port[count].dev ); lp->wds_port[count].netif_queue_on = TRUE; } } } return; } // wl_wds_netif_start_queue /*============================================================================*/ /******************************************************************************* * wl_wds_netif_stop_queue() ******************************************************************************* * * DESCRIPTION: * * Used to stop the netif queues of all the "virtual" network devices * which repesent the WDS ports. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_netif_stop_queue( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ if( lp != NULL ) { for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( lp->wds_port[count].is_registered && lp->wds_port[count].netif_queue_on == TRUE ) { netif_stop_queue( lp->wds_port[count].dev ); lp->wds_port[count].netif_queue_on = FALSE; } } } return; } // wl_wds_netif_stop_queue /*============================================================================*/ /******************************************************************************* * wl_wds_netif_wake_queue() ******************************************************************************* * * DESCRIPTION: * * Used to wake the netif queues of all the "virtual" network devices * which repesent the WDS ports. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_netif_wake_queue( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ if( lp != NULL ) { for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( lp->wds_port[count].is_registered && lp->wds_port[count].netif_queue_on == FALSE ) { netif_wake_queue( lp->wds_port[count].dev ); lp->wds_port[count].netif_queue_on = TRUE; } } } return; } // wl_wds_netif_wake_queue /*============================================================================*/ /******************************************************************************* * wl_wds_netif_carrier_on() ******************************************************************************* * * DESCRIPTION: * * Used to signal the network layer that carrier is present on all of the * "virtual" network devices which repesent the WDS ports. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_netif_carrier_on( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ if( lp != NULL ) { for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( lp->wds_port[count].is_registered ) { netif_carrier_on( lp->wds_port[count].dev ); } } } return; } // wl_wds_netif_carrier_on /*============================================================================*/ /******************************************************************************* * wl_wds_netif_carrier_off() ******************************************************************************* * * DESCRIPTION: * * Used to signal the network layer that carrier is NOT present on all of * the "virtual" network devices which repesent the WDS ports. * * PARAMETERS: * * lp - a pointer to the device's private adapter structure * * RETURNS: * * N/A * ******************************************************************************/ void wl_wds_netif_carrier_off( struct wl_private *lp ) { int count; /*------------------------------------------------------------------------*/ if( lp != NULL ) { for( count = 0; count < NUM_WDS_PORTS; count++ ) { if( lp->wds_port[count].is_registered ) { netif_carrier_off( lp->wds_port[count].dev ); } } } return; } // wl_wds_netif_carrier_off /*============================================================================*/ #endif /* USE_WDS */ #ifdef ENABLE_DMA /******************************************************************************* * wl_send_dma() ******************************************************************************* * * DESCRIPTION: * * The routine which performs data transmits when using busmaster DMA. * * PARAMETERS: * * lp - a pointer to the device's wl_private struct. * skb - a pointer to the network layer's data buffer. * port - the Hermes port on which to transmit. * * RETURNS: * * 0 on success * 1 on error * ******************************************************************************/ int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port ) { int len; DESC_STRCT *desc = NULL; DESC_STRCT *desc_next = NULL; /*------------------------------------------------------------------------*/ DBG_FUNC( "wl_send_dma" ); if( lp == NULL ) { DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" ); return FALSE; } if( lp->dev == NULL ) { DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" ); return FALSE; } /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */ if( skb == NULL ) { DBG_WARNING (DbgInfo, "Nothing to send.\n"); return FALSE; } len = skb->len; /* Get a free descriptor */ desc = wl_pci_dma_get_tx_packet( lp ); if( desc == NULL ) { if( lp->netif_queue_on == TRUE ) { netif_stop_queue( lp->dev ); WL_WDS_NETIF_STOP_QUEUE( lp ); lp->netif_queue_on = FALSE; dev_kfree_skb( skb ); return 0; } } SET_BUF_CNT( desc, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST ); SET_BUF_SIZE( desc, HCF_DMA_TX_BUF1_SIZE ); desc_next = desc->next_desc_addr; if( desc_next->buf_addr == NULL ) { DBG_ERROR( DbgInfo, "DMA descriptor buf_addr is NULL\n" ); return FALSE; } /* Copy the payload into the DMA packet */ memcpy( desc_next->buf_addr, skb->data, len ); SET_BUF_CNT( desc_next, len ); SET_BUF_SIZE( desc_next, HCF_MAX_PACKET_SIZE ); hcf_dma_tx_put( &( lp->hcfCtx ), desc, 0 ); /* Free the skb and perform queue cleanup, as the buffer was transmitted successfully */ dev_kfree_skb( skb ); return TRUE; } // wl_send_dma /*============================================================================*/ /******************************************************************************* * wl_rx_dma() ******************************************************************************* * * DESCRIPTION: * * The routine which performs data reception when using busmaster DMA. * * PARAMETERS: * * dev - a pointer to the device's net_device structure. * * RETURNS: * * 0 on success * 1 on error * ******************************************************************************/ int wl_rx_dma( struct net_device *dev ) { int port; hcf_16 pktlen; hcf_16 hfs_stat; struct sk_buff *skb; struct wl_private *lp = NULL; DESC_STRCT *desc, *desc_next; //CFG_MB_INFO_RANGE2_STRCT x; /*------------------------------------------------------------------------*/ DBG_FUNC("wl_rx") DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); if((( lp = dev->priv ) != NULL ) && !( lp->flags & WVLAN2_UIL_BUSY )) { #ifdef USE_RTS if( lp->useRTS == 1 ) { DBG_PRINT( "RTS: We're getting an Rx...\n" ); return -EIO; } #endif /* USE_RTS */ //if( lp->dma.status == 0 ) //{ desc = hcf_dma_rx_get( &( lp->hcfCtx )); if( desc != NULL ) { /* Check and see if we rcvd. a WMP frame */ /* if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG ) { DBG_TRACE( DbgInfo, "Got a WMP frame\n" ); x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 ); x.typ = CFG_MB_INFO; x.base_typ = CFG_WMP; x.frag_cnt = 2; x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 ); x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ; x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 ); x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ; hcf_put_info( &( lp->hcfCtx ), (LTVP)&x ); } */ desc_next = desc->next_desc_addr; /* Make sure the buffer isn't empty */ if( GET_BUF_CNT( desc ) == 0 ) { DBG_WARNING( DbgInfo, "Buffer is empty!\n" ); /* Give the descriptor back to the HCF */ hcf_dma_rx_put( &( lp->hcfCtx ), desc ); return -EIO; } /* Read the HFS_STAT register from the lookahead buffer */ hfs_stat = (hcf_16)( desc->buf_addr[HFS_STAT/2] ); /* Make sure the frame isn't bad */ if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS ) { DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n", desc->buf_addr[HFS_STAT/2] ); /* Give the descriptor back to the HCF */ hcf_dma_rx_put( &( lp->hcfCtx ), desc ); return -EIO; } /* Determine what port this packet is for */ port = ( hfs_stat >> 8 ) & 0x0007; DBG_RX( DbgInfo, "Rx frame for port %d\n", port ); pktlen = GET_BUF_CNT(desc_next); if (pktlen != 0) { skb = ALLOC_SKB(pktlen); if (skb != NULL) { switch( port ) { #ifdef USE_WDS case 1: case 2: case 3: case 4: case 5: case 6: skb->dev = lp->wds_port[port-1].dev; break; #endif /* USE_WDS */ case 0: default: skb->dev = dev; break; } GET_PACKET_DMA( skb->dev, skb, pktlen ); /* Give the descriptor back to the HCF */ hcf_dma_rx_put( &( lp->hcfCtx ), desc ); netif_rx( skb ); if( port == 0 ) { lp->stats.rx_packets++; lp->stats.rx_bytes += pktlen; } #ifdef USE_WDS else { lp->wds_port[port-1].stats.rx_packets++; lp->wds_port[port-1].stats.rx_bytes += pktlen; } #endif /* USE_WDS */ dev->last_rx = jiffies; } else { DBG_ERROR( DbgInfo, "Could not alloc skb\n" ); if( port == 0 ) { lp->stats.rx_dropped++; } #ifdef USE_WDS else { lp->wds_port[port-1].stats.rx_dropped++; } #endif /* USE_WDS */ } } } //} } return 0; } // wl_rx_dma /*============================================================================*/ #endif // ENABLE_DMA
/* * netup-init.c * * NetUP Dual DVB-S2 CI driver * * Copyright (C) 2009 NetUP Inc. * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru> * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "cx23885.h" static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val) { int ret; u8 buf[3]; struct i2c_msg msg = { .addr = 0x88 >> 1, .flags = 0, .buf = buf, .len = 3 }; buf[0] = reg >> 8; buf[1] = reg & 0xff; buf[2] = val; ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) printk(KERN_ERR "%s: i2c write error!\n", __func__); } static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val) { int ret; u8 buf[6]; struct i2c_msg msg = { .addr = 0x88 >> 1, .flags = 0, .buf = buf, .len = 6 }; buf[0] = reg >> 8; buf[1] = reg & 0xff; buf[2] = val & 0xff; buf[3] = (val >> 8) & 0xff; buf[4] = (val >> 16) & 0xff; buf[5] = val >> 24; ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) printk(KERN_ERR "%s: i2c write error!\n", __func__); } static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg) { int ret; u8 buf[2]; struct i2c_msg msg = { .addr = 0x88 >> 1, .flags = 0, .buf = buf, .len = 2 }; buf[0] = reg >> 8; buf[1] = reg & 0xff; ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) printk(KERN_ERR "%s: i2c write error!\n", __func__); msg.flags = I2C_M_RD; msg.len = 1; ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) printk(KERN_ERR "%s: i2c read error!\n", __func__); return buf[0]; } static void i2c_av_and_or(struct i2c_adapter *i2c, u16 reg, unsigned and_mask, u8 or_value) { i2c_av_write(i2c, reg, (i2c_av_read(i2c, reg) & and_mask) | or_value); } /* set 27MHz on AUX_CLK */ void netup_initialize(struct cx23885_dev *dev) { struct cx23885_i2c *i2c_bus = &dev->i2c_bus[2]; struct i2c_adapter *i2c = &i2c_bus->i2c_adap; /* Stop microcontroller */ i2c_av_and_or(i2c, 0x803, ~0x10, 0x00); /* Aux PLL frac for 27 MHz */ i2c_av_write4(i2c, 0x114, 0xea0eb3); /* Aux PLL int for 27 MHz */ i2c_av_write4(i2c, 0x110, 0x090319); /* start microcontroller */ i2c_av_and_or(i2c, 0x803, ~0x10, 0x10); }
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This is an empty file with a .cc extension, to convince the toolchain // (I'm looking at YOU, Xcode) that it needs to link any target this file // belongs to as C++.
package com.iluwatar.servicelayer.wizard; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.Table; import com.iluwatar.servicelayer.common.BaseEntity; import com.iluwatar.servicelayer.spellbook.Spellbook; /** * * Wizard entity. * */ @Entity @Table(name="WIZARD") public class Wizard extends BaseEntity { public Wizard() { spellbooks = new HashSet<Spellbook>(); } public Wizard(String name) { this(); this.name = name; } @Id @GeneratedValue @Column(name = "WIZARD_ID") private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; } private String name; @ManyToMany(cascade = CascadeType.ALL) private Set<Spellbook> spellbooks; public String getName() { return name; } public void setName(String name) { this.name = name; } public Set<Spellbook> getSpellbooks() { return spellbooks; } public void setSpellbooks(Set<Spellbook> spellbooks) { this.spellbooks = spellbooks; } public void addSpellbook(Spellbook spellbook) { spellbook.getWizards().add(this); spellbooks.add(spellbook); } @Override public String toString() { return name; } }
#ifndef _LINUX_MEMBLOCK_H #define _LINUX_MEMBLOCK_H #ifdef __KERNEL__ #ifdef CONFIG_HAVE_MEMBLOCK /* * Logical memory blocks. * * Copyright (C) 2001 Peter Bergner, IBM Corp. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <linux/init.h> #include <linux/mm.h> #define INIT_MEMBLOCK_REGIONS 128 struct memblock_region { phys_addr_t base; phys_addr_t size; #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int nid; #endif }; struct memblock_type { unsigned long cnt; /* number of regions */ unsigned long max; /* size of the allocated array */ phys_addr_t total_size; /* size of all regions */ struct memblock_region *regions; }; struct memblock { phys_addr_t current_limit; struct memblock_type memory; struct memblock_type reserved; }; extern struct memblock memblock; extern int memblock_debug; #define memblock_dbg(fmt, ...) \ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align, int nid); phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align); phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr); void memblock_allow_resize(void); int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); int memblock_add(phys_addr_t base, phys_addr_t size); int memblock_remove(phys_addr_t base, phys_addr_t size); int memblock_free(phys_addr_t base, phys_addr_t size); int memblock_reserve(phys_addr_t base, phys_addr_t size); #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, unsigned long *out_end_pfn, int *out_nid); /** * for_each_mem_pfn_range - early memory pfn range iterator * @i: an integer used as loop variable * @nid: node selector, %MAX_NUMNODES for all nodes * @p_start: ptr to ulong for start pfn of the range, can be %NULL * @p_end: ptr to ulong for end pfn of the range, can be %NULL * @p_nid: ptr to int for nid of the range, can be %NULL * * Walks over configured memory ranges. Available after early_node_map is * populated. */ #define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \ for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \ i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid)) #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start, phys_addr_t *out_end, int *out_nid); /** * for_each_free_mem_range - iterate through free memblock areas * @i: u64 used as loop variable * @nid: node selector, %MAX_NUMNODES for all nodes * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL * @p_nid: ptr to int for nid of the range, can be %NULL * * Walks over free (memory && !reserved) areas of memblock. Available as * soon as memblock is initialized. */ #define for_each_free_mem_range(i, nid, p_start, p_end, p_nid) \ for (i = 0, \ __next_free_mem_range(&i, nid, p_start, p_end, p_nid); \ i != (u64)ULLONG_MAX; \ __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) void __next_free_mem_range_rev(u64 *idx, int nid, phys_addr_t *out_start, phys_addr_t *out_end, int *out_nid); /** * for_each_free_mem_range_reverse - rev-iterate through free memblock areas * @i: u64 used as loop variable * @nid: node selector, %MAX_NUMNODES for all nodes * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL * @p_nid: ptr to int for nid of the range, can be %NULL * * Walks over free (memory && !reserved) areas of memblock in reverse * order. Available as soon as memblock is initialized. */ #define for_each_free_mem_range_reverse(i, nid, p_start, p_end, p_nid) \ for (i = (u64)ULLONG_MAX, \ __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid); \ i != (u64)ULLONG_MAX; \ __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid)) #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); static inline void memblock_set_region_node(struct memblock_region *r, int nid) { r->nid = nid; } static inline int memblock_get_region_node(const struct memblock_region *r) { return r->nid; } #else static inline void memblock_set_region_node(struct memblock_region *r, int nid) { } static inline int memblock_get_region_node(const struct memblock_region *r) { return 0; } #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align); /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ #define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) #define MEMBLOCK_ALLOC_ACCESSIBLE 0 phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr); phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr); phys_addr_t memblock_phys_mem_size(void); phys_addr_t memblock_start_of_DRAM(void); phys_addr_t memblock_end_of_DRAM(void); void memblock_enforce_memory_limit(phys_addr_t memory_limit); int memblock_is_memory(phys_addr_t addr); int memblock_is_region_memory(phys_addr_t base, phys_addr_t size); int memblock_is_reserved(phys_addr_t addr); int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); extern void __memblock_dump_all(void); static inline void memblock_dump_all(void) { if (memblock_debug) __memblock_dump_all(); } /** * memblock_set_current_limit - Set the current allocation limit to allow * limiting allocations to what is currently * accessible during boot * @limit: New limit value (physical address) */ void memblock_set_current_limit(phys_addr_t limit); /* * pfn conversion functions * * While the memory MEMBLOCKs should always be page aligned, the reserved * MEMBLOCKs may not be. This accessor attempt to provide a very clear * idea of what they return for such non aligned MEMBLOCKs. */ /** * memblock_region_memory_base_pfn - Return the lowest pfn intersecting with the memory region * @reg: memblock_region structure */ static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg) { return PFN_UP(reg->base); } /** * memblock_region_memory_end_pfn - Return the end_pfn this region * @reg: memblock_region structure */ static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg) { return PFN_DOWN(reg->base + reg->size); } /** * memblock_region_reserved_base_pfn - Return the lowest pfn intersecting with the reserved region * @reg: memblock_region structure */ static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg) { return PFN_DOWN(reg->base); } /** * memblock_region_reserved_end_pfn - Return the end_pfn this region * @reg: memblock_region structure */ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg) { return PFN_UP(reg->base + reg->size); } #define for_each_memblock(memblock_type, region) \ for (region = memblock.memblock_type.regions; \ region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \ region++) #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK #define __init_memblock __meminit #define __initdata_memblock __meminitdata #else #define __init_memblock #define __initdata_memblock #endif #else static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align) { return 0; } #endif /* CONFIG_HAVE_MEMBLOCK */ #endif /* __KERNEL__ */ #endif /* _LINUX_MEMBLOCK_H */
/* * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de> * JZ4740 platform IRQ support * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include <linux/errno.h> #include <linux/init.h> #include <linux/types.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/irqchip/ingenic.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/timex.h> #include <linux/slab.h> #include <linux/delay.h> #include <asm/io.h> #include <asm/mach-jz4740/irq.h> #include "irqchip.h" struct ingenic_intc_data { void __iomem *base; unsigned num_chips; }; #define JZ_REG_INTC_STATUS 0x00 #define JZ_REG_INTC_MASK 0x04 #define JZ_REG_INTC_SET_MASK 0x08 #define JZ_REG_INTC_CLEAR_MASK 0x0c #define JZ_REG_INTC_PENDING 0x10 #define CHIP_SIZE 0x20 static irqreturn_t intc_cascade(int irq, void *data) { struct ingenic_intc_data *intc = irq_get_handler_data(irq); uint32_t irq_reg; unsigned i; for (i = 0; i < intc->num_chips; i++) { irq_reg = readl(intc->base + (i * CHIP_SIZE) + JZ_REG_INTC_PENDING); if (!irq_reg) continue; generic_handle_irq(__fls(irq_reg) + (i * 32) + JZ4740_IRQ_BASE); } return IRQ_HANDLED; } static void intc_irq_set_mask(struct irq_chip_generic *gc, uint32_t mask) { struct irq_chip_regs *regs = &gc->chip_types->regs; writel(mask, gc->reg_base + regs->enable); writel(~mask, gc->reg_base + regs->disable); } void ingenic_intc_irq_suspend(struct irq_data *data) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); intc_irq_set_mask(gc, gc->wake_active); } void ingenic_intc_irq_resume(struct irq_data *data) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); intc_irq_set_mask(gc, gc->mask_cache); } static struct irqaction intc_cascade_action = { .handler = intc_cascade, .name = "SoC intc cascade interrupt", }; static int __init ingenic_intc_of_init(struct device_node *node, unsigned num_chips) { struct ingenic_intc_data *intc; struct irq_chip_generic *gc; struct irq_chip_type *ct; struct irq_domain *domain; int parent_irq, err = 0; unsigned i; intc = kzalloc(sizeof(*intc), GFP_KERNEL); if (!intc) { err = -ENOMEM; goto out_err; } parent_irq = irq_of_parse_and_map(node, 0); if (!parent_irq) { err = -EINVAL; goto out_free; } err = irq_set_handler_data(parent_irq, intc); if (err) goto out_unmap_irq; intc->num_chips = num_chips; intc->base = of_iomap(node, 0); if (!intc->base) { err = -ENODEV; goto out_unmap_irq; } for (i = 0; i < num_chips; i++) { /* Mask all irqs */ writel(0xffffffff, intc->base + (i * CHIP_SIZE) + JZ_REG_INTC_SET_MASK); gc = irq_alloc_generic_chip("INTC", 1, JZ4740_IRQ_BASE + (i * 32), intc->base + (i * CHIP_SIZE), handle_level_irq); gc->wake_enabled = IRQ_MSK(32); ct = gc->chip_types; ct->regs.enable = JZ_REG_INTC_CLEAR_MASK; ct->regs.disable = JZ_REG_INTC_SET_MASK; ct->chip.irq_unmask = irq_gc_unmask_enable_reg; ct->chip.irq_mask = irq_gc_mask_disable_reg; ct->chip.irq_mask_ack = irq_gc_mask_disable_reg; ct->chip.irq_set_wake = irq_gc_set_wake; ct->chip.irq_suspend = ingenic_intc_irq_suspend; ct->chip.irq_resume = ingenic_intc_irq_resume; irq_setup_generic_chip(gc, IRQ_MSK(32), 0, 0, IRQ_NOPROBE | IRQ_LEVEL); } domain = irq_domain_add_legacy(node, num_chips * 32, JZ4740_IRQ_BASE, 0, &irq_domain_simple_ops, NULL); if (!domain) pr_warn("unable to register IRQ domain\n"); setup_irq(parent_irq, &intc_cascade_action); return 0; out_unmap_irq: irq_dispose_mapping(parent_irq); out_free: kfree(intc); out_err: return err; } static int __init intc_1chip_of_init(struct device_node *node, struct device_node *parent) { return ingenic_intc_of_init(node, 1); } IRQCHIP_DECLARE(jz4740_intc, "ingenic,jz4740-intc", intc_1chip_of_init); static int __init intc_2chip_of_init(struct device_node *node, struct device_node *parent) { return ingenic_intc_of_init(node, 2); } IRQCHIP_DECLARE(jz4770_intc, "ingenic,jz4770-intc", intc_2chip_of_init); IRQCHIP_DECLARE(jz4775_intc, "ingenic,jz4775-intc", intc_2chip_of_init); IRQCHIP_DECLARE(jz4780_intc, "ingenic,jz4780-intc", intc_2chip_of_init);
/* * arch/powerpc/sysdev/ipic.c * * IPIC routines implementations. * * Copyright 2005 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/reboot.h> #include <linux/slab.h> #include <linux/stddef.h> #include <linux/sched.h> #include <linux/signal.h> #include <linux/syscore_ops.h> #include <linux/device.h> #include <linux/spinlock.h> #include <linux/fsl_devices.h> #include <asm/irq.h> #include <asm/io.h> #include <asm/prom.h> #include <asm/ipic.h> #include "ipic.h" static struct ipic * primary_ipic; static struct irq_chip ipic_level_irq_chip, ipic_edge_irq_chip; static DEFINE_RAW_SPINLOCK(ipic_lock); static struct ipic_info ipic_info[] = { [1] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 16, .prio_mask = 0, }, [2] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 17, .prio_mask = 1, }, [3] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 18, .prio_mask = 2, }, [4] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 19, .prio_mask = 3, }, [5] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 20, .prio_mask = 4, }, [6] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 21, .prio_mask = 5, }, [7] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 22, .prio_mask = 6, }, [8] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_C, .force = IPIC_SIFCR_H, .bit = 23, .prio_mask = 7, }, [9] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 24, .prio_mask = 0, }, [10] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 25, .prio_mask = 1, }, [11] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 26, .prio_mask = 2, }, [12] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 27, .prio_mask = 3, }, [13] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 28, .prio_mask = 4, }, [14] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 29, .prio_mask = 5, }, [15] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 30, .prio_mask = 6, }, [16] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_D, .force = IPIC_SIFCR_H, .bit = 31, .prio_mask = 7, }, [17] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_A, .force = IPIC_SEFCR, .bit = 1, .prio_mask = 5, }, [18] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_A, .force = IPIC_SEFCR, .bit = 2, .prio_mask = 6, }, [19] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_A, .force = IPIC_SEFCR, .bit = 3, .prio_mask = 7, }, [20] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_B, .force = IPIC_SEFCR, .bit = 4, .prio_mask = 4, }, [21] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_B, .force = IPIC_SEFCR, .bit = 5, .prio_mask = 5, }, [22] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_B, .force = IPIC_SEFCR, .bit = 6, .prio_mask = 6, }, [23] = { .ack = IPIC_SEPNR, .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_B, .force = IPIC_SEFCR, .bit = 7, .prio_mask = 7, }, [32] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 0, .prio_mask = 0, }, [33] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 1, .prio_mask = 1, }, [34] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 2, .prio_mask = 2, }, [35] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 3, .prio_mask = 3, }, [36] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 4, .prio_mask = 4, }, [37] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 5, .prio_mask = 5, }, [38] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 6, .prio_mask = 6, }, [39] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_A, .force = IPIC_SIFCR_H, .bit = 7, .prio_mask = 7, }, [40] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 8, .prio_mask = 0, }, [41] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 9, .prio_mask = 1, }, [42] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 10, .prio_mask = 2, }, [43] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 11, .prio_mask = 3, }, [44] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 12, .prio_mask = 4, }, [45] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 13, .prio_mask = 5, }, [46] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 14, .prio_mask = 6, }, [47] = { .mask = IPIC_SIMSR_H, .prio = IPIC_SIPRR_B, .force = IPIC_SIFCR_H, .bit = 15, .prio_mask = 7, }, [48] = { .mask = IPIC_SEMSR, .prio = IPIC_SMPRR_A, .force = IPIC_SEFCR, .bit = 0, .prio_mask = 4, }, [64] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_A, .force = IPIC_SIFCR_L, .bit = 0, .prio_mask = 0, }, [65] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_A, .force = IPIC_SIFCR_L, .bit = 1, .prio_mask = 1, }, [66] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_A, .force = IPIC_SIFCR_L, .bit = 2, .prio_mask = 2, }, [67] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_A, .force = IPIC_SIFCR_L, .bit = 3, .prio_mask = 3, }, [68] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_B, .force = IPIC_SIFCR_L, .bit = 4, .prio_mask = 0, }, [69] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_B, .force = IPIC_SIFCR_L, .bit = 5, .prio_mask = 1, }, [70] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_B, .force = IPIC_SIFCR_L, .bit = 6, .prio_mask = 2, }, [71] = { .mask = IPIC_SIMSR_L, .prio = IPIC_SMPRR_B, .force = IPIC_SIFCR_L, .bit = 7, .prio_mask = 3, }, [72] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 8, }, [73] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 9, }, [74] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 10, }, [75] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 11, }, [76] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 12, }, [77] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 13, }, [78] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 14, }, [79] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 15, }, [80] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 16, }, [81] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 17, }, [82] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 18, }, [83] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 19, }, [84] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 20, }, [85] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 21, }, [86] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 22, }, [87] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 23, }, [88] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 24, }, [89] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 25, }, [90] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 26, }, [91] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 27, }, [94] = { .mask = IPIC_SIMSR_L, .prio = 0, .force = IPIC_SIFCR_L, .bit = 30, }, }; static inline u32 ipic_read(volatile u32 __iomem *base, unsigned int reg) { return in_be32(base + (reg >> 2)); } static inline void ipic_write(volatile u32 __iomem *base, unsigned int reg, u32 value) { out_be32(base + (reg >> 2), value); } static inline struct ipic * ipic_from_irq(unsigned int virq) { return primary_ipic; } static void ipic_unmask_irq(struct irq_data *d) { struct ipic *ipic = ipic_from_irq(d->irq); unsigned int src = irqd_to_hwirq(d); unsigned long flags; u32 temp; raw_spin_lock_irqsave(&ipic_lock, flags); temp = ipic_read(ipic->regs, ipic_info[src].mask); temp |= (1 << (31 - ipic_info[src].bit)); ipic_write(ipic->regs, ipic_info[src].mask, temp); raw_spin_unlock_irqrestore(&ipic_lock, flags); } static void ipic_mask_irq(struct irq_data *d) { struct ipic *ipic = ipic_from_irq(d->irq); unsigned int src = irqd_to_hwirq(d); unsigned long flags; u32 temp; raw_spin_lock_irqsave(&ipic_lock, flags); temp = ipic_read(ipic->regs, ipic_info[src].mask); temp &= ~(1 << (31 - ipic_info[src].bit)); ipic_write(ipic->regs, ipic_info[src].mask, temp); /* mb() can't guarantee that masking is finished. But it does finish * for nearly all cases. */ mb(); raw_spin_unlock_irqrestore(&ipic_lock, flags); } static void ipic_ack_irq(struct irq_data *d) { struct ipic *ipic = ipic_from_irq(d->irq); unsigned int src = irqd_to_hwirq(d); unsigned long flags; u32 temp; raw_spin_lock_irqsave(&ipic_lock, flags); temp = 1 << (31 - ipic_info[src].bit); ipic_write(ipic->regs, ipic_info[src].ack, temp); /* mb() can't guarantee that ack is finished. But it does finish * for nearly all cases. */ mb(); raw_spin_unlock_irqrestore(&ipic_lock, flags); } static void ipic_mask_irq_and_ack(struct irq_data *d) { struct ipic *ipic = ipic_from_irq(d->irq); unsigned int src = irqd_to_hwirq(d); unsigned long flags; u32 temp; raw_spin_lock_irqsave(&ipic_lock, flags); temp = ipic_read(ipic->regs, ipic_info[src].mask); temp &= ~(1 << (31 - ipic_info[src].bit)); ipic_write(ipic->regs, ipic_info[src].mask, temp); temp = 1 << (31 - ipic_info[src].bit); ipic_write(ipic->regs, ipic_info[src].ack, temp); /* mb() can't guarantee that ack is finished. But it does finish * for nearly all cases. */ mb(); raw_spin_unlock_irqrestore(&ipic_lock, flags); } static int ipic_set_irq_type(struct irq_data *d, unsigned int flow_type) { struct ipic *ipic = ipic_from_irq(d->irq); unsigned int src = irqd_to_hwirq(d); unsigned int vold, vnew, edibit; if (flow_type == IRQ_TYPE_NONE) flow_type = IRQ_TYPE_LEVEL_LOW; /* ipic supports only low assertion and high-to-low change senses */ if (!(flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING))) { printk(KERN_ERR "ipic: sense type 0x%x not supported\n", flow_type); return -EINVAL; } /* ipic supports only edge mode on external interrupts */ if ((flow_type & IRQ_TYPE_EDGE_FALLING) && !ipic_info[src].ack) { printk(KERN_ERR "ipic: edge sense not supported on internal " "interrupts\n"); return -EINVAL; } irqd_set_trigger_type(d, flow_type); if (flow_type & IRQ_TYPE_LEVEL_LOW) { __irq_set_handler_locked(d->irq, handle_level_irq); d->chip = &ipic_level_irq_chip; } else { __irq_set_handler_locked(d->irq, handle_edge_irq); d->chip = &ipic_edge_irq_chip; } /* only EXT IRQ senses are programmable on ipic * internal IRQ senses are LEVEL_LOW */ if (src == IPIC_IRQ_EXT0) edibit = 15; else if (src >= IPIC_IRQ_EXT1 && src <= IPIC_IRQ_EXT7) edibit = (14 - (src - IPIC_IRQ_EXT1)); else return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL; vold = ipic_read(ipic->regs, IPIC_SECNR); if ((flow_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_FALLING) { vnew = vold | (1 << edibit); } else { vnew = vold & ~(1 << edibit); } if (vold != vnew) ipic_write(ipic->regs, IPIC_SECNR, vnew); return IRQ_SET_MASK_OK_NOCOPY; } /* level interrupts and edge interrupts have different ack operations */ static struct irq_chip ipic_level_irq_chip = { .name = "IPIC", .irq_unmask = ipic_unmask_irq, .irq_mask = ipic_mask_irq, .irq_mask_ack = ipic_mask_irq, .irq_set_type = ipic_set_irq_type, }; static struct irq_chip ipic_edge_irq_chip = { .name = "IPIC", .irq_unmask = ipic_unmask_irq, .irq_mask = ipic_mask_irq, .irq_mask_ack = ipic_mask_irq_and_ack, .irq_ack = ipic_ack_irq, .irq_set_type = ipic_set_irq_type, }; static int ipic_host_match(struct irq_domain *h, struct device_node *node) { /* Exact match, unless ipic node is NULL */ return h->of_node == NULL || h->of_node == node; } static int ipic_host_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw) { struct ipic *ipic = h->host_data; irq_set_chip_data(virq, ipic); irq_set_chip_and_handler(virq, &ipic_level_irq_chip, handle_level_irq); /* Set default irq type */ irq_set_irq_type(virq, IRQ_TYPE_NONE); return 0; } static const struct irq_domain_ops ipic_host_ops = { .match = ipic_host_match, .map = ipic_host_map, .xlate = irq_domain_xlate_onetwocell, }; struct ipic * __init ipic_init(struct device_node *node, unsigned int flags) { struct ipic *ipic; struct resource res; u32 temp = 0, ret; ret = of_address_to_resource(node, 0, &res); if (ret) return NULL; ipic = kzalloc(sizeof(*ipic), GFP_KERNEL); if (ipic == NULL) return NULL; ipic->irqhost = irq_domain_add_linear(node, NR_IPIC_INTS, &ipic_host_ops, ipic); if (ipic->irqhost == NULL) { kfree(ipic); return NULL; } ipic->regs = ioremap(res.start, resource_size(&res)); /* init hw */ ipic_write(ipic->regs, IPIC_SICNR, 0x0); /* default priority scheme is grouped. If spread mode is required * configure SICFR accordingly */ if (flags & IPIC_SPREADMODE_GRP_A) temp |= SICFR_IPSA; if (flags & IPIC_SPREADMODE_GRP_B) temp |= SICFR_IPSB; if (flags & IPIC_SPREADMODE_GRP_C) temp |= SICFR_IPSC; if (flags & IPIC_SPREADMODE_GRP_D) temp |= SICFR_IPSD; if (flags & IPIC_SPREADMODE_MIX_A) temp |= SICFR_MPSA; if (flags & IPIC_SPREADMODE_MIX_B) temp |= SICFR_MPSB; ipic_write(ipic->regs, IPIC_SICFR, temp); /* handle MCP route */ temp = 0; if (flags & IPIC_DISABLE_MCP_OUT) temp = SERCR_MCPR; ipic_write(ipic->regs, IPIC_SERCR, temp); /* handle routing of IRQ0 to MCP */ temp = ipic_read(ipic->regs, IPIC_SEMSR); if (flags & IPIC_IRQ0_MCP) temp |= SEMSR_SIRQ0; else temp &= ~SEMSR_SIRQ0; ipic_write(ipic->regs, IPIC_SEMSR, temp); primary_ipic = ipic; irq_set_default_host(primary_ipic->irqhost); ipic_write(ipic->regs, IPIC_SIMSR_H, 0); ipic_write(ipic->regs, IPIC_SIMSR_L, 0); printk ("IPIC (%d IRQ sources) at %p\n", NR_IPIC_INTS, primary_ipic->regs); return ipic; } int ipic_set_priority(unsigned int virq, unsigned int priority) { struct ipic *ipic = ipic_from_irq(virq); unsigned int src = virq_to_hw(virq); u32 temp; if (priority > 7) return -EINVAL; if (src > 127) return -EINVAL; if (ipic_info[src].prio == 0) return -EINVAL; temp = ipic_read(ipic->regs, ipic_info[src].prio); if (priority < 4) { temp &= ~(0x7 << (20 + (3 - priority) * 3)); temp |= ipic_info[src].prio_mask << (20 + (3 - priority) * 3); } else { temp &= ~(0x7 << (4 + (7 - priority) * 3)); temp |= ipic_info[src].prio_mask << (4 + (7 - priority) * 3); } ipic_write(ipic->regs, ipic_info[src].prio, temp); return 0; } void ipic_set_highest_priority(unsigned int virq) { struct ipic *ipic = ipic_from_irq(virq); unsigned int src = virq_to_hw(virq); u32 temp; temp = ipic_read(ipic->regs, IPIC_SICFR); /* clear and set HPI */ temp &= 0x7f000000; temp |= (src & 0x7f) << 24; ipic_write(ipic->regs, IPIC_SICFR, temp); } void ipic_set_default_priority(void) { ipic_write(primary_ipic->regs, IPIC_SIPRR_A, IPIC_PRIORITY_DEFAULT); ipic_write(primary_ipic->regs, IPIC_SIPRR_B, IPIC_PRIORITY_DEFAULT); ipic_write(primary_ipic->regs, IPIC_SIPRR_C, IPIC_PRIORITY_DEFAULT); ipic_write(primary_ipic->regs, IPIC_SIPRR_D, IPIC_PRIORITY_DEFAULT); ipic_write(primary_ipic->regs, IPIC_SMPRR_A, IPIC_PRIORITY_DEFAULT); ipic_write(primary_ipic->regs, IPIC_SMPRR_B, IPIC_PRIORITY_DEFAULT); } void ipic_enable_mcp(enum ipic_mcp_irq mcp_irq) { struct ipic *ipic = primary_ipic; u32 temp; temp = ipic_read(ipic->regs, IPIC_SERMR); temp |= (1 << (31 - mcp_irq)); ipic_write(ipic->regs, IPIC_SERMR, temp); } void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq) { struct ipic *ipic = primary_ipic; u32 temp; temp = ipic_read(ipic->regs, IPIC_SERMR); temp &= (1 << (31 - mcp_irq)); ipic_write(ipic->regs, IPIC_SERMR, temp); } u32 ipic_get_mcp_status(void) { return ipic_read(primary_ipic->regs, IPIC_SERMR); } void ipic_clear_mcp_status(u32 mask) { ipic_write(primary_ipic->regs, IPIC_SERMR, mask); } /* Return an interrupt vector or NO_IRQ if no interrupt is pending. */ unsigned int ipic_get_irq(void) { int irq; BUG_ON(primary_ipic == NULL); #define IPIC_SIVCR_VECTOR_MASK 0x7f irq = ipic_read(primary_ipic->regs, IPIC_SIVCR) & IPIC_SIVCR_VECTOR_MASK; if (irq == 0) /* 0 --> no irq is pending */ return NO_IRQ; return irq_linear_revmap(primary_ipic->irqhost, irq); } #ifdef CONFIG_SUSPEND static struct { u32 sicfr; u32 siprr[2]; u32 simsr[2]; u32 sicnr; u32 smprr[2]; u32 semsr; u32 secnr; u32 sermr; u32 sercr; } ipic_saved_state; static int ipic_suspend(void) { struct ipic *ipic = primary_ipic; ipic_saved_state.sicfr = ipic_read(ipic->regs, IPIC_SICFR); ipic_saved_state.siprr[0] = ipic_read(ipic->regs, IPIC_SIPRR_A); ipic_saved_state.siprr[1] = ipic_read(ipic->regs, IPIC_SIPRR_D); ipic_saved_state.simsr[0] = ipic_read(ipic->regs, IPIC_SIMSR_H); ipic_saved_state.simsr[1] = ipic_read(ipic->regs, IPIC_SIMSR_L); ipic_saved_state.sicnr = ipic_read(ipic->regs, IPIC_SICNR); ipic_saved_state.smprr[0] = ipic_read(ipic->regs, IPIC_SMPRR_A); ipic_saved_state.smprr[1] = ipic_read(ipic->regs, IPIC_SMPRR_B); ipic_saved_state.semsr = ipic_read(ipic->regs, IPIC_SEMSR); ipic_saved_state.secnr = ipic_read(ipic->regs, IPIC_SECNR); ipic_saved_state.sermr = ipic_read(ipic->regs, IPIC_SERMR); ipic_saved_state.sercr = ipic_read(ipic->regs, IPIC_SERCR); if (fsl_deep_sleep()) { /* In deep sleep, make sure there can be no * pending interrupts, as this can cause * problems on 831x. */ ipic_write(ipic->regs, IPIC_SIMSR_H, 0); ipic_write(ipic->regs, IPIC_SIMSR_L, 0); ipic_write(ipic->regs, IPIC_SEMSR, 0); ipic_write(ipic->regs, IPIC_SERMR, 0); } return 0; } static void ipic_resume(void) { struct ipic *ipic = primary_ipic; ipic_write(ipic->regs, IPIC_SICFR, ipic_saved_state.sicfr); ipic_write(ipic->regs, IPIC_SIPRR_A, ipic_saved_state.siprr[0]); ipic_write(ipic->regs, IPIC_SIPRR_D, ipic_saved_state.siprr[1]); ipic_write(ipic->regs, IPIC_SIMSR_H, ipic_saved_state.simsr[0]); ipic_write(ipic->regs, IPIC_SIMSR_L, ipic_saved_state.simsr[1]); ipic_write(ipic->regs, IPIC_SICNR, ipic_saved_state.sicnr); ipic_write(ipic->regs, IPIC_SMPRR_A, ipic_saved_state.smprr[0]); ipic_write(ipic->regs, IPIC_SMPRR_B, ipic_saved_state.smprr[1]); ipic_write(ipic->regs, IPIC_SEMSR, ipic_saved_state.semsr); ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr); ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr); ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr); } #else #define ipic_suspend NULL #define ipic_resume NULL #endif static struct syscore_ops ipic_syscore_ops = { .suspend = ipic_suspend, .resume = ipic_resume, }; static int __init init_ipic_syscore(void) { if (!primary_ipic || !primary_ipic->regs) return -ENODEV; printk(KERN_DEBUG "Registering ipic system core operations\n"); register_syscore_ops(&ipic_syscore_ops); return 0; } subsys_initcall(init_ipic_syscore);
<?php /** * @file * Contains \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest. */ namespace Drupal\Tests\Core\Database\Driver\pgsql; use Drupal\Core\Database\Driver\pgsql\Schema; use Drupal\Tests\UnitTestCase; /** * @coversDefaultClass \Drupal\Core\Database\Driver\pgsql\Schema * @group Database */ class PostgresqlSchemaTest extends UnitTestCase { /** * The PostgreSql DB connection. * * @var \PHPUnit_Framework_MockObject_MockObject|\Drupal\Core\Database\Driver\pgsql\Connection */ protected $connection; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->connection = $this->getMockBuilder('\Drupal\Core\Database\Driver\pgsql\Connection') ->disableOriginalConstructor() ->getMock(); } /** * Tests whether the actual constraint name is correctly computed. * * @param string $table_name * The table name the constrained column belongs to. * @param string $name * The constraint name. * @param string $expected * The expected computed constraint name. * * @covers ::constraintExists * @dataProvider providerComputedConstraintName */ public function testComputedConstraintName($table_name, $name, $expected) { $max_identifier_length = 63; $schema = new Schema($this->connection); $statement = $this->getMock('\Drupal\Core\Database\StatementInterface'); $statement->expects($this->any()) ->method('fetchField') ->willReturn($max_identifier_length); $this->connection->expects($this->any()) ->method('query') ->willReturn($statement); $this->connection->expects($this->at(2)) ->method('query') ->with("SELECT 1 FROM pg_constraint WHERE conname = '$expected'") ->willReturn($this->getMock('\Drupal\Core\Database\StatementInterface')); $schema->constraintExists($table_name, $name); } /** * Data provider for ::testComputedConstraintName(). */ public function providerComputedConstraintName() { return [ ['user_field_data', 'pkey', 'user_field_data____pkey'], ['user_field_data', 'name__key', 'user_field_data__name__key'], ['user_field_data', 'a_veeeery_veery_very_super_long_field_name__key', 'drupal_BGGYAXgbqlAF1rMOyFTdZGj9zIMXZtSvEjMAKZ9wGIk_key'], ]; } }
obj-$(CONFIG_PANEL_GENERIC_DPI) += panel-generic-dpi.o obj-$(CONFIG_PANEL_TFP410) += panel-tfp410.o obj-$(CONFIG_PANEL_LGPHILIPS_LB035Q02) += panel-lgphilips-lb035q02.o obj-$(CONFIG_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o obj-$(CONFIG_PANEL_NEC_NL8048HL11_01B) += panel-nec-nl8048hl11-01b.o obj-$(CONFIG_PANEL_TAAL) += panel-taal.o obj-$(CONFIG_PANEL_PICODLP) += panel-picodlp.o obj-$(CONFIG_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o obj-$(CONFIG_PANEL_ACX565AKM) += panel-acx565akm.o obj-$(CONFIG_PANEL_N8X0) += panel-n8x0.o
#ifndef _ASMPPC_SIGNAL_H #define _ASMPPC_SIGNAL_H #include <linux/types.h> /* Avoid too many header ordering problems. */ struct siginfo; /* Most things should be clean enough to redefine this at will, if care is taken to make libc match. */ #define _NSIG 64 #define _NSIG_BPW 32 #define _NSIG_WORDS (_NSIG / _NSIG_BPW) typedef unsigned long old_sigset_t; /* at least 32 bits */ typedef struct { unsigned long sig[_NSIG_WORDS]; } sigset_t; #define SIGHUP 1 #define SIGINT 2 #define SIGQUIT 3 #define SIGILL 4 #define SIGTRAP 5 #define SIGABRT 6 #define SIGIOT 6 #define SIGBUS 7 #define SIGFPE 8 #define SIGKILL 9 #define SIGUSR1 10 #define SIGSEGV 11 #define SIGUSR2 12 #define SIGPIPE 13 #define SIGALRM 14 #define SIGTERM 15 #define SIGSTKFLT 16 #define SIGCHLD 17 #define SIGCONT 18 #define SIGSTOP 19 #define SIGTSTP 20 #define SIGTTIN 21 #define SIGTTOU 22 #define SIGURG 23 #define SIGXCPU 24 #define SIGXFSZ 25 #define SIGVTALRM 26 #define SIGPROF 27 #define SIGWINCH 28 #define SIGIO 29 #define SIGPOLL SIGIO /* #define SIGLOST 29 */ #define SIGPWR 30 #define SIGSYS 31 #define SIGUNUSED 31 /* These should not be considered constants from userland. */ #define SIGRTMIN 32 #define SIGRTMAX (_NSIG-1) /* * SA_FLAGS values: * * SA_ONSTACK is not currently supported, but will allow sigaltstack(2). * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the * SA_RESTART flag to get restarting signals (which were the default long ago) * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. * SA_RESETHAND clears the handler when the signal is delivered. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. * SA_NODEFER prevents the current signal from being masked in the handler. * * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single * Unix names RESETHAND and NODEFER respectively. */ #define SA_NOCLDSTOP 0x00000001 #define SA_NOCLDWAIT 0x00000002 /* not supported yet */ #define SA_SIGINFO 0x00000004 #define SA_ONSTACK 0x08000000 #define SA_RESTART 0x10000000 #define SA_NODEFER 0x40000000 #define SA_RESETHAND 0x80000000 #define SA_NOMASK SA_NODEFER #define SA_ONESHOT SA_RESETHAND #define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ #define SA_RESTORER 0x04000000 /* * sigaltstack controls */ #define SS_ONSTACK 1 #define SS_DISABLE 2 #define MINSIGSTKSZ 2048 #define SIGSTKSZ 8192 #ifdef __KERNEL__ /* * These values of sa_flags are used only by the kernel as part of the * irq handling routines. * * SA_INTERRUPT is also used by the irq handling routines. * SA_SHIRQ is for shared interrupt support on PCI and EISA. */ #define SA_PROBE SA_ONESHOT #define SA_SAMPLE_RANDOM SA_RESTART #define SA_SHIRQ 0x04000000 #endif #define SIG_BLOCK 0 /* for blocking signals */ #define SIG_UNBLOCK 1 /* for unblocking signals */ #define SIG_SETMASK 2 /* for setting the signal mask */ /* Type of a signal handler. */ typedef void (*__sighandler_t)(int); #define SIG_DFL ((__sighandler_t)0) /* default signal handling */ #define SIG_IGN ((__sighandler_t)1) /* ignore signal */ #define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ struct old_sigaction { __sighandler_t sa_handler; old_sigset_t sa_mask; unsigned long sa_flags; void (*sa_restorer)(void); }; struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; void (*sa_restorer)(void); sigset_t sa_mask; /* mask last for extensibility */ }; struct k_sigaction { struct sigaction sa; }; typedef struct sigaltstack { void *ss_sp; int ss_flags; size_t ss_size; } stack_t; #ifdef __KERNEL__ #include <asm/sigcontext.h> #endif #endif
# SPDX-License-Identifier: GPL-2.0 # # Makefile for MIPS crypto files.. # obj-$(CONFIG_CRYPTO_CRC32_MIPS) += crc32-mips.o
/***************************************************************************/ /* */ /* afangles.c */ /* */ /* Routines used to compute vector angles with limited accuracy */ /* and very high speed. It also contains sorting routines (body). */ /* */ /* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "aftypes.h" #if 0 FT_LOCAL_DEF( FT_Int ) af_corner_is_flat( FT_Pos x_in, FT_Pos y_in, FT_Pos x_out, FT_Pos y_out ) { FT_Pos ax = x_in; FT_Pos ay = y_in; FT_Pos d_in, d_out, d_corner; if ( ax < 0 ) ax = -ax; if ( ay < 0 ) ay = -ay; d_in = ax + ay; ax = x_out; if ( ax < 0 ) ax = -ax; ay = y_out; if ( ay < 0 ) ay = -ay; d_out = ax + ay; ax = x_out + x_in; if ( ax < 0 ) ax = -ax; ay = y_out + y_in; if ( ay < 0 ) ay = -ay; d_corner = ax + ay; return ( d_in + d_out - d_corner ) < ( d_corner >> 4 ); } FT_LOCAL_DEF( FT_Int ) af_corner_orientation( FT_Pos x_in, FT_Pos y_in, FT_Pos x_out, FT_Pos y_out ) { FT_Pos delta; delta = x_in * y_out - y_in * x_out; if ( delta == 0 ) return 0; else return 1 - 2 * ( delta < 0 ); } #endif /* * We are not using `af_angle_atan' anymore, but we keep the source * code below just in case... */ #if 0 /* * The trick here is to realize that we don't need a very accurate angle * approximation. We are going to use the result of `af_angle_atan' to * only compare the sign of angle differences, or check whether its * magnitude is very small. * * The approximation * * dy * PI / (|dx|+|dy|) * * should be enough, and much faster to compute. */ FT_LOCAL_DEF( AF_Angle ) af_angle_atan( FT_Fixed dx, FT_Fixed dy ) { AF_Angle angle; FT_Fixed ax = dx; FT_Fixed ay = dy; if ( ax < 0 ) ax = -ax; if ( ay < 0 ) ay = -ay; ax += ay; if ( ax == 0 ) angle = 0; else { angle = ( AF_ANGLE_PI2 * dy ) / ( ax + ay ); if ( dx < 0 ) { if ( angle >= 0 ) angle = AF_ANGLE_PI - angle; else angle = -AF_ANGLE_PI - angle; } } return angle; } #elif 0 /* the following table has been automatically generated with */ /* the `mather.py' Python script */ #define AF_ATAN_BITS 8 static const FT_Byte af_arctan[1L << AF_ATAN_BITS] = { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64 }; FT_LOCAL_DEF( AF_Angle ) af_angle_atan( FT_Fixed dx, FT_Fixed dy ) { AF_Angle angle; /* check trivial cases */ if ( dy == 0 ) { angle = 0; if ( dx < 0 ) angle = AF_ANGLE_PI; return angle; } else if ( dx == 0 ) { angle = AF_ANGLE_PI2; if ( dy < 0 ) angle = -AF_ANGLE_PI2; return angle; } angle = 0; if ( dx < 0 ) { dx = -dx; dy = -dy; angle = AF_ANGLE_PI; } if ( dy < 0 ) { FT_Pos tmp; tmp = dx; dx = -dy; dy = tmp; angle -= AF_ANGLE_PI2; } if ( dx == 0 && dy == 0 ) return 0; if ( dx == dy ) angle += AF_ANGLE_PI4; else if ( dx > dy ) angle += af_arctan[FT_DivFix( dy, dx ) >> ( 16 - AF_ATAN_BITS )]; else angle += AF_ANGLE_PI2 - af_arctan[FT_DivFix( dx, dy ) >> ( 16 - AF_ATAN_BITS )]; if ( angle > AF_ANGLE_PI ) angle -= AF_ANGLE_2PI; return angle; } #endif /* 0 */ FT_LOCAL_DEF( void ) af_sort_pos( FT_UInt count, FT_Pos* table ) { FT_UInt i, j; FT_Pos swap; for ( i = 1; i < count; i++ ) { for ( j = i; j > 0; j-- ) { if ( table[j] > table[j - 1] ) break; swap = table[j]; table[j] = table[j - 1]; table[j - 1] = swap; } } } FT_LOCAL_DEF( void ) af_sort_widths( FT_UInt count, AF_Width table ) { FT_UInt i, j; AF_WidthRec swap; for ( i = 1; i < count; i++ ) { for ( j = i; j > 0; j-- ) { if ( table[j].org > table[j - 1].org ) break; swap = table[j]; table[j] = table[j - 1]; table[j - 1] = swap; } } } /* END */
/* -*- mode: c; c-basic-offset: 8; -*- * vim: noexpandtab sw=8 ts=8 sts=0: * * dlmglue.h * * description here * * Copyright (C) 2002, 2004 Oracle. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 021110-1307, USA. */ #ifndef DLMGLUE_H #define DLMGLUE_H #include "dcache.h" #define OCFS2_LVB_VERSION 5 struct ocfs2_meta_lvb { __u8 lvb_version; __u8 lvb_reserved0; __be16 lvb_idynfeatures; __be32 lvb_iclusters; __be32 lvb_iuid; __be32 lvb_igid; __be64 lvb_iatime_packed; __be64 lvb_ictime_packed; __be64 lvb_imtime_packed; __be64 lvb_isize; __be16 lvb_imode; __be16 lvb_inlink; __be32 lvb_iattr; __be32 lvb_igeneration; __be32 lvb_reserved2; }; #define OCFS2_QINFO_LVB_VERSION 1 struct ocfs2_qinfo_lvb { __u8 lvb_version; __u8 lvb_reserved[3]; __be32 lvb_bgrace; __be32 lvb_igrace; __be32 lvb_syncms; __be32 lvb_blocks; __be32 lvb_free_blk; __be32 lvb_free_entry; }; #define OCFS2_ORPHAN_LVB_VERSION 1 struct ocfs2_orphan_scan_lvb { __u8 lvb_version; __u8 lvb_reserved[3]; __be32 lvb_os_seqno; }; struct ocfs2_lock_holder { struct list_head oh_list; struct pid *oh_owner_pid; }; /* ocfs2_inode_lock_full() 'arg_flags' flags */ /* don't wait on recovery. */ #define OCFS2_META_LOCK_RECOVERY (0x01) /* Instruct the dlm not to queue ourselves on the other node. */ #define OCFS2_META_LOCK_NOQUEUE (0x02) /* don't block waiting for the downconvert thread, instead return -EAGAIN */ #define OCFS2_LOCK_NONBLOCK (0x04) /* just get back disk inode bh if we've got cluster lock. */ #define OCFS2_META_LOCK_GETBH (0x08) /* Locking subclasses of inode cluster lock */ enum { OI_LS_NORMAL = 0, OI_LS_PARENT, OI_LS_RENAME1, OI_LS_RENAME2, OI_LS_REFLINK_TARGET, }; int ocfs2_dlm_init(struct ocfs2_super *osb); void ocfs2_dlm_shutdown(struct ocfs2_super *osb, int hangup_pending); void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res); void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, enum ocfs2_lock_type type, unsigned int generation, struct inode *inode); void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, u64 parent, struct inode *inode); struct ocfs2_file_private; void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, struct ocfs2_file_private *fp); struct ocfs2_mem_dqinfo; void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres, struct ocfs2_mem_dqinfo *info); void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, struct ocfs2_super *osb, u64 ref_blkno, unsigned int generation); void ocfs2_lock_res_free(struct ocfs2_lock_res *res); int ocfs2_create_new_inode_locks(struct inode *inode); int ocfs2_drop_inode_locks(struct inode *inode); int ocfs2_rw_lock(struct inode *inode, int write); void ocfs2_rw_unlock(struct inode *inode, int write); int ocfs2_open_lock(struct inode *inode); int ocfs2_try_open_lock(struct inode *inode, int write); void ocfs2_open_unlock(struct inode *inode); int ocfs2_inode_lock_atime(struct inode *inode, struct vfsmount *vfsmnt, int *level); int ocfs2_inode_lock_full_nested(struct inode *inode, struct buffer_head **ret_bh, int ex, int arg_flags, int subclass); int ocfs2_inode_lock_with_page(struct inode *inode, struct buffer_head **ret_bh, int ex, struct page *page); /* Variants without special locking class or flags */ #define ocfs2_inode_lock_full(i, r, e, f)\ ocfs2_inode_lock_full_nested(i, r, e, f, OI_LS_NORMAL) #define ocfs2_inode_lock_nested(i, b, e, s)\ ocfs2_inode_lock_full_nested(i, b, e, 0, s) /* 99% of the time we don't want to supply any additional flags -- * those are for very specific cases only. */ #define ocfs2_inode_lock(i, b, e) ocfs2_inode_lock_full_nested(i, b, e, 0, OI_LS_NORMAL) void ocfs2_inode_unlock(struct inode *inode, int ex); int ocfs2_super_lock(struct ocfs2_super *osb, int ex); void ocfs2_super_unlock(struct ocfs2_super *osb, int ex); int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno); void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno); int ocfs2_rename_lock(struct ocfs2_super *osb); void ocfs2_rename_unlock(struct ocfs2_super *osb); int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex); void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex); int ocfs2_dentry_lock(struct dentry *dentry, int ex); void ocfs2_dentry_unlock(struct dentry *dentry, int ex); int ocfs2_file_lock(struct file *file, int ex, int trylock); void ocfs2_file_unlock(struct file *file); int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex); void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex); struct ocfs2_refcount_tree; int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex); void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex); void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb, struct ocfs2_lock_res *lockres); void ocfs2_simple_drop_lockres(struct ocfs2_super *osb, struct ocfs2_lock_res *lockres); /* for the downconvert thread */ void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb); struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void); void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug); /* To set the locking protocol on module initialization */ void ocfs2_set_locking_protocol(void); /* The _tracker pair is used to avoid cluster recursive locking */ int ocfs2_inode_lock_tracker(struct inode *inode, struct buffer_head **ret_bh, int ex, struct ocfs2_lock_holder *oh); void ocfs2_inode_unlock_tracker(struct inode *inode, int ex, struct ocfs2_lock_holder *oh, int had_lock); #endif /* DLMGLUE_H */
<!DOCTYPE html> <html><head> <title> scheduler: event listener defined by script in a document in history</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="testlib/testlib.js"></script> </head> <body> <div id="log">FAILED (This TC requires JavaScript enabled)</div> <iframe src="about:blank"></iframe> <script> log('inline script #1'); function fireFooEvent(){ var evt=document.createEvent('Event'); evt.initEvent('foo', true, true); document.dispatchEvent(evt); } var doc = frames[0].document; doc.open('text/html'); doc.write('<script>top.log("IFRAME script");top.document.addEventListener("foo", function(e){ top.log("event: "+e.type); }, false)<\/script>'); log('end script #1'); </script> <script> fireFooEvent(); frames[0].location='about:blank'; // returning to about:blank should de-activate document that defined event listener..? </script> <script> fireFooEvent(); </script> <script type="text/javascript"> log( 'inline script #2' ); var t = async_test() function test() { assert_equals(frames[0].location.toString(), "about:blank"); assert_array_equals(eventOrder, ['inline script #1', 'IFRAME script', 'end script #1', 'event: foo', 'inline script #2' ]); t.done(); } onload = function() {setTimeout(t.step_func(function() {fireFooEvent(); test()}), 80)}; </script> </body></html>
/* * linux/kernel/ptrace.c * * (C) Copyright 1999 Linus Torvalds * * Common interfaces for "ptrace()" which we do not want * to continually duplicate across every architecture. */ #include <linux/capability.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/errno.h> #include <linux/mm.h> #include <linux/highmem.h> #include <linux/pagemap.h> #include <linux/ptrace.h> #include <linux/security.h> #include <linux/signal.h> #include <linux/uio.h> #include <linux/audit.h> #include <linux/pid_namespace.h> #include <linux/syscalls.h> #include <linux/uaccess.h> #include <linux/regset.h> #include <linux/hw_breakpoint.h> #include <linux/cn_proc.h> #include <linux/compat.h> static int ptrace_trapping_sleep_fn(void *flags) { schedule(); return 0; } /* * ptrace a task: make the debugger its new parent and * move it to the ptrace list. * * Must be called with the tasklist lock write-held. */ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) { BUG_ON(!list_empty(&child->ptrace_entry)); list_add(&child->ptrace_entry, &new_parent->ptraced); child->parent = new_parent; } /** * __ptrace_unlink - unlink ptracee and restore its execution state * @child: ptracee to be unlinked * * Remove @child from the ptrace list, move it back to the original parent, * and restore the execution state so that it conforms to the group stop * state. * * Unlinking can happen via two paths - explicit PTRACE_DETACH or ptracer * exiting. For PTRACE_DETACH, unless the ptracee has been killed between * ptrace_check_attach() and here, it's guaranteed to be in TASK_TRACED. * If the ptracer is exiting, the ptracee can be in any state. * * After detach, the ptracee should be in a state which conforms to the * group stop. If the group is stopped or in the process of stopping, the * ptracee should be put into TASK_STOPPED; otherwise, it should be woken * up from TASK_TRACED. * * If the ptracee is in TASK_TRACED and needs to be moved to TASK_STOPPED, * it goes through TRACED -> RUNNING -> STOPPED transition which is similar * to but in the opposite direction of what happens while attaching to a * stopped task. However, in this direction, the intermediate RUNNING * state is not hidden even from the current ptracer and if it immediately * re-attaches and performs a WNOHANG wait(2), it may fail. * * CONTEXT: * write_lock_irq(tasklist_lock) */ void __ptrace_unlink(struct task_struct *child) { BUG_ON(!child->ptrace); child->ptrace = 0; child->parent = child->real_parent; list_del_init(&child->ptrace_entry); spin_lock(&child->sighand->siglock); /* * Clear all pending traps and TRAPPING. TRAPPING should be * cleared regardless of JOBCTL_STOP_PENDING. Do it explicitly. */ task_clear_jobctl_pending(child, JOBCTL_TRAP_MASK); task_clear_jobctl_trapping(child); /* * Reinstate JOBCTL_STOP_PENDING if group stop is in effect and * @child isn't dead. */ if (!(child->flags & PF_EXITING) && (child->signal->flags & SIGNAL_STOP_STOPPED || child->signal->group_stop_count)) { child->jobctl |= JOBCTL_STOP_PENDING; /* * This is only possible if this thread was cloned by the * traced task running in the stopped group, set the signal * for the future reports. * FIXME: we should change ptrace_init_task() to handle this * case. */ if (!(child->jobctl & JOBCTL_STOP_SIGMASK)) child->jobctl |= SIGSTOP; } /* * If transition to TASK_STOPPED is pending or in TASK_TRACED, kick * @child in the butt. Note that @resume should be used iff @child * is in TASK_TRACED; otherwise, we might unduly disrupt * TASK_KILLABLE sleeps. */ if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child)) ptrace_signal_wake_up(child, true); spin_unlock(&child->sighand->siglock); } /* Ensure that nothing can wake it up, even SIGKILL */ static bool ptrace_freeze_traced(struct task_struct *task) { bool ret = false; /* Lockless, nobody but us can set this flag */ if (task->jobctl & JOBCTL_LISTENING) return ret; spin_lock_irq(&task->sighand->siglock); if (task_is_traced(task) && !__fatal_signal_pending(task)) { task->state = __TASK_TRACED; ret = true; } spin_unlock_irq(&task->sighand->siglock); return ret; } static void ptrace_unfreeze_traced(struct task_struct *task) { if (task->state != __TASK_TRACED) return; WARN_ON(!task->ptrace || task->parent != current); spin_lock_irq(&task->sighand->siglock); if (__fatal_signal_pending(task)) wake_up_state(task, __TASK_TRACED); else task->state = TASK_TRACED; spin_unlock_irq(&task->sighand->siglock); } /** * ptrace_check_attach - check whether ptracee is ready for ptrace operation * @child: ptracee to check for * @ignore_state: don't check whether @child is currently %TASK_TRACED * * Check whether @child is being ptraced by %current and ready for further * ptrace operations. If @ignore_state is %false, @child also should be in * %TASK_TRACED state and on return the child is guaranteed to be traced * and not executing. If @ignore_state is %true, @child can be in any * state. * * CONTEXT: * Grabs and releases tasklist_lock and @child->sighand->siglock. * * RETURNS: * 0 on success, -ESRCH if %child is not ready. */ static int ptrace_check_attach(struct task_struct *child, bool ignore_state) { int ret = -ESRCH; /* * We take the read lock around doing both checks to close a * possible race where someone else was tracing our child and * detached between these two checks. After this locked check, * we are sure that this is our traced child and that can only * be changed by us so it's not changing right after this. */ read_lock(&tasklist_lock); if (child->ptrace && child->parent == current) { WARN_ON(child->state == __TASK_TRACED); /* * child->sighand can't be NULL, release_task() * does ptrace_unlink() before __exit_signal(). */ if (ignore_state || ptrace_freeze_traced(child)) ret = 0; } read_unlock(&tasklist_lock); if (!ret && !ignore_state) { if (!wait_task_inactive(child, __TASK_TRACED)) { /* * This can only happen if may_ptrace_stop() fails and * ptrace_stop() changes ->state back to TASK_RUNNING, * so we should not worry about leaking __TASK_TRACED. */ WARN_ON(child->state == __TASK_TRACED); ret = -ESRCH; } } return ret; } static int ptrace_has_cap(struct user_namespace *ns, unsigned int mode) { if (mode & PTRACE_MODE_NOAUDIT) return has_ns_capability_noaudit(current, ns, CAP_SYS_PTRACE); else return has_ns_capability(current, ns, CAP_SYS_PTRACE); } /* Returns 0 on success, -errno on denial. */ static int __ptrace_may_access(struct task_struct *task, unsigned int mode) { const struct cred *cred = current_cred(), *tcred; /* May we inspect the given task? * This check is used both for attaching with ptrace * and for allowing access to sensitive information in /proc. * * ptrace_attach denies several cases that /proc allows * because setting up the necessary parent/child relationship * or halting the specified task is impossible. */ int dumpable = 0; /* Don't let security modules deny introspection */ if (task == current) return 0; rcu_read_lock(); tcred = __task_cred(task); if (uid_eq(cred->uid, tcred->euid) && uid_eq(cred->uid, tcred->suid) && uid_eq(cred->uid, tcred->uid) && gid_eq(cred->gid, tcred->egid) && gid_eq(cred->gid, tcred->sgid) && gid_eq(cred->gid, tcred->gid)) goto ok; if (ptrace_has_cap(tcred->user_ns, mode)) goto ok; rcu_read_unlock(); return -EPERM; ok: rcu_read_unlock(); smp_rmb(); if (task->mm) dumpable = get_dumpable(task->mm); rcu_read_lock(); if (dumpable != SUID_DUMP_USER && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) { rcu_read_unlock(); return -EPERM; } rcu_read_unlock(); return security_ptrace_access_check(task, mode); } bool ptrace_may_access(struct task_struct *task, unsigned int mode) { int err; task_lock(task); err = __ptrace_may_access(task, mode); task_unlock(task); return !err; } static int ptrace_attach(struct task_struct *task, long request, unsigned long addr, unsigned long flags) { bool seize = (request == PTRACE_SEIZE); int retval; retval = -EIO; if (seize) { if (addr != 0) goto out; if (flags & ~(unsigned long)PTRACE_O_MASK) goto out; flags = PT_PTRACED | PT_SEIZED | (flags << PT_OPT_FLAG_SHIFT); } else { flags = PT_PTRACED; } audit_ptrace(task); retval = -EPERM; if (unlikely(task->flags & PF_KTHREAD)) goto out; if (same_thread_group(task, current)) goto out; /* * Protect exec's credential calculations against our interference; * SUID, SGID and LSM creds get determined differently * under ptrace. */ retval = -ERESTARTNOINTR; if (mutex_lock_interruptible(&task->signal->cred_guard_mutex)) goto out; task_lock(task); retval = __ptrace_may_access(task, PTRACE_MODE_ATTACH); task_unlock(task); if (retval) goto unlock_creds; write_lock_irq(&tasklist_lock); retval = -EPERM; if (unlikely(task->exit_state)) goto unlock_tasklist; if (task->ptrace) goto unlock_tasklist; if (seize) flags |= PT_SEIZED; rcu_read_lock(); if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE)) flags |= PT_PTRACE_CAP; rcu_read_unlock(); task->ptrace = flags; __ptrace_link(task, current); /* SEIZE doesn't trap tracee on attach */ if (!seize) send_sig_info(SIGSTOP, SEND_SIG_FORCED, task); spin_lock(&task->sighand->siglock); /* * If the task is already STOPPED, set JOBCTL_TRAP_STOP and * TRAPPING, and kick it so that it transits to TRACED. TRAPPING * will be cleared if the child completes the transition or any * event which clears the group stop states happens. We'll wait * for the transition to complete before returning from this * function. * * This hides STOPPED -> RUNNING -> TRACED transition from the * attaching thread but a different thread in the same group can * still observe the transient RUNNING state. IOW, if another * thread's WNOHANG wait(2) on the stopped tracee races against * ATTACH, the wait(2) may fail due to the transient RUNNING. * * The following task_is_stopped() test is safe as both transitions * in and out of STOPPED are protected by siglock. */ if (task_is_stopped(task) && task_set_jobctl_pending(task, JOBCTL_TRAP_STOP | JOBCTL_TRAPPING)) signal_wake_up_state(task, __TASK_STOPPED); spin_unlock(&task->sighand->siglock); retval = 0; unlock_tasklist: write_unlock_irq(&tasklist_lock); unlock_creds: mutex_unlock(&task->signal->cred_guard_mutex); out: if (!retval) { wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT, ptrace_trapping_sleep_fn, TASK_UNINTERRUPTIBLE); proc_ptrace_connector(task, PTRACE_ATTACH); } return retval; } /** * ptrace_traceme -- helper for PTRACE_TRACEME * * Performs checks and sets PT_PTRACED. * Should be used by all ptrace implementations for PTRACE_TRACEME. */ static int ptrace_traceme(void) { int ret = -EPERM; write_lock_irq(&tasklist_lock); /* Are we already being traced? */ if (!current->ptrace) { ret = security_ptrace_traceme(current->parent); /* * Check PF_EXITING to ensure ->real_parent has not passed * exit_ptrace(). Otherwise we don't report the error but * pretend ->real_parent untraces us right after return. */ if (!ret && !(current->real_parent->flags & PF_EXITING)) { current->ptrace = PT_PTRACED; __ptrace_link(current, current->real_parent); } } write_unlock_irq(&tasklist_lock); return ret; } /* * Called with irqs disabled, returns true if childs should reap themselves. */ static int ignoring_children(struct sighand_struct *sigh) { int ret; spin_lock(&sigh->siglock); ret = (sigh->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) || (sigh->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT); spin_unlock(&sigh->siglock); return ret; } /* * Called with tasklist_lock held for writing. * Unlink a traced task, and clean it up if it was a traced zombie. * Return true if it needs to be reaped with release_task(). * (We can't call release_task() here because we already hold tasklist_lock.) * * If it's a zombie, our attachedness prevented normal parent notification * or self-reaping. Do notification now if it would have happened earlier. * If it should reap itself, return true. * * If it's our own child, there is no notification to do. But if our normal * children self-reap, then this child was prevented by ptrace and we must * reap it now, in that case we must also wake up sub-threads sleeping in * do_wait(). */ static bool __ptrace_detach(struct task_struct *tracer, struct task_struct *p) { bool dead; __ptrace_unlink(p); if (p->exit_state != EXIT_ZOMBIE) return false; dead = !thread_group_leader(p); if (!dead && thread_group_empty(p)) { if (!same_thread_group(p->real_parent, tracer)) dead = do_notify_parent(p, p->exit_signal); else if (ignoring_children(tracer->sighand)) { __wake_up_parent(p, tracer); dead = true; } } /* Mark it as in the process of being reaped. */ if (dead) p->exit_state = EXIT_DEAD; return dead; } static int ptrace_detach(struct task_struct *child, unsigned int data) { bool dead = false; if (!valid_signal(data)) return -EIO; /* Architecture-specific hardware disable .. */ ptrace_disable(child); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); write_lock_irq(&tasklist_lock); /* * This child can be already killed. Make sure de_thread() or * our sub-thread doing do_wait() didn't do release_task() yet. */ if (child->ptrace) { child->exit_code = data; dead = __ptrace_detach(current, child); } write_unlock_irq(&tasklist_lock); proc_ptrace_connector(child, PTRACE_DETACH); if (unlikely(dead)) release_task(child); return 0; } /* * Detach all tasks we were using ptrace on. Called with tasklist held * for writing, and returns with it held too. But note it can release * and reacquire the lock. */ void exit_ptrace(struct task_struct *tracer) __releases(&tasklist_lock) __acquires(&tasklist_lock) { struct task_struct *p, *n; LIST_HEAD(ptrace_dead); if (likely(list_empty(&tracer->ptraced))) return; list_for_each_entry_safe(p, n, &tracer->ptraced, ptrace_entry) { if (unlikely(p->ptrace & PT_EXITKILL)) send_sig_info(SIGKILL, SEND_SIG_FORCED, p); if (__ptrace_detach(tracer, p)) list_add(&p->ptrace_entry, &ptrace_dead); } write_unlock_irq(&tasklist_lock); BUG_ON(!list_empty(&tracer->ptraced)); list_for_each_entry_safe(p, n, &ptrace_dead, ptrace_entry) { list_del_init(&p->ptrace_entry); release_task(p); } write_lock_irq(&tasklist_lock); } int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len) { int copied = 0; while (len > 0) { char buf[128]; int this_len, retval; this_len = (len > sizeof(buf)) ? sizeof(buf) : len; retval = access_process_vm(tsk, src, buf, this_len, 0); if (!retval) { if (copied) break; return -EIO; } if (copy_to_user(dst, buf, retval)) return -EFAULT; copied += retval; src += retval; dst += retval; len -= retval; } return copied; } int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len) { int copied = 0; while (len > 0) { char buf[128]; int this_len, retval; this_len = (len > sizeof(buf)) ? sizeof(buf) : len; if (copy_from_user(buf, src, this_len)) return -EFAULT; retval = access_process_vm(tsk, dst, buf, this_len, 1); if (!retval) { if (copied) break; return -EIO; } copied += retval; src += retval; dst += retval; len -= retval; } return copied; } static int ptrace_setoptions(struct task_struct *child, unsigned long data) { unsigned flags; if (data & ~(unsigned long)PTRACE_O_MASK) return -EINVAL; /* Avoid intermediate state when all opts are cleared */ flags = child->ptrace; flags &= ~(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT); flags |= (data << PT_OPT_FLAG_SHIFT); child->ptrace = flags; return 0; } static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info) { unsigned long flags; int error = -ESRCH; if (lock_task_sighand(child, &flags)) { error = -EINVAL; if (likely(child->last_siginfo != NULL)) { *info = *child->last_siginfo; error = 0; } unlock_task_sighand(child, &flags); } return error; } static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) { unsigned long flags; int error = -ESRCH; if (lock_task_sighand(child, &flags)) { error = -EINVAL; if (likely(child->last_siginfo != NULL)) { *child->last_siginfo = *info; error = 0; } unlock_task_sighand(child, &flags); } return error; } static int ptrace_peek_siginfo(struct task_struct *child, unsigned long addr, unsigned long data) { struct ptrace_peeksiginfo_args arg; struct sigpending *pending; struct sigqueue *q; int ret, i; ret = copy_from_user(&arg, (void __user *) addr, sizeof(struct ptrace_peeksiginfo_args)); if (ret) return -EFAULT; if (arg.flags & ~PTRACE_PEEKSIGINFO_SHARED) return -EINVAL; /* unknown flags */ if (arg.nr < 0) return -EINVAL; if (arg.flags & PTRACE_PEEKSIGINFO_SHARED) pending = &child->signal->shared_pending; else pending = &child->pending; for (i = 0; i < arg.nr; ) { siginfo_t info; s32 off = arg.off + i; spin_lock_irq(&child->sighand->siglock); list_for_each_entry(q, &pending->list, list) { if (!off--) { copy_siginfo(&info, &q->info); break; } } spin_unlock_irq(&child->sighand->siglock); if (off >= 0) /* beyond the end of the list */ break; #ifdef CONFIG_COMPAT if (unlikely(is_compat_task())) { compat_siginfo_t __user *uinfo = compat_ptr(data); if (copy_siginfo_to_user32(uinfo, &info) || __put_user(info.si_code, &uinfo->si_code)) { ret = -EFAULT; break; } } else #endif { siginfo_t __user *uinfo = (siginfo_t __user *) data; if (copy_siginfo_to_user(uinfo, &info) || __put_user(info.si_code, &uinfo->si_code)) { ret = -EFAULT; break; } } data += sizeof(siginfo_t); i++; if (signal_pending(current)) break; cond_resched(); } if (i > 0) return i; return ret; } #ifdef PTRACE_SINGLESTEP #define is_singlestep(request) ((request) == PTRACE_SINGLESTEP) #else #define is_singlestep(request) 0 #endif #ifdef PTRACE_SINGLEBLOCK #define is_singleblock(request) ((request) == PTRACE_SINGLEBLOCK) #else #define is_singleblock(request) 0 #endif #ifdef PTRACE_SYSEMU #define is_sysemu_singlestep(request) ((request) == PTRACE_SYSEMU_SINGLESTEP) #else #define is_sysemu_singlestep(request) 0 #endif static int ptrace_resume(struct task_struct *child, long request, unsigned long data) { if (!valid_signal(data)) return -EIO; if (request == PTRACE_SYSCALL) set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); else clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); #ifdef TIF_SYSCALL_EMU if (request == PTRACE_SYSEMU || request == PTRACE_SYSEMU_SINGLESTEP) set_tsk_thread_flag(child, TIF_SYSCALL_EMU); else clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); #endif if (is_singleblock(request)) { if (unlikely(!arch_has_block_step())) return -EIO; user_enable_block_step(child); } else if (is_singlestep(request) || is_sysemu_singlestep(request)) { if (unlikely(!arch_has_single_step())) return -EIO; user_enable_single_step(child); } else { user_disable_single_step(child); } child->exit_code = data; wake_up_state(child, __TASK_TRACED); return 0; } #ifdef CONFIG_HAVE_ARCH_TRACEHOOK static const struct user_regset * find_regset(const struct user_regset_view *view, unsigned int type) { const struct user_regset *regset; int n; for (n = 0; n < view->n; ++n) { regset = view->regsets + n; if (regset->core_note_type == type) return regset; } return NULL; } static int ptrace_regset(struct task_struct *task, int req, unsigned int type, struct iovec *kiov) { const struct user_regset_view *view = task_user_regset_view(task); const struct user_regset *regset = find_regset(view, type); int regset_no; if (!regset || (kiov->iov_len % regset->size) != 0) return -EINVAL; regset_no = regset - view->regsets; kiov->iov_len = min(kiov->iov_len, (__kernel_size_t) (regset->n * regset->size)); if (req == PTRACE_GETREGSET) return copy_regset_to_user(task, view, regset_no, 0, kiov->iov_len, kiov->iov_base); else return copy_regset_from_user(task, view, regset_no, 0, kiov->iov_len, kiov->iov_base); } /* * This is declared in linux/regset.h and defined in machine-dependent * code. We put the export here, near the primary machine-neutral use, * to ensure no machine forgets it. */ EXPORT_SYMBOL_GPL(task_user_regset_view); #endif int ptrace_request(struct task_struct *child, long request, unsigned long addr, unsigned long data) { bool seized = child->ptrace & PT_SEIZED; int ret = -EIO; siginfo_t siginfo, *si; void __user *datavp = (void __user *) data; unsigned long __user *datalp = datavp; unsigned long flags; switch (request) { case PTRACE_PEEKTEXT: case PTRACE_PEEKDATA: return generic_ptrace_peekdata(child, addr, data); case PTRACE_POKETEXT: case PTRACE_POKEDATA: return generic_ptrace_pokedata(child, addr, data); #ifdef PTRACE_OLDSETOPTIONS case PTRACE_OLDSETOPTIONS: #endif case PTRACE_SETOPTIONS: ret = ptrace_setoptions(child, data); break; case PTRACE_GETEVENTMSG: ret = put_user(child->ptrace_message, datalp); break; case PTRACE_PEEKSIGINFO: ret = ptrace_peek_siginfo(child, addr, data); break; case PTRACE_GETSIGINFO: ret = ptrace_getsiginfo(child, &siginfo); if (!ret) ret = copy_siginfo_to_user(datavp, &siginfo); break; case PTRACE_SETSIGINFO: if (copy_from_user(&siginfo, datavp, sizeof siginfo)) ret = -EFAULT; else ret = ptrace_setsiginfo(child, &siginfo); break; case PTRACE_INTERRUPT: /* * Stop tracee without any side-effect on signal or job * control. At least one trap is guaranteed to happen * after this request. If @child is already trapped, the * current trap is not disturbed and another trap will * happen after the current trap is ended with PTRACE_CONT. * * The actual trap might not be PTRACE_EVENT_STOP trap but * the pending condition is cleared regardless. */ if (unlikely(!seized || !lock_task_sighand(child, &flags))) break; /* * INTERRUPT doesn't disturb existing trap sans one * exception. If ptracer issued LISTEN for the current * STOP, this INTERRUPT should clear LISTEN and re-trap * tracee into STOP. */ if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP))) ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING); unlock_task_sighand(child, &flags); ret = 0; break; case PTRACE_LISTEN: /* * Listen for events. Tracee must be in STOP. It's not * resumed per-se but is not considered to be in TRACED by * wait(2) or ptrace(2). If an async event (e.g. group * stop state change) happens, tracee will enter STOP trap * again. Alternatively, ptracer can issue INTERRUPT to * finish listening and re-trap tracee into STOP. */ if (unlikely(!seized || !lock_task_sighand(child, &flags))) break; si = child->last_siginfo; if (likely(si && (si->si_code >> 8) == PTRACE_EVENT_STOP)) { child->jobctl |= JOBCTL_LISTENING; /* * If NOTIFY is set, it means event happened between * start of this trap and now. Trigger re-trap. */ if (child->jobctl & JOBCTL_TRAP_NOTIFY) ptrace_signal_wake_up(child, true); ret = 0; } unlock_task_sighand(child, &flags); break; case PTRACE_DETACH: /* detach a process that was attached. */ ret = ptrace_detach(child, data); break; #ifdef CONFIG_BINFMT_ELF_FDPIC case PTRACE_GETFDPIC: { struct mm_struct *mm = get_task_mm(child); unsigned long tmp = 0; ret = -ESRCH; if (!mm) break; switch (addr) { case PTRACE_GETFDPIC_EXEC: tmp = mm->context.exec_fdpic_loadmap; break; case PTRACE_GETFDPIC_INTERP: tmp = mm->context.interp_fdpic_loadmap; break; default: break; } mmput(mm); ret = put_user(tmp, datalp); break; } #endif #ifdef PTRACE_SINGLESTEP case PTRACE_SINGLESTEP: #endif #ifdef PTRACE_SINGLEBLOCK case PTRACE_SINGLEBLOCK: #endif #ifdef PTRACE_SYSEMU case PTRACE_SYSEMU: case PTRACE_SYSEMU_SINGLESTEP: #endif case PTRACE_SYSCALL: case PTRACE_CONT: return ptrace_resume(child, request, data); case PTRACE_KILL: if (child->exit_state) /* already dead */ return 0; return ptrace_resume(child, request, SIGKILL); #ifdef CONFIG_HAVE_ARCH_TRACEHOOK case PTRACE_GETREGSET: case PTRACE_SETREGSET: { struct iovec kiov; struct iovec __user *uiov = datavp; if (!access_ok(VERIFY_WRITE, uiov, sizeof(*uiov))) return -EFAULT; if (__get_user(kiov.iov_base, &uiov->iov_base) || __get_user(kiov.iov_len, &uiov->iov_len)) return -EFAULT; ret = ptrace_regset(child, request, addr, &kiov); if (!ret) ret = __put_user(kiov.iov_len, &uiov->iov_len); break; } #endif default: break; } return ret; } static struct task_struct *ptrace_get_task_struct(pid_t pid) { struct task_struct *child; rcu_read_lock(); child = find_task_by_vpid(pid); if (child) get_task_struct(child); rcu_read_unlock(); if (!child) return ERR_PTR(-ESRCH); return child; } #ifndef arch_ptrace_attach #define arch_ptrace_attach(child) do { } while (0) #endif SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, unsigned long, data) { struct task_struct *child; long ret; if (request == PTRACE_TRACEME) { ret = ptrace_traceme(); if (!ret) arch_ptrace_attach(current); goto out; } child = ptrace_get_task_struct(pid); if (IS_ERR(child)) { ret = PTR_ERR(child); goto out; } if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) { ret = ptrace_attach(child, request, addr, data); /* * Some architectures need to do book-keeping after * a ptrace attach. */ if (!ret) arch_ptrace_attach(child); goto out_put_task_struct; } ret = ptrace_check_attach(child, request == PTRACE_KILL || request == PTRACE_INTERRUPT); if (ret < 0) goto out_put_task_struct; ret = arch_ptrace(child, request, addr, data); if (ret || request != PTRACE_DETACH) ptrace_unfreeze_traced(child); out_put_task_struct: put_task_struct(child); out: return ret; } int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr, unsigned long data) { unsigned long tmp; int copied; copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0); if (copied != sizeof(tmp)) return -EIO; return put_user(tmp, (unsigned long __user *)data); } int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr, unsigned long data) { int copied; copied = access_process_vm(tsk, addr, &data, sizeof(data), 1); return (copied == sizeof(data)) ? 0 : -EIO; } #if defined CONFIG_COMPAT #include <linux/compat.h> int compat_ptrace_request(struct task_struct *child, compat_long_t request, compat_ulong_t addr, compat_ulong_t data) { compat_ulong_t __user *datap = compat_ptr(data); compat_ulong_t word; siginfo_t siginfo; int ret; switch (request) { case PTRACE_PEEKTEXT: case PTRACE_PEEKDATA: ret = access_process_vm(child, addr, &word, sizeof(word), 0); if (ret != sizeof(word)) ret = -EIO; else ret = put_user(word, datap); break; case PTRACE_POKETEXT: case PTRACE_POKEDATA: ret = access_process_vm(child, addr, &data, sizeof(data), 1); ret = (ret != sizeof(data) ? -EIO : 0); break; case PTRACE_GETEVENTMSG: ret = put_user((compat_ulong_t) child->ptrace_message, datap); break; case PTRACE_GETSIGINFO: ret = ptrace_getsiginfo(child, &siginfo); if (!ret) ret = copy_siginfo_to_user32( (struct compat_siginfo __user *) datap, &siginfo); break; case PTRACE_SETSIGINFO: memset(&siginfo, 0, sizeof siginfo); if (copy_siginfo_from_user32( &siginfo, (struct compat_siginfo __user *) datap)) ret = -EFAULT; else ret = ptrace_setsiginfo(child, &siginfo); break; #ifdef CONFIG_HAVE_ARCH_TRACEHOOK case PTRACE_GETREGSET: case PTRACE_SETREGSET: { struct iovec kiov; struct compat_iovec __user *uiov = (struct compat_iovec __user *) datap; compat_uptr_t ptr; compat_size_t len; if (!access_ok(VERIFY_WRITE, uiov, sizeof(*uiov))) return -EFAULT; if (__get_user(ptr, &uiov->iov_base) || __get_user(len, &uiov->iov_len)) return -EFAULT; kiov.iov_base = compat_ptr(ptr); kiov.iov_len = len; ret = ptrace_regset(child, request, addr, &kiov); if (!ret) ret = __put_user(kiov.iov_len, &uiov->iov_len); break; } #endif default: ret = ptrace_request(child, request, addr, data); } return ret; } asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, compat_long_t addr, compat_long_t data) { struct task_struct *child; long ret; if (request == PTRACE_TRACEME) { ret = ptrace_traceme(); goto out; } child = ptrace_get_task_struct(pid); if (IS_ERR(child)) { ret = PTR_ERR(child); goto out; } if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) { ret = ptrace_attach(child, request, addr, data); /* * Some architectures need to do book-keeping after * a ptrace attach. */ if (!ret) arch_ptrace_attach(child); goto out_put_task_struct; } ret = ptrace_check_attach(child, request == PTRACE_KILL || request == PTRACE_INTERRUPT); if (!ret) { ret = compat_arch_ptrace(child, request, addr, data); if (ret || request != PTRACE_DETACH) ptrace_unfreeze_traced(child); } out_put_task_struct: put_task_struct(child); out: return ret; } #endif /* CONFIG_COMPAT */ #ifdef CONFIG_HAVE_HW_BREAKPOINT int ptrace_get_breakpoints(struct task_struct *tsk) { if (atomic_inc_not_zero(&tsk->ptrace_bp_refcnt)) return 0; return -1; } void ptrace_put_breakpoints(struct task_struct *tsk) { if (atomic_dec_and_test(&tsk->ptrace_bp_refcnt)) flush_ptrace_hw_breakpoint(tsk); } #endif /* CONFIG_HAVE_HW_BREAKPOINT */
/* LUFA Library Copyright (C) Dean Camera, 2011. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software. */ /** \file * * USB Device Descriptors, for library use when in USB device mode. Descriptors are special * computer-readable structures which the host requests upon device enumeration, to determine * the device's capabilities and functions. */ #include "Descriptors.h" /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall * device characteristics, including the supported USB version, control endpoint size and the * number of device configurations. The descriptor is read out by the USB host when the enumeration * process begins. */ const USB_Descriptor_Device_t DeviceDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, .USBSpecification = VERSION_BCD(01.10), .Class = CDC_CSCP_CDCClass, .SubClass = CDC_CSCP_NoSpecificSubclass, .Protocol = CDC_CSCP_NoSpecificProtocol, .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, .VendorID = DEVICE_VID, .ProductID = DEVICE_PID, .ReleaseNumber = VERSION_BCD(00.01), .ManufacturerStrIndex = 0x02, .ProductStrIndex = 0x01, .SerialNumStrIndex = NO_DESCRIPTOR, .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS }; /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage * of the device in one of its supported configurations, including information about any device interfaces * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting * a configuration so that the host may correctly communicate with the USB device. */ const USB_Descriptor_Configuration_t ConfigurationDescriptor = { .Config = { .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), .TotalInterfaces = 2, .ConfigurationNumber = 1, .ConfigurationStrIndex = NO_DESCRIPTOR, .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) }, .CDC_CCI_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .InterfaceNumber = 0, .AlternateSetting = 0, .TotalEndpoints = 1, .Class = CDC_CSCP_CDCClass, .SubClass = CDC_CSCP_ACMSubclass, .Protocol = CDC_CSCP_ATCommandProtocol, .InterfaceStrIndex = NO_DESCRIPTOR }, .CDC_Functional_Header = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Subtype = 0x00, .CDCSpecification = VERSION_BCD(01.10), }, .CDC_Functional_ACM = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Subtype = 0x02, .Capabilities = 0x04, }, .CDC_Functional_Union = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Subtype = 0x06, .MasterInterfaceNumber = 0, .SlaveInterfaceNumber = 1, }, .CDC_NotificationEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_NOTIFICATION_EPSIZE, .PollingIntervalMS = 0xFF }, .CDC_DCI_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .InterfaceNumber = 1, .AlternateSetting = 0, .TotalEndpoints = 2, .Class = CDC_CSCP_CDCDataClass, .SubClass = CDC_CSCP_NoDataSubclass, .Protocol = CDC_CSCP_NoDataProtocol, .InterfaceStrIndex = NO_DESCRIPTOR }, .CDC_DataOutEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, .PollingIntervalMS = 0x01 }, .CDC_DataInEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, .PollingIntervalMS = 0x01 } }; /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate * via the language ID table available at USB.org what languages the device supports for its string descriptors. */ const USB_Descriptor_String_t LanguageString = { .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, .UnicodeString = {LANGUAGE_ID_ENG} }; /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ const USB_Descriptor_String_t ProductString = { .Header = {.Size = USB_STRING_LEN(16), .Type = DTYPE_String}, #if DEVICE_PID == 0x0036 .UnicodeString = L"Arduino Leonardo" #elif DEVICE_PID == 0x0037 .UnicodeString = L"Arduino Micro " #elif DEVICE_PID == 0x003C .UnicodeString = L"Arduino Esplora " #else .UnicodeString = L"USB IO board " #endif }; const USB_Descriptor_String_t ManufNameString = { .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, #if DEVICE_VID == 0x2341 .UnicodeString = L"Arduino LLC" #else .UnicodeString = L"Unknown " #endif }; /** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors" * documentation) by the application code so that the address and size of a requested descriptor can be given * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the * USB host. */ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void** const DescriptorAddress) { const uint8_t DescriptorType = (wValue >> 8); const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: if (!(DescriptorNumber)) { Address = &LanguageString; Size = LanguageString.Header.Size; } else if (DescriptorNumber == DeviceDescriptor.ProductStrIndex) { Address = &ProductString; Size = ProductString.Header.Size; } else if (DescriptorNumber == DeviceDescriptor.ManufacturerStrIndex) { Address = &ManufNameString; Size = ManufNameString.Header.Size; } break; } *DescriptorAddress = Address; return Size; }
!==================assumed_size_refs_1.f90================== ! { dg-do compile } ! Test the fix for PR25029, PR21256 in which references to ! assumed size arrays without an upper bound to the last ! dimension were generating no error. The first version of ! the patch failed in DHSEQR, as pointed out by Toon Moene ! in http://gcc.gnu.org/ml/fortran/2005-12/msg00466.html ! ! Contributed by Paul Thomas <pault@gcc.gnu.org> ! program assumed_size_test_1 implicit none real a(2, 4) a = 1.0 call foo (a) contains subroutine foo(m) real, target :: m(1:2, *) real x(2,2,2) real, external :: bar real, pointer :: p(:,:), q(:,:) allocate (q(2,2)) ! PR25029 p => m ! { dg-error "upper bound in the last dimension" } q = m ! { dg-error "upper bound in the last dimension" } ! PR21256( and PR25060) m = 1 ! { dg-error "upper bound in the last dimension" } m(1,1) = 2.0 x = bar (m) x = fcn (m) ! { dg-error "upper bound in the last dimension" } m(:, 1:2) = fcn (q) call sub (m, x) ! { dg-error "upper bound in the last dimension" } call sub (m(1:2, 1:2), x) ! { dg-error "Incompatible ranks in elemental procedure" } print *, p call DHSEQR(x) end subroutine foo elemental function fcn (a) result (b) real, intent(in) :: a real :: b b = 2.0 * a end function fcn elemental subroutine sub (a, b) real, intent(inout) :: a, b b = 2.0 * a end subroutine sub SUBROUTINE DHSEQR( WORK ) REAL WORK( * ) EXTERNAL DLARFX INTRINSIC MIN WORK( 1 ) = 1.0 CALL DLARFX( MIN( 1, 8 ), WORK ) END SUBROUTINE DHSEQR end program assumed_size_test_1
/* Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package options import ( "fmt" "net" "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apiserver/pkg/server" utilfeature "k8s.io/apiserver/pkg/util/feature" // add the generic feature gates _ "k8s.io/apiserver/pkg/features" "github.com/spf13/pflag" ) // ServerRunOptions contains the options while running a generic api server. type ServerRunOptions struct { AdvertiseAddress net.IP CorsAllowedOriginList []string ExternalHost string MaxRequestsInFlight int MaxMutatingRequestsInFlight int RequestTimeout time.Duration MinRequestTimeout int TargetRAMMB int } func NewServerRunOptions() *ServerRunOptions { defaults := server.NewConfig(serializer.CodecFactory{}) return &ServerRunOptions{ MaxRequestsInFlight: defaults.MaxRequestsInFlight, MaxMutatingRequestsInFlight: defaults.MaxMutatingRequestsInFlight, RequestTimeout: defaults.RequestTimeout, MinRequestTimeout: defaults.MinRequestTimeout, } } // ApplyOptions applies the run options to the method receiver and returns self func (s *ServerRunOptions) ApplyTo(c *server.Config) error { c.CorsAllowedOriginList = s.CorsAllowedOriginList c.ExternalAddress = s.ExternalHost c.MaxRequestsInFlight = s.MaxRequestsInFlight c.MaxMutatingRequestsInFlight = s.MaxMutatingRequestsInFlight c.RequestTimeout = s.RequestTimeout c.MinRequestTimeout = s.MinRequestTimeout c.PublicAddress = s.AdvertiseAddress return nil } // DefaultAdvertiseAddress sets the field AdvertiseAddress if unset. The field will be set based on the SecureServingOptions. func (s *ServerRunOptions) DefaultAdvertiseAddress(secure *SecureServingOptions) error { if secure == nil { return nil } if s.AdvertiseAddress == nil || s.AdvertiseAddress.IsUnspecified() { hostIP, err := secure.DefaultExternalAddress() if err != nil { return fmt.Errorf("Unable to find suitable network address.error='%v'. "+ "Try to set the AdvertiseAddress directly or provide a valid BindAddress to fix this.", err) } s.AdvertiseAddress = hostIP } return nil } // Validate checks validation of ServerRunOptions func (s *ServerRunOptions) Validate() []error { errors := []error{} if s.TargetRAMMB < 0 { errors = append(errors, fmt.Errorf("--target-ram-mb can not be negative value")) } if s.MaxRequestsInFlight < 0 { errors = append(errors, fmt.Errorf("--max-requests-inflight can not be negative value")) } if s.MaxMutatingRequestsInFlight < 0 { errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight can not be negative value")) } if s.RequestTimeout.Nanoseconds() < 0 { errors = append(errors, fmt.Errorf("--request-timeout can not be negative value")) } return errors } // AddFlags adds flags for a specific APIServer to the specified FlagSet func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) { // Note: the weird ""+ in below lines seems to be the only way to get gofmt to // arrange these text blocks sensibly. Grrr. fs.IPVar(&s.AdvertiseAddress, "advertise-address", s.AdvertiseAddress, ""+ "The IP address on which to advertise the apiserver to members of the cluster. This "+ "address must be reachable by the rest of the cluster. If blank, the --bind-address "+ "will be used. If --bind-address is unspecified, the host's default interface will "+ "be used.") fs.StringSliceVar(&s.CorsAllowedOriginList, "cors-allowed-origins", s.CorsAllowedOriginList, ""+ "List of allowed origins for CORS, comma separated. An allowed origin can be a regular "+ "expression to support subdomain matching. If this list is empty CORS will not be enabled.") fs.IntVar(&s.TargetRAMMB, "target-ram-mb", s.TargetRAMMB, "Memory limit for apiserver in MB (used to configure sizes of caches, etc.)") fs.StringVar(&s.ExternalHost, "external-hostname", s.ExternalHost, "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs).") deprecatedMasterServiceNamespace := metav1.NamespaceDefault fs.StringVar(&deprecatedMasterServiceNamespace, "master-service-namespace", deprecatedMasterServiceNamespace, ""+ "DEPRECATED: the namespace from which the kubernetes master services should be injected into pods.") fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", s.MaxRequestsInFlight, ""+ "The maximum number of non-mutating requests in flight at a given time. When the server exceeds this, "+ "it rejects requests. Zero for no limit.") fs.IntVar(&s.MaxMutatingRequestsInFlight, "max-mutating-requests-inflight", s.MaxMutatingRequestsInFlight, ""+ "The maximum number of mutating requests in flight at a given time. When the server exceeds this, "+ "it rejects requests. Zero for no limit.") fs.DurationVar(&s.RequestTimeout, "request-timeout", s.RequestTimeout, ""+ "An optional field indicating the duration a handler must keep a request open before timing "+ "it out. This is the default request timeout for requests but may be overridden by flags such as "+ "--min-request-timeout for specific types of requests.") fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", s.MinRequestTimeout, ""+ "An optional field indicating the minimum number of seconds a handler must keep "+ "a request open before timing it out. Currently only honored by the watch request "+ "handler, which picks a randomized value above this number as the connection timeout, "+ "to spread out load.") utilfeature.DefaultFeatureGate.AddFlag(fs) }
/* * Platform data for the chipidea USB dual role controller */ #ifndef __LINUX_USB_CHIPIDEA_H #define __LINUX_USB_CHIPIDEA_H #include <linux/usb/otg.h> struct ci_hdrc; struct ci_hdrc_platform_data { const char *name; /* offset of the capability registers */ uintptr_t capoffset; unsigned power_budget; struct usb_phy *phy; enum usb_phy_interface phy_mode; unsigned long flags; #define CI_HDRC_REGS_SHARED BIT(0) #define CI_HDRC_REQUIRE_TRANSCEIVER BIT(1) #define CI_HDRC_DISABLE_STREAMING BIT(3) /* * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1, * but otg is not supported (no register otgsc). */ #define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4) #define CI_HDRC_IMX28_WRITE_FIX BIT(5) #define CI_HDRC_FORCE_FULLSPEED BIT(6) enum usb_dr_mode dr_mode; #define CI_HDRC_CONTROLLER_RESET_EVENT 0 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 void (*notify_event) (struct ci_hdrc *ci, unsigned event); struct regulator *reg_vbus; }; /* Default offset of capability registers */ #define DEF_CAPOFFSET 0x100 /* Add ci hdrc device */ struct platform_device *ci_hdrc_add_device(struct device *dev, struct resource *res, int nres, struct ci_hdrc_platform_data *platdata); /* Remove ci hdrc device */ void ci_hdrc_remove_device(struct platform_device *pdev); #endif
-- remove auras that are already applied in SAI UPDATE `creature_template_addon` SET `auras`='' WHERE `entry` IN ( 215, -- Defias Night Runner 579, -- Shadowhide Assassin 938, -- Kurzen Commando 1040, -- Fen Creeper 8550, -- Shadowmage 9299, -- Gaeriyan 10414, -- Patchwork Horror 10426, -- Crimson Inquisitor 10471, -- Scholomance Acolyte 11885, -- Blighthound 16017, -- Patchwork Golem 16375, -- Sewage Slime 21080, -- Dormant Infernal 22853, -- Illidari Defiler 24818, -- Anvilrage Taskmaster 25596, -- Infected Kodo Beast 25781, -- Oil Pool 26624, -- Wretched Belcher 26782, -- Crystalline Keeper 28161); -- Chicken Escapee
<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\View\Helper; /** * Renders <html> tag (both opening and closing) of a web page, to which some custom * attributes can be added dynamically. * * @author Nikola Posa <posa.nikola@gmail.com> */ class HtmlTag extends AbstractHtmlElement { /** * Attributes for the <html> tag. * * @var array */ protected $attributes = array(); /** * Whether to pre-set appropriate attributes in accordance * with the currently set DOCTYPE. * * @var bool */ protected $useNamespaces = false; /** * @var bool */ private $handledNamespaces = false; /** * Retrieve object instance; optionally add attributes. * * @param array $attribs * @return self */ public function __invoke(array $attribs = array()) { if (!empty($attribs)) { $this->setAttributes($attribs); } return $this; } /** * Set new attribute. * * @param string $attrName * @param string $attrValue * @return self */ public function setAttribute($attrName, $attrValue) { $this->attributes[$attrName] = $attrValue; return $this; } /** * Add new or overwrite the existing attributes. * * @param array $attribs * @return self */ public function setAttributes(array $attribs) { foreach ($attribs as $name => $value) { $this->setAttribute($name, $value); } return $this; } /** * @return array */ public function getAttributes() { return $this->attributes; } /** * @param bool $useNamespaces * @return self */ public function setUseNamespaces($useNamespaces) { $this->useNamespaces = (bool) $useNamespaces; return $this; } /** * @return bool */ public function getUseNamespaces() { return $this->useNamespaces; } /** * Render opening tag. * * @return string */ public function openTag() { $this->handleNamespaceAttributes(); return sprintf('<html%s>', $this->htmlAttribs($this->attributes)); } protected function handleNamespaceAttributes() { if ($this->useNamespaces && !$this->handledNamespaces) { if (method_exists($this->view, 'plugin')) { $doctypeAttributes = array(); if ($this->view->plugin('doctype')->isXhtml()) { $doctypeAttributes = array('xmlns' => 'http://www.w3.org/1999/xhtml'); } if (!empty($doctypeAttributes)) { $this->attributes = array_merge($doctypeAttributes, $this->attributes); } } $this->handledNamespaces = true; } } /** * Render closing tag. * * @return string */ public function closeTag() { return '</html>'; } }
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Unit tests for Web CT question importer. * * @package qformat_webct * @copyright 2013 Jean-Michel Vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->libdir . '/questionlib.php'); require_once($CFG->dirroot . '/question/format.php'); require_once($CFG->dirroot . '/question/format/webct/format.php'); require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); /** * Unit tests for the webct question import format. * * @copyright 2013 Jean-Michel Vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qformat_webct_test extends question_testcase { public function make_test() { $lines = file(__DIR__ . '/fixtures/sample_webct.txt'); return $lines; } public function test_import_match() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[3]; $expectedq = new stdClass(); $expectedq->qtype = 'match'; $expectedq->name = 'Classify the animals.'; $expectedq->questiontext = '<i>Classify the animals.</i>'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->partiallycorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->incorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_MOODLE; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->penalty = 0.3333333; $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers'); $expectedq->subquestions = array( 1 => array('text' => 'cat', 'format' => FORMAT_HTML), 2 => array('text' => 'frog', 'format' => FORMAT_HTML), 3 => array('text' => 'newt', 'format' => FORMAT_HTML)); $expectedq->subanswers = array(1 => 'mammal', 2 => 'amphibian', 3 => 'amphibian'); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } public function test_import_multichoice_single() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[1]; $expectedq = new stdClass(); $expectedq->qtype = 'multichoice'; $expectedq->single = 1; $expectedq->name = 'USER-2'; $expectedq->questiontext = '<font size="+1">What\'s between orange and green in the spectrum?</font>'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->partiallycorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->incorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_MOODLE; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->penalty = 0.3333333; $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers'); $expectedq->answer = array( 1 => array( 'text' => 'red', 'format' => FORMAT_HTML, ), 2 => array( 'text' => 'yellow', 'format' => FORMAT_HTML, ), 3 => array( 'text' => 'blue', 'format' => FORMAT_HTML, ) ); $expectedq->fraction = array( 1 => 0, 2 => 1, 3 => 0, ); $expectedq->feedback = array( 1 => array( 'text' => 'Red is not between orange and green in the spectrum but yellow is.', 'format' => FORMAT_HTML, ), 2 => array( 'text' => 'You gave the right answer.', 'format' => FORMAT_HTML, ), 3 => array( 'text' => 'Blue is not between orange and green in the spectrum but yellow is.', 'format' => FORMAT_HTML, ) ); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } public function test_import_multichoice_multi() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[2]; $expectedq = new stdClass(); $expectedq->qtype = 'multichoice'; $expectedq->single = 0; $expectedq->name = 'USER-3'; $expectedq->questiontext = '<i>What\'s between orange and green in the spectrum?</i>'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->partiallycorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->incorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_MOODLE; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->penalty = 0.3333333; $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers'); $expectedq->answer = array( 1 => array( 'text' => 'yellow', 'format' => FORMAT_HTML, ), 2 => array( 'text' => 'red', 'format' => FORMAT_HTML, ), 3 => array( 'text' => 'off-beige', 'format' => FORMAT_HTML, ), 4 => array( 'text' => 'blue', 'format' => FORMAT_HTML, ) ); $expectedq->fraction = array( 1 => 0.5, 2 => 0, 3 => 0.5, 4 => 0, ); $expectedq->feedback = array( 1 => array( 'text' => 'True, yellow is between orange and green in the spectrum,', 'format' => FORMAT_HTML, ), 2 => array( 'text' => 'False, red is not between orange and green in the spectrum,', 'format' => FORMAT_HTML, ), 3 => array( 'text' => 'True, off-beige is between orange and green in the spectrum,', 'format' => FORMAT_HTML, ), 4 => array( 'text' => 'False, red is not between orange and green in the spectrum,', 'format' => FORMAT_HTML, ) ); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } public function test_import_truefalse() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[0]; $expectedq = new stdClass(); $expectedq->qtype = 'multichoice'; $expectedq->single = 1; $expectedq->name = 'USER-1'; $expectedq->questiontext = '42 is the Absolute Answer to everything.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->partiallycorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->incorrectfeedback = array( 'text' => '', 'format' => FORMAT_HTML, 'files' => array(), ); $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_MOODLE; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers'); $expectedq->answer = array( 1 => array( 'text' => 'True', 'format' => FORMAT_HTML, ), 2 => array( 'text' => 'False', 'format' => FORMAT_HTML, ), ); $expectedq->fraction = array( 1 => 0, 2 => 1, ); $expectedq->feedback = array( 1 => array( 'text' => '42 is the <b>Ultimate</b> Answer.', 'format' => FORMAT_HTML, ), 2 => array( 'text' => '42 is the <b>Ultimate</b> Answer.', 'format' => FORMAT_HTML, ), ); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } public function test_import_fill_in_the_blank() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[4]; $expectedq = new stdClass(); $expectedq->qtype = 'shortanswer'; $expectedq->name = 'USER-5'; $expectedq->questiontext = 'Name an amphibian&#58; __________'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = 'A frog is an amphibian'; $expectedq->generalfeedbackformat = FORMAT_HTML; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->usecase = 0; $expectedq->answer = array( 1 => 'frog', ); $expectedq->fraction = array( 1 => 1, ); $expectedq->feedback = array( 1 => array( 'text' => '', 'format' => FORMAT_HTML, ), ); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } public function test_import_essay() { $txt = $this->make_test(); $importer = new qformat_webct(); $questions = $importer->readquestions($txt); $q = $questions[5]; $expectedq = new stdClass(); $expectedq->qtype = 'essay'; $expectedq->name = 'USER-6'; $expectedq->questiontext = 'How are you?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->responseformat = 'editor'; $expectedq->responsefieldlines = 15; $expectedq->attachments = 0; $expectedq->graderinfo = array( 'text' => 'Blackboard answer for essay questions will be imported as informations for graders.', 'format' => FORMAT_HTML, ); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } }
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with this * work for additional information regarding copyright ownership. The ASF * licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package org.apache.hadoop.io.file.tfile; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; /** * Exception - No such Meta Block with the given name. */ @SuppressWarnings("serial") @InterfaceAudience.Public @InterfaceStability.Stable public class MetaBlockDoesNotExist extends IOException { /** * Constructor * * @param s * message. */ MetaBlockDoesNotExist(String s) { super(s); } }
/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. * * GPL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * * Copyright (c) 2011, 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ #define MAX_STRING_SIZE 128 extern int ldlm_srv_namespace_nr; extern int ldlm_cli_namespace_nr; extern struct mutex ldlm_srv_namespace_lock; extern struct list_head ldlm_srv_namespace_list; extern struct mutex ldlm_cli_namespace_lock; extern struct list_head ldlm_cli_active_namespace_list; extern struct list_head ldlm_cli_inactive_namespace_list; static inline int ldlm_namespace_nr_read(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? ldlm_srv_namespace_nr : ldlm_cli_namespace_nr; } static inline void ldlm_namespace_nr_inc(ldlm_side_t client) { if (client == LDLM_NAMESPACE_SERVER) ldlm_srv_namespace_nr++; else ldlm_cli_namespace_nr++; } static inline void ldlm_namespace_nr_dec(ldlm_side_t client) { if (client == LDLM_NAMESPACE_SERVER) ldlm_srv_namespace_nr--; else ldlm_cli_namespace_nr--; } static inline struct list_head *ldlm_namespace_list(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? &ldlm_srv_namespace_list : &ldlm_cli_active_namespace_list; } static inline struct list_head *ldlm_namespace_inactive_list(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? &ldlm_srv_namespace_list : &ldlm_cli_inactive_namespace_list; } static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? &ldlm_srv_namespace_lock : &ldlm_cli_namespace_lock; } /* ns_bref is the number of resources in this namespace */ static inline int ldlm_ns_empty(struct ldlm_namespace *ns) { return atomic_read(&ns->ns_bref) == 0; } void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *, ldlm_side_t); void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *, ldlm_side_t); struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t); /* ldlm_request.c */ /* Cancel lru flag, it indicates we cancel aged locks. */ enum { LDLM_CANCEL_AGED = 1 << 0, /* Cancel aged locks (non lru resize). */ LDLM_CANCEL_PASSED = 1 << 1, /* Cancel passed number of locks. */ LDLM_CANCEL_SHRINK = 1 << 2, /* Cancel locks from shrinker. */ LDLM_CANCEL_LRUR = 1 << 3, /* Cancel locks from lru resize. */ LDLM_CANCEL_NO_WAIT = 1 << 4 /* Cancel locks w/o blocking (neither * sending nor waiting for any rpcs) */ }; int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_cancel_flags_t sync, int flags); int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, int count, int max, ldlm_cancel_flags_t cancel_flags, int flags); extern int ldlm_enqueue_min; int ldlm_get_enq_timeout(struct ldlm_lock *lock); /* ldlm_resource.c */ int ldlm_resource_putref_locked(struct ldlm_resource *res); void ldlm_resource_insert_lock_after(struct ldlm_lock *original, struct ldlm_lock *new); void ldlm_namespace_free_prior(struct ldlm_namespace *ns, struct obd_import *imp, int force); void ldlm_namespace_free_post(struct ldlm_namespace *ns); /* ldlm_lock.c */ struct ldlm_cb_set_arg { struct ptlrpc_request_set *set; int type; /* LDLM_{CP,BL,GL}_CALLBACK */ atomic_t restart; struct list_head *list; union ldlm_gl_desc *gl_desc; /* glimpse AST descriptor */ }; typedef enum { LDLM_WORK_BL_AST, LDLM_WORK_CP_AST, LDLM_WORK_REVOKE_AST, LDLM_WORK_GL_AST } ldlm_desc_ast_t; void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list); int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, enum req_location loc, void *data, int size); struct ldlm_lock * ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *, ldlm_type_t type, ldlm_mode_t, const struct ldlm_callback_suite *cbs, void *data, __u32 lvb_len, enum lvb_type lvb_type); ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *, struct ldlm_lock **, void *cookie, __u64 *flags); void ldlm_lock_addref_internal(struct ldlm_lock *, __u32 mode); void ldlm_lock_addref_internal_nolock(struct ldlm_lock *, __u32 mode); void ldlm_lock_decref_internal(struct ldlm_lock *, __u32 mode); void ldlm_lock_decref_internal_nolock(struct ldlm_lock *, __u32 mode); void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, struct list_head *work_list); int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, ldlm_desc_ast_t ast_type); int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq); int ldlm_lock_remove_from_lru(struct ldlm_lock *lock); int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock); void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock); void ldlm_lock_add_to_lru(struct ldlm_lock *lock); void ldlm_lock_touch_in_lru(struct ldlm_lock *lock); void ldlm_lock_destroy_nolock(struct ldlm_lock *lock); void ldlm_cancel_locks_for_export(struct obd_export *export); /* ldlm_lockd.c */ int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock); int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, ldlm_cancel_flags_t cancel_flags); void ldlm_handle_bl_callback(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock); /* ldlm_extent.c */ void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock); void ldlm_extent_unlink_lock(struct ldlm_lock *lock); /* ldlm_flock.c */ int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, ldlm_error_t *err, struct list_head *work_list); int ldlm_init_flock_export(struct obd_export *exp); void ldlm_destroy_flock_export(struct obd_export *exp); /* l_lock.c */ void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); extern struct proc_dir_entry *ldlm_svc_proc_dir; extern struct proc_dir_entry *ldlm_type_proc_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; struct ptlrpc_service *ldlm_cancel_service; struct ptlrpc_client *ldlm_client; struct ptlrpc_connection *ldlm_server_conn; struct ldlm_bl_pool *ldlm_bl_pool; }; /* interval tree, for LDLM_EXTENT. */ extern struct kmem_cache *ldlm_interval_slab; /* slab cache for ldlm_interval */ extern void ldlm_interval_attach(struct ldlm_interval *n, struct ldlm_lock *l); extern struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l); extern struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock); extern void ldlm_interval_free(struct ldlm_interval *node); /* this function must be called with res lock held */ static inline struct ldlm_extent * ldlm_interval_extent(struct ldlm_interval *node) { struct ldlm_lock *lock; LASSERT(!list_empty(&node->li_group)); lock = list_entry(node->li_group.next, struct ldlm_lock, l_sl_policy); return &lock->l_policy_data.l_extent; } int ldlm_init(void); void ldlm_exit(void); enum ldlm_policy_res { LDLM_POLICY_CANCEL_LOCK, LDLM_POLICY_KEEP_LOCK, LDLM_POLICY_SKIP_LOCK }; typedef enum ldlm_policy_res ldlm_policy_res_t; #define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \ static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \ { \ struct ldlm_pool *pl = m->private; \ type tmp; \ \ spin_lock(&pl->pl_lock); \ tmp = pl->pl_##var; \ spin_unlock(&pl->pl_lock); \ \ return lprocfs_rd_uint(m, &tmp); \ } \ struct __##var##__dummy_read {;} /* semicolon catcher */ #define LDLM_POOL_PROC_WRITER(var, type) \ int lprocfs_wr_##var(struct file *file, const char *buffer, \ unsigned long count, void *data) \ { \ struct ldlm_pool *pl = data; \ type tmp; \ int rc; \ \ rc = lprocfs_wr_uint(file, buffer, count, &tmp); \ if (rc < 0) { \ CERROR("Can't parse user input, rc = %d\n", rc); \ return rc; \ } \ \ spin_lock(&pl->pl_lock); \ pl->pl_##var = tmp; \ spin_unlock(&pl->pl_lock); \ \ return rc; \ } \ struct __##var##__dummy_write {;} /* semicolon catcher */ static inline int is_granted_or_cancelled(struct ldlm_lock *lock) { int ret = 0; lock_res_and_lock(lock); if (((lock->l_req_mode == lock->l_granted_mode) && !(lock->l_flags & LDLM_FL_CP_REQD)) || (lock->l_flags & (LDLM_FL_FAILED | LDLM_FL_CANCEL))) ret = 1; unlock_res_and_lock(lock); return ret; } typedef void (*ldlm_policy_wire_to_local_t)(const ldlm_wire_policy_data_t *, ldlm_policy_data_t *); typedef void (*ldlm_policy_local_to_wire_t)(const ldlm_policy_data_t *, ldlm_wire_policy_data_t *); void ldlm_plain_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_plain_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy); void ldlm_ibits_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_ibits_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy); void ldlm_extent_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_extent_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy); void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy);
/* * Sonics Silicon Backplane PCI-Hostbus related functions. * * Copyright (C) 2005-2006 Michael Buesch <m@bues.ch> * Copyright (C) 2005 Martin Langer <martin-langer@gmx.de> * Copyright (C) 2005 Stefano Brivio <st3@riseup.net> * Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org> * Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch> * * Derived from the Broadcom 4400 device driver. * Copyright (C) 2002 David S. Miller (davem@redhat.com) * Fixed by Pekka Pietikainen (pp@ee.oulu.fi) * Copyright (C) 2006 Broadcom Corporation. * * Licensed under the GNU/GPL. See COPYING for details. */ #include <linux/ssb/ssb.h> #include <linux/ssb/ssb_regs.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/delay.h> #include "ssb_private.h" /* Define the following to 1 to enable a printk on each coreswitch. */ #define SSB_VERBOSE_PCICORESWITCH_DEBUG 0 /* Lowlevel coreswitching */ int ssb_pci_switch_coreidx(struct ssb_bus *bus, u8 coreidx) { int err; int attempts = 0; u32 cur_core; while (1) { err = pci_write_config_dword(bus->host_pci, SSB_BAR0_WIN, (coreidx * SSB_CORE_SIZE) + SSB_ENUM_BASE); if (err) goto error; err = pci_read_config_dword(bus->host_pci, SSB_BAR0_WIN, &cur_core); if (err) goto error; cur_core = (cur_core - SSB_ENUM_BASE) / SSB_CORE_SIZE; if (cur_core == coreidx) break; if (attempts++ > SSB_BAR0_MAX_RETRIES) goto error; udelay(10); } return 0; error: ssb_printk(KERN_ERR PFX "Failed to switch to core %u\n", coreidx); return -ENODEV; } int ssb_pci_switch_core(struct ssb_bus *bus, struct ssb_device *dev) { int err; unsigned long flags; #if SSB_VERBOSE_PCICORESWITCH_DEBUG ssb_printk(KERN_INFO PFX "Switching to %s core, index %d\n", ssb_core_name(dev->id.coreid), dev->core_index); #endif spin_lock_irqsave(&bus->bar_lock, flags); err = ssb_pci_switch_coreidx(bus, dev->core_index); if (!err) bus->mapped_device = dev; spin_unlock_irqrestore(&bus->bar_lock, flags); return err; } /* Enable/disable the on board crystal oscillator and/or PLL. */ int ssb_pci_xtal(struct ssb_bus *bus, u32 what, int turn_on) { int err; u32 in, out, outenable; u16 pci_status; if (bus->bustype != SSB_BUSTYPE_PCI) return 0; err = pci_read_config_dword(bus->host_pci, SSB_GPIO_IN, &in); if (err) goto err_pci; err = pci_read_config_dword(bus->host_pci, SSB_GPIO_OUT, &out); if (err) goto err_pci; err = pci_read_config_dword(bus->host_pci, SSB_GPIO_OUT_ENABLE, &outenable); if (err) goto err_pci; outenable |= what; if (turn_on) { /* Avoid glitching the clock if GPRS is already using it. * We can't actually read the state of the PLLPD so we infer it * by the value of XTAL_PU which *is* readable via gpioin. */ if (!(in & SSB_GPIO_XTAL)) { if (what & SSB_GPIO_XTAL) { /* Turn the crystal on */ out |= SSB_GPIO_XTAL; if (what & SSB_GPIO_PLL) out |= SSB_GPIO_PLL; err = pci_write_config_dword(bus->host_pci, SSB_GPIO_OUT, out); if (err) goto err_pci; err = pci_write_config_dword(bus->host_pci, SSB_GPIO_OUT_ENABLE, outenable); if (err) goto err_pci; msleep(1); } if (what & SSB_GPIO_PLL) { /* Turn the PLL on */ out &= ~SSB_GPIO_PLL; err = pci_write_config_dword(bus->host_pci, SSB_GPIO_OUT, out); if (err) goto err_pci; msleep(5); } } err = pci_read_config_word(bus->host_pci, PCI_STATUS, &pci_status); if (err) goto err_pci; pci_status &= ~PCI_STATUS_SIG_TARGET_ABORT; err = pci_write_config_word(bus->host_pci, PCI_STATUS, pci_status); if (err) goto err_pci; } else { if (what & SSB_GPIO_XTAL) { /* Turn the crystal off */ out &= ~SSB_GPIO_XTAL; } if (what & SSB_GPIO_PLL) { /* Turn the PLL off */ out |= SSB_GPIO_PLL; } err = pci_write_config_dword(bus->host_pci, SSB_GPIO_OUT, out); if (err) goto err_pci; err = pci_write_config_dword(bus->host_pci, SSB_GPIO_OUT_ENABLE, outenable); if (err) goto err_pci; } out: return err; err_pci: printk(KERN_ERR PFX "Error: ssb_pci_xtal() could not access PCI config space!\n"); err = -EBUSY; goto out; } /* Get the word-offset for a SSB_SPROM_XXX define. */ #define SPOFF(offset) ((offset) / sizeof(u16)) /* Helper to extract some _offset, which is one of the SSB_SPROM_XXX defines. */ #define SPEX16(_outvar, _offset, _mask, _shift) \ out->_outvar = ((in[SPOFF(_offset)] & (_mask)) >> (_shift)) #define SPEX32(_outvar, _offset, _mask, _shift) \ out->_outvar = ((((u32)in[SPOFF((_offset)+2)] << 16 | \ in[SPOFF(_offset)]) & (_mask)) >> (_shift)) #define SPEX(_outvar, _offset, _mask, _shift) \ SPEX16(_outvar, _offset, _mask, _shift) static inline u8 ssb_crc8(u8 crc, u8 data) { /* Polynomial: x^8 + x^7 + x^6 + x^4 + x^2 + 1 */ static const u8 t[] = { 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B, 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21, 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF, 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5, 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14, 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E, 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80, 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA, 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95, 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF, 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01, 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B, 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA, 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0, 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E, 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34, 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0, 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A, 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54, 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E, 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF, 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5, 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B, 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61, 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E, 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74, 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA, 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0, 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41, 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B, 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5, 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F, }; return t[crc ^ data]; } static u8 ssb_sprom_crc(const u16 *sprom, u16 size) { int word; u8 crc = 0xFF; for (word = 0; word < size - 1; word++) { crc = ssb_crc8(crc, sprom[word] & 0x00FF); crc = ssb_crc8(crc, (sprom[word] & 0xFF00) >> 8); } crc = ssb_crc8(crc, sprom[size - 1] & 0x00FF); crc ^= 0xFF; return crc; } static int sprom_check_crc(const u16 *sprom, size_t size) { u8 crc; u8 expected_crc; u16 tmp; crc = ssb_sprom_crc(sprom, size); tmp = sprom[size - 1] & SSB_SPROM_REVISION_CRC; expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT; if (crc != expected_crc) return -EPROTO; return 0; } static int sprom_do_read(struct ssb_bus *bus, u16 *sprom) { int i; for (i = 0; i < bus->sprom_size; i++) sprom[i] = ioread16(bus->mmio + bus->sprom_offset + (i * 2)); return 0; } static int sprom_do_write(struct ssb_bus *bus, const u16 *sprom) { struct pci_dev *pdev = bus->host_pci; int i, err; u32 spromctl; u16 size = bus->sprom_size; ssb_printk(KERN_NOTICE PFX "Writing SPROM. Do NOT turn off the power! Please stand by...\n"); err = pci_read_config_dword(pdev, SSB_SPROMCTL, &spromctl); if (err) goto err_ctlreg; spromctl |= SSB_SPROMCTL_WE; err = pci_write_config_dword(pdev, SSB_SPROMCTL, spromctl); if (err) goto err_ctlreg; ssb_printk(KERN_NOTICE PFX "[ 0%%"); msleep(500); for (i = 0; i < size; i++) { if (i == size / 4) ssb_printk("25%%"); else if (i == size / 2) ssb_printk("50%%"); else if (i == (size * 3) / 4) ssb_printk("75%%"); else if (i % 2) ssb_printk("."); writew(sprom[i], bus->mmio + bus->sprom_offset + (i * 2)); mmiowb(); msleep(20); } err = pci_read_config_dword(pdev, SSB_SPROMCTL, &spromctl); if (err) goto err_ctlreg; spromctl &= ~SSB_SPROMCTL_WE; err = pci_write_config_dword(pdev, SSB_SPROMCTL, spromctl); if (err) goto err_ctlreg; msleep(500); ssb_printk("100%% ]\n"); ssb_printk(KERN_NOTICE PFX "SPROM written.\n"); return 0; err_ctlreg: ssb_printk(KERN_ERR PFX "Could not access SPROM control register.\n"); return err; } static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in, u16 mask, u16 shift) { u16 v; u8 gain; v = in[SPOFF(SSB_SPROM1_AGAIN)]; gain = (v & mask) >> shift; if (gain == 0xFF) gain = 2; /* If unset use 2dBm */ if (sprom_revision == 1) { /* Convert to Q5.2 */ gain <<= 2; } else { /* Q5.2 Fractional part is stored in 0xC0 */ gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2); } return (s8)gain; } static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) { int i; u16 v; u16 loc[3]; if (out->revision == 3) /* rev 3 moved MAC */ loc[0] = SSB_SPROM3_IL0MAC; else { loc[0] = SSB_SPROM1_IL0MAC; loc[1] = SSB_SPROM1_ET0MAC; loc[2] = SSB_SPROM1_ET1MAC; } for (i = 0; i < 3; i++) { v = in[SPOFF(loc[0]) + i]; *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v); } if (out->revision < 3) { /* only rev 1-2 have et0, et1 */ for (i = 0; i < 3; i++) { v = in[SPOFF(loc[1]) + i]; *(((__be16 *)out->et0mac) + i) = cpu_to_be16(v); } for (i = 0; i < 3; i++) { v = in[SPOFF(loc[2]) + i]; *(((__be16 *)out->et1mac) + i) = cpu_to_be16(v); } } SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0); SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A, SSB_SPROM1_ETHPHY_ET1A_SHIFT); SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14); SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15); SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0); SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE, SSB_SPROM1_BINF_CCODE_SHIFT); SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA, SSB_SPROM1_BINF_ANTA_SHIFT); SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG, SSB_SPROM1_BINF_ANTBG_SHIFT); SPEX(pa0b0, SSB_SPROM1_PA0B0, 0xFFFF, 0); SPEX(pa0b1, SSB_SPROM1_PA0B1, 0xFFFF, 0); SPEX(pa0b2, SSB_SPROM1_PA0B2, 0xFFFF, 0); SPEX(pa1b0, SSB_SPROM1_PA1B0, 0xFFFF, 0); SPEX(pa1b1, SSB_SPROM1_PA1B1, 0xFFFF, 0); SPEX(pa1b2, SSB_SPROM1_PA1B2, 0xFFFF, 0); SPEX(gpio0, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P0, 0); SPEX(gpio1, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P1, SSB_SPROM1_GPIOA_P1_SHIFT); SPEX(gpio2, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P2, 0); SPEX(gpio3, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P3, SSB_SPROM1_GPIOB_P3_SHIFT); SPEX(maxpwr_a, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_A, SSB_SPROM1_MAXPWR_A_SHIFT); SPEX(maxpwr_bg, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_BG, 0); SPEX(itssi_a, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_A, SSB_SPROM1_ITSSI_A_SHIFT); SPEX(itssi_bg, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_BG, 0); SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0); if (out->revision >= 2) SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0); /* Extract the antenna gain values. */ out->antenna_gain.a0 = r123_extract_antgain(out->revision, in, SSB_SPROM1_AGAIN_BG, SSB_SPROM1_AGAIN_BG_SHIFT); out->antenna_gain.a1 = r123_extract_antgain(out->revision, in, SSB_SPROM1_AGAIN_A, SSB_SPROM1_AGAIN_A_SHIFT); } /* Revs 4 5 and 8 have partially shared layout */ static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in) { SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0, SSB_SPROM4_TXPID2G0_SHIFT); SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1, SSB_SPROM4_TXPID2G1_SHIFT); SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2, SSB_SPROM4_TXPID2G2_SHIFT); SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3, SSB_SPROM4_TXPID2G3_SHIFT); SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0, SSB_SPROM4_TXPID5GL0_SHIFT); SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1, SSB_SPROM4_TXPID5GL1_SHIFT); SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2, SSB_SPROM4_TXPID5GL2_SHIFT); SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3, SSB_SPROM4_TXPID5GL3_SHIFT); SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0, SSB_SPROM4_TXPID5G0_SHIFT); SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1, SSB_SPROM4_TXPID5G1_SHIFT); SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2, SSB_SPROM4_TXPID5G2_SHIFT); SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3, SSB_SPROM4_TXPID5G3_SHIFT); SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0, SSB_SPROM4_TXPID5GH0_SHIFT); SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1, SSB_SPROM4_TXPID5GH1_SHIFT); SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2, SSB_SPROM4_TXPID5GH2_SHIFT); SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3, SSB_SPROM4_TXPID5GH3_SHIFT); } static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) { int i; u16 v; u16 il0mac_offset; if (out->revision == 4) il0mac_offset = SSB_SPROM4_IL0MAC; else il0mac_offset = SSB_SPROM5_IL0MAC; /* extract the MAC address */ for (i = 0; i < 3; i++) { v = in[SPOFF(il0mac_offset) + i]; *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v); } SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0); SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A, SSB_SPROM4_ETHPHY_ET1A_SHIFT); if (out->revision == 4) { SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0); SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0); SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0); SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0); SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0); } else { SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0); SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0); SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0); SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0); SPEX(boardflags2_hi, SSB_SPROM5_BFL2HI, 0xFFFF, 0); } SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A, SSB_SPROM4_ANTAVAIL_A_SHIFT); SPEX(ant_available_bg, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_BG, SSB_SPROM4_ANTAVAIL_BG_SHIFT); SPEX(maxpwr_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_MAXP_BG_MASK, 0); SPEX(itssi_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_ITSSI_BG, SSB_SPROM4_ITSSI_BG_SHIFT); SPEX(maxpwr_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_MAXP_A_MASK, 0); SPEX(itssi_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_ITSSI_A, SSB_SPROM4_ITSSI_A_SHIFT); if (out->revision == 4) { SPEX(gpio0, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P0, 0); SPEX(gpio1, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P1, SSB_SPROM4_GPIOA_P1_SHIFT); SPEX(gpio2, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P2, 0); SPEX(gpio3, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P3, SSB_SPROM4_GPIOB_P3_SHIFT); } else { SPEX(gpio0, SSB_SPROM5_GPIOA, SSB_SPROM5_GPIOA_P0, 0); SPEX(gpio1, SSB_SPROM5_GPIOA, SSB_SPROM5_GPIOA_P1, SSB_SPROM5_GPIOA_P1_SHIFT); SPEX(gpio2, SSB_SPROM5_GPIOB, SSB_SPROM5_GPIOB_P2, 0); SPEX(gpio3, SSB_SPROM5_GPIOB, SSB_SPROM5_GPIOB_P3, SSB_SPROM5_GPIOB_P3_SHIFT); } /* Extract the antenna gain values. */ SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01, SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT); SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01, SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT); SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23, SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT); SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23, SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT); sprom_extract_r458(out, in); /* TODO - get remaining rev 4 stuff needed */ } static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) { int i; u16 v, o; u16 pwr_info_offset[] = { SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1, SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3 }; BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) != ARRAY_SIZE(out->core_pwr_info)); /* extract the MAC address */ for (i = 0; i < 3; i++) { v = in[SPOFF(SSB_SPROM8_IL0MAC) + i]; *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v); } SPEX(country_code, SSB_SPROM8_CCODE, 0xFFFF, 0); SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0); SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0); SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0); SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, 0xFFFF, 0); SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A, SSB_SPROM8_ANTAVAIL_A_SHIFT); SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG, SSB_SPROM8_ANTAVAIL_BG_SHIFT); SPEX(maxpwr_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_MAXP_BG_MASK, 0); SPEX(itssi_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_ITSSI_BG, SSB_SPROM8_ITSSI_BG_SHIFT); SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0); SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A, SSB_SPROM8_ITSSI_A_SHIFT); SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0); SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK, SSB_SPROM8_MAXP_AL_SHIFT); SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0); SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1, SSB_SPROM8_GPIOA_P1_SHIFT); SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0); SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3, SSB_SPROM8_GPIOB_P3_SHIFT); SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0); SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G, SSB_SPROM8_TRI5G_SHIFT); SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0); SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH, SSB_SPROM8_TRI5GH_SHIFT); SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G, 0); SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G, SSB_SPROM8_RXPO5G_SHIFT); SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0); SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G, SSB_SPROM8_RSSISMC2G_SHIFT); SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G, SSB_SPROM8_RSSISAV2G_SHIFT); SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G, SSB_SPROM8_BXA2G_SHIFT); SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0); SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G, SSB_SPROM8_RSSISMC5G_SHIFT); SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G, SSB_SPROM8_RSSISAV5G_SHIFT); SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G, SSB_SPROM8_BXA5G_SHIFT); SPEX(pa0b0, SSB_SPROM8_PA0B0, 0xFFFF, 0); SPEX(pa0b1, SSB_SPROM8_PA0B1, 0xFFFF, 0); SPEX(pa0b2, SSB_SPROM8_PA0B2, 0xFFFF, 0); SPEX(pa1b0, SSB_SPROM8_PA1B0, 0xFFFF, 0); SPEX(pa1b1, SSB_SPROM8_PA1B1, 0xFFFF, 0); SPEX(pa1b2, SSB_SPROM8_PA1B2, 0xFFFF, 0); SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, 0xFFFF, 0); SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, 0xFFFF, 0); SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, 0xFFFF, 0); SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, 0xFFFF, 0); SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, 0xFFFF, 0); SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, 0xFFFF, 0); SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, 0xFFFF, 0); SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, 0xFFFFFFFF, 0); SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, 0xFFFFFFFF, 0); SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, 0xFFFFFFFF, 0); SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0); /* Extract the antenna gain values. */ SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01, SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT); SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01, SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT); SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23, SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT); SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23, SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT); /* Extract cores power info info */ for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { o = pwr_info_offset[i]; SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI, SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT); SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI, SSB_SPROM8_2G_MAXP, 0); SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0); SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0); SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0); SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI, SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT); SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI, SSB_SPROM8_5G_MAXP, 0); SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP, SSB_SPROM8_5GH_MAXP, 0); SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP, SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT); SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0); SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0); SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0); SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0); SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0); SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0); SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0); SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0); SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0); } /* Extract FEM info */ SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT); SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT); SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT); SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT); SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT); SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT); SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT); SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT); sprom_extract_r458(out, in); /* TODO - get remaining rev 8 stuff needed */ } static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out, const u16 *in, u16 size) { memset(out, 0, sizeof(*out)); out->revision = in[size - 1] & 0x00FF; ssb_dprintk(KERN_DEBUG PFX "SPROM revision %d detected.\n", out->revision); memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */ memset(out->et1mac, 0xFF, 6); if ((bus->chip_id & 0xFF00) == 0x4400) { /* Workaround: The BCM44XX chip has a stupid revision * number stored in the SPROM. * Always extract r1. */ out->revision = 1; ssb_dprintk(KERN_DEBUG PFX "SPROM treated as revision %d\n", out->revision); } switch (out->revision) { case 1: case 2: case 3: sprom_extract_r123(out, in); break; case 4: case 5: sprom_extract_r45(out, in); break; case 8: sprom_extract_r8(out, in); break; default: ssb_printk(KERN_WARNING PFX "Unsupported SPROM" " revision %d detected. Will extract" " v1\n", out->revision); out->revision = 1; sprom_extract_r123(out, in); } if (out->boardflags_lo == 0xFFFF) out->boardflags_lo = 0; /* per specs */ if (out->boardflags_hi == 0xFFFF) out->boardflags_hi = 0; /* per specs */ return 0; } static int ssb_pci_sprom_get(struct ssb_bus *bus, struct ssb_sprom *sprom) { int err; u16 *buf; if (!ssb_is_sprom_available(bus)) { ssb_printk(KERN_ERR PFX "No SPROM available!\n"); return -ENODEV; } if (bus->chipco.dev) { /* can be unavailable! */ /* * get SPROM offset: SSB_SPROM_BASE1 except for * chipcommon rev >= 31 or chip ID is 0x4312 and * chipcommon status & 3 == 2 */ if (bus->chipco.dev->id.revision >= 31) bus->sprom_offset = SSB_SPROM_BASE31; else if (bus->chip_id == 0x4312 && (bus->chipco.status & 0x03) == 2) bus->sprom_offset = SSB_SPROM_BASE31; else bus->sprom_offset = SSB_SPROM_BASE1; } else { bus->sprom_offset = SSB_SPROM_BASE1; } ssb_dprintk(KERN_INFO PFX "SPROM offset is 0x%x\n", bus->sprom_offset); buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL); if (!buf) return -ENOMEM; bus->sprom_size = SSB_SPROMSIZE_WORDS_R123; sprom_do_read(bus, buf); err = sprom_check_crc(buf, bus->sprom_size); if (err) { /* try for a 440 byte SPROM - revision 4 and higher */ kfree(buf); buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), GFP_KERNEL); if (!buf) return -ENOMEM; bus->sprom_size = SSB_SPROMSIZE_WORDS_R4; sprom_do_read(bus, buf); err = sprom_check_crc(buf, bus->sprom_size); if (err) { /* All CRC attempts failed. * Maybe there is no SPROM on the device? * Now we ask the arch code if there is some sprom * available for this device in some other storage */ err = ssb_fill_sprom_with_fallback(bus, sprom); if (err) { ssb_printk(KERN_WARNING PFX "WARNING: Using" " fallback SPROM failed (err %d)\n", err); } else { ssb_dprintk(KERN_DEBUG PFX "Using SPROM" " revision %d provided by" " platform.\n", sprom->revision); err = 0; goto out_free; } ssb_printk(KERN_WARNING PFX "WARNING: Invalid" " SPROM CRC (corrupt SPROM)\n"); } } err = sprom_extract(bus, sprom, buf, bus->sprom_size); out_free: kfree(buf); return err; } static void ssb_pci_get_boardinfo(struct ssb_bus *bus, struct ssb_boardinfo *bi) { bi->vendor = bus->host_pci->subsystem_vendor; bi->type = bus->host_pci->subsystem_device; bi->rev = bus->host_pci->revision; } int ssb_pci_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv) { int err; err = ssb_pci_sprom_get(bus, &iv->sprom); if (err) goto out; ssb_pci_get_boardinfo(bus, &iv->boardinfo); out: return err; } #ifdef CONFIG_SSB_DEBUG static int ssb_pci_assert_buspower(struct ssb_bus *bus) { if (likely(bus->powered_up)) return 0; printk(KERN_ERR PFX "FATAL ERROR: Bus powered down " "while accessing PCI MMIO space\n"); if (bus->power_warn_count <= 10) { bus->power_warn_count++; dump_stack(); } return -ENODEV; } #else /* DEBUG */ static inline int ssb_pci_assert_buspower(struct ssb_bus *bus) { return 0; } #endif /* DEBUG */ static u8 ssb_pci_read8(struct ssb_device *dev, u16 offset) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return 0xFF; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return 0xFF; } return ioread8(bus->mmio + offset); } static u16 ssb_pci_read16(struct ssb_device *dev, u16 offset) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return 0xFFFF; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return 0xFFFF; } return ioread16(bus->mmio + offset); } static u32 ssb_pci_read32(struct ssb_device *dev, u16 offset) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return 0xFFFFFFFF; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return 0xFFFFFFFF; } return ioread32(bus->mmio + offset); } #ifdef CONFIG_SSB_BLOCKIO static void ssb_pci_block_read(struct ssb_device *dev, void *buffer, size_t count, u16 offset, u8 reg_width) { struct ssb_bus *bus = dev->bus; void __iomem *addr = bus->mmio + offset; if (unlikely(ssb_pci_assert_buspower(bus))) goto error; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) goto error; } switch (reg_width) { case sizeof(u8): ioread8_rep(addr, buffer, count); break; case sizeof(u16): SSB_WARN_ON(count & 1); ioread16_rep(addr, buffer, count >> 1); break; case sizeof(u32): SSB_WARN_ON(count & 3); ioread32_rep(addr, buffer, count >> 2); break; default: SSB_WARN_ON(1); } return; error: memset(buffer, 0xFF, count); } #endif /* CONFIG_SSB_BLOCKIO */ static void ssb_pci_write8(struct ssb_device *dev, u16 offset, u8 value) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return; } iowrite8(value, bus->mmio + offset); } static void ssb_pci_write16(struct ssb_device *dev, u16 offset, u16 value) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return; } iowrite16(value, bus->mmio + offset); } static void ssb_pci_write32(struct ssb_device *dev, u16 offset, u32 value) { struct ssb_bus *bus = dev->bus; if (unlikely(ssb_pci_assert_buspower(bus))) return; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return; } iowrite32(value, bus->mmio + offset); } #ifdef CONFIG_SSB_BLOCKIO static void ssb_pci_block_write(struct ssb_device *dev, const void *buffer, size_t count, u16 offset, u8 reg_width) { struct ssb_bus *bus = dev->bus; void __iomem *addr = bus->mmio + offset; if (unlikely(ssb_pci_assert_buspower(bus))) return; if (unlikely(bus->mapped_device != dev)) { if (unlikely(ssb_pci_switch_core(bus, dev))) return; } switch (reg_width) { case sizeof(u8): iowrite8_rep(addr, buffer, count); break; case sizeof(u16): SSB_WARN_ON(count & 1); iowrite16_rep(addr, buffer, count >> 1); break; case sizeof(u32): SSB_WARN_ON(count & 3); iowrite32_rep(addr, buffer, count >> 2); break; default: SSB_WARN_ON(1); } } #endif /* CONFIG_SSB_BLOCKIO */ /* Not "static", as it's used in main.c */ const struct ssb_bus_ops ssb_pci_ops = { .read8 = ssb_pci_read8, .read16 = ssb_pci_read16, .read32 = ssb_pci_read32, .write8 = ssb_pci_write8, .write16 = ssb_pci_write16, .write32 = ssb_pci_write32, #ifdef CONFIG_SSB_BLOCKIO .block_read = ssb_pci_block_read, .block_write = ssb_pci_block_write, #endif }; static ssize_t ssb_pci_attr_sprom_show(struct device *pcidev, struct device_attribute *attr, char *buf) { struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev); struct ssb_bus *bus; bus = ssb_pci_dev_to_bus(pdev); if (!bus) return -ENODEV; return ssb_attr_sprom_show(bus, buf, sprom_do_read); } static ssize_t ssb_pci_attr_sprom_store(struct device *pcidev, struct device_attribute *attr, const char *buf, size_t count) { struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev); struct ssb_bus *bus; bus = ssb_pci_dev_to_bus(pdev); if (!bus) return -ENODEV; return ssb_attr_sprom_store(bus, buf, count, sprom_check_crc, sprom_do_write); } static DEVICE_ATTR(ssb_sprom, 0600, ssb_pci_attr_sprom_show, ssb_pci_attr_sprom_store); void ssb_pci_exit(struct ssb_bus *bus) { struct pci_dev *pdev; if (bus->bustype != SSB_BUSTYPE_PCI) return; pdev = bus->host_pci; device_remove_file(&pdev->dev, &dev_attr_ssb_sprom); } int ssb_pci_init(struct ssb_bus *bus) { struct pci_dev *pdev; int err; if (bus->bustype != SSB_BUSTYPE_PCI) return 0; pdev = bus->host_pci; mutex_init(&bus->sprom_mutex); err = device_create_file(&pdev->dev, &dev_attr_ssb_sprom); if (err) goto out; out: return err; }
#ifndef A3XX_XML #define A3XX_XML /* Autogenerated file, DO NOT EDIT manually! This file was generated by the rules-ng-ng headergen tool in this git repository: http://github.com/freedreno/envytools/ git clone https://github.com/freedreno/envytools.git The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml ( 364 bytes, from 2015-05-20 20:03:07) - /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml ( 1453 bytes, from 2015-05-20 20:03:07) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2015-05-20 20:03:14) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2015-05-20 20:03:14) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 14968 bytes, from 2015-05-20 20:12:27) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 67120 bytes, from 2015-08-14 23:22:03) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 63785 bytes, from 2015-08-14 18:27:06) Copyright (C) 2013-2015 by the following authors: - Rob Clark <robdclark@gmail.com> (robclark) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ enum a3xx_tile_mode { LINEAR = 0, TILE_32X32 = 2, }; enum a3xx_state_block_id { HLSQ_BLOCK_ID_TP_TEX = 2, HLSQ_BLOCK_ID_TP_MIPMAP = 3, HLSQ_BLOCK_ID_SP_VS = 4, HLSQ_BLOCK_ID_SP_FS = 6, }; enum a3xx_cache_opcode { INVALIDATE = 1, }; enum a3xx_vtx_fmt { VFMT_32_FLOAT = 0, VFMT_32_32_FLOAT = 1, VFMT_32_32_32_FLOAT = 2, VFMT_32_32_32_32_FLOAT = 3, VFMT_16_FLOAT = 4, VFMT_16_16_FLOAT = 5, VFMT_16_16_16_FLOAT = 6, VFMT_16_16_16_16_FLOAT = 7, VFMT_32_FIXED = 8, VFMT_32_32_FIXED = 9, VFMT_32_32_32_FIXED = 10, VFMT_32_32_32_32_FIXED = 11, VFMT_16_SINT = 16, VFMT_16_16_SINT = 17, VFMT_16_16_16_SINT = 18, VFMT_16_16_16_16_SINT = 19, VFMT_16_UINT = 20, VFMT_16_16_UINT = 21, VFMT_16_16_16_UINT = 22, VFMT_16_16_16_16_UINT = 23, VFMT_16_SNORM = 24, VFMT_16_16_SNORM = 25, VFMT_16_16_16_SNORM = 26, VFMT_16_16_16_16_SNORM = 27, VFMT_16_UNORM = 28, VFMT_16_16_UNORM = 29, VFMT_16_16_16_UNORM = 30, VFMT_16_16_16_16_UNORM = 31, VFMT_32_UINT = 32, VFMT_32_32_UINT = 33, VFMT_32_32_32_UINT = 34, VFMT_32_32_32_32_UINT = 35, VFMT_32_SINT = 36, VFMT_32_32_SINT = 37, VFMT_32_32_32_SINT = 38, VFMT_32_32_32_32_SINT = 39, VFMT_8_UINT = 40, VFMT_8_8_UINT = 41, VFMT_8_8_8_UINT = 42, VFMT_8_8_8_8_UINT = 43, VFMT_8_UNORM = 44, VFMT_8_8_UNORM = 45, VFMT_8_8_8_UNORM = 46, VFMT_8_8_8_8_UNORM = 47, VFMT_8_SINT = 48, VFMT_8_8_SINT = 49, VFMT_8_8_8_SINT = 50, VFMT_8_8_8_8_SINT = 51, VFMT_8_SNORM = 52, VFMT_8_8_SNORM = 53, VFMT_8_8_8_SNORM = 54, VFMT_8_8_8_8_SNORM = 55, VFMT_10_10_10_2_UINT = 60, VFMT_10_10_10_2_UNORM = 61, VFMT_10_10_10_2_SINT = 62, VFMT_10_10_10_2_SNORM = 63, }; enum a3xx_tex_fmt { TFMT_5_6_5_UNORM = 4, TFMT_5_5_5_1_UNORM = 5, TFMT_4_4_4_4_UNORM = 7, TFMT_Z16_UNORM = 9, TFMT_X8Z24_UNORM = 10, TFMT_Z32_FLOAT = 11, TFMT_NV12_UV_TILED = 17, TFMT_NV12_Y_TILED = 19, TFMT_NV12_UV = 21, TFMT_NV12_Y = 23, TFMT_I420_Y = 24, TFMT_I420_U = 26, TFMT_I420_V = 27, TFMT_ATC_RGB = 32, TFMT_ATC_RGBA_EXPLICIT = 33, TFMT_ETC1 = 34, TFMT_ATC_RGBA_INTERPOLATED = 35, TFMT_DXT1 = 36, TFMT_DXT3 = 37, TFMT_DXT5 = 38, TFMT_10_10_10_2_UNORM = 41, TFMT_9_9_9_E5_FLOAT = 42, TFMT_11_11_10_FLOAT = 43, TFMT_A8_UNORM = 44, TFMT_L8_A8_UNORM = 47, TFMT_8_UNORM = 48, TFMT_8_8_UNORM = 49, TFMT_8_8_8_UNORM = 50, TFMT_8_8_8_8_UNORM = 51, TFMT_8_SNORM = 52, TFMT_8_8_SNORM = 53, TFMT_8_8_8_SNORM = 54, TFMT_8_8_8_8_SNORM = 55, TFMT_8_UINT = 56, TFMT_8_8_UINT = 57, TFMT_8_8_8_UINT = 58, TFMT_8_8_8_8_UINT = 59, TFMT_8_SINT = 60, TFMT_8_8_SINT = 61, TFMT_8_8_8_SINT = 62, TFMT_8_8_8_8_SINT = 63, TFMT_16_FLOAT = 64, TFMT_16_16_FLOAT = 65, TFMT_16_16_16_16_FLOAT = 67, TFMT_16_UINT = 68, TFMT_16_16_UINT = 69, TFMT_16_16_16_16_UINT = 71, TFMT_16_SINT = 72, TFMT_16_16_SINT = 73, TFMT_16_16_16_16_SINT = 75, TFMT_16_UNORM = 76, TFMT_16_16_UNORM = 77, TFMT_16_16_16_16_UNORM = 79, TFMT_16_SNORM = 80, TFMT_16_16_SNORM = 81, TFMT_16_16_16_16_SNORM = 83, TFMT_32_FLOAT = 84, TFMT_32_32_FLOAT = 85, TFMT_32_32_32_32_FLOAT = 87, TFMT_32_UINT = 88, TFMT_32_32_UINT = 89, TFMT_32_32_32_32_UINT = 91, TFMT_32_SINT = 92, TFMT_32_32_SINT = 93, TFMT_32_32_32_32_SINT = 95, TFMT_ETC2_RG11_SNORM = 112, TFMT_ETC2_RG11_UNORM = 113, TFMT_ETC2_R11_SNORM = 114, TFMT_ETC2_R11_UNORM = 115, TFMT_ETC2_RGBA8 = 116, TFMT_ETC2_RGB8A1 = 117, TFMT_ETC2_RGB8 = 118, }; enum a3xx_tex_fetchsize { TFETCH_DISABLE = 0, TFETCH_1_BYTE = 1, TFETCH_2_BYTE = 2, TFETCH_4_BYTE = 3, TFETCH_8_BYTE = 4, TFETCH_16_BYTE = 5, }; enum a3xx_color_fmt { RB_R5G6B5_UNORM = 0, RB_R5G5B5A1_UNORM = 1, RB_R4G4B4A4_UNORM = 3, RB_R8G8B8_UNORM = 4, RB_R8G8B8A8_UNORM = 8, RB_R8G8B8A8_SNORM = 9, RB_R8G8B8A8_UINT = 10, RB_R8G8B8A8_SINT = 11, RB_R8G8_UNORM = 12, RB_R8G8_SNORM = 13, RB_R8_UINT = 14, RB_R8_SINT = 15, RB_R10G10B10A2_UNORM = 16, RB_A8_UNORM = 20, RB_R8_UNORM = 21, RB_R16_FLOAT = 24, RB_R16G16_FLOAT = 25, RB_R16G16B16A16_FLOAT = 27, RB_R11G11B10_FLOAT = 28, RB_R16_SNORM = 32, RB_R16G16_SNORM = 33, RB_R16G16B16A16_SNORM = 35, RB_R16_UNORM = 36, RB_R16G16_UNORM = 37, RB_R16G16B16A16_UNORM = 39, RB_R16_SINT = 40, RB_R16G16_SINT = 41, RB_R16G16B16A16_SINT = 43, RB_R16_UINT = 44, RB_R16G16_UINT = 45, RB_R16G16B16A16_UINT = 47, RB_R32_FLOAT = 48, RB_R32G32_FLOAT = 49, RB_R32G32B32A32_FLOAT = 51, RB_R32_SINT = 52, RB_R32G32_SINT = 53, RB_R32G32B32A32_SINT = 55, RB_R32_UINT = 56, RB_R32G32_UINT = 57, RB_R32G32B32A32_UINT = 59, }; enum a3xx_sp_perfcounter_select { SP_FS_CFLOW_INSTRUCTIONS = 12, SP_FS_FULL_ALU_INSTRUCTIONS = 14, SP0_ICL1_MISSES = 26, SP_ALU_ACTIVE_CYCLES = 29, }; enum a3xx_rop_code { ROP_CLEAR = 0, ROP_NOR = 1, ROP_AND_INVERTED = 2, ROP_COPY_INVERTED = 3, ROP_AND_REVERSE = 4, ROP_INVERT = 5, ROP_XOR = 6, ROP_NAND = 7, ROP_AND = 8, ROP_EQUIV = 9, ROP_NOOP = 10, ROP_OR_INVERTED = 11, ROP_COPY = 12, ROP_OR_REVERSE = 13, ROP_OR = 14, ROP_SET = 15, }; enum a3xx_rb_blend_opcode { BLEND_DST_PLUS_SRC = 0, BLEND_SRC_MINUS_DST = 1, BLEND_DST_MINUS_SRC = 2, BLEND_MIN_DST_SRC = 3, BLEND_MAX_DST_SRC = 4, }; enum a3xx_intp_mode { SMOOTH = 0, FLAT = 1, }; enum a3xx_repl_mode { S = 1, T = 2, ONE_T = 3, }; enum a3xx_tex_filter { A3XX_TEX_NEAREST = 0, A3XX_TEX_LINEAR = 1, A3XX_TEX_ANISO = 2, }; enum a3xx_tex_clamp { A3XX_TEX_REPEAT = 0, A3XX_TEX_CLAMP_TO_EDGE = 1, A3XX_TEX_MIRROR_REPEAT = 2, A3XX_TEX_CLAMP_TO_BORDER = 3, A3XX_TEX_MIRROR_CLAMP = 4, }; enum a3xx_tex_aniso { A3XX_TEX_ANISO_1 = 0, A3XX_TEX_ANISO_2 = 1, A3XX_TEX_ANISO_4 = 2, A3XX_TEX_ANISO_8 = 3, A3XX_TEX_ANISO_16 = 4, }; enum a3xx_tex_swiz { A3XX_TEX_X = 0, A3XX_TEX_Y = 1, A3XX_TEX_Z = 2, A3XX_TEX_W = 3, A3XX_TEX_ZERO = 4, A3XX_TEX_ONE = 5, }; enum a3xx_tex_type { A3XX_TEX_1D = 0, A3XX_TEX_2D = 1, A3XX_TEX_CUBE = 2, A3XX_TEX_3D = 3, }; enum a3xx_tex_msaa { A3XX_TPL1_MSAA1X = 0, A3XX_TPL1_MSAA2X = 1, A3XX_TPL1_MSAA4X = 2, A3XX_TPL1_MSAA8X = 3, }; #define A3XX_INT0_RBBM_GPU_IDLE 0x00000001 #define A3XX_INT0_RBBM_AHB_ERROR 0x00000002 #define A3XX_INT0_RBBM_REG_TIMEOUT 0x00000004 #define A3XX_INT0_RBBM_ME_MS_TIMEOUT 0x00000008 #define A3XX_INT0_RBBM_PFP_MS_TIMEOUT 0x00000010 #define A3XX_INT0_RBBM_ATB_BUS_OVERFLOW 0x00000020 #define A3XX_INT0_VFD_ERROR 0x00000040 #define A3XX_INT0_CP_SW_INT 0x00000080 #define A3XX_INT0_CP_T0_PACKET_IN_IB 0x00000100 #define A3XX_INT0_CP_OPCODE_ERROR 0x00000200 #define A3XX_INT0_CP_RESERVED_BIT_ERROR 0x00000400 #define A3XX_INT0_CP_HW_FAULT 0x00000800 #define A3XX_INT0_CP_DMA 0x00001000 #define A3XX_INT0_CP_IB2_INT 0x00002000 #define A3XX_INT0_CP_IB1_INT 0x00004000 #define A3XX_INT0_CP_RB_INT 0x00008000 #define A3XX_INT0_CP_REG_PROTECT_FAULT 0x00010000 #define A3XX_INT0_CP_RB_DONE_TS 0x00020000 #define A3XX_INT0_CP_VS_DONE_TS 0x00040000 #define A3XX_INT0_CP_PS_DONE_TS 0x00080000 #define A3XX_INT0_CACHE_FLUSH_TS 0x00100000 #define A3XX_INT0_CP_AHB_ERROR_HALT 0x00200000 #define A3XX_INT0_MISC_HANG_DETECT 0x01000000 #define A3XX_INT0_UCHE_OOB_ACCESS 0x02000000 #define REG_A3XX_RBBM_HW_VERSION 0x00000000 #define REG_A3XX_RBBM_HW_RELEASE 0x00000001 #define REG_A3XX_RBBM_HW_CONFIGURATION 0x00000002 #define REG_A3XX_RBBM_CLOCK_CTL 0x00000010 #define REG_A3XX_RBBM_SP_HYST_CNT 0x00000012 #define REG_A3XX_RBBM_SW_RESET_CMD 0x00000018 #define REG_A3XX_RBBM_AHB_CTL0 0x00000020 #define REG_A3XX_RBBM_AHB_CTL1 0x00000021 #define REG_A3XX_RBBM_AHB_CMD 0x00000022 #define REG_A3XX_RBBM_AHB_ERROR_STATUS 0x00000027 #define REG_A3XX_RBBM_GPR0_CTL 0x0000002e #define REG_A3XX_RBBM_STATUS 0x00000030 #define A3XX_RBBM_STATUS_HI_BUSY 0x00000001 #define A3XX_RBBM_STATUS_CP_ME_BUSY 0x00000002 #define A3XX_RBBM_STATUS_CP_PFP_BUSY 0x00000004 #define A3XX_RBBM_STATUS_CP_NRT_BUSY 0x00004000 #define A3XX_RBBM_STATUS_VBIF_BUSY 0x00008000 #define A3XX_RBBM_STATUS_TSE_BUSY 0x00010000 #define A3XX_RBBM_STATUS_RAS_BUSY 0x00020000 #define A3XX_RBBM_STATUS_RB_BUSY 0x00040000 #define A3XX_RBBM_STATUS_PC_DCALL_BUSY 0x00080000 #define A3XX_RBBM_STATUS_PC_VSD_BUSY 0x00100000 #define A3XX_RBBM_STATUS_VFD_BUSY 0x00200000 #define A3XX_RBBM_STATUS_VPC_BUSY 0x00400000 #define A3XX_RBBM_STATUS_UCHE_BUSY 0x00800000 #define A3XX_RBBM_STATUS_SP_BUSY 0x01000000 #define A3XX_RBBM_STATUS_TPL1_BUSY 0x02000000 #define A3XX_RBBM_STATUS_MARB_BUSY 0x04000000 #define A3XX_RBBM_STATUS_VSC_BUSY 0x08000000 #define A3XX_RBBM_STATUS_ARB_BUSY 0x10000000 #define A3XX_RBBM_STATUS_HLSQ_BUSY 0x20000000 #define A3XX_RBBM_STATUS_GPU_BUSY_NOHC 0x40000000 #define A3XX_RBBM_STATUS_GPU_BUSY 0x80000000 #define REG_A3XX_RBBM_NQWAIT_UNTIL 0x00000040 #define REG_A3XX_RBBM_WAIT_IDLE_CLOCKS_CTL 0x00000033 #define REG_A3XX_RBBM_INTERFACE_HANG_INT_CTL 0x00000050 #define REG_A3XX_RBBM_INTERFACE_HANG_MASK_CTL0 0x00000051 #define REG_A3XX_RBBM_INTERFACE_HANG_MASK_CTL1 0x00000054 #define REG_A3XX_RBBM_INTERFACE_HANG_MASK_CTL2 0x00000057 #define REG_A3XX_RBBM_INTERFACE_HANG_MASK_CTL3 0x0000005a #define REG_A3XX_RBBM_INT_SET_CMD 0x00000060 #define REG_A3XX_RBBM_INT_CLEAR_CMD 0x00000061 #define REG_A3XX_RBBM_INT_0_MASK 0x00000063 #define REG_A3XX_RBBM_INT_0_STATUS 0x00000064 #define REG_A3XX_RBBM_PERFCTR_CTL 0x00000080 #define A3XX_RBBM_PERFCTR_CTL_ENABLE 0x00000001 #define REG_A3XX_RBBM_PERFCTR_LOAD_CMD0 0x00000081 #define REG_A3XX_RBBM_PERFCTR_LOAD_CMD1 0x00000082 #define REG_A3XX_RBBM_PERFCTR_LOAD_VALUE_LO 0x00000084 #define REG_A3XX_RBBM_PERFCTR_LOAD_VALUE_HI 0x00000085 #define REG_A3XX_RBBM_PERFCOUNTER0_SELECT 0x00000086 #define REG_A3XX_RBBM_PERFCOUNTER1_SELECT 0x00000087 #define REG_A3XX_RBBM_GPU_BUSY_MASKED 0x00000088 #define REG_A3XX_RBBM_PERFCTR_CP_0_LO 0x00000090 #define REG_A3XX_RBBM_PERFCTR_CP_0_HI 0x00000091 #define REG_A3XX_RBBM_PERFCTR_RBBM_0_LO 0x00000092 #define REG_A3XX_RBBM_PERFCTR_RBBM_0_HI 0x00000093 #define REG_A3XX_RBBM_PERFCTR_RBBM_1_LO 0x00000094 #define REG_A3XX_RBBM_PERFCTR_RBBM_1_HI 0x00000095 #define REG_A3XX_RBBM_PERFCTR_PC_0_LO 0x00000096 #define REG_A3XX_RBBM_PERFCTR_PC_0_HI 0x00000097 #define REG_A3XX_RBBM_PERFCTR_PC_1_LO 0x00000098 #define REG_A3XX_RBBM_PERFCTR_PC_1_HI 0x00000099 #define REG_A3XX_RBBM_PERFCTR_PC_2_LO 0x0000009a #define REG_A3XX_RBBM_PERFCTR_PC_2_HI 0x0000009b #define REG_A3XX_RBBM_PERFCTR_PC_3_LO 0x0000009c #define REG_A3XX_RBBM_PERFCTR_PC_3_HI 0x0000009d #define REG_A3XX_RBBM_PERFCTR_VFD_0_LO 0x0000009e #define REG_A3XX_RBBM_PERFCTR_VFD_0_HI 0x0000009f #define REG_A3XX_RBBM_PERFCTR_VFD_1_LO 0x000000a0 #define REG_A3XX_RBBM_PERFCTR_VFD_1_HI 0x000000a1 #define REG_A3XX_RBBM_PERFCTR_HLSQ_0_LO 0x000000a2 #define REG_A3XX_RBBM_PERFCTR_HLSQ_0_HI 0x000000a3 #define REG_A3XX_RBBM_PERFCTR_HLSQ_1_LO 0x000000a4 #define REG_A3XX_RBBM_PERFCTR_HLSQ_1_HI 0x000000a5 #define REG_A3XX_RBBM_PERFCTR_HLSQ_2_LO 0x000000a6 #define REG_A3XX_RBBM_PERFCTR_HLSQ_2_HI 0x000000a7 #define REG_A3XX_RBBM_PERFCTR_HLSQ_3_LO 0x000000a8 #define REG_A3XX_RBBM_PERFCTR_HLSQ_3_HI 0x000000a9 #define REG_A3XX_RBBM_PERFCTR_HLSQ_4_LO 0x000000aa #define REG_A3XX_RBBM_PERFCTR_HLSQ_4_HI 0x000000ab #define REG_A3XX_RBBM_PERFCTR_HLSQ_5_LO 0x000000ac #define REG_A3XX_RBBM_PERFCTR_HLSQ_5_HI 0x000000ad #define REG_A3XX_RBBM_PERFCTR_VPC_0_LO 0x000000ae #define REG_A3XX_RBBM_PERFCTR_VPC_0_HI 0x000000af #define REG_A3XX_RBBM_PERFCTR_VPC_1_LO 0x000000b0 #define REG_A3XX_RBBM_PERFCTR_VPC_1_HI 0x000000b1 #define REG_A3XX_RBBM_PERFCTR_TSE_0_LO 0x000000b2 #define REG_A3XX_RBBM_PERFCTR_TSE_0_HI 0x000000b3 #define REG_A3XX_RBBM_PERFCTR_TSE_1_LO 0x000000b4 #define REG_A3XX_RBBM_PERFCTR_TSE_1_HI 0x000000b5 #define REG_A3XX_RBBM_PERFCTR_RAS_0_LO 0x000000b6 #define REG_A3XX_RBBM_PERFCTR_RAS_0_HI 0x000000b7 #define REG_A3XX_RBBM_PERFCTR_RAS_1_LO 0x000000b8 #define REG_A3XX_RBBM_PERFCTR_RAS_1_HI 0x000000b9 #define REG_A3XX_RBBM_PERFCTR_UCHE_0_LO 0x000000ba #define REG_A3XX_RBBM_PERFCTR_UCHE_0_HI 0x000000bb #define REG_A3XX_RBBM_PERFCTR_UCHE_1_LO 0x000000bc #define REG_A3XX_RBBM_PERFCTR_UCHE_1_HI 0x000000bd #define REG_A3XX_RBBM_PERFCTR_UCHE_2_LO 0x000000be #define REG_A3XX_RBBM_PERFCTR_UCHE_2_HI 0x000000bf #define REG_A3XX_RBBM_PERFCTR_UCHE_3_LO 0x000000c0 #define REG_A3XX_RBBM_PERFCTR_UCHE_3_HI 0x000000c1 #define REG_A3XX_RBBM_PERFCTR_UCHE_4_LO 0x000000c2 #define REG_A3XX_RBBM_PERFCTR_UCHE_4_HI 0x000000c3 #define REG_A3XX_RBBM_PERFCTR_UCHE_5_LO 0x000000c4 #define REG_A3XX_RBBM_PERFCTR_UCHE_5_HI 0x000000c5 #define REG_A3XX_RBBM_PERFCTR_TP_0_LO 0x000000c6 #define REG_A3XX_RBBM_PERFCTR_TP_0_HI 0x000000c7 #define REG_A3XX_RBBM_PERFCTR_TP_1_LO 0x000000c8 #define REG_A3XX_RBBM_PERFCTR_TP_1_HI 0x000000c9 #define REG_A3XX_RBBM_PERFCTR_TP_2_LO 0x000000ca #define REG_A3XX_RBBM_PERFCTR_TP_2_HI 0x000000cb #define REG_A3XX_RBBM_PERFCTR_TP_3_LO 0x000000cc #define REG_A3XX_RBBM_PERFCTR_TP_3_HI 0x000000cd #define REG_A3XX_RBBM_PERFCTR_TP_4_LO 0x000000ce #define REG_A3XX_RBBM_PERFCTR_TP_4_HI 0x000000cf #define REG_A3XX_RBBM_PERFCTR_TP_5_LO 0x000000d0 #define REG_A3XX_RBBM_PERFCTR_TP_5_HI 0x000000d1 #define REG_A3XX_RBBM_PERFCTR_SP_0_LO 0x000000d2 #define REG_A3XX_RBBM_PERFCTR_SP_0_HI 0x000000d3 #define REG_A3XX_RBBM_PERFCTR_SP_1_LO 0x000000d4 #define REG_A3XX_RBBM_PERFCTR_SP_1_HI 0x000000d5 #define REG_A3XX_RBBM_PERFCTR_SP_2_LO 0x000000d6 #define REG_A3XX_RBBM_PERFCTR_SP_2_HI 0x000000d7 #define REG_A3XX_RBBM_PERFCTR_SP_3_LO 0x000000d8 #define REG_A3XX_RBBM_PERFCTR_SP_3_HI 0x000000d9 #define REG_A3XX_RBBM_PERFCTR_SP_4_LO 0x000000da #define REG_A3XX_RBBM_PERFCTR_SP_4_HI 0x000000db #define REG_A3XX_RBBM_PERFCTR_SP_5_LO 0x000000dc #define REG_A3XX_RBBM_PERFCTR_SP_5_HI 0x000000dd #define REG_A3XX_RBBM_PERFCTR_SP_6_LO 0x000000de #define REG_A3XX_RBBM_PERFCTR_SP_6_HI 0x000000df #define REG_A3XX_RBBM_PERFCTR_SP_7_LO 0x000000e0 #define REG_A3XX_RBBM_PERFCTR_SP_7_HI 0x000000e1 #define REG_A3XX_RBBM_PERFCTR_RB_0_LO 0x000000e2 #define REG_A3XX_RBBM_PERFCTR_RB_0_HI 0x000000e3 #define REG_A3XX_RBBM_PERFCTR_RB_1_LO 0x000000e4 #define REG_A3XX_RBBM_PERFCTR_RB_1_HI 0x000000e5 #define REG_A3XX_RBBM_PERFCTR_PWR_0_LO 0x000000ea #define REG_A3XX_RBBM_PERFCTR_PWR_0_HI 0x000000eb #define REG_A3XX_RBBM_PERFCTR_PWR_1_LO 0x000000ec #define REG_A3XX_RBBM_PERFCTR_PWR_1_HI 0x000000ed #define REG_A3XX_RBBM_RBBM_CTL 0x00000100 #define REG_A3XX_RBBM_DEBUG_BUS_CTL 0x00000111 #define REG_A3XX_RBBM_DEBUG_BUS_DATA_STATUS 0x00000112 #define REG_A3XX_CP_PFP_UCODE_ADDR 0x000001c9 #define REG_A3XX_CP_PFP_UCODE_DATA 0x000001ca #define REG_A3XX_CP_ROQ_ADDR 0x000001cc #define REG_A3XX_CP_ROQ_DATA 0x000001cd #define REG_A3XX_CP_MERCIU_ADDR 0x000001d1 #define REG_A3XX_CP_MERCIU_DATA 0x000001d2 #define REG_A3XX_CP_MERCIU_DATA2 0x000001d3 #define REG_A3XX_CP_MEQ_ADDR 0x000001da #define REG_A3XX_CP_MEQ_DATA 0x000001db #define REG_A3XX_CP_WFI_PEND_CTR 0x000001f5 #define REG_A3XX_RBBM_PM_OVERRIDE2 0x0000039d #define REG_A3XX_CP_PERFCOUNTER_SELECT 0x00000445 #define REG_A3XX_CP_HW_FAULT 0x0000045c #define REG_A3XX_CP_PROTECT_CTRL 0x0000045e #define REG_A3XX_CP_PROTECT_STATUS 0x0000045f static inline uint32_t REG_A3XX_CP_PROTECT(uint32_t i0) { return 0x00000460 + 0x1*i0; } static inline uint32_t REG_A3XX_CP_PROTECT_REG(uint32_t i0) { return 0x00000460 + 0x1*i0; } #define REG_A3XX_CP_AHB_FAULT 0x0000054d #define REG_A3XX_SQ_GPR_MANAGEMENT 0x00000d00 #define REG_A3XX_SQ_INST_STORE_MANAGMENT 0x00000d02 #define REG_A3XX_TP0_CHICKEN 0x00000e1e #define REG_A3XX_SP_GLOBAL_MEM_SIZE 0x00000e22 #define REG_A3XX_SP_GLOBAL_MEM_ADDR 0x00000e23 #define REG_A3XX_GRAS_CL_CLIP_CNTL 0x00002040 #define A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER 0x00001000 #define A3XX_GRAS_CL_CLIP_CNTL_CLIP_DISABLE 0x00010000 #define A3XX_GRAS_CL_CLIP_CNTL_ZFAR_CLIP_DISABLE 0x00020000 #define A3XX_GRAS_CL_CLIP_CNTL_VP_CLIP_CODE_IGNORE 0x00080000 #define A3XX_GRAS_CL_CLIP_CNTL_VP_XFORM_DISABLE 0x00100000 #define A3XX_GRAS_CL_CLIP_CNTL_PERSP_DIVISION_DISABLE 0x00200000 #define A3XX_GRAS_CL_CLIP_CNTL_ZCOORD 0x00800000 #define A3XX_GRAS_CL_CLIP_CNTL_WCOORD 0x01000000 #define A3XX_GRAS_CL_CLIP_CNTL_ZCLIP_DISABLE 0x02000000 #define REG_A3XX_GRAS_CL_GB_CLIP_ADJ 0x00002044 #define A3XX_GRAS_CL_GB_CLIP_ADJ_HORZ__MASK 0x000003ff #define A3XX_GRAS_CL_GB_CLIP_ADJ_HORZ__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_GB_CLIP_ADJ_HORZ(uint32_t val) { return ((val) << A3XX_GRAS_CL_GB_CLIP_ADJ_HORZ__SHIFT) & A3XX_GRAS_CL_GB_CLIP_ADJ_HORZ__MASK; } #define A3XX_GRAS_CL_GB_CLIP_ADJ_VERT__MASK 0x000ffc00 #define A3XX_GRAS_CL_GB_CLIP_ADJ_VERT__SHIFT 10 static inline uint32_t A3XX_GRAS_CL_GB_CLIP_ADJ_VERT(uint32_t val) { return ((val) << A3XX_GRAS_CL_GB_CLIP_ADJ_VERT__SHIFT) & A3XX_GRAS_CL_GB_CLIP_ADJ_VERT__MASK; } #define REG_A3XX_GRAS_CL_VPORT_XOFFSET 0x00002048 #define A3XX_GRAS_CL_VPORT_XOFFSET__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_XOFFSET__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_XOFFSET(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_XOFFSET__SHIFT) & A3XX_GRAS_CL_VPORT_XOFFSET__MASK; } #define REG_A3XX_GRAS_CL_VPORT_XSCALE 0x00002049 #define A3XX_GRAS_CL_VPORT_XSCALE__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_XSCALE__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_XSCALE(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_XSCALE__SHIFT) & A3XX_GRAS_CL_VPORT_XSCALE__MASK; } #define REG_A3XX_GRAS_CL_VPORT_YOFFSET 0x0000204a #define A3XX_GRAS_CL_VPORT_YOFFSET__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_YOFFSET__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_YOFFSET(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_YOFFSET__SHIFT) & A3XX_GRAS_CL_VPORT_YOFFSET__MASK; } #define REG_A3XX_GRAS_CL_VPORT_YSCALE 0x0000204b #define A3XX_GRAS_CL_VPORT_YSCALE__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_YSCALE__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_YSCALE(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_YSCALE__SHIFT) & A3XX_GRAS_CL_VPORT_YSCALE__MASK; } #define REG_A3XX_GRAS_CL_VPORT_ZOFFSET 0x0000204c #define A3XX_GRAS_CL_VPORT_ZOFFSET__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_ZOFFSET__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_ZOFFSET(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_ZOFFSET__SHIFT) & A3XX_GRAS_CL_VPORT_ZOFFSET__MASK; } #define REG_A3XX_GRAS_CL_VPORT_ZSCALE 0x0000204d #define A3XX_GRAS_CL_VPORT_ZSCALE__MASK 0xffffffff #define A3XX_GRAS_CL_VPORT_ZSCALE__SHIFT 0 static inline uint32_t A3XX_GRAS_CL_VPORT_ZSCALE(float val) { return ((fui(val)) << A3XX_GRAS_CL_VPORT_ZSCALE__SHIFT) & A3XX_GRAS_CL_VPORT_ZSCALE__MASK; } #define REG_A3XX_GRAS_SU_POINT_MINMAX 0x00002068 #define A3XX_GRAS_SU_POINT_MINMAX_MIN__MASK 0x0000ffff #define A3XX_GRAS_SU_POINT_MINMAX_MIN__SHIFT 0 static inline uint32_t A3XX_GRAS_SU_POINT_MINMAX_MIN(float val) { return ((((uint32_t)(val * 16.0))) << A3XX_GRAS_SU_POINT_MINMAX_MIN__SHIFT) & A3XX_GRAS_SU_POINT_MINMAX_MIN__MASK; } #define A3XX_GRAS_SU_POINT_MINMAX_MAX__MASK 0xffff0000 #define A3XX_GRAS_SU_POINT_MINMAX_MAX__SHIFT 16 static inline uint32_t A3XX_GRAS_SU_POINT_MINMAX_MAX(float val) { return ((((uint32_t)(val * 16.0))) << A3XX_GRAS_SU_POINT_MINMAX_MAX__SHIFT) & A3XX_GRAS_SU_POINT_MINMAX_MAX__MASK; } #define REG_A3XX_GRAS_SU_POINT_SIZE 0x00002069 #define A3XX_GRAS_SU_POINT_SIZE__MASK 0xffffffff #define A3XX_GRAS_SU_POINT_SIZE__SHIFT 0 static inline uint32_t A3XX_GRAS_SU_POINT_SIZE(float val) { return ((((int32_t)(val * 16.0))) << A3XX_GRAS_SU_POINT_SIZE__SHIFT) & A3XX_GRAS_SU_POINT_SIZE__MASK; } #define REG_A3XX_GRAS_SU_POLY_OFFSET_SCALE 0x0000206c #define A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL__MASK 0x00ffffff #define A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL__SHIFT 0 static inline uint32_t A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL(float val) { return ((((int32_t)(val * 16384.0))) << A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL__SHIFT) & A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL__MASK; } #define REG_A3XX_GRAS_SU_POLY_OFFSET_OFFSET 0x0000206d #define A3XX_GRAS_SU_POLY_OFFSET_OFFSET__MASK 0xffffffff #define A3XX_GRAS_SU_POLY_OFFSET_OFFSET__SHIFT 0 static inline uint32_t A3XX_GRAS_SU_POLY_OFFSET_OFFSET(float val) { return ((((int32_t)(val * 64.0))) << A3XX_GRAS_SU_POLY_OFFSET_OFFSET__SHIFT) & A3XX_GRAS_SU_POLY_OFFSET_OFFSET__MASK; } #define REG_A3XX_GRAS_SU_MODE_CONTROL 0x00002070 #define A3XX_GRAS_SU_MODE_CONTROL_CULL_FRONT 0x00000001 #define A3XX_GRAS_SU_MODE_CONTROL_CULL_BACK 0x00000002 #define A3XX_GRAS_SU_MODE_CONTROL_FRONT_CW 0x00000004 #define A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH__MASK 0x000007f8 #define A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH__SHIFT 3 static inline uint32_t A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(float val) { return ((((int32_t)(val * 4.0))) << A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH__SHIFT) & A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH__MASK; } #define A3XX_GRAS_SU_MODE_CONTROL_POLY_OFFSET 0x00000800 #define REG_A3XX_GRAS_SC_CONTROL 0x00002072 #define A3XX_GRAS_SC_CONTROL_RENDER_MODE__MASK 0x000000f0 #define A3XX_GRAS_SC_CONTROL_RENDER_MODE__SHIFT 4 static inline uint32_t A3XX_GRAS_SC_CONTROL_RENDER_MODE(enum a3xx_render_mode val) { return ((val) << A3XX_GRAS_SC_CONTROL_RENDER_MODE__SHIFT) & A3XX_GRAS_SC_CONTROL_RENDER_MODE__MASK; } #define A3XX_GRAS_SC_CONTROL_MSAA_SAMPLES__MASK 0x00000f00 #define A3XX_GRAS_SC_CONTROL_MSAA_SAMPLES__SHIFT 8 static inline uint32_t A3XX_GRAS_SC_CONTROL_MSAA_SAMPLES(enum a3xx_msaa_samples val) { return ((val) << A3XX_GRAS_SC_CONTROL_MSAA_SAMPLES__SHIFT) & A3XX_GRAS_SC_CONTROL_MSAA_SAMPLES__MASK; } #define A3XX_GRAS_SC_CONTROL_RASTER_MODE__MASK 0x0000f000 #define A3XX_GRAS_SC_CONTROL_RASTER_MODE__SHIFT 12 static inline uint32_t A3XX_GRAS_SC_CONTROL_RASTER_MODE(uint32_t val) { return ((val) << A3XX_GRAS_SC_CONTROL_RASTER_MODE__SHIFT) & A3XX_GRAS_SC_CONTROL_RASTER_MODE__MASK; } #define REG_A3XX_GRAS_SC_SCREEN_SCISSOR_TL 0x00002074 #define A3XX_GRAS_SC_SCREEN_SCISSOR_TL_WINDOW_OFFSET_DISABLE 0x80000000 #define A3XX_GRAS_SC_SCREEN_SCISSOR_TL_X__MASK 0x00007fff #define A3XX_GRAS_SC_SCREEN_SCISSOR_TL_X__SHIFT 0 static inline uint32_t A3XX_GRAS_SC_SCREEN_SCISSOR_TL_X(uint32_t val) { return ((val) << A3XX_GRAS_SC_SCREEN_SCISSOR_TL_X__SHIFT) & A3XX_GRAS_SC_SCREEN_SCISSOR_TL_X__MASK; } #define A3XX_GRAS_SC_SCREEN_SCISSOR_TL_Y__MASK 0x7fff0000 #define A3XX_GRAS_SC_SCREEN_SCISSOR_TL_Y__SHIFT 16 static inline uint32_t A3XX_GRAS_SC_SCREEN_SCISSOR_TL_Y(uint32_t val) { return ((val) << A3XX_GRAS_SC_SCREEN_SCISSOR_TL_Y__SHIFT) & A3XX_GRAS_SC_SCREEN_SCISSOR_TL_Y__MASK; } #define REG_A3XX_GRAS_SC_SCREEN_SCISSOR_BR 0x00002075 #define A3XX_GRAS_SC_SCREEN_SCISSOR_BR_WINDOW_OFFSET_DISABLE 0x80000000 #define A3XX_GRAS_SC_SCREEN_SCISSOR_BR_X__MASK 0x00007fff #define A3XX_GRAS_SC_SCREEN_SCISSOR_BR_X__SHIFT 0 static inline uint32_t A3XX_GRAS_SC_SCREEN_SCISSOR_BR_X(uint32_t val) { return ((val) << A3XX_GRAS_SC_SCREEN_SCISSOR_BR_X__SHIFT) & A3XX_GRAS_SC_SCREEN_SCISSOR_BR_X__MASK; } #define A3XX_GRAS_SC_SCREEN_SCISSOR_BR_Y__MASK 0x7fff0000 #define A3XX_GRAS_SC_SCREEN_SCISSOR_BR_Y__SHIFT 16 static inline uint32_t A3XX_GRAS_SC_SCREEN_SCISSOR_BR_Y(uint32_t val) { return ((val) << A3XX_GRAS_SC_SCREEN_SCISSOR_BR_Y__SHIFT) & A3XX_GRAS_SC_SCREEN_SCISSOR_BR_Y__MASK; } #define REG_A3XX_GRAS_SC_WINDOW_SCISSOR_TL 0x00002079 #define A3XX_GRAS_SC_WINDOW_SCISSOR_TL_WINDOW_OFFSET_DISABLE 0x80000000 #define A3XX_GRAS_SC_WINDOW_SCISSOR_TL_X__MASK 0x00007fff #define A3XX_GRAS_SC_WINDOW_SCISSOR_TL_X__SHIFT 0 static inline uint32_t A3XX_GRAS_SC_WINDOW_SCISSOR_TL_X(uint32_t val) { return ((val) << A3XX_GRAS_SC_WINDOW_SCISSOR_TL_X__SHIFT) & A3XX_GRAS_SC_WINDOW_SCISSOR_TL_X__MASK; } #define A3XX_GRAS_SC_WINDOW_SCISSOR_TL_Y__MASK 0x7fff0000 #define A3XX_GRAS_SC_WINDOW_SCISSOR_TL_Y__SHIFT 16 static inline uint32_t A3XX_GRAS_SC_WINDOW_SCISSOR_TL_Y(uint32_t val) { return ((val) << A3XX_GRAS_SC_WINDOW_SCISSOR_TL_Y__SHIFT) & A3XX_GRAS_SC_WINDOW_SCISSOR_TL_Y__MASK; } #define REG_A3XX_GRAS_SC_WINDOW_SCISSOR_BR 0x0000207a #define A3XX_GRAS_SC_WINDOW_SCISSOR_BR_WINDOW_OFFSET_DISABLE 0x80000000 #define A3XX_GRAS_SC_WINDOW_SCISSOR_BR_X__MASK 0x00007fff #define A3XX_GRAS_SC_WINDOW_SCISSOR_BR_X__SHIFT 0 static inline uint32_t A3XX_GRAS_SC_WINDOW_SCISSOR_BR_X(uint32_t val) { return ((val) << A3XX_GRAS_SC_WINDOW_SCISSOR_BR_X__SHIFT) & A3XX_GRAS_SC_WINDOW_SCISSOR_BR_X__MASK; } #define A3XX_GRAS_SC_WINDOW_SCISSOR_BR_Y__MASK 0x7fff0000 #define A3XX_GRAS_SC_WINDOW_SCISSOR_BR_Y__SHIFT 16 static inline uint32_t A3XX_GRAS_SC_WINDOW_SCISSOR_BR_Y(uint32_t val) { return ((val) << A3XX_GRAS_SC_WINDOW_SCISSOR_BR_Y__SHIFT) & A3XX_GRAS_SC_WINDOW_SCISSOR_BR_Y__MASK; } #define REG_A3XX_RB_MODE_CONTROL 0x000020c0 #define A3XX_RB_MODE_CONTROL_GMEM_BYPASS 0x00000080 #define A3XX_RB_MODE_CONTROL_RENDER_MODE__MASK 0x00000700 #define A3XX_RB_MODE_CONTROL_RENDER_MODE__SHIFT 8 static inline uint32_t A3XX_RB_MODE_CONTROL_RENDER_MODE(enum a3xx_render_mode val) { return ((val) << A3XX_RB_MODE_CONTROL_RENDER_MODE__SHIFT) & A3XX_RB_MODE_CONTROL_RENDER_MODE__MASK; } #define A3XX_RB_MODE_CONTROL_MRT__MASK 0x00003000 #define A3XX_RB_MODE_CONTROL_MRT__SHIFT 12 static inline uint32_t A3XX_RB_MODE_CONTROL_MRT(uint32_t val) { return ((val) << A3XX_RB_MODE_CONTROL_MRT__SHIFT) & A3XX_RB_MODE_CONTROL_MRT__MASK; } #define A3XX_RB_MODE_CONTROL_MARB_CACHE_SPLIT_MODE 0x00008000 #define A3XX_RB_MODE_CONTROL_PACKER_TIMER_ENABLE 0x00010000 #define REG_A3XX_RB_RENDER_CONTROL 0x000020c1 #define A3XX_RB_RENDER_CONTROL_FACENESS 0x00000008 #define A3XX_RB_RENDER_CONTROL_BIN_WIDTH__MASK 0x00000ff0 #define A3XX_RB_RENDER_CONTROL_BIN_WIDTH__SHIFT 4 static inline uint32_t A3XX_RB_RENDER_CONTROL_BIN_WIDTH(uint32_t val) { return ((val >> 5) << A3XX_RB_RENDER_CONTROL_BIN_WIDTH__SHIFT) & A3XX_RB_RENDER_CONTROL_BIN_WIDTH__MASK; } #define A3XX_RB_RENDER_CONTROL_DISABLE_COLOR_PIPE 0x00001000 #define A3XX_RB_RENDER_CONTROL_ENABLE_GMEM 0x00002000 #define A3XX_RB_RENDER_CONTROL_XCOORD 0x00004000 #define A3XX_RB_RENDER_CONTROL_YCOORD 0x00008000 #define A3XX_RB_RENDER_CONTROL_ZCOORD 0x00010000 #define A3XX_RB_RENDER_CONTROL_WCOORD 0x00020000 #define A3XX_RB_RENDER_CONTROL_ALPHA_TEST 0x00400000 #define A3XX_RB_RENDER_CONTROL_ALPHA_TEST_FUNC__MASK 0x07000000 #define A3XX_RB_RENDER_CONTROL_ALPHA_TEST_FUNC__SHIFT 24 static inline uint32_t A3XX_RB_RENDER_CONTROL_ALPHA_TEST_FUNC(enum adreno_compare_func val) { return ((val) << A3XX_RB_RENDER_CONTROL_ALPHA_TEST_FUNC__SHIFT) & A3XX_RB_RENDER_CONTROL_ALPHA_TEST_FUNC__MASK; } #define REG_A3XX_RB_MSAA_CONTROL 0x000020c2 #define A3XX_RB_MSAA_CONTROL_DISABLE 0x00000400 #define A3XX_RB_MSAA_CONTROL_SAMPLES__MASK 0x0000f000 #define A3XX_RB_MSAA_CONTROL_SAMPLES__SHIFT 12 static inline uint32_t A3XX_RB_MSAA_CONTROL_SAMPLES(enum a3xx_msaa_samples val) { return ((val) << A3XX_RB_MSAA_CONTROL_SAMPLES__SHIFT) & A3XX_RB_MSAA_CONTROL_SAMPLES__MASK; } #define A3XX_RB_MSAA_CONTROL_SAMPLE_MASK__MASK 0xffff0000 #define A3XX_RB_MSAA_CONTROL_SAMPLE_MASK__SHIFT 16 static inline uint32_t A3XX_RB_MSAA_CONTROL_SAMPLE_MASK(uint32_t val) { return ((val) << A3XX_RB_MSAA_CONTROL_SAMPLE_MASK__SHIFT) & A3XX_RB_MSAA_CONTROL_SAMPLE_MASK__MASK; } #define REG_A3XX_RB_ALPHA_REF 0x000020c3 #define A3XX_RB_ALPHA_REF_UINT__MASK 0x0000ff00 #define A3XX_RB_ALPHA_REF_UINT__SHIFT 8 static inline uint32_t A3XX_RB_ALPHA_REF_UINT(uint32_t val) { return ((val) << A3XX_RB_ALPHA_REF_UINT__SHIFT) & A3XX_RB_ALPHA_REF_UINT__MASK; } #define A3XX_RB_ALPHA_REF_FLOAT__MASK 0xffff0000 #define A3XX_RB_ALPHA_REF_FLOAT__SHIFT 16 static inline uint32_t A3XX_RB_ALPHA_REF_FLOAT(float val) { return ((util_float_to_half(val)) << A3XX_RB_ALPHA_REF_FLOAT__SHIFT) & A3XX_RB_ALPHA_REF_FLOAT__MASK; } static inline uint32_t REG_A3XX_RB_MRT(uint32_t i0) { return 0x000020c4 + 0x4*i0; } static inline uint32_t REG_A3XX_RB_MRT_CONTROL(uint32_t i0) { return 0x000020c4 + 0x4*i0; } #define A3XX_RB_MRT_CONTROL_READ_DEST_ENABLE 0x00000008 #define A3XX_RB_MRT_CONTROL_BLEND 0x00000010 #define A3XX_RB_MRT_CONTROL_BLEND2 0x00000020 #define A3XX_RB_MRT_CONTROL_ROP_CODE__MASK 0x00000f00 #define A3XX_RB_MRT_CONTROL_ROP_CODE__SHIFT 8 static inline uint32_t A3XX_RB_MRT_CONTROL_ROP_CODE(enum a3xx_rop_code val) { return ((val) << A3XX_RB_MRT_CONTROL_ROP_CODE__SHIFT) & A3XX_RB_MRT_CONTROL_ROP_CODE__MASK; } #define A3XX_RB_MRT_CONTROL_DITHER_MODE__MASK 0x00003000 #define A3XX_RB_MRT_CONTROL_DITHER_MODE__SHIFT 12 static inline uint32_t A3XX_RB_MRT_CONTROL_DITHER_MODE(enum adreno_rb_dither_mode val) { return ((val) << A3XX_RB_MRT_CONTROL_DITHER_MODE__SHIFT) & A3XX_RB_MRT_CONTROL_DITHER_MODE__MASK; } #define A3XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK 0x0f000000 #define A3XX_RB_MRT_CONTROL_COMPONENT_ENABLE__SHIFT 24 static inline uint32_t A3XX_RB_MRT_CONTROL_COMPONENT_ENABLE(uint32_t val) { return ((val) << A3XX_RB_MRT_CONTROL_COMPONENT_ENABLE__SHIFT) & A3XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK; } static inline uint32_t REG_A3XX_RB_MRT_BUF_INFO(uint32_t i0) { return 0x000020c5 + 0x4*i0; } #define A3XX_RB_MRT_BUF_INFO_COLOR_FORMAT__MASK 0x0000003f #define A3XX_RB_MRT_BUF_INFO_COLOR_FORMAT__SHIFT 0 static inline uint32_t A3XX_RB_MRT_BUF_INFO_COLOR_FORMAT(enum a3xx_color_fmt val) { return ((val) << A3XX_RB_MRT_BUF_INFO_COLOR_FORMAT__SHIFT) & A3XX_RB_MRT_BUF_INFO_COLOR_FORMAT__MASK; } #define A3XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE__MASK 0x000000c0 #define A3XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE__SHIFT 6 static inline uint32_t A3XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(enum a3xx_tile_mode val) { return ((val) << A3XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE__SHIFT) & A3XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE__MASK; } #define A3XX_RB_MRT_BUF_INFO_COLOR_SWAP__MASK 0x00000c00 #define A3XX_RB_MRT_BUF_INFO_COLOR_SWAP__SHIFT 10 static inline uint32_t A3XX_RB_MRT_BUF_INFO_COLOR_SWAP(enum a3xx_color_swap val) { return ((val) << A3XX_RB_MRT_BUF_INFO_COLOR_SWAP__SHIFT) & A3XX_RB_MRT_BUF_INFO_COLOR_SWAP__MASK; } #define A3XX_RB_MRT_BUF_INFO_COLOR_SRGB 0x00004000 #define A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH__MASK 0xfffe0000 #define A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH__SHIFT 17 static inline uint32_t A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH(uint32_t val) { return ((val >> 5) << A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH__SHIFT) & A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH__MASK; } static inline uint32_t REG_A3XX_RB_MRT_BUF_BASE(uint32_t i0) { return 0x000020c6 + 0x4*i0; } #define A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE__MASK 0xfffffff0 #define A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE__SHIFT 4 static inline uint32_t A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE(uint32_t val) { return ((val >> 5) << A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE__SHIFT) & A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE__MASK; } static inline uint32_t REG_A3XX_RB_MRT_BLEND_CONTROL(uint32_t i0) { return 0x000020c7 + 0x4*i0; } #define A3XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR__MASK 0x0000001f #define A3XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR__SHIFT 0 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(enum adreno_rb_blend_factor val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE__MASK 0x000000e0 #define A3XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE__SHIFT 5 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(enum a3xx_rb_blend_opcode val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR__MASK 0x00001f00 #define A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR__SHIFT 8 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(enum adreno_rb_blend_factor val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR__MASK 0x001f0000 #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR__SHIFT 16 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR(enum adreno_rb_blend_factor val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE__MASK 0x00e00000 #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE__SHIFT 21 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE(enum a3xx_rb_blend_opcode val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__MASK 0x1f000000 #define A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__SHIFT 24 static inline uint32_t A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(enum adreno_rb_blend_factor val) { return ((val) << A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__SHIFT) & A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__MASK; } #define A3XX_RB_MRT_BLEND_CONTROL_CLAMP_ENABLE 0x20000000 #define REG_A3XX_RB_BLEND_RED 0x000020e4 #define A3XX_RB_BLEND_RED_UINT__MASK 0x000000ff #define A3XX_RB_BLEND_RED_UINT__SHIFT 0 static inline uint32_t A3XX_RB_BLEND_RED_UINT(uint32_t val) { return ((val) << A3XX_RB_BLEND_RED_UINT__SHIFT) & A3XX_RB_BLEND_RED_UINT__MASK; } #define A3XX_RB_BLEND_RED_FLOAT__MASK 0xffff0000 #define A3XX_RB_BLEND_RED_FLOAT__SHIFT 16 static inline uint32_t A3XX_RB_BLEND_RED_FLOAT(float val) { return ((util_float_to_half(val)) << A3XX_RB_BLEND_RED_FLOAT__SHIFT) & A3XX_RB_BLEND_RED_FLOAT__MASK; } #define REG_A3XX_RB_BLEND_GREEN 0x000020e5 #define A3XX_RB_BLEND_GREEN_UINT__MASK 0x000000ff #define A3XX_RB_BLEND_GREEN_UINT__SHIFT 0 static inline uint32_t A3XX_RB_BLEND_GREEN_UINT(uint32_t val) { return ((val) << A3XX_RB_BLEND_GREEN_UINT__SHIFT) & A3XX_RB_BLEND_GREEN_UINT__MASK; } #define A3XX_RB_BLEND_GREEN_FLOAT__MASK 0xffff0000 #define A3XX_RB_BLEND_GREEN_FLOAT__SHIFT 16 static inline uint32_t A3XX_RB_BLEND_GREEN_FLOAT(float val) { return ((util_float_to_half(val)) << A3XX_RB_BLEND_GREEN_FLOAT__SHIFT) & A3XX_RB_BLEND_GREEN_FLOAT__MASK; } #define REG_A3XX_RB_BLEND_BLUE 0x000020e6 #define A3XX_RB_BLEND_BLUE_UINT__MASK 0x000000ff #define A3XX_RB_BLEND_BLUE_UINT__SHIFT 0 static inline uint32_t A3XX_RB_BLEND_BLUE_UINT(uint32_t val) { return ((val) << A3XX_RB_BLEND_BLUE_UINT__SHIFT) & A3XX_RB_BLEND_BLUE_UINT__MASK; } #define A3XX_RB_BLEND_BLUE_FLOAT__MASK 0xffff0000 #define A3XX_RB_BLEND_BLUE_FLOAT__SHIFT 16 static inline uint32_t A3XX_RB_BLEND_BLUE_FLOAT(float val) { return ((util_float_to_half(val)) << A3XX_RB_BLEND_BLUE_FLOAT__SHIFT) & A3XX_RB_BLEND_BLUE_FLOAT__MASK; } #define REG_A3XX_RB_BLEND_ALPHA 0x000020e7 #define A3XX_RB_BLEND_ALPHA_UINT__MASK 0x000000ff #define A3XX_RB_BLEND_ALPHA_UINT__SHIFT 0 static inline uint32_t A3XX_RB_BLEND_ALPHA_UINT(uint32_t val) { return ((val) << A3XX_RB_BLEND_ALPHA_UINT__SHIFT) & A3XX_RB_BLEND_ALPHA_UINT__MASK; } #define A3XX_RB_BLEND_ALPHA_FLOAT__MASK 0xffff0000 #define A3XX_RB_BLEND_ALPHA_FLOAT__SHIFT 16 static inline uint32_t A3XX_RB_BLEND_ALPHA_FLOAT(float val) { return ((util_float_to_half(val)) << A3XX_RB_BLEND_ALPHA_FLOAT__SHIFT) & A3XX_RB_BLEND_ALPHA_FLOAT__MASK; } #define REG_A3XX_RB_CLEAR_COLOR_DW0 0x000020e8 #define REG_A3XX_RB_CLEAR_COLOR_DW1 0x000020e9 #define REG_A3XX_RB_CLEAR_COLOR_DW2 0x000020ea #define REG_A3XX_RB_CLEAR_COLOR_DW3 0x000020eb #define REG_A3XX_RB_COPY_CONTROL 0x000020ec #define A3XX_RB_COPY_CONTROL_MSAA_RESOLVE__MASK 0x00000003 #define A3XX_RB_COPY_CONTROL_MSAA_RESOLVE__SHIFT 0 static inline uint32_t A3XX_RB_COPY_CONTROL_MSAA_RESOLVE(enum a3xx_msaa_samples val) { return ((val) << A3XX_RB_COPY_CONTROL_MSAA_RESOLVE__SHIFT) & A3XX_RB_COPY_CONTROL_MSAA_RESOLVE__MASK; } #define A3XX_RB_COPY_CONTROL_DEPTHCLEAR 0x00000008 #define A3XX_RB_COPY_CONTROL_MODE__MASK 0x00000070 #define A3XX_RB_COPY_CONTROL_MODE__SHIFT 4 static inline uint32_t A3XX_RB_COPY_CONTROL_MODE(enum adreno_rb_copy_control_mode val) { return ((val) << A3XX_RB_COPY_CONTROL_MODE__SHIFT) & A3XX_RB_COPY_CONTROL_MODE__MASK; } #define A3XX_RB_COPY_CONTROL_FASTCLEAR__MASK 0x00000f00 #define A3XX_RB_COPY_CONTROL_FASTCLEAR__SHIFT 8 static inline uint32_t A3XX_RB_COPY_CONTROL_FASTCLEAR(uint32_t val) { return ((val) << A3XX_RB_COPY_CONTROL_FASTCLEAR__SHIFT) & A3XX_RB_COPY_CONTROL_FASTCLEAR__MASK; } #define A3XX_RB_COPY_CONTROL_UNK12 0x00001000 #define A3XX_RB_COPY_CONTROL_GMEM_BASE__MASK 0xffffc000 #define A3XX_RB_COPY_CONTROL_GMEM_BASE__SHIFT 14 static inline uint32_t A3XX_RB_COPY_CONTROL_GMEM_BASE(uint32_t val) { return ((val >> 14) << A3XX_RB_COPY_CONTROL_GMEM_BASE__SHIFT) & A3XX_RB_COPY_CONTROL_GMEM_BASE__MASK; } #define REG_A3XX_RB_COPY_DEST_BASE 0x000020ed #define A3XX_RB_COPY_DEST_BASE_BASE__MASK 0xfffffff0 #define A3XX_RB_COPY_DEST_BASE_BASE__SHIFT 4 static inline uint32_t A3XX_RB_COPY_DEST_BASE_BASE(uint32_t val) { return ((val >> 5) << A3XX_RB_COPY_DEST_BASE_BASE__SHIFT) & A3XX_RB_COPY_DEST_BASE_BASE__MASK; } #define REG_A3XX_RB_COPY_DEST_PITCH 0x000020ee #define A3XX_RB_COPY_DEST_PITCH_PITCH__MASK 0xffffffff #define A3XX_RB_COPY_DEST_PITCH_PITCH__SHIFT 0 static inline uint32_t A3XX_RB_COPY_DEST_PITCH_PITCH(uint32_t val) { return ((val >> 5) << A3XX_RB_COPY_DEST_PITCH_PITCH__SHIFT) & A3XX_RB_COPY_DEST_PITCH_PITCH__MASK; } #define REG_A3XX_RB_COPY_DEST_INFO 0x000020ef #define A3XX_RB_COPY_DEST_INFO_TILE__MASK 0x00000003 #define A3XX_RB_COPY_DEST_INFO_TILE__SHIFT 0 static inline uint32_t A3XX_RB_COPY_DEST_INFO_TILE(enum a3xx_tile_mode val) { return ((val) << A3XX_RB_COPY_DEST_INFO_TILE__SHIFT) & A3XX_RB_COPY_DEST_INFO_TILE__MASK; } #define A3XX_RB_COPY_DEST_INFO_FORMAT__MASK 0x000000fc #define A3XX_RB_COPY_DEST_INFO_FORMAT__SHIFT 2 static inline uint32_t A3XX_RB_COPY_DEST_INFO_FORMAT(enum a3xx_color_fmt val) { return ((val) << A3XX_RB_COPY_DEST_INFO_FORMAT__SHIFT) & A3XX_RB_COPY_DEST_INFO_FORMAT__MASK; } #define A3XX_RB_COPY_DEST_INFO_SWAP__MASK 0x00000300 #define A3XX_RB_COPY_DEST_INFO_SWAP__SHIFT 8 static inline uint32_t A3XX_RB_COPY_DEST_INFO_SWAP(enum a3xx_color_swap val) { return ((val) << A3XX_RB_COPY_DEST_INFO_SWAP__SHIFT) & A3XX_RB_COPY_DEST_INFO_SWAP__MASK; } #define A3XX_RB_COPY_DEST_INFO_DITHER_MODE__MASK 0x00000c00 #define A3XX_RB_COPY_DEST_INFO_DITHER_MODE__SHIFT 10 static inline uint32_t A3XX_RB_COPY_DEST_INFO_DITHER_MODE(enum adreno_rb_dither_mode val) { return ((val) << A3XX_RB_COPY_DEST_INFO_DITHER_MODE__SHIFT) & A3XX_RB_COPY_DEST_INFO_DITHER_MODE__MASK; } #define A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE__MASK 0x0003c000 #define A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE__SHIFT 14 static inline uint32_t A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE(uint32_t val) { return ((val) << A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE__SHIFT) & A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE__MASK; } #define A3XX_RB_COPY_DEST_INFO_ENDIAN__MASK 0x001c0000 #define A3XX_RB_COPY_DEST_INFO_ENDIAN__SHIFT 18 static inline uint32_t A3XX_RB_COPY_DEST_INFO_ENDIAN(enum adreno_rb_surface_endian val) { return ((val) << A3XX_RB_COPY_DEST_INFO_ENDIAN__SHIFT) & A3XX_RB_COPY_DEST_INFO_ENDIAN__MASK; } #define REG_A3XX_RB_DEPTH_CONTROL 0x00002100 #define A3XX_RB_DEPTH_CONTROL_FRAG_WRITES_Z 0x00000001 #define A3XX_RB_DEPTH_CONTROL_Z_ENABLE 0x00000002 #define A3XX_RB_DEPTH_CONTROL_Z_WRITE_ENABLE 0x00000004 #define A3XX_RB_DEPTH_CONTROL_EARLY_Z_DISABLE 0x00000008 #define A3XX_RB_DEPTH_CONTROL_ZFUNC__MASK 0x00000070 #define A3XX_RB_DEPTH_CONTROL_ZFUNC__SHIFT 4 static inline uint32_t A3XX_RB_DEPTH_CONTROL_ZFUNC(enum adreno_compare_func val) { return ((val) << A3XX_RB_DEPTH_CONTROL_ZFUNC__SHIFT) & A3XX_RB_DEPTH_CONTROL_ZFUNC__MASK; } #define A3XX_RB_DEPTH_CONTROL_BF_ENABLE 0x00000080 #define A3XX_RB_DEPTH_CONTROL_Z_TEST_ENABLE 0x80000000 #define REG_A3XX_RB_DEPTH_CLEAR 0x00002101 #define REG_A3XX_RB_DEPTH_INFO 0x00002102 #define A3XX_RB_DEPTH_INFO_DEPTH_FORMAT__MASK 0x00000003 #define A3XX_RB_DEPTH_INFO_DEPTH_FORMAT__SHIFT 0 static inline uint32_t A3XX_RB_DEPTH_INFO_DEPTH_FORMAT(enum adreno_rb_depth_format val) { return ((val) << A3XX_RB_DEPTH_INFO_DEPTH_FORMAT__SHIFT) & A3XX_RB_DEPTH_INFO_DEPTH_FORMAT__MASK; } #define A3XX_RB_DEPTH_INFO_DEPTH_BASE__MASK 0xfffff800 #define A3XX_RB_DEPTH_INFO_DEPTH_BASE__SHIFT 11 static inline uint32_t A3XX_RB_DEPTH_INFO_DEPTH_BASE(uint32_t val) { return ((val >> 12) << A3XX_RB_DEPTH_INFO_DEPTH_BASE__SHIFT) & A3XX_RB_DEPTH_INFO_DEPTH_BASE__MASK; } #define REG_A3XX_RB_DEPTH_PITCH 0x00002103 #define A3XX_RB_DEPTH_PITCH__MASK 0xffffffff #define A3XX_RB_DEPTH_PITCH__SHIFT 0 static inline uint32_t A3XX_RB_DEPTH_PITCH(uint32_t val) { return ((val >> 3) << A3XX_RB_DEPTH_PITCH__SHIFT) & A3XX_RB_DEPTH_PITCH__MASK; } #define REG_A3XX_RB_STENCIL_CONTROL 0x00002104 #define A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE 0x00000001 #define A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE_BF 0x00000002 #define A3XX_RB_STENCIL_CONTROL_STENCIL_READ 0x00000004 #define A3XX_RB_STENCIL_CONTROL_FUNC__MASK 0x00000700 #define A3XX_RB_STENCIL_CONTROL_FUNC__SHIFT 8 static inline uint32_t A3XX_RB_STENCIL_CONTROL_FUNC(enum adreno_compare_func val) { return ((val) << A3XX_RB_STENCIL_CONTROL_FUNC__SHIFT) & A3XX_RB_STENCIL_CONTROL_FUNC__MASK; } #define A3XX_RB_STENCIL_CONTROL_FAIL__MASK 0x00003800 #define A3XX_RB_STENCIL_CONTROL_FAIL__SHIFT 11 static inline uint32_t A3XX_RB_STENCIL_CONTROL_FAIL(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_FAIL__SHIFT) & A3XX_RB_STENCIL_CONTROL_FAIL__MASK; } #define A3XX_RB_STENCIL_CONTROL_ZPASS__MASK 0x0001c000 #define A3XX_RB_STENCIL_CONTROL_ZPASS__SHIFT 14 static inline uint32_t A3XX_RB_STENCIL_CONTROL_ZPASS(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_ZPASS__SHIFT) & A3XX_RB_STENCIL_CONTROL_ZPASS__MASK; } #define A3XX_RB_STENCIL_CONTROL_ZFAIL__MASK 0x000e0000 #define A3XX_RB_STENCIL_CONTROL_ZFAIL__SHIFT 17 static inline uint32_t A3XX_RB_STENCIL_CONTROL_ZFAIL(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_ZFAIL__SHIFT) & A3XX_RB_STENCIL_CONTROL_ZFAIL__MASK; } #define A3XX_RB_STENCIL_CONTROL_FUNC_BF__MASK 0x00700000 #define A3XX_RB_STENCIL_CONTROL_FUNC_BF__SHIFT 20 static inline uint32_t A3XX_RB_STENCIL_CONTROL_FUNC_BF(enum adreno_compare_func val) { return ((val) << A3XX_RB_STENCIL_CONTROL_FUNC_BF__SHIFT) & A3XX_RB_STENCIL_CONTROL_FUNC_BF__MASK; } #define A3XX_RB_STENCIL_CONTROL_FAIL_BF__MASK 0x03800000 #define A3XX_RB_STENCIL_CONTROL_FAIL_BF__SHIFT 23 static inline uint32_t A3XX_RB_STENCIL_CONTROL_FAIL_BF(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_FAIL_BF__SHIFT) & A3XX_RB_STENCIL_CONTROL_FAIL_BF__MASK; } #define A3XX_RB_STENCIL_CONTROL_ZPASS_BF__MASK 0x1c000000 #define A3XX_RB_STENCIL_CONTROL_ZPASS_BF__SHIFT 26 static inline uint32_t A3XX_RB_STENCIL_CONTROL_ZPASS_BF(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_ZPASS_BF__SHIFT) & A3XX_RB_STENCIL_CONTROL_ZPASS_BF__MASK; } #define A3XX_RB_STENCIL_CONTROL_ZFAIL_BF__MASK 0xe0000000 #define A3XX_RB_STENCIL_CONTROL_ZFAIL_BF__SHIFT 29 static inline uint32_t A3XX_RB_STENCIL_CONTROL_ZFAIL_BF(enum adreno_stencil_op val) { return ((val) << A3XX_RB_STENCIL_CONTROL_ZFAIL_BF__SHIFT) & A3XX_RB_STENCIL_CONTROL_ZFAIL_BF__MASK; } #define REG_A3XX_RB_STENCIL_CLEAR 0x00002105 #define REG_A3XX_RB_STENCIL_INFO 0x00002106 #define A3XX_RB_STENCIL_INFO_STENCIL_BASE__MASK 0xfffff800 #define A3XX_RB_STENCIL_INFO_STENCIL_BASE__SHIFT 11 static inline uint32_t A3XX_RB_STENCIL_INFO_STENCIL_BASE(uint32_t val) { return ((val >> 12) << A3XX_RB_STENCIL_INFO_STENCIL_BASE__SHIFT) & A3XX_RB_STENCIL_INFO_STENCIL_BASE__MASK; } #define REG_A3XX_RB_STENCIL_PITCH 0x00002107 #define A3XX_RB_STENCIL_PITCH__MASK 0xffffffff #define A3XX_RB_STENCIL_PITCH__SHIFT 0 static inline uint32_t A3XX_RB_STENCIL_PITCH(uint32_t val) { return ((val >> 3) << A3XX_RB_STENCIL_PITCH__SHIFT) & A3XX_RB_STENCIL_PITCH__MASK; } #define REG_A3XX_RB_STENCILREFMASK 0x00002108 #define A3XX_RB_STENCILREFMASK_STENCILREF__MASK 0x000000ff #define A3XX_RB_STENCILREFMASK_STENCILREF__SHIFT 0 static inline uint32_t A3XX_RB_STENCILREFMASK_STENCILREF(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_STENCILREF__SHIFT) & A3XX_RB_STENCILREFMASK_STENCILREF__MASK; } #define A3XX_RB_STENCILREFMASK_STENCILMASK__MASK 0x0000ff00 #define A3XX_RB_STENCILREFMASK_STENCILMASK__SHIFT 8 static inline uint32_t A3XX_RB_STENCILREFMASK_STENCILMASK(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_STENCILMASK__SHIFT) & A3XX_RB_STENCILREFMASK_STENCILMASK__MASK; } #define A3XX_RB_STENCILREFMASK_STENCILWRITEMASK__MASK 0x00ff0000 #define A3XX_RB_STENCILREFMASK_STENCILWRITEMASK__SHIFT 16 static inline uint32_t A3XX_RB_STENCILREFMASK_STENCILWRITEMASK(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_STENCILWRITEMASK__SHIFT) & A3XX_RB_STENCILREFMASK_STENCILWRITEMASK__MASK; } #define REG_A3XX_RB_STENCILREFMASK_BF 0x00002109 #define A3XX_RB_STENCILREFMASK_BF_STENCILREF__MASK 0x000000ff #define A3XX_RB_STENCILREFMASK_BF_STENCILREF__SHIFT 0 static inline uint32_t A3XX_RB_STENCILREFMASK_BF_STENCILREF(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_BF_STENCILREF__SHIFT) & A3XX_RB_STENCILREFMASK_BF_STENCILREF__MASK; } #define A3XX_RB_STENCILREFMASK_BF_STENCILMASK__MASK 0x0000ff00 #define A3XX_RB_STENCILREFMASK_BF_STENCILMASK__SHIFT 8 static inline uint32_t A3XX_RB_STENCILREFMASK_BF_STENCILMASK(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_BF_STENCILMASK__SHIFT) & A3XX_RB_STENCILREFMASK_BF_STENCILMASK__MASK; } #define A3XX_RB_STENCILREFMASK_BF_STENCILWRITEMASK__MASK 0x00ff0000 #define A3XX_RB_STENCILREFMASK_BF_STENCILWRITEMASK__SHIFT 16 static inline uint32_t A3XX_RB_STENCILREFMASK_BF_STENCILWRITEMASK(uint32_t val) { return ((val) << A3XX_RB_STENCILREFMASK_BF_STENCILWRITEMASK__SHIFT) & A3XX_RB_STENCILREFMASK_BF_STENCILWRITEMASK__MASK; } #define REG_A3XX_RB_LRZ_VSC_CONTROL 0x0000210c #define A3XX_RB_LRZ_VSC_CONTROL_BINNING_ENABLE 0x00000002 #define REG_A3XX_RB_WINDOW_OFFSET 0x0000210e #define A3XX_RB_WINDOW_OFFSET_X__MASK 0x0000ffff #define A3XX_RB_WINDOW_OFFSET_X__SHIFT 0 static inline uint32_t A3XX_RB_WINDOW_OFFSET_X(uint32_t val) { return ((val) << A3XX_RB_WINDOW_OFFSET_X__SHIFT) & A3XX_RB_WINDOW_OFFSET_X__MASK; } #define A3XX_RB_WINDOW_OFFSET_Y__MASK 0xffff0000 #define A3XX_RB_WINDOW_OFFSET_Y__SHIFT 16 static inline uint32_t A3XX_RB_WINDOW_OFFSET_Y(uint32_t val) { return ((val) << A3XX_RB_WINDOW_OFFSET_Y__SHIFT) & A3XX_RB_WINDOW_OFFSET_Y__MASK; } #define REG_A3XX_RB_SAMPLE_COUNT_CONTROL 0x00002110 #define A3XX_RB_SAMPLE_COUNT_CONTROL_RESET 0x00000001 #define A3XX_RB_SAMPLE_COUNT_CONTROL_COPY 0x00000002 #define REG_A3XX_RB_SAMPLE_COUNT_ADDR 0x00002111 #define REG_A3XX_RB_Z_CLAMP_MIN 0x00002114 #define REG_A3XX_RB_Z_CLAMP_MAX 0x00002115 #define REG_A3XX_VGT_BIN_BASE 0x000021e1 #define REG_A3XX_VGT_BIN_SIZE 0x000021e2 #define REG_A3XX_PC_VSTREAM_CONTROL 0x000021e4 #define A3XX_PC_VSTREAM_CONTROL_SIZE__MASK 0x003f0000 #define A3XX_PC_VSTREAM_CONTROL_SIZE__SHIFT 16 static inline uint32_t A3XX_PC_VSTREAM_CONTROL_SIZE(uint32_t val) { return ((val) << A3XX_PC_VSTREAM_CONTROL_SIZE__SHIFT) & A3XX_PC_VSTREAM_CONTROL_SIZE__MASK; } #define A3XX_PC_VSTREAM_CONTROL_N__MASK 0x07c00000 #define A3XX_PC_VSTREAM_CONTROL_N__SHIFT 22 static inline uint32_t A3XX_PC_VSTREAM_CONTROL_N(uint32_t val) { return ((val) << A3XX_PC_VSTREAM_CONTROL_N__SHIFT) & A3XX_PC_VSTREAM_CONTROL_N__MASK; } #define REG_A3XX_PC_VERTEX_REUSE_BLOCK_CNTL 0x000021ea #define REG_A3XX_PC_PRIM_VTX_CNTL 0x000021ec #define A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC__MASK 0x0000001f #define A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC__SHIFT 0 static inline uint32_t A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC(uint32_t val) { return ((val) << A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC__SHIFT) & A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC__MASK; } #define A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE__MASK 0x000000e0 #define A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE__SHIFT 5 static inline uint32_t A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE(enum adreno_pa_su_sc_draw val) { return ((val) << A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE__SHIFT) & A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE__MASK; } #define A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE__MASK 0x00000700 #define A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE__SHIFT 8 static inline uint32_t A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(enum adreno_pa_su_sc_draw val) { return ((val) << A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE__SHIFT) & A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE__MASK; } #define A3XX_PC_PRIM_VTX_CNTL_POLYMODE_ENABLE 0x00001000 #define A3XX_PC_PRIM_VTX_CNTL_PRIMITIVE_RESTART 0x00100000 #define A3XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST 0x02000000 #define A3XX_PC_PRIM_VTX_CNTL_PSIZE 0x04000000 #define REG_A3XX_PC_RESTART_INDEX 0x000021ed #define REG_A3XX_HLSQ_CONTROL_0_REG 0x00002200 #define A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK 0x00000010 #define A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__SHIFT 4 static inline uint32_t A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE(enum a3xx_threadsize val) { return ((val) << A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__SHIFT) & A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK; } #define A3XX_HLSQ_CONTROL_0_REG_FSSUPERTHREADENABLE 0x00000040 #define A3XX_HLSQ_CONTROL_0_REG_SPSHADERRESTART 0x00000200 #define A3XX_HLSQ_CONTROL_0_REG_RESERVED2 0x00000400 #define A3XX_HLSQ_CONTROL_0_REG_CHUNKDISABLE 0x04000000 #define A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__MASK 0x08000000 #define A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__SHIFT 27 static inline uint32_t A3XX_HLSQ_CONTROL_0_REG_CONSTMODE(uint32_t val) { return ((val) << A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__SHIFT) & A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__MASK; } #define A3XX_HLSQ_CONTROL_0_REG_LAZYUPDATEDISABLE 0x10000000 #define A3XX_HLSQ_CONTROL_0_REG_SPCONSTFULLUPDATE 0x20000000 #define A3XX_HLSQ_CONTROL_0_REG_TPFULLUPDATE 0x40000000 #define A3XX_HLSQ_CONTROL_0_REG_SINGLECONTEXT 0x80000000 #define REG_A3XX_HLSQ_CONTROL_1_REG 0x00002201 #define A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__MASK 0x00000040 #define A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__SHIFT 6 static inline uint32_t A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE(enum a3xx_threadsize val) { return ((val) << A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__SHIFT) & A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__MASK; } #define A3XX_HLSQ_CONTROL_1_REG_VSSUPERTHREADENABLE 0x00000100 #define A3XX_HLSQ_CONTROL_1_REG_RESERVED1 0x00000200 #define A3XX_HLSQ_CONTROL_1_REG_ZWCOORD 0x02000000 #define REG_A3XX_HLSQ_CONTROL_2_REG 0x00002202 #define A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__MASK 0xfc000000 #define A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__SHIFT 26 static inline uint32_t A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD(uint32_t val) { return ((val) << A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__SHIFT) & A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__MASK; } #define REG_A3XX_HLSQ_CONTROL_3_REG 0x00002203 #define A3XX_HLSQ_CONTROL_3_REG_REGID__MASK 0x000000ff #define A3XX_HLSQ_CONTROL_3_REG_REGID__SHIFT 0 static inline uint32_t A3XX_HLSQ_CONTROL_3_REG_REGID(uint32_t val) { return ((val) << A3XX_HLSQ_CONTROL_3_REG_REGID__SHIFT) & A3XX_HLSQ_CONTROL_3_REG_REGID__MASK; } #define REG_A3XX_HLSQ_VS_CONTROL_REG 0x00002204 #define A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__MASK 0x00000fff #define A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__SHIFT 0 static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH(uint32_t val) { return ((val) << A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__SHIFT) & A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__MASK; } #define A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__MASK 0x00fff000 #define A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT 12 static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET(uint32_t val) { return ((val) << A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT) & A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__MASK; } #define A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH__MASK 0xff000000 #define A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH__SHIFT 24 static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH(uint32_t val) { return ((val) << A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH__SHIFT) & A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH__MASK; } #define REG_A3XX_HLSQ_FS_CONTROL_REG 0x00002205 #define A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__MASK 0x00000fff #define A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__SHIFT 0 static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH(uint32_t val) { return ((val) << A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__SHIFT) & A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__MASK; } #define A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__MASK 0x00fff000 #define A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT 12 static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET(uint32_t val) { return ((val) << A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT) & A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__MASK; } #define A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH__MASK 0xff000000 #define A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH__SHIFT 24 static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH(uint32_t val) { return ((val) << A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH__SHIFT) & A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH__MASK; } #define REG_A3XX_HLSQ_CONST_VSPRESV_RANGE_REG 0x00002206 #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__MASK 0x0000ffff #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__SHIFT 0 static inline uint32_t A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY(uint32_t val) { return ((val) << A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__SHIFT) & A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__MASK; } #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__MASK 0xffff0000 #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__SHIFT 16 static inline uint32_t A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY(uint32_t val) { return ((val) << A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__SHIFT) & A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__MASK; } #define REG_A3XX_HLSQ_CONST_FSPRESV_RANGE_REG 0x00002207 #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__MASK 0x0000ffff #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__SHIFT 0 static inline uint32_t A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY(uint32_t val) { return ((val) << A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__SHIFT) & A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__MASK; } #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__MASK 0xffff0000 #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__SHIFT 16 static inline uint32_t A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY(uint32_t val) { return ((val) << A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__SHIFT) & A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__MASK; } #define REG_A3XX_HLSQ_CL_NDRANGE_0_REG 0x0000220a #define A3XX_HLSQ_CL_NDRANGE_0_REG_WORKDIM__MASK 0x00000003 #define A3XX_HLSQ_CL_NDRANGE_0_REG_WORKDIM__SHIFT 0 static inline uint32_t A3XX_HLSQ_CL_NDRANGE_0_REG_WORKDIM(uint32_t val) { return ((val) << A3XX_HLSQ_CL_NDRANGE_0_REG_WORKDIM__SHIFT) & A3XX_HLSQ_CL_NDRANGE_0_REG_WORKDIM__MASK; } #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE0__MASK 0x00000ffc #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE0__SHIFT 2 static inline uint32_t A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE0(uint32_t val) { return ((val) << A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE0__SHIFT) & A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE0__MASK; } #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE1__MASK 0x003ff000 #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE1__SHIFT 12 static inline uint32_t A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE1(uint32_t val) { return ((val) << A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE1__SHIFT) & A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE1__MASK; } #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE2__MASK 0xffc00000 #define A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE2__SHIFT 22 static inline uint32_t A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE2(uint32_t val) { return ((val) << A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE2__SHIFT) & A3XX_HLSQ_CL_NDRANGE_0_REG_LOCALSIZE2__MASK; } static inline uint32_t REG_A3XX_HLSQ_CL_GLOBAL_WORK(uint32_t i0) { return 0x0000220b + 0x2*i0; } static inline uint32_t REG_A3XX_HLSQ_CL_GLOBAL_WORK_SIZE(uint32_t i0) { return 0x0000220b + 0x2*i0; } static inline uint32_t REG_A3XX_HLSQ_CL_GLOBAL_WORK_OFFSET(uint32_t i0) { return 0x0000220c + 0x2*i0; } #define REG_A3XX_HLSQ_CL_CONTROL_0_REG 0x00002211 #define REG_A3XX_HLSQ_CL_CONTROL_1_REG 0x00002212 #define REG_A3XX_HLSQ_CL_KERNEL_CONST_REG 0x00002214 static inline uint32_t REG_A3XX_HLSQ_CL_KERNEL_GROUP(uint32_t i0) { return 0x00002215 + 0x1*i0; } static inline uint32_t REG_A3XX_HLSQ_CL_KERNEL_GROUP_RATIO(uint32_t i0) { return 0x00002215 + 0x1*i0; } #define REG_A3XX_HLSQ_CL_KERNEL_GROUP_Y_REG 0x00002216 #define REG_A3XX_HLSQ_CL_KERNEL_GROUP_Z_REG 0x00002217 #define REG_A3XX_HLSQ_CL_WG_OFFSET_REG 0x0000221a #define REG_A3XX_VFD_CONTROL_0 0x00002240 #define A3XX_VFD_CONTROL_0_TOTALATTRTOVS__MASK 0x0003ffff #define A3XX_VFD_CONTROL_0_TOTALATTRTOVS__SHIFT 0 static inline uint32_t A3XX_VFD_CONTROL_0_TOTALATTRTOVS(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_0_TOTALATTRTOVS__SHIFT) & A3XX_VFD_CONTROL_0_TOTALATTRTOVS__MASK; } #define A3XX_VFD_CONTROL_0_PACKETSIZE__MASK 0x003c0000 #define A3XX_VFD_CONTROL_0_PACKETSIZE__SHIFT 18 static inline uint32_t A3XX_VFD_CONTROL_0_PACKETSIZE(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_0_PACKETSIZE__SHIFT) & A3XX_VFD_CONTROL_0_PACKETSIZE__MASK; } #define A3XX_VFD_CONTROL_0_STRMDECINSTRCNT__MASK 0x07c00000 #define A3XX_VFD_CONTROL_0_STRMDECINSTRCNT__SHIFT 22 static inline uint32_t A3XX_VFD_CONTROL_0_STRMDECINSTRCNT(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_0_STRMDECINSTRCNT__SHIFT) & A3XX_VFD_CONTROL_0_STRMDECINSTRCNT__MASK; } #define A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT__MASK 0xf8000000 #define A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT__SHIFT 27 static inline uint32_t A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT__SHIFT) & A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT__MASK; } #define REG_A3XX_VFD_CONTROL_1 0x00002241 #define A3XX_VFD_CONTROL_1_MAXSTORAGE__MASK 0x0000ffff #define A3XX_VFD_CONTROL_1_MAXSTORAGE__SHIFT 0 static inline uint32_t A3XX_VFD_CONTROL_1_MAXSTORAGE(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_1_MAXSTORAGE__SHIFT) & A3XX_VFD_CONTROL_1_MAXSTORAGE__MASK; } #define A3XX_VFD_CONTROL_1_REGID4VTX__MASK 0x00ff0000 #define A3XX_VFD_CONTROL_1_REGID4VTX__SHIFT 16 static inline uint32_t A3XX_VFD_CONTROL_1_REGID4VTX(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_1_REGID4VTX__SHIFT) & A3XX_VFD_CONTROL_1_REGID4VTX__MASK; } #define A3XX_VFD_CONTROL_1_REGID4INST__MASK 0xff000000 #define A3XX_VFD_CONTROL_1_REGID4INST__SHIFT 24 static inline uint32_t A3XX_VFD_CONTROL_1_REGID4INST(uint32_t val) { return ((val) << A3XX_VFD_CONTROL_1_REGID4INST__SHIFT) & A3XX_VFD_CONTROL_1_REGID4INST__MASK; } #define REG_A3XX_VFD_INDEX_MIN 0x00002242 #define REG_A3XX_VFD_INDEX_MAX 0x00002243 #define REG_A3XX_VFD_INSTANCEID_OFFSET 0x00002244 #define REG_A3XX_VFD_INDEX_OFFSET 0x00002245 #define REG_A3XX_VFD_INDEX_OFFSET 0x00002245 static inline uint32_t REG_A3XX_VFD_FETCH(uint32_t i0) { return 0x00002246 + 0x2*i0; } static inline uint32_t REG_A3XX_VFD_FETCH_INSTR_0(uint32_t i0) { return 0x00002246 + 0x2*i0; } #define A3XX_VFD_FETCH_INSTR_0_FETCHSIZE__MASK 0x0000007f #define A3XX_VFD_FETCH_INSTR_0_FETCHSIZE__SHIFT 0 static inline uint32_t A3XX_VFD_FETCH_INSTR_0_FETCHSIZE(uint32_t val) { return ((val) << A3XX_VFD_FETCH_INSTR_0_FETCHSIZE__SHIFT) & A3XX_VFD_FETCH_INSTR_0_FETCHSIZE__MASK; } #define A3XX_VFD_FETCH_INSTR_0_BUFSTRIDE__MASK 0x0000ff80 #define A3XX_VFD_FETCH_INSTR_0_BUFSTRIDE__SHIFT 7 static inline uint32_t A3XX_VFD_FETCH_INSTR_0_BUFSTRIDE(uint32_t val) { return ((val) << A3XX_VFD_FETCH_INSTR_0_BUFSTRIDE__SHIFT) & A3XX_VFD_FETCH_INSTR_0_BUFSTRIDE__MASK; } #define A3XX_VFD_FETCH_INSTR_0_INSTANCED 0x00010000 #define A3XX_VFD_FETCH_INSTR_0_SWITCHNEXT 0x00020000 #define A3XX_VFD_FETCH_INSTR_0_INDEXCODE__MASK 0x00fc0000 #define A3XX_VFD_FETCH_INSTR_0_INDEXCODE__SHIFT 18 static inline uint32_t A3XX_VFD_FETCH_INSTR_0_INDEXCODE(uint32_t val) { return ((val) << A3XX_VFD_FETCH_INSTR_0_INDEXCODE__SHIFT) & A3XX_VFD_FETCH_INSTR_0_INDEXCODE__MASK; } #define A3XX_VFD_FETCH_INSTR_0_STEPRATE__MASK 0xff000000 #define A3XX_VFD_FETCH_INSTR_0_STEPRATE__SHIFT 24 static inline uint32_t A3XX_VFD_FETCH_INSTR_0_STEPRATE(uint32_t val) { return ((val) << A3XX_VFD_FETCH_INSTR_0_STEPRATE__SHIFT) & A3XX_VFD_FETCH_INSTR_0_STEPRATE__MASK; } static inline uint32_t REG_A3XX_VFD_FETCH_INSTR_1(uint32_t i0) { return 0x00002247 + 0x2*i0; } static inline uint32_t REG_A3XX_VFD_DECODE(uint32_t i0) { return 0x00002266 + 0x1*i0; } static inline uint32_t REG_A3XX_VFD_DECODE_INSTR(uint32_t i0) { return 0x00002266 + 0x1*i0; } #define A3XX_VFD_DECODE_INSTR_WRITEMASK__MASK 0x0000000f #define A3XX_VFD_DECODE_INSTR_WRITEMASK__SHIFT 0 static inline uint32_t A3XX_VFD_DECODE_INSTR_WRITEMASK(uint32_t val) { return ((val) << A3XX_VFD_DECODE_INSTR_WRITEMASK__SHIFT) & A3XX_VFD_DECODE_INSTR_WRITEMASK__MASK; } #define A3XX_VFD_DECODE_INSTR_CONSTFILL 0x00000010 #define A3XX_VFD_DECODE_INSTR_FORMAT__MASK 0x00000fc0 #define A3XX_VFD_DECODE_INSTR_FORMAT__SHIFT 6 static inline uint32_t A3XX_VFD_DECODE_INSTR_FORMAT(enum a3xx_vtx_fmt val) { return ((val) << A3XX_VFD_DECODE_INSTR_FORMAT__SHIFT) & A3XX_VFD_DECODE_INSTR_FORMAT__MASK; } #define A3XX_VFD_DECODE_INSTR_REGID__MASK 0x000ff000 #define A3XX_VFD_DECODE_INSTR_REGID__SHIFT 12 static inline uint32_t A3XX_VFD_DECODE_INSTR_REGID(uint32_t val) { return ((val) << A3XX_VFD_DECODE_INSTR_REGID__SHIFT) & A3XX_VFD_DECODE_INSTR_REGID__MASK; } #define A3XX_VFD_DECODE_INSTR_INT 0x00100000 #define A3XX_VFD_DECODE_INSTR_SWAP__MASK 0x00c00000 #define A3XX_VFD_DECODE_INSTR_SWAP__SHIFT 22 static inline uint32_t A3XX_VFD_DECODE_INSTR_SWAP(enum a3xx_color_swap val) { return ((val) << A3XX_VFD_DECODE_INSTR_SWAP__SHIFT) & A3XX_VFD_DECODE_INSTR_SWAP__MASK; } #define A3XX_VFD_DECODE_INSTR_SHIFTCNT__MASK 0x1f000000 #define A3XX_VFD_DECODE_INSTR_SHIFTCNT__SHIFT 24 static inline uint32_t A3XX_VFD_DECODE_INSTR_SHIFTCNT(uint32_t val) { return ((val) << A3XX_VFD_DECODE_INSTR_SHIFTCNT__SHIFT) & A3XX_VFD_DECODE_INSTR_SHIFTCNT__MASK; } #define A3XX_VFD_DECODE_INSTR_LASTCOMPVALID 0x20000000 #define A3XX_VFD_DECODE_INSTR_SWITCHNEXT 0x40000000 #define REG_A3XX_VFD_VS_THREADING_THRESHOLD 0x0000227e #define A3XX_VFD_VS_THREADING_THRESHOLD_REGID_THRESHOLD__MASK 0x0000000f #define A3XX_VFD_VS_THREADING_THRESHOLD_REGID_THRESHOLD__SHIFT 0 static inline uint32_t A3XX_VFD_VS_THREADING_THRESHOLD_REGID_THRESHOLD(uint32_t val) { return ((val) << A3XX_VFD_VS_THREADING_THRESHOLD_REGID_THRESHOLD__SHIFT) & A3XX_VFD_VS_THREADING_THRESHOLD_REGID_THRESHOLD__MASK; } #define A3XX_VFD_VS_THREADING_THRESHOLD_REGID_VTXCNT__MASK 0x0000ff00 #define A3XX_VFD_VS_THREADING_THRESHOLD_REGID_VTXCNT__SHIFT 8 static inline uint32_t A3XX_VFD_VS_THREADING_THRESHOLD_REGID_VTXCNT(uint32_t val) { return ((val) << A3XX_VFD_VS_THREADING_THRESHOLD_REGID_VTXCNT__SHIFT) & A3XX_VFD_VS_THREADING_THRESHOLD_REGID_VTXCNT__MASK; } #define REG_A3XX_VPC_ATTR 0x00002280 #define A3XX_VPC_ATTR_TOTALATTR__MASK 0x000001ff #define A3XX_VPC_ATTR_TOTALATTR__SHIFT 0 static inline uint32_t A3XX_VPC_ATTR_TOTALATTR(uint32_t val) { return ((val) << A3XX_VPC_ATTR_TOTALATTR__SHIFT) & A3XX_VPC_ATTR_TOTALATTR__MASK; } #define A3XX_VPC_ATTR_PSIZE 0x00000200 #define A3XX_VPC_ATTR_THRDASSIGN__MASK 0x0ffff000 #define A3XX_VPC_ATTR_THRDASSIGN__SHIFT 12 static inline uint32_t A3XX_VPC_ATTR_THRDASSIGN(uint32_t val) { return ((val) << A3XX_VPC_ATTR_THRDASSIGN__SHIFT) & A3XX_VPC_ATTR_THRDASSIGN__MASK; } #define A3XX_VPC_ATTR_LMSIZE__MASK 0xf0000000 #define A3XX_VPC_ATTR_LMSIZE__SHIFT 28 static inline uint32_t A3XX_VPC_ATTR_LMSIZE(uint32_t val) { return ((val) << A3XX_VPC_ATTR_LMSIZE__SHIFT) & A3XX_VPC_ATTR_LMSIZE__MASK; } #define REG_A3XX_VPC_PACK 0x00002281 #define A3XX_VPC_PACK_NUMFPNONPOSVAR__MASK 0x0000ff00 #define A3XX_VPC_PACK_NUMFPNONPOSVAR__SHIFT 8 static inline uint32_t A3XX_VPC_PACK_NUMFPNONPOSVAR(uint32_t val) { return ((val) << A3XX_VPC_PACK_NUMFPNONPOSVAR__SHIFT) & A3XX_VPC_PACK_NUMFPNONPOSVAR__MASK; } #define A3XX_VPC_PACK_NUMNONPOSVSVAR__MASK 0x00ff0000 #define A3XX_VPC_PACK_NUMNONPOSVSVAR__SHIFT 16 static inline uint32_t A3XX_VPC_PACK_NUMNONPOSVSVAR(uint32_t val) { return ((val) << A3XX_VPC_PACK_NUMNONPOSVSVAR__SHIFT) & A3XX_VPC_PACK_NUMNONPOSVSVAR__MASK; } static inline uint32_t REG_A3XX_VPC_VARYING_INTERP(uint32_t i0) { return 0x00002282 + 0x1*i0; } static inline uint32_t REG_A3XX_VPC_VARYING_INTERP_MODE(uint32_t i0) { return 0x00002282 + 0x1*i0; } #define A3XX_VPC_VARYING_INTERP_MODE_C0__MASK 0x00000003 #define A3XX_VPC_VARYING_INTERP_MODE_C0__SHIFT 0 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C0(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C0__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C0__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C1__MASK 0x0000000c #define A3XX_VPC_VARYING_INTERP_MODE_C1__SHIFT 2 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C1(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C1__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C1__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C2__MASK 0x00000030 #define A3XX_VPC_VARYING_INTERP_MODE_C2__SHIFT 4 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C2(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C2__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C2__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C3__MASK 0x000000c0 #define A3XX_VPC_VARYING_INTERP_MODE_C3__SHIFT 6 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C3(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C3__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C3__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C4__MASK 0x00000300 #define A3XX_VPC_VARYING_INTERP_MODE_C4__SHIFT 8 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C4(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C4__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C4__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C5__MASK 0x00000c00 #define A3XX_VPC_VARYING_INTERP_MODE_C5__SHIFT 10 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C5(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C5__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C5__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C6__MASK 0x00003000 #define A3XX_VPC_VARYING_INTERP_MODE_C6__SHIFT 12 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C6(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C6__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C6__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C7__MASK 0x0000c000 #define A3XX_VPC_VARYING_INTERP_MODE_C7__SHIFT 14 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C7(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C7__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C7__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C8__MASK 0x00030000 #define A3XX_VPC_VARYING_INTERP_MODE_C8__SHIFT 16 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C8(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C8__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C8__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_C9__MASK 0x000c0000 #define A3XX_VPC_VARYING_INTERP_MODE_C9__SHIFT 18 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_C9(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_C9__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_C9__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CA__MASK 0x00300000 #define A3XX_VPC_VARYING_INTERP_MODE_CA__SHIFT 20 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CA(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CA__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CA__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CB__MASK 0x00c00000 #define A3XX_VPC_VARYING_INTERP_MODE_CB__SHIFT 22 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CB(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CB__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CB__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CC__MASK 0x03000000 #define A3XX_VPC_VARYING_INTERP_MODE_CC__SHIFT 24 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CC(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CC__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CC__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CD__MASK 0x0c000000 #define A3XX_VPC_VARYING_INTERP_MODE_CD__SHIFT 26 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CD(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CD__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CD__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CE__MASK 0x30000000 #define A3XX_VPC_VARYING_INTERP_MODE_CE__SHIFT 28 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CE(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CE__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CE__MASK; } #define A3XX_VPC_VARYING_INTERP_MODE_CF__MASK 0xc0000000 #define A3XX_VPC_VARYING_INTERP_MODE_CF__SHIFT 30 static inline uint32_t A3XX_VPC_VARYING_INTERP_MODE_CF(enum a3xx_intp_mode val) { return ((val) << A3XX_VPC_VARYING_INTERP_MODE_CF__SHIFT) & A3XX_VPC_VARYING_INTERP_MODE_CF__MASK; } static inline uint32_t REG_A3XX_VPC_VARYING_PS_REPL(uint32_t i0) { return 0x00002286 + 0x1*i0; } static inline uint32_t REG_A3XX_VPC_VARYING_PS_REPL_MODE(uint32_t i0) { return 0x00002286 + 0x1*i0; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C0__MASK 0x00000003 #define A3XX_VPC_VARYING_PS_REPL_MODE_C0__SHIFT 0 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C0(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C0__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C0__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C1__MASK 0x0000000c #define A3XX_VPC_VARYING_PS_REPL_MODE_C1__SHIFT 2 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C1(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C1__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C1__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C2__MASK 0x00000030 #define A3XX_VPC_VARYING_PS_REPL_MODE_C2__SHIFT 4 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C2(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C2__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C2__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C3__MASK 0x000000c0 #define A3XX_VPC_VARYING_PS_REPL_MODE_C3__SHIFT 6 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C3(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C3__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C3__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C4__MASK 0x00000300 #define A3XX_VPC_VARYING_PS_REPL_MODE_C4__SHIFT 8 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C4(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C4__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C4__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C5__MASK 0x00000c00 #define A3XX_VPC_VARYING_PS_REPL_MODE_C5__SHIFT 10 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C5(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C5__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C5__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C6__MASK 0x00003000 #define A3XX_VPC_VARYING_PS_REPL_MODE_C6__SHIFT 12 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C6(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C6__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C6__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C7__MASK 0x0000c000 #define A3XX_VPC_VARYING_PS_REPL_MODE_C7__SHIFT 14 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C7(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C7__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C7__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C8__MASK 0x00030000 #define A3XX_VPC_VARYING_PS_REPL_MODE_C8__SHIFT 16 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C8(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C8__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C8__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_C9__MASK 0x000c0000 #define A3XX_VPC_VARYING_PS_REPL_MODE_C9__SHIFT 18 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_C9(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_C9__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_C9__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CA__MASK 0x00300000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CA__SHIFT 20 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CA(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CA__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CA__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CB__MASK 0x00c00000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CB__SHIFT 22 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CB(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CB__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CB__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CC__MASK 0x03000000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CC__SHIFT 24 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CC(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CC__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CC__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CD__MASK 0x0c000000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CD__SHIFT 26 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CD(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CD__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CD__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CE__MASK 0x30000000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CE__SHIFT 28 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CE(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CE__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CE__MASK; } #define A3XX_VPC_VARYING_PS_REPL_MODE_CF__MASK 0xc0000000 #define A3XX_VPC_VARYING_PS_REPL_MODE_CF__SHIFT 30 static inline uint32_t A3XX_VPC_VARYING_PS_REPL_MODE_CF(enum a3xx_repl_mode val) { return ((val) << A3XX_VPC_VARYING_PS_REPL_MODE_CF__SHIFT) & A3XX_VPC_VARYING_PS_REPL_MODE_CF__MASK; } #define REG_A3XX_VPC_VARY_CYLWRAP_ENABLE_0 0x0000228a #define REG_A3XX_VPC_VARY_CYLWRAP_ENABLE_1 0x0000228b #define REG_A3XX_SP_SP_CTRL_REG 0x000022c0 #define A3XX_SP_SP_CTRL_REG_RESOLVE 0x00010000 #define A3XX_SP_SP_CTRL_REG_CONSTMODE__MASK 0x00040000 #define A3XX_SP_SP_CTRL_REG_CONSTMODE__SHIFT 18 static inline uint32_t A3XX_SP_SP_CTRL_REG_CONSTMODE(uint32_t val) { return ((val) << A3XX_SP_SP_CTRL_REG_CONSTMODE__SHIFT) & A3XX_SP_SP_CTRL_REG_CONSTMODE__MASK; } #define A3XX_SP_SP_CTRL_REG_BINNING 0x00080000 #define A3XX_SP_SP_CTRL_REG_SLEEPMODE__MASK 0x00300000 #define A3XX_SP_SP_CTRL_REG_SLEEPMODE__SHIFT 20 static inline uint32_t A3XX_SP_SP_CTRL_REG_SLEEPMODE(uint32_t val) { return ((val) << A3XX_SP_SP_CTRL_REG_SLEEPMODE__SHIFT) & A3XX_SP_SP_CTRL_REG_SLEEPMODE__MASK; } #define A3XX_SP_SP_CTRL_REG_L0MODE__MASK 0x00c00000 #define A3XX_SP_SP_CTRL_REG_L0MODE__SHIFT 22 static inline uint32_t A3XX_SP_SP_CTRL_REG_L0MODE(uint32_t val) { return ((val) << A3XX_SP_SP_CTRL_REG_L0MODE__SHIFT) & A3XX_SP_SP_CTRL_REG_L0MODE__MASK; } #define REG_A3XX_SP_VS_CTRL_REG0 0x000022c4 #define A3XX_SP_VS_CTRL_REG0_THREADMODE__MASK 0x00000001 #define A3XX_SP_VS_CTRL_REG0_THREADMODE__SHIFT 0 static inline uint32_t A3XX_SP_VS_CTRL_REG0_THREADMODE(enum a3xx_threadmode val) { return ((val) << A3XX_SP_VS_CTRL_REG0_THREADMODE__SHIFT) & A3XX_SP_VS_CTRL_REG0_THREADMODE__MASK; } #define A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__MASK 0x00000002 #define A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__SHIFT 1 static inline uint32_t A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE(enum a3xx_instrbuffermode val) { return ((val) << A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__SHIFT) & A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__MASK; } #define A3XX_SP_VS_CTRL_REG0_CACHEINVALID 0x00000004 #define A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__MASK 0x000003f0 #define A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT 4 static inline uint32_t A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT) & A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__MASK; } #define A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__MASK 0x0003fc00 #define A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT 10 static inline uint32_t A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT) & A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__MASK; } #define A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__MASK 0x000c0000 #define A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__SHIFT 18 static inline uint32_t A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__SHIFT) & A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__MASK; } #define A3XX_SP_VS_CTRL_REG0_THREADSIZE__MASK 0x00100000 #define A3XX_SP_VS_CTRL_REG0_THREADSIZE__SHIFT 20 static inline uint32_t A3XX_SP_VS_CTRL_REG0_THREADSIZE(enum a3xx_threadsize val) { return ((val) << A3XX_SP_VS_CTRL_REG0_THREADSIZE__SHIFT) & A3XX_SP_VS_CTRL_REG0_THREADSIZE__MASK; } #define A3XX_SP_VS_CTRL_REG0_SUPERTHREADMODE 0x00200000 #define A3XX_SP_VS_CTRL_REG0_PIXLODENABLE 0x00400000 #define A3XX_SP_VS_CTRL_REG0_COMPUTEMODE 0x00800000 #define A3XX_SP_VS_CTRL_REG0_LENGTH__MASK 0xff000000 #define A3XX_SP_VS_CTRL_REG0_LENGTH__SHIFT 24 static inline uint32_t A3XX_SP_VS_CTRL_REG0_LENGTH(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG0_LENGTH__SHIFT) & A3XX_SP_VS_CTRL_REG0_LENGTH__MASK; } #define REG_A3XX_SP_VS_CTRL_REG1 0x000022c5 #define A3XX_SP_VS_CTRL_REG1_CONSTLENGTH__MASK 0x000003ff #define A3XX_SP_VS_CTRL_REG1_CONSTLENGTH__SHIFT 0 static inline uint32_t A3XX_SP_VS_CTRL_REG1_CONSTLENGTH(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG1_CONSTLENGTH__SHIFT) & A3XX_SP_VS_CTRL_REG1_CONSTLENGTH__MASK; } #define A3XX_SP_VS_CTRL_REG1_CONSTFOOTPRINT__MASK 0x000ffc00 #define A3XX_SP_VS_CTRL_REG1_CONSTFOOTPRINT__SHIFT 10 static inline uint32_t A3XX_SP_VS_CTRL_REG1_CONSTFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG1_CONSTFOOTPRINT__SHIFT) & A3XX_SP_VS_CTRL_REG1_CONSTFOOTPRINT__MASK; } #define A3XX_SP_VS_CTRL_REG1_INITIALOUTSTANDING__MASK 0x7f000000 #define A3XX_SP_VS_CTRL_REG1_INITIALOUTSTANDING__SHIFT 24 static inline uint32_t A3XX_SP_VS_CTRL_REG1_INITIALOUTSTANDING(uint32_t val) { return ((val) << A3XX_SP_VS_CTRL_REG1_INITIALOUTSTANDING__SHIFT) & A3XX_SP_VS_CTRL_REG1_INITIALOUTSTANDING__MASK; } #define REG_A3XX_SP_VS_PARAM_REG 0x000022c6 #define A3XX_SP_VS_PARAM_REG_POSREGID__MASK 0x000000ff #define A3XX_SP_VS_PARAM_REG_POSREGID__SHIFT 0 static inline uint32_t A3XX_SP_VS_PARAM_REG_POSREGID(uint32_t val) { return ((val) << A3XX_SP_VS_PARAM_REG_POSREGID__SHIFT) & A3XX_SP_VS_PARAM_REG_POSREGID__MASK; } #define A3XX_SP_VS_PARAM_REG_PSIZEREGID__MASK 0x0000ff00 #define A3XX_SP_VS_PARAM_REG_PSIZEREGID__SHIFT 8 static inline uint32_t A3XX_SP_VS_PARAM_REG_PSIZEREGID(uint32_t val) { return ((val) << A3XX_SP_VS_PARAM_REG_PSIZEREGID__SHIFT) & A3XX_SP_VS_PARAM_REG_PSIZEREGID__MASK; } #define A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__MASK 0xfff00000 #define A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__SHIFT 20 static inline uint32_t A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR(uint32_t val) { return ((val) << A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__SHIFT) & A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__MASK; } static inline uint32_t REG_A3XX_SP_VS_OUT(uint32_t i0) { return 0x000022c7 + 0x1*i0; } static inline uint32_t REG_A3XX_SP_VS_OUT_REG(uint32_t i0) { return 0x000022c7 + 0x1*i0; } #define A3XX_SP_VS_OUT_REG_A_REGID__MASK 0x000001ff #define A3XX_SP_VS_OUT_REG_A_REGID__SHIFT 0 static inline uint32_t A3XX_SP_VS_OUT_REG_A_REGID(uint32_t val) { return ((val) << A3XX_SP_VS_OUT_REG_A_REGID__SHIFT) & A3XX_SP_VS_OUT_REG_A_REGID__MASK; } #define A3XX_SP_VS_OUT_REG_A_COMPMASK__MASK 0x00001e00 #define A3XX_SP_VS_OUT_REG_A_COMPMASK__SHIFT 9 static inline uint32_t A3XX_SP_VS_OUT_REG_A_COMPMASK(uint32_t val) { return ((val) << A3XX_SP_VS_OUT_REG_A_COMPMASK__SHIFT) & A3XX_SP_VS_OUT_REG_A_COMPMASK__MASK; } #define A3XX_SP_VS_OUT_REG_B_REGID__MASK 0x01ff0000 #define A3XX_SP_VS_OUT_REG_B_REGID__SHIFT 16 static inline uint32_t A3XX_SP_VS_OUT_REG_B_REGID(uint32_t val) { return ((val) << A3XX_SP_VS_OUT_REG_B_REGID__SHIFT) & A3XX_SP_VS_OUT_REG_B_REGID__MASK; } #define A3XX_SP_VS_OUT_REG_B_COMPMASK__MASK 0x1e000000 #define A3XX_SP_VS_OUT_REG_B_COMPMASK__SHIFT 25 static inline uint32_t A3XX_SP_VS_OUT_REG_B_COMPMASK(uint32_t val) { return ((val) << A3XX_SP_VS_OUT_REG_B_COMPMASK__SHIFT) & A3XX_SP_VS_OUT_REG_B_COMPMASK__MASK; } static inline uint32_t REG_A3XX_SP_VS_VPC_DST(uint32_t i0) { return 0x000022d0 + 0x1*i0; } static inline uint32_t REG_A3XX_SP_VS_VPC_DST_REG(uint32_t i0) { return 0x000022d0 + 0x1*i0; } #define A3XX_SP_VS_VPC_DST_REG_OUTLOC0__MASK 0x000000ff #define A3XX_SP_VS_VPC_DST_REG_OUTLOC0__SHIFT 0 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC0(uint32_t val) { return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC0__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC0__MASK; } #define A3XX_SP_VS_VPC_DST_REG_OUTLOC1__MASK 0x0000ff00 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC1__SHIFT 8 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC1(uint32_t val) { return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC1__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC1__MASK; } #define A3XX_SP_VS_VPC_DST_REG_OUTLOC2__MASK 0x00ff0000 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC2__SHIFT 16 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC2(uint32_t val) { return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC2__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC2__MASK; } #define A3XX_SP_VS_VPC_DST_REG_OUTLOC3__MASK 0xff000000 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC3__SHIFT 24 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC3(uint32_t val) { return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC3__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC3__MASK; } #define REG_A3XX_SP_VS_OBJ_OFFSET_REG 0x000022d4 #define A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK 0x01ff0000 #define A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT 16 static inline uint32_t A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET(uint32_t val) { return ((val) << A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT) & A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK; } #define A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET__MASK 0xfe000000 #define A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET__SHIFT 25 static inline uint32_t A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET(uint32_t val) { return ((val) << A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET__SHIFT) & A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET__MASK; } #define REG_A3XX_SP_VS_OBJ_START_REG 0x000022d5 #define REG_A3XX_SP_VS_PVT_MEM_PARAM_REG 0x000022d6 #define REG_A3XX_SP_VS_PVT_MEM_ADDR_REG 0x000022d7 #define REG_A3XX_SP_VS_PVT_MEM_SIZE_REG 0x000022d8 #define REG_A3XX_SP_VS_LENGTH_REG 0x000022df #define A3XX_SP_VS_LENGTH_REG_SHADERLENGTH__MASK 0xffffffff #define A3XX_SP_VS_LENGTH_REG_SHADERLENGTH__SHIFT 0 static inline uint32_t A3XX_SP_VS_LENGTH_REG_SHADERLENGTH(uint32_t val) { return ((val) << A3XX_SP_VS_LENGTH_REG_SHADERLENGTH__SHIFT) & A3XX_SP_VS_LENGTH_REG_SHADERLENGTH__MASK; } #define REG_A3XX_SP_FS_CTRL_REG0 0x000022e0 #define A3XX_SP_FS_CTRL_REG0_THREADMODE__MASK 0x00000001 #define A3XX_SP_FS_CTRL_REG0_THREADMODE__SHIFT 0 static inline uint32_t A3XX_SP_FS_CTRL_REG0_THREADMODE(enum a3xx_threadmode val) { return ((val) << A3XX_SP_FS_CTRL_REG0_THREADMODE__SHIFT) & A3XX_SP_FS_CTRL_REG0_THREADMODE__MASK; } #define A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__MASK 0x00000002 #define A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__SHIFT 1 static inline uint32_t A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE(enum a3xx_instrbuffermode val) { return ((val) << A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__SHIFT) & A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__MASK; } #define A3XX_SP_FS_CTRL_REG0_CACHEINVALID 0x00000004 #define A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__MASK 0x000003f0 #define A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT 4 static inline uint32_t A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT) & A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__MASK; } #define A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__MASK 0x0003fc00 #define A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT 10 static inline uint32_t A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT) & A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__MASK; } #define A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__MASK 0x000c0000 #define A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__SHIFT 18 static inline uint32_t A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__SHIFT) & A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__MASK; } #define A3XX_SP_FS_CTRL_REG0_THREADSIZE__MASK 0x00100000 #define A3XX_SP_FS_CTRL_REG0_THREADSIZE__SHIFT 20 static inline uint32_t A3XX_SP_FS_CTRL_REG0_THREADSIZE(enum a3xx_threadsize val) { return ((val) << A3XX_SP_FS_CTRL_REG0_THREADSIZE__SHIFT) & A3XX_SP_FS_CTRL_REG0_THREADSIZE__MASK; } #define A3XX_SP_FS_CTRL_REG0_SUPERTHREADMODE 0x00200000 #define A3XX_SP_FS_CTRL_REG0_PIXLODENABLE 0x00400000 #define A3XX_SP_FS_CTRL_REG0_COMPUTEMODE 0x00800000 #define A3XX_SP_FS_CTRL_REG0_LENGTH__MASK 0xff000000 #define A3XX_SP_FS_CTRL_REG0_LENGTH__SHIFT 24 static inline uint32_t A3XX_SP_FS_CTRL_REG0_LENGTH(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG0_LENGTH__SHIFT) & A3XX_SP_FS_CTRL_REG0_LENGTH__MASK; } #define REG_A3XX_SP_FS_CTRL_REG1 0x000022e1 #define A3XX_SP_FS_CTRL_REG1_CONSTLENGTH__MASK 0x000003ff #define A3XX_SP_FS_CTRL_REG1_CONSTLENGTH__SHIFT 0 static inline uint32_t A3XX_SP_FS_CTRL_REG1_CONSTLENGTH(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG1_CONSTLENGTH__SHIFT) & A3XX_SP_FS_CTRL_REG1_CONSTLENGTH__MASK; } #define A3XX_SP_FS_CTRL_REG1_CONSTFOOTPRINT__MASK 0x000ffc00 #define A3XX_SP_FS_CTRL_REG1_CONSTFOOTPRINT__SHIFT 10 static inline uint32_t A3XX_SP_FS_CTRL_REG1_CONSTFOOTPRINT(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG1_CONSTFOOTPRINT__SHIFT) & A3XX_SP_FS_CTRL_REG1_CONSTFOOTPRINT__MASK; } #define A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__MASK 0x00f00000 #define A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__SHIFT 20 static inline uint32_t A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__SHIFT) & A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__MASK; } #define A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__MASK 0x3f000000 #define A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__SHIFT 24 static inline uint32_t A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET(uint32_t val) { return ((val) << A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__SHIFT) & A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__MASK; } #define REG_A3XX_SP_FS_OBJ_OFFSET_REG 0x000022e2 #define A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK 0x01ff0000 #define A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT 16 static inline uint32_t A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET(uint32_t val) { return ((val) << A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT) & A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK; } #define A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET__MASK 0xfe000000 #define A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET__SHIFT 25 static inline uint32_t A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET(uint32_t val) { return ((val) << A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET__SHIFT) & A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET__MASK; } #define REG_A3XX_SP_FS_OBJ_START_REG 0x000022e3 #define REG_A3XX_SP_FS_PVT_MEM_PARAM_REG 0x000022e4 #define REG_A3XX_SP_FS_PVT_MEM_ADDR_REG 0x000022e5 #define REG_A3XX_SP_FS_PVT_MEM_SIZE_REG 0x000022e6 #define REG_A3XX_SP_FS_FLAT_SHAD_MODE_REG_0 0x000022e8 #define REG_A3XX_SP_FS_FLAT_SHAD_MODE_REG_1 0x000022e9 #define REG_A3XX_SP_FS_OUTPUT_REG 0x000022ec #define A3XX_SP_FS_OUTPUT_REG_MRT__MASK 0x00000003 #define A3XX_SP_FS_OUTPUT_REG_MRT__SHIFT 0 static inline uint32_t A3XX_SP_FS_OUTPUT_REG_MRT(uint32_t val) { return ((val) << A3XX_SP_FS_OUTPUT_REG_MRT__SHIFT) & A3XX_SP_FS_OUTPUT_REG_MRT__MASK; } #define A3XX_SP_FS_OUTPUT_REG_DEPTH_ENABLE 0x00000080 #define A3XX_SP_FS_OUTPUT_REG_DEPTH_REGID__MASK 0x0000ff00 #define A3XX_SP_FS_OUTPUT_REG_DEPTH_REGID__SHIFT 8 static inline uint32_t A3XX_SP_FS_OUTPUT_REG_DEPTH_REGID(uint32_t val) { return ((val) << A3XX_SP_FS_OUTPUT_REG_DEPTH_REGID__SHIFT) & A3XX_SP_FS_OUTPUT_REG_DEPTH_REGID__MASK; } static inline uint32_t REG_A3XX_SP_FS_MRT(uint32_t i0) { return 0x000022f0 + 0x1*i0; } static inline uint32_t REG_A3XX_SP_FS_MRT_REG(uint32_t i0) { return 0x000022f0 + 0x1*i0; } #define A3XX_SP_FS_MRT_REG_REGID__MASK 0x000000ff #define A3XX_SP_FS_MRT_REG_REGID__SHIFT 0 static inline uint32_t A3XX_SP_FS_MRT_REG_REGID(uint32_t val) { return ((val) << A3XX_SP_FS_MRT_REG_REGID__SHIFT) & A3XX_SP_FS_MRT_REG_REGID__MASK; } #define A3XX_SP_FS_MRT_REG_HALF_PRECISION 0x00000100 #define A3XX_SP_FS_MRT_REG_SINT 0x00000400 #define A3XX_SP_FS_MRT_REG_UINT 0x00000800 static inline uint32_t REG_A3XX_SP_FS_IMAGE_OUTPUT(uint32_t i0) { return 0x000022f4 + 0x1*i0; } static inline uint32_t REG_A3XX_SP_FS_IMAGE_OUTPUT_REG(uint32_t i0) { return 0x000022f4 + 0x1*i0; } #define A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT__MASK 0x0000003f #define A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT__SHIFT 0 static inline uint32_t A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT(enum a3xx_color_fmt val) { return ((val) << A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT__SHIFT) & A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT__MASK; } #define REG_A3XX_SP_FS_LENGTH_REG 0x000022ff #define A3XX_SP_FS_LENGTH_REG_SHADERLENGTH__MASK 0xffffffff #define A3XX_SP_FS_LENGTH_REG_SHADERLENGTH__SHIFT 0 static inline uint32_t A3XX_SP_FS_LENGTH_REG_SHADERLENGTH(uint32_t val) { return ((val) << A3XX_SP_FS_LENGTH_REG_SHADERLENGTH__SHIFT) & A3XX_SP_FS_LENGTH_REG_SHADERLENGTH__MASK; } #define REG_A3XX_PA_SC_AA_CONFIG 0x00002301 #define REG_A3XX_TPL1_TP_VS_TEX_OFFSET 0x00002340 #define A3XX_TPL1_TP_VS_TEX_OFFSET_SAMPLEROFFSET__MASK 0x000000ff #define A3XX_TPL1_TP_VS_TEX_OFFSET_SAMPLEROFFSET__SHIFT 0 static inline uint32_t A3XX_TPL1_TP_VS_TEX_OFFSET_SAMPLEROFFSET(uint32_t val) { return ((val) << A3XX_TPL1_TP_VS_TEX_OFFSET_SAMPLEROFFSET__SHIFT) & A3XX_TPL1_TP_VS_TEX_OFFSET_SAMPLEROFFSET__MASK; } #define A3XX_TPL1_TP_VS_TEX_OFFSET_MEMOBJOFFSET__MASK 0x0000ff00 #define A3XX_TPL1_TP_VS_TEX_OFFSET_MEMOBJOFFSET__SHIFT 8 static inline uint32_t A3XX_TPL1_TP_VS_TEX_OFFSET_MEMOBJOFFSET(uint32_t val) { return ((val) << A3XX_TPL1_TP_VS_TEX_OFFSET_MEMOBJOFFSET__SHIFT) & A3XX_TPL1_TP_VS_TEX_OFFSET_MEMOBJOFFSET__MASK; } #define A3XX_TPL1_TP_VS_TEX_OFFSET_BASETABLEPTR__MASK 0xffff0000 #define A3XX_TPL1_TP_VS_TEX_OFFSET_BASETABLEPTR__SHIFT 16 static inline uint32_t A3XX_TPL1_TP_VS_TEX_OFFSET_BASETABLEPTR(uint32_t val) { return ((val) << A3XX_TPL1_TP_VS_TEX_OFFSET_BASETABLEPTR__SHIFT) & A3XX_TPL1_TP_VS_TEX_OFFSET_BASETABLEPTR__MASK; } #define REG_A3XX_TPL1_TP_VS_BORDER_COLOR_BASE_ADDR 0x00002341 #define REG_A3XX_TPL1_TP_FS_TEX_OFFSET 0x00002342 #define A3XX_TPL1_TP_FS_TEX_OFFSET_SAMPLEROFFSET__MASK 0x000000ff #define A3XX_TPL1_TP_FS_TEX_OFFSET_SAMPLEROFFSET__SHIFT 0 static inline uint32_t A3XX_TPL1_TP_FS_TEX_OFFSET_SAMPLEROFFSET(uint32_t val) { return ((val) << A3XX_TPL1_TP_FS_TEX_OFFSET_SAMPLEROFFSET__SHIFT) & A3XX_TPL1_TP_FS_TEX_OFFSET_SAMPLEROFFSET__MASK; } #define A3XX_TPL1_TP_FS_TEX_OFFSET_MEMOBJOFFSET__MASK 0x0000ff00 #define A3XX_TPL1_TP_FS_TEX_OFFSET_MEMOBJOFFSET__SHIFT 8 static inline uint32_t A3XX_TPL1_TP_FS_TEX_OFFSET_MEMOBJOFFSET(uint32_t val) { return ((val) << A3XX_TPL1_TP_FS_TEX_OFFSET_MEMOBJOFFSET__SHIFT) & A3XX_TPL1_TP_FS_TEX_OFFSET_MEMOBJOFFSET__MASK; } #define A3XX_TPL1_TP_FS_TEX_OFFSET_BASETABLEPTR__MASK 0xffff0000 #define A3XX_TPL1_TP_FS_TEX_OFFSET_BASETABLEPTR__SHIFT 16 static inline uint32_t A3XX_TPL1_TP_FS_TEX_OFFSET_BASETABLEPTR(uint32_t val) { return ((val) << A3XX_TPL1_TP_FS_TEX_OFFSET_BASETABLEPTR__SHIFT) & A3XX_TPL1_TP_FS_TEX_OFFSET_BASETABLEPTR__MASK; } #define REG_A3XX_TPL1_TP_FS_BORDER_COLOR_BASE_ADDR 0x00002343 #define REG_A3XX_VBIF_CLKON 0x00003001 #define REG_A3XX_VBIF_FIXED_SORT_EN 0x0000300c #define REG_A3XX_VBIF_FIXED_SORT_SEL0 0x0000300d #define REG_A3XX_VBIF_FIXED_SORT_SEL1 0x0000300e #define REG_A3XX_VBIF_ABIT_SORT 0x0000301c #define REG_A3XX_VBIF_ABIT_SORT_CONF 0x0000301d #define REG_A3XX_VBIF_GATE_OFF_WRREQ_EN 0x0000302a #define REG_A3XX_VBIF_IN_RD_LIM_CONF0 0x0000302c #define REG_A3XX_VBIF_IN_RD_LIM_CONF1 0x0000302d #define REG_A3XX_VBIF_IN_WR_LIM_CONF0 0x00003030 #define REG_A3XX_VBIF_IN_WR_LIM_CONF1 0x00003031 #define REG_A3XX_VBIF_OUT_RD_LIM_CONF0 0x00003034 #define REG_A3XX_VBIF_OUT_WR_LIM_CONF0 0x00003035 #define REG_A3XX_VBIF_DDR_OUT_MAX_BURST 0x00003036 #define REG_A3XX_VBIF_ARB_CTL 0x0000303c #define REG_A3XX_VBIF_ROUND_ROBIN_QOS_ARB 0x00003049 #define REG_A3XX_VBIF_OUT_AXI_AMEMTYPE_CONF0 0x00003058 #define REG_A3XX_VBIF_OUT_AXI_AOOO_EN 0x0000305e #define REG_A3XX_VBIF_OUT_AXI_AOOO 0x0000305f #define REG_A3XX_VBIF_PERF_CNT_EN 0x00003070 #define A3XX_VBIF_PERF_CNT_EN_CNT0 0x00000001 #define A3XX_VBIF_PERF_CNT_EN_CNT1 0x00000002 #define A3XX_VBIF_PERF_CNT_EN_PWRCNT0 0x00000004 #define A3XX_VBIF_PERF_CNT_EN_PWRCNT1 0x00000008 #define A3XX_VBIF_PERF_CNT_EN_PWRCNT2 0x00000010 #define REG_A3XX_VBIF_PERF_CNT_CLR 0x00003071 #define A3XX_VBIF_PERF_CNT_CLR_CNT0 0x00000001 #define A3XX_VBIF_PERF_CNT_CLR_CNT1 0x00000002 #define A3XX_VBIF_PERF_CNT_CLR_PWRCNT0 0x00000004 #define A3XX_VBIF_PERF_CNT_CLR_PWRCNT1 0x00000008 #define A3XX_VBIF_PERF_CNT_CLR_PWRCNT2 0x00000010 #define REG_A3XX_VBIF_PERF_CNT_SEL 0x00003072 #define REG_A3XX_VBIF_PERF_CNT0_LO 0x00003073 #define REG_A3XX_VBIF_PERF_CNT0_HI 0x00003074 #define REG_A3XX_VBIF_PERF_CNT1_LO 0x00003075 #define REG_A3XX_VBIF_PERF_CNT1_HI 0x00003076 #define REG_A3XX_VBIF_PERF_PWR_CNT0_LO 0x00003077 #define REG_A3XX_VBIF_PERF_PWR_CNT0_HI 0x00003078 #define REG_A3XX_VBIF_PERF_PWR_CNT1_LO 0x00003079 #define REG_A3XX_VBIF_PERF_PWR_CNT1_HI 0x0000307a #define REG_A3XX_VBIF_PERF_PWR_CNT2_LO 0x0000307b #define REG_A3XX_VBIF_PERF_PWR_CNT2_HI 0x0000307c #define REG_A3XX_VSC_BIN_SIZE 0x00000c01 #define A3XX_VSC_BIN_SIZE_WIDTH__MASK 0x0000001f #define A3XX_VSC_BIN_SIZE_WIDTH__SHIFT 0 static inline uint32_t A3XX_VSC_BIN_SIZE_WIDTH(uint32_t val) { return ((val >> 5) << A3XX_VSC_BIN_SIZE_WIDTH__SHIFT) & A3XX_VSC_BIN_SIZE_WIDTH__MASK; } #define A3XX_VSC_BIN_SIZE_HEIGHT__MASK 0x000003e0 #define A3XX_VSC_BIN_SIZE_HEIGHT__SHIFT 5 static inline uint32_t A3XX_VSC_BIN_SIZE_HEIGHT(uint32_t val) { return ((val >> 5) << A3XX_VSC_BIN_SIZE_HEIGHT__SHIFT) & A3XX_VSC_BIN_SIZE_HEIGHT__MASK; } #define REG_A3XX_VSC_SIZE_ADDRESS 0x00000c02 static inline uint32_t REG_A3XX_VSC_PIPE(uint32_t i0) { return 0x00000c06 + 0x3*i0; } static inline uint32_t REG_A3XX_VSC_PIPE_CONFIG(uint32_t i0) { return 0x00000c06 + 0x3*i0; } #define A3XX_VSC_PIPE_CONFIG_X__MASK 0x000003ff #define A3XX_VSC_PIPE_CONFIG_X__SHIFT 0 static inline uint32_t A3XX_VSC_PIPE_CONFIG_X(uint32_t val) { return ((val) << A3XX_VSC_PIPE_CONFIG_X__SHIFT) & A3XX_VSC_PIPE_CONFIG_X__MASK; } #define A3XX_VSC_PIPE_CONFIG_Y__MASK 0x000ffc00 #define A3XX_VSC_PIPE_CONFIG_Y__SHIFT 10 static inline uint32_t A3XX_VSC_PIPE_CONFIG_Y(uint32_t val) { return ((val) << A3XX_VSC_PIPE_CONFIG_Y__SHIFT) & A3XX_VSC_PIPE_CONFIG_Y__MASK; } #define A3XX_VSC_PIPE_CONFIG_W__MASK 0x00f00000 #define A3XX_VSC_PIPE_CONFIG_W__SHIFT 20 static inline uint32_t A3XX_VSC_PIPE_CONFIG_W(uint32_t val) { return ((val) << A3XX_VSC_PIPE_CONFIG_W__SHIFT) & A3XX_VSC_PIPE_CONFIG_W__MASK; } #define A3XX_VSC_PIPE_CONFIG_H__MASK 0x0f000000 #define A3XX_VSC_PIPE_CONFIG_H__SHIFT 24 static inline uint32_t A3XX_VSC_PIPE_CONFIG_H(uint32_t val) { return ((val) << A3XX_VSC_PIPE_CONFIG_H__SHIFT) & A3XX_VSC_PIPE_CONFIG_H__MASK; } static inline uint32_t REG_A3XX_VSC_PIPE_DATA_ADDRESS(uint32_t i0) { return 0x00000c07 + 0x3*i0; } static inline uint32_t REG_A3XX_VSC_PIPE_DATA_LENGTH(uint32_t i0) { return 0x00000c08 + 0x3*i0; } #define REG_A3XX_VSC_BIN_CONTROL 0x00000c3c #define A3XX_VSC_BIN_CONTROL_BINNING_ENABLE 0x00000001 #define REG_A3XX_UNKNOWN_0C3D 0x00000c3d #define REG_A3XX_PC_PERFCOUNTER0_SELECT 0x00000c48 #define REG_A3XX_PC_PERFCOUNTER1_SELECT 0x00000c49 #define REG_A3XX_PC_PERFCOUNTER2_SELECT 0x00000c4a #define REG_A3XX_PC_PERFCOUNTER3_SELECT 0x00000c4b #define REG_A3XX_GRAS_TSE_DEBUG_ECO 0x00000c81 #define REG_A3XX_GRAS_PERFCOUNTER0_SELECT 0x00000c88 #define REG_A3XX_GRAS_PERFCOUNTER1_SELECT 0x00000c89 #define REG_A3XX_GRAS_PERFCOUNTER2_SELECT 0x00000c8a #define REG_A3XX_GRAS_PERFCOUNTER3_SELECT 0x00000c8b static inline uint32_t REG_A3XX_GRAS_CL_USER_PLANE(uint32_t i0) { return 0x00000ca0 + 0x4*i0; } static inline uint32_t REG_A3XX_GRAS_CL_USER_PLANE_X(uint32_t i0) { return 0x00000ca0 + 0x4*i0; } static inline uint32_t REG_A3XX_GRAS_CL_USER_PLANE_Y(uint32_t i0) { return 0x00000ca1 + 0x4*i0; } static inline uint32_t REG_A3XX_GRAS_CL_USER_PLANE_Z(uint32_t i0) { return 0x00000ca2 + 0x4*i0; } static inline uint32_t REG_A3XX_GRAS_CL_USER_PLANE_W(uint32_t i0) { return 0x00000ca3 + 0x4*i0; } #define REG_A3XX_RB_GMEM_BASE_ADDR 0x00000cc0 #define REG_A3XX_RB_DEBUG_ECO_CONTROLS_ADDR 0x00000cc1 #define REG_A3XX_RB_PERFCOUNTER0_SELECT 0x00000cc6 #define REG_A3XX_RB_PERFCOUNTER1_SELECT 0x00000cc7 #define REG_A3XX_RB_FRAME_BUFFER_DIMENSION 0x00000ce0 #define A3XX_RB_FRAME_BUFFER_DIMENSION_WIDTH__MASK 0x00003fff #define A3XX_RB_FRAME_BUFFER_DIMENSION_WIDTH__SHIFT 0 static inline uint32_t A3XX_RB_FRAME_BUFFER_DIMENSION_WIDTH(uint32_t val) { return ((val) << A3XX_RB_FRAME_BUFFER_DIMENSION_WIDTH__SHIFT) & A3XX_RB_FRAME_BUFFER_DIMENSION_WIDTH__MASK; } #define A3XX_RB_FRAME_BUFFER_DIMENSION_HEIGHT__MASK 0x0fffc000 #define A3XX_RB_FRAME_BUFFER_DIMENSION_HEIGHT__SHIFT 14 static inline uint32_t A3XX_RB_FRAME_BUFFER_DIMENSION_HEIGHT(uint32_t val) { return ((val) << A3XX_RB_FRAME_BUFFER_DIMENSION_HEIGHT__SHIFT) & A3XX_RB_FRAME_BUFFER_DIMENSION_HEIGHT__MASK; } #define REG_A3XX_HLSQ_PERFCOUNTER0_SELECT 0x00000e00 #define REG_A3XX_HLSQ_PERFCOUNTER1_SELECT 0x00000e01 #define REG_A3XX_HLSQ_PERFCOUNTER2_SELECT 0x00000e02 #define REG_A3XX_HLSQ_PERFCOUNTER3_SELECT 0x00000e03 #define REG_A3XX_HLSQ_PERFCOUNTER4_SELECT 0x00000e04 #define REG_A3XX_HLSQ_PERFCOUNTER5_SELECT 0x00000e05 #define REG_A3XX_UNKNOWN_0E43 0x00000e43 #define REG_A3XX_VFD_PERFCOUNTER0_SELECT 0x00000e44 #define REG_A3XX_VFD_PERFCOUNTER1_SELECT 0x00000e45 #define REG_A3XX_VPC_VPC_DEBUG_RAM_SEL 0x00000e61 #define REG_A3XX_VPC_VPC_DEBUG_RAM_READ 0x00000e62 #define REG_A3XX_VPC_PERFCOUNTER0_SELECT 0x00000e64 #define REG_A3XX_VPC_PERFCOUNTER1_SELECT 0x00000e65 #define REG_A3XX_UCHE_CACHE_MODE_CONTROL_REG 0x00000e82 #define REG_A3XX_UCHE_PERFCOUNTER0_SELECT 0x00000e84 #define REG_A3XX_UCHE_PERFCOUNTER1_SELECT 0x00000e85 #define REG_A3XX_UCHE_PERFCOUNTER2_SELECT 0x00000e86 #define REG_A3XX_UCHE_PERFCOUNTER3_SELECT 0x00000e87 #define REG_A3XX_UCHE_PERFCOUNTER4_SELECT 0x00000e88 #define REG_A3XX_UCHE_PERFCOUNTER5_SELECT 0x00000e89 #define REG_A3XX_UCHE_CACHE_INVALIDATE0_REG 0x00000ea0 #define A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR__MASK 0x0fffffff #define A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR__SHIFT 0 static inline uint32_t A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR(uint32_t val) { return ((val) << A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR__SHIFT) & A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR__MASK; } #define REG_A3XX_UCHE_CACHE_INVALIDATE1_REG 0x00000ea1 #define A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR__MASK 0x0fffffff #define A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR__SHIFT 0 static inline uint32_t A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR(uint32_t val) { return ((val) << A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR__SHIFT) & A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR__MASK; } #define A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE__MASK 0x30000000 #define A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE__SHIFT 28 static inline uint32_t A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE(enum a3xx_cache_opcode val) { return ((val) << A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE__SHIFT) & A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE__MASK; } #define A3XX_UCHE_CACHE_INVALIDATE1_REG_ENTIRE_CACHE 0x80000000 #define REG_A3XX_UNKNOWN_0EA6 0x00000ea6 #define REG_A3XX_SP_PERFCOUNTER0_SELECT 0x00000ec4 #define REG_A3XX_SP_PERFCOUNTER1_SELECT 0x00000ec5 #define REG_A3XX_SP_PERFCOUNTER2_SELECT 0x00000ec6 #define REG_A3XX_SP_PERFCOUNTER3_SELECT 0x00000ec7 #define REG_A3XX_SP_PERFCOUNTER4_SELECT 0x00000ec8 #define REG_A3XX_SP_PERFCOUNTER5_SELECT 0x00000ec9 #define REG_A3XX_SP_PERFCOUNTER6_SELECT 0x00000eca #define REG_A3XX_SP_PERFCOUNTER7_SELECT 0x00000ecb #define REG_A3XX_UNKNOWN_0EE0 0x00000ee0 #define REG_A3XX_UNKNOWN_0F03 0x00000f03 #define REG_A3XX_TP_PERFCOUNTER0_SELECT 0x00000f04 #define REG_A3XX_TP_PERFCOUNTER1_SELECT 0x00000f05 #define REG_A3XX_TP_PERFCOUNTER2_SELECT 0x00000f06 #define REG_A3XX_TP_PERFCOUNTER3_SELECT 0x00000f07 #define REG_A3XX_TP_PERFCOUNTER4_SELECT 0x00000f08 #define REG_A3XX_TP_PERFCOUNTER5_SELECT 0x00000f09 #define REG_A3XX_VGT_CL_INITIATOR 0x000021f0 #define REG_A3XX_VGT_EVENT_INITIATOR 0x000021f9 #define REG_A3XX_VGT_DRAW_INITIATOR 0x000021fc #define A3XX_VGT_DRAW_INITIATOR_PRIM_TYPE__MASK 0x0000003f #define A3XX_VGT_DRAW_INITIATOR_PRIM_TYPE__SHIFT 0 static inline uint32_t A3XX_VGT_DRAW_INITIATOR_PRIM_TYPE(enum pc_di_primtype val) { return ((val) << A3XX_VGT_DRAW_INITIATOR_PRIM_TYPE__SHIFT) & A3XX_VGT_DRAW_INITIATOR_PRIM_TYPE__MASK; } #define A3XX_VGT_DRAW_INITIATOR_SOURCE_SELECT__MASK 0x000000c0 #define A3XX_VGT_DRAW_INITIATOR_SOURCE_SELECT__SHIFT 6 static inline uint32_t A3XX_VGT_DRAW_INITIATOR_SOURCE_SELECT(enum pc_di_src_sel val) { return ((val) << A3XX_VGT_DRAW_INITIATOR_SOURCE_SELECT__SHIFT) & A3XX_VGT_DRAW_INITIATOR_SOURCE_SELECT__MASK; } #define A3XX_VGT_DRAW_INITIATOR_VIS_CULL__MASK 0x00000600 #define A3XX_VGT_DRAW_INITIATOR_VIS_CULL__SHIFT 9 static inline uint32_t A3XX_VGT_DRAW_INITIATOR_VIS_CULL(enum pc_di_vis_cull_mode val) { return ((val) << A3XX_VGT_DRAW_INITIATOR_VIS_CULL__SHIFT) & A3XX_VGT_DRAW_INITIATOR_VIS_CULL__MASK; } #define A3XX_VGT_DRAW_INITIATOR_INDEX_SIZE__MASK 0x00000800 #define A3XX_VGT_DRAW_INITIATOR_INDEX_SIZE__SHIFT 11 static inline uint32_t A3XX_VGT_DRAW_INITIATOR_INDEX_SIZE(enum pc_di_index_size val) { return ((val) << A3XX_VGT_DRAW_INITIATOR_INDEX_SIZE__SHIFT) & A3XX_VGT_DRAW_INITIATOR_INDEX_SIZE__MASK; } #define A3XX_VGT_DRAW_INITIATOR_NOT_EOP 0x00001000 #define A3XX_VGT_DRAW_INITIATOR_SMALL_INDEX 0x00002000 #define A3XX_VGT_DRAW_INITIATOR_PRE_DRAW_INITIATOR_ENABLE 0x00004000 #define A3XX_VGT_DRAW_INITIATOR_NUM_INSTANCES__MASK 0xff000000 #define A3XX_VGT_DRAW_INITIATOR_NUM_INSTANCES__SHIFT 24 static inline uint32_t A3XX_VGT_DRAW_INITIATOR_NUM_INSTANCES(uint32_t val) { return ((val) << A3XX_VGT_DRAW_INITIATOR_NUM_INSTANCES__SHIFT) & A3XX_VGT_DRAW_INITIATOR_NUM_INSTANCES__MASK; } #define REG_A3XX_VGT_IMMED_DATA 0x000021fd #define REG_A3XX_TEX_SAMP_0 0x00000000 #define A3XX_TEX_SAMP_0_CLAMPENABLE 0x00000001 #define A3XX_TEX_SAMP_0_MIPFILTER_LINEAR 0x00000002 #define A3XX_TEX_SAMP_0_XY_MAG__MASK 0x0000000c #define A3XX_TEX_SAMP_0_XY_MAG__SHIFT 2 static inline uint32_t A3XX_TEX_SAMP_0_XY_MAG(enum a3xx_tex_filter val) { return ((val) << A3XX_TEX_SAMP_0_XY_MAG__SHIFT) & A3XX_TEX_SAMP_0_XY_MAG__MASK; } #define A3XX_TEX_SAMP_0_XY_MIN__MASK 0x00000030 #define A3XX_TEX_SAMP_0_XY_MIN__SHIFT 4 static inline uint32_t A3XX_TEX_SAMP_0_XY_MIN(enum a3xx_tex_filter val) { return ((val) << A3XX_TEX_SAMP_0_XY_MIN__SHIFT) & A3XX_TEX_SAMP_0_XY_MIN__MASK; } #define A3XX_TEX_SAMP_0_WRAP_S__MASK 0x000001c0 #define A3XX_TEX_SAMP_0_WRAP_S__SHIFT 6 static inline uint32_t A3XX_TEX_SAMP_0_WRAP_S(enum a3xx_tex_clamp val) { return ((val) << A3XX_TEX_SAMP_0_WRAP_S__SHIFT) & A3XX_TEX_SAMP_0_WRAP_S__MASK; } #define A3XX_TEX_SAMP_0_WRAP_T__MASK 0x00000e00 #define A3XX_TEX_SAMP_0_WRAP_T__SHIFT 9 static inline uint32_t A3XX_TEX_SAMP_0_WRAP_T(enum a3xx_tex_clamp val) { return ((val) << A3XX_TEX_SAMP_0_WRAP_T__SHIFT) & A3XX_TEX_SAMP_0_WRAP_T__MASK; } #define A3XX_TEX_SAMP_0_WRAP_R__MASK 0x00007000 #define A3XX_TEX_SAMP_0_WRAP_R__SHIFT 12 static inline uint32_t A3XX_TEX_SAMP_0_WRAP_R(enum a3xx_tex_clamp val) { return ((val) << A3XX_TEX_SAMP_0_WRAP_R__SHIFT) & A3XX_TEX_SAMP_0_WRAP_R__MASK; } #define A3XX_TEX_SAMP_0_ANISO__MASK 0x00038000 #define A3XX_TEX_SAMP_0_ANISO__SHIFT 15 static inline uint32_t A3XX_TEX_SAMP_0_ANISO(enum a3xx_tex_aniso val) { return ((val) << A3XX_TEX_SAMP_0_ANISO__SHIFT) & A3XX_TEX_SAMP_0_ANISO__MASK; } #define A3XX_TEX_SAMP_0_COMPARE_FUNC__MASK 0x00700000 #define A3XX_TEX_SAMP_0_COMPARE_FUNC__SHIFT 20 static inline uint32_t A3XX_TEX_SAMP_0_COMPARE_FUNC(enum adreno_compare_func val) { return ((val) << A3XX_TEX_SAMP_0_COMPARE_FUNC__SHIFT) & A3XX_TEX_SAMP_0_COMPARE_FUNC__MASK; } #define A3XX_TEX_SAMP_0_CUBEMAPSEAMLESSFILTOFF 0x01000000 #define A3XX_TEX_SAMP_0_UNNORM_COORDS 0x80000000 #define REG_A3XX_TEX_SAMP_1 0x00000001 #define A3XX_TEX_SAMP_1_LOD_BIAS__MASK 0x000007ff #define A3XX_TEX_SAMP_1_LOD_BIAS__SHIFT 0 static inline uint32_t A3XX_TEX_SAMP_1_LOD_BIAS(float val) { return ((((int32_t)(val * 64.0))) << A3XX_TEX_SAMP_1_LOD_BIAS__SHIFT) & A3XX_TEX_SAMP_1_LOD_BIAS__MASK; } #define A3XX_TEX_SAMP_1_MAX_LOD__MASK 0x003ff000 #define A3XX_TEX_SAMP_1_MAX_LOD__SHIFT 12 static inline uint32_t A3XX_TEX_SAMP_1_MAX_LOD(float val) { return ((((uint32_t)(val * 64.0))) << A3XX_TEX_SAMP_1_MAX_LOD__SHIFT) & A3XX_TEX_SAMP_1_MAX_LOD__MASK; } #define A3XX_TEX_SAMP_1_MIN_LOD__MASK 0xffc00000 #define A3XX_TEX_SAMP_1_MIN_LOD__SHIFT 22 static inline uint32_t A3XX_TEX_SAMP_1_MIN_LOD(float val) { return ((((uint32_t)(val * 64.0))) << A3XX_TEX_SAMP_1_MIN_LOD__SHIFT) & A3XX_TEX_SAMP_1_MIN_LOD__MASK; } #define REG_A3XX_TEX_CONST_0 0x00000000 #define A3XX_TEX_CONST_0_TILED 0x00000001 #define A3XX_TEX_CONST_0_SRGB 0x00000004 #define A3XX_TEX_CONST_0_SWIZ_X__MASK 0x00000070 #define A3XX_TEX_CONST_0_SWIZ_X__SHIFT 4 static inline uint32_t A3XX_TEX_CONST_0_SWIZ_X(enum a3xx_tex_swiz val) { return ((val) << A3XX_TEX_CONST_0_SWIZ_X__SHIFT) & A3XX_TEX_CONST_0_SWIZ_X__MASK; } #define A3XX_TEX_CONST_0_SWIZ_Y__MASK 0x00000380 #define A3XX_TEX_CONST_0_SWIZ_Y__SHIFT 7 static inline uint32_t A3XX_TEX_CONST_0_SWIZ_Y(enum a3xx_tex_swiz val) { return ((val) << A3XX_TEX_CONST_0_SWIZ_Y__SHIFT) & A3XX_TEX_CONST_0_SWIZ_Y__MASK; } #define A3XX_TEX_CONST_0_SWIZ_Z__MASK 0x00001c00 #define A3XX_TEX_CONST_0_SWIZ_Z__SHIFT 10 static inline uint32_t A3XX_TEX_CONST_0_SWIZ_Z(enum a3xx_tex_swiz val) { return ((val) << A3XX_TEX_CONST_0_SWIZ_Z__SHIFT) & A3XX_TEX_CONST_0_SWIZ_Z__MASK; } #define A3XX_TEX_CONST_0_SWIZ_W__MASK 0x0000e000 #define A3XX_TEX_CONST_0_SWIZ_W__SHIFT 13 static inline uint32_t A3XX_TEX_CONST_0_SWIZ_W(enum a3xx_tex_swiz val) { return ((val) << A3XX_TEX_CONST_0_SWIZ_W__SHIFT) & A3XX_TEX_CONST_0_SWIZ_W__MASK; } #define A3XX_TEX_CONST_0_MIPLVLS__MASK 0x000f0000 #define A3XX_TEX_CONST_0_MIPLVLS__SHIFT 16 static inline uint32_t A3XX_TEX_CONST_0_MIPLVLS(uint32_t val) { return ((val) << A3XX_TEX_CONST_0_MIPLVLS__SHIFT) & A3XX_TEX_CONST_0_MIPLVLS__MASK; } #define A3XX_TEX_CONST_0_MSAATEX__MASK 0x00300000 #define A3XX_TEX_CONST_0_MSAATEX__SHIFT 20 static inline uint32_t A3XX_TEX_CONST_0_MSAATEX(enum a3xx_tex_msaa val) { return ((val) << A3XX_TEX_CONST_0_MSAATEX__SHIFT) & A3XX_TEX_CONST_0_MSAATEX__MASK; } #define A3XX_TEX_CONST_0_FMT__MASK 0x1fc00000 #define A3XX_TEX_CONST_0_FMT__SHIFT 22 static inline uint32_t A3XX_TEX_CONST_0_FMT(enum a3xx_tex_fmt val) { return ((val) << A3XX_TEX_CONST_0_FMT__SHIFT) & A3XX_TEX_CONST_0_FMT__MASK; } #define A3XX_TEX_CONST_0_NOCONVERT 0x20000000 #define A3XX_TEX_CONST_0_TYPE__MASK 0xc0000000 #define A3XX_TEX_CONST_0_TYPE__SHIFT 30 static inline uint32_t A3XX_TEX_CONST_0_TYPE(enum a3xx_tex_type val) { return ((val) << A3XX_TEX_CONST_0_TYPE__SHIFT) & A3XX_TEX_CONST_0_TYPE__MASK; } #define REG_A3XX_TEX_CONST_1 0x00000001 #define A3XX_TEX_CONST_1_HEIGHT__MASK 0x00003fff #define A3XX_TEX_CONST_1_HEIGHT__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_1_HEIGHT(uint32_t val) { return ((val) << A3XX_TEX_CONST_1_HEIGHT__SHIFT) & A3XX_TEX_CONST_1_HEIGHT__MASK; } #define A3XX_TEX_CONST_1_WIDTH__MASK 0x0fffc000 #define A3XX_TEX_CONST_1_WIDTH__SHIFT 14 static inline uint32_t A3XX_TEX_CONST_1_WIDTH(uint32_t val) { return ((val) << A3XX_TEX_CONST_1_WIDTH__SHIFT) & A3XX_TEX_CONST_1_WIDTH__MASK; } #define A3XX_TEX_CONST_1_FETCHSIZE__MASK 0xf0000000 #define A3XX_TEX_CONST_1_FETCHSIZE__SHIFT 28 static inline uint32_t A3XX_TEX_CONST_1_FETCHSIZE(enum a3xx_tex_fetchsize val) { return ((val) << A3XX_TEX_CONST_1_FETCHSIZE__SHIFT) & A3XX_TEX_CONST_1_FETCHSIZE__MASK; } #define REG_A3XX_TEX_CONST_2 0x00000002 #define A3XX_TEX_CONST_2_INDX__MASK 0x000001ff #define A3XX_TEX_CONST_2_INDX__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_2_INDX(uint32_t val) { return ((val) << A3XX_TEX_CONST_2_INDX__SHIFT) & A3XX_TEX_CONST_2_INDX__MASK; } #define A3XX_TEX_CONST_2_PITCH__MASK 0x3ffff000 #define A3XX_TEX_CONST_2_PITCH__SHIFT 12 static inline uint32_t A3XX_TEX_CONST_2_PITCH(uint32_t val) { return ((val) << A3XX_TEX_CONST_2_PITCH__SHIFT) & A3XX_TEX_CONST_2_PITCH__MASK; } #define A3XX_TEX_CONST_2_SWAP__MASK 0xc0000000 #define A3XX_TEX_CONST_2_SWAP__SHIFT 30 static inline uint32_t A3XX_TEX_CONST_2_SWAP(enum a3xx_color_swap val) { return ((val) << A3XX_TEX_CONST_2_SWAP__SHIFT) & A3XX_TEX_CONST_2_SWAP__MASK; } #define REG_A3XX_TEX_CONST_3 0x00000003 #define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x0001ffff #define A3XX_TEX_CONST_3_LAYERSZ1__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_3_LAYERSZ1(uint32_t val) { return ((val >> 12) << A3XX_TEX_CONST_3_LAYERSZ1__SHIFT) & A3XX_TEX_CONST_3_LAYERSZ1__MASK; } #define A3XX_TEX_CONST_3_DEPTH__MASK 0x0ffe0000 #define A3XX_TEX_CONST_3_DEPTH__SHIFT 17 static inline uint32_t A3XX_TEX_CONST_3_DEPTH(uint32_t val) { return ((val) << A3XX_TEX_CONST_3_DEPTH__SHIFT) & A3XX_TEX_CONST_3_DEPTH__MASK; } #define A3XX_TEX_CONST_3_LAYERSZ2__MASK 0xf0000000 #define A3XX_TEX_CONST_3_LAYERSZ2__SHIFT 28 static inline uint32_t A3XX_TEX_CONST_3_LAYERSZ2(uint32_t val) { return ((val >> 12) << A3XX_TEX_CONST_3_LAYERSZ2__SHIFT) & A3XX_TEX_CONST_3_LAYERSZ2__MASK; } #endif /* A3XX_XML */
/* YUI 3.15.0 (build 834026e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ /* Horizontal Slider */ /* Use thumbUrl /build/slider-base/assets/skins/capsule/thumb-x.png */ /* Alternate thumbUrl /build/slider-base/assets/skins/capsule/thumb-x-line.png */ .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail, .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail-cap-left, .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail-cap-right { background-image: url(https://yui-s.yahooapis.com/3.15.0/build/slider-base/assets/skins/capsule/rail-x.png); background-repeat: repeat-x; background-repeat: repeat-x; /* alternate: rail-x-dots.png */ /* alternate: rail-x-lines.png */ } .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail { height: 25px; } .yui3-skin-capsule .yui3-slider-x .yui3-slider-thumb { height: 30px; width: 14px; } .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail-cap-left { background-position: 0 -20px; height: 20px; left: -2px; width: 5px; } .yui3-skin-capsule .yui3-slider-x .yui3-slider-rail-cap-right { background-position: 0 -40px; height: 20px; right: -2px; width: 5px; } .yui3-skin-capsule .yui3-slider-x .yui3-slider-thumb-image { left: 0; top: -10px; } .yui3-skin-capsule .yui3-slider-x .yui3-slider-thumb-shadow { left: 0; opacity: 0.15; filter: alpha(opacity=15); top: -50px; } /* Vertical Slider */ /* Use thumbUrl /build/slider-base/assets/skins/capsule/thumb-y.png */ /* Alternate thumbUrl /build/slider-base/assets/skins/capsule/thumb-y-line.png */ .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail, .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail-cap-top, .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail-cap-bottom { background-image: url(https://yui-s.yahooapis.com/3.15.0/build/slider-base/assets/skins/capsule/rail-y.png); background-repeat: repeat-y; background-repeat: repeat-y; /* alternate: rail-y-dots.png */ /* alternate: rail-y-lines.png */ } .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail { width: 25px; } .yui3-skin-capsule .yui3-slider-y .yui3-slider-thumb { width: 30px; height: 14px; } .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail-cap-top { background-position: -20px 0; width: 20px; top: -2px; height: 5px; } .yui3-skin-capsule .yui3-slider-y .yui3-slider-rail-cap-bottom { background-position: -40px 0; width: 20px; bottom: -2px; height: 5px; } .yui3-skin-capsule .yui3-slider-y .yui3-slider-thumb-image { left: -10px; top: 0; } .yui3-skin-capsule .yui3-slider-y .yui3-slider-thumb-shadow { left: -50px; opacity: 0.15; filter: alpha(opacity=15); top: 0; }
/* * linux/arch/arm/kernel/bios32.c * * PCI bios-type initialisation for PCI machines * * Bits taken from various places. */ #include <linux/export.h> #include <linux/kernel.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/io.h> #include <asm/mach-types.h> #include <asm/mach/map.h> #include <asm/mach/pci.h> static int debug_pci; /* * We can't use pci_get_device() here since we are * called from interrupt context. */ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, int warn) { struct pci_dev *dev; list_for_each_entry(dev, &bus->devices, bus_list) { u16 status; /* * ignore host bridge - we handle * that separately */ if (dev->bus->number == 0 && dev->devfn == 0) continue; pci_read_config_word(dev, PCI_STATUS, &status); if (status == 0xffff) continue; if ((status & status_mask) == 0) continue; /* clear the status errors */ pci_write_config_word(dev, PCI_STATUS, status & status_mask); if (warn) printk("(%s: %04X) ", pci_name(dev), status); } list_for_each_entry(dev, &bus->devices, bus_list) if (dev->subordinate) pcibios_bus_report_status(dev->subordinate, status_mask, warn); } void pcibios_report_status(u_int status_mask, int warn) { struct pci_bus *bus; list_for_each_entry(bus, &pci_root_buses, node) pcibios_bus_report_status(bus, status_mask, warn); } /* * We don't use this to fix the device, but initialisation of it. * It's not the correct use for this, but it works. * Note that the arbiter/ISA bridge appears to be buggy, specifically in * the following area: * 1. park on CPU * 2. ISA bridge ping-pong * 3. ISA bridge master handling of target RETRY * * Bug 3 is responsible for the sound DMA grinding to a halt. We now * live with bug 2. */ static void pci_fixup_83c553(struct pci_dev *dev) { /* * Set memory region to start at address 0, and enable IO */ pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_SPACE_MEMORY); pci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_IO); dev->resource[0].end -= dev->resource[0].start; dev->resource[0].start = 0; /* * All memory requests from ISA to be channelled to PCI */ pci_write_config_byte(dev, 0x48, 0xff); /* * Enable ping-pong on bus master to ISA bridge transactions. * This improves the sound DMA substantially. The fixed * priority arbiter also helps (see below). */ pci_write_config_byte(dev, 0x42, 0x01); /* * Enable PCI retry */ pci_write_config_byte(dev, 0x40, 0x22); /* * We used to set the arbiter to "park on last master" (bit * 1 set), but unfortunately the CyberPro does not park the * bus. We must therefore park on CPU. Unfortunately, this * may trigger yet another bug in the 553. */ pci_write_config_byte(dev, 0x83, 0x02); /* * Make the ISA DMA request lowest priority, and disable * rotating priorities completely. */ pci_write_config_byte(dev, 0x80, 0x11); pci_write_config_byte(dev, 0x81, 0x00); /* * Route INTA input to IRQ 11, and set IRQ11 to be level * sensitive. */ pci_write_config_word(dev, 0x44, 0xb000); outb(0x08, 0x4d1); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_83C553, pci_fixup_83c553); static void pci_fixup_unassign(struct pci_dev *dev) { dev->resource[0].end -= dev->resource[0].start; dev->resource[0].start = 0; } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940F, pci_fixup_unassign); /* * Prevent the PCI layer from seeing the resources allocated to this device * if it is the host bridge by marking it as such. These resources are of * no consequence to the PCI layer (they are handled elsewhere). */ static void pci_fixup_dec21285(struct pci_dev *dev) { int i; if (dev->devfn == 0) { dev->class &= 0xff; dev->class |= PCI_CLASS_BRIDGE_HOST << 8; for (i = 0; i < PCI_NUM_RESOURCES; i++) { dev->resource[i].start = 0; dev->resource[i].end = 0; dev->resource[i].flags = 0; } } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, pci_fixup_dec21285); /* * PCI IDE controllers use non-standard I/O port decoding, respect it. */ static void pci_fixup_ide_bases(struct pci_dev *dev) { struct resource *r; int i; if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) return; for (i = 0; i < PCI_NUM_RESOURCES; i++) { r = dev->resource + i; if ((r->start & ~0x80) == 0x374) { r->start |= 2; r->end = r->start; } } } DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases); /* * Put the DEC21142 to sleep */ static void pci_fixup_dec21142(struct pci_dev *dev) { pci_write_config_dword(dev, 0x40, 0x80000000); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, pci_fixup_dec21142); /* * The CY82C693 needs some rather major fixups to ensure that it does * the right thing. Idea from the Alpha people, with a few additions. * * We ensure that the IDE base registers are set to 1f0/3f4 for the * primary bus, and 170/374 for the secondary bus. Also, hide them * from the PCI subsystem view as well so we won't try to perform * our own auto-configuration on them. * * In addition, we ensure that the PCI IDE interrupts are routed to * IRQ 14 and IRQ 15 respectively. * * The above gets us to a point where the IDE on this device is * functional. However, The CY82C693U _does not work_ in bus * master mode without locking the PCI bus solid. */ static void pci_fixup_cy82c693(struct pci_dev *dev) { if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) { u32 base0, base1; if (dev->class & 0x80) { /* primary */ base0 = 0x1f0; base1 = 0x3f4; } else { /* secondary */ base0 = 0x170; base1 = 0x374; } pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, base0 | PCI_BASE_ADDRESS_SPACE_IO); pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, base1 | PCI_BASE_ADDRESS_SPACE_IO); dev->resource[0].start = 0; dev->resource[0].end = 0; dev->resource[0].flags = 0; dev->resource[1].start = 0; dev->resource[1].end = 0; dev->resource[1].flags = 0; } else if (PCI_FUNC(dev->devfn) == 0) { /* * Setup IDE IRQ routing. */ pci_write_config_byte(dev, 0x4b, 14); pci_write_config_byte(dev, 0x4c, 15); /* * Disable FREQACK handshake, enable USB. */ pci_write_config_byte(dev, 0x4d, 0x41); /* * Enable PCI retry, and PCI post-write buffer. */ pci_write_config_byte(dev, 0x44, 0x17); /* * Enable ISA master and DMA post write buffering. */ pci_write_config_byte(dev, 0x45, 0x03); } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, pci_fixup_cy82c693); static void pci_fixup_it8152(struct pci_dev *dev) { int i; /* fixup for ITE 8152 devices */ /* FIXME: add defines for class 0x68000 and 0x80103 */ if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST || dev->class == 0x68000 || dev->class == 0x80103) { for (i = 0; i < PCI_NUM_RESOURCES; i++) { dev->resource[i].start = 0; dev->resource[i].end = 0; dev->resource[i].flags = 0; } } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8152, pci_fixup_it8152); /* * If the bus contains any of these devices, then we must not turn on * parity checking of any kind. Currently this is CyberPro 20x0 only. */ static inline int pdev_bad_for_parity(struct pci_dev *dev) { return ((dev->vendor == PCI_VENDOR_ID_INTERG && (dev->device == PCI_DEVICE_ID_INTERG_2000 || dev->device == PCI_DEVICE_ID_INTERG_2010)) || (dev->vendor == PCI_VENDOR_ID_ITE && dev->device == PCI_DEVICE_ID_ITE_8152)); } /* * pcibios_fixup_bus - Called after each bus is probed, * but before its children are examined. */ void pcibios_fixup_bus(struct pci_bus *bus) { struct pci_dev *dev; u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_FAST_BACK; /* * Walk the devices on this bus, working out what we can * and can't support. */ list_for_each_entry(dev, &bus->devices, bus_list) { u16 status; pci_read_config_word(dev, PCI_STATUS, &status); /* * If any device on this bus does not support fast back * to back transfers, then the bus as a whole is not able * to support them. Having fast back to back transfers * on saves us one PCI cycle per transaction. */ if (!(status & PCI_STATUS_FAST_BACK)) features &= ~PCI_COMMAND_FAST_BACK; if (pdev_bad_for_parity(dev)) features &= ~(PCI_COMMAND_SERR | PCI_COMMAND_PARITY); switch (dev->class >> 8) { case PCI_CLASS_BRIDGE_PCI: pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &status); status |= PCI_BRIDGE_CTL_PARITY|PCI_BRIDGE_CTL_MASTER_ABORT; status &= ~(PCI_BRIDGE_CTL_BUS_RESET|PCI_BRIDGE_CTL_FAST_BACK); pci_write_config_word(dev, PCI_BRIDGE_CONTROL, status); break; case PCI_CLASS_BRIDGE_CARDBUS: pci_read_config_word(dev, PCI_CB_BRIDGE_CONTROL, &status); status |= PCI_CB_BRIDGE_CTL_PARITY|PCI_CB_BRIDGE_CTL_MASTER_ABORT; pci_write_config_word(dev, PCI_CB_BRIDGE_CONTROL, status); break; } } /* * Now walk the devices again, this time setting them up. */ list_for_each_entry(dev, &bus->devices, bus_list) { u16 cmd; pci_read_config_word(dev, PCI_COMMAND, &cmd); cmd |= features; pci_write_config_word(dev, PCI_COMMAND, cmd); pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES >> 2); } /* * Propagate the flags to the PCI bridge. */ if (bus->self && bus->self->hdr_type == PCI_HEADER_TYPE_BRIDGE) { if (features & PCI_COMMAND_FAST_BACK) bus->bridge_ctl |= PCI_BRIDGE_CTL_FAST_BACK; if (features & PCI_COMMAND_PARITY) bus->bridge_ctl |= PCI_BRIDGE_CTL_PARITY; } /* * Report what we did for this bus */ pr_info("PCI: bus%d: Fast back to back transfers %sabled\n", bus->number, (features & PCI_COMMAND_FAST_BACK) ? "en" : "dis"); } EXPORT_SYMBOL(pcibios_fixup_bus); /* * Swizzle the device pin each time we cross a bridge. If a platform does * not provide a swizzle function, we perform the standard PCI swizzling. * * The default swizzling walks up the bus tree one level at a time, applying * the standard swizzle function at each step, stopping when it finds the PCI * root bus. This will return the slot number of the bridge device on the * root bus and the interrupt pin on that device which should correspond * with the downstream device interrupt. * * Platforms may override this, in which case the slot and pin returned * depend entirely on the platform code. However, please note that the * PCI standard swizzle is implemented on plug-in cards and Cardbus based * PCI extenders, so it can not be ignored. */ static u8 pcibios_swizzle(struct pci_dev *dev, u8 *pin) { struct pci_sys_data *sys = dev->sysdata; int slot, oldpin = *pin; if (sys->swizzle) slot = sys->swizzle(dev, pin); else slot = pci_common_swizzle(dev, pin); if (debug_pci) printk("PCI: %s swizzling pin %d => pin %d slot %d\n", pci_name(dev), oldpin, *pin, slot); return slot; } /* * Map a slot/pin to an IRQ. */ static int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { struct pci_sys_data *sys = dev->sysdata; int irq = -1; if (sys->map_irq) irq = sys->map_irq(dev, slot, pin); if (debug_pci) printk("PCI: %s mapping slot %d pin %d => irq %d\n", pci_name(dev), slot, pin, irq); return irq; } static int pcibios_init_resources(int busnr, struct pci_sys_data *sys) { int ret; struct resource_entry *window; if (list_empty(&sys->resources)) { pci_add_resource_offset(&sys->resources, &iomem_resource, sys->mem_offset); } resource_list_for_each_entry(window, &sys->resources) if (resource_type(window->res) == IORESOURCE_IO) return 0; sys->io_res.start = (busnr * SZ_64K) ? : pcibios_min_io; sys->io_res.end = (busnr + 1) * SZ_64K - 1; sys->io_res.flags = IORESOURCE_IO; sys->io_res.name = sys->io_res_name; sprintf(sys->io_res_name, "PCI%d I/O", busnr); ret = request_resource(&ioport_resource, &sys->io_res); if (ret) { pr_err("PCI: unable to allocate I/O port region (%d)\n", ret); return ret; } pci_add_resource_offset(&sys->resources, &sys->io_res, sys->io_offset); return 0; } static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, struct list_head *head) { struct pci_sys_data *sys = NULL; int ret; int nr, busnr; for (nr = busnr = 0; nr < hw->nr_controllers; nr++) { sys = kzalloc(sizeof(struct pci_sys_data), GFP_KERNEL); if (WARN(!sys, "PCI: unable to allocate sys data!")) break; sys->busnr = busnr; sys->swizzle = hw->swizzle; sys->map_irq = hw->map_irq; INIT_LIST_HEAD(&sys->resources); if (hw->private_data) sys->private_data = hw->private_data[nr]; ret = hw->setup(nr, sys); if (ret > 0) { struct pci_host_bridge *host_bridge; ret = pcibios_init_resources(nr, sys); if (ret) { kfree(sys); break; } if (hw->scan) sys->bus = hw->scan(nr, sys); else sys->bus = pci_scan_root_bus_msi(parent, sys->busnr, hw->ops, sys, &sys->resources, hw->msi_ctrl); if (WARN(!sys->bus, "PCI: unable to scan bus!")) { kfree(sys); break; } busnr = sys->bus->busn_res.end + 1; list_add(&sys->node, head); host_bridge = pci_find_host_bridge(sys->bus); host_bridge->align_resource = hw->align_resource; } else { kfree(sys); if (ret < 0) break; } } } void pci_common_init_dev(struct device *parent, struct hw_pci *hw) { struct pci_sys_data *sys; LIST_HEAD(head); pci_add_flags(PCI_REASSIGN_ALL_RSRC); if (hw->preinit) hw->preinit(); pcibios_init_hw(parent, hw, &head); if (hw->postinit) hw->postinit(); pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq); list_for_each_entry(sys, &head, node) { struct pci_bus *bus = sys->bus; if (!pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; /* * Size the bridge windows. */ pci_bus_size_bridges(bus); /* * Assign resources. */ pci_bus_assign_resources(bus); list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); } /* * Tell drivers about devices found. */ pci_bus_add_devices(bus); } } #ifndef CONFIG_PCI_HOST_ITE8152 void pcibios_set_master(struct pci_dev *dev) { /* No special bus mastering setup handling */ } #endif char * __init pcibios_setup(char *str) { if (!strcmp(str, "debug")) { debug_pci = 1; return NULL; } else if (!strcmp(str, "firmware")) { pci_add_flags(PCI_PROBE_ONLY); return NULL; } return str; } /* * From arch/i386/kernel/pci-i386.c: * * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the * addresses to be allocated in the 0x000-0x0ff region * modulo 0x400. * * Why? Because some silly external IO cards only decode * the low 10 bits of the IO address. The 0x00-0xff region * is reserved for motherboard devices that decode all 16 * bits, so it's ok to allocate at, say, 0x2800-0x28ff, * but we want to try to avoid allocating at 0x2900-0x2bff * which might be mirrored at 0x0100-0x03ff.. */ resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) { struct pci_dev *dev = data; resource_size_t start = res->start; struct pci_host_bridge *host_bridge; if (res->flags & IORESOURCE_IO && start & 0x300) start = (start + 0x3ff) & ~0x3ff; start = (start + align - 1) & ~(align - 1); host_bridge = pci_find_host_bridge(dev->bus); if (host_bridge->align_resource) return host_bridge->align_resource(dev, res, start, size, align); return start; } /** * pcibios_enable_device - Enable I/O and memory. * @dev: PCI device to be enabled */ int pcibios_enable_device(struct pci_dev *dev, int mask) { if (pci_has_flag(PCI_PROBE_ONLY)) return 0; return pci_enable_resources(dev, mask); } int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, enum pci_mmap_state mmap_state, int write_combine) { if (mmap_state == pci_mmap_io) return -EINVAL; /* * Mark this as IO */ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; return 0; } void __init pci_map_io_early(unsigned long pfn) { struct map_desc pci_io_desc = { .virtual = PCI_IO_VIRT_BASE, .type = MT_DEVICE, .length = SZ_64K, }; pci_io_desc.pfn = pfn; iotable_init(&pci_io_desc, 1); }
/* { dg-do compile } */ /* { dg-options "-O2" } */ /* We were not getting the offset of a in B and a in C::B correct, causing an abort. */ struct A { A(); }; struct B : A { A a; }; struct C : B { }; C c;
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Resets the emoticons mapping into the default value * * @package core * @copyright 2010 David Mudrak <david@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__ . '/../config.php'); require_once($CFG->libdir.'/adminlib.php'); admin_externalpage_setup('resetemoticons'); $confirm = optional_param('confirm', false, PARAM_BOOL); if (!$confirm or !confirm_sesskey()) { echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('confirmation', 'admin')); echo $OUTPUT->confirm(get_string('emoticonsreset', 'admin'), new moodle_url($PAGE->url, array('confirm' => 1)), new moodle_url('/admin/settings.php', array('section' => 'htmlsettings'))); echo $OUTPUT->footer(); die(); } $manager = get_emoticon_manager(); set_config('emoticons', $manager->encode_stored_config($manager->default_emoticons())); redirect(new moodle_url('/admin/settings.php', array('section' => 'htmlsettings')));
// { dg-do assemble } // Copyright (C) 2000 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 23 June 2000 <nathan@codesourcery.com> // Origin GNATS bug report 69 from Glenn Ammons <ammons@cs.wisc.edu> // // A base which derives a virtual base hides declarations in the virtual base, // even if that virtual base is accessible via another path [10.2]/6. Make // sure that non-virtual bases of the virtual base are also hidden, not matter // what order bases are declared in. struct A {int a;}; struct B : A {}; struct L1 : virtual B { int a; }; struct L2 : virtual A { int a; }; struct R1 : virtual B {}; struct R2 : virtual A {}; struct C1 : R1, L1 {}; struct C2 : R2, L2 {}; struct D1 : L1, R1 {}; struct D2 : L2, R2 {}; void fn (C1 *c1, D1 *d1, C2 *c2, D2 *d2) { c1->a = 1; d1->a = 1; c2->a = 1; d2->a = 1; }
// { dg-do run } // GROUPS passed miscellaneous extern "C" int printf (const char *, ...); int main() { int i = 0; // Make sure build_unary_op correctly computes this. int *pi = &(++i); *pi = 4; if (i != 4) { printf ("FAIL\n"); return 1; } else printf ("PASS\n"); }
// { dg-do assemble } template <class A> class B { public: A a; }; static B<int> b_int; static B<char> b_char; static B<unsigned char> b_uchar; int foo () { return b_int.a + b_char.a + b_uchar.a; }
/** * @fileoverview Rule to spot scenarios where a newline looks like it is ending a statement, but is not. * @author Glen Mailer * @copyright 2015 Glen Mailer */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { var FUNCTION_MESSAGE = "Unexpected newline between function and ( of function call."; var PROPERTY_MESSAGE = "Unexpected newline between object and [ of property access."; /** * Check to see if the bracket prior to the node is continuing the previous * line's expression * @param {ASTNode} node The node to check. * @param {string} msg The error message to use. * @returns {void} * @private */ function checkForBreakBefore(node, msg) { var tokens = context.getTokensBefore(node, 2); var paren = tokens[1]; var before = tokens[0]; if (paren.loc.start.line !== before.loc.end.line) { context.report(node, paren.loc.start, msg, { char: paren.value }); } } //-------------------------------------------------------------------------- // Public API //-------------------------------------------------------------------------- return { "MemberExpression": function(node) { if (!node.computed) { return; } checkForBreakBefore(node.property, PROPERTY_MESSAGE); }, "CallExpression": function(node) { if (node.arguments.length === 0) { return; } checkForBreakBefore(node.arguments[0], FUNCTION_MESSAGE); } }; }; module.exports.schema = [];
YUI.add('color-base', function (Y, NAME) { /** Color provides static methods for color conversion. Y.Color.toRGB('f00'); // rgb(255, 0, 0) Y.Color.toHex('rgb(255, 255, 0)'); // #ffff00 @module color @submodule color-base @class Color @since 3.8.0 **/ var REGEX_HEX = /^#?([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/, REGEX_HEX3 = /^#?([\da-fA-F]{1})([\da-fA-F]{1})([\da-fA-F]{1})/, REGEX_RGB = /rgba?\(([\d]{1,3}), ?([\d]{1,3}), ?([\d]{1,3}),? ?([.\d]*)?\)/, TYPES = { 'HEX': 'hex', 'RGB': 'rgb', 'RGBA': 'rgba' }, CONVERTS = { 'hex': 'toHex', 'rgb': 'toRGB', 'rgba': 'toRGBA' }; Y.Color = { /** @static @property KEYWORDS @type Object @since 3.8.0 **/ KEYWORDS: { 'black': '000', 'silver': 'c0c0c0', 'gray': '808080', 'white': 'fff', 'maroon': '800000', 'red': 'f00', 'purple': '800080', 'fuchsia': 'f0f', 'green': '008000', 'lime': '0f0', 'olive': '808000', 'yellow': 'ff0', 'navy': '000080', 'blue': '00f', 'teal': '008080', 'aqua': '0ff' }, /** @static @property REGEX_HEX @type RegExp @default /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/ @since 3.8.0 **/ REGEX_HEX: REGEX_HEX, /** @static @property REGEX_HEX3 @type RegExp @default /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})/ @since 3.8.0 **/ REGEX_HEX3: REGEX_HEX3, /** @static @property REGEX_RGB @type RegExp @default /rgba?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3}),? ?([.0-9]{1,3})?\)/ @since 3.8.0 **/ REGEX_RGB: REGEX_RGB, re_RGB: REGEX_RGB, re_hex: REGEX_HEX, re_hex3: REGEX_HEX3, /** @static @property STR_HEX @type String @default #{*}{*}{*} @since 3.8.0 **/ STR_HEX: '#{*}{*}{*}', /** @static @property STR_RGB @type String @default rgb({*}, {*}, {*}) @since 3.8.0 **/ STR_RGB: 'rgb({*}, {*}, {*})', /** @static @property STR_RGBA @type String @default rgba({*}, {*}, {*}, {*}) @since 3.8.0 **/ STR_RGBA: 'rgba({*}, {*}, {*}, {*})', /** @static @property TYPES @type Object @default {'rgb':'rgb', 'rgba':'rgba'} @since 3.8.0 **/ TYPES: TYPES, /** @static @property CONVERTS @type Object @default {} @since 3.8.0 **/ CONVERTS: CONVERTS, /** @public @method convert @param {String} str @param {String} to @return {String} @since 3.8.0 **/ convert: function (str, to) { // check for a toXXX conversion method first // if it doesn't exist, use the toXxx conversion method var convert = Y.Color.CONVERTS[to], clr = Y.Color[convert](str); return clr.toLowerCase(); }, /** Converts provided color value to a hex value string @public @method toHex @param {String} str Hex or RGB value string @return {String} returns array of values or CSS string if options.css is true @since 3.8.0 **/ toHex: function (str) { var clr = Y.Color._convertTo(str, 'hex'); return clr.toLowerCase(); }, /** Converts provided color value to an RGB value string @public @method toRGB @param {String} str Hex or RGB value string @return {String} @since 3.8.0 **/ toRGB: function (str) { var clr = Y.Color._convertTo(str, 'rgb'); return clr.toLowerCase(); }, /** Converts provided color value to an RGB value string @public @method toRGBA @param {String} str Hex or RGB value string @return {String} @since 3.8.0 **/ toRGBA: function (str) { var clr = Y.Color._convertTo(str, 'rgba' ); return clr.toLowerCase(); }, /** Converts the provided color string to an array of values. Will return an empty array if the provided string is not able to be parsed. @public @method toArray @param {String} str @return {Array} @since 3.8.0 **/ toArray: function(str) { // parse with regex and return "matches" array var type = Y.Color.findType(str).toUpperCase(), regex, arr, length, lastItem; if (type === 'HEX' && str.length < 5) { type = 'HEX3'; } if (type.charAt(type.length - 1) === 'A') { type = type.slice(0, -1); } regex = Y.Color['REGEX_' + type]; if (regex) { arr = regex.exec(str) || []; length = arr.length; if (length) { arr.shift(); length--; lastItem = arr[length - 1]; if (!lastItem) { arr[length - 1] = 1; } } } return arr; }, /** Converts the array of values to a string based on the provided template. @public @method fromArray @param {Array} arr @param {String} template @return {String} @since 3.8.0 **/ fromArray: function(arr, template) { arr = arr.concat(); if (typeof template === 'undefined') { return arr.join(', '); } var replace = '{*}'; template = Y.Color['STR_' + template.toUpperCase()]; if (arr.length === 3 && template.match(/\{\*\}/g).length === 4) { arr.push(1); } while ( template.indexOf(replace) >= 0 && arr.length > 0) { template = template.replace(replace, arr.shift()); } return template; }, /** Finds the value type based on the str value provided. @public @method findType @param {String} str @return {String} @since 3.8.0 **/ findType: function (str) { if (Y.Color.KEYWORDS[str]) { return 'keyword'; } var index = str.indexOf('('), key; if (index > 0) { key = str.substr(0, index); } if (key && Y.Color.TYPES[key.toUpperCase()]) { return Y.Color.TYPES[key.toUpperCase()]; } return 'hex'; }, // return 'keyword', 'hex', 'rgb' /** Retrives the alpha channel from the provided string. If no alpha channel is present, `1` will be returned. @protected @method _getAlpha @param {String} clr @return {Number} @since 3.8.0 **/ _getAlpha: function (clr) { var alpha, arr = Y.Color.toArray(clr); if (arr.length > 3) { alpha = arr.pop(); } return +alpha || 1; }, /** Returns the hex value string if found in the KEYWORDS object @protected @method _keywordToHex @param {String} clr @return {String} @since 3.8.0 **/ _keywordToHex: function (clr) { var keyword = Y.Color.KEYWORDS[clr]; if (keyword) { return keyword; } }, /** Converts the provided color string to the value type provided as `to` @protected @method _convertTo @param {String} clr @param {String} to @return {String} @since 3.8.0 **/ _convertTo: function(clr, to) { var from = Y.Color.findType(clr), originalTo = to, needsAlpha, alpha, method, ucTo; if (from === 'keyword') { clr = Y.Color._keywordToHex(clr); from = 'hex'; } if (from === 'hex' && clr.length < 5) { if (clr.charAt(0) === '#') { clr = clr.substr(1); } clr = '#' + clr.charAt(0) + clr.charAt(0) + clr.charAt(1) + clr.charAt(1) + clr.charAt(2) + clr.charAt(2); } if (from === to) { return clr; } if (from.charAt(from.length - 1) === 'a') { from = from.slice(0, -1); } needsAlpha = (to.charAt(to.length - 1) === 'a'); if (needsAlpha) { to = to.slice(0, -1); alpha = Y.Color._getAlpha(clr); } ucTo = to.charAt(0).toUpperCase() + to.substr(1).toLowerCase(); method = Y.Color['_' + from + 'To' + ucTo ]; // check to see if need conversion to rgb first // check to see if there is a direct conversion method // convertions are: hex <-> rgb <-> hsl if (!method) { if (from !== 'rgb' && to !== 'rgb') { clr = Y.Color['_' + from + 'ToRgb'](clr); from = 'rgb'; method = Y.Color['_' + from + 'To' + ucTo ]; } } if (method) { clr = ((method)(clr, needsAlpha)); } // process clr from arrays to strings after conversions if alpha is needed if (needsAlpha) { if (!Y.Lang.isArray(clr)) { clr = Y.Color.toArray(clr); } clr.push(alpha); clr = Y.Color.fromArray(clr, originalTo.toUpperCase()); } return clr; }, /** Processes the hex string into r, g, b values. Will return values as an array, or as an rgb string. @protected @method _hexToRgb @param {String} str @param {Boolean} [toArray] @return {String|Array} @since 3.8.0 **/ _hexToRgb: function (str, toArray) { var r, g, b; /*jshint bitwise:false*/ if (str.charAt(0) === '#') { str = str.substr(1); } str = parseInt(str, 16); r = str >> 16; g = str >> 8 & 0xFF; b = str & 0xFF; if (toArray) { return [r, g, b]; } return 'rgb(' + r + ', ' + g + ', ' + b + ')'; }, /** Processes the rgb string into r, g, b values. Will return values as an array, or as a hex string. @protected @method _rgbToHex @param {String} str @param {Boolean} [toArray] @return {String|Array} @since 3.8.0 **/ _rgbToHex: function (str) { /*jshint bitwise:false*/ var rgb = Y.Color.toArray(str), hex = rgb[2] | (rgb[1] << 8) | (rgb[0] << 16); hex = (+hex).toString(16); while (hex.length < 6) { hex = '0' + hex; } return '#' + hex; } }; }, '@VERSION@', {"requires": ["yui-base"]});
#!/bin/bash # # Kernel-version-dependent shell functions for the rest of the scripts. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, you can access it online at # http://www.gnu.org/licenses/gpl-2.0.html. # # Copyright (C) IBM Corporation, 2013 # # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> # rcutorture_param_n_barrier_cbs bootparam-string # # Adds n_barrier_cbs rcutorture module parameter to kernels having it. rcutorture_param_n_barrier_cbs () { if echo $1 | grep -q "rcutorture\.n_barrier_cbs" then : else echo rcutorture.n_barrier_cbs=4 fi } # rcutorture_param_onoff bootparam-string config-file # # Adds onoff rcutorture module parameters to kernels having it. rcutorture_param_onoff () { if ! bootparam_hotplug_cpu "$1" && configfrag_hotplug_cpu "$2" then echo CPU-hotplug kernel, adding rcutorture onoff. 1>&2 echo rcutorture.onoff_interval=3 rcutorture.onoff_holdoff=30 fi } # per_version_boot_params bootparam-string config-file seconds # # Adds per-version torture-module parameters to kernels supporting them. per_version_boot_params () { echo $1 `rcutorture_param_onoff "$1" "$2"` \ `rcutorture_param_n_barrier_cbs "$1"` \ rcutorture.stat_interval=15 \ rcutorture.shutdown_secs=$3 \ rcutorture.torture_runnable=1 \ rcutorture.test_no_idle_hz=1 \ rcutorture.verbose=1 }
// SPDX-License-Identifier: GPL-2.0-only /* * copyright (c) 2013 Freescale Semiconductor, Inc. * Freescale IMX AHCI SATA platform driver * * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/ahci_platform.h> #include <linux/gpio/consumer.h> #include <linux/of_device.h> #include <linux/mfd/syscon.h> #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> #include <linux/libata.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> #include <linux/thermal.h> #include "ahci.h" #define DRV_NAME "ahci-imx" enum { /* Timer 1-ms Register */ IMX_TIMER1MS = 0x00e0, /* Port0 PHY Control Register */ IMX_P0PHYCR = 0x0178, IMX_P0PHYCR_TEST_PDDQ = 1 << 20, IMX_P0PHYCR_CR_READ = 1 << 19, IMX_P0PHYCR_CR_WRITE = 1 << 18, IMX_P0PHYCR_CR_CAP_DATA = 1 << 17, IMX_P0PHYCR_CR_CAP_ADDR = 1 << 16, /* Port0 PHY Status Register */ IMX_P0PHYSR = 0x017c, IMX_P0PHYSR_CR_ACK = 1 << 18, IMX_P0PHYSR_CR_DATA_OUT = 0xffff << 0, /* Lane0 Output Status Register */ IMX_LANE0_OUT_STAT = 0x2003, IMX_LANE0_OUT_STAT_RX_PLL_STATE = 1 << 1, /* Clock Reset Register */ IMX_CLOCK_RESET = 0x7f3f, IMX_CLOCK_RESET_RESET = 1 << 0, /* IMX8QM HSIO AHCI definitions */ IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET = 0x03, IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET = 0x09, IMX8QM_SATA_PHY_IMPED_RATIO_85OHM = 0x6c, IMX8QM_LPCG_PHYX2_OFFSET = 0x00000, IMX8QM_CSR_PHYX2_OFFSET = 0x90000, IMX8QM_CSR_PHYX1_OFFSET = 0xa0000, IMX8QM_CSR_PHYX_STTS0_OFFSET = 0x4, IMX8QM_CSR_PCIEA_OFFSET = 0xb0000, IMX8QM_CSR_PCIEB_OFFSET = 0xc0000, IMX8QM_CSR_SATA_OFFSET = 0xd0000, IMX8QM_CSR_PCIE_CTRL2_OFFSET = 0x8, IMX8QM_CSR_MISC_OFFSET = 0xe0000, IMX8QM_LPCG_PHYX2_PCLK0_MASK = (0x3 << 16), IMX8QM_LPCG_PHYX2_PCLK1_MASK = (0x3 << 20), IMX8QM_PHY_APB_RSTN_0 = BIT(0), IMX8QM_PHY_MODE_SATA = BIT(19), IMX8QM_PHY_MODE_MASK = (0xf << 17), IMX8QM_PHY_PIPE_RSTN_0 = BIT(24), IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0 = BIT(25), IMX8QM_PHY_PIPE_RSTN_1 = BIT(26), IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1 = BIT(27), IMX8QM_STTS0_LANE0_TX_PLL_LOCK = BIT(4), IMX8QM_MISC_IOB_RXENA = BIT(0), IMX8QM_MISC_IOB_TXENA = BIT(1), IMX8QM_MISC_PHYX1_EPCS_SEL = BIT(12), IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 = BIT(24), IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 = BIT(25), IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 = BIT(28), IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0 = BIT(29), IMX8QM_SATA_CTRL_RESET_N = BIT(12), IMX8QM_SATA_CTRL_EPCS_PHYRESET_N = BIT(7), IMX8QM_CTRL_BUTTON_RST_N = BIT(21), IMX8QM_CTRL_POWER_UP_RST_N = BIT(23), IMX8QM_CTRL_LTSSM_ENABLE = BIT(4), }; enum ahci_imx_type { AHCI_IMX53, AHCI_IMX6Q, AHCI_IMX6QP, AHCI_IMX8QM, }; struct imx_ahci_priv { struct platform_device *ahci_pdev; enum ahci_imx_type type; struct clk *sata_clk; struct clk *sata_ref_clk; struct clk *ahb_clk; struct clk *epcs_tx_clk; struct clk *epcs_rx_clk; struct clk *phy_apbclk; struct clk *phy_pclk0; struct clk *phy_pclk1; void __iomem *phy_base; struct gpio_desc *clkreq_gpiod; struct regmap *gpr; bool no_device; bool first_time; u32 phy_params; u32 imped_ratio; }; static int ahci_imx_hotplug; module_param_named(hotplug, ahci_imx_hotplug, int, 0644); MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)"); static void ahci_imx_host_stop(struct ata_host *host); static int imx_phy_crbit_assert(void __iomem *mmio, u32 bit, bool assert) { int timeout = 10; u32 crval; u32 srval; /* Assert or deassert the bit */ crval = readl(mmio + IMX_P0PHYCR); if (assert) crval |= bit; else crval &= ~bit; writel(crval, mmio + IMX_P0PHYCR); /* Wait for the cr_ack signal */ do { srval = readl(mmio + IMX_P0PHYSR); if ((assert ? srval : ~srval) & IMX_P0PHYSR_CR_ACK) break; usleep_range(100, 200); } while (--timeout); return timeout ? 0 : -ETIMEDOUT; } static int imx_phy_reg_addressing(u16 addr, void __iomem *mmio) { u32 crval = addr; int ret; /* Supply the address on cr_data_in */ writel(crval, mmio + IMX_P0PHYCR); /* Assert the cr_cap_addr signal */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, true); if (ret) return ret; /* Deassert cr_cap_addr */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, false); if (ret) return ret; return 0; } static int imx_phy_reg_write(u16 val, void __iomem *mmio) { u32 crval = val; int ret; /* Supply the data on cr_data_in */ writel(crval, mmio + IMX_P0PHYCR); /* Assert the cr_cap_data signal */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, true); if (ret) return ret; /* Deassert cr_cap_data */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, false); if (ret) return ret; if (val & IMX_CLOCK_RESET_RESET) { /* * In case we're resetting the phy, it's unable to acknowledge, * so we return immediately here. */ crval |= IMX_P0PHYCR_CR_WRITE; writel(crval, mmio + IMX_P0PHYCR); goto out; } /* Assert the cr_write signal */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, true); if (ret) return ret; /* Deassert cr_write */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, false); if (ret) return ret; out: return 0; } static int imx_phy_reg_read(u16 *val, void __iomem *mmio) { int ret; /* Assert the cr_read signal */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, true); if (ret) return ret; /* Capture the data from cr_data_out[] */ *val = readl(mmio + IMX_P0PHYSR) & IMX_P0PHYSR_CR_DATA_OUT; /* Deassert cr_read */ ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, false); if (ret) return ret; return 0; } static int imx_sata_phy_reset(struct ahci_host_priv *hpriv) { struct imx_ahci_priv *imxpriv = hpriv->plat_data; void __iomem *mmio = hpriv->mmio; int timeout = 10; u16 val; int ret; if (imxpriv->type == AHCI_IMX6QP) { /* 6qp adds the sata reset mechanism, use it for 6qp sata */ regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, IMX6Q_GPR5_SATA_SW_PD, 0); regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, IMX6Q_GPR5_SATA_SW_RST, 0); udelay(50); regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, IMX6Q_GPR5_SATA_SW_RST, IMX6Q_GPR5_SATA_SW_RST); return 0; } /* Reset SATA PHY by setting RESET bit of PHY register CLOCK_RESET */ ret = imx_phy_reg_addressing(IMX_CLOCK_RESET, mmio); if (ret) return ret; ret = imx_phy_reg_write(IMX_CLOCK_RESET_RESET, mmio); if (ret) return ret; /* Wait for PHY RX_PLL to be stable */ do { usleep_range(100, 200); ret = imx_phy_reg_addressing(IMX_LANE0_OUT_STAT, mmio); if (ret) return ret; ret = imx_phy_reg_read(&val, mmio); if (ret) return ret; if (val & IMX_LANE0_OUT_STAT_RX_PLL_STATE) break; } while (--timeout); return timeout ? 0 : -ETIMEDOUT; } enum { /* SATA PHY Register */ SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001, SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008, SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009, SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A, SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017, }; static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio) { u16 adc_out_reg, read_sum; u32 index, read_attempt; const u32 attempt_limit = 200; imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio); imx_phy_reg_write(rtune_ctl_reg, mmio); /* two dummy read */ index = 0; read_attempt = 0; adc_out_reg = 0; imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_ADC_OUT, mmio); while (index < 2) { imx_phy_reg_read(&adc_out_reg, mmio); /* check if valid */ if (adc_out_reg & 0x400) index++; read_attempt++; if (read_attempt > attempt_limit) { dev_err(dev, "Read REG more than %d times!\n", attempt_limit); break; } } index = 0; read_attempt = 0; read_sum = 0; while (index < 80) { imx_phy_reg_read(&adc_out_reg, mmio); if (adc_out_reg & 0x400) { read_sum = read_sum + (adc_out_reg & 0x3FF); index++; } read_attempt++; if (read_attempt > attempt_limit) { dev_err(dev, "Read REG more than %d times!\n", attempt_limit); break; } } /* Use the U32 to make 1000 precision */ return (read_sum * 1000) / 80; } /* SATA AHCI temperature monitor */ static int sata_ahci_read_temperature(void *dev, int *temp) { u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum; u32 str1, str2, str3, str4; int m1, m2, a; struct ahci_host_priv *hpriv = dev_get_drvdata(dev); void __iomem *mmio = hpriv->mmio; /* check rd-wr to reg */ read_sum = 0; imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT, mmio); imx_phy_reg_write(read_sum, mmio); imx_phy_reg_read(&read_sum, mmio); if ((read_sum & 0xffff) != 0) dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum); imx_phy_reg_write(0x5A5A, mmio); imx_phy_reg_read(&read_sum, mmio); if ((read_sum & 0xffff) != 0x5A5A) dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum); imx_phy_reg_write(0x1234, mmio); imx_phy_reg_read(&read_sum, mmio); if ((read_sum & 0xffff) != 0x1234) dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum); /* start temperature test */ imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_MPLL_TST, mmio); imx_phy_reg_read(&mpll_test_reg, mmio); imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio); imx_phy_reg_read(&rtune_ctl_reg, mmio); imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_DAC_CTL, mmio); imx_phy_reg_read(&dac_ctl_reg, mmio); /* mpll_tst.meas_iv ([12:2]) */ str1 = (mpll_test_reg >> 2) & 0x7FF; /* rtune_ctl.mode ([1:0]) */ str2 = (rtune_ctl_reg) & 0x3; /* dac_ctl.dac_mode ([14:12]) */ str3 = (dac_ctl_reg >> 12) & 0x7; /* rtune_ctl.sel_atbp ([4]) */ str4 = (rtune_ctl_reg >> 4); /* Calculate the m1 */ /* mpll_tst.meas_iv */ mpll_test_reg = (mpll_test_reg & 0xE03) | (512) << 2; /* rtune_ctl.mode */ rtune_ctl_reg = (rtune_ctl_reg & 0xFFC) | (1); /* dac_ctl.dac_mode */ dac_ctl_reg = (dac_ctl_reg & 0x8FF) | (4) << 12; /* rtune_ctl.sel_atbp */ rtune_ctl_reg = (rtune_ctl_reg & 0xFEF) | (0) << 4; imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_MPLL_TST, mmio); imx_phy_reg_write(mpll_test_reg, mmio); imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_DAC_CTL, mmio); imx_phy_reg_write(dac_ctl_reg, mmio); m1 = read_adc_sum(dev, rtune_ctl_reg, mmio); /* Calculate the m2 */ /* rtune_ctl.sel_atbp */ rtune_ctl_reg = (rtune_ctl_reg & 0xFEF) | (1) << 4; m2 = read_adc_sum(dev, rtune_ctl_reg, mmio); /* restore the status */ /* mpll_tst.meas_iv */ mpll_test_reg = (mpll_test_reg & 0xE03) | (str1) << 2; /* rtune_ctl.mode */ rtune_ctl_reg = (rtune_ctl_reg & 0xFFC) | (str2); /* dac_ctl.dac_mode */ dac_ctl_reg = (dac_ctl_reg & 0x8FF) | (str3) << 12; /* rtune_ctl.sel_atbp */ rtune_ctl_reg = (rtune_ctl_reg & 0xFEF) | (str4) << 4; imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_MPLL_TST, mmio); imx_phy_reg_write(mpll_test_reg, mmio); imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_DAC_CTL, mmio); imx_phy_reg_write(dac_ctl_reg, mmio); imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio); imx_phy_reg_write(rtune_ctl_reg, mmio); /* Compute temperature */ if (!(m2 / 1000)) m2 = 1000; a = (m2 - m1) / (m2/1000); *temp = ((-559) * a * a) / 1000 + (1379) * a + (-458000); return 0; } static ssize_t sata_ahci_show_temp(struct device *dev, struct device_attribute *da, char *buf) { unsigned int temp = 0; int err; err = sata_ahci_read_temperature(dev, &temp); if (err < 0) return err; return sprintf(buf, "%u\n", temp); } static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = { .get_temp = sata_ahci_read_temperature, }; static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, sata_ahci_show_temp, NULL, 0); static struct attribute *fsl_sata_ahci_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, NULL }; ATTRIBUTE_GROUPS(fsl_sata_ahci); static int imx8_sata_enable(struct ahci_host_priv *hpriv) { u32 val, reg; int i, ret; struct imx_ahci_priv *imxpriv = hpriv->plat_data; struct device *dev = &imxpriv->ahci_pdev->dev; /* configure the hsio for sata */ ret = clk_prepare_enable(imxpriv->phy_pclk0); if (ret < 0) { dev_err(dev, "can't enable phy_pclk0.\n"); return ret; } ret = clk_prepare_enable(imxpriv->phy_pclk1); if (ret < 0) { dev_err(dev, "can't enable phy_pclk1.\n"); goto disable_phy_pclk0; } ret = clk_prepare_enable(imxpriv->epcs_tx_clk); if (ret < 0) { dev_err(dev, "can't enable epcs_tx_clk.\n"); goto disable_phy_pclk1; } ret = clk_prepare_enable(imxpriv->epcs_rx_clk); if (ret < 0) { dev_err(dev, "can't enable epcs_rx_clk.\n"); goto disable_epcs_tx_clk; } ret = clk_prepare_enable(imxpriv->phy_apbclk); if (ret < 0) { dev_err(dev, "can't enable phy_apbclk.\n"); goto disable_epcs_rx_clk; } /* Configure PHYx2 PIPE_RSTN */ regmap_read(imxpriv->gpr, IMX8QM_CSR_PCIEA_OFFSET + IMX8QM_CSR_PCIE_CTRL2_OFFSET, &val); if ((val & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { /* The link of the PCIEA of HSIO is down */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_PHYX2_OFFSET, IMX8QM_PHY_PIPE_RSTN_0 | IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0, IMX8QM_PHY_PIPE_RSTN_0 | IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0); } regmap_read(imxpriv->gpr, IMX8QM_CSR_PCIEB_OFFSET + IMX8QM_CSR_PCIE_CTRL2_OFFSET, &reg); if ((reg & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { /* The link of the PCIEB of HSIO is down */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_PHYX2_OFFSET, IMX8QM_PHY_PIPE_RSTN_1 | IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1, IMX8QM_PHY_PIPE_RSTN_1 | IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1); } if (((reg | val) & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { /* The links of both PCIA and PCIEB of HSIO are down */ regmap_update_bits(imxpriv->gpr, IMX8QM_LPCG_PHYX2_OFFSET, IMX8QM_LPCG_PHYX2_PCLK0_MASK | IMX8QM_LPCG_PHYX2_PCLK1_MASK, 0); } /* set PWR_RST and BT_RST of csr_pciea */ val = IMX8QM_CSR_PCIEA_OFFSET + IMX8QM_CSR_PCIE_CTRL2_OFFSET; regmap_update_bits(imxpriv->gpr, val, IMX8QM_CTRL_BUTTON_RST_N, IMX8QM_CTRL_BUTTON_RST_N); regmap_update_bits(imxpriv->gpr, val, IMX8QM_CTRL_POWER_UP_RST_N, IMX8QM_CTRL_POWER_UP_RST_N); /* PHYX1_MODE to SATA */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_PHYX1_OFFSET, IMX8QM_PHY_MODE_MASK, IMX8QM_PHY_MODE_SATA); /* * BIT0 RXENA 1, BIT1 TXENA 0 * BIT12 PHY_X1_EPCS_SEL 1. */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_MISC_OFFSET, IMX8QM_MISC_IOB_RXENA, IMX8QM_MISC_IOB_RXENA); regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_MISC_OFFSET, IMX8QM_MISC_IOB_TXENA, 0); regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_MISC_OFFSET, IMX8QM_MISC_PHYX1_EPCS_SEL, IMX8QM_MISC_PHYX1_EPCS_SEL); /* * It is possible, for PCIe and SATA are sharing * the same clock source, HPLL or external oscillator. * When PCIe is in low power modes (L1.X or L2 etc), * the clock source can be turned off. In this case, * if this clock source is required to be toggling by * SATA, then SATA functions will be abnormal. * Set the override here to avoid it. */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_MISC_OFFSET, IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 | IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 | IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 | IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0, IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 | IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 | IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 | IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0); /* clear PHY RST, then set it */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_SATA_OFFSET, IMX8QM_SATA_CTRL_EPCS_PHYRESET_N, 0); regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_SATA_OFFSET, IMX8QM_SATA_CTRL_EPCS_PHYRESET_N, IMX8QM_SATA_CTRL_EPCS_PHYRESET_N); /* CTRL RST: SET -> delay 1 us -> CLEAR -> SET */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_SATA_OFFSET, IMX8QM_SATA_CTRL_RESET_N, IMX8QM_SATA_CTRL_RESET_N); udelay(1); regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_SATA_OFFSET, IMX8QM_SATA_CTRL_RESET_N, 0); regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_SATA_OFFSET, IMX8QM_SATA_CTRL_RESET_N, IMX8QM_SATA_CTRL_RESET_N); /* APB reset */ regmap_update_bits(imxpriv->gpr, IMX8QM_CSR_PHYX1_OFFSET, IMX8QM_PHY_APB_RSTN_0, IMX8QM_PHY_APB_RSTN_0); for (i = 0; i < 100; i++) { reg = IMX8QM_CSR_PHYX1_OFFSET + IMX8QM_CSR_PHYX_STTS0_OFFSET; regmap_read(imxpriv->gpr, reg, &val); val &= IMX8QM_STTS0_LANE0_TX_PLL_LOCK; if (val == IMX8QM_STTS0_LANE0_TX_PLL_LOCK) break; udelay(1); } if (val != IMX8QM_STTS0_LANE0_TX_PLL_LOCK) { dev_err(dev, "TX PLL of the PHY is not locked\n"); ret = -ENODEV; } else { writeb(imxpriv->imped_ratio, imxpriv->phy_base + IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET); writeb(imxpriv->imped_ratio, imxpriv->phy_base + IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET); reg = readb(imxpriv->phy_base + IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET); if (unlikely(reg != imxpriv->imped_ratio)) dev_info(dev, "Can't set PHY RX impedance ratio.\n"); reg = readb(imxpriv->phy_base + IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET); if (unlikely(reg != imxpriv->imped_ratio)) dev_info(dev, "Can't set PHY TX impedance ratio.\n"); usleep_range(50, 100); /* * To reduce the power consumption, gate off * the PHY clks */ clk_disable_unprepare(imxpriv->phy_apbclk); clk_disable_unprepare(imxpriv->phy_pclk1); clk_disable_unprepare(imxpriv->phy_pclk0); return ret; } clk_disable_unprepare(imxpriv->phy_apbclk); disable_epcs_rx_clk: clk_disable_unprepare(imxpriv->epcs_rx_clk); disable_epcs_tx_clk: clk_disable_unprepare(imxpriv->epcs_tx_clk); disable_phy_pclk1: clk_disable_unprepare(imxpriv->phy_pclk1); disable_phy_pclk0: clk_disable_unprepare(imxpriv->phy_pclk0); return ret; } static int imx_sata_enable(struct ahci_host_priv *hpriv) { struct imx_ahci_priv *imxpriv = hpriv->plat_data; struct device *dev = &imxpriv->ahci_pdev->dev; int ret; if (imxpriv->no_device) return 0; ret = ahci_platform_enable_regulators(hpriv); if (ret) return ret; ret = clk_prepare_enable(imxpriv->sata_ref_clk); if (ret < 0) goto disable_regulator; if (imxpriv->type == AHCI_IMX6Q || imxpriv->type == AHCI_IMX6QP) { /* * set PHY Paremeters, two steps to configure the GPR13, * one write for rest of parameters, mask of first write * is 0x07ffffff, and the other one write for setting * the mpll_clk_en. */ regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK | IMX6Q_GPR13_SATA_SPD_MODE_MASK | IMX6Q_GPR13_SATA_MPLL_SS_EN | IMX6Q_GPR13_SATA_TX_ATTEN_MASK | IMX6Q_GPR13_SATA_TX_BOOST_MASK | IMX6Q_GPR13_SATA_TX_LVL_MASK | IMX6Q_GPR13_SATA_MPLL_CLK_EN | IMX6Q_GPR13_SATA_TX_EDGE_RATE, imxpriv->phy_params); regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, IMX6Q_GPR13_SATA_MPLL_CLK_EN, IMX6Q_GPR13_SATA_MPLL_CLK_EN); usleep_range(100, 200); ret = imx_sata_phy_reset(hpriv); if (ret) { dev_err(dev, "failed to reset phy: %d\n", ret); goto disable_clk; } } else if (imxpriv->type == AHCI_IMX8QM) { ret = imx8_sata_enable(hpriv); } usleep_range(1000, 2000); return 0; disable_clk: clk_disable_unprepare(imxpriv->sata_ref_clk); disable_regulator: ahci_platform_disable_regulators(hpriv); return ret; } static void imx_sata_disable(struct ahci_host_priv *hpriv) { struct imx_ahci_priv *imxpriv = hpriv->plat_data; if (imxpriv->no_device) return; switch (imxpriv->type) { case AHCI_IMX6QP: regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, IMX6Q_GPR5_SATA_SW_PD, IMX6Q_GPR5_SATA_SW_PD); regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, IMX6Q_GPR13_SATA_MPLL_CLK_EN, !IMX6Q_GPR13_SATA_MPLL_CLK_EN); break; case AHCI_IMX6Q: regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, IMX6Q_GPR13_SATA_MPLL_CLK_EN, !IMX6Q_GPR13_SATA_MPLL_CLK_EN); break; case AHCI_IMX8QM: clk_disable_unprepare(imxpriv->epcs_rx_clk); clk_disable_unprepare(imxpriv->epcs_tx_clk); break; default: break; } clk_disable_unprepare(imxpriv->sata_ref_clk); ahci_platform_disable_regulators(hpriv); } static void ahci_imx_error_handler(struct ata_port *ap) { u32 reg_val; struct ata_device *dev; struct ata_host *host = dev_get_drvdata(ap->dev); struct ahci_host_priv *hpriv = host->private_data; void __iomem *mmio = hpriv->mmio; struct imx_ahci_priv *imxpriv = hpriv->plat_data; ahci_error_handler(ap); if (!(imxpriv->first_time) || ahci_imx_hotplug) return; imxpriv->first_time = false; ata_for_each_dev(dev, &ap->link, ENABLED) return; /* * Disable link to save power. An imx ahci port can't be recovered * without full reset once the pddq mode is enabled making it * impossible to use as part of libata LPM. */ reg_val = readl(mmio + IMX_P0PHYCR); writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR); imx_sata_disable(hpriv); imxpriv->no_device = true; dev_info(ap->dev, "no device found, disabling link.\n"); dev_info(ap->dev, "pass " MODULE_PARAM_PREFIX ".hotplug=1 to enable hotplug\n"); } static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, unsigned long deadline) { struct ata_port *ap = link->ap; struct ata_host *host = dev_get_drvdata(ap->dev); struct ahci_host_priv *hpriv = host->private_data; struct imx_ahci_priv *imxpriv = hpriv->plat_data; int ret; if (imxpriv->type == AHCI_IMX53) ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline); else ret = ahci_ops.softreset(link, class, deadline); return ret; } static struct ata_port_operations ahci_imx_ops = { .inherits = &ahci_ops, .host_stop = ahci_imx_host_stop, .error_handler = ahci_imx_error_handler, .softreset = ahci_imx_softreset, }; static const struct ata_port_info ahci_imx_port_info = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, .port_ops = &ahci_imx_ops, }; static const struct of_device_id imx_ahci_of_match[] = { { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 }, { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q }, { .compatible = "fsl,imx6qp-ahci", .data = (void *)AHCI_IMX6QP }, { .compatible = "fsl,imx8qm-ahci", .data = (void *)AHCI_IMX8QM }, {}, }; MODULE_DEVICE_TABLE(of, imx_ahci_of_match); struct reg_value { u32 of_value; u32 reg_value; }; struct reg_property { const char *name; const struct reg_value *values; size_t num_values; u32 def_value; u32 set_value; }; static const struct reg_value gpr13_tx_level[] = { { 937, IMX6Q_GPR13_SATA_TX_LVL_0_937_V }, { 947, IMX6Q_GPR13_SATA_TX_LVL_0_947_V }, { 957, IMX6Q_GPR13_SATA_TX_LVL_0_957_V }, { 966, IMX6Q_GPR13_SATA_TX_LVL_0_966_V }, { 976, IMX6Q_GPR13_SATA_TX_LVL_0_976_V }, { 986, IMX6Q_GPR13_SATA_TX_LVL_0_986_V }, { 996, IMX6Q_GPR13_SATA_TX_LVL_0_996_V }, { 1005, IMX6Q_GPR13_SATA_TX_LVL_1_005_V }, { 1015, IMX6Q_GPR13_SATA_TX_LVL_1_015_V }, { 1025, IMX6Q_GPR13_SATA_TX_LVL_1_025_V }, { 1035, IMX6Q_GPR13_SATA_TX_LVL_1_035_V }, { 1045, IMX6Q_GPR13_SATA_TX_LVL_1_045_V }, { 1054, IMX6Q_GPR13_SATA_TX_LVL_1_054_V }, { 1064, IMX6Q_GPR13_SATA_TX_LVL_1_064_V }, { 1074, IMX6Q_GPR13_SATA_TX_LVL_1_074_V }, { 1084, IMX6Q_GPR13_SATA_TX_LVL_1_084_V }, { 1094, IMX6Q_GPR13_SATA_TX_LVL_1_094_V }, { 1104, IMX6Q_GPR13_SATA_TX_LVL_1_104_V }, { 1113, IMX6Q_GPR13_SATA_TX_LVL_1_113_V }, { 1123, IMX6Q_GPR13_SATA_TX_LVL_1_123_V }, { 1133, IMX6Q_GPR13_SATA_TX_LVL_1_133_V }, { 1143, IMX6Q_GPR13_SATA_TX_LVL_1_143_V }, { 1152, IMX6Q_GPR13_SATA_TX_LVL_1_152_V }, { 1162, IMX6Q_GPR13_SATA_TX_LVL_1_162_V }, { 1172, IMX6Q_GPR13_SATA_TX_LVL_1_172_V }, { 1182, IMX6Q_GPR13_SATA_TX_LVL_1_182_V }, { 1191, IMX6Q_GPR13_SATA_TX_LVL_1_191_V }, { 1201, IMX6Q_GPR13_SATA_TX_LVL_1_201_V }, { 1211, IMX6Q_GPR13_SATA_TX_LVL_1_211_V }, { 1221, IMX6Q_GPR13_SATA_TX_LVL_1_221_V }, { 1230, IMX6Q_GPR13_SATA_TX_LVL_1_230_V }, { 1240, IMX6Q_GPR13_SATA_TX_LVL_1_240_V } }; static const struct reg_value gpr13_tx_boost[] = { { 0, IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB }, { 370, IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB }, { 740, IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB }, { 1110, IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB }, { 1480, IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB }, { 1850, IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB }, { 2220, IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB }, { 2590, IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB }, { 2960, IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB }, { 3330, IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB }, { 3700, IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB }, { 4070, IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB }, { 4440, IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB }, { 4810, IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB }, { 5280, IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB }, { 5750, IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB } }; static const struct reg_value gpr13_tx_atten[] = { { 8, IMX6Q_GPR13_SATA_TX_ATTEN_8_16 }, { 9, IMX6Q_GPR13_SATA_TX_ATTEN_9_16 }, { 10, IMX6Q_GPR13_SATA_TX_ATTEN_10_16 }, { 12, IMX6Q_GPR13_SATA_TX_ATTEN_12_16 }, { 14, IMX6Q_GPR13_SATA_TX_ATTEN_14_16 }, { 16, IMX6Q_GPR13_SATA_TX_ATTEN_16_16 }, }; static const struct reg_value gpr13_rx_eq[] = { { 500, IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB }, { 1000, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB }, { 1500, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB }, { 2000, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB }, { 2500, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB }, { 3000, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB }, { 3500, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB }, { 4000, IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB }, }; static const struct reg_property gpr13_props[] = { { .name = "fsl,transmit-level-mV", .values = gpr13_tx_level, .num_values = ARRAY_SIZE(gpr13_tx_level), .def_value = IMX6Q_GPR13_SATA_TX_LVL_1_025_V, }, { .name = "fsl,transmit-boost-mdB", .values = gpr13_tx_boost, .num_values = ARRAY_SIZE(gpr13_tx_boost), .def_value = IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB, }, { .name = "fsl,transmit-atten-16ths", .values = gpr13_tx_atten, .num_values = ARRAY_SIZE(gpr13_tx_atten), .def_value = IMX6Q_GPR13_SATA_TX_ATTEN_9_16, }, { .name = "fsl,receive-eq-mdB", .values = gpr13_rx_eq, .num_values = ARRAY_SIZE(gpr13_rx_eq), .def_value = IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB, }, { .name = "fsl,no-spread-spectrum", .def_value = IMX6Q_GPR13_SATA_MPLL_SS_EN, .set_value = 0, }, }; static u32 imx_ahci_parse_props(struct device *dev, const struct reg_property *prop, size_t num) { struct device_node *np = dev->of_node; u32 reg_value = 0; int i, j; for (i = 0; i < num; i++, prop++) { u32 of_val; if (prop->num_values == 0) { if (of_property_read_bool(np, prop->name)) reg_value |= prop->set_value; else reg_value |= prop->def_value; continue; } if (of_property_read_u32(np, prop->name, &of_val)) { dev_info(dev, "%s not specified, using %08x\n", prop->name, prop->def_value); reg_value |= prop->def_value; continue; } for (j = 0; j < prop->num_values; j++) { if (prop->values[j].of_value == of_val) { dev_info(dev, "%s value %u, using %08x\n", prop->name, of_val, prop->values[j].reg_value); reg_value |= prop->values[j].reg_value; break; } } if (j == prop->num_values) { dev_err(dev, "DT property %s is not a valid value\n", prop->name); reg_value |= prop->def_value; } } return reg_value; } static struct scsi_host_template ahci_platform_sht = { AHCI_SHT(DRV_NAME), }; static int imx8_sata_probe(struct device *dev, struct imx_ahci_priv *imxpriv) { struct resource *phy_res; struct platform_device *pdev = imxpriv->ahci_pdev; struct device_node *np = dev->of_node; if (of_property_read_u32(np, "fsl,phy-imp", &imxpriv->imped_ratio)) imxpriv->imped_ratio = IMX8QM_SATA_PHY_IMPED_RATIO_85OHM; phy_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); if (phy_res) { imxpriv->phy_base = devm_ioremap(dev, phy_res->start, resource_size(phy_res)); if (!imxpriv->phy_base) { dev_err(dev, "error with ioremap\n"); return -ENOMEM; } } else { dev_err(dev, "missing *phy* reg region.\n"); return -ENOMEM; } imxpriv->gpr = syscon_regmap_lookup_by_phandle(np, "hsio"); if (IS_ERR(imxpriv->gpr)) { dev_err(dev, "unable to find gpr registers\n"); return PTR_ERR(imxpriv->gpr); } imxpriv->epcs_tx_clk = devm_clk_get(dev, "epcs_tx"); if (IS_ERR(imxpriv->epcs_tx_clk)) { dev_err(dev, "can't get epcs_tx_clk clock.\n"); return PTR_ERR(imxpriv->epcs_tx_clk); } imxpriv->epcs_rx_clk = devm_clk_get(dev, "epcs_rx"); if (IS_ERR(imxpriv->epcs_rx_clk)) { dev_err(dev, "can't get epcs_rx_clk clock.\n"); return PTR_ERR(imxpriv->epcs_rx_clk); } imxpriv->phy_pclk0 = devm_clk_get(dev, "phy_pclk0"); if (IS_ERR(imxpriv->phy_pclk0)) { dev_err(dev, "can't get phy_pclk0 clock.\n"); return PTR_ERR(imxpriv->phy_pclk0); } imxpriv->phy_pclk1 = devm_clk_get(dev, "phy_pclk1"); if (IS_ERR(imxpriv->phy_pclk1)) { dev_err(dev, "can't get phy_pclk1 clock.\n"); return PTR_ERR(imxpriv->phy_pclk1); } imxpriv->phy_apbclk = devm_clk_get(dev, "phy_apbclk"); if (IS_ERR(imxpriv->phy_apbclk)) { dev_err(dev, "can't get phy_apbclk clock.\n"); return PTR_ERR(imxpriv->phy_apbclk); } /* Fetch GPIO, then enable the external OSC */ imxpriv->clkreq_gpiod = devm_gpiod_get_optional(dev, "clkreq", GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); if (IS_ERR(imxpriv->clkreq_gpiod)) return PTR_ERR(imxpriv->clkreq_gpiod); if (imxpriv->clkreq_gpiod) gpiod_set_consumer_name(imxpriv->clkreq_gpiod, "SATA CLKREQ"); return 0; } static int imx_ahci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct of_device_id *of_id; struct ahci_host_priv *hpriv; struct imx_ahci_priv *imxpriv; unsigned int reg_val; int ret; of_id = of_match_device(imx_ahci_of_match, dev); if (!of_id) return -EINVAL; imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL); if (!imxpriv) return -ENOMEM; imxpriv->ahci_pdev = pdev; imxpriv->no_device = false; imxpriv->first_time = true; imxpriv->type = (enum ahci_imx_type)of_id->data; imxpriv->sata_clk = devm_clk_get(dev, "sata"); if (IS_ERR(imxpriv->sata_clk)) { dev_err(dev, "can't get sata clock.\n"); return PTR_ERR(imxpriv->sata_clk); } imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref"); if (IS_ERR(imxpriv->sata_ref_clk)) { dev_err(dev, "can't get sata_ref clock.\n"); return PTR_ERR(imxpriv->sata_ref_clk); } imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); if (IS_ERR(imxpriv->ahb_clk)) { dev_err(dev, "can't get ahb clock.\n"); return PTR_ERR(imxpriv->ahb_clk); } if (imxpriv->type == AHCI_IMX6Q || imxpriv->type == AHCI_IMX6QP) { u32 reg_value; imxpriv->gpr = syscon_regmap_lookup_by_compatible( "fsl,imx6q-iomuxc-gpr"); if (IS_ERR(imxpriv->gpr)) { dev_err(dev, "failed to find fsl,imx6q-iomux-gpr regmap\n"); return PTR_ERR(imxpriv->gpr); } reg_value = imx_ahci_parse_props(dev, gpr13_props, ARRAY_SIZE(gpr13_props)); imxpriv->phy_params = IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | IMX6Q_GPR13_SATA_SPD_MODE_3P0G | reg_value; } else if (imxpriv->type == AHCI_IMX8QM) { ret = imx8_sata_probe(dev, imxpriv); if (ret) return ret; } hpriv = ahci_platform_get_resources(pdev, 0); if (IS_ERR(hpriv)) return PTR_ERR(hpriv); hpriv->plat_data = imxpriv; ret = clk_prepare_enable(imxpriv->sata_clk); if (ret) return ret; if (imxpriv->type == AHCI_IMX53 && IS_ENABLED(CONFIG_HWMON)) { /* Add the temperature monitor */ struct device *hwmon_dev; hwmon_dev = devm_hwmon_device_register_with_groups(dev, "sata_ahci", hpriv, fsl_sata_ahci_groups); if (IS_ERR(hwmon_dev)) { ret = PTR_ERR(hwmon_dev); goto disable_clk; } devm_thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev, &fsl_sata_ahci_of_thermal_ops); dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev)); } ret = imx_sata_enable(hpriv); if (ret) goto disable_clk; /* * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, * and IP vendor specific register IMX_TIMER1MS. * Configure CAP_SSS (support stagered spin up). * Implement the port0. * Get the ahb clock rate, and configure the TIMER1MS register. */ reg_val = readl(hpriv->mmio + HOST_CAP); if (!(reg_val & HOST_CAP_SSS)) { reg_val |= HOST_CAP_SSS; writel(reg_val, hpriv->mmio + HOST_CAP); } reg_val = readl(hpriv->mmio + HOST_PORTS_IMPL); if (!(reg_val & 0x1)) { reg_val |= 0x1; writel(reg_val, hpriv->mmio + HOST_PORTS_IMPL); } reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; writel(reg_val, hpriv->mmio + IMX_TIMER1MS); ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, &ahci_platform_sht); if (ret) goto disable_sata; return 0; disable_sata: imx_sata_disable(hpriv); disable_clk: clk_disable_unprepare(imxpriv->sata_clk); return ret; } static void ahci_imx_host_stop(struct ata_host *host) { struct ahci_host_priv *hpriv = host->private_data; struct imx_ahci_priv *imxpriv = hpriv->plat_data; imx_sata_disable(hpriv); clk_disable_unprepare(imxpriv->sata_clk); } #ifdef CONFIG_PM_SLEEP static int imx_ahci_suspend(struct device *dev) { struct ata_host *host = dev_get_drvdata(dev); struct ahci_host_priv *hpriv = host->private_data; int ret; ret = ahci_platform_suspend_host(dev); if (ret) return ret; imx_sata_disable(hpriv); return 0; } static int imx_ahci_resume(struct device *dev) { struct ata_host *host = dev_get_drvdata(dev); struct ahci_host_priv *hpriv = host->private_data; int ret; ret = imx_sata_enable(hpriv); if (ret) return ret; return ahci_platform_resume_host(dev); } #endif static SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume); static struct platform_driver imx_ahci_driver = { .probe = imx_ahci_probe, .remove = ata_platform_remove_one, .driver = { .name = DRV_NAME, .of_match_table = imx_ahci_of_match, .pm = &ahci_imx_pm_ops, }, }; module_platform_driver(imx_ahci_driver); MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver"); MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@freescale.com>"); MODULE_LICENSE("GPL"); MODULE_ALIAS("ahci:imx");
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Writes logs to the console output depending on its verbosity setting. * * It is disabled by default and gets activated as soon as a command is executed. * Instead of listening to the console events, the output can also be set manually. * * The minimum logging level at which this handler will be triggered depends on the * verbosity setting of the console output. The default mapping is: * - OutputInterface::VERBOSITY_NORMAL will show all WARNING and higher logs * - OutputInterface::VERBOSITY_VERBOSE (-v) will show all NOTICE and higher logs * - OutputInterface::VERBOSITY_VERY_VERBOSE (-vv) will show all INFO and higher logs * - OutputInterface::VERBOSITY_DEBUG (-vvv) will show all DEBUG and higher logs, i.e. all logs * * This mapping can be customized with the $verbosityLevelMap constructor parameter. * * @author Tobias Schultze <http://tobion.de> */ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscriberInterface { /** * @var OutputInterface|null */ private $output; /** * @var array */ private $verbosityLevelMap = array( OutputInterface::VERBOSITY_NORMAL => Logger::WARNING, OutputInterface::VERBOSITY_VERBOSE => Logger::NOTICE, OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO, OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG ); /** * Constructor. * * @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null * until the output is set, e.g. by using console events) * @param bool $bubble Whether the messages that are handled can bubble up the stack * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = array()) { parent::__construct(Logger::DEBUG, $bubble); $this->output = $output; if ($verbosityLevelMap) { $this->verbosityLevelMap = $verbosityLevelMap; } } /** * {@inheritdoc} */ public function isHandling(array $record) { return $this->updateLevel() && parent::isHandling($record); } /** * {@inheritdoc} */ public function handle(array $record) { // we have to update the logging level each time because the verbosity of the // console output might have changed in the meantime (it is not immutable) return $this->updateLevel() && parent::handle($record); } /** * Sets the console output to use for printing logs. * * @param OutputInterface $output The console output to use */ public function setOutput(OutputInterface $output) { $this->output = $output; } /** * Disables the output. */ public function close() { $this->output = null; parent::close(); } /** * Before a command is executed, the handler gets activated and the console output * is set in order to know where to write the logs. * * @param ConsoleCommandEvent $event */ public function onCommand(ConsoleCommandEvent $event) { $this->setOutput($event->getOutput()); } /** * After a command has been executed, it disables the output. * * @param ConsoleTerminateEvent $event */ public function onTerminate(ConsoleTerminateEvent $event) { $this->close(); } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array( ConsoleEvents::COMMAND => 'onCommand', ConsoleEvents::TERMINATE => 'onTerminate' ); } /** * {@inheritdoc} */ protected function write(array $record) { if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) { $this->output->getErrorOutput()->write((string) $record['formatted']); } else { $this->output->write((string) $record['formatted']); } } /** * {@inheritdoc} */ protected function getDefaultFormatter() { return new ConsoleFormatter(); } /** * Updates the logging level based on the verbosity setting of the console output. * * @return bool Whether the handler is enabled and verbosity is not set to quiet. */ private function updateLevel() { if (null === $this->output || OutputInterface::VERBOSITY_QUIET === $verbosity = $this->output->getVerbosity()) { return false; } if (isset($this->verbosityLevelMap[$verbosity])) { $this->setLevel($this->verbosityLevelMap[$verbosity]); } else { $this->setLevel(Logger::DEBUG); } return true; } }
/* * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel * * Copyright (C) 1999-2012, Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you * under the terms of the GNU General Public License version 2 (the "GPL"), * available at http://www.broadcom.com/licenses/GPLv2.php, with the * following added to such license: * * As a special exception, the copyright holders of this software give you * permission to link this software with independent modules, and to copy and * distribute the resulting executable under terms of your choice, provided that * you also meet, for each linked independent module, the terms and conditions of * the license of that module. An independent module is a module which is not * derived from this software. The special exception does not apply to any * modifications of the software. * * Notwithstanding the above, under no circumstances may you combine this * software in any way with any other Broadcom software provided under a license * other than the GPL, without Broadcom's express prior written consent. * * $Id: bcmsdh_sdmmc.h 366811 2012-11-05 13:49:17Z $ */ #ifndef __BCMSDH_SDMMC_H__ #define __BCMSDH_SDMMC_H__ #define sd_err(x) #define sd_trace(x) #define sd_info(x) #define sd_debug(x) #define sd_data(x) #define sd_ctrl(x) #ifdef CUSTOMER_HW4 #undef sd_err #define sd_err(x) do {printf x;} while (0) #define sd_trace_hw4 sd_err #else #define sd_trace_hw4 sd_trace #endif #define sd_sync_dma(sd, read, nbytes) #define sd_init_dma(sd) #define sd_ack_intr(sd) #define sd_wakeup(sd); /* Allocate/init/free per-OS private data */ extern int sdioh_sdmmc_osinit(sdioh_info_t *sd); extern void sdioh_sdmmc_osfree(sdioh_info_t *sd); #define sd_log(x) #define SDIOH_ASSERT(exp) \ do { if (!(exp)) \ printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \ } while (0) #define BLOCK_SIZE_4318 64 #define BLOCK_SIZE_4328 512 /* internal return code */ #define SUCCESS 0 #define ERROR 1 /* private bus modes */ #define SDIOH_MODE_SD4 2 #define CLIENT_INTR 0x100 /* Get rid of this! */ struct sdioh_info { osl_t *osh; /* osh handler */ bool client_intr_enabled; /* interrupt connnected flag */ bool intr_handler_valid; /* client driver interrupt handler valid */ sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ void *intr_handler_arg; /* argument to call interrupt handler */ uint16 intmask; /* Current active interrupts */ void *sdos_info; /* Pointer to per-OS private data */ uint irq; /* Client irq */ int intrcount; /* Client interrupts */ bool sd_use_dma; /* DMA on CMD53 */ bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */ /* Must be on for sd_multiblock to be effective */ bool use_client_ints; /* If this is false, make sure to restore */ int sd_mode; /* SD1/SD4/SPI */ int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ uint8 num_funcs; /* Supported funcs on client */ uint32 com_cis_ptr; uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; #define SDIOH_SDMMC_MAX_SG_ENTRIES 32 struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES]; bool use_rxchain; }; /************************************************************ * Internal interfaces: per-port references into bcmsdh_sdmmc.c */ /* Global message bits */ extern uint sd_msglevel; /* OS-independent interrupt handler */ extern bool check_client_intr(sdioh_info_t *sd); /* Core interrupt enable/disable of device interrupts */ extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); /************************************************************** * Internal interfaces: bcmsdh_sdmmc.c references to per-port code */ /* Register mapping routines */ extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size); extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size); /* Interrupt (de)registration routines */ extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); typedef struct _BCMSDH_SDMMC_INSTANCE { sdioh_info_t *sd; struct sdio_func *func[SDIOD_MAX_IOFUNCS]; } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE; #endif /* __BCMSDH_SDMMC_H__ */
class Ssdb < Formula desc "NoSQL database supporting many data structures: Redis alternative" homepage "http://ssdb.io/" url "https://github.com/ideawu/ssdb/archive/1.8.2.tar.gz" sha256 "2fe10689a0e1e9e9ca67acbe9e0fa3607810dca90dcc9f0813b2661cc6d4e826" head "https://github.com/ideawu/ssdb.git" bottle do cellar :any sha256 "1970e505fd1e8f6166010a892e66a718a39cbab1bcdd515bd6fdd4ec7c185600" => :yosemite sha256 "61430871ab15a312f8a6b0caf68003d379fc8e52199702747b84f86f3887d911" => :mavericks sha256 "16b3c20d79519328e01139ccf8fc71832f90d5df1c55c9ba32ab150a0cddf77e" => :mountain_lion end def install inreplace "Makefile", "PREFIX=/usr/local/ssdb", "PREFIX=#{prefix}" system "make", "prefix=#{prefix} CC=#{ENV.cc} CXX=#{ENV.cxx}" system "make", "install" ["bench", "dump", "ins.sh", "repair", "server"].each do |suffix| bin.install "#{prefix}/ssdb-#{suffix}" end ["run", "db/ssdb", "log"].each do |dir| (var+dir).mkpath end inreplace "ssdb.conf" do |s| s.gsub! "work_dir = ./var", "work_dir = #{var}/db/ssdb/" s.gsub! "pidfile = ./var/ssdb.pid", "pidfile = #{var}/run/ssdb.pid" s.gsub! "\toutput: log.txt", "\toutput: #{var}/log/ssdb.log" end inreplace "ssdb_slave.conf" do |s| s.gsub! "work_dir = ./var_slave", "work_dir = #{var}/db/ssdb/" s.gsub! "pidfile = ./var_slave/ssdb.pid", "pidfile = #{var}/run/ssdb_slave.pid" s.gsub! "\toutput: log_slave.txt", "\toutput: #{var}/log/ssdb_slave.log" end etc.install "ssdb.conf" etc.install "ssdb_slave.conf" end plist_options :manual => "ssdb-server #{HOMEBREW_PREFIX}/etc/ssdb.conf" def plist; <<-EOS.undent <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> <key>Label</key> <string>#{plist_name}</string> <key>ProgramArguments</key> <array> <string>#{opt_bin}/ssdb-server</string> <string>#{etc}/ssdb.conf</string> </array> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>#{var}</string> <key>StandardErrorPath</key> <string>#{var}/log/ssdb.log</string> <key>StandardOutPath</key> <string>#{var}/log/ssdb.log</string> </dict> </plist> EOS end test do pid = fork do Signal.trap("TERM") do system("#{bin}/ssdb-server -d #{HOMEBREW_PREFIX}/etc/ssdb.conf") exit end end sleep(3) Process.kill("TERM", pid) end end
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build plan9,!race package plan9 import ( "unsafe" ) const raceenabled = false func raceAcquire(addr unsafe.Pointer) { } func raceReleaseMerge(addr unsafe.Pointer) { } func raceReadRange(addr unsafe.Pointer, len int) { } func raceWriteRange(addr unsafe.Pointer, len int) { }
class Token(object): def __init__(self, start_mark, end_mark): self.start_mark = start_mark self.end_mark = end_mark def __repr__(self): attributes = [key for key in self.__dict__ if not key.endswith('_mark')] attributes.sort() arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) for key in attributes]) return '%s(%s)' % (self.__class__.__name__, arguments) #class BOMToken(Token): # id = '<byte order mark>' class DirectiveToken(Token): id = '<directive>' def __init__(self, name, value, start_mark, end_mark): self.name = name self.value = value self.start_mark = start_mark self.end_mark = end_mark class DocumentStartToken(Token): id = '<document start>' class DocumentEndToken(Token): id = '<document end>' class StreamStartToken(Token): id = '<stream start>' def __init__(self, start_mark=None, end_mark=None, encoding=None): self.start_mark = start_mark self.end_mark = end_mark self.encoding = encoding class StreamEndToken(Token): id = '<stream end>' class BlockSequenceStartToken(Token): id = '<block sequence start>' class BlockMappingStartToken(Token): id = '<block mapping start>' class BlockEndToken(Token): id = '<block end>' class FlowSequenceStartToken(Token): id = '[' class FlowMappingStartToken(Token): id = '{' class FlowSequenceEndToken(Token): id = ']' class FlowMappingEndToken(Token): id = '}' class KeyToken(Token): id = '?' class ValueToken(Token): id = ':' class BlockEntryToken(Token): id = '-' class FlowEntryToken(Token): id = ',' class AliasToken(Token): id = '<alias>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class AnchorToken(Token): id = '<anchor>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class TagToken(Token): id = '<tag>' def __init__(self, value, start_mark, end_mark): self.value = value self.start_mark = start_mark self.end_mark = end_mark class ScalarToken(Token): id = '<scalar>' def __init__(self, value, plain, start_mark, end_mark, style=None): self.value = value self.plain = plain self.start_mark = start_mark self.end_mark = end_mark self.style = style
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 20010-2011 Hauke Heibel <hauke.heibel@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_SPLINE_H #define EIGEN_SPLINE_H #include "SplineFwd.h" namespace Eigen { /** * \ingroup Splines_Module * \class Spline * \brief A class representing multi-dimensional spline curves. * * The class represents B-splines with non-uniform knot vectors. Each control * point of the B-spline is associated with a basis function * \f{align*} * C(u) & = \sum_{i=0}^{n}N_{i,p}(u)P_i * \f} * * \tparam _Scalar The underlying data type (typically float or double) * \tparam _Dim The curve dimension (e.g. 2 or 3) * \tparam _Degree Per default set to Dynamic; could be set to the actual desired * degree for optimization purposes (would result in stack allocation * of several temporary variables). **/ template <typename _Scalar, int _Dim, int _Degree> class Spline { public: typedef _Scalar Scalar; /*!< The spline curve's scalar type. */ enum { Dimension = _Dim /*!< The spline curve's dimension. */ }; enum { Degree = _Degree /*!< The spline curve's degree. */ }; /** \brief The point type the spline is representing. */ typedef typename SplineTraits<Spline>::PointType PointType; /** \brief The data type used to store knot vectors. */ typedef typename SplineTraits<Spline>::KnotVectorType KnotVectorType; /** \brief The data type used to store non-zero basis functions. */ typedef typename SplineTraits<Spline>::BasisVectorType BasisVectorType; /** \brief The data type representing the spline's control points. */ typedef typename SplineTraits<Spline>::ControlPointVectorType ControlPointVectorType; /** * \brief Creates a (constant) zero spline. * For Splines with dynamic degree, the resulting degree will be 0. **/ Spline() : m_knots(1, (Degree==Dynamic ? 2 : 2*Degree+2)) , m_ctrls(ControlPointVectorType::Zero(2,(Degree==Dynamic ? 1 : Degree+1))) { // in theory this code can go to the initializer list but it will get pretty // much unreadable ... enum { MinDegree = (Degree==Dynamic ? 0 : Degree) }; m_knots.template segment<MinDegree+1>(0) = Array<Scalar,1,MinDegree+1>::Zero(); m_knots.template segment<MinDegree+1>(MinDegree+1) = Array<Scalar,1,MinDegree+1>::Ones(); } /** * \brief Creates a spline from a knot vector and control points. * \param knots The spline's knot vector. * \param ctrls The spline's control point vector. **/ template <typename OtherVectorType, typename OtherArrayType> Spline(const OtherVectorType& knots, const OtherArrayType& ctrls) : m_knots(knots), m_ctrls(ctrls) {} /** * \brief Copy constructor for splines. * \param spline The input spline. **/ template <int OtherDegree> Spline(const Spline<Scalar, Dimension, OtherDegree>& spline) : m_knots(spline.knots()), m_ctrls(spline.ctrls()) {} /** * \brief Returns the knots of the underlying spline. **/ const KnotVectorType& knots() const { return m_knots; } /** * \brief Returns the knots of the underlying spline. **/ const ControlPointVectorType& ctrls() const { return m_ctrls; } /** * \brief Returns the spline value at a given site \f$u\f$. * * The function returns * \f{align*} * C(u) & = \sum_{i=0}^{n}N_{i,p}P_i * \f} * * \param u Parameter \f$u \in [0;1]\f$ at which the spline is evaluated. * \return The spline value at the given location \f$u\f$. **/ PointType operator()(Scalar u) const; /** * \brief Evaluation of spline derivatives of up-to given order. * * The function returns * \f{align*} * \frac{d^i}{du^i}C(u) & = \sum_{i=0}^{n} \frac{d^i}{du^i} N_{i,p}(u)P_i * \f} * for i ranging between 0 and order. * * \param u Parameter \f$u \in [0;1]\f$ at which the spline derivative is evaluated. * \param order The order up to which the derivatives are computed. **/ typename SplineTraits<Spline>::DerivativeType derivatives(Scalar u, DenseIndex order) const; /** * \copydoc Spline::derivatives * Using the template version of this function is more efficieent since * temporary objects are allocated on the stack whenever this is possible. **/ template <int DerivativeOrder> typename SplineTraits<Spline,DerivativeOrder>::DerivativeType derivatives(Scalar u, DenseIndex order = DerivativeOrder) const; /** * \brief Computes the non-zero basis functions at the given site. * * Splines have local support and a point from their image is defined * by exactly \f$p+1\f$ control points \f$P_i\f$ where \f$p\f$ is the * spline degree. * * This function computes the \f$p+1\f$ non-zero basis function values * for a given parameter value \f$u\f$. It returns * \f{align*}{ * N_{i,p}(u), \hdots, N_{i+p+1,p}(u) * \f} * * \param u Parameter \f$u \in [0;1]\f$ at which the non-zero basis functions * are computed. **/ typename SplineTraits<Spline>::BasisVectorType basisFunctions(Scalar u) const; /** * \brief Computes the non-zero spline basis function derivatives up to given order. * * The function computes * \f{align*}{ * \frac{d^i}{du^i} N_{i,p}(u), \hdots, \frac{d^i}{du^i} N_{i+p+1,p}(u) * \f} * with i ranging from 0 up to the specified order. * * \param u Parameter \f$u \in [0;1]\f$ at which the non-zero basis function * derivatives are computed. * \param order The order up to which the basis function derivatives are computes. **/ typename SplineTraits<Spline>::BasisDerivativeType basisFunctionDerivatives(Scalar u, DenseIndex order) const; /** * \copydoc Spline::basisFunctionDerivatives * Using the template version of this function is more efficieent since * temporary objects are allocated on the stack whenever this is possible. **/ template <int DerivativeOrder> typename SplineTraits<Spline,DerivativeOrder>::BasisDerivativeType basisFunctionDerivatives(Scalar u, DenseIndex order = DerivativeOrder) const; /** * \brief Returns the spline degree. **/ DenseIndex degree() const; /** * \brief Returns the span within the knot vector in which u is falling. * \param u The site for which the span is determined. **/ DenseIndex span(Scalar u) const; /** * \brief Computes the spang within the provided knot vector in which u is falling. **/ static DenseIndex Span(typename SplineTraits<Spline>::Scalar u, DenseIndex degree, const typename SplineTraits<Spline>::KnotVectorType& knots); /** * \brief Returns the spline's non-zero basis functions. * * The function computes and returns * \f{align*}{ * N_{i,p}(u), \hdots, N_{i+p+1,p}(u) * \f} * * \param u The site at which the basis functions are computed. * \param degree The degree of the underlying spline. * \param knots The underlying spline's knot vector. **/ static BasisVectorType BasisFunctions(Scalar u, DenseIndex degree, const KnotVectorType& knots); private: KnotVectorType m_knots; /*!< Knot vector. */ ControlPointVectorType m_ctrls; /*!< Control points. */ }; template <typename _Scalar, int _Dim, int _Degree> DenseIndex Spline<_Scalar, _Dim, _Degree>::Span( typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::Scalar u, DenseIndex degree, const typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::KnotVectorType& knots) { // Piegl & Tiller, "The NURBS Book", A2.1 (p. 68) if (u <= knots(0)) return degree; const Scalar* pos = std::upper_bound(knots.data()+degree-1, knots.data()+knots.size()-degree-1, u); return static_cast<DenseIndex>( std::distance(knots.data(), pos) - 1 ); } template <typename _Scalar, int _Dim, int _Degree> typename Spline<_Scalar, _Dim, _Degree>::BasisVectorType Spline<_Scalar, _Dim, _Degree>::BasisFunctions( typename Spline<_Scalar, _Dim, _Degree>::Scalar u, DenseIndex degree, const typename Spline<_Scalar, _Dim, _Degree>::KnotVectorType& knots) { typedef typename Spline<_Scalar, _Dim, _Degree>::BasisVectorType BasisVectorType; const DenseIndex p = degree; const DenseIndex i = Spline::Span(u, degree, knots); const KnotVectorType& U = knots; BasisVectorType left(p+1); left(0) = Scalar(0); BasisVectorType right(p+1); right(0) = Scalar(0); VectorBlock<BasisVectorType,Degree>(left,1,p) = u - VectorBlock<const KnotVectorType,Degree>(U,i+1-p,p).reverse(); VectorBlock<BasisVectorType,Degree>(right,1,p) = VectorBlock<const KnotVectorType,Degree>(U,i+1,p) - u; BasisVectorType N(1,p+1); N(0) = Scalar(1); for (DenseIndex j=1; j<=p; ++j) { Scalar saved = Scalar(0); for (DenseIndex r=0; r<j; r++) { const Scalar tmp = N(r)/(right(r+1)+left(j-r)); N[r] = saved + right(r+1)*tmp; saved = left(j-r)*tmp; } N(j) = saved; } return N; } template <typename _Scalar, int _Dim, int _Degree> DenseIndex Spline<_Scalar, _Dim, _Degree>::degree() const { if (_Degree == Dynamic) return m_knots.size() - m_ctrls.cols() - 1; else return _Degree; } template <typename _Scalar, int _Dim, int _Degree> DenseIndex Spline<_Scalar, _Dim, _Degree>::span(Scalar u) const { return Spline::Span(u, degree(), knots()); } template <typename _Scalar, int _Dim, int _Degree> typename Spline<_Scalar, _Dim, _Degree>::PointType Spline<_Scalar, _Dim, _Degree>::operator()(Scalar u) const { enum { Order = SplineTraits<Spline>::OrderAtCompileTime }; const DenseIndex span = this->span(u); const DenseIndex p = degree(); const BasisVectorType basis_funcs = basisFunctions(u); const Replicate<BasisVectorType,Dimension,1> ctrl_weights(basis_funcs); const Block<const ControlPointVectorType,Dimension,Order> ctrl_pts(ctrls(),0,span-p,Dimension,p+1); return (ctrl_weights * ctrl_pts).rowwise().sum(); } /* --------------------------------------------------------------------------------------------- */ template <typename SplineType, typename DerivativeType> void derivativesImpl(const SplineType& spline, typename SplineType::Scalar u, DenseIndex order, DerivativeType& der) { enum { Dimension = SplineTraits<SplineType>::Dimension }; enum { Order = SplineTraits<SplineType>::OrderAtCompileTime }; enum { DerivativeOrder = DerivativeType::ColsAtCompileTime }; typedef typename SplineTraits<SplineType>::ControlPointVectorType ControlPointVectorType; typedef typename SplineTraits<SplineType,DerivativeOrder>::BasisDerivativeType BasisDerivativeType; typedef typename BasisDerivativeType::ConstRowXpr BasisDerivativeRowXpr; const DenseIndex p = spline.degree(); const DenseIndex span = spline.span(u); const DenseIndex n = (std::min)(p, order); der.resize(Dimension,n+1); // Retrieve the basis function derivatives up to the desired order... const BasisDerivativeType basis_func_ders = spline.template basisFunctionDerivatives<DerivativeOrder>(u, n+1); // ... and perform the linear combinations of the control points. for (DenseIndex der_order=0; der_order<n+1; ++der_order) { const Replicate<BasisDerivativeRowXpr,Dimension,1> ctrl_weights( basis_func_ders.row(der_order) ); const Block<const ControlPointVectorType,Dimension,Order> ctrl_pts(spline.ctrls(),0,span-p,Dimension,p+1); der.col(der_order) = (ctrl_weights * ctrl_pts).rowwise().sum(); } } template <typename _Scalar, int _Dim, int _Degree> typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::DerivativeType Spline<_Scalar, _Dim, _Degree>::derivatives(Scalar u, DenseIndex order) const { typename SplineTraits< Spline >::DerivativeType res; derivativesImpl(*this, u, order, res); return res; } template <typename _Scalar, int _Dim, int _Degree> template <int DerivativeOrder> typename SplineTraits< Spline<_Scalar, _Dim, _Degree>, DerivativeOrder >::DerivativeType Spline<_Scalar, _Dim, _Degree>::derivatives(Scalar u, DenseIndex order) const { typename SplineTraits< Spline, DerivativeOrder >::DerivativeType res; derivativesImpl(*this, u, order, res); return res; } template <typename _Scalar, int _Dim, int _Degree> typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::BasisVectorType Spline<_Scalar, _Dim, _Degree>::basisFunctions(Scalar u) const { return Spline::BasisFunctions(u, degree(), knots()); } /* --------------------------------------------------------------------------------------------- */ template <typename SplineType, typename DerivativeType> void basisFunctionDerivativesImpl(const SplineType& spline, typename SplineType::Scalar u, DenseIndex order, DerivativeType& N_) { enum { Order = SplineTraits<SplineType>::OrderAtCompileTime }; typedef typename SplineTraits<SplineType>::Scalar Scalar; typedef typename SplineTraits<SplineType>::BasisVectorType BasisVectorType; typedef typename SplineTraits<SplineType>::KnotVectorType KnotVectorType; const KnotVectorType& U = spline.knots(); const DenseIndex p = spline.degree(); const DenseIndex span = spline.span(u); const DenseIndex n = (std::min)(p, order); N_.resize(n+1, p+1); BasisVectorType left = BasisVectorType::Zero(p+1); BasisVectorType right = BasisVectorType::Zero(p+1); Matrix<Scalar,Order,Order> ndu(p+1,p+1); double saved, temp; ndu(0,0) = 1.0; DenseIndex j; for (j=1; j<=p; ++j) { left[j] = u-U[span+1-j]; right[j] = U[span+j]-u; saved = 0.0; for (DenseIndex r=0; r<j; ++r) { /* Lower triangle */ ndu(j,r) = right[r+1]+left[j-r]; temp = ndu(r,j-1)/ndu(j,r); /* Upper triangle */ ndu(r,j) = static_cast<Scalar>(saved+right[r+1] * temp); saved = left[j-r] * temp; } ndu(j,j) = static_cast<Scalar>(saved); } for (j = p; j>=0; --j) N_(0,j) = ndu(j,p); // Compute the derivatives DerivativeType a(n+1,p+1); DenseIndex r=0; for (; r<=p; ++r) { DenseIndex s1,s2; s1 = 0; s2 = 1; // alternate rows in array a a(0,0) = 1.0; // Compute the k-th derivative for (DenseIndex k=1; k<=static_cast<DenseIndex>(n); ++k) { double d = 0.0; DenseIndex rk,pk,j1,j2; rk = r-k; pk = p-k; if (r>=k) { a(s2,0) = a(s1,0)/ndu(pk+1,rk); d = a(s2,0)*ndu(rk,pk); } if (rk>=-1) j1 = 1; else j1 = -rk; if (r-1 <= pk) j2 = k-1; else j2 = p-r; for (j=j1; j<=j2; ++j) { a(s2,j) = (a(s1,j)-a(s1,j-1))/ndu(pk+1,rk+j); d += a(s2,j)*ndu(rk+j,pk); } if (r<=pk) { a(s2,k) = -a(s1,k-1)/ndu(pk+1,r); d += a(s2,k)*ndu(r,pk); } N_(k,r) = static_cast<Scalar>(d); j = s1; s1 = s2; s2 = j; // Switch rows } } /* Multiply through by the correct factors */ /* (Eq. [2.9]) */ r = p; for (DenseIndex k=1; k<=static_cast<DenseIndex>(n); ++k) { for (DenseIndex j=p; j>=0; --j) N_(k,j) *= r; r *= p-k; } } template <typename _Scalar, int _Dim, int _Degree> typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::BasisDerivativeType Spline<_Scalar, _Dim, _Degree>::basisFunctionDerivatives(Scalar u, DenseIndex order) const { typename SplineTraits< Spline >::BasisDerivativeType der; basisFunctionDerivativesImpl(*this, u, order, der); return der; } template <typename _Scalar, int _Dim, int _Degree> template <int DerivativeOrder> typename SplineTraits< Spline<_Scalar, _Dim, _Degree>, DerivativeOrder >::BasisDerivativeType Spline<_Scalar, _Dim, _Degree>::basisFunctionDerivatives(Scalar u, DenseIndex order) const { typename SplineTraits< Spline, DerivativeOrder >::BasisDerivativeType der; basisFunctionDerivativesImpl(*this, u, order, der); return der; } } #endif // EIGEN_SPLINE_H
UPDATE `creature_template` SET `mindmg`=700, `maxdmg`=1200, `attackpower`=1000, `flags_extra`=196641 WHERE `entry`=23418;
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _postcss = require('postcss'); var _clone = require('../clone'); var _clone2 = _interopRequireDefault(_clone); var _hasAllProps = require('../hasAllProps'); var _hasAllProps2 = _interopRequireDefault(_hasAllProps); var _getLastNode = require('../getLastNode'); var _getLastNode2 = _interopRequireDefault(_getLastNode); var _canMerge = require('../canMerge'); var _canMerge2 = _interopRequireDefault(_canMerge); exports['default'] = function (direction) { var wsc = ['width', 'style', 'color'].map(function (d) { return 'border-' + direction + '-' + d; }); var defaults = ['medium', 'none', 'currentColor']; var declaration = 'border-' + direction; var processor = { explode: function explode(rule) { rule.walkDecls(declaration, function (decl) { var values = _postcss.list.space(decl.value); wsc.forEach(function (prop, index) { var node = (0, _clone2['default'])(decl); node.prop = prop; node.value = values[index]; if (node.value === undefined) { node.value = defaults[index]; } rule.insertAfter(decl, node); }); decl.remove(); }); }, merge: function merge(rule) { var decls = rule.nodes.filter(function (node) { return node.prop && ~wsc.indexOf(node.prop); }); var _loop = function () { var lastNode = decls[decls.length - 1]; var props = decls.filter(function (node) { return node.important === lastNode.important; }); if (_hasAllProps2['default'].apply(undefined, [props].concat(wsc)) && _canMerge2['default'].apply(undefined, props)) { var values = wsc.map(function (prop) { return (0, _getLastNode2['default'])(props, prop).value; }); var value = values.concat(['']).reduceRight(function (prev, cur, i) { if (prev === '' && cur === defaults[i]) { return prev; } return cur + " " + prev; }).trim(); if (value === '') { value = defaults[0]; } var shorthand = (0, _clone2['default'])(lastNode); shorthand.prop = declaration; shorthand.value = value; rule.insertAfter(lastNode, shorthand); props.forEach(function (prop) { return prop.remove(); }); } decls = decls.filter(function (node) { return ! ~props.indexOf(node); }); }; while (decls.length) { _loop(); } } }; return processor; }; module.exports = exports['default'];
/** * @license AngularJS v1.3.10 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular, undefined) {'use strict'; var $sanitizeMinErr = angular.$$minErr('$sanitize'); /** * @ngdoc module * @name ngSanitize * @description * * # ngSanitize * * The `ngSanitize` module provides functionality to sanitize HTML. * * * <div doc-module-components="ngSanitize"></div> * * See {@link ngSanitize.$sanitize `$sanitize`} for usage. */ /* * HTML Parser By Misko Hevery (misko@hevery.com) * based on: HTML Parser By John Resig (ejohn.org) * Original code by Erik Arvidsson, Mozilla Public License * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js * * // Use like so: * htmlParser(htmlString, { * start: function(tag, attrs, unary) {}, * end: function(tag) {}, * chars: function(text) {}, * comment: function(text) {} * }); * */ /** * @ngdoc service * @name $sanitize * @kind function * * @description * The input is sanitized by parsing the HTML into tokens. All safe tokens (from a whitelist) are * then serialized back to properly escaped html string. This means that no unsafe input can make * it into the returned string, however, since our parser is more strict than a typical browser * parser, it's possible that some obscure input, which would be recognized as valid HTML by a * browser, won't make it through the sanitizer. The input may also contain SVG markup. * The whitelist is configured using the functions `aHrefSanitizationWhitelist` and * `imgSrcSanitizationWhitelist` of {@link ng.$compileProvider `$compileProvider`}. * * @param {string} html HTML input. * @returns {string} Sanitized HTML. * * @example <example module="sanitizeExample" deps="angular-sanitize.js"> <file name="index.html"> <script> angular.module('sanitizeExample', ['ngSanitize']) .controller('ExampleController', ['$scope', '$sce', function($scope, $sce) { $scope.snippet = '<p style="color:blue">an html\n' + '<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' + 'snippet</p>'; $scope.deliberatelyTrustDangerousSnippet = function() { return $sce.trustAsHtml($scope.snippet); }; }]); </script> <div ng-controller="ExampleController"> Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea> <table> <tr> <td>Directive</td> <td>How</td> <td>Source</td> <td>Rendered</td> </tr> <tr id="bind-html-with-sanitize"> <td>ng-bind-html</td> <td>Automatically uses $sanitize</td> <td><pre>&lt;div ng-bind-html="snippet"&gt;<br/>&lt;/div&gt;</pre></td> <td><div ng-bind-html="snippet"></div></td> </tr> <tr id="bind-html-with-trust"> <td>ng-bind-html</td> <td>Bypass $sanitize by explicitly trusting the dangerous value</td> <td> <pre>&lt;div ng-bind-html="deliberatelyTrustDangerousSnippet()"&gt; &lt;/div&gt;</pre> </td> <td><div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div></td> </tr> <tr id="bind-default"> <td>ng-bind</td> <td>Automatically escapes</td> <td><pre>&lt;div ng-bind="snippet"&gt;<br/>&lt;/div&gt;</pre></td> <td><div ng-bind="snippet"></div></td> </tr> </table> </div> </file> <file name="protractor.js" type="protractor"> it('should sanitize the html snippet by default', function() { expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). toBe('<p>an html\n<em>click here</em>\nsnippet</p>'); }); it('should inline raw snippet if bound to a trusted value', function() { expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()). toBe("<p style=\"color:blue\">an html\n" + "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" + "snippet</p>"); }); it('should escape snippet without any filter', function() { expect(element(by.css('#bind-default div')).getInnerHtml()). toBe("&lt;p style=\"color:blue\"&gt;an html\n" + "&lt;em onmouseover=\"this.textContent='PWN3D!'\"&gt;click here&lt;/em&gt;\n" + "snippet&lt;/p&gt;"); }); it('should update', function() { element(by.model('snippet')).clear(); element(by.model('snippet')).sendKeys('new <b onclick="alert(1)">text</b>'); expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). toBe('new <b>text</b>'); expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()).toBe( 'new <b onclick="alert(1)">text</b>'); expect(element(by.css('#bind-default div')).getInnerHtml()).toBe( "new &lt;b onclick=\"alert(1)\"&gt;text&lt;/b&gt;"); }); </file> </example> */ function $SanitizeProvider() { this.$get = ['$$sanitizeUri', function($$sanitizeUri) { return function(html) { var buf = []; htmlParser(html, htmlSanitizeWriter(buf, function(uri, isImage) { return !/^unsafe/.test($$sanitizeUri(uri, isImage)); })); return buf.join(''); }; }]; } function sanitizeText(chars) { var buf = []; var writer = htmlSanitizeWriter(buf, angular.noop); writer.chars(chars); return buf.join(''); } // Regular Expressions for parsing tags and attributes var START_TAG_REGEXP = /^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/, END_TAG_REGEXP = /^<\/\s*([\w:-]+)[^>]*>/, ATTR_REGEXP = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g, BEGIN_TAG_REGEXP = /^</, BEGING_END_TAGE_REGEXP = /^<\//, COMMENT_REGEXP = /<!--(.*?)-->/g, DOCTYPE_REGEXP = /<!DOCTYPE([^>]*?)>/i, CDATA_REGEXP = /<!\[CDATA\[(.*?)]]>/g, SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, // Match everything outside of normal chars and " (quote character) NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; // Good source of info about elements and attributes // http://dev.w3.org/html5/spec/Overview.html#semantics // http://simon.html5.org/html-elements // Safe Void Elements - HTML5 // http://dev.w3.org/html5/spec/Overview.html#void-elements var voidElements = makeMap("area,br,col,hr,img,wbr"); // Elements that you can, intentionally, leave open (and which close themselves) // http://dev.w3.org/html5/spec/Overview.html#optional-tags var optionalEndTagBlockElements = makeMap("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"), optionalEndTagInlineElements = makeMap("rp,rt"), optionalEndTagElements = angular.extend({}, optionalEndTagInlineElements, optionalEndTagBlockElements); // Safe Block Elements - HTML5 var blockElements = angular.extend({}, optionalEndTagBlockElements, makeMap("address,article," + "aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5," + "h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")); // Inline Elements - HTML5 var inlineElements = angular.extend({}, optionalEndTagInlineElements, makeMap("a,abbr,acronym,b," + "bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s," + "samp,small,span,strike,strong,sub,sup,time,tt,u,var")); // SVG Elements // https://wiki.whatwg.org/wiki/Sanitization_rules#svg_Elements var svgElements = makeMap("animate,animateColor,animateMotion,animateTransform,circle,defs," + "desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient," + "line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,set," + "stop,svg,switch,text,title,tspan,use"); // Special Elements (can contain anything) var specialElements = makeMap("script,style"); var validElements = angular.extend({}, voidElements, blockElements, inlineElements, optionalEndTagElements, svgElements); //Attributes that have href and hence need to be sanitized var uriAttrs = makeMap("background,cite,href,longdesc,src,usemap,xlink:href"); var htmlAttrs = makeMap('abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,'+ 'color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,'+ 'id,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,'+ 'scope,scrolling,shape,size,span,start,summary,target,title,type,'+ 'valign,value,vspace,width'); // SVG attributes (without "id" and "name" attributes) // https://wiki.whatwg.org/wiki/Sanitization_rules#svg_Attributes var svgAttrs = makeMap('accent-height,accumulate,additive,alphabetic,arabic-form,ascent,' + 'attributeName,attributeType,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,' + 'color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,' + 'font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,' + 'gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,' + 'keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,' + 'markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,' + 'overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,' + 'repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,' + 'stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,' + 'stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,' + 'stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,' + 'underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,' + 'viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,' + 'xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,' + 'zoomAndPan'); var validAttrs = angular.extend({}, uriAttrs, svgAttrs, htmlAttrs); function makeMap(str) { var obj = {}, items = str.split(','), i; for (i = 0; i < items.length; i++) obj[items[i]] = true; return obj; } /** * @example * htmlParser(htmlString, { * start: function(tag, attrs, unary) {}, * end: function(tag) {}, * chars: function(text) {}, * comment: function(text) {} * }); * * @param {string} html string * @param {object} handler */ function htmlParser(html, handler) { if (typeof html !== 'string') { if (html === null || typeof html === 'undefined') { html = ''; } else { html = '' + html; } } var index, chars, match, stack = [], last = html, text; stack.last = function() { return stack[ stack.length - 1 ]; }; while (html) { text = ''; chars = true; // Make sure we're not in a script or style element if (!stack.last() || !specialElements[ stack.last() ]) { // Comment if (html.indexOf("<!--") === 0) { // comments containing -- are not allowed unless they terminate the comment index = html.indexOf("--", 4); if (index >= 0 && html.lastIndexOf("-->", index) === index) { if (handler.comment) handler.comment(html.substring(4, index)); html = html.substring(index + 3); chars = false; } // DOCTYPE } else if (DOCTYPE_REGEXP.test(html)) { match = html.match(DOCTYPE_REGEXP); if (match) { html = html.replace(match[0], ''); chars = false; } // end tag } else if (BEGING_END_TAGE_REGEXP.test(html)) { match = html.match(END_TAG_REGEXP); if (match) { html = html.substring(match[0].length); match[0].replace(END_TAG_REGEXP, parseEndTag); chars = false; } // start tag } else if (BEGIN_TAG_REGEXP.test(html)) { match = html.match(START_TAG_REGEXP); if (match) { // We only have a valid start-tag if there is a '>'. if (match[4]) { html = html.substring(match[0].length); match[0].replace(START_TAG_REGEXP, parseStartTag); } chars = false; } else { // no ending tag found --- this piece should be encoded as an entity. text += '<'; html = html.substring(1); } } if (chars) { index = html.indexOf("<"); text += index < 0 ? html : html.substring(0, index); html = index < 0 ? "" : html.substring(index); if (handler.chars) handler.chars(decodeEntities(text)); } } else { html = html.replace(new RegExp("(.*)<\\s*\\/\\s*" + stack.last() + "[^>]*>", 'i'), function(all, text) { text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1"); if (handler.chars) handler.chars(decodeEntities(text)); return ""; }); parseEndTag("", stack.last()); } if (html == last) { throw $sanitizeMinErr('badparse', "The sanitizer was unable to parse the following block " + "of html: {0}", html); } last = html; } // Clean up any remaining tags parseEndTag(); function parseStartTag(tag, tagName, rest, unary) { tagName = angular.lowercase(tagName); if (blockElements[ tagName ]) { while (stack.last() && inlineElements[ stack.last() ]) { parseEndTag("", stack.last()); } } if (optionalEndTagElements[ tagName ] && stack.last() == tagName) { parseEndTag("", tagName); } unary = voidElements[ tagName ] || !!unary; if (!unary) stack.push(tagName); var attrs = {}; rest.replace(ATTR_REGEXP, function(match, name, doubleQuotedValue, singleQuotedValue, unquotedValue) { var value = doubleQuotedValue || singleQuotedValue || unquotedValue || ''; attrs[name] = decodeEntities(value); }); if (handler.start) handler.start(tagName, attrs, unary); } function parseEndTag(tag, tagName) { var pos = 0, i; tagName = angular.lowercase(tagName); if (tagName) // Find the closest opened tag of the same type for (pos = stack.length - 1; pos >= 0; pos--) if (stack[ pos ] == tagName) break; if (pos >= 0) { // Close all the open elements, up the stack for (i = stack.length - 1; i >= pos; i--) if (handler.end) handler.end(stack[ i ]); // Remove the open elements from the stack stack.length = pos; } } } var hiddenPre=document.createElement("pre"); var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/; /** * decodes all entities into regular string * @param value * @returns {string} A string with decoded entities. */ function decodeEntities(value) { if (!value) { return ''; } // Note: IE8 does not preserve spaces at the start/end of innerHTML // so we must capture them and reattach them afterward var parts = spaceRe.exec(value); var spaceBefore = parts[1]; var spaceAfter = parts[3]; var content = parts[2]; if (content) { hiddenPre.innerHTML=content.replace(/</g,"&lt;"); // innerText depends on styling as it doesn't display hidden elements. // Therefore, it's better to use textContent not to cause unnecessary // reflows. However, IE<9 don't support textContent so the innerText // fallback is necessary. content = 'textContent' in hiddenPre ? hiddenPre.textContent : hiddenPre.innerText; } return spaceBefore + content + spaceAfter; } /** * Escapes all potentially dangerous characters, so that the * resulting string can be safely inserted into attribute or * element text. * @param value * @returns {string} escaped text */ function encodeEntities(value) { return value. replace(/&/g, '&amp;'). replace(SURROGATE_PAIR_REGEXP, function(value) { var hi = value.charCodeAt(0); var low = value.charCodeAt(1); return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';'; }). replace(NON_ALPHANUMERIC_REGEXP, function(value) { // unsafe chars are: \u0000-\u001f \u007f-\u009f \u00ad \u0600-\u0604 \u070f \u17b4 \u17b5 \u200c-\u200f \u2028-\u202f \u2060-\u206f \ufeff \ufff0-\uffff from jslint.com/lint.html // decimal values are: 0-31, 127-159, 173, 1536-1540, 1807, 6068, 6069, 8204-8207, 8232-8239, 8288-8303, 65279, 65520-65535 var c = value.charCodeAt(0); // if unsafe character encode if(c <= 159 || c == 173 || (c >= 1536 && c <= 1540) || c == 1807 || c == 6068 || c == 6069 || (c >= 8204 && c <= 8207) || (c >= 8232 && c <= 8239) || (c >= 8288 && c <= 8303) || c == 65279 || (c >= 65520 && c <= 65535)) return '&#' + c + ';'; return value; // avoids multilingual issues }). replace(/</g, '&lt;'). replace(/>/g, '&gt;'); } var trim = (function() { // native trim is way faster: http://jsperf.com/angular-trim-test // but IE doesn't have it... :-( // TODO: we should move this into IE/ES5 polyfill if (!String.prototype.trim) { return function(value) { return angular.isString(value) ? value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') : value; }; } return function(value) { return angular.isString(value) ? value.trim() : value; }; })(); // Custom logic for accepting certain style options only - textAngular // Currently allows only the color, background-color, text-align, float, width and height attributes // all other attributes should be easily done through classes. function validStyles(styleAttr){ var result = ''; var styleArray = styleAttr.split(';'); angular.forEach(styleArray, function(value){ var v = value.split(':'); if(v.length == 2){ var key = trim(angular.lowercase(v[0])); var value = trim(angular.lowercase(v[1])); if( (key === 'color' || key === 'background-color') && ( value.match(/^rgb\([0-9%,\. ]*\)$/i) || value.match(/^rgba\([0-9%,\. ]*\)$/i) || value.match(/^hsl\([0-9%,\. ]*\)$/i) || value.match(/^hsla\([0-9%,\. ]*\)$/i) || value.match(/^#[0-9a-f]{3,6}$/i) || value.match(/^[a-z]*$/i) ) || key === 'text-align' && ( value === 'left' || value === 'right' || value === 'center' || value === 'justify' ) || key === 'float' && ( value === 'left' || value === 'right' || value === 'none' ) || (key === 'width' || key === 'height') && ( value.match(/[0-9\.]*(px|em|rem|%)/) ) ) result += key + ': ' + value + ';'; } }); return result; } // this function is used to manually allow specific attributes on specific tags with certain prerequisites function validCustomTag(tag, attrs, lkey, value){ // catch the div placeholder for the iframe replacement if (tag === 'img' && attrs['ta-insert-video']){ if(lkey === 'ta-insert-video' || lkey === 'allowfullscreen' || lkey === 'frameborder' || (lkey === 'contenteditble' && value === 'false')) return true; } return false; } /** * create an HTML/XML writer which writes to buffer * @param {Array} buf use buf.jain('') to get out sanitized html string * @returns {object} in the form of { * start: function(tag, attrs, unary) {}, * end: function(tag) {}, * chars: function(text) {}, * comment: function(text) {} * } */ function htmlSanitizeWriter(buf, uriValidator) { var ignore = false; var out = angular.bind(buf, buf.push); return { start: function(tag, attrs, unary) { tag = angular.lowercase(tag); if (!ignore && specialElements[tag]) { ignore = tag; } if (!ignore && validElements[tag] === true) { out('<'); out(tag); angular.forEach(attrs, function(value, key) { var lkey=angular.lowercase(key); var isImage=(tag === 'img' && lkey === 'src') || (lkey === 'background'); if ((lkey === 'style' && (value = validStyles(value)) !== '') || validCustomTag(tag, attrs, lkey, value) || validAttrs[lkey] === true && (uriAttrs[lkey] !== true || uriValidator(value, isImage))) { out(' '); out(key); out('="'); out(encodeEntities(value)); out('"'); } }); out(unary ? '/>' : '>'); } }, end: function(tag) { tag = angular.lowercase(tag); if (!ignore && validElements[tag] === true) { out('</'); out(tag); out('>'); } if (tag == ignore) { ignore = false; } }, chars: function(chars) { if (!ignore) { out(encodeEntities(chars)); } } }; } // define ngSanitize module and register $sanitize service angular.module('ngSanitize', []).provider('$sanitize', $SanitizeProvider); /* global sanitizeText: false */ /** * @ngdoc filter * @name linky * @kind function * * @description * Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and * plain email address links. * * Requires the {@link ngSanitize `ngSanitize`} module to be installed. * * @param {string} text Input text. * @param {string} target Window (_blank|_self|_parent|_top) or named frame to open links in. * @returns {string} Html-linkified text. * * @usage <span ng-bind-html="linky_expression | linky"></span> * * @example <example module="linkyExample" deps="angular-sanitize.js"> <file name="index.html"> <script> angular.module('linkyExample', ['ngSanitize']) .controller('ExampleController', ['$scope', function($scope) { $scope.snippet = 'Pretty text with some links:\n'+ 'http://angularjs.org/,\n'+ 'mailto:us@somewhere.org,\n'+ 'another@somewhere.org,\n'+ 'and one more: ftp://127.0.0.1/.'; $scope.snippetWithTarget = 'http://angularjs.org/'; }]); </script> <div ng-controller="ExampleController"> Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea> <table> <tr> <td>Filter</td> <td>Source</td> <td>Rendered</td> </tr> <tr id="linky-filter"> <td>linky filter</td> <td> <pre>&lt;div ng-bind-html="snippet | linky"&gt;<br>&lt;/div&gt;</pre> </td> <td> <div ng-bind-html="snippet | linky"></div> </td> </tr> <tr id="linky-target"> <td>linky target</td> <td> <pre>&lt;div ng-bind-html="snippetWithTarget | linky:'_blank'"&gt;<br>&lt;/div&gt;</pre> </td> <td> <div ng-bind-html="snippetWithTarget | linky:'_blank'"></div> </td> </tr> <tr id="escaped-html"> <td>no filter</td> <td><pre>&lt;div ng-bind="snippet"&gt;<br>&lt;/div&gt;</pre></td> <td><div ng-bind="snippet"></div></td> </tr> </table> </file> <file name="protractor.js" type="protractor"> it('should linkify the snippet with urls', function() { expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()). toBe('Pretty text with some links: http://angularjs.org/, us@somewhere.org, ' + 'another@somewhere.org, and one more: ftp://127.0.0.1/.'); expect(element.all(by.css('#linky-filter a')).count()).toEqual(4); }); it('should not linkify snippet without the linky filter', function() { expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()). toBe('Pretty text with some links: http://angularjs.org/, mailto:us@somewhere.org, ' + 'another@somewhere.org, and one more: ftp://127.0.0.1/.'); expect(element.all(by.css('#escaped-html a')).count()).toEqual(0); }); it('should update', function() { element(by.model('snippet')).clear(); element(by.model('snippet')).sendKeys('new http://link.'); expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()). toBe('new http://link.'); expect(element.all(by.css('#linky-filter a')).count()).toEqual(1); expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()) .toBe('new http://link.'); }); it('should work with the target property', function() { expect(element(by.id('linky-target')). element(by.binding("snippetWithTarget | linky:'_blank'")).getText()). toBe('http://angularjs.org/'); expect(element(by.css('#linky-target a')).getAttribute('target')).toEqual('_blank'); }); </file> </example> */ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) { var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"”’]/, MAILTO_REGEXP = /^mailto:/; return function(text, target) { if (!text) return text; var match; var raw = text; var html = []; var url; var i; while ((match = raw.match(LINKY_URL_REGEXP))) { // We can not end in these as they are sometimes found at the end of the sentence url = match[0]; // if we did not match ftp/http/www/mailto then assume mailto if (!match[2] && !match[4]) { url = (match[3] ? 'http://' : 'mailto:') + url; } i = match.index; addText(raw.substr(0, i)); addLink(url, match[0].replace(MAILTO_REGEXP, '')); raw = raw.substring(i + match[0].length); } addText(raw); return $sanitize(html.join('')); function addText(text) { if (!text) { return; } html.push(sanitizeText(text)); } function addLink(url, text) { html.push('<a '); if (angular.isDefined(target)) { html.push('target="', target, '" '); } html.push('href="', url.replace(/"/g, '&quot;'), '">'); addText(text); html.push('</a>'); } }; }]); })(window, window.angular);
<?php /* * This file is part of PHPUnit. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Filesystem helpers. * * @since Class available since Release 3.0.0 */ class PHPUnit_Util_Filesystem { /** * @var array */ protected static $buffer = []; /** * Maps class names to source file names: * - PEAR CS: Foo_Bar_Baz -> Foo/Bar/Baz.php * - Namespace: Foo\Bar\Baz -> Foo/Bar/Baz.php * * @param string $className * * @return string * * @since Method available since Release 3.4.0 */ public static function classNameToFilename($className) { return str_replace( ['_', '\\'], DIRECTORY_SEPARATOR, $className ) . '.php'; } }
/* ** This program searches an SQLite database file for the lengths and ** offsets for all TEXT or BLOB entries for a particular column of a ** particular table. The rowid, size and offset for the column are ** written to standard output. There are three arguments, which are the ** name of the database file, the table, and the column. */ #include "sqlite3.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> typedef unsigned char u8; typedef struct GState GState; #define ArraySize(X) (sizeof(X)/sizeof(X[0])) /* ** Global state information for this program. */ struct GState { char *zErr; /* Error message text */ FILE *f; /* Open database file */ int szPg; /* Page size for the database file */ int iRoot; /* Root page of the table */ int iCol; /* Column number for the column */ int pgno; /* Current page number */ u8 *aPage; /* Current page content */ u8 *aStack[20]; /* Page stack */ int aPgno[20]; /* Page number stack */ int nStack; /* Depth of stack */ int bTrace; /* True for tracing output */ }; /* ** Write an error. */ static void ofstError(GState *p, const char *zFormat, ...){ va_list ap; sqlite3_free(p->zErr); va_start(ap, zFormat); p->zErr = sqlite3_vmprintf(zFormat, ap); va_end(ap); } /* ** Write a trace message */ static void ofstTrace(GState *p, const char *zFormat, ...){ va_list ap; if( p->bTrace ){ va_start(ap, zFormat); vprintf(zFormat, ap); va_end(ap); } } /* ** Find the root page of the table and the column number of the column. */ static void ofstRootAndColumn( GState *p, /* Global state */ const char *zFile, /* Name of the database file */ const char *zTable, /* Name of the table */ const char *zColumn /* Name of the column */ ){ sqlite3 *db = 0; sqlite3_stmt *pStmt = 0; char *zSql = 0; int rc; if( p->zErr ) return; rc = sqlite3_open(zFile, &db); if( rc ){ ofstError(p, "cannot open database file \"%s\"", zFile); goto rootAndColumn_exit; } zSql = sqlite3_mprintf("SELECT rootpage FROM sqlite_master WHERE name=%Q", zTable); rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); if( rc ) ofstError(p, "%s: [%s]", sqlite3_errmsg(db), zSql); sqlite3_free(zSql); if( p->zErr ) goto rootAndColumn_exit; if( sqlite3_step(pStmt)!=SQLITE_ROW ){ ofstError(p, "cannot find table [%s]\n", zTable); sqlite3_finalize(pStmt); goto rootAndColumn_exit; } p->iRoot = sqlite3_column_int(pStmt , 0); sqlite3_finalize(pStmt); p->iCol = -1; zSql = sqlite3_mprintf("PRAGMA table_info(%Q)", zTable); rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); if( rc ) ofstError(p, "%s: [%s}", sqlite3_errmsg(db), zSql); sqlite3_free(zSql); if( p->zErr ) goto rootAndColumn_exit; while( sqlite3_step(pStmt)==SQLITE_ROW ){ const char *zCol = sqlite3_column_text(pStmt, 1); if( strlen(zCol)==strlen(zColumn) && sqlite3_strnicmp(zCol, zColumn, strlen(zCol))==0 ){ p->iCol = sqlite3_column_int(pStmt, 0); break; } } sqlite3_finalize(pStmt); if( p->iCol<0 ){ ofstError(p, "no such column: %s.%s", zTable, zColumn); goto rootAndColumn_exit; } zSql = sqlite3_mprintf("PRAGMA page_size"); rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); if( rc ) ofstError(p, "%s: [%s]", sqlite3_errmsg(db), zSql); sqlite3_free(zSql); if( p->zErr ) goto rootAndColumn_exit; if( sqlite3_step(pStmt)!=SQLITE_ROW ){ ofstError(p, "cannot find page size"); }else{ p->szPg = sqlite3_column_int(pStmt, 0); } sqlite3_finalize(pStmt); rootAndColumn_exit: sqlite3_close(db); return; } /* ** Pop a page from the stack */ static void ofstPopPage(GState *p){ if( p->nStack<=0 ) return; p->nStack--; sqlite3_free(p->aStack[p->nStack]); p->pgno = p->aPgno[p->nStack-1]; p->aPage = p->aStack[p->nStack-1]; } /* ** Push a new page onto the stack. */ static void ofstPushPage(GState *p, int pgno){ u8 *pPage; size_t got; if( p->zErr ) return; if( p->nStack >= ArraySize(p->aStack) ){ ofstError(p, "page stack overflow"); return; } p->aPgno[p->nStack] = pgno; p->aStack[p->nStack] = pPage = sqlite3_malloc( p->szPg ); if( pPage==0 ){ fprintf(stderr, "out of memory\n"); exit(1); } p->nStack++; p->aPage = pPage; p->pgno = pgno; fseek(p->f, (pgno-1)*p->szPg, SEEK_SET); got = fread(pPage, 1, p->szPg, p->f); if( got!=p->szPg ){ ofstError(p, "unable to read page %d", pgno); ofstPopPage(p); } } /* Read a two-byte integer at the given offset into the current page */ static int ofst2byte(GState *p, int ofst){ int x = p->aPage[ofst]; return (x<<8) + p->aPage[ofst+1]; } /* Read a four-byte integer at the given offset into the current page */ static int ofst4byte(GState *p, int ofst){ int x = p->aPage[ofst]; x = (x<<8) + p->aPage[ofst+1]; x = (x<<8) + p->aPage[ofst+2]; x = (x<<8) + p->aPage[ofst+3]; return x; } /* Read a variable-length integer. Update the offset */ static sqlite3_int64 ofstVarint(GState *p, int *pOfst){ sqlite3_int64 x = 0; u8 *a = &p->aPage[*pOfst]; int n = 0; while( n<8 && (a[0] & 0x80)!=0 ){ x = (x<<7) + (a[0] & 0x7f); n++; a++; } if( n==8 ){ x = (x<<8) + a[0]; }else{ x = (x<<7) + a[0]; } *pOfst += (n+1); return x; } /* Return the absolute offset into a file for the given offset ** into the current page */ static int ofstInFile(GState *p, int ofst){ return p->szPg*(p->pgno-1) + ofst; } /* Return the size (in bytes) of the data corresponding to the ** given serial code */ static int ofstSerialSize(int scode){ if( scode<5 ) return scode; if( scode==5 ) return 6; if( scode<8 ) return 8; if( scode<12 ) return 0; return (scode-12)/2; } /* Forward reference */ static void ofstWalkPage(GState*, int); /* Walk an interior btree page */ static void ofstWalkInteriorPage(GState *p){ int nCell; int i; int ofst; int iChild; nCell = ofst2byte(p, 3); for(i=0; i<nCell; i++){ ofst = ofst2byte(p, 12+i*2); iChild = ofst4byte(p, ofst); ofstWalkPage(p, iChild); if( p->zErr ) return; } ofstWalkPage(p, ofst4byte(p, 8)); } /* Walk a leaf btree page */ static void ofstWalkLeafPage(GState *p){ int nCell; int i; int ofst; int nPayload; sqlite3_int64 rowid; int nHdr; int j; int scode; int sz; int dataOfst; char zMsg[200]; nCell = ofst2byte(p, 3); for(i=0; i<nCell; i++){ ofst = ofst2byte(p, 8+i*2); nPayload = ofstVarint(p, &ofst); rowid = ofstVarint(p, &ofst); if( nPayload > p->szPg-35 ){ sqlite3_snprintf(sizeof(zMsg), zMsg, "# overflow rowid %lld", rowid); printf("%s\n", zMsg); continue; } dataOfst = ofst; nHdr = ofstVarint(p, &ofst); dataOfst += nHdr; for(j=0; j<p->iCol; j++){ scode = ofstVarint(p, &ofst); dataOfst += ofstSerialSize(scode); } scode = ofstVarint(p, &ofst); sz = ofstSerialSize(scode); sqlite3_snprintf(sizeof(zMsg), zMsg, "rowid %12lld size %5d offset %8d", rowid, sz, ofstInFile(p, dataOfst)); printf("%s\n", zMsg); } } /* ** Output results from a single page. */ static void ofstWalkPage(GState *p, int pgno){ if( p->zErr ) return; ofstPushPage(p, pgno); if( p->zErr ) return; if( p->aPage[0]==5 ){ ofstWalkInteriorPage(p); }else if( p->aPage[0]==13 ){ ofstWalkLeafPage(p); }else{ ofstError(p, "page %d has a faulty type byte: %d", pgno, p->aPage[0]); } ofstPopPage(p); } int main(int argc, char **argv){ GState g; memset(&g, 0, sizeof(g)); if( argc>2 && strcmp(argv[1],"--trace")==0 ){ g.bTrace = 1; argc--; argv++; } if( argc!=4 ){ fprintf(stderr, "Usage: %s DATABASE TABLE COLUMN\n", *argv); exit(1); } ofstRootAndColumn(&g, argv[1], argv[2], argv[3]); if( g.zErr ){ fprintf(stderr, "%s\n", g.zErr); exit(1); } ofstTrace(&g, "# szPg = %d\n", g.szPg); ofstTrace(&g, "# iRoot = %d\n", g.iRoot); ofstTrace(&g, "# iCol = %d\n", g.iCol); g.f = fopen(argv[1], "rb"); if( g.f==0 ){ fprintf(stderr, "cannot open \"%s\"\n", argv[1]); exit(1); } ofstWalkPage(&g, g.iRoot); if( g.zErr ){ fprintf(stderr, "%s\n", g.zErr); exit(1); } return 0; }
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\User; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; /** * InMemoryUserProvider is a simple non persistent user provider. * * Useful for testing, demonstration, prototyping, and for simple needs * (a backend with a unique admin for instance) * * @author Fabien Potencier <fabien@symfony.com> */ class InMemoryUserProvider implements UserProviderInterface { private $users; /** * Constructor. * * The user array is a hash where the keys are usernames and the values are * an array of attributes: 'password', 'enabled', and 'roles'. * * @param array $users An array of users */ public function __construct(array $users = array()) { foreach ($users as $username => $attributes) { $password = isset($attributes['password']) ? $attributes['password'] : null; $enabled = isset($attributes['enabled']) ? $attributes['enabled'] : true; $roles = isset($attributes['roles']) ? $attributes['roles'] : array(); $user = new User($username, $password, $roles, $enabled, true, true, true); $this->createUser($user); } } /** * Adds a new User to the provider. * * @param UserInterface $user A UserInterface instance * * @throws \LogicException */ public function createUser(UserInterface $user) { if (isset($this->users[strtolower($user->getUsername())])) { throw new \LogicException('Another user with the same username already exist.'); } $this->users[strtolower($user->getUsername())] = $user; } /** * {@inheritdoc} */ public function loadUserByUsername($username) { if (!isset($this->users[strtolower($username)])) { $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); $ex->setUsername($username); throw $ex; } $user = $this->users[strtolower($username)]; return new User($user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled(), $user->isAccountNonExpired(), $user->isCredentialsNonExpired(), $user->isAccountNonLocked()); } /** * {@inheritDoc} */ public function refreshUser(UserInterface $user) { if (!$user instanceof User) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); } return $this->loadUserByUsername($user->getUsername()); } /** * {@inheritDoc} */ public function supportsClass($class) { return $class === 'Symfony\Component\Security\Core\User\User'; } }
/* * Minimalistic braille device kernel support. * * By default, shows console messages on the braille device. * Pressing Insert switches to VC browsing. * * Copyright (C) Samuel Thibault <samuel.thibault@ens-lyon.org> * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation ; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY ; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the program ; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/autoconf.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/console.h> #include <linux/notifier.h> #include <linux/selection.h> #include <linux/vt_kern.h> #include <linux/consolemap.h> #include <linux/keyboard.h> #include <linux/kbd_kern.h> #include <linux/input.h> MODULE_AUTHOR("samuel.thibault@ens-lyon.org"); MODULE_DESCRIPTION("braille device"); MODULE_LICENSE("GPL"); /* * Braille device support part. */ /* Emit various sounds */ static int sound; module_param(sound, bool, 0); MODULE_PARM_DESC(sound, "emit sounds"); static void beep(unsigned int freq) { if (sound) kd_mksound(freq, HZ/10); } /* mini console */ #define WIDTH 40 #define BRAILLE_KEY KEY_INSERT static u16 console_buf[WIDTH]; static int console_cursor; /* mini view of VC */ static int vc_x, vc_y, lastvc_x, lastvc_y; /* show console ? (or show VC) */ static int console_show = 1; /* pending newline ? */ static int console_newline = 1; static int lastVC = -1; static struct console *braille_co; /* Very VisioBraille-specific */ static void braille_write(u16 *buf) { static u16 lastwrite[WIDTH]; unsigned char data[1 + 1 + 2*WIDTH + 2 + 1], csum = 0, *c; u16 out; int i; if (!braille_co) return; if (!memcmp(lastwrite, buf, WIDTH * sizeof(*buf))) return; memcpy(lastwrite, buf, WIDTH * sizeof(*buf)); #define SOH 1 #define STX 2 #define ETX 2 #define EOT 4 #define ENQ 5 data[0] = STX; data[1] = '>'; csum ^= '>'; c = &data[2]; for (i = 0; i < WIDTH; i++) { out = buf[i]; if (out >= 0x100) out = '?'; else if (out == 0x00) out = ' '; csum ^= out; if (out <= 0x05) { *c++ = SOH; out |= 0x40; } *c++ = out; } if (csum <= 0x05) { *c++ = SOH; csum |= 0x40; } *c++ = csum; *c++ = ETX; braille_co->write(braille_co, data, c - data); } /* Follow the VC cursor*/ static void vc_follow_cursor(struct vc_data *vc) { vc_x = vc->vc_x - (vc->vc_x % WIDTH); vc_y = vc->vc_y; lastvc_x = vc->vc_x; lastvc_y = vc->vc_y; } /* Maybe the VC cursor moved, if so follow it */ static void vc_maybe_cursor_moved(struct vc_data *vc) { if (vc->vc_x != lastvc_x || vc->vc_y != lastvc_y) vc_follow_cursor(vc); } /* Show portion of VC at vc_x, vc_y */ static void vc_refresh(struct vc_data *vc) { u16 buf[WIDTH]; int i; for (i = 0; i < WIDTH; i++) { u16 glyph = screen_glyph(vc, 2 * (vc_x + i) + vc_y * vc->vc_size_row); buf[i] = inverse_translate(vc, glyph, 1); } braille_write(buf); } /* * Link to keyboard */ static int keyboard_notifier_call(struct notifier_block *blk, unsigned long code, void *_param) { struct keyboard_notifier_param *param = _param; struct vc_data *vc = param->vc; int ret = NOTIFY_OK; if (!param->down) return ret; switch (code) { case KBD_KEYCODE: if (console_show) { if (param->value == BRAILLE_KEY) { console_show = 0; beep(880); vc_maybe_cursor_moved(vc); vc_refresh(vc); ret = NOTIFY_STOP; } } else { ret = NOTIFY_STOP; switch (param->value) { case KEY_INSERT: beep(440); console_show = 1; lastVC = -1; braille_write(console_buf); break; case KEY_LEFT: if (vc_x > 0) { vc_x -= WIDTH; if (vc_x < 0) vc_x = 0; } else if (vc_y >= 1) { beep(880); vc_y--; vc_x = vc->vc_cols-WIDTH; } else beep(220); break; case KEY_RIGHT: if (vc_x + WIDTH < vc->vc_cols) { vc_x += WIDTH; } else if (vc_y + 1 < vc->vc_rows) { beep(880); vc_y++; vc_x = 0; } else beep(220); break; case KEY_DOWN: if (vc_y + 1 < vc->vc_rows) vc_y++; else beep(220); break; case KEY_UP: if (vc_y >= 1) vc_y--; else beep(220); break; case KEY_HOME: vc_follow_cursor(vc); break; case KEY_PAGEUP: vc_x = 0; vc_y = 0; break; case KEY_PAGEDOWN: vc_x = 0; vc_y = vc->vc_rows-1; break; default: ret = NOTIFY_OK; break; } if (ret == NOTIFY_STOP) vc_refresh(vc); } break; case KBD_POST_KEYSYM: { unsigned char type = KTYP(param->value) - 0xf0; if (type == KT_SPEC) { unsigned char val = KVAL(param->value); int on_off = -1; switch (val) { case KVAL(K_CAPS): on_off = vc_kbd_led(kbd_table + fg_console, VC_CAPSLOCK); break; case KVAL(K_NUM): on_off = vc_kbd_led(kbd_table + fg_console, VC_NUMLOCK); break; case KVAL(K_HOLD): on_off = vc_kbd_led(kbd_table + fg_console, VC_SCROLLOCK); break; } if (on_off == 1) beep(880); else if (on_off == 0) beep(440); } } case KBD_UNBOUND_KEYCODE: case KBD_UNICODE: case KBD_KEYSYM: /* Unused */ break; } return ret; } static struct notifier_block keyboard_notifier_block = { .notifier_call = keyboard_notifier_call, }; static int vt_notifier_call(struct notifier_block *blk, unsigned long code, void *_param) { struct vt_notifier_param *param = _param; struct vc_data *vc = param->vc; switch (code) { case VT_ALLOCATE: break; case VT_DEALLOCATE: break; case VT_WRITE: { unsigned char c = param->c; if (vc->vc_num != fg_console) break; switch (c) { case '\b': case 127: if (console_cursor > 0) { console_cursor--; console_buf[console_cursor] = ' '; } break; case '\n': case '\v': case '\f': case '\r': console_newline = 1; break; case '\t': c = ' '; /* Fallthrough */ default: if (c < 32) /* Ignore other control sequences */ break; if (console_newline) { memset(console_buf, 0, sizeof(console_buf)); console_cursor = 0; console_newline = 0; } if (console_cursor == WIDTH) memmove(console_buf, &console_buf[1], (WIDTH-1) * sizeof(*console_buf)); else console_cursor++; console_buf[console_cursor-1] = c; break; } if (console_show) braille_write(console_buf); else { vc_maybe_cursor_moved(vc); vc_refresh(vc); } break; } case VT_UPDATE: /* Maybe a VT switch, flush */ if (console_show) { if (vc->vc_num != lastVC) { lastVC = vc->vc_num; memset(console_buf, 0, sizeof(console_buf)); console_cursor = 0; braille_write(console_buf); } } else { vc_maybe_cursor_moved(vc); vc_refresh(vc); } break; } return NOTIFY_OK; } static struct notifier_block vt_notifier_block = { .notifier_call = vt_notifier_call, }; /* * Called from printk.c when console=brl is given */ int braille_register_console(struct console *console, int index, char *console_options, char *braille_options) { int ret; if (!console_options) /* Only support VisioBraille for now */ console_options = "57600o8"; if (braille_co) return -ENODEV; if (console->setup) { ret = console->setup(console, console_options); if (ret != 0) return ret; } console->flags |= CON_ENABLED; console->index = index; braille_co = console; register_keyboard_notifier(&keyboard_notifier_block); register_vt_notifier(&vt_notifier_block); return 0; } int braille_unregister_console(struct console *console) { if (braille_co != console) return -EINVAL; unregister_keyboard_notifier(&keyboard_notifier_block); unregister_vt_notifier(&vt_notifier_block); braille_co = NULL; return 0; }
module.exports = collect function collect (stream) { if (stream._collected) return stream._collected = true stream.pause() stream.on("data", save) stream.on("end", save) var buf = [] function save (b) { if (typeof b === "string") b = new Buffer(b) if (Buffer.isBuffer(b) && !b.length) return buf.push(b) } stream.on("entry", saveEntry) var entryBuffer = [] function saveEntry (e) { collect(e) entryBuffer.push(e) } stream.on("proxy", proxyPause) function proxyPause (p) { p.pause() } // replace the pipe method with a new version that will // unlock the buffered stuff. if you just call .pipe() // without a destination, then it'll re-play the events. stream.pipe = (function (orig) { return function (dest) { // console.error(" === open the pipes", dest && dest.path) // let the entries flow through one at a time. // Once they're all done, then we can resume completely. var e = 0 ;(function unblockEntry () { var entry = entryBuffer[e++] // console.error(" ==== unblock entry", entry && entry.path) if (!entry) return resume() entry.on("end", unblockEntry) if (dest) dest.add(entry) else stream.emit("entry", entry) })() function resume () { stream.removeListener("entry", saveEntry) stream.removeListener("data", save) stream.removeListener("end", save) stream.pipe = orig if (dest) stream.pipe(dest) buf.forEach(function (b) { if (b) stream.emit("data", b) else stream.emit("end") }) stream.resume() } return dest }})(stream.pipe) }
<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Mvc\Controller\Plugin; use Zend\Mvc\Exception\RuntimeException; use Zend\Session\Container; /** * Plugin to help facilitate Post/Redirect/Get (http://en.wikipedia.org/wiki/Post/Redirect/Get) */ class PostRedirectGet extends AbstractPlugin { /** * @var Container */ protected $sessionContainer; /** * Perform PRG logic * * If a null value is present for the $redirect, the current route is * retrieved and use to generate the URL for redirect. * * If the request method is POST, creates a session container set to expire * after 1 hop containing the values of the POST. It then redirects to the * specified URL using a status 303. * * If the request method is GET, checks to see if we have values in the * session container, and, if so, returns them; otherwise, it returns a * boolean false. * * @param null|string $redirect * @param bool $redirectToUrl * @return \Zend\Http\Response|array|\Traversable|false */ public function __invoke($redirect = null, $redirectToUrl = false) { $controller = $this->getController(); $request = $controller->getRequest(); $container = $this->getSessionContainer(); if ($request->isPost()) { $container->setExpirationHops(1, 'post'); $container->post = $request->getPost()->toArray(); return $this->redirect($redirect, $redirectToUrl); } else { if ($container->post !== null) { $post = $container->post; unset($container->post); return $post; } return false; } } /** * @return Container */ public function getSessionContainer() { if (!isset($this->sessionContainer)) { $this->sessionContainer = new Container('prg_post1'); } return $this->sessionContainer; } /** * @param Container $container * @return PostRedirectGet */ public function setSessionContainer(Container $container) { $this->sessionContainer = $container; return $this; } /** * TODO: Good candidate for traits method in PHP 5.4 with FilePostRedirectGet plugin * * @param string $redirect * @param bool $redirectToUrl * @return \Zend\Http\Response * @throws \Zend\Mvc\Exception\RuntimeException */ protected function redirect($redirect, $redirectToUrl) { $controller = $this->getController(); $params = array(); $options = array('query' => $controller->params()->fromQuery()); $reuseMatchedParams = false; if (null === $redirect) { $routeMatch = $controller->getEvent()->getRouteMatch(); $redirect = $routeMatch->getMatchedRouteName(); //null indicates to redirect for self. $reuseMatchedParams = true; } if (method_exists($controller, 'getPluginManager')) { // get the redirect plugin from the plugin manager $redirector = $controller->getPluginManager()->get('Redirect'); } else { /* * If the user wants to redirect to a route, the redirector has to come * from the plugin manager -- otherwise no router will be injected */ if ($redirectToUrl === false) { throw new RuntimeException('Could not redirect to a route without a router'); } $redirector = new Redirect(); } if ($redirectToUrl === false) { $response = $redirector->toRoute($redirect, $params, $options, $reuseMatchedParams); $response->setStatusCode(303); return $response; } $response = $redirector->toUrl($redirect); $response->setStatusCode(303); return $response; } }
/* * Copyright (C) 2003 Jana Saout <jana@saout.de> * * This file is released under the GPL. */ #include <linux/device-mapper.h> #include <linux/module.h> #include <linux/init.h> #include <linux/bio.h> #define DM_MSG_PREFIX "zero" /* * Construct a dummy mapping that only returns zeros */ static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv) { if (argc != 0) { ti->error = "No arguments required"; return -EINVAL; } /* * Silently drop discards, avoiding -EOPNOTSUPP. */ ti->num_discard_bios = 1; return 0; } /* * Return zeros only on reads */ static int zero_map(struct dm_target *ti, struct bio *bio) { switch(bio_rw(bio)) { case READ: zero_fill_bio(bio); break; case READA: /* readahead of null bytes only wastes buffer cache */ return -EIO; case WRITE: /* writes get silently dropped */ break; } bio_endio(bio); /* accepted bio, don't make new request */ return DM_MAPIO_SUBMITTED; } static struct target_type zero_target = { .name = "zero", .version = {1, 1, 0}, .module = THIS_MODULE, .ctr = zero_ctr, .map = zero_map, }; static int __init dm_zero_init(void) { int r = dm_register_target(&zero_target); if (r < 0) DMERR("register failed %d", r); return r; } static void __exit dm_zero_exit(void) { dm_unregister_target(&zero_target); } module_init(dm_zero_init) module_exit(dm_zero_exit) MODULE_AUTHOR("Jana Saout <jana@saout.de>"); MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros"); MODULE_LICENSE("GPL");
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\User; use Symfony\Component\Security\Core\Exception\AccountStatusException; use Symfony\Component\Security\Core\Exception\AccountExpiredException; use Symfony\Component\Security\Core\Exception\LockedException; use Symfony\Component\Security\Core\Exception\CredentialsExpiredException; use Symfony\Component\Security\Core\Exception\DisabledException; /** * Adds extra features to a user class related to account status flags. * * This interface can be implemented in place of UserInterface if you'd like * the authentication system to consider different account status flags * during authentication. If any of the methods in this interface return * false, authentication will fail. * * If you need to perform custom logic for any of these situations, then * you will need to register an exception listener and watch for the specific * exception instances thrown in each case. All exceptions are a subclass * of AccountStatusException * * @see UserInterface * @see AccountStatusException * * @author Fabien Potencier <fabien@symfony.com> */ interface AdvancedUserInterface extends UserInterface { /** * Checks whether the user's account has expired. * * Internally, if this method returns false, the authentication system * will throw an AccountExpiredException and prevent login. * * @return Boolean true if the user's account is non expired, false otherwise * * @see AccountExpiredException */ public function isAccountNonExpired(); /** * Checks whether the user is locked. * * Internally, if this method returns false, the authentication system * will throw a LockedException and prevent login. * * @return Boolean true if the user is not locked, false otherwise * * @see LockedException */ public function isAccountNonLocked(); /** * Checks whether the user's credentials (password) has expired. * * Internally, if this method returns false, the authentication system * will throw a CredentialsExpiredException and prevent login. * * @return Boolean true if the user's credentials are non expired, false otherwise * * @see CredentialsExpiredException */ public function isCredentialsNonExpired(); /** * Checks whether the user is enabled. * * Internally, if this method returns false, the authentication system * will throw a DisabledException and prevent login. * * @return Boolean true if the user is enabled, false otherwise * * @see DisabledException */ public function isEnabled(); }
/***************************************************************************/ /* */ /* cffpic.c */ /* */ /* The FreeType position independent code services for cff module. */ /* */ /* Copyright 2009 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "cffpic.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from cffdrivr.c */ FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**); void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*); void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*); void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*); void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*); void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*); void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*); /* forward declaration of PIC init functions from cffparse.c */ FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**); void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*); /* forward declaration of PIC init functions from cffcmap.c */ void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*); void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*); void cff_driver_class_pic_free( FT_Library library ) { FT_PIC_Container* pic_container = &library->pic_container; FT_Memory memory = library->memory; if ( pic_container->cff ) { CffModulePIC* container = (CffModulePIC*)pic_container->cff; if(container->cff_services) FT_Destroy_Class_cff_services(library, container->cff_services); container->cff_services = NULL; if(container->cff_field_handlers) FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers); container->cff_field_handlers = NULL; FT_FREE( container ); pic_container->cff = NULL; } } FT_Error cff_driver_class_pic_init( FT_Library library ) { FT_PIC_Container* pic_container = &library->pic_container; FT_Error error = FT_Err_Ok; CffModulePIC* container; FT_Memory memory = library->memory; /* allocate pointer, clear and set global container pointer */ if ( FT_ALLOC ( container, sizeof ( *container ) ) ) return error; FT_MEM_SET( container, 0, sizeof(*container) ); pic_container->cff = container; /* initialize pointer table - this is how the module usually expects this data */ error = FT_Create_Class_cff_services(library, &container->cff_services); if(error) goto Exit; error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers); if(error) goto Exit; FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info); FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict); FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name); FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info); FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info); FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec); FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec); Exit: if(error) cff_driver_class_pic_free(library); return error; } #endif /* FT_CONFIG_OPTION_PIC */ /* END */
/// <reference path="../../yui/yui.d.ts" /> /// <reference path="../cryptojs.d.ts" /> YUI.add('enc-latin1-test', function (Y) { var C = CryptoJS; Y.Test.Runner.add(new Y.Test.Case({ name: 'Latin1', testStringify: function () { Y.Assert.areEqual('\x12\x34\x56\x78', C.enc.Latin1.stringify(C.lib.WordArray.create([0x12345678]))); }, testParse: function () { Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Latin1.parse('\x12\x34\x56\x78').toString()); } })); }, '$Rev$');